����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����
Server IP : 74.208.127.88 / Your IP : 18.117.186.60 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 SellData { public static $tablename = "sell"; public function SellData(){ $this->created_at = "NOW()"; } public function getPerson(){ return PersonData::getById($this->person_id);} public function getUser(){ return UserData::getById($this->user_id);} public function getP(){ return PData::getById($this->p_id);} public function getD(){ return DData::getById($this->d_id);} public function getStockTo(){ return StockData::getById($this->stock_to_id);} public function add(){ $sql = "insert into ".self::$tablename." (person_id,stock_to_id,iva,p_id,d_id,total,discount,user_id,created_at) "; $sql .= "value ($this->person_id,$this->stock_to_id,$this->iva,$this->p_id,$this->d_id,$this->total,$this->discount,$this->user_id,$this->created_at)"; return Executor::doit($sql); } public function add_traspase(){ $sql = "insert into ".self::$tablename." (operation_type_id,iva,p_id,d_id,total,discount,user_id,created_at) "; echo $sql .= "value (6,$this->iva,$this->p_id,$this->d_id,$this->total,$this->discount,$this->user_id,$this->created_at)"; return Executor::doit($sql); } //ventas de contado sin corte public static function getSellUnBoxedSum(){ $sql = "select SUM(total) as suma, COUNT(id) as contador from ".self::$tablename." where box_id is NULL and p_id=1 and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } //ventas de credito sin corte public static function getSellUnBoxedSumCre(){ $sql = "select SUM(cash) as suma, COUNT(id) as contador from ".self::$tablename." where box_id is NULL and p_id=4 and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public function add_cotization(){ $sql = "insert into ".self::$tablename." (is_draft,p_id,d_id,user_id,total,stock_to_id,created_at) "; $sql .= "value (1,2,2,$this->user_id,$this->total,$this->stock_to_id,$this->created_at)"; return Executor::doit($sql); } public function add_cotization_by_client(){ $sql = "insert into ".self::$tablename." (is_draft,p_id,d_id,person_id,created_at) "; echo $sql .= "value (1,2,2,$this->person_id,$this->created_at)"; return Executor::doit($sql); } public function add_de(){ $sql = "insert into ".self::$tablename." (user_id,operation_type_id,created_at) "; $sql .= "value ($this->user_id,1,$this->created_at)"; return Executor::doit($sql); } public function add_re(){ $sql = "insert into ".self::$tablename." (person_id,stock_to_id,total,p_id,d_id,user_id,operation_type_id,created_at) "; $sql .= "value ($this->person_id,$this->stock_to_id,$this->total,$this->p_id,$this->d_id,$this->user_id,1,$this->created_at)"; return Executor::doit($sql); } public function add_with_client(){ $sql = "insert into ".self::$tablename." (iva,p_id,d_id,total,discount,person_id,user_id,created_at) "; $sql .= "value ($this->iva,$this->p_id,$this->d_id,$this->total,$this->discount,$this->person_id,$this->user_id,$this->created_at)"; return Executor::doit($sql); } public function add_re_with_client(){ $sql = "insert into ".self::$tablename." (p_id,d_id,person_id,operation_type_id,user_id,created_at) "; $sql .= "value ($this->p_id,$this->d_id,$this->person_id,1,$this->user_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); } public function process_cotization(){ $sql = "update ".self::$tablename." set stock_to_id=$this->stock_to_id,p_id=$this->p_id,d_id=$this->d_id,iva=$this->iva,total=$this->total,discount=$this->discount,cash=$this->cash,is_draft=0 where id=$this->id"; Executor::doit($sql); } public function update_box(){ $sql = "update ".self::$tablename." set box_id=$this->box_id where box_id is null"; Executor::doit($sql); } public function update_d(){ $sql = "update ".self::$tablename." set d_id=$this->d_id where id=$this->id"; Executor::doit($sql); } public function update_factura(){ $sql = "update ".self::$tablename." set d_id=$this->d_id where id=$this->id"; Executor::doit($sql); } public function update_p(){ $sql = "update ".self::$tablename." set p_id=$this->p_id where id=$this->id"; Executor::doit($sql); } public function update_sale_id($id,$sale_id){ $sql = "update ".self::$tablename." set sale_id='$sale_id' where id='$id'"; Executor::doit($sql); } public static function getByIdF($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and id='$id' order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getById($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and id='$id' and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getByIdCot($id){ $sql = "select * from ".self::$tablename." where operation_type_id=4 and id='$id' order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getByIdSale($id){ $sql = "select * from t_sale where sale_id='$id' "; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } //ventas por vendedor public static function getByIdSaleVendedor($id,$seller){ $sql = "select * from t_sale where sale_id='$id' and id_seller = $seller "; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } //SELECT sum(`total` - `paid`) as total FROM `t_sale` WHERE `id_client` = 442 and `is_credit` = 1 public static function getByIdSaleClient($client){ $sql = "SELECT sum(`total` - `paid`) as total FROM `t_sale` WHERE `id_client` = $client and `is_credit` = 1 "; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } //venta desde t_sale public static function getByc($search){ $sql = "select * from t_sale where sale_id = \"$search\" and is_credit = 1 "; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } //venta desde sell public static function getBycSell($search){ $sql = "select * from ".self::$tablename." where sale_id = \"$search\" and is_draft = 0 "; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } public static function getBycStock($search, $stock_id){ $sql = "select * from ".self::$tablename." where sale_id = '$search' and is_draft = 0 and stock_to_id = $stock_id"; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } //cotizacion public static function getBycCot($search){ $sql = "select * from ".self::$tablename." where sale_id = '$search' and is_draft = 1"; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } //ventas t sale public static function getBySale($search){ $sql = "select * from t_sale where sale_id = '$search' "; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } //facturar public static function getByFactura($search){ $sql = "select * from ".self::$tablename." where id = '$search' "; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } public static function getByFacturar($search){ $sql = "select * from ".self::$tablename." where sale_id = '$search' "; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } public static function getByErrFact($search){ $sql = "select * from ".self::$tablename." where id = '$search' "; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } public static function getByc2($search){ $sql = "select * from ".self::$tablename." where id='$search' "; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } //buscar por sucursal public static function getByStock($search){ $sql = "select * from t_sale where stock_to_id = '$search' "; $query = Executor::doit($sql); return Model::one($query[0],new SellData()); } public static function getCotizations(){ $sql = "select * from ".self::$tablename." where operation_type_id=4 and p_id=2 and d_id=2 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getCotizationsByClientId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and p_id=2 and d_id=2 and is_draft=1 and person_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellDay(){ $sql = "select SUM(total) as suma from ".self::$tablename." where operation_type_id = 2 and (date(created_at)= CURDATE()) order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSells($start,$end){ $sql = "select * from ".self::$tablename." where operation_type_id = 2 and (date(created_at)>=\"$start\" and date(created_at)<=\"$end\") order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsStock($start,$end, $stock_id){ $sql = "select * from ".self::$tablename." where operation_type_id = 2 and box_id IS NULL and (date(created_at)>=\"$start\" and date(created_at)<=\"$end\") and stock_to_id = $stock_id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } //ventas de contado almacen public static function getSellsStock2($start,$end, $stock_id){ $sql = "select SUM(total) as total from ".self::$tablename." where operation_type_id = 2 and (date(sale_date)>=\"$start\" and date(sale_date)<=\"$end\") and stock_to_id = $stock_id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } //ventas de credito almacen public static function getSellsStockCredit($start,$end, $stock_id){ $sql = "select SUM(cash) as cash from ".self::$tablename." where operation_type_id = 2 and p_id=4 and is_draft=0 and (date(sale_date)>=\"$start\" and date(sale_date)<=\"$end\") and stock_to_id = $stock_id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSells_1(){ $sql = "select * from ".self::$tablename." where operation_type_id=2 order by created_at"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsMes($m){ $sql = "SELECT f.* FROM `facturaok` f WHERE MONTH(f.created_at) = $m and f.is_service = 1;"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellByTop20(){ $sql = "select * from ".self::$tablename." where operation_type_id=2 order by created_at desc limit 20"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellAll(){ $sql = "select * from ".self::$tablename." where operation_type_id=2 order by created_at desc limit 100"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSells2($start,$end,$id){ $sql = "select * from ".self::$tablename." where sale_id=$id and operation_type_id=2 and (date(created_at)>=\"$start\" and date(created_at)<=\"$end\") order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsByUS($id){ $sql = "select * from ".self::$tablename." where user_id='$id' and operation_type_id=2 and p_id=1 and d_id=1 and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsByPersonId($id,$p,$d){ $sql = "select * from ".self::$tablename." where person_id=$id and operation_type_id=2 and p_id=$p and d_id=$d and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsByUserId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and p_id=1 and d_id=1 and is_draft=0 and user_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsByStockId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and p_id=1 and d_id=1 and is_draft=0 and stock_to_id='$id' order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getCredits(){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and p_id=4 and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellCreditsUnBoxed(){ $sql = "select * from ".self::$tablename." where box_id is NULL and p_id=4 and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getCreditsByUserId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and p_id=4 and is_draft=0 and user_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getCreditsByStockId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and p_id=4 and is_draft=0 and stock_to_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsByClientId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and p_id=1 and d_id=1 and is_draft=0 and person_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsToDeliver(){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and d_id=2 and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsToDeliverByUserId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and d_id=2 and is_draft=0 and user_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsToDeliverByStockId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and d_id=2 and is_draft=0 and stock_to_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsToDeliverByClient($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and d_id=2 and is_draft=0 and person_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsToCob(){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and p_id=2 and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsToCobByUserId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and p_id=2 and is_draft=0 and user_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsToCobByStockId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and p_id=2 and is_draft=0 and stock_to_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsToCobByClientId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and p_id=2 and is_draft=0 and person_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getSellsUnBoxed(){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and box_id is NULL and p_id=1 and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getAllSellsUnBoxed(){ $sql = "select * from ".self::$tablename." where box_id is NULL and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getAllSellsUnBoxedstock($id){ $sql = "select * from ".self::$tablename." where box_id is NULL and is_draft=0 and stock_to_id = $id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getByBoxId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=2 and box_id=$id and is_draft=0 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getRes(){ $sql = "select * from ".self::$tablename." where operation_type_id=1 and p_id=1 and d_id=1 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getResByStockId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=1 and p_id=1 and d_id=1 and stock_to_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getResToPay(){ $sql = "select * from ".self::$tablename." where operation_type_id=1 and p_id=2 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getResToPayByStockId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=1 and p_id=2 and stock_to_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getResToReceive(){ $sql = "select * from ".self::$tablename." where operation_type_id=1 and d_id=2 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getResToCredit(){ $sql = "select * from ".self::$tablename." where operation_type_id=1 and p_id=4 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getResToReceiveByStockId($id){ $sql = "select * from ".self::$tablename." where operation_type_id=1 and d_id=2 and stock_to_id=$id order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getAllByPage($start_from,$limit){ $sql = "select * from ".self::$tablename." where id<=$start_from limit $limit"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getAllByDateOp($start,$end,$op){ $sql = "select * from ".self::$tablename." where date(created_at) >= \"$start\" and date(created_at) <= \"$end\" and operation_type_id=$op and is_draft=0 and p_id=1 and d_id=1 order by created_at GROUP BY created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getAllByDateOpByUserId($user,$start,$end,$op){ $sql = "select * from ".self::$tablename." where date(created_at) >= \"$start\" and date(created_at) <= \"$end\" and operation_type_id=$op and is_draft=0 and p_id=1 and d_id=1 and id_seller=$user order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getGroupByDateOp($start,$end,$op){ $sql = "select id,sum(total) as tot,discount,sum(total) as t,count(*) as c from ".self::$tablename." where date(created_at) >= \"$start\" and date(created_at) <= \"$end\" and operation_type_id=$op and is_draft=0 GROUP BY created_at"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } //SELECT SUM(`total`) AS t FROM `t_sale` WHERE date(`sale_date`) = "2024/11/09"; //ventas de contado public static function getByDateOp($start){ $sql = "SELECT sum(total) as c FROM `t_sale` WHERE date(`sale_date`) = \"$start\" and is_credit = 0"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } //ventas a credito pago cash public static function getByDateOpCredit($start){ $sql = "SELECT sum(paid) as p FROM `t_sale` WHERE date(`sale_date`) = \"$start\" and is_credit = 1"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } //SELECT date(`created_at`) as created_at,SUM(`qty`) AS t,sum(price*qty) as c FROM `t_sale_detail` WHERE date(created_at) >= "2024-11-01" and date(created_at) <= "2024-11-30" and `is_draft` = 0 GROUP BY created_at public static function getAllByDateBCOp($clientid,$start,$end,$op){ $sql = "select * from ".self::$tablename." where date(created_at) >= \"$start\" and date(created_at) <= \"$end\" and person_id=$clientid and operation_type_id=$op and is_draft=0 and p_id=1 and d_id=1 order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } public static function getAllByDateBCOpByUserId($user,$clientid,$start,$end,$op){ $sql = "select * from ".self::$tablename." where date(created_at) >= \"$start\" and date(created_at) <= \"$end\" and person_id=$clientid and operation_type_id=$op and is_draft=0 and p_id=1 and d_id=1 and id_seller=$user order by created_at desc"; $query = Executor::doit($sql); return Model::many($query[0],new SellData()); } } ?>