| 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/public_html/lrsys_apps/imobles/application/plugins/module_fish/models/ |
Upload File : |
<?php
include_once __DIR__ . "/../../../autoload/My_Model.php";
class MovementModel extends My_Model
{
/**
* @var string
*/
public $table = 'module_fish_movement';
/**
* @param array $data
* @return bool|ORM
*/
//echo 0 se nao eccontrar o lote com o tank, e maior que 0 se encontrar
public function verifyTankLote($module_fish_lots_distribuition_id,$module_fish_tank_id){
$module_fish_lots_distribution = ORM::for_table('module_fish_lots_distribution')->find_one($module_fish_lots_distribuition_id);
$dT = ORM::for_table('module_fish_lots')
->table_alias('l')
->select('l.*')
->select_expr('t.title_tank,t.id as id_tank,ld.qty')
->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');
$dT->where('l.id', $module_fish_lots_distribution->module_fish_lots_id);
$dT->where('ld.module_fish_tank_id', $module_fish_tank_id);
$module_fish_lots_distributionTank = $dT->find_many();
return count($module_fish_lots_distributionTank);
}
public function getTotalMovimentTankLote($module_fish_lots_distribution_id,$module_fish_tank_id,$date,$module_fish_movement_id=0){
$totalQtyOut = ORM::for_table('module_fish_movement')->raw_query(""
. "select sum(i.qty) as total from module_fish_movement_itens i join module_fish_movement m on(i.module_fish_movement_id=m.id) where m.module_fish_lots_distribution_id=". $module_fish_lots_distribution_id." and i.type<>'recont' and m.created_at<='".$date."'".($module_fish_movement_id==0?"":" and i.module_fish_movement_id<>".$module_fish_movement_id))->find_many();
$totalQtyIn = ORM::for_table('module_fish_movement')->raw_query("select sum(i.qty) as total from module_fish_movement m join module_fish_movement_itens i on(i.module_fish_movement_id=m.id) where m.module_fish_lots_distribution_id=". $module_fish_lots_distribution_id." and i.type='fusion' and i.module_fish_tank_id_destiny=" .$module_fish_tank_id." and m.created_at<='".$date."'".($module_fish_movement_id==0?"":" and i.module_fish_movement_id<>".$module_fish_movement_id))->find_many();
$totalQtyInRecont = ORM::for_table('module_fish_movement')->raw_query(""
. "select sum(i.qty) as total from module_fish_movement_itens i join module_fish_movement m on(i.module_fish_movement_id=m.id) where i.type='recont' and m.module_fish_lots_distribution_id=". $module_fish_lots_distribution_id." and m.created_at<='".$date."'".($module_fish_movement_id==0?"":" and i.module_fish_movement_id<>".$module_fish_movement_id))->find_many();
return intval($totalQtyInRecont[0]->total)+ intval($totalQtyIn[0]->total) -intval($totalQtyOut[0]->total);
}
public function getMoviment($module_fish_lots_distribution_id,$type='death'){
$totalQtyOut = ORM::for_table('module_fish_movement_itens')->raw_query(""
. "select i.* from module_fish_movement_itens i join module_fish_movement m on(i.module_fish_movement_id=m.id) where i.type='".$type."' and m.module_fish_lots_distribution_id=". $module_fish_lots_distribution_id)->find_many();
return $totalQtyOut;
}
}