Save pos_source with id of POS station

This commit is contained in:
Laurent Destailleur 2018-10-08 22:51:20 +02:00
parent 41f2289ffa
commit 35d5a495de
2 changed files with 4 additions and 3 deletions

View File

@ -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");

View File

@ -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);
}
}