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; } } ?>