From 7025d3839a8ad3e13155f631ac09644917376479 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 29 Dec 2019 09:56:03 +0100 Subject: [PATCH 01/16] =?UTF-8?q?Remove=20=E2=82=AC=20+=20unsed=20code=20a?= =?UTF-8?q?nd=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/loan/card.php | 14 -- htdocs/loan/createschedule.php | 228 --------------------------------- htdocs/loan/schedule.php | 16 +-- 3 files changed, 8 insertions(+), 250 deletions(-) delete mode 100644 htdocs/loan/createschedule.php diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index aeb4f77550b..20d07afc083 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -425,18 +425,6 @@ if ($id > 0) dol_fiche_head($head, 'card', $langs->trans("Loan"), -1, 'bill'); - print ''; - - // Loan card $linkback = ''.$langs->trans("BackToList").''; @@ -792,8 +780,6 @@ if ($id > 0) // Edit if ($object->paid == 0 && $user->rights->loan->write) { - // print ''.$langs->trans('CreateCalcSchedule').''; - print '
'.$langs->trans("Modify").'
'; } diff --git a/htdocs/loan/createschedule.php b/htdocs/loan/createschedule.php deleted file mode 100644 index ccd6026580b..00000000000 --- a/htdocs/loan/createschedule.php +++ /dev/null @@ -1,228 +0,0 @@ - - * Copyright (C) 2018 Alexandre Spangaro - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/loan/createschedule.php - * \ingroup loan - * \brief Schedule card - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; - -$loanid = GETPOST('loanid', 'int'); -$action = GETPOST('action', 'aZ09'); - -$object = new Loan($db); -$object->fetch($loanid); - -// Load translation files required by the page -$langs->loadLangs(array("compta", "bills", "loan")); - -if ($action == 'createecheancier') { - $i = 1; - while ($i < $object->nbterm + 1) { - $date = GETPOST('hi_date'.$i, 'int'); - $mens = GETPOST('mens'.$i); - $int = GETPOST('hi_interets'.$i); - $insurance = GETPOST('hi_insurance'.$i); - - $echeance = new LoanSchedule($db); - - $echeance->fk_loan = $object->id; - $echeance->datec = dol_now(); - $echeance->tms = dol_now(); - $echeance->datep = $date; - $echeance->amount_capital = $mens - $int; - $echeance->amount_insurance = $insurance; - $echeance->amount_interest = $int; - $echeance->fk_typepayment = 3; - $echeance->fk_bank = 0; - $echeance->fk_user_creat = $user->id; - $echeance->fk_user_modif = $user->id; - $result = $echeance->create($user); - if ($result < 0) { - setEventMessages($echeance->error, $echeance->errors, 'errors'); - } - $i++; - } -} - -if ($action == 'updateecheancier') { - $i = 1; - while ($i < $object->nbterm + 1) { - $mens = GETPOST('mens'.$i); - $int = GETPOST('hi_interets'.$i); - $id = GETPOST('hi_rowid'.$i); - $insurance = GETPOST('hi_insurance'.$i); - - $echeance = new LoanSchedule($db); - $echeance->fetch($id); - $echeance->tms = dol_now(); - $echeance->amount_capital = $mens - $int; - $echeance->amount_insurance = $insurance; - $echeance->amount_interest = $int; - $echeance->fk_user_modif = $user->id; - $result = $echeance->update($user, 0); - if ($result < 0) { - setEventMessages(null, $echeance->errors, 'errors'); - } - $i++; - } -} - -$echeance = new LoanSchedule($db); -$echeance->fetchAll($object->id); - -top_htmlhead('', ''); -$var = !$var; - - -?> - -'; -print ''; -print ''; -if (count($echeance->lines) > 0) -{ - print ''; -} else { - print ''; -} -print ''; -print ''; -$colspan = 6; -if (count($echeance->lines) > 0) $colspan++; -print ''; -print ''; - -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -if (count($echeance->lines) > 0) print ''; -print ''."\n"; - -if ($object->nbterm > 0 && count($echeance->lines) == 0) -{ - $i = 1; - $capital = $object->capital; - $insurance = $object->insurance_amount / $object->nbterm; - $insurance = price2num($insurance, 'MT'); - $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); - while ($i < $object->nbterm + 1) - { - $mens = price2num($echeance->calcMonthlyPayments($capital, $object->rate / 100, $object->nbterm - $i + 1), 'MT'); - $int = ($capital * ($object->rate / 12)) / 100; - $int = price2num($int, 'MT'); - $cap_rest = price2num($capital - ($mens - $int), 'MT'); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''."\n"; - $i++; - $capital = $cap_rest; - } -} -elseif (count($echeance->lines) > 0) -{ - $i = 1; - $capital = $object->capital; - $insurance = $object->insurance_amount / $object->nbterm; - $insurance = price2num($insurance, 'MT'); - $regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm)); - foreach ($echeance->lines as $line) { - $mens = $line->amount_capital + $line->amount_insurance + $line->amount_interest; - $int = $line->amount_interest; - $cap_rest = price2num($capital - ($mens - $int), 'MT'); - print ''; - print ''; - print ''; - print ''; - print ''; - if ($line->datep > dol_now()) { - print ''; - } else { - print ''; - } - - print ''; - print ''; - print ''."\n"; - $i++; - $capital = $cap_rest; - } -} - -print '
'; -print $langs->trans("FinancialCommitment"); -print '
'.$langs->trans("Term").''.$langs->trans("Date").''.$langs->trans("Insurance"); -print ''.$langs->trans("InterestAmount").''.$langs->trans("Amount").''.$langs->trans("CapitalRemain"); -print ' ('.price2num($object->capital).')'; -print ''; -print ''.$langs->trans('DoPayment').'
'.$i.''.dol_print_date(dol_time_plus_duree($object->datestart, $i - 1, 'm'), 'day').''.price($insurance + (($i == 1) ? $regulInsurance : 0), 0, '', 1).' €'.price($int, 0, '', 1).' €'.price($cap_rest).' €
'.$i.''.dol_print_date($line->datep, 'day').''.price($insurance + (($i == 1) ? $regulInsurance : 0), 0, '', 1).' €'.price($int, 0, '', 1).' €'.price($mens).' €'.price($cap_rest).' €'.$langs->trans('DoPayment').'
'; -print '
'; -print '
'; -print '
'; -print ''; - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php index a951b9c9b0f..fb3cd86ebe3 100644 --- a/htdocs/loan/schedule.php +++ b/htdocs/loan/schedule.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/loan/createschedule.php + * \file htdocs/loan/schedule.php * \ingroup loan * \brief Schedule card */ @@ -229,10 +229,10 @@ if ($object->nbterm > 0 && count($echeance->lines) == 0) print ''; print ''.$i.''; print ''.dol_print_date(dol_time_plus_duree($object->datestart, $i - 1, 'm'), 'day').''; - print ''.price($insurance + (($i == 1) ? $regulInsurance : 0), 0, '', 1, -1, -1, $conf->currency).' €'; - print ''.price($int, 0, '', 1, -1, -1, $conf->currency).' €'; - print ' €'; - print ''.price($cap_rest).' €'; + print ''.price($insurance + (($i == 1) ? $regulInsurance : 0), 0, '', 1, -1, -1, $conf->currency).''; + print ''.price($int, 0, '', 1, -1, -1, $conf->currency).''; + print ''; + print ''.price($cap_rest).''; print ''."\n"; $i++; $capital = $cap_rest; @@ -255,10 +255,10 @@ elseif (count($echeance->lines) > 0) print ''; print ''.$i.''; print ''.dol_print_date($line->datep, 'day').''; - print ''.price($insu, 0, '', 1, -1, -1, $conf->currency).' €'; - print ''.price($int, 0, '', 1, -1, -1, $conf->currency).' €'; + print ''.price($insu, 0, '', 1, -1, -1, $conf->currency).''; + print ''.price($int, 0, '', 1, -1, -1, $conf->currency).''; if ($line->datep > dol_now() && empty($line->fk_bank)) { - print ' €'; + print ''; } else { print ''.price($mens, 0, '', 1, -1, -1, $conf->currency).''; } From 83ada939d569e3b6bad563f7ff324a41539f0354 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 9 Jan 2020 16:26:30 +0100 Subject: [PATCH 02/16] fix warning --- htdocs/conf/conf.php.example | 0 htdocs/conf/index.html | 0 htdocs/core/class/dolgraph.class.php | 5 ++++- 3 files changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 htdocs/conf/conf.php.example mode change 100644 => 100755 htdocs/conf/index.html diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example old mode 100644 new mode 100755 diff --git a/htdocs/conf/index.html b/htdocs/conf/index.html old mode 100644 new mode 100755 diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 37f1d6036c6..5b477ace9c8 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -899,7 +899,10 @@ class DolGraph } $legends=array(); - $nblot=count($this->data[0])-1; // -1 to remove legend + $nblot=0; + if (is_array($this->data) && is_array($this->data[0])) { + $nblot=count($this->data[0])-1; // -1 to remove legend + } if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING); $firstlot=0; // Works with line but not with bars From e0dfe894f535c9f6e1b781d35b68559db2ddb6f7 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 9 Jan 2020 16:45:17 +0100 Subject: [PATCH 03/16] fix warning --- htdocs/conf/conf.php.example | 0 htdocs/conf/index.html | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 htdocs/conf/conf.php.example mode change 100755 => 100644 htdocs/conf/index.html diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example old mode 100755 new mode 100644 diff --git a/htdocs/conf/index.html b/htdocs/conf/index.html old mode 100755 new mode 100644 From 67d73c54882b616101fadf81a5ffef8c9bed76c4 Mon Sep 17 00:00:00 2001 From: Laurent De Coninck Date: Sun, 12 Jan 2020 21:52:42 +0100 Subject: [PATCH 04/16] Fix the select of the provider for one product --- htdocs/product/stock/replenish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 438bcaa79af..5164b72fa4a 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -724,7 +724,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) // Supplier print ''; - $form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier); + print $form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier); print ''; // Fields from hook From 66e08103de4cae0f6f7ab2111e653ef202d998d3 Mon Sep 17 00:00:00 2001 From: Laurent De Coninck Date: Mon, 13 Jan 2020 10:43:39 +0100 Subject: [PATCH 05/16] change the PHPdoc --- htdocs/core/class/html.form.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9bd402a1485..fbd00c99281 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3008,7 +3008,8 @@ class Form * @param int $productid Id of product * @param string $htmlname Name of HTML field * @param int $selected_supplier Pre-selected supplier if more than 1 result - * @return void + * + * @return string */ public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') { From 5740d174508779b4df2f73a06b1fb8064b3bf270 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Jan 2020 12:10:20 +0100 Subject: [PATCH 06/16] Better help --- htdocs/admin/emailcollector_card.php | 6 +++++- htdocs/emailcollector/class/emailcollector.class.php | 2 +- htdocs/langs/en_US/admin.lang | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 09871ee1276..49217b55963 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -595,13 +595,17 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; + print ''; print $langs->trans($arrayoftypes[$ruleaction['type']]); if (in_array($ruleaction['type'], array('recordevent'))) { print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked')); } + elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) { + print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp')); + } print ''; - print ''; + print ''; if ($action == 'editoperation' && $ruleaction['id'] == $operationid) { print '
'; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index d988711ae12..7e957385e60 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -106,7 +106,7 @@ class EmailCollector extends CommonObject 'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>103, 'notnull'=>1, 'default' => 'Inbox', 'help'=>'Example: INBOX'), //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), - 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'comment'=>"Where to store messages once processed"), + 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'help'=>"EmailCollectorTargetDir"), 'maxemailpercollect' => array('type'=>'integer', 'label'=>'MaxEmailCollectPerCollect', 'visible'=>-1, 'enabled'=>1, 'position'=>111, 'default'=>100), 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastCollectResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1,), 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4be8392bdce..011bb0b613d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1954,6 +1954,8 @@ SmallerThan=Smaller than LargerThan=Larger than IfTrackingIDFoundEventWillBeLinked=Note that If a tracking ID is found into incoming email, the event will be automatically linked to the related objects. WithGMailYouCanCreateADedicatedPassword=With a GMail account, if you enabled the 2 steps validation, it is recommanded to create a dedicated second password for the application instead of using your own account passsword from https://myaccount.google.com/. +EmailCollectorTargetDir=It may be a desired behaviour to move the email into another tag/directory when it was processed successfully. Just set a value here to use this feature. Note that you must also use a read/write login account. +EmailCollectorLoadThirdPartyHelp=You can use this action to use the email content to find and load an existing thirdparty in your database. The found (or created) thirdparty will be used for following actions that need it. In the parameter field you can use for example 'EXTRACT:BODY:Name:\s([^\s]*)' if you want to extract the name of the thirdparty from a string 'Name: name to find' found into the body. EndPointFor=End point for %s : %s DeleteEmailCollector=Delete email collector ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector? From bfa13e16ed3ba4c0036b66539402df857258adad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Jan 2020 12:30:48 +0100 Subject: [PATCH 07/16] Debug MO module --- ChangeLog | 2 +- htdocs/mrp/mo_production.php | 31 ++++++++++++++----- .../product/stock/class/productlot.class.php | 6 ++-- htdocs/product/stock/productlot_card.php | 8 ++--- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 020367a5453..49bb05ea2c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,7 @@ English Dolibarr ChangeLog For Users: NEW: Module BOM is now stable. -NEW: Module MO - Manufacturing Order available with experimental status. +NEW: Module MO (Manufacturing Order) is available with experimental status. NEW: Can set the Address/Contact by default on third parties. NEW: Add a dictionary to edit list of Social networks. NEW: A nicer dashboard for open elements on Home page. diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index e3b5e159913..0d7fb48e45c 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -50,6 +50,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; dol_include_once('/mrp/class/mo.class.php'); dol_include_once('/mrp/lib/mrp_mo.lib.php'); @@ -371,10 +372,10 @@ if (empty($reshook)) */ $form = new Form($db); -$formfile = new FormFile($db); $formproject = new FormProjets($db); $formproduct = new FormProduct($db); $tmpwarehouse = new Entrepot($db); +$tmpbatch = new Productlot($db); llxHeader('', $langs->trans('Mo'), ''); @@ -606,7 +607,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print load_fiche_titre($langs->trans('Consumption'), '', ''); print '
'; - print ''; + print '
'; print ''; print ''; @@ -664,7 +665,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea jQuery("#expandtoproduce'.$line->id.'").click(function() { console.log("Expand mrp_production line '.$line->id.'"); jQuery(".expanddetail'.$line->id.'").toggle();'; - if ($nblinetoconsume == $nblinetoconsumecursor) { + if ($nblinetoconsume == $nblinetoconsumecursor) { // If it is the last line print 'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }'; } print ' @@ -674,6 +675,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($conf->use_javascript_ajax)) print 'id.'">'; print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"'); if (empty($conf->use_javascript_ajax)) print ''; + } else { + if ($nblinetoconsume == $nblinetoconsumecursor) { // If it is the last line + print ''; + } } print ' '.$alreadyconsumed; print ''; @@ -695,10 +700,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; + // Lot Batch + print ''; - print ''; print ''; } @@ -721,6 +732,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } else { print ''.$langs->trans("NoStockChangeOnServices").''; } + // Lot / Batch print ''; if ($conf->productbatch->enabled) { print ''; + print ''; - print ''; print ''; } diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index e2d954b2847..d02d1599dbc 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -220,9 +220,9 @@ class Productlot extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object - * @param int $product_id Id of product, batch number parameter required - * @param string $batch batch number + * @param int $id Id of lot/batch + * @param int $product_id Id of product, batch number parameter required + * @param string $batch batch number * * @return int <0 if KO, 0 if not found, >0 if OK */ diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index c4ec988b269..c3eb7523e7d 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -336,17 +336,17 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Eat by print ''; print ''; // Sell by print ''; print ''; From 9c9b73e4d1de4d2dd0cd51c32a80ee28a311c87e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Jan 2020 13:11:25 +0100 Subject: [PATCH 08/16] Fix translation of \n and \\s into language files. --- htdocs/core/class/translate.class.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 4f6d6750040..0ce761d12b8 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -291,7 +291,6 @@ class Translate //if ($key == 'Order') print "Domain=$domain, found a string for key=$key=$tab[0] with value $tab[1]. Currently in cache ".$this->tab_translate[$key]."
"; if (empty($this->tab_translate[$key])) { // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries) - $value = preg_replace('/\\n/', "\n", $value); // Parse and render carriage returns if ($key == 'DIRECTION') { // This is to declare direction of language if ($alt < 2 || empty($this->tab_translate[$key])) { // We load direction only for primary files or if not yet loaded $this->tab_translate[$key] = $value; @@ -307,8 +306,8 @@ class Translate continue; } else { - $this->tab_translate[$key] = $value; - //if ($domain == 'orders') print "$tab[0] value $value
"; + // Convert some strings: Parse and render carriage returns. Also, change '\\s' int '\s' because transifex sync pull the string '\s' into string '\\s' + $this->tab_translate[$key] = str_replace(array('\\n', '\\\\s'), array("\n", '\s'), $value); if ($usecachekey) { $tabtranslatedomain[$key] = $value; } // To save lang content in cache @@ -491,9 +490,9 @@ class Translate //print "Domain=$domain, found a string for $tab[0] with value $tab[1]
"; if (empty($this->tab_translate[$key])) // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries) { - $value=trim(preg_replace('/\\n/', "\n", $value)); + // Convert some strings: Parse and render carriage returns. Also, change '\\s' int '\s' because transifex sync pull the string '\s' into string '\\s' + $this->tab_translate[$key] = str_replace(array('\\n', '\\\\s'), array("\n", '\s'), $value); - $this->tab_translate[$key]=$value; if ($usecachekey) $tabtranslatedomain[$key]=$value; // To save lang content in cache } @@ -618,9 +617,8 @@ class Translate } } - if (! preg_match('/^Format/', $key)) + if (strpos($key, 'Format') !== 0) { - //print $str; $str=sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings. } From ccdee44ed130c67f10b7be13998c7a99e94db6e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Jan 2020 13:35:29 +0100 Subject: [PATCH 09/16] Look and feel v11 --- htdocs/loan/list.php | 110 +++++++++++++----- .../modulebuilder/template/myobject_list.php | 2 +- 2 files changed, 85 insertions(+), 27 deletions(-) diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index d1a01cd11b1..3b1ccfd2724 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -36,13 +36,18 @@ if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'loan', '', '', ''); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; + +// Initialize technical objects +$loan_static = new Loan($db); +$extrafields = new ExtraFields($db); + if (!$sortfield) $sortfield = "l.rowid"; if (!$sortorder) $sortorder = "DESC"; @@ -53,12 +58,27 @@ $search_amount = GETPOST('search_amount', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search $optioncss = GETPOST('optioncss', 'alpha'); -// Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - $search_ref = ""; - $search_label = ""; - $search_amount = ""; + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_ref = ""; + $search_label = ""; + $search_amount = ""; + } } @@ -66,9 +86,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', * View */ -$loan_static = new Loan($db); +$now = dol_now(); -llxHeader(); +//$help_url="EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject"; +$help_url = ''; +$title = $langs->trans('Loans'); $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.paid,"; $sql .= " SUM(pl.amount_capital) as alreadypayed"; @@ -81,25 +103,45 @@ if ($search_label) $sql .= natural_search("l.label", $search_label); $sql .= " GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend"; $sql .= $db->order($sortfield, $sortorder); +// Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 { $page = 0; $offset = 0; } } -$sql.= $db->plimit($limit+1, $offset); +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) +{ + $num = $nbtotalofrecords; +} +else +{ + if ($limit) $sql .= $db->plimit($limit + 1, $offset); + + $resql = $db->query($sql); + if (!$resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); +} + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); -//print $sql; -$resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); $i = 0; $param=''; @@ -116,13 +158,15 @@ if ($resql) $newcardbutton.= dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/loan/card.php?action=create'); } - print '
'."\n"; + print ''."\n"; if ($optioncss != '') print ''; print ''; + print ''; print ''; print ''; print ''; print ''; + print ''; print ''; print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, $newcardbutton, '', $limit); @@ -146,6 +190,8 @@ if ($resql) print ''; print ''; + // Fields title label + // -------------------------------------------------------------------- print '
'; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "l.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "l.label", "", $param, '', $sortfield, $sortorder, 'left '); @@ -156,9 +202,15 @@ if ($resql) print_liste_field_titre(''); print "\n"; + // Loop on record + // -------------------------------------------------------------------- + $i = 0; + $totalarray = array(); while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + $loan_static->id = $obj->rowid; $loan_static->ref = $obj->rowid; $loan_static->label = $obj->label; @@ -166,19 +218,19 @@ if ($resql) print ''; // Ref - print ''; + print ''; // Label print ''; // Capital - print ''; + print ''; // Date start - print ''; + print ''; // Date end - print ''; + print ''; print ''; @@ -197,9 +249,15 @@ if ($resql) print ''; } - print "
'.$langs->trans("Product").''; if ($line2['fk_warehouse'] > 0) { $tmpwarehouse->fetch($line2['fk_warehouse']); - print $tmpwarehouse->getNomUrl(); + print $tmpwarehouse->getNomUrl(1); + } + print ''; + if ($line2['batch'] != '') { + $tmpbatch->fetch(0, $line2['fk_product'], $line2['batch']); + print $tmpbatch->getNomUrl(1); } print ''.$line2['batch'].'
'; @@ -826,10 +838,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if ($line2['fk_warehouse'] > 0) { $tmpwarehouse->fetch($line2['fk_warehouse']); - print $tmpwarehouse->getNomUrl(); + print $tmpwarehouse->getNomUrl(1); + } + print ''; + if ($line2['batch'] != '') { + $tmpbatch->fetch(0, $line2['fk_product'], $line2['batch']); + print $tmpbatch->getNomUrl(1); } print ''.$line2['batch'].'
'; - print $form->editfieldkey($langs->trans('Eatby'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); print ''; - print $form->editfieldval($langs->trans('Eatby'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); print '
'; - print $form->editfieldkey($langs->trans('Sellby'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); print ''; - print $form->editfieldval($langs->trans('Sellby'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); print '
'.$loan_static->getNomUrl(1, 42).''.$loan_static->getNomUrl(1).''.dol_trunc($obj->label, 42).''.price($obj->capital).''.price($obj->capital).''.dol_print_date($db->jdate($obj->datestart), 'day').''.dol_print_date($db->jdate($obj->datestart), 'day').''.dol_print_date($db->jdate($obj->dateend), 'day').''.dol_print_date($db->jdate($obj->dateend), 'day').''.$loan_static->LibStatut($obj->paid, 5, $obj->alreadypayed).'
'.$langs->trans("NoRecordFound").'
"; - print '
'; - print "\n"; + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print ''."\n"; + print ''."\n"; + + print ''."\n"; + $db->free($resql); } else diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 70f550e4ba1..09c90aba987 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -360,7 +360,7 @@ if ($permissiontodelete) $arrayofmassactions['predelete'] = ''; +print '
'."\n"; if ($optioncss != '') print ''; print ''; print ''; From 9ceec670b9300319315b1ed9b1b3c7ca0729d398 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Jan 2020 13:52:48 +0100 Subject: [PATCH 10/16] Fix date format in FEC export --- htdocs/accountancy/class/accountancyexport.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index f36b98b15b1..46b7a532a35 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -704,9 +704,9 @@ class AccountancyExport print $end_line; foreach ($objectLines as $line) { - $date_creation = dol_print_date($line->date_creation, '%d%m%Y'); - $date_doc = dol_print_date($line->doc_date, '%d%m%Y'); - $date_valid = dol_print_date($line->date_validated, '%d%m%Y'); + $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); + $date_doc = dol_print_date($line->doc_date, '%Y%m%d'); + $date_valid = dol_print_date($line->date_validated, '%Y%m%d'); // FEC:JournalCode print $line->code_journal.$separator; From b6ed6df75d89e6ec55f1fb55a823f24a1563441b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Jan 2020 14:14:51 +0100 Subject: [PATCH 11/16] Remove property tha has no sense in output #12803 --- htdocs/societe/class/api_thirdparties.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index c855346dbec..07dd2ba6031 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1685,6 +1685,8 @@ class Thirdparties extends DolibarrApi unset($object->particulier); unset($object->prefix_comm); + unset($object->commercial_id); // This property is used in create/update only. It does not exists in read mode because there is several sales representatives. + unset($object->total_ht); unset($object->total_tva); unset($object->total_localtax1); From 9d4e1a3941d0d1a099193f96cdb91474a70aa04a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Jan 2020 14:25:48 +0100 Subject: [PATCH 12/16] FIX #12797 --- htdocs/core/lib/functions.lib.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8980f2a41dd..861b49adde2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1639,13 +1639,14 @@ function dol_bc($var, $moreclass = '') } /** - * Return a formated address (part address/zip/town/state) according to country rules + * Return a formated address (part address/zip/town/state) according to country rules. + * See https://en.wikipedia.org/wiki/Address * * @param Object $object A company or contact object - * @param int $withcountry 1=Add country into address string - * @param string $sep Separator to use to build string - * @param Translate $outputlangs Object lang that contains language for text translation. - * @param int $mode 0=Standard output, 1=Remove address + * @param int $withcountry 1=Add country into address string + * @param string $sep Separator to use to build string + * @param Translate $outputlangs Object lang that contains language for text translation. + * @param int $mode 0=Standard output, 1=Remove address * @return string Formated string * @see dol_print_address() */ @@ -1656,6 +1657,8 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs $ret = ''; $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS + // See format of addresses on https://en.wikipedia.org/wiki/Address + // Address if (empty($mode)) { $ret .= $object->address; @@ -1692,7 +1695,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs { $ret .= ($ret ? $sep : '').$object->zip; $ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : ''); - $ret .= ($object->state_id ? (' ('.($object->state_id).')') : ''); + $ret .= ($object->state_code ? (' '.($object->state_code)) : ''); } else // Other: title firstname name \n address lines \n zip town \n country { From ab4e0fe99cddfcd3c5c7b62025aa6e2de36edfc9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Jan 2020 14:30:37 +0100 Subject: [PATCH 13/16] FIX #12758 --- build/generate_filelist_xml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index 59a39416b28..976f2cb6ba3 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -146,7 +146,7 @@ $iterator1 = new RecursiveIteratorIterator($dir_iterator1); $files = new RegexIterator($iterator1, '#^(?:[A-Z]:)?(?:/(?!(?:'.($includecustom?'':'custom\/|').'documents\/|conf\/|install\/))[^/]+)+/[^/]+\.(?:php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$#i'); */ $regextoinclude='\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$'; -$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs +$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs $files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname'); $dir=''; $needtoclose=0; From 68169b6df045de3f0b8424c27f8fd644318a700f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Jan 2020 14:43:27 +0100 Subject: [PATCH 14/16] Fix debian package --- build/debian/source/include-binaries | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/debian/source/include-binaries b/build/debian/source/include-binaries index 401eae93712..021641d5c04 100644 --- a/build/debian/source/include-binaries +++ b/build/debian/source/include-binaries @@ -1 +1,2 @@ -htdocs/install/doctemplates/websites/website_template-corporate.zip \ No newline at end of file +htdocs/install/doctemplates/websites/website_template-corporate.zip +htdocs/install/doctemplates/websites/website_template-stellar.zip \ No newline at end of file From 56fb6dce6199a36a3e6780ce517058bbb1406cdf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Jan 2020 15:32:11 +0100 Subject: [PATCH 15/16] FIX #12756 --- htdocs/core/modules/modExpedition.class.php | 14 +++++++------- htdocs/core/modules/modSupplierProposal.class.php | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 96d3d3f45a5..93cd08c7001 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -65,8 +65,8 @@ class modExpedition extends DolibarrModules "/expedition/sending/temp", "/expedition/receipt", "/expedition/receipt/temp", - "/doctemplates/shipment", - "/doctemplates/delivery" + "/doctemplates/shipments", + "/doctemplates/deliveries" ); // Config pages @@ -98,7 +98,7 @@ class modExpedition extends DolibarrModules $this->const[$r][0] = "EXPEDITION_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/shipment"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/shipments"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -119,7 +119,7 @@ class modExpedition extends DolibarrModules $this->const[$r][0] = "LIVRAISON_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/delivery"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/deliveries"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; @@ -127,7 +127,7 @@ class modExpedition extends DolibarrModules $this->const[$r][0] = "MAIN_SUBMODULE_EXPEDITION"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "1"; - $this->const[$r][3] = "Enable shipments"; + $this->const[$r][3] = "Enable delivery receipts"; $this->const[$r][4] = 0; $r++; @@ -326,8 +326,8 @@ class modExpedition extends DolibarrModules $this->remove($options); //ODT template - $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/shipment'; + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/shipments/template_shipment.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/shipments'; $dest = $dirodt.'/template_shipment.odt'; if (file_exists($src) && !file_exists($dest)) diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index c24c3787a9c..e2d071ac730 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -93,7 +93,7 @@ class modSupplierProposal extends DolibarrModules $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_proposal"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_proposals"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; @@ -215,8 +215,8 @@ class modSupplierProposal extends DolibarrModules $this->remove($options); //ODT template - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_proposal/template_supplier_proposal.odt'; - $dirodt=DOL_DATA_ROOT.'/doctemplates/supplier_proposal'; + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_proposals/template_supplier_proposal.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/supplier_proposals'; $dest=$dirodt.'/template_supplier_proposal.odt'; if (file_exists($src) && ! file_exists($dest)) From e2e06b47fff965cf4833ebc2f233fde0f5942e63 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Jan 2020 15:58:03 +0100 Subject: [PATCH 16/16] FIX #12617 --- htdocs/commande/class/commande.class.php | 1 + htdocs/contrat/card.php | 14 +++++++------- htdocs/contrat/class/contrat.class.php | 23 ++++++++++++----------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ef15d983d20..a21e9534f49 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1447,6 +1447,7 @@ class Commande extends CommonOrder $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code + $reg = array(); $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index e61b0077ef7..9342a81395b 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2017 Juanjo Menent @@ -417,12 +417,12 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); - $price_ht = GETPOST('price_ht'); - $price_ht_devise = GETPOST('multicurrency_price_ht'); - if (GETPOST('prod_entry_mode') == 'free') + $price_ht = price2num(GETPOST('price_ht')); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht')); + if (GETPOST('prod_entry_mode', 'alpha') == 'free') { $idprod = 0; - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + $tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0); } else { @@ -430,7 +430,7 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); + $qty = price2num(GETPOST('qty'.$predef)); $remise_percent = ((GETPOST('remise_percent'.$predef) != '') ? GETPOST('remise_percent'.$predef) : 0); if ($qty == '') @@ -438,7 +438,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); $error++; } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) + if (GETPOST('prod_entry_mode', 'alpha') == 'free' && empty($idprod) && empty($product_desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); $error++; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 89ee93a39e8..ead2e1c816b 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1421,9 +1421,18 @@ class Contrat extends CommonObject $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); $pa_ht = price2num($pa_ht); - if (!preg_match('/\((.*)\)/', $txtva)) { - $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + + // Clean vat code + $reg = array(); + $vat_src_code = ''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } + + $txtva = price2num($txtva); + $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); $remise_percent = price2num($remise_percent); @@ -1456,15 +1465,7 @@ class Contrat extends CommonObject $this->db->begin(); - $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); - - // Clean vat code - $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } + $localtaxes_type = getLocalTaxesFromRate($txtva.($vat_src_code ? ' ('.$vat_src_code.')' : ''), 0, $this->societe, $mysoc); // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva