AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.217.80
Web Server : Apache
System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : lrsys ( 1015)
PHP Version : 5.6.40
Disable Function : exec,passthru,shell_exec,system
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/lrsys/public_html/lrsys_apps/regional/application/plugins/module_pcp/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/public_html/lrsys_apps/regional/application/plugins/module_pcp/models/Equipament.php
<?php

Class Equipament extends Model {

  public static $_table = 'module_pcp_equipaments';


  /**
   * Function to add a new equipament to list of equipaments.
   * @param array var Description
   */
  public function save() {

    $ids_employees = isset($_POST['employees']) ? $_POST['employees'] : array();

    try {
      // Start a transaction
      ORM::get_db()->beginTransaction();

      //store equipament to equipament table to get a unique id.
      parent::save();


      if(count($ids_employees) > 0) {

        //remove old employees and add the news ones.
        $this->employees()->find_many()->delete();

        //get ids employees(operators) involved with this equipment;
        foreach ($ids_employees as $id) {
          $employee = $this->employees()->create();
          $employee->id_equipament = $this->id;
          $employee->id_account = $id;
          $employee->save();
        }
      }


      // Commit a transaction
      ORM::get_db()->commit();
      return true;

    } catch (Exception $e) {
      // Roll back a transaction
      die($e->getMessage());
      ORM::get_db()->rollBack();
      return false;
    }


  }


  /**
   * Equipament has many maintenances. Associate to Maintenance Class;
   */
  public function maintenances() {
        return $this->has_many('Maintenance', 'id_equipament', 'id');
  }

  /**
   * Equipament has many employees. Associate to Employee Class;
   */
  public function employees(){
    return $this->has_many('Employee', 'id_equipament', 'id');
  }

  /**
   * Equipament has one Unit. Associate to Unit Class;
   */
  public function unit() {
    return $this->has_one('Unit', 'id_equipament', 'id');
  }
  

  /**
   * This function set a situation of equipament.
   *
   * eg. 0: bloked, 1: available, 2: working, 3: stoped, 4: maintenance
   *
   * @param INT $situation_code  Description: 0: bloked, 1: available, 2: working, 3: stoped, 4: maintenance
   * @return {void}
   */
  public function changeSituation( $situation_code )
  {
    $this->situation = $situation_code;
  }

  /**
   * This static function return a label situation of equipament.
   *
   * eg. 0: bloked, 1: available, 2: working, 3: stoped, 4: maintenance
   *
   * @param INT $situation_code  Description: 0: bloked, 1: available, 2: working, 3: stoped, 4: maintenance
   * @return {void}
   */
  public static function getLabelSituation($situation_code)
  {
    global $_L;
    $situation = '';
    switch ($situation_code) {
      case '0':
        $situation = $_L['Pcp_Equip label_situation_bloked'];
        $clabel = 'danger';
        break;
      case '1':
        $situation = $_L['Pcp_Equip label_situation_available'];
        $clabel = 'success';
        break;
      case '2':
        $situation = $_L['Pcp_Equip label_situation_working'];
        $clabel = 'primary';
        break;
      case '3':
        $situation = $_L['Pcp_Equip label_situation_stoped'];
        $clabel = 'danger';
        break;
      case '4':
        $situation = $_L['Pcp_Equip label_situation_maintenance'];
        $clabel = 'warning';
        break;

      default:
      $situation = "undefined";  //:)
        break;
    }

    $label = '<span class="label label-'.$clabel.'"> '.$situation.' </span>';

    return $label;

  }

  public static function getSumary()
  {
    $sumary = array();
    $sumary['total_price'] = 0;
    $sumary['qtd_maintenace'] = 0;
    $sumary['qtd_available'] = 0;
    $sumary['qtd_working'] = 0;
    $sumary['qtd_stoped'] = 0;

    $equips = Model::factory('Equipament')->findArray();

    $sumary['total_equip'] = count($equips);

    foreach ($equips as $equip) {

      $sumary['total_price'] += $equip['purchase_price'];

      if($equip['situation'] == 1)
        $sumary['qtd_available']++;

      if($equip['situation'] == 4)
        $sumary['qtd_maintenace']++;

      if($equip['situation'] == 2)
        $sumary['qtd_working']++;

      if($equip['situation'] == 3)
        $sumary['qtd_stoped']++;
    }

    return $sumary;

  }


}

Anon7 - 2022
AnonSec Team