| 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/controllers/ |
Upload File : |
<?php
include_once "Controller.php";
class AjaxController extends Controller {
/**
* @param $ui
* @param array $_L
* @param array $config
* @param $_pd
*/
public function __construct($ui, $_L, $config, $_pd) {
parent::__construct($ui, $_L, $config, $_pd);
}
public function crm_accounts() {
$type = isset($this->routes[3]) ? $this->routes[3] : "";
$d = ORM::for_table('crm_accounts')
->table_alias('c')
->select('c.*');
$term = _post('term');
if (!empty($type)) {
$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.gname', $type)
->where('g.default', 1);
}
$d->where_any_is(array(array("c.account" => '%' . $term . '%')
), 'like');
$crms = $d->find_many();
$data = array();
if(isset($this->routes[4]) && $this->routes[4]=='select'){
$data[] = array(
'id' => 0,
'name' => '',
'text' => $this->_L['module_helpdesk select'],
'cpf_cnpj' => '',
'account' => '',
'company' => '',
'kinf_of_person' => '',
'foreign_doc_identification' => '',
);
}
foreach ($crms as $c) {
$data[] = array(
'id' => $c->id,
'name' => $c->account,
'text' => $c->account,
'cpf_cnpj' => $c->cpf_cnpj,
'account' => $c->account,
'company' => $c->company,
'kinf_of_person' => $c->kind_of_person,
'foreign_doc_identification' => $c->foreign_doc_identification,
);
}
echo json_encode($data);
}
public function priority() {
$term = _post('term');
$specie = ORM::for_table('module_helpdesk_tickets_priority')
->table_alias('s');
$specie->where_any_is(array(array("s.name" => '%' . $term . '%')
), 'like');
$especies = $specie->find_many();
$data = array();
foreach ($especies as $p) {
$data[] = array(
'id' => $p->id,
'text' =>$p->default?$this->_L[$p->name]: $p->name
);
}
echo json_encode($data);
}
public function category() {
$term = _post('term');
$specie = ORM::for_table('module_helpdesk_tickets_cat')
->table_alias('s');
$specie->where_any_is(array(array("s.description" => '%' . $term . '%'), array("s.title" => '%' . $term . '%')
), 'like');
$especies = $specie->find_many();
$data = array();
foreach ($especies as $p) {
$data[] = array(
'id' => $p->id,
'text' => $p->title
);
}
echo json_encode($data);
}
public function type() {
$term = _post('term');
$specie = ORM::for_table('module_helpdesk_tickets_treatment_type')
->table_alias('s');
$specie->where_any_is(array(array("s.name" => '%' . $term . '%')
), 'like');
// $specie ->select(array('s.popular_name', 's.id','s.scientific_name'))
$especies = $specie->find_many();
$data = array();
foreach ($especies as $p) {
$data[] = array(
'id' => $p->id,
'text' =>$p->default?$this->_L[$p->name]: $p->name
);
}
echo json_encode($data);
}
//listagem de program Associated
public function product($hideWithoutCategory = true) {
$term = _post('term');
$data = array();
$category = _post('category');
if(!empty($category) && $hideWithoutCategory) {
$d = ORM::for_table('sys_items')
->table_alias('i')
->select('i.*')
->left_outer_join('sys_items_category', array('is.id', '=', 'i.category_id'), 'is')
->order_by_asc('i.description');
if (!empty($category)) {
$d->where('is.id', $category);
}
$d->where_any_is(array(array("i.description" => '%' . $term . '%'),
array("i.id" => '%' . $term . '%')
), 'like');
$prods = $d->find_many();
foreach ($prods as $p) {
$data[] = array(
'id' => $p->id,
'text' => "(" . $p->id . ") " . $p->description
);
}
}
echo json_encode($data);
}
public function categoryProduct() {
$term = _post('term');
$d = ORM::for_table('sys_items_category')
->table_alias('i')
->select('i.*')
->order_by_asc('i.name');
if (!empty($category)) {
$d->where('s.id', $category);
}
$d->where_any_is(array(array("i.name" => '%' . $term . '%'),
array("i.id" => '%' . $term . '%')
), 'like');
$prods = $d->find_many();
$data = array();
foreach ($prods as $p) {
$data[] = array(
'id' => $p->id,
'text' => $p->name
);
}
echo json_encode($data);
}
}