| Server IP : 162.214.74.102 / Your IP : 216.73.217.114 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/erp/application/plugins/module_helpdesk/factories/ |
Upload File : |
<?php
include_once "Factory.php";
class TicketFactory extends Factory {
public static function create($data, $ticket, $create = false) {
static::populate($data, $ticket, 'client_id');
static::populate($data, $ticket, 'requester_id');
static::populate($data, $ticket, 'module_helpdesk_tickets_priority_id');
static::populate($data, $ticket, 'module_helpdesk_tickets_cat_id');
static::populate($data, $ticket, 'module_helpdesk_tickets_treatment_type_id');
$ticket->treatment_type_local = $data['module_helpdesk_tickets_treatment_type_id']==2?$data['treatment_type_local']:'';
// static::populate($data, $ticket, 'product_cat_id');
static::populate($data, $ticket, 'description');
$ticket->responsible_id = empty($data['responsible_id']) ? 0 : $data['responsible_id'];
$ticket->status = empty($data['status']) ? 'Open' : $data['status'];
if ($create) {
$ticket->created_at = date('Y-m-d H:i:s');
$user = User::_info();
$ticket->requester_id = $user->id;
}
//sem responsável, o sistema localiza o com menos tickets
if ($ticket->responsible_id == 0) {
$d = ORM::for_table('crm_accounts')
->table_alias('c')
->select('c.id')
->select_expr("(select count(sub_t.id) from module_helpdesk_tickets sub_t where sub_t.responsible_id= c.id and status in ('Open','Atendence') " . ($ticket->id > 0 ? " and sub_t.id<>" . $ticket->id : "") . ") as number_tickets");
$d->join('crm_accounts_groups', array('c.id', '=', 'ag.crm_accounts_id'), 'ag')
->join('crm_groups', array('g.id', '=', 'ag.crm_group_id'), 'g')
->where('g.id', 5) //employee;
->order_by_expr('number_tickets ASC')
->limit(1);
$resp = $d->find_array();
if (count($resp) > 0) {
$ticket->responsible_id = $resp[0]['id'];
}
}
return $ticket;
}
}