| 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/imobles/application/plugins/module_helpdesk/models/ |
Upload File : |
<?php
include_once __DIR__ . "/../../../autoload/My_Model.php";
include_once __DIR__ . "/../factories/SlaFactory.php";
class SlaModel extends My_Model {
/**
* @var string
*/
public $table = 'module_helpdesk_sla';
public function createSla($data) {
$sla = self::create();
SlaFactory::create($data, $sla, true);
$sla->save();
$this->saveUpdateProducts($sla, $data);
return $sla;
}
private function saveUpdateProducts($sla, $data) {
ORM::for_table('module_helpdesk_sla_products')->where('module_helpdesk_sla_id', $sla->id)->delete_many();
if (!empty($data['product_id'])) {
foreach ($data['product_id'] as $p) {
if (intval($p) > 0) {
$d = ORM::for_table('module_helpdesk_sla_products')->create();
$d->product_cat_id = $data['product_cat_id'];
$d->product_id = intval($p);
$d->module_helpdesk_sla_id = $sla->id;
$d->save();
}
}
}
}
public function getProducts($sla) {
return ORM::for_table('module_helpdesk_sla_products')
->table_alias('tp')
->select('s.*')
->select('tp.product_cat_id')
->join('sys_items', array('s.id', '=', 'tp.product_id'), 's')
->where('tp.module_helpdesk_sla_id', $sla->id)->find_many();
}
public function updateSla($data, $sla) {
ORM::for_table($this->table)->create($sla);
SlaFactory::create($data, $sla);
$sla->save();
$this->saveUpdateProducts($sla, $data);
return $sla;
}
public function deleteSla($sla) {
ORM::for_table('module_helpdesk_sla_products')->where('module_helpdesk_sla_id', $sla->id)->delete_many();
ORM::for_table($this->table)->create($sla);
$sla->deleted_at = date('Y-m-d H:i:s');
$sla->save();
return $sla;
}
}