AnonSec Shell
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/dialogo/application/plugins/module_helpdesk/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/dialogo/application/plugins/module_helpdesk/models/TicketModel.php
<?php

include_once __DIR__ . "/../../../autoload/My_Model.php";
include_once __DIR__ . "/../factories/TicketFactory.php";

class TicketModel extends My_Model {

    /**
     * @var string
     */
    public $table = 'module_helpdesk_tickets';

    public function createTicket($data) {
        $ticket = self::create();
        TicketFactory::create($data, $ticket, true);
        $ticket->save();
        $this->saveUpdateProducts($ticket, $data);
        $this->updateattach($data, $ticket->id);
        if ($ticket->module_helpdesk_tickets_treatment_type_id == 3) {
            $this->updateAttachTypeTreatment($data, $ticket->id);
        }
        return $ticket;
    }

    private function saveUpdateProducts($ticket, $data) {

        ORM::for_table('module_helpdesk_tickets_products')->where('module_helpdesk_tickets_id', $ticket->id)->delete_many();
        if (!empty($data['product_id'])) {

            foreach ($data['product_id'] as $p) {

                if (intval($p) > 0) {
                    $d = ORM::for_table('module_helpdesk_tickets_products')->create();
                    $d->product_cat_id = $data['product_cat_id'];
                    $d->product_id = intval($p);
                    $d->module_helpdesk_tickets_id = $ticket->id;
                    $d->save();
                }
            }
        }
    }

    public function getProducts($ticket) {
        return ORM::for_table('module_helpdesk_tickets_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_tickets_id', $ticket->id)->find_many();
    }

    public function updateTicket($data, $ticket) {
        ORM::for_table($this->table)->create($ticket);
        TicketFactory::create($data, $ticket);
        $ticket->save();
        $this->saveUpdateProducts($ticket, $data);
        return $ticket;
    }

    public function deleteTicket($ticket) {
        ORM::for_table('module_helpdesk_tickets_products')->where('module_helpdesk_tickets_id', $ticket->id)->delete_many();
        ORM::for_table($this->table)->create($ticket);
        $ticket->deleted_at = date('Y-m-d H:i:s');
        $ticket->save();
        return $ticket;
    }

    public function updateAttach($data, $ticket) {
        if (isset($data['attachment'])) {
            $attachs = explode(',', $data['attachment']);
            foreach ($attachs as $t) {
                if (intval($t) > 0) {
                    $a = ORM::for_table('module_helpdesk_tickets_attach')->find_one($t);
                    $a->module_helpdesk_tickets_id = $ticket;
                    $a->save();
                }
            }
        }
    }

    public function updateAttachTypeTreatment($data, $ticket) {
        if (isset($data['attachment_type_atendence'])) {
            $attachs = explode(',', $data['attachment_type_atendence']);
            foreach ($attachs as $t) {
                if (intval($t) > 0) {
                    $a = ORM::for_table('module_helpdesk_tickets_type_attachment')->find_one($t);
                    $a->module_helpdesk_tickets_id = $ticket;
                    $a->save();
                }
            }
        }
    }

}

Anon7 - 2022
AnonSec Team