From 41f2289ffaabbf7992436cf4f56511644e91a2f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Oct 2018 22:28:30 +0200 Subject: [PATCH] Save pos station into invoice --- htdocs/cashdesk/validation_verif.php | 1 + htdocs/compta/facture/class/facture.class.php | 5 ++++- htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 1 + htdocs/install/mysql/tables/llx_facture.sql | 1 + htdocs/takepos/invoice.php | 3 ++- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index 05da0bdebe1..b42bc90d8fb 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -216,6 +216,7 @@ switch ($action) $invoice->cond_reglement_id=$cond_reglement_id; $invoice->mode_reglement_id=$mode_reglement_id; $invoice->module_source = 'cashdesk'; + $invoice->pos_source = '0'; //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 dd207af57ec..a0013593390 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -128,6 +128,8 @@ class Facture extends CommonInvoice public $paye; //! key of module source when invoice generated from a dedicated module ('cashdesk', 'takepos', ...) public $module_source; + //! key of pos source ('0', '1', ...) + public $pos_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 @@ -447,7 +449,7 @@ class Facture extends CommonInvoice $sql.= ", note_public"; $sql.= ", ref_client, ref_int"; $sql.= ", fk_account"; - $sql.= ", module_source, fk_fac_rec_source, fk_facture_source, fk_user_author, fk_projet"; + $sql.= ", module_source, pos_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"; @@ -472,6 +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->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/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 0d3f823cb52..476eac1c4d9 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -35,6 +35,7 @@ ALTER TABLE llx_accounting_system MODIFY COLUMN pcg_version varchar(32) NOT NULL ALTER TABLE llx_accounting_account ADD CONSTRAINT fk_accounting_account_fk_pcg_version FOREIGN KEY (fk_pcg_version) REFERENCES llx_accounting_system (pcg_version); ALTER TABLE llx_facture ADD COLUMN module_source varchar(32); +ALTER TABLE llx_facture ADD COLUMN pos_source varchar(32); create table llx_facture_rec_extrafields ( diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index 6f326450f7f..c001d459b48 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -64,6 +64,7 @@ create table llx_facture fk_user_valid integer, -- user validating module_source varchar(32), -- name of module when invoice generated by a dedicated module (POS, ...) + pos_source varchar(32), -- name of POS station when invoice is generated by a POS module fk_fac_rec_source integer, -- facture rec source fk_facture_source integer, -- facture origin if credit notes or replacement invoice fk_projet integer DEFAULT NULL, -- project invoice is linked to diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 939d1ea2189..165a128b9e5 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -83,9 +83,10 @@ if (($action=="addline" || $action=="freezone") and $placeid==0) $invoice->date=dol_now(); $invoice->ref="(PROV-POS)"; $invoice->module_source = 'takepos'; + $invoice->pos_source = (string) $place; $placeid=$invoice->create($user); - $sql="UPDATE ".MAIN_DB_PREFIX."facture set facnumber='(PROV-POS-".$place.")' where rowid=".$placeid; + $sql="UPDATE ".MAIN_DB_PREFIX."facture set facnumber='(PROV-POS-".$placeid.")' where rowid=".$placeid; $db->query($sql); } }