| Server IP : 162.214.74.102 / Your IP : 216.73.216.59 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/www/lrsys_apps/dialogo/application/plugins/module_pcp/models/ |
Upload File : |
<?php
/**
*
*/
class ProductionPlan extends Model
{
/**
* To override the default naming behaviour and directly specify a table name
*
* @var string
*/
public static $_table = 'module_pcp_production_plan';
public static function calcDuration($id)
{
$list_steps = Model::factory('ProductionSteps')->where('product_id', $id)->order_by_asc('order')->findArray();
$time = 0;
foreach ($list_steps as $key => $value) {
$time = $time + (int)$value['duration_time'];
}
return $time;
}
public static function calcCosts($id)
{
global $_c;
$p = new Pcp($id);
return $p->getStepsCosts();
}
public function saveOrUpdate($params = null)
{
try {
// Start a transaction
ORM::get_db()->beginTransaction();
if($this->id) {
$this->name = $params['name'];
$this->product_id = $params['product_id'];
$this->production_qtd = $params['production_qtd'];
$this->obs = $params['obs'];
$this->save();
} else {
$this->created_at = ib_today();
$this->save();
}
// Commit a transaction
ORM::get_db()->commit();
return true;
} catch (Exception $e) {
// Roll back a transaction
// Roll back a transaction
die($e->getMessage());
ORM::get_db()->rollBack();
return false;
}
}
}