AnonSec Shell
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/leve/application/plugins/module_helpdesk/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/leve/application/plugins/module_helpdesk/controllers/AjaxController.php
<?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 ping() {
        echo 1;
        exit();
    }

    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);
        }
        if (!empty(_post('cost_center'))) {
            $d->where_in("c.cost_center_id", explode(",", _post('cost_center')));
        }

        $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' => (@$type == 'customer' ? $c->company : $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);
    }

    // Funcionção para pegar as categorias de produtos
    public function categoryProductAjax() {
        $all = ProductCategory::all();
        $data = array();
        foreach ($all as $s) {

            // PACTH HEXAGON
            // Pega apenas as categorias o Pai "FORM"
            if (!$s['parent']) {
                continue;
            }
            $data[] = array(
                'id' => $s['id'],
                'name' => $s['name'], //verifica se são os dados pre cadastrados que são traduzidos
                'parent' => $s['parent'],
                'name_parent' => $s['name_parent']
            );
        }
        echo json_encode($data);
    }

    public function selectForm() {
        $form_id = $this->routes[4];
        $ticket_id = _post('ticket_id');
        $ticket = ORM::for_table('module_helpdesk_tickets')->find_one($this->routes[3]);

        if (!$ticket) {
            die($this->_L['Not_Found']);
        }
        if ($ticket->deleted_at != null) {
            die($this->_L['Not_Found']);
        }

        $ticket->form_id = $form_id;
        $ticket->status = 'Atendence';
        $ticket->begin_at = date('Y-m-d H:i:s');

        $ticket->save();

        $data = array(
            'status' => 'OK'
        );
        echo json_encode($data);
    }

    public function accept() {
//        $ticket_id = _post('ticket_id');

        $ticket = ORM::for_table('module_helpdesk_tickets')->find_one($this->routes[3]);

        if (!$ticket) {
            die($this->_L['Not_Found']);
        }
        if ($ticket->deleted_at != null) {
            die($this->_L['Not_Found']);
        }
        $form_id = _post('form_id');
        if (!empty($form_id)) {
            $ticket->form_id = $form_id;
        }
        $ticket->status = 'Atendence';
        $user = User::_info();
        if (!empty($user->crm_accounts_id)) {
            $ticket->responsible_id = $user->crm_accounts_id;
        }
        $ticket->updated_at = date('Y-m-d H:i:s');
        $ticket->begin_at = date('Y-m-d H:i:s');

        $ticket->save();

        $data = array(
            'status' => 'OK'
        );
        _notify($this->_L['Register Successfull'], 's');
        echo json_encode($data);
    }

    // Função para associar um provedor a um cliente
    public function selectProvider() {
        $client_id = isset($this->routes[3]) ? $this->routes[3] : "";

        // if(empty(intval($client_id))){
        //     $sql = "SELECT c.* FROM crm_accounts as c
        //     JOIN crm_accounts_groups as ccg ON ccg.crm_accounts_id = c.id
        //     WHERE ccg.crm_group_id = 6";
        // } else {
        //     $sql = "SELECT c.* FROM crm_accounts as c
        //     JOIN crm_accounts_contacts as cc ON cc.crm_accounts_id_contact = c.id AND cc.crm_accounts_id = ".$client_id."
        //     JOIN crm_accounts_groups as ccg ON ccg.crm_accounts_id = c.id
        //     WHERE ccg.crm_group_id = 6";
        // }

        // TODO: VERIFICAR SE É NECESSÁRIO FILTRAR PELOS PROVEDORES QUE ESTÃO ASSOCIADOS AO CLIENTE
        $sql = "SELECT c.* FROM crm_accounts as c
                JOIN crm_accounts_groups as ccg ON ccg.crm_accounts_id = c.id
                WHERE ccg.crm_group_id = 6";

        $term = _post('term');
        $sql .= " AND c.account LIKE '%".$term."%'";
        $d = ORM::for_table('crm_accounts')->raw_query($sql)->find_many();
        $crms = $d;
        // var_dump($d);exit; 
        $data = array();
        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 selectProducer() {
        $provider_id = isset($this->routes[3]) ? $this->routes[3] : "";
        if(empty($provider_id)){
            return false;
        } 
            
        $sql = "SELECT 
                    c.*
                FROM
                    crm_accounts_contacts AS cc
                        JOIN
                    crm_accounts AS c ON cc.crm_accounts_id = c.id
                WHERE
                    cc.crm_accounts_id_contact = ".$provider_id;

        $d = ORM::for_table('crm_accounts')->raw_query($sql)->find_many();
        $crms = $d;
        $data = array();
        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);
    }

}

Anon7 - 2022
AnonSec Team