diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 1f38171f19937..0328eba010c79 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -38,6 +38,7 @@ $langs->loadLangs(array("accountancy", "bills", "compta")); $action = GETPOST('action', 'aZ09'); +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id', 'int'); // id of record $mode = GETPOST('mode', 'aZ09'); // '' or 'tmp' @@ -346,6 +347,8 @@ } print '
'; + if ($optioncss != '') print ''; + print ''; print '' . "\n"; print '' . "\n"; print '' . "\n"; @@ -441,7 +444,8 @@ print ''; if ($action == 'editdate') { print ''; - print ''; + if ($optioncss != '') print ''; + print ''; print ''; print ''; print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate"); @@ -464,7 +468,8 @@ print ''; if ($action == 'editjournal') { print ''; - print ''; + if ($optioncss != '') print ''; + print ''; print ''; print ''; print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1); @@ -487,7 +492,8 @@ print ''; if ($action == 'editdocref') { print ''; - print ''; + if ($optioncss != '') print ''; + print ''; print ''; print ''; print ''; @@ -583,6 +589,8 @@ print load_fiche_titre($langs->trans("ListeMvts"), '', ''); print ''; + if ($optioncss != '') print ''; + print ''; print '' . "\n"; print '' . "\n"; print '' . "\n"; diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 10ebabc4f8a23..347de02962fca 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -284,7 +284,6 @@ public function export(&$TData) * Export format : CEGID * * @param array $objectLines data - * * @return void */ public function exportCegid($objectLines) @@ -310,7 +309,6 @@ public function exportCegid($objectLines) * Export format : COGILOG * * @param array $objectLines data - * * @return void */ public function exportCogilog($objectLines) @@ -344,7 +342,6 @@ public function exportCogilog($objectLines) * Export format : COALA * * @param array $objectLines data - * * @return void */ public function exportCoala($objectLines) @@ -372,7 +369,6 @@ public function exportCoala($objectLines) * Export format : BOB50 * * @param array $objectLines data - * * @return void */ public function exportBob50($objectLines) @@ -411,7 +407,6 @@ public function exportBob50($objectLines) * Export format : CIEL * * @param array $TData data - * * @return void */ public function exportCiel(&$TData) @@ -452,7 +447,6 @@ public function exportCiel(&$TData) * Export format : Quadratus * * @param array $TData data - * * @return void */ public function exportQuadratus(&$TData) @@ -536,7 +530,6 @@ public function exportQuadratus(&$TData) * Export format : EBP * * @param array $objectLines data - * * @return void */ public function exportEbp($objectLines) @@ -573,7 +566,6 @@ public function exportEbp($objectLines) * Export format : Agiris Isacompta * * @param array $objectLines data - * * @return void */ public function exportAgiris($objectLines) @@ -614,7 +606,6 @@ public function exportAgiris($objectLines) * Export format : OpenConcerto * * @param array $objectLines data - * * @return void */ public function exportOpenConcerto($objectLines) @@ -644,16 +635,17 @@ public function exportOpenConcerto($objectLines) } /** - * Export format : Configurable + * Export format : Configurable CSV * * @param array $objectLines data - * * @return void */ public function exportConfigurable($objectLines) { global $conf; + $separator = $this->separator; + foreach ($objectLines as $line) { $tab = array(); // export configurable @@ -661,15 +653,14 @@ public function exportConfigurable($objectLines) $tab[] = $line->piece_num; $tab[] = $date; $tab[] = $line->doc_ref; - $tab[] = $line->label_operation; + $tab[] = preg_match('/'.$separator.'/', $line->label_operation) ? "'".$line->label_operation."'" : $line->label_operation; $tab[] = length_accountg($line->numero_compte); $tab[] = length_accounta($line->subledger_account); - $tab[] = price($line->debit); - $tab[] = price($line->credit); - $tab[] = price($line->montant); + $tab[] = price2num($line->debit); + $tab[] = price2num($line->credit); + $tab[] = price2num($line->montant); $tab[] = $line->code_journal; - $separator = $this->separator; print implode($separator, $tab) . $this->end_line; } } @@ -678,7 +669,6 @@ public function exportConfigurable($objectLines) * Export format : FEC * * @param array $objectLines data - * * @return void */ public function exportFEC($objectLines) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index e63aec50dca5e..c06314daa9aa1 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -446,8 +446,10 @@ function hideoptions () {
-
" id="buttonGo" />
+
+ " id="buttonGo"> + +

'.$langs->trans("BackupResult").': '; print $_SESSION["commandbackupresult"]; @@ -598,9 +600,6 @@ function hideoptions () { - - - trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod")))); + header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod"))).(GETPOST('page_y', 'int')?'&page_y='.GETPOST('page_y', 'int'):'')); exit; } @@ -122,25 +122,15 @@ // MYSQL if ($what == 'mysql') { - $cmddump=GETPOST("mysqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump=dol_sanitizePathName($cmddump); if (! empty($dolibarr_main_restrict_os_commands)) { $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); - $ok=0; dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); - foreach($arrayofallowedcommand as $allowedcommand) - { - $basenamecmddump=basename($cmddump); - if (preg_match('/^'.preg_quote($allowedcommand, '/').'$/', $basenamecmddump)) // the provided command $cmddump must be an allowed command - { - $ok=1; - break; - } - } - if (! $ok) + $basenamecmddump=basename($cmddump); + if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command { $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); } @@ -176,6 +166,18 @@ $cmddump=GETPOST("postgresqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump=dol_sanitizePathName($cmddump); + /* Not required, the command is output on screen but not ran for pgsql + if (! empty($dolibarr_main_restrict_os_commands)) + { + $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); + dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); + $basenamecmddump=basename($cmddump); + if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command + { + $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); + } + } */ + if (! $errormsg && $cmddump) { dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); @@ -193,7 +195,6 @@ } - if ($errormsg) { setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); @@ -230,8 +231,8 @@ print '
'; */ -// Redirect t backup page -header("Location: dolibarr_export.php"); +// Redirect to backup page +header("Location: dolibarr_export.php".(GETPOST('page_y', 'int')?'?page_y='.GETPOST('page_y', 'int'):'')); $time_end = time(); diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index baa1f57a3074e..5f7f7d0fc0a77 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -281,7 +281,7 @@ print ''; if ($obj->periode) { - print 'jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode),'day').''; + print 'jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode), 'day').''; } else { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 28ea7f44f10c2..f69b4db68c148 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6084,6 +6084,12 @@ public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix $type='link'; $param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]); } + elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[1] . ':' . $reg[2] . ':' . $reg[3] . ':' . $reg[4] => 'N'); + $type = 'sellist'; + } + + $langfile=$val['langfile']; $list=$val['list']; $help=$val['help']; diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index f9b0a59280fb0..ea038fa813190 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -199,8 +199,6 @@ public function displayMarginInfos($object, $force_price = false) if (! $user->rights->margins->liretous) return; - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); - $marginInfo = $this->getMarginInfosArray($object, $force_price); if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better @@ -240,13 +238,13 @@ public function displayMarginInfos($object, $force_price = false) //if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) { print ''; print ''.$langs->trans('MarginOnProducts').''; - print ''.price($marginInfo['pv_products'], null, null, null, null, $rounding).''; - print ''.price($marginInfo['pa_products'], null, null, null, null, $rounding).''; - print ''.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).''; + print ''.price($marginInfo['pv_products']).''; + print ''.price($marginInfo['pa_products']).''; + print ''.price($marginInfo['margin_on_products']).''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').''; + print ''.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, 2).'%').''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').''; + print ''.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, 2).'%').''; print ''; } @@ -254,13 +252,13 @@ public function displayMarginInfos($object, $force_price = false) { print ''; print ''.$langs->trans('MarginOnServices').''; - print ''.price($marginInfo['pv_services'], null, null, null, null, $rounding).''; - print ''.price($marginInfo['pa_services'], null, null, null, null, $rounding).''; - print ''.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).''; + print ''.price($marginInfo['pv_services']).''; + print ''.price($marginInfo['pa_services']).''; + print ''.price($marginInfo['margin_on_services']).''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').''; + print ''.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, 2).'%').''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').''; + print ''.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, 2).'%').''; print ''; } @@ -268,13 +266,13 @@ public function displayMarginInfos($object, $force_price = false) { print ''; print ''.$langs->trans('TotalMargin').''; - print ''.price($marginInfo['pv_total'], null, null, null, null, $rounding).''; - print ''.price($marginInfo['pa_total'], null, null, null, null, $rounding).''; - print ''.price($marginInfo['total_margin'], null, null, null, null, $rounding).''; + print ''.price($marginInfo['pv_total']).''; + print ''.price($marginInfo['pa_total']).''; + print ''.price($marginInfo['total_margin']).''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').''; + print ''.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').''; + print ''.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; print ''; } print ''; diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 14c69259b9894..79ad6d1911504 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -148,6 +148,7 @@ /* Set handler to add page_y param on output (click on href links or submit button) */ jQuery(".reposition").click(function() { var page_y = $(document).scrollTop(); + if (page_y > 0) { if (this.href) @@ -157,7 +158,7 @@ } else { - console.log("We click on tag with .reposition class but element is not an html tag, so we try to update form field page_y with value "+page_y); + console.log("We click on tag with .reposition class but element is not an html tag, so we try to update input form field page_y with value "+page_y); jQuery("input[type=hidden][name=page_y]").val(page_y); } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9aa6177adf499..e9f4301f8f23e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4400,7 +4400,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ { if ($currency_code == 'auto') $currency_code=$conf->currency; - $listofcurrenciesbefore=array('USD','GBP','AUD','HKD','MXN','PEN','CNY'); + $listofcurrenciesbefore=array('USD','GBP','AUD','HKD','MXN','PEN','CNY','CAD'); $listoflanguagesbefore=array('nl_NL'); if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) { @@ -6554,10 +6554,17 @@ function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'o $newmesgarray=array(); foreach($mesgarray as $val) { - $tmpmesgstring=preg_replace('/<\/div>
/', '
', $val); - $tmpmesgstring=preg_replace('/
/', '', $tmpmesgstring); - $tmpmesgstring=preg_replace('/<\/div>/', '', $tmpmesgstring); - $newmesgarray[]=$tmpmesgstring; + if (is_string($val)) + { + $tmpmesgstring=preg_replace('/<\/div>
/', '
', $val); + $tmpmesgstring=preg_replace('/
/', '', $tmpmesgstring); + $tmpmesgstring=preg_replace('/<\/div>/', '', $tmpmesgstring); + $newmesgarray[]=$tmpmesgstring; + } + else + { + dol_syslog("Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING); + } } $mesgarray=$newmesgarray; } diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 80876747d59ef..f2ef19ca19aee 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -252,7 +252,7 @@ public function Header(&$pdf, $page, $pages, $outputlangs) $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L'); $pdf->SetFont('', '', $default_font_size); $pdf->SetXY(32, 26); - $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L'); + $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L'); $pdf->SetFont('', '', $default_font_size); $pdf->SetXY(10, 32); diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 10b2a5662f300..af9c0e2c4120a 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -622,7 +622,7 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji if (! empty($objimport->array_import_regex[0][$val]) && ($newval != '')) { // If test is "Must exist in a field@table or field@table:..." - if (preg_match('/^(.+)@([^:]+)(:.+)?$/',$objimport->array_import_regex[0][$val],$reg)) + if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg)) { $field=$reg[1]; $table=$reg[2]; diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 1d7e3d983fb7c..381d68c16d2f9 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -438,7 +438,7 @@ public function write_file($object, $outputlangs) $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); } $pdf->SetXY($this->posxstatut, $curY); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Statut"), 1, 'R'); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Status"), 1, 'R'); if (is_array($elementarray) && count($elementarray) > 0) { diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 2c5c27bc93949..5fd43a69a3747 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -114,8 +114,8 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of order = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) + { foreach($object->linkedObjects['propal'] as $element) { $ret=$element->classifyBilled($user); @@ -143,7 +143,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { foreach($object->linkedObjects['commande'] as $element) { @@ -166,7 +166,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf if ($element->statut == Propal::STATUS_SIGNED || $element->statut == Propal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked proposals = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { foreach($object->linkedObjects['propal'] as $element) { @@ -195,8 +195,8 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf if ($element->statut == CommandeFournisseur::STATUS_ACCEPTED || $element->statut == CommandeFournisseur::STATUS_ORDERSENT || $element->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY || $element->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) - { + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) + { foreach($object->linkedObjects['order_supplier'] as $element) { $ret=$element->classifyBilled($user); @@ -218,7 +218,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf if ($element->statut == SupplierProposal::STATUS_SIGNED || $element->statut == SupplierProposal::STATUS_BILLED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked supplier proposals = ".$totalonlinkedelements.", of supplier invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { foreach($object->linkedObjects['supplier_proposal'] as $element) { @@ -246,7 +246,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf if ($element->statut == Commande::STATUS_VALIDATED || $element->statut == Commande::STATUS_SHIPMENTONPROCESS || $element->statut == Commande::STATUS_CLOSED) $totalonlinkedelements += $element->total_ht; } dol_syslog("Amount of linked orders = ".$totalonlinkedelements.", of invoice = ".$object->total_ht.", egality is ".($totalonlinkedelements == $object->total_ht)); - if ( ($totalonlinkedelements == $object->total_ht) || (! empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) ) + if ($this->shouldClassify($conf, $totalonlinkedelements, $object->total_ht)) { foreach($object->linkedObjects['commande'] as $element) { @@ -345,4 +345,24 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf return 0; } + + /** + * @param Object $conf Dolibarr settings object + * @param float $totalonlinkedelements Sum of total amounts (excl VAT) of + * invoices linked to $object + * @param float $object_total_ht The total amount (excl VAT) of the object + * (an order, a proposal, a bill, etc.) + * @return bool True if the amounts are equal (rounded on total amount) + * True if the module is configured to skip the amount equality check + * False otherwise. + */ + private function shouldClassify($conf, $totalonlinkedelements, $object_total_ht) + { + // if the configuration allows unmatching amounts, allow classification anyway + if (!empty($conf->global->WORKFLOW_CLASSIFY_IF_AMOUNTS_ARE_DIFFERENTS)) { + return true; + } + // if the amount are same, allow classification, else deny + return (price2num($totalonlinkedelements, 'MT') == price2num($object_total_ht, 'MT')); + } } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 04044e0ad9719..a764e2df47c62 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1958,7 +1958,7 @@ if ($resql) { $num = $db->num_rows($resql); - $i = 0; $total = 0; + $i = 0; $totalpaid = 0; while ($i < $num) { $objp = $db->fetch_object($resql); diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index dc820633395e1..1854ccbf1057e 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -453,7 +453,7 @@ // Replace the prefix in table names if ($dolibarr_main_db_prefix != 'llx_') { - $buffer=preg_replace('/llx_/i',$dolibarr_main_db_prefix,$buffer); + $buffer=preg_replace('/llx_/i', $dolibarr_main_db_prefix,$buffer); } dolibarr_install_syslog("step2: request: " . $buffer); print "\n"; diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index f40d3afce33b0..2a4195cb07b9c 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -533,7 +533,9 @@ } print ''; //var_dump($arrayofstatus);var_dump($search['fk_statut']);var_dump(array_values($search[$key])); - print Form::multiselectarray('search_fk_statut', $arrayofstatus, array_values($search[$key]), 0, 0, 'minwidth150', 1, 0, '', '', ''); + $selectedarray = null; + if ($search[$key]) $selectedarray = array_values($search[$key]); + print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'minwidth150', 1, 0, '', '', ''); print ''; } elseif ($key == "fk_soc") diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index 3e7ddfb7f0f01..ce3312ba44133 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -365,5 +365,4 @@ public function testUpdateBalance() $localobjecta->updateBalance(); } - }