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_fish/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/dialogo/application/plugins/module_fish/controllers/TankController.php
<?php

include_once "Controller.php";
include_once __DIR__ . "/../models/TankModel.php";

class TankController extends Controller
{
    /**
     * @var ID Tank
     */
    protected $id;
    
    /**
     * @var Client ID
     */
    protected $client_id;

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

    /**
     * @param $ui
     * @param array $this->_L
     * @param array $config
     * @param $_pd
     */
    public function __construct($ui, $_L, $config, $_pd, $client_id = null)
    {
        parent::__construct($ui, $_L, $config, $_pd);

        $this->ui->assign('_title', $this->_L['Fish Description module'] . ' - ' . $this->config['CompanyName']);

        $this->model = new TankModel();

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

    /**
     * Show list to tank
     */
    public function listTank()
    {
        // LISTAR TANQUES
        
        $where = '';
        $filter['items_per_page'] = 10;
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $filter['search'] = filter_var(_post('search'), FILTER_SANITIZE_STRING);
            $filter['type'] = filter_var(_post('type'), FILTER_SANITIZE_STRING);
            $filter['function'] = filter_var(_post('function'), FILTER_SANITIZE_STRING);
            $filter['items_per_page'] = filter_var(_post('items_per_page'), FILTER_SANITIZE_STRING);
        } else {
            if ($i = array_search('search', $this->routes))
                $filter['search'] = filter_var($this->routes[$i + 1], FILTER_SANITIZE_STRING);
            if ($i = array_search('type', $this->routes))
                $filter['type'] = filter_var($this->routes[$i + 1], FILTER_SANITIZE_STRING);
            if ($i = array_search('function', $this->routes))
                $filter['function'] = filter_var($this->routes[$i + 1], FILTER_SANITIZE_STRING);
            if ($i = array_search('items_per_page', $this->routes))
                $filter['items_per_page'] = filter_var($this->routes[$i + 1], FILTER_SANITIZE_STRING);
        }
        
        // verifido se é um cliente que está acessando
        if($this->client_id > 0)
        {
            $where.=" AND t.crm_accounts_id ='" . $this->client_id . "'";
        }
        
        if(!empty($filter['search'])){
            $where.=" AND ca.account  LIKE '%" . htmlentities($filter['search']) . "%'";
        }
        
        if(!empty($filter['function']) && $filter['function']!='all'){
            $where.=" AND t.function_tank ='" . ($filter['function']) . "'";
        }
        
        if(!empty($filter['type']) && $filter['type']!='all'){
            $where.=" AND t.type_tank ='" . htmlentities($filter['type']) . "'";
        }
        
        $sql = 'Select t.* , ca.account from module_fish_tank t '
                . ' LEFT JOIN crm_accounts ca ON(t.crm_accounts_id=ca.id)'
                . '' . (empty($where) ? '' : " WHERE t.deleted_at IS NULL " .$where).
                ' order by ca.account asc, t.title_tank';
        if ($filter['items_per_page'] != 'all')
            $filter['items_per_page'] = ($filter['items_per_page'] > 0) ? $filter['items_per_page'] : 10;

        $page = isset($this->routes['3']) ? $this->routes['3'] : 1;
        $paginator = new ModulePaginator('module_billing_records', $sql, $filter);
        $records = $paginator->setItemsPerPage($filter['items_per_page'])
                ->setCurrentPageNumber($page)
                ->run();

       
        $css_arr = array('/../../../application/plugins/module_fish/assets/css/tank-list');

        $js_arr = array(
            '/../../../application/plugins/module_fish/assets/js/tank-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('records', $records);
        $this->ui->assign('paginator', $paginator);
        $this->ui->assign('filter', $filter);
        $this->ui->assign('tanks', $records);
       
        $d = ORM::for_table('module_billing_records')->raw_query($sql)->find_many();
         $areatotal=0;
        $volumetotal=0;
        for($i=0;$i<count($d);$i++){
            $areatotal+=$d[$i]->area_tank;
            $volumetotal+=$d[$i]->area_tank*$d[$i]->depth_tank;
            
        }
        $bottomBar = array(
            array('type' => 'float', 'info' => $this->_L['Module_Fish Total volume'], 'value' => $volumetotal),
            array('type' => 'float', 'info' => $this->_L['Module_Fish Total area'], 'value' => $areatotal),
            array('type' => 'int', 'info' => $this->_L['Module_Fish Number Tanks'], 'value' => count($d)),
        );
        $this->ui->assign('bottomBar', $bottomBar);
        
        $this->ui->assign('_st', $this->_L['Fish Description module']);
        $this->ui->assign('_include', 'tank/' . __FUNCTION__);
        $this->ui->display('wrapper.tpl');
    }

    /**
     * Show add to type tank
     */
    public function add()
    {
        // CARREGA CSS E JS'S
        $css_arr = array('s2/css/select2.min');

        $js_arr = array(
            's2/js/select2.min',
            '/../../../application/plugins/module_fish/assets/js/default-tank',
        );

        $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('_st', $this->_L['Tank_List_Fish']);
        $this->ui->assign('_include', 'tank/' . __FUNCTION__);
        $this->ui->display('wrapper.tpl');
    }

    /**
     * Insert add to type diary
     */
    public function create()
    {
        $data = $_POST;

        $this->model->createTank($data);

        $this->ui->assign('_st', $this->_L['Tank_Save_Msg']);
        r2(U . ($this->client_id>0?'client/':'').'module_fish/tank/listTank', 's', $this->_L['Tank_Save_Msg']);
    }

    /**
     * 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']);
        }

        $tank = $this->model->getOne($this->routes[3]);
        if (!$tank) {
            die($this->_L['Not_Found']);
        }
        
           if($this->client_id > 0)
        {
            if($tank->crm_accounts_id!=$this->client_id ){
                r2(U .($this->client_id>0?'client/':'').'module_fish/tank/listTank', 's', $this->_L['Associated']." ". $this->_L['Not Permited']);
            }
           
        }
        
        $account =  ORM::for_table('crm_accounts')->find_one($tank->crm_accounts_id);
        if($account){
            $tank->crm_accounts_name=$account->account;
        }
        $this->ui->assign('tank', $tank);

        // CARREGA CSS E JS'S
        $css_arr = array('s2/css/select2.min');

        $js_arr = array(
            's2/js/select2.min',
            '/../../../application/plugins/module_fish/assets/js/default-tank',
        );

        $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('_st', $this->_L['Tank_List_Fish'] . ' - ' . $this->_L['Tank_Edit_Module']);
        $this->ui->assign('_include', 'tank/add');
        $this->ui->display('wrapper.tpl');
    }

    public function delete()
    {
        $tank = $this->validateTank();
        $this->model->deleteTank($tank);

        $this->ui->assign('_st', $this->_L['Tank_Del_Msg']);
        r2(U . ($this->client_id>0?'client/':'').'module_fish/tank/listTank', 's', $this->_L['Tank_Del_Msg']);
        $this->ui->display('wrapper.tpl');
    }

    /**
     * Show form to update diary
     */
    public function update()
    {
        $diary = $this->validateTank();

        $this->model->updateTank($this->data, $diary);

        $this->ui->assign('_st', $this->_L['Tank_Edit_Msg']);
        r2(U . ($this->client_id>0?'client/':'').'module_fish/tank/listTank', 's', $this->_L['Tank_Edit_Msg']);
        $this->ui->display('wrapper.tpl');
    }

    /**
     * @return ORM
     */
    protected function validateTank()
    {
        $this->data = $_POST;
        if (empty($this->data['id']) || !is_numeric($this->data['id'])) {
            die($this->_L['Id_Required']);
        }

        $tank = $this->model->getOne($this->data['id']);

        if (!$tank) {
            die($this->_L['Not_Found']);
        }

        return $tank;
    }
}

Anon7 - 2022
AnonSec Team