diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index cdf9873e791..05da0bdebe1 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -215,6 +215,7 @@ switch ($action) $invoice->note_private=$note; $invoice->cond_reglement_id=$cond_reglement_id; $invoice->mode_reglement_id=$mode_reglement_id; + $invoice->module_source = 'cashdesk'; //print "c=".$invoice->cond_reglement_id." m=".$invoice->mode_reglement_id; exit; // Si paiement differe ... diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 280c791fa5d..dd207af57ec 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -126,6 +126,10 @@ class Facture extends CommonInvoice public $close_note; //! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code) public $paye; + //! key of module source when invoice generated from a dedicated module ('cashdesk', 'takepos', ...) + public $module_source; + //! id of template invoice when generated from a template invoice + public $fk_fac_rec_source; //! id of source invoice if replacement invoice or credit note public $fk_facture_source; public $linked_objects=array(); @@ -443,7 +447,7 @@ class Facture extends CommonInvoice $sql.= ", note_public"; $sql.= ", ref_client, ref_int"; $sql.= ", fk_account"; - $sql.= ", fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; + $sql.= ", module_source, fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; $sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; $sql.= ", situation_cycle_ref, situation_counter, situation_final"; $sql.= ", fk_incoterms, location_incoterms"; @@ -467,6 +471,7 @@ class Facture extends CommonInvoice $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); $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->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 f0e5d21770c..939d1ea2189 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -75,16 +75,18 @@ if ($action == 'valid' && $user->rights->facture->creer){ $invoice->set_paid($user); } -if (($action=="addline" or $action=="freezone") and $placeid==0) +if (($action=="addline" || $action=="freezone") and $placeid==0) { if ($placeid==0) { - $invoice = new Facture($db); - $invoice->socid=$conf->global->CASHDESK_ID_THIRDPARTY; - $invoice->date=mktime(); - $invoice->ref="asdf"; - $placeid=$invoice->create($user); - $sql="UPDATE ".MAIN_DB_PREFIX."facture set facnumber='(PROV-POS-".$place.")' where rowid=".$placeid; - $db->query($sql); + $invoice = new Facture($db); + $invoice->socid=$conf->global->CASHDESK_ID_THIRDPARTY; + $invoice->date=dol_now(); + $invoice->ref="(PROV-POS)"; + $invoice->module_source = 'takepos'; + + $placeid=$invoice->create($user); + $sql="UPDATE ".MAIN_DB_PREFIX."facture set facnumber='(PROV-POS-".$place.")' where rowid=".$placeid; + $db->query($sql); } }