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/SlaController.php
<?php

include_once "Controller.php";
include_once __DIR__ . "/../models/SlaModel.php";
include_once __DIR__ . "/../assets/libs/Helper.php";
include_once __DIR__ . "/../assets/libs/StatusOS.php";

class SlaController extends Controller {

    protected $id;
    protected $model;
    protected $client_id;
    
    /** @var Helper $helper */
    protected $helper;

    /** @var StatusOS $statusHelper */
    protected $statusHelper;

    public function __construct($ui, $_L, $config, $_pd, $client_id = null) {
        parent::__construct($ui, $_L, $config, $_pd, $client_id);
        
        $this->helper = new Helper($_L);
        $this->statusHelper = new StatusOS($_L);

        $this->ui->assign('_title', $this->_L['module_helpdesk sla'] . ' - ' . $this->config['CompanyName']);
        $this->ui->assign('_st', $_L['module_helpdesk']);
        $this->ui->assign('helper', $this->helper);

        $this->model = new SlaModel();

        $this->id = $this->routes[3];
        $this->client_id = $client_id;
        if($this->isAdminOrManager === false){
            echo $this->_L['Not Permited'];
            exit;
        }
    }

    public function listAll() {

        $filter = array();
        $filter['items_per_page'] = 10;

        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $_SESSION['filter_helpdesk_responsible_id'] = isset($_POST['responsible_id']) ? $_POST['responsible_id'] : '';
            $_SESSION['filter_helpdesk_status'] = _post('status');
            $_SESSION['filter_helpdesk_client_id'] = isset($_POST['client_id']) ? $_POST['client_id'] : '';

            $_SESSION['filter_helpdesk_search'] = _post('search');
            $_SESSION['filter_helpdesk_period'] = _post('period');
            if ($_SESSION['filter_helpdesk_period'] == 'interval') {
                $_SESSION['filter_helpdesk_period_ini'] = _postDate('period_ini');
                $_SESSION['filter_helpdesk_period_end'] = _postDate('period_end');
            } else {
                $_SESSION['filter_helpdesk_period_ini'] = '';
                $_SESSION['filter_helpdesk_period_end'] = '';
            }
            $filter['items_per_page'] = filter_var(_post('items_per_page'), FILTER_SANITIZE_STRING);
        } else {
            if ($i = array_search('items_per_page', $this->routes))
                $filter['items_per_page'] = filter_var($this->routes[$i + 1], FILTER_SANITIZE_STRING);
        }


        if (isset($_SESSION['filter_helpdesk_responsible_id'])) {
            $filter['responsible_id'] = $_SESSION['filter_helpdesk_responsible_id'];
        } else {
            $filter['responsible_id'] = '';
        }
        if (isset($_SESSION['filter_helpdesk_client_id'])) {
            $filter['client_id'] = $_SESSION['filter_helpdesk_client_id'];
        } else {
            $filter['client_id'] = '';
        }
        if (isset($_SESSION['filter_helpdesk_search'])) {
            $filter['search'] = $_SESSION['filter_helpdesk_search'];
        } else {
            $filter['search'] = '';
        }

        if (isset($_SESSION['filter_helpdesk_status'])) {
            $filter['status'] = $_SESSION['filter_helpdesk_status'];
        } else {
            $filter['status'] = '';
        }

        if (isset($_SESSION['filter_helpdesk_period'])) {
            $filter['period'] = $_SESSION['filter_helpdesk_period'];
        } else {
            $filter['period'] = '';
        }
        if (isset($_SESSION['filter_helpdesk_period_ini'])) {
            $filter['period_ini'] = $_SESSION['filter_helpdesk_period_ini'];
        } else {
            $filter['period_ini'] = '';
        }
        if (isset($_SESSION['filter_helpdesk_period_end'])) {
            $filter['period_end'] = $_SESSION['filter_helpdesk_period_end'];
        } else {
            $filter['period_end'] = '';
        }


        $sql = 'Select t.*,'
                . 'ca.account as client_account, '
                . '(select group_concat(s.description ) from sys_items s JOIN module_helpdesk_sla_products sub_p ON ( sub_p.product_id=s.id) where   sub_p.module_helpdesk_sla_id=t.id) as desc_product, '
                . 'cat.title as desc_category, '
                . 'type.name as treatment_type ';

        $from = ' from module_helpdesk_sla t'
                . ' LEFT JOIN module_helpdesk_tickets_cat cat ON(t.module_helpdesk_tickets_cat_id=cat.id)'
                . ' LEFT JOIN crm_accounts ca ON(t.client_id=ca.id)'
                . ' LEFT JOIN module_helpdesk_tickets_treatment_type type ON(t.module_helpdesk_tickets_treatment_type_id=type.id)'
                . " WHERE (t.deleted_at IS NULL OR t.deleted_at =0)  ";
        $where = "";
        // Filtro por períodos
        if (isset($filter['period']) && $filter['period'] != '') {
            if ($filter['period'] == 'all')
//                $where .= " AND t.created_at IS NOT NULL";
                if ($filter['period'] == 'day')
                    $where .= " AND  t.created_at = '" . date('Y-m-d') . "'";
            if ($filter['period'] == 'week')
                $where .= " AND WEEK( t.created_at) = WEEK('" . date('Y-m-d') . "')";
            if ($filter['period'] == 'month')
                $where .= " AND MONTH( t.created_at) = MONTH('" . date('Y-m-d') . "')";
            if ($filter['period'] == 'interval') {
                if ($filter['period_ini'] != '') {
                    $where .= " AND DATE(t.created_at) >= '" . $filter['period_ini'] . "'";
                }

                if ($filter['period_end'] != '') {
                    $where .= " AND DATE(t.created_at) <= '" . $filter['period_end'] . "'";
                }
            }
        }

        if (isset($filter['client_id']) && $filter['client_id'] != '') {
            //$where .= " AND l.client_id IN (" . implode(',', $filter['client_id']) . ")";
//            $options = "";
//            foreach ($filter['client_id'] as $c) {
//                $c = ORM::for_table('crm_accounts')->find_one($c);
//                if (count($c) > 0) {
//                    $options .= '<option value="' . $c->id . '" selected >' . $c->account . '</option>';
//                }
//            }
            $where .= " AND t.client_id IN (" . $filter['client_id'] . ")";
//            $options = "";
//            foreach ($filter['client_id'] as $c) {
            $c = ORM::for_table('crm_accounts')->find_one($filter['client_id']);
//                if (count($c) > 0) {
            $options = '<option value="' . $c->id . '" selected >' . $c->account . '</option>';
//                }
//            }
            $this->ui->assign('account', $options);
        } else {
            $this->ui->assign('account', false);
        }

        // verifido se é um cliente que está acessando
        if($this->client_id > 0)
        {
            $where.=" AND t.client_id ='" . $this->client_id . "'";
        }

        
        

        if (isset($filter['search']) && $filter['search'] != '') {
            $where .= " AND (ca.account LIKE '%" . $filter['search'] . "%' 
			OR t.id LIKE '%" . $filter['search'] . "%' 
			)";
        }


        if ($filter['items_per_page'] != 'all')
            $filter['items_per_page'] = ($filter['items_per_page'] > 0) ? $filter['items_per_page'] : 10;

        $sql .= $from . $where . ' order by  t.created_at DESC ';

        $page = isset($this->routes['3']) ? $this->routes['3'] : 1;
        $paginator = new ModulePaginator('module_fish_movement', $sql, $filter);
        $records = $paginator->setItemsPerPage($filter['items_per_page'])
                ->setCurrentPageNumber($page)
                ->run();
        
        $graph['date']=array();
        $graph['qty']=array();
        
        foreach (array_reverse($records) as $a)
        {
            if(isset($graph['qty'][date('Y-m-d',strtotime($a['created_at']))])){
                $graph['qty'][date('Y-m-d',strtotime($a['created_at']))]++;
            }else{
                $graph['date'][date('Y-m-d',strtotime($a['created_at']))]="'".date($this->config['df'],strtotime($a['created_at']))."'";
                $graph['qty'][date('Y-m-d',strtotime($a['created_at']))]=1;
            }
        }
        
        


        $css_arr = array(
            's2/css/select2.min',
            'dp/dist/datepicker.min',
            '/../../../application/plugins/module_helpdesk/assets/css/default');

        $js_arr = array(
            's2/js/select2.min',
            'dp/dist/datepicker.min',
            'dashboard/graph', 'chart/echarts.min',
            '/../../../application/plugins/module_helpdesk/assets/js/sla-list'
        );

        $assets_css = Asset::css($css_arr);
        $assets_js = Asset::js($js_arr);
        $this->ui->assign('xheader', $assets_css);
        $this->ui->assign('xfooter', $assets_js);

        $this->ui->assign('showFilters', true);
        //  $sla = $this->model->all('id');

        $slas = ORM::for_table('module_helpdesk_sla')->raw_query("Select count(*) as total " . $from . $where)->find_array();

        $bottomBar = array(
            array('type' => 'int', 'info' => $this->_L['module_helpdesk sla Qty'], 'value' => ($slas[0]['total']))
        );
        $this->ui->assign('bottomBar', $bottomBar);
        
        
        // Gráficos
        $jsvar = '
        _L[\'Data View\'] = \'' . $this->_L['Data View'] . '\';
        _L[\'Refresh\'] = \'' . $this->_L['Refresh'] . '\';
        _L[\'Reset\'] = \'' . $this->_L['Reset'] . '\';
        _L[\'Cancel\'] = \'' . $this->_L['Cancel'] . '\';
        _L[\'Save as Image\'] = \'' . $this->_L['Save as Image'] . '\';
        _L[\'Click to Save\'] = \'' . $this->_L['Click to Save'] . '\';
        _L[\'Average\'] = \'' . $this->_L['Average'] . '\';
        _L[\'Line\'] = \'' . $this->_L['Line'] . '\';
        _L[\'Bar\'] = \'' . $this->_L['Bar'] . '\';

        ';
//        $this->ui->assign('jsvar', $jsvar
//            .showGraph($this->_L['module_helpdesk sla Qty'],$this->_L['module_helpdesk sla Qty']."/dia", "graph_qty",$graph['qty'],$graph['date']));


        $this->ui->assign('formatDateHour', $this->config['df'] . " H:i:s");
        $this->ui->assign('filter', $filter);
        $this->ui->assign('records', $records);
        $this->ui->assign('paginator', $paginator);
        $this->ui->assign('_st', $this->_L['module_helpdesk sla List']);
        $this->ui->assign('_include', 'sla/list');
        $this->ui->display('wrapper.tpl');
    }

    public function add() {
//
        $js_arr = array(
            '/../../../application/plugins/module_helpdesk/assets/js/sla-form',
            'redactor/redactor.min', 's2/js/select2.min', 's2/js/i18n/' . lan(), 'dropzone/dropzone'
        );
        $assets_js = Asset::js($js_arr);
        $this->ui->assign('xfooter', $assets_js);
        
        $css_arr = array('s2/css/select2.min', 'redactor/redactor', 'dropzone/dropzone'
        );
        $assets_css = Asset::css($css_arr);
        $this->ui->assign('xheader', $assets_css);
        
        $user = User::_info();
        
        
        $this->ui->assign('jsvar', '
        _L[\'are_you_sure\'] = \'' . $this->_L['are_you_sure'] . '\';
        _L[\'Save\'] = \'' . $this->_L['Save'] . '\';
        _L[\'OK\'] = \'' . $this->_L['OK'] . '\';
        _L[\'Remove\'] = \'' . $this->_L['Remove'] . '\';
        _L[\'Cancel\'] = \'' . $this->_L['Cancel'] . '\';
        _L[\'Select\'] = \'' . $this->_L['Select'] . '\'; ');



        $this->ui->assign('typeForm', 'window');
        $this->ui->assign('sla', (object) array("title" => "",
                    'id' => "",
                    'product_cat_id' => '',
                    'product_id' => '',
                    'client_id' => '',
                    'treatment_type_local' => '',
                    'sla1' => '',
                    'sla2' => '',
                    'sla3' => '',
                    'sla4' => '',
                    'sla5' => ''
        ));
        $this->ui->assign('_st', $this->_L['module_helpdesk sla insert']);
        $this->ui->assign('_include', 'sla/' . __FUNCTION__);
        $this->ui->display('wrapper.tpl');
    }

    /**
     * Insert add to type diary
     */
    public function post() {
        try {
            
            if($this->client_id > 0)
            {
                $_POST['client_id'] = $this->client_id;
            }
            
            $data = $_POST;
            $msg = '';
            
            
            
            if (empty(_post('client_id'))) {
//                $msg .= $this->_L['Customer'] . $this->_L['is required'];
            }

            
            if (empty(_post('module_helpdesk_tickets_cat_id'))) {
//                $msg .= $this->_L['module_helpdesk ticket category'] . $this->_L['is required'];
            }
            if (empty(_post('module_helpdesk_tickets_treatment_type_id'))) {
//                $msg .= $this->_L['module_helpdesk type'] . $this->_L['is required'];
            }
            if (empty(_post('product_cat_id'))) {
//                $msg .= $this->_L['Category'] . $this->_L['is required'];
            }

            if (!isset($_POST['product_id'])) {
//                $msg .= $this->_L['module_helpdesk product'] . $this->_L['is required'];
            }



            if (empty($msg)) {
                if (isset($data['id']) && $data['id'] > 0) {
                    $ticket = $this->model->getOne($data['id']);
                    $ticket = $this->model->updateSla($data, $ticket);
                    _notify($this->_L['module_helpdesk ticket'] . " " . $this->_L['Edited Successfull'], 's');
                } else {
                    $ticket = $this->model->createSla($data);
                    _notify($this->_L['module_helpdesk sla'] . " " . $this->_L['Add Successfull'], 's');
                }
              
                echo json_encode(array('status' => 'OK', 'msg' => '', 'id' => $ticket->id));
                
                // envio email para responsável
                // FALTA ASSUNTO E TEXTO PARA EMAIL
//                $responsible = ORM::for_table('crm_accounts')->find_one($ticket->responsible_id);
//                Notify_Email::_send('Leonaro Lopes','leolopesramos@me.com', 'HELP DESK HEXAGON | Você tem um novo Ticket', 'teste');
                
                
                
//                $e = ORM::for_table('sys_email_templates')->where('tplname', 'Admin:Password Change Request')->find_one();
//
//                $subject = new Template($e['subject']);
//                $subject->set('business_name', 'lr');
//                $subj = $subject->output();
//                $message = new Template($e['message']);
//                $message->set('name', 'Leonardo teste');
//                $message->set('business_name', 'lr2');
//                $message->set('password_reset_link', U . 'fdsa');
//                $message->set('username', 'leolopesramos@me.com');
//                $message->set('ip_address', $_SERVER["REMOTE_ADDR"]);
//                $message_o = $message->output();
//                var_dump($message_o);exit;
//                Notify_Email::_send('Leonaro Lopes','leolopesramos@me.com', 'fasdfasd', 'dsafdsa');






                
                
            } else {
                echo json_encode(array('status' => 'ERRO', 'msg' => $msg, 'id' => ''));
            }
        } catch (Exception $ex) {
            echo json_encode(array('status' => 'ERRO', 'msg' => $ex->getMessage(), 'id' => ''));
            exit();
        }
    }

    /**
     * Show form to edit type exam
     */
    public function edit() {
        $this->id = $this->routes[3];

        if (empty($this->routes[3]) || !is_numeric($this->routes[3])) {
            die($this->_L['Id_Required']);
        }

        $sla = $this->model->getOne($this->routes[3]);

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

        $js_arr = array(
            '/../../../application/plugins/module_helpdesk/assets/js/sla-form',
            'redactor/redactor.min', 's2/js/select2.min', 's2/js/i18n/' . lan(), 'dropzone/dropzone'
        );
        $css_arr = array('s2/css/select2.min', 'redactor/redactor', 'dropzone/dropzone'
        );
        
        $assets_css = Asset::css($css_arr);
        $assets_js = Asset::js($js_arr);
        $this->ui->assign('xheader', $assets_css);
        $this->ui->assign('xfooter', $assets_js);
        $this->ui->assign('jsvar', '
        _L[\'are_you_sure\'] = \'' . $this->_L['are_you_sure'] . '\';
        _L[\'Save\'] = \'' . $this->_L['Save'] . '\';
        _L[\'OK\'] = \'' . $this->_L['OK'] . '\';
        _L[\'Remove\'] = \'' . $this->_L['Remove'] . '\';
        _L[\'Cancel\'] = \'' . $this->_L['Cancel'] . '\';
        _L[\'Select\'] = \'' . $this->_L['Select'] . '\'; 
   _L[\'View\'] = \'' . $this->_L['View'] . '\'; ');

        $client = ORM::for_table('crm_accounts')->find_one($sla->client_id);
        $this->ui->assign('client', $client);


        $requester = ORM::for_table('module_helpdesk_tickets_cat')->find_one($sla->module_helpdesk_tickets_cat_id);
        $this->ui->assign('cat_ticket', $requester);


        $requester = ORM::for_table('module_helpdesk_tickets_treatment_type')->find_one($sla->module_helpdesk_tickets_treatment_type_id);
        $this->ui->assign('type_ticket', $requester);


        $prods = $this->model->getProducts($sla);
        $this->ui->assign('products', $prods);
        if (count($prods) > 0) {
            $sla->product_cat_id = $prods[0]->product_cat_id;
        }

        $this->ui->assign('sla', $sla);
        $this->ui->assign('typeForm', 'window');
        $this->ui->assign('_st', $this->_L['module_helpdesk sla']);
        $this->ui->assign('_include', 'sla/add');
        $this->ui->display('wrapper.tpl');
    }

    public function view() {
        $this->id = $this->routes[3];

        if (empty($this->routes[3]) || !is_numeric($this->routes[3])) {
            die($this->_L['Id_Required']);
        }

        $ticket = $this->model->getOne($this->routes[3]);

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


        $attach = ORM::for_table('module_helpdesk_tickets_attach')->where('module_helpdesk_tickets_id', $ticket->id)->find_many();

        if (count($attach) > 0) {
            $this->ui->assign('attachs', $attach);
        } else {
            $this->ui->assign('attachs', "");
        }




        $client = ORM::for_table('crm_accounts')->find_one($ticket->client_id);
        $this->ui->assign('client', $client);


        $requester = ORM::for_table('crm_accounts')->find_one($ticket->responsible_id);
        $this->ui->assign('responsible', $requester);

        $requester = ORM::for_table('sys_users')->find_one($ticket->requester_id);
        $this->ui->assign('register', $requester);

        $requester = ORM::for_table('module_helpdesk_tickets_priority')->find_one($ticket->module_helpdesk_tickets_priority_id);
        $this->ui->assign('priority_ticket', $requester);


        $requester = ORM::for_table('module_helpdesk_tickets_cat')->find_one($ticket->module_helpdesk_tickets_cat_id);
        $this->ui->assign('cat_ticket', $requester);


        $requester = ORM::for_table('module_helpdesk_tickets_treatment_type')->find_one($ticket->module_helpdesk_tickets_treatment_type_id);
        $this->ui->assign('type_ticket', $requester);



        $prods = $this->model->getProducts($ticket);
        $this->ui->assign('products', $prods);
        if (count($prods) > 0) {
            $requester = ORM::for_table('sys_items_category')->find_one($prods[0]->product_cat_id);
            $this->ui->assign('category', $requester);
        } else {
            $this->ui->assign('category', '');
        }




        $this->ui->assign('ticket', $ticket);
        $this->ui->assign('typeForm', 'window');
        $this->ui->assign('_st', $this->_L['module_helpdesk view ticket']);
        $this->ui->assign('_include', 'ticket/view');
        $this->ui->display('wrapper.tpl');
    }

    public function delete() {
        $type = $this->model->getOne(_post('id'));

        $this->model->deleteTicket($type);
        r2(U . 'module_helpdesk/ticket/listall', 's', $this->_L['delete_successful']);
    }

    public function add_attach() {
        $uploader = new Uploader();

        $uploader->setDir('application/plugins/module_helpdesk/uploads/tickets/');
        $uploader->sameName(false);
        $uploader->setExtensions(array('jpg', 'jpeg', 'png', 'gif', 'pdf'));
        $uploader->setMaxSize(5);
        if ($uploader->uploadFile('file')) {
            $uploaded = $uploader->getUploadName();
            $file = $uploaded;
            $msg = "Envio concluído";
            $success = 'Yes';
            $d = ORM::for_table('module_helpdesk_tickets_attach')->create();
            $d->src = $uploaded;
            $d->name = $uploader->getOldName();
            if (isset($this->routes['3']) && $this->routes['3'] > 0) {
                $d->module_helpdesk_tickets_id = $this->routes['3'];
            } else {
                //grava a imagem como pertencente ao usuário, antes dele salvar o novo produto
                $user = User::_info();
                $d->user_id = $user->id;
            }
            $d->save();
            $id = $d->id;
        } else {//upload failed
            $file = '';
            $msg = $uploader->getMessage();
            $success = 'No';
            $id = '';
        }

        $a = array(
            'success' => $success,
            'msg' => $msg,
            'file' => $file,
            'id' => $id,
            'url' => APP_URL . '/application/plugins/module_helpdesk/uploads/tickets/' . $file
        );

        header('Content-Type: application/json');

        echo json_encode($a);
    }

    public function delete_attach() {
        $id = _post('id');
        $d = ORM::for_table('module_helpdesk_tickets_attach')->find_one($id);
        if ($d) {
            $d->delete();
            unlink('application/plugins/module_helpdesk/uploads/tickets/' . $d->src);
            $msg = $this->_L['Deleted Successfully'];
            $status = 'Yes';
        } else {
            $msg = $this->_L['Not found'];
            $status = "ERROR";
        }
        $data = array(
            'status' => $status,
            'msg' => $msg,
        );
        header('Content-Type: application/json');
        echo json_encode($data);
    }

    public function add_attach_type_atendence() {
        $uploader = new Uploader();

        $uploader->setDir('application/plugins/module_helpdesk/uploads/tickets/type_atendence/');
        $uploader->sameName(false);
        $uploader->setExtensions(array('jpg', 'jpeg', 'png', 'gif', 'pdf'));
        $uploader->setMaxSize(5);
        if ($uploader->uploadFile('file')) {
            $uploaded = $uploader->getUploadName();
            $file = $uploaded;
            $msg = "Envio concluído";
            $success = 'Yes';
            $d = ORM::for_table('module_helpdesk_tickets_type_attachment')->create();
            $d->src = $uploaded;
            $d->name = $uploader->getOldName();
            if (isset($this->routes['3']) && $this->routes['3'] > 0) {
                $d->module_helpdesk_tickets_id = $this->routes['3'];
            } else {
                //grava a imagem como pertencente ao usuário, antes dele salvar o novo produto
                $user = User::_info();
                $d->user_id = $user->id;
            }
            $d->save();
            $id = $d->id;
        } else {//upload failed
            $file = '';
            $msg = $uploader->getMessage();
            $success = 'No';
            $id = '';
        }

        $a = array(
            'success' => $success,
            'msg' => $msg,
            'file' => $file,
            'id' => $id,
            'url' => APP_URL . '/application/plugins/module_helpdesk/uploads/tickets/type_atendence/' . $file
        );

        header('Content-Type: application/json');

        echo json_encode($a);
    }

    public function delete_attach_type_atendence() {
        $id = _post('id');
        $d = ORM::for_table('module_helpdesk_tickets_type_attachment')->find_one($id);
        if ($d) {
            $d->delete();
            unlink('application/plugins/module_helpdesk/uploads/tickets/type_atendence/' . $d->src);
            $msg = $this->_L['Deleted Successfully'];
            $status = 'Yes';
        } else {
            $msg = $this->_L['Not found'];
            $status = "ERROR";
        }
        $data = array(
            'status' => $status,
            'msg' => $msg,
        );
        header('Content-Type: application/json');
        echo json_encode($data);
    }

}

function showGraph($title,$description, $identificador,$valueSeries,$listDay,$showBackground=false,$color="#2196f3"){
    global $_L;
         $series="{
                    name:'".$title."',
                    type:'line',    
                    smooth:true,
                    color: [
                    '".$color."'
                    ],".
                  ($showBackground? "itemStyle: {normal: {areaStyle: {type: 'default'}}}," :"")
                   ." data:[".  implode(",", $valueSeries)."]
                }";
        
      return " $(function() { var ".$identificador."_opt =  {
            title : {
                text:'".$description."',
                subtext: ''
            },
            tooltip : {
                trigger: 'axis'
            },
             legend: {
                data:['".$title."']
            },
            toolbox: {
                show : true,
                feature : {
                    mark : {show: true},
                    dataView : {show: true, readOnly: false, title : _L['Data View'],
                        lang: [_L['Data View'], _L['Cancel'], _L['Reset']] },
                    magicType : {show: true, title : {
                        line : 'Line',
                        bar : 'Bar',
                        stack : 'Stack',
                        tiled : 'Tiled',
                        force: 'Force',
                        chord: 'Chord',
                        pie: 'Pie',
                        funnel: 'Funnel'
                    }, type: ['line', 'bar', 'stack', 'tiled']},
                    restore : {show: true, title : 'Reset'},
                    saveAsImage : {show: true, title : _L['Save as Image'],
                        type : 'png',
                        lang : [_L['Click to Save']]}
                }
            },
            calculable : true,
            xAxis : [
                {
                    type : 'category',
                    boundaryGap : false,
                    data :[".  implode(",",$listDay)."]
                }
            ],
            yAxis : [
                {
                    type : 'value'
                }
            ],
            series :
                    [
                ".$series."
            ]
        };
        var ".$identificador." = echarts.init(document.getElementById('".$identificador."'));
        ".$identificador.".setOption(".$identificador."_opt);
    });";
}

Anon7 - 2022
AnonSec Team