diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a0013593390..98222fafc00 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -474,7 +474,7 @@ class Facture extends CommonInvoice $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); $sql.= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); - $sql.= ", ".($this->pos_source ? "'".$this->db->escape($this->pos_source)."'" : "null"); + $sql.= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); $sql.= ", ".($this->fk_fac_rec_source?"'".$this->db->escape($this->fk_fac_rec_source)."'":"null"); $sql.= ", ".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null"); $sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null"); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 165a128b9e5..cdfe47a756f 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -77,16 +77,17 @@ if ($action == 'valid' && $user->rights->facture->creer){ if (($action=="addline" || $action=="freezone") and $placeid==0) { + // $place is id of POS, $placeid is id of invoice if ($placeid==0) { $invoice = new Facture($db); $invoice->socid=$conf->global->CASHDESK_ID_THIRDPARTY; $invoice->date=dol_now(); $invoice->ref="(PROV-POS)"; $invoice->module_source = 'takepos'; - $invoice->pos_source = (string) $place; + $invoice->pos_source = (string) (empty($place)?'0':$place); $placeid=$invoice->create($user); - $sql="UPDATE ".MAIN_DB_PREFIX."facture set facnumber='(PROV-POS-".$placeid.")' where rowid=".$placeid; + $sql="UPDATE ".MAIN_DB_PREFIX."facture set facnumber='(PROV-POS-".$place.")' where rowid=".$placeid; $db->query($sql); } }