From 58535993c171b40bd4e65a5459c13876c3851bbf Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 12 Apr 2018 16:12:23 +0200 Subject: [PATCH 1/5] use special_code on order_supplier lines --- htdocs/fourn/class/fournisseur.commande.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7c7837e75fe..c9f2ad3f525 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2961,6 +2961,7 @@ class CommandeFournisseurLigne extends CommonOrderLine public $fk_facture; public $label; public $rang = 0; + public $special_code = 0; /** * Unit price without taxes @@ -3000,7 +3001,7 @@ class CommandeFournisseurLigne extends CommonOrderLine */ public function fetch($rowid) { - $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx,'; + $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx, cd.special_code'; $sql.= ' cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.ref,'; $sql.= ' cd.remise, cd.remise_percent, cd.subprice,'; $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,'; @@ -3039,6 +3040,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $this->total_localtax2 = $objp->total_localtax2; $this->total_ttc = $objp->total_ttc; $this->product_type = $objp->product_type; + $this->special_code = $objp->special_code; $this->ref = $objp->product_ref; $this->product_ref = $objp->product_ref; @@ -3145,7 +3147,7 @@ class CommandeFournisseurLigne extends CommonOrderLine // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element; $sql.= " (fk_commande, label, description, date_start, date_end,"; - $sql.= " fk_product, product_type,"; + $sql.= " fk_product, product_type, special_code,"; $sql.= " qty, vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice, ref,"; $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_unit,"; $sql.= " fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc"; @@ -3156,6 +3158,7 @@ class CommandeFournisseurLigne extends CommonOrderLine if ($this->fk_product) { $sql.= $this->fk_product.","; } else { $sql.= "null,"; } $sql.= "'".$this->product_type."',"; + $sql.= "'".$this->special_code."',"; $sql.= "'".$this->qty."', "; $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->vat_src_code."'").","; @@ -3259,6 +3262,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql.= ", total_localtax2='".price2num($this->total_localtax2)."'"; $sql.= ", total_ttc='".price2num($this->total_ttc)."'"; $sql.= ", product_type=".$this->product_type; + $sql.= ", special_code=".(!empty($this->special_code) ? $this->special_code : 0); $sql.= ($this->fk_unit ? ", fk_unit='".$this->db->escape($this->fk_unit)."'":", fk_unit=null"); // Multicurrency From ef2c6a0ed48beab49adc89a79bd569e509557745 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Fri, 13 Apr 2018 10:14:57 +0200 Subject: [PATCH 2/5] fix sql error --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c9f2ad3f525..e3a674a3e94 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3001,7 +3001,7 @@ class CommandeFournisseurLigne extends CommonOrderLine */ public function fetch($rowid) { - $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx, cd.special_code'; + $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx, cd.special_code,'; $sql.= ' cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.ref,'; $sql.= ' cd.remise, cd.remise_percent, cd.subprice,'; $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,'; From 8d4126274aac00fbb6b3350751ecce05c49cd58b Mon Sep 17 00:00:00 2001 From: atm-greg Date: Fri, 13 Apr 2018 15:53:49 +0200 Subject: [PATCH 3/5] rang was missing on order_supplier lines --- htdocs/fourn/class/fournisseur.commande.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e3a674a3e94..916f297af78 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1535,7 +1535,7 @@ class CommandeFournisseur extends CommonOrder $this->line->product_type=$product_type; $this->line->remise_percent=$remise_percent; $this->line->subprice=$pu_ht; - $this->line->rang=$this->rang; + $this->line->rang=$rang; $this->line->info_bits=$info_bits; $this->line->vat_src_code=$vat_src_code; @@ -3147,7 +3147,7 @@ class CommandeFournisseurLigne extends CommonOrderLine // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element; $sql.= " (fk_commande, label, description, date_start, date_end,"; - $sql.= " fk_product, product_type, special_code,"; + $sql.= " fk_product, product_type, special_code, rang,"; $sql.= " qty, vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice, ref,"; $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_unit,"; $sql.= " fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc"; @@ -3159,6 +3159,7 @@ class CommandeFournisseurLigne extends CommonOrderLine else { $sql.= "null,"; } $sql.= "'".$this->product_type."',"; $sql.= "'".$this->special_code."',"; + $sql.= "'".$this->rang."',"; $sql.= "'".$this->qty."', "; $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->vat_src_code."'").","; From 199bf4c044b73535d2f7cf7edd67a8025d41d03b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 13 Apr 2018 17:10:07 +0200 Subject: [PATCH 4/5] Fix: avoid focus problem when select2 is in a modal dialog window --- htdocs/core/lib/ajax.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 2ddc7125d4a..a558d97569f 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -386,10 +386,11 @@ function ajax_autoselect($htmlname, $addlink='') * @param int $minLengthToAutocomplete Minimum length of input string to start autocomplete * @param int $forcefocus Force focus on field * @param string $widthTypeOfAutocomplete 'resolve' or 'off' + * @param string $modalid ID of modal (for avoid focus problem when select2 is in a modal dialog window) * @return string Return html string to convert a select field into a combo, or '' if feature has been disabled for some reason. * @see selectArrayAjax of html.form.class */ -function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve') +function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $modalid='dialog-confirm') { global $conf; @@ -425,7 +426,8 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $ }, escapeMarkup: function(markup) { return markup; - } + }, + dropdownParent: $(\'#'.$modalid.'\') })'; if ($forcefocus) $msg.= '.select2(\'focus\')'; $msg.= ';'."\n"; From 556a418132ed8d9d17973c42dd3813d7b9073818 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 13 Apr 2018 19:30:11 +0200 Subject: [PATCH 5/5] Fix: best method --- htdocs/core/lib/ajax.lib.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index a558d97569f..856d7cdfbd1 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -386,11 +386,10 @@ function ajax_autoselect($htmlname, $addlink='') * @param int $minLengthToAutocomplete Minimum length of input string to start autocomplete * @param int $forcefocus Force focus on field * @param string $widthTypeOfAutocomplete 'resolve' or 'off' - * @param string $modalid ID of modal (for avoid focus problem when select2 is in a modal dialog window) * @return string Return html string to convert a select field into a combo, or '' if feature has been disabled for some reason. * @see selectArrayAjax of html.form.class */ -function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $modalid='dialog-confirm') +function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve') { global $conf; @@ -427,7 +426,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $ escapeMarkup: function(markup) { return markup; }, - dropdownParent: $(\'#'.$modalid.'\') + dropdownCssClass: \'ui-dialog\' })'; if ($forcefocus) $msg.= '.select2(\'focus\')'; $msg.= ';'."\n";