From 90615a8682daa57a5449885ec22917824b957a89 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Nov 2017 02:44:02 +0100 Subject: [PATCH 01/14] Fix busy tag not set sometimes --- htdocs/comm/action/card.php | 2 ++ htdocs/comm/action/class/actioncomm.class.php | 6 +++--- htdocs/theme/eldy/style.css.php | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 03d73635c17..c8fd5d32c2e 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1329,6 +1329,8 @@ if ($id > 0) print ''; if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid))) { + //var_dump($object->userassigned); + //var_dump($listofuserid); print '
'; print $langs->trans("MyAvailability").': '.(($object->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody print '
'; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 00561fcd3b0..24b768397e2 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -225,11 +225,11 @@ class ActionComm extends CommonObject if ($this->elementtype=='commande') $this->elementtype='order'; if ($this->elementtype=='contrat') $this->elementtype='contract'; - if (! is_array($this->userassigned) && ! empty($this->userassigned)) // For backward compatibility + if (! is_array($this->userassigned) && ! empty($this->userassigned)) // For backward compatibility when userassigned was an int instead fo array { $tmpid=$this->userassigned; $this->userassigned=array(); - $this->userassigned[$tmpid]=array('id'=>$tmpid); + $this->userassigned[$tmpid]=array('id'=>$tmpid, 'transparency'=>$this->transparency); } if (is_object($this->contact) && isset($this->contact->id) && $this->contact->id > 0 && ! ($this->contactid > 0)) $this->contactid = $this->contact->id; // For backward compatibility. Using this->contact->xx is deprecated @@ -240,7 +240,7 @@ class ActionComm extends CommonObject // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). if (empty($this->userassigned) || count($this->userassigned) == 0 || ! is_array($this->userassigned)) - $this->userassigned = array($userownerid=>array('id'=>$userownerid)); + $this->userassigned = array($userownerid=>array('id'=>$userownerid, 'transparency'=>$this->transparency)); if (! $this->type_id || ! $this->type_code) { diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 515015b5b5a..06d24db8948 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3401,7 +3401,7 @@ table.cal_month td:last-child { border-right: 0px; } .cal_today_peruser { background: #FDFDF0; border-right: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } .cal_today_peruser_peruserleft { background: #FDFDF0; border-left: solid 2px #6C7C7B; border-right: solid 1px #E0E0E0; border-bottom: solid 1px #E0E0E0; padding-: 2px; padding-: 1px; padding-top: 0px; padding-bottom: 0px; } .cal_past { } -.cal_peruser { padding: 0px; } +.cal_peruser { padding-top: 0 !important; padding-bottom: 0 !important; padding-: 1px !important; padding-: 1px !important; } .cal_impair { background: #F8F8F8; } .cal_today_peruser_impair { background: #F8F8F0; } .peruser_busy { background: #CC8888; } From 05683bbf6172f91fa350161706e6bb6d6916aafe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Nov 2017 11:41:37 +0100 Subject: [PATCH 02/14] Code comment --- dev/dolibarr_changes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 3b9ef4cc447..3c2b7b3c932 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -99,7 +99,7 @@ JQUERYFILETREE: RESTLER: -------- -* Add 2 lines into function +* Add 2 lines into file AutoLoader.php to complete function private function alias($className, $currentClass) { ... From 1a5bbef2664e2307460aeae9a3bbdeff1020d182 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Nov 2017 13:07:31 +0100 Subject: [PATCH 03/14] FIX Locatax were not propagated when cloning order or proposal --- htdocs/comm/propal/class/propal.class.php | 19 +++++++++++-------- htdocs/commande/class/commande.class.php | 12 ++++++++---- htdocs/compta/facture/class/facture.class.php | 10 +++++++--- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 64997b4c9ea..ffeda27da42 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -371,12 +371,12 @@ class Propal extends CommonObject * by whose calling the method get_default_tva (societe_vendeuse, societe_acheteuse, '' product) * and desc must already have the right value (it's up to the caller to manage multilanguage) * - * @param string $desc Description de la ligne - * @param float $pu_ht Prix unitaire - * @param float $qty Quantite - * @param float $txtva Taux de tva - * @param float $txlocaltax1 Local tax 1 rate - * @param float $txlocaltax2 Local tax 2 rate + * @param string $desc Description of line + * @param float $pu_ht Unit price + * @param float $qty Quantity + * @param float $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') + * @param float $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) + * @param float $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) * @param int $fk_product Id du produit/service predefini * @param float $remise_percent Pourcentage de remise de la ligne * @param string $price_base_type HT or TTC @@ -1018,11 +1018,15 @@ class Propal extends CommonObject $fk_parent_line = 0; } + // Complete vat rate with code + $vatrate = $this->lines[$i]->tva_tx; + if ($this->lines[$i]->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$this->lines[$i]->vat_src_code.')'; + $result = $this->addline( $this->lines[$i]->desc, $this->lines[$i]->subprice, $this->lines[$i]->qty, - $this->lines[$i]->tva_tx, + $vatrate, $this->lines[$i]->localtax1_tx, $this->lines[$i]->localtax2_tx, $this->lines[$i]->fk_product, @@ -1227,7 +1231,6 @@ class Propal extends CommonObject if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $clonedObj->ref_client = ''; // Create clone - $result=$clonedObj->create($user); if ($result < 0) $error++; else diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 56a7fe16b43..5023410cf53 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -821,11 +821,15 @@ class Commande extends CommonOrder $fk_parent_line = 0; } + // Complete vat rate with code + $vatrate = $line->tva_tx; + if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; + $result = $this->addline( $line->desc, $line->subprice, $line->qty, - $line->tva_tx, + $vatrate, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, @@ -1211,9 +1215,9 @@ class Commande extends CommonOrder * @param string $desc Description of line * @param float $pu_ht Unit price (without tax) * @param float $qty Quantite - * @param float $txtva Taux de tva force, sinon -1 - * @param float $txlocaltax1 Local tax 1 rate - * @param float $txlocaltax2 Local tax 2 rate + * @param float $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') + * @param float $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) + * @param float $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) * @param int $fk_product Id of product * @param float $remise_percent Pourcentage de remise de la ligne * @param int $info_bits Bits de type de lignes diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 99665476a8e..e704a5a229a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -575,11 +575,15 @@ class Facture extends CommonInvoice $fk_parent_line = 0; } + // Complete vat rate with code + $vatrate = $line->tva_tx; + if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; + $result = $this->addline( $line->desc, $line->subprice, $line->qty, - $line->tva_tx, + $vatrate, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, @@ -2427,8 +2431,8 @@ class Facture extends CommonInvoice * @param double $pu_ht Unit price without tax (> 0 even for credit note) * @param double $qty Quantity * @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') - * @param double $txlocaltax1 Local tax 1 rate (deprecated) - * @param double $txlocaltax2 Local tax 2 rate (deprecated) + * @param double $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside) + * @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) * @param int $fk_product Id of predefined product/service * @param double $remise_percent Percent of discount on line * @param int $date_start Date start of service From b5196b71641699b8e83ba6166a74a52081c0405e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Nov 2017 14:02:17 +0100 Subject: [PATCH 04/14] FIX A lot of several fix on local taxes and NPR tax --- htdocs/cashdesk/facturation_verif.php | 11 ++- htdocs/comm/propal/card.php | 3 + htdocs/commande/card.php | 11 ++- htdocs/compta/facture/card.php | 3 + htdocs/compta/facture/fiche-rec.php | 3 + htdocs/contrat/card.php | 3 + htdocs/core/class/commonobject.class.php | 1 + htdocs/expedition/class/expedition.class.php | 3 +- .../install/mysql/migration/5.0.0-6.0.0.sql | 2 + htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/stocks.lang | 2 +- htdocs/product/price.php | 73 ++++++++++++++----- 12 files changed, 88 insertions(+), 28 deletions(-) diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 24876a0a8fb..25ddfd8c1f8 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -114,10 +114,13 @@ switch($action) { if (count($prodcustprice->lines) > 0) { - $pu_ht = price($prodcustprice->lines [0]->price); - $pu_ttc = price($prodcustprice->lines [0]->price_ttc); - $price_base_type = $prodcustprice->lines [0]->price_base_type; - $tva_tx = $prodcustprice->lines [0]->tva_tx; + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $tva_tx = $prodcustprice->lines[0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr=0; } } else diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 839538f777e..c3be71c35a1 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -805,6 +805,9 @@ if (empty($reshook)) $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; $tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx . ' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx); + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr=0; } } } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 374ec0477fe..33048f8d470 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -766,10 +766,13 @@ if (empty($reshook)) { if (count($prodcustprice->lines) > 0) { - $pu_ht = price($prodcustprice->lines [0]->price); - $pu_ttc = price($prodcustprice->lines [0]->price_ttc); - $price_base_type = $prodcustprice->lines [0]->price_base_type; - $tva_tx = $prodcustprice->lines [0]->tva_tx; + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $tva_tx = $prodcustprice->lines[0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr=0; } } else diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index f438a5ab6b9..3bc4759e589 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1589,6 +1589,9 @@ if (empty($reshook)) $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; $tva_tx = $prodcustprice->lines[0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr=0; } } } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 0bfdc134258..c748cb0a0e3 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -530,6 +530,9 @@ if (empty($reshook)) $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; $tva_tx = $prodcustprice->lines[0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr=0; } } } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 39a708bcdad..43f086fbab4 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -509,6 +509,9 @@ if (empty($reshook)) $pu_ttc = price($prodcustprice->lines [0]->price_ttc); $price_base_type = $prodcustprice->lines [0]->price_base_type; $tva_tx = $prodcustprice->lines [0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr=0; } } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a97b553aed4..83c38477f28 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3748,6 +3748,7 @@ abstract class CommonObject // VAT Rate $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); + $this->tpl['vat_rate'] .= (($line->info_bits & 1) == 1) ? '*' : ''; if (! empty($line->vat_src_code) && ! preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'].=' ('.$line->vat_src_code.')'; $this->tpl['price'] = price($line->subprice); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 879b5745db4..bccfba4446d 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1321,7 +1321,7 @@ class Expedition extends CommonObject $sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked, cd.product_type"; $sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva"; - $sql.= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; + $sql.= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.info_bits, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; $sql.= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc"; $sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; $sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; @@ -1418,6 +1418,7 @@ class Expedition extends CommonObject $line->tva_tx = $obj->tva_tx; $line->localtax1_tx = $obj->localtax1_tx; $line->localtax2_tx = $obj->localtax2_tx; + $line->info_bits = $obj->info_bits; $line->price = $obj->price; $line->subprice = $obj->subprice; $line->remise_percent = $obj->remise_percent; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 5da8799d7b3..8b68929864f 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -382,6 +382,8 @@ ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_tx d ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price double(24,8) DEFAULT NULL; ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price_ttc double(24,8) DEFAULT NULL; +ALTER TABLE llx_product_customer_price_log ADD COLUMN default_vat_code varchar(10); + UPDATE llx_contrat SET ref = rowid WHERE ref IS NULL OR ref = ''; ALTER TABLE llx_contratdet ADD COLUMN vat_src_code varchar(10) DEFAULT ''; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 02f3f80982e..9c53b726544 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -366,6 +366,7 @@ TotalLT1IN=Total CGST TotalLT2IN=Total SGST HT=Net of tax TTC=Inc. tax +INCVATONLY=Inc. VAT INCT=Inc. all taxes VAT=Sales tax VATIN=IGST diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index f2115666a36..a4fb098f5ac 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -133,7 +133,7 @@ MovementLabel=Label of movement InventoryCode=Movement or inventory code IsInPackage=Contained into package WarehouseAllowNegativeTransfer=Stock can be negative -qtyToTranferIsNotEnough=You don't have enough stock from your source warehouse +qtyToTranferIsNotEnough=You don't have enough stock from your source warehouse and your setup does not allow negative stocks. ShowWarehouse=Show warehouse MovementCorrectStock=Stock correction for product %s MovementTransferStock=Stock transfer of product %s into another warehouse diff --git a/htdocs/product/price.php b/htdocs/product/price.php index f16b716c9cc..b38aa15a694 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1800,8 +1800,15 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '' . $langs->trans("PriceBase") . ''; print '' . $langs->trans("VATRate") . ''; print '' . $langs->trans("HT") . ''; - print '' . $langs->trans("TTC") . ''; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '' . $langs->trans("INCT") . ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") + { + //print '' . $langs->trans("INCVATONLY") . ''; + print '' . $langs->trans("INCT") . ''; + } + else + { + print '' . $langs->trans("TTC") . ''; + } print '' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . ''; print '' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . ''; print '' . $langs->trans("ChangedBy") . ''; @@ -1843,20 +1850,28 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print "" . dol_print_date($line->datec, "dayhour") . ""; print '' . $langs->trans($line->price_base_type) . ""; print ''; -var_dump($prodcustprice);exit; + $positiverates=''; - if (price2num($objp->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($objp->tva_tx); - if (price2num($objp->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($objp->localtax1_tx); - if (price2num($objp->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($objp->localtax2_tx); + if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); + if (price2num($line->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); + if (price2num($line->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); if (empty($positiverates)) $positiverates='0'; - echo vatrate($positiverates.($objp->default_vat_code?' ('.$objp->default_vat_code.')':''), '%', $objp->tva_npr); + + echo vatrate($positiverates.($line->default_vat_code?' ('.$line->default_vat_code.')':''), '%', ($line->tva_npr?$line->tva_npr:$line->recuperableonly)); //. vatrate($tva_tx, true, $line->recuperableonly) . print ""; print '' . price($line->price) . ""; - print '' . price($line->price_ttc) . ""; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '' . price($resultarray[2]) . ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") + { + //print '' . price($line->price_ttc) . ""; + print '' . price($resultarray[2]) . ''; + } + else + { + print '' . price($line->price_ttc) . ""; + } print '' . price($line->price_min) . ''; print '' . price($line->price_min_ttc) . ''; @@ -1902,7 +1917,7 @@ var_dump($prodcustprice);exit; if (count($prodcustprice->lines) > 0 || $search_soc) { $colspan=8; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++; + //if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++; print ''; print ''; @@ -1921,8 +1936,16 @@ var_dump($prodcustprice);exit; print '' . $langs->trans("PriceBase") . ''; print '' . $langs->trans("VATRate") . ''; print '' . $langs->trans("HT") . ''; - print '' . $langs->trans("TTC") . ''; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '' . $langs->trans("INCT") . ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") + { + //print '' . $langs->trans("INCVATONLY") . ''; + print '' . $langs->trans("INCT") . ''; + } + else + { + print '' . $langs->trans("TTC") . ''; + } + print '' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . ''; print '' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . ''; print '' . $langs->trans("ChangedBy") . ''; @@ -1969,9 +1992,17 @@ var_dump($prodcustprice);exit; print ""; print '' . price($object->price) . ""; - print '' . price($object->price_ttc) . ""; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '' . price($resultarray[2]) . ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") + { + //print '' . price($object->price_ttc) . ""; + print '' . price($resultarray[2]) . ''; + } + else + { + print '' . price($object->price_ttc) . ""; + } + print '' . price($object->price_min) . ''; print '' . price($object->price_min_ttc) . ''; @@ -1992,7 +2023,6 @@ var_dump($prodcustprice);exit; } print "\n"; - if (count($prodcustprice->lines) > 0) { foreach ($prodcustprice->lines as $line) @@ -2037,13 +2067,20 @@ var_dump($prodcustprice);exit; if (price2num($line->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); if (price2num($line->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); if (empty($positiverates)) $positiverates='0'; - echo vatrate($positiverates.($line->default_vat_code?' ('.$line->default_vat_code.')':''), '%', $line->tva_npr); + echo vatrate($positiverates.($line->default_vat_code?' ('.$line->default_vat_code.')':''), '%', ($line->tva_npr?$line->tva_npr:$line->recuperableonly)); print ""; print '' . price($line->price) . ""; - print '' . price($line->price_ttc) . ""; - if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '' . price($resultarray[2]) . ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") + { + //print '' . price($line->price_ttc) . ""; + print '' . price($resultarray[2]) . ''; + } + else + { + print '' . price($line->price_ttc) . ""; + } print '' . price($line->price_min) . ''; print '' . price($line->price_min_ttc) . ''; From a2c80a704f69316e65414b3ffac9388326d2d77d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Nov 2017 19:06:58 +0100 Subject: [PATCH 05/14] Code comment --- .../modules/import/import_xlsx.modules.php | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index eff3b8f8b21..22b81fcdcbf 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -20,9 +20,9 @@ */ /** - * \file htdocs/core/modules/import/import_csv.modules.php + * \file htdocs/core/modules/import/import_xlsx.modules.php * \ingroup import - * \brief File to load import files with CSV format + * \brief File to load import files with Excel format */ require_once DOL_DOCUMENT_ROOT .'/core/modules/import/modules_import.php'; @@ -54,10 +54,10 @@ class ImportXlsx extends ModeleImports var $cacheconvert=array(); // Array to cache list of value found after a convertion var $cachefieldtable=array(); // Array to cache list of value found into fields@tables - + var $workbook; // temporary import file var $record; // current record - var $headers; + var $headers; /** @@ -95,7 +95,7 @@ class ImportXlsx extends ModeleImports if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db); } - + /** * Output header of an example file for this format * @@ -144,7 +144,7 @@ class ImportXlsx extends ModeleImports foreach($headerlinefields as $field) { $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($col, 1, $outputlangs->transnoentities($field)); // set autowidth - //$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($col + 1))->setAutoSize(true); + //$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($col + 1))->setAutoSize(true); $col++; } return ''; // final output will be generated in footer @@ -211,10 +211,10 @@ class ImportXlsx extends ModeleImports return $ret; } - + /** * Return nb of records. File must be closed. - * + * * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ @@ -222,15 +222,15 @@ class ImportXlsx extends ModeleImports { $reader = new PHPExcel_Reader_Excel2007(); $this->workbook = $reader->load($file); - + $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow(); - + $this->workbook->disconnectWorksheets(); unset($this->workbook); - + return $rowcount; } - + /** * Input header line from file @@ -399,7 +399,7 @@ class ImportXlsx extends ModeleImports if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i',$newval)) $isidorref='ref'; $newval=preg_replace('/^(id|ref):/i','',$newval); // Remove id: or ref: that was used to force if field is id or ref //print 'Val is now '.$newval.' and is type '.$isidorref."
\n"; - + if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor { $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); @@ -502,9 +502,9 @@ class ImportXlsx extends ModeleImports } if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; $newval=$defaultref; - } - - + } + + elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') { $newval = price2num($newval); @@ -616,7 +616,7 @@ class ImportXlsx extends ModeleImports // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) if (empty($lastinsertid)) { $sqlSelect = 'SELECT rowid FROM '.$tablename; - + $data = array_combine($listfields, $listvalues); $where = array(); $filters = array(); @@ -627,7 +627,7 @@ class ImportXlsx extends ModeleImports $filters[] = $col.' = '.$data[$key]; } $sqlSelect.= ' WHERE '.implode(' AND ', $where); - + $resql=$this->db->query($sqlSelect); if($resql) { $res = $this->db->fetch_object($resql); @@ -650,23 +650,23 @@ class ImportXlsx extends ModeleImports $error++; } } - + if (!empty($lastinsertid)) { // Build SQL UPDATE request $sqlstart = 'UPDATE '.$tablename; - + $data = array_combine($listfields, $listvalues); $set = array(); foreach ($data as $key => $val) { $set[] = $key.' = '.$val; } $sqlstart.= ' SET '.implode(', ', $set); - + if(empty($keyfield)) $keyfield = 'rowid'; $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; - + $sql = $sqlstart.$sqlend; - + // Run update request $resql=$this->db->query($sql); if($resql) { @@ -691,14 +691,14 @@ class ImportXlsx extends ModeleImports if (! empty($tablewithentity_cache[$tablename])) { $sqlstart.= ', entity'; $sqlend.= ', '.$conf->entity; - } + } if (! empty($objimport->array_import_tables_creator[0][$alias])) { $sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias]; $sqlend.=', '.$user->id; } $sql = $sqlstart.$sqlend.')'; dol_syslog("import_xlsx.modules", LOG_DEBUG); - + // Run insert request if ($sql) { From a50589c3c9e72e6423366108f07f41698ab7552f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 14 Nov 2017 15:10:46 +0100 Subject: [PATCH 06/14] NEW Better behaviour when using a text browser --- htdocs/core/class/html.formother.class.php | 6 +++++- htdocs/core/menus/standard/auguria.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/core/search_page.php | 11 +++++------ htdocs/main.inc.php | 16 ++++++++++++---- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 432a7bb37de..565cd4310b4 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1023,7 +1023,11 @@ class FormOther $selectboxlist.=Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone', 0, 'hidden selected', 0, 1); if (empty($conf->use_javascript_ajax)) $selectboxlist.=' '; $selectboxlist.=''; - $selectboxlist.=ajax_combobox("boxcombo"); + if (! empty($conf->use_javascript_ajax)) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $selectboxlist.=ajax_combobox("boxcombo"); + } } // Javascript code for dynamic actions diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index ebd64b36a3c..90089488389 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -298,7 +298,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM print ''."\n"; } - if (is_array($moredata) && ! empty($moredata['searchform'])) + if (is_array($moredata) && ! empty($moredata['searchform'])) // searchform can contains select2 code or link to show old search form or link to switch on search page { print "\n"; print "\n"; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 9e88767f473..1f8529257d2 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -484,7 +484,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu print ''."\n"; } - if (is_array($moredata) && ! empty($moredata['searchform']) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (is_array($moredata) && ! empty($moredata['searchform'])) // searchform can contains select2 code or link to show old search form or link to switch on search page { print "\n"; print "\n"; diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index eb873d0e8f9..83ef016d3a9 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2017 Laurent Destailleur * * This file is a modified version of datepicker.php from phpBSM to fix some * bugs, to add new features and to dramatically increase speed. @@ -20,7 +20,7 @@ /** * \file htdocs/core/search_page.php - * \brief File to return search box + * \brief File to return a page with search boxes */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language @@ -78,7 +78,8 @@ if ($conf->use_javascript_ajax && 1 == 2) // select2 is ko with jmobile else { $usedbyinclude = 1; // Used into next include - include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; + $showtitlebefore = GETPOST('showtitlebefore','int'); + include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; $accesskeyalreadyassigned=array(); foreach($arrayresult as $key => $val) @@ -94,7 +95,7 @@ else $accesskey=$val['label'][0]; $accesskeyalreadyassigned[$accesskey]=$accesskey; } - $searchform.=printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, img_picto('',$val['img'],'', 0, 1)); + $searchform.=printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, img_picto('',$val['img'],'', 0, 1), $showtitlebefore); } } @@ -112,11 +113,9 @@ print "\n"; print "\n"; print '
'; print ''; -//print '
'; print '
'."\n"; print $searchform; print '
'."\n"; -//print '
'; print '
'; print "\n\n"; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 1d049e670c9..a4654713208 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1589,9 +1589,9 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra print "\n".''."\n".'
'."\n"; - print "\n"; + if ($conf->browser->layout == 'phone') $conf->global->MAIN_USE_OLD_SEARCH_FORM=1; // Select into select2 is awfull on smartphone. TODO Is this still true with select2 v4 ? - if ($conf->browser->layout == 'phone') $conf->global->MAIN_USE_OLD_SEARCH_FORM=1; // Select into select2 is awfull on smartphone + print "\n"; if ($conf->use_javascript_ajax && empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) { if (! is_object($form)) $form=new Form($db); @@ -1621,7 +1621,13 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra } else $searchform=$hookmanager->resPrint; - if ($conf->use_javascript_ajax && ! empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) + // Force special value for $searchform + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $urltosearch=DOL_URL_ROOT.'/core/search_page.php?showtitlebefore=1'; + $searchform='
'; + } + elseif ($conf->use_javascript_ajax && ! empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) { $searchform='
'; $searchform.='