60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php
|
|
|
|
class Order{
|
|
public $id;
|
|
public $product_id;
|
|
public $parent_id;
|
|
public $purchase_price;
|
|
public $sell_price;
|
|
public $sell_quantity;
|
|
public $buy_quantity;
|
|
public $date;
|
|
public $file_id;
|
|
public $file_name;
|
|
public $file_date;
|
|
public $user_id;
|
|
|
|
public function __construct(){
|
|
global $current_user;
|
|
$this->id = create_guid();
|
|
$this->user_id=$current_user->id;
|
|
}
|
|
|
|
public function setProductId($string){
|
|
$product_name = explode(" ",$string);
|
|
|
|
$product = new EcmProduct();
|
|
$product->retrieve_by_string_fields(['code'=>$product_name[1]]);
|
|
|
|
$this->product_id=$product->id;
|
|
$this->purchase_price=$product->price_msh;
|
|
|
|
}
|
|
|
|
public function getPrice(){
|
|
$query="select c.price_brutto from ecminvoiceoutitems c
|
|
inner join ecminvoiceouts i on i.id=c.ecminvoiceout_id
|
|
inner join accounts a on a.id= i.parent_id
|
|
where c.ecmproduct_id='".$this->product_id."' and a.parent_id=1249 and i.deleted=0 and i.canceled=0 order by i.date_entered desc limit 1";
|
|
|
|
$res=$GLOBALS['db']->query($query);
|
|
$files = [];
|
|
$dane=$GLOBALS['db']->fetchByAssoc($res);
|
|
|
|
|
|
$this->sell_price=$dane['price_brutto'];
|
|
|
|
|
|
|
|
}
|
|
|
|
public function setParentId($string){
|
|
$parent = explode(" ",$string);
|
|
|
|
$account = new Account();
|
|
$account->retrieve_by_string_fields(['shop_number'=>substr($parent[0],0,4)]);
|
|
|
|
$this->parent_id=$account->id;
|
|
}
|
|
}
|
|
?>
|