From 2ab17c44e9fc12c162ba7e680ab8c5fcb680094b Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Fri, 23 Apr 2021 11:11:47 +0200 Subject: [PATCH 01/22] FIX : Add function price2num for rounding values in productAlertStock box --- htdocs/core/boxes/box_produits_alerte_stock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index dcd95445ddd..47009c77a53 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -203,7 +203,7 @@ class box_produits_alerte_stock extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="center"', - 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, + 'text' => price2num($objp->total_stock).' / '.$objp->seuil_stock_alerte, 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), ); From c5775cc90257319341d150d1cd4ffc6a07795078 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Fri, 23 Apr 2021 12:31:45 +0200 Subject: [PATCH 02/22] FIX : Add parameter to function price2num() --- htdocs/core/boxes/box_produits_alerte_stock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 47009c77a53..7982181f7ca 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -203,7 +203,7 @@ class box_produits_alerte_stock extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="center"', - 'text' => price2num($objp->total_stock).' / '.$objp->seuil_stock_alerte, + 'text' => price2num($objp->total_stock, 'MF').' / '.$objp->seuil_stock_alerte, 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), ); From e8c2085abd328a76e9d1f0841df4a0eb666927fa Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 27 Apr 2021 09:24:22 +0200 Subject: [PATCH 03/22] FIX : Change parameters MF to MS for price2num() function --- htdocs/core/boxes/box_produits_alerte_stock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 7982181f7ca..74b0703ccfa 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -203,7 +203,7 @@ class box_produits_alerte_stock extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="center"', - 'text' => price2num($objp->total_stock, 'MF').' / '.$objp->seuil_stock_alerte, + 'text' => price2num($objp->total_stock, 'MS').' / '.$objp->seuil_stock_alerte, 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), ); From 0037da1a5657a1bdb1a1c76fa0e0f1de82ec0df8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Apr 2021 23:29:53 +0200 Subject: [PATCH 04/22] FIX selection of project for reception must use PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS --- htdocs/reception/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 66aa1b300b8..18aa08b0d85 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -770,8 +770,8 @@ if ($action == 'create') $langs->load("projects"); print ''; print ''.$langs->trans("Project").''; - $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - print '   id).'">'.$langs->trans("AddProject").''; + print $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); + print '   id).'">'; print ''; print ''; } From 18d2bef8f38c94d24731eab199237506588d4974 Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Wed, 28 Apr 2021 11:58:34 +0200 Subject: [PATCH 05/22] Error 500 on propal card when we change the deadline if we don't use the automatic generation for PDF documents (MAIN_DISABLE_PDF_AUTOUPDATE is set to 1) when we change the deadline on a proposal we get an error 500. --- htdocs/comm/propal/card.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 73ea01bc3f8..99a6f759206 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -285,8 +285,28 @@ if (empty($reshook)) } elseif ($action == 'setecheance' && $usercancreate) { $result = $object->set_echeance($user, dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); - $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) + if ($result >= 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model = $object->model_pdf; + $ret = $object->fetch($id); // Reload to get new records + if ($ret > 0) { + $object->fetch_thirdparty(); + } + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + elseif ($result < 0) dol_print_error($db, $object->error); } elseif ($action == 'setdate_livraison' && $usercancreate) { From 6dcee425a1850c8802eede4a4835129643bbd430 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Apr 2021 15:07:31 +0200 Subject: [PATCH 06/22] Update card.php --- htdocs/comm/propal/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 99a6f759206..af88178fe27 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -305,9 +305,9 @@ if (empty($reshook)) $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } + } else { + setEventMessages($object->error, $object->errors, 'errors'); } - elseif ($result < 0) - dol_print_error($db, $object->error); } elseif ($action == 'setdate_livraison' && $usercancreate) { $result = $object->setDeliveryDate($user, dol_mktime(12, 0, 0, $_POST['date_livraisonmonth'], $_POST['date_livraisonday'], $_POST['date_livraisonyear'])); From 95ecb95ff142710a34bb2ee76cca7650431f5cf6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Apr 2021 20:47:28 +0200 Subject: [PATCH 07/22] FIX dol_print_date for %a and %b with some timezone --- htdocs/core/lib/functions.lib.php | 124 +++++++++++++++++------------- 1 file changed, 70 insertions(+), 54 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2a57a983496..37e55b42fde 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1991,19 +1991,15 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = // Clean parameters $to_gmt = false; $offsettz = $offsetdst = 0; - if ($tzoutput) - { + if ($tzoutput) { $to_gmt = true; // For backward compatibility - if (is_string($tzoutput)) - { - if ($tzoutput == 'tzserver') - { + if (is_string($tzoutput)) { + if ($tzoutput == 'tzserver') { $to_gmt = false; $offsettzstring = @date_default_timezone_get(); // Example 'Europe/Berlin' or 'Indian/Reunion' - $offsettz = 0; - $offsetdst = 0; - } elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') - { + $offsettz = 0; // Timezone offset with server timezone, so 0 + $offsetdst = 0; // Dst offset with server timezone, so 0 + } elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') { $to_gmt = true; $offsettzstring = (empty($_SESSION['dol_tz_string']) ? 'UTC' : $_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion' $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore @@ -2011,54 +2007,77 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = } } } - if (!is_object($outputlangs)) $outputlangs = $langs; - if (!$format) $format = 'daytextshort'; + if (!is_object($outputlangs)) { + $outputlangs = $langs; + } + if (!$format) { + $format = 'daytextshort'; + } // Do we have to reduce the length of date (year on 2 chars) to save space. // Note: dayinputnoreduce is same than day but no reduction of year length will be done $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0; // Test on original $format param. $format = preg_replace('/inputnoreduce/', '', $format); // so format 'dayinputnoreduce' is processed like day $formatwithoutreduce = preg_replace('/reduceformat/', '', $format); - if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat = 1; } // so format 'dayreduceformat' is processed like day + if ($formatwithoutreduce != $format) { + $format = $formatwithoutreduce; + $reduceformat = 1; + } // so format 'dayreduceformat' is processed like day // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. // TODO Add format daysmallyear and dayhoursmallyear - if ($format == 'day') $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short); - elseif ($format == 'hour') $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short); - elseif ($format == 'hourduration') $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration); - elseif ($format == 'daytext') $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text); - elseif ($format == 'daytextshort') $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : $conf->format_date_text_short); - elseif ($format == 'dayhour') $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : $conf->format_date_hour_short); - elseif ($format == 'dayhoursec') $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : $conf->format_date_hour_sec_short); - elseif ($format == 'dayhourtext') $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text); - elseif ($format == 'dayhourtextshort') $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short); - // Format not sensitive to language - elseif ($format == 'dayhourlog') $format = '%Y%m%d%H%M%S'; - elseif ($format == 'dayhourldap') $format = '%Y%m%d%H%M%SZ'; - elseif ($format == 'dayhourxcard') $format = '%Y%m%dT%H%M%SZ'; - elseif ($format == 'dayxcard') $format = '%Y%m%d'; - elseif ($format == 'dayrfc') $format = '%Y-%m-%d'; // DATE_RFC3339 - elseif ($format == 'dayhourrfc') $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 - elseif ($format == 'standard') $format = '%Y-%m-%d %H:%M:%S'; + if ($format == 'day') { + $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short); + } elseif ($format == 'hour') { + $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short); + } elseif ($format == 'hourduration') { + $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration); + } elseif ($format == 'daytext') { + $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text); + } elseif ($format == 'daytextshort') { + $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : $conf->format_date_text_short); + } elseif ($format == 'dayhour') { + $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : $conf->format_date_hour_short); + } elseif ($format == 'dayhoursec') { + $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : $conf->format_date_hour_sec_short); + } elseif ($format == 'dayhourtext') { + $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text); + } elseif ($format == 'dayhourtextshort') { + $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short); + } elseif ($format == 'dayhourlog') { + // Format not sensitive to language + $format = '%Y%m%d%H%M%S'; + } elseif ($format == 'dayhourldap') { + $format = '%Y%m%d%H%M%SZ'; + } elseif ($format == 'dayhourxcard') { + $format = '%Y%m%dT%H%M%SZ'; + } elseif ($format == 'dayxcard') { + $format = '%Y%m%d'; + } elseif ($format == 'dayrfc') { + $format = '%Y-%m-%d'; // DATE_RFC3339 + } elseif ($format == 'dayhourrfc') { + $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 + } elseif ($format == 'standard') { + $format = '%Y-%m-%d %H:%M:%S'; + } - if ($reduceformat) - { + if ($reduceformat) { $format = str_replace('%Y', '%y', $format); $format = str_replace('yyyy', 'yy', $format); } // If date undefined or "", we return "" - if (dol_strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) + if (dol_strlen($time) == 0) { + return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) + } // Clean format - if (preg_match('/%b/i', $format)) // There is some text to translate - { + if (preg_match('/%b/i', $format)) { // There is some text to translate // We inhibate translation to text made by strftime functions. We will use trans instead later. $format = str_replace('%b', '__b__', $format); $format = str_replace('%B', '__B__', $format); } - if (preg_match('/%a/i', $format)) // There is some text to translate - { + if (preg_match('/%a/i', $format)) { // There is some text to translate // We inhibate translation to text made by strftime functions. We will use trans instead later. $format = str_replace('%a', '__a__', $format); $format = str_replace('%A', '__A__', $format); @@ -2067,13 +2086,11 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = // Analyze date $reg = array(); - if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 - { + if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) { // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 dol_print_error("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]); return ''; - } elseif (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) // Still available to solve problems in extrafields of type date - { - // This part of code should not be used. + } elseif (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) { // Still available to solve problems in extrafields of type date + // This part of code should not be used anymore. dol_syslog("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"], LOG_WARNING); //if (function_exists('debug_print_backtrace')) debug_print_backtrace(); // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' @@ -2088,23 +2105,22 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = $ret = adodb_strftime($format, $time + $offsettz + $offsetdst, $to_gmt); } else { // Date is a timestamps - if ($time < 100000000000) // Protection against bad date values - { + if ($time < 100000000000) { // Protection against bad date values $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. - $ret = adodb_strftime($format, $timetouse, $to_gmt); - } else $ret = 'Bad value '.$time.' for date'; + $ret = adodb_strftime($format, $timetouse, $to_gmt); // If to_gmt = false then adodb_strftime use TZ of server + } else { + $ret = 'Bad value '.$time.' for date'; + } } - if (preg_match('/__b__/i', $format)) - { + if (preg_match('/__b__/i', $format)) { $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. // Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs. - $month = adodb_strftime('%m', $timetouse); + $month = adodb_strftime('%m', $timetouse, $to_gmt); // If to_gmt = false then adodb_strftime use TZ of server $month = sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'. - if ($encodetooutput) - { + if ($encodetooutput) { $monthtext = $outputlangs->transnoentities('Month'.$month); $monthtextshort = $outputlangs->transnoentities('MonthShort'.$month); } else { @@ -2117,11 +2133,11 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = //print 'x'.$outputlangs->charset_output.'-'.$ret.'x'; //return $ret; } - if (preg_match('/__a__/i', $format)) - { + if (preg_match('/__a__/i', $format)) { + //print "time=$time offsettz=$offsettz offsetdst=$offsetdst offsettzstring=$offsettzstring"; $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. - $w = adodb_strftime('%w', $timetouse); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. + $w = adodb_strftime('%w', $timetouse, $to_gmt); // If to_gmt = false then adodb_strftime use TZ of server $dayweek = $outputlangs->transnoentitiesnoconv('Day'.$w); $ret = str_replace('__A__', $dayweek, $ret); $ret = str_replace('__a__', dol_substr($dayweek, 0, 3), $ret); From 68415322ecfaef55e885bea7ee2f9b7b044c5e28 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 29 Apr 2021 10:00:54 +0200 Subject: [PATCH 08/22] Fix v11 wrong alias in natural_search --- htdocs/adherents/type.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 4590254ebf6..65996fc7283 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -511,7 +511,7 @@ if ($rowid > 0) $sql .= " AND t.rowid = ".$object->id; if ($sall) { - $sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall); + $sql .= natural_search(array("d.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall); } if ($status != '') { From a7b093ed81d81768e1a528e2370e8951222ea198 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 29 Apr 2021 11:34:09 +0200 Subject: [PATCH 09/22] FIX: Espadon PDF shippment model with long public note now wroking --- .../expedition/doc/pdf_espadon.modules.php | 180 ++++++++++++++---- 1 file changed, 141 insertions(+), 39 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 165e83a8e87..e0d9695f79f 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -274,6 +274,15 @@ class pdf_espadon extends ModelePdfExpedition if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6; $pdf->SetAutoPageBreak(1, 0); + // Create pdf instance + /*$pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $pdf->SetAutoPageBreak(1, 0); + + $heightforinfotot = 40; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin) + */ if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -306,13 +315,13 @@ class pdf_espadon extends ModelePdfExpedition $pdf->AddPage(); if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 90; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift: 10); $tab_height = 130; $tab_height_newpage = 150; @@ -351,62 +360,153 @@ class pdf_espadon extends ModelePdfExpedition $notetoshow = dol_concatdesc($notetoshow, $extranote); } - if (!empty($notetoshow) || !empty($object->tracking_number)) - { - $tab_top = 88 + $height_incoterms; - $tab_top_alt = $tab_top; - - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); - - $tab_top_alt = $pdf->GetY(); - //$tab_top_alt += 1; + if (!empty($notetoshow) || !empty($object->tracking_number)) { + $tab_top -= 2; // Tracking number - if (!empty($object->tracking_number)) - { + if (!empty($object->tracking_number)) { + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber") . " : " . $object->tracking_number, 0, 1, false, true, 'L'); + + $tab_top_alt = $pdf->GetY(); $object->getUrlTrackingStatus($object->tracking_number); - if (!empty($object->tracking_url)) - { - if ($object->shipping_method_id > 0) - { + if (!empty($object->tracking_url)) { + if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); $label = ''; - if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."
"; - $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); + if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage") . "
"; + $label .= $outputlangs->trans("SendingMethod") . ": " . $outputlangs->trans("SendingMethod" . strtoupper($code)); //var_dump($object->tracking_url != $object->tracking_number);exit; - if ($object->tracking_url != $object->tracking_number) - { + if ($object->tracking_url != $object->tracking_number) { $label .= " : "; $label .= $object->tracking_url; } $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); - $tab_top_alt = $pdf->GetY(); + $tab_top = $pdf->GetY(); } } } + // Notes + $pagenb = $pdf->getPage(); if (!empty($notetoshow)) { - $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page - $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($notetoshow), 0, 1); + $tab_top -= 2; + + $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; + $pageposbeforenote = $pagenb; + + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); + + $pdf->startTransaction(); + + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + // Description + $pageposafternote = $pdf->getPage(); + $posyafter = $pdf->GetY(); + + if ($pageposafternote > $pageposbeforenote) + { + $pdf->rollbackTransaction(true); + + // prepare pages to receive notes + while ($pagenb < $pageposafternote) { + $pdf->AddPage(); + $pagenb++; + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + // $this->_pagefoot($pdf,$object,$outputlangs,1); + $pdf->setTopMargin($tab_top_newpage); + // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + } + + // back to start + $pdf->setPage($pageposbeforenote); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pageposafternote = $pdf->getPage(); + + $posyafter = $pdf->GetY(); + + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text + { + $pdf->AddPage('', '', true); + $pagenb++; + $pageposafternote++; + $pdf->setPage($pageposafternote); + $pdf->setTopMargin($tab_top_newpage); + // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); + //$posyafter = $tab_top_newpage; + } + + + // apply note frame to previous pages + $i = $pageposbeforenote; + while ($i < $pageposafternote) { + $pdf->setPage($i); + + + $pdf->SetDrawColor(128, 128, 128); + // Draw note frame + if ($i > $pageposbeforenote) { + $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + } else { + $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + } + + // Add footer + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $this->_pagefoot($pdf, $object, $outputlangs, 1); + + $i++; + } + + // apply note frame to last page + $pdf->setPage($pageposafternote); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $height_note = $posyafter - $tab_top_newpage; + $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); + } else // No pagebreak + { + $pdf->commitTransaction(); + $posyafter = $pdf->GetY(); + $height_note = $posyafter - $tab_top; + $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); + + + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) + { + // not enough space, need to add page + $pdf->AddPage('', '', true); + $pagenb++; + $pageposafternote++; + $pdf->setPage($pageposafternote); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + + $posyafter = $tab_top_newpage; + } + } + + $tab_height = $tab_height - $height_note; + $tab_top = $posyafter + 6; + } else { + $height_note = 0; } - - $nexY = $pdf->GetY(); - $height_note = $nexY - $tab_top; - - // Rect takes a length in 3rd parameter - $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); - - $tab_height = $tab_height - $height_note; - $tab_top = $nexY + 6; - } else { - $height_note = 0; } @@ -415,13 +515,15 @@ class pdf_espadon extends ModelePdfExpedition // Table simulation to know the height of the title line $pdf->startTransaction(); - $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); + $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs); $pdf->rollbackTransaction(true); $nexY = $tab_top + $this->tabTitleHeight; // Loop on each lines + $pageposbeforeprintlines = $pdf->getPage(); + $pagenb = $pageposbeforeprintlines; for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; @@ -590,7 +692,7 @@ class pdf_espadon extends ModelePdfExpedition while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); - if ($pagenb == 1) + if ($pagenb == $pageposbeforeprintlines) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); } else { From 965eb2d6397025e8ddf72501d4f46185a1aed744 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 29 Apr 2021 22:57:39 +0200 Subject: [PATCH 10/22] Fix logical test always false subscription is an integer and is set to 0 or 1. So subscription is never equal to "yes" --- htdocs/adherents/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 838e7cd9a5c..dad19ffafcd 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -857,7 +857,7 @@ while ($i < min($num, $limit)) else { print ''; - if ($obj->subscription == 'yes') + if (!empty($obj->subscription)) { print $langs->trans("SubscriptionNotReceived"); if ($obj->statut > 0) print " ".img_warning(); From 4174ebd9c0023bdda8ad1d9899a8a1a003aeb19b Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 29 Apr 2021 23:11:51 +0200 Subject: [PATCH 11/22] Fix subscription =="yes" --- htdocs/adherents/type.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 4590254ebf6..81e387b8dbb 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -710,7 +710,7 @@ if ($rowid > 0) else { print ''; - if ($objp->subscription == 'yes') + if (!empty($objp->subscription)) { print $langs->trans("SubscriptionNotReceived"); if ($objp->statut > 0) print " ".img_warning(); From 749aeeb233f26cdf1af9f3de6edcae140296af45 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Thu, 29 Apr 2021 23:16:21 +0200 Subject: [PATCH 12/22] Fix $objp->subscription =="yes" --- htdocs/societe/societecontact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 8874a62bc3b..4a8879c60bd 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -331,7 +331,7 @@ if ($id > 0 || ! empty($ref)) else { print ''; - if ($objp->subscription == 'yes') + if (!empty($objp->subscription)) { print $langs->trans("SubscriptionNotReceived"); if ($objp->statut > 0) print " ".img_warning(); From 5e98d9932156019c948c1d3e3b29011a8451a12a Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 30 Apr 2021 10:04:21 +0200 Subject: [PATCH 13/22] FIX SQL Error show_contacts : socialnetworks --- htdocs/core/lib/company.lib.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 48ab350d60f..d71be0b723e 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -902,11 +902,11 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 't.email', ); //Social media - foreach ($socialnetworks as $key => $value) { - if ($value['active']) { - $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->'$.".$key."'"; - } - } +// foreach ($socialnetworks as $key => $value) { +// if ($value['active']) { +// $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->'$.".$key."'"; +// } +// } if (!$sortorder) $sortorder = "ASC"; if (!$sortfield) $sortfield = "t.lastname"; From 81b964db45b353abf21f54a8bb6e369e32f1b600 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 30 Apr 2021 08:12:24 +0000 Subject: [PATCH 14/22] Fixing style errors. --- htdocs/core/lib/company.lib.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index d71be0b723e..16f52ad80e3 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -902,11 +902,11 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 't.email', ); //Social media -// foreach ($socialnetworks as $key => $value) { -// if ($value['active']) { -// $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->'$.".$key."'"; -// } -// } + // foreach ($socialnetworks as $key => $value) { + // if ($value['active']) { + // $searchAddressPhoneDBFields['t.'.$key] = "t.socialnetworks->'$.".$key."'"; + // } + // } if (!$sortorder) $sortorder = "ASC"; if (!$sortfield) $sortfield = "t.lastname"; From 6c1e0919c8c42789ab2993d61ae116b9c952a832 Mon Sep 17 00:00:00 2001 From: ATM john Date: Fri, 30 Apr 2021 12:20:43 +0200 Subject: [PATCH 15/22] Fix checkbox multiselect pre-selected value from get/post --- htdocs/core/class/extrafields.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ed85a328edc..07d80acd9aa 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1339,7 +1339,11 @@ class ExtraFields } elseif ($type == 'checkbox') { - $value_arr = explode(',', $value); + $value_arr = $value; + if (!is_array($value)) + { + $value_arr = explode(',', $value); + } $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); } elseif ($type == 'radio') From 972776819290ef76ec38eb5ea967fa2835faa484 Mon Sep 17 00:00:00 2001 From: Indelog Date: Mon, 3 May 2021 09:46:51 +0200 Subject: [PATCH 16/22] Fix show table of pdf payments repports in file order Use scandir() rather opendir() and readdir() to get a sorted list of files. --- htdocs/compta/paiement/rapport.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php index 0af202016df..7670e03d094 100644 --- a/htdocs/compta/paiement/rapport.php +++ b/htdocs/compta/paiement/rapport.php @@ -136,7 +136,6 @@ if ($year) { if (is_dir($dir.'/'.$year)) { - $handle = opendir($dir.'/'.$year); if ($found) print '
'; print '
'; @@ -147,22 +146,17 @@ if ($year) print ''.$langs->trans("Date").''; print ''; - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/^payment/i', $file)) - { - $tfile = $dir.'/'.$year.'/'.$file; - $relativepath = $year.'/'.$file; - print ''; - print ''.img_pdf().' '.$file.''.$formfile->showPreview($file, 'facture_paiement', $relativepath, 0).''; - print ''.dol_print_size(dol_filesize($tfile)).''; - print ''.dol_print_date(dol_filemtime($tfile), "dayhour").''; - print ''; - } + $files = (scandir($dir.'/'.$year)); + foreach ($files as $f) { + $tfile = $dir.'/'.$year.'/'.$f; + $relativepath = $year.'/'.$f; + if (is_file($tfile)) { + print ''; + print ''.img_pdf().' '.$f.''.$formfile->showPreview($f, 'facture_paiement', $relativepath, 0).''; + print ''.dol_print_size(dol_filesize($tfile)).''; + print ''.dol_print_date(dol_filemtime($tfile), "dayhour").''; + print ''; } - closedir($handle); } print ''; } From dba9b17275a2e53da6e4102b5381c7800b1be390 Mon Sep 17 00:00:00 2001 From: Indelog Date: Mon, 3 May 2021 16:00:14 +0200 Subject: [PATCH 17/22] Fix forgot payment filter on file name --- htdocs/compta/paiement/rapport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php index 7670e03d094..a640ef1f8fe 100644 --- a/htdocs/compta/paiement/rapport.php +++ b/htdocs/compta/paiement/rapport.php @@ -150,7 +150,7 @@ if ($year) foreach ($files as $f) { $tfile = $dir.'/'.$year.'/'.$f; $relativepath = $year.'/'.$f; - if (is_file($tfile)) { + if (is_file($tfile) && preg_match('/^payment/i', $f)) { print ''; print ''.img_pdf().' '.$f.''.$formfile->showPreview($f, 'facture_paiement', $relativepath, 0).''; print ''.dol_print_size(dol_filesize($tfile)).''; From 33a20ae9a1f43dc7adcecdd32bf140ccf3973c8d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 May 2021 16:16:44 +0200 Subject: [PATCH 18/22] Update extrafields.class.php --- htdocs/core/class/extrafields.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 07d80acd9aa..3d55b12c35c 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1340,8 +1340,7 @@ class ExtraFields elseif ($type == 'checkbox') { $value_arr = $value; - if (!is_array($value)) - { + if (!is_array($value)) { $value_arr = explode(',', $value); } $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); From c18848c9444c0a607838ec347cb22057d26b6e55 Mon Sep 17 00:00:00 2001 From: Indelog Date: Mon, 3 May 2021 17:17:44 +0200 Subject: [PATCH 19/22] Fix: simplify code with dol_dir_list() --- htdocs/compta/paiement/rapport.php | 44 ++++++++---------------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php index a640ef1f8fe..c76697c8401 100644 --- a/htdocs/compta/paiement/rapport.php +++ b/htdocs/compta/paiement/rapport.php @@ -109,35 +109,18 @@ print '
'; clearstatcache(); // Show link on other years -$linkforyear = array(); -$found = 0; -if (is_dir($dir)) +$year_dirs = dol_dir_list($dir, 'directories', 0, '^[0-9]{4}$', '', 'DESC'); +foreach ($year_dirs as $d) { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_dir($dir.'/'.$file) && !preg_match('/^\./', $file) && is_numeric($file)) - { - $found = 1; - $linkforyear[] = $file; - } - } - } -} -asort($linkforyear); -foreach ($linkforyear as $cursoryear) -{ - print ''.$cursoryear.'  '; + print ''.$d['name'].'  '; } +$found = true; if ($year) { if (is_dir($dir.'/'.$year)) { - - if ($found) print '
'; + if (!empty($year_dirs)) print '
'; print '
'; print ''; print ''; @@ -146,17 +129,14 @@ if ($year) print ''; print ''; - $files = (scandir($dir.'/'.$year)); + $files = (dol_dir_list($dir.'/'.$year, 'files', 0, '^payments-[0-9]{4}-[0-9]{2}\.pdf$', '', 'name', 'DESC', 1)); foreach ($files as $f) { - $tfile = $dir.'/'.$year.'/'.$f; - $relativepath = $year.'/'.$f; - if (is_file($tfile) && preg_match('/^payment/i', $f)) { - print ''; - print ''; - print ''; - print ''; - print ''; - } + $relativepath = $f['level1name'].'/'.$f['name']; + print ''; + print ''; + print ''; + print ''; + print ''; } print '
'.$langs->trans("Date").'
'.img_pdf().' '.$f.''.$formfile->showPreview($f, 'facture_paiement', $relativepath, 0).''.dol_print_size(dol_filesize($tfile)).''.dol_print_date(dol_filemtime($tfile), "dayhour").'
'.img_pdf().' '.$f['name'].''.$formfile->showPreview($f['name'], 'facture_paiement', $relativepath, 0).''.dol_print_size($f['size']).''.dol_print_date($f['date'], "dayhour").'
'; } From 9278228e2027671a4612534409d9b63be04e3d50 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 3 May 2021 18:08:49 +0200 Subject: [PATCH 20/22] FIX: create event from contact card preselect contact correctly --- htdocs/comm/action/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index b3cb6d60a23..2a0371d4615 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1143,6 +1143,7 @@ if ($action == 'create') print ''.$langs->trans("ActionOnContact").''; $preselectedids = GETPOST('socpeopleassigned', 'array'); if (GETPOST('contactid', 'int')) $preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int'); + if ($origin=='contact') $preselectedids[GETPOST('originid', 'int')] = GETPOST('originid', 'int'); print img_picto('', 'contact', 'class="paddingrightonly"'); print $form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); print ''; From 706545081cac9ff42cc4dce138d4abfe03b78112 Mon Sep 17 00:00:00 2001 From: WimpyMan <12594973+WimpyMan@users.noreply.github.com> Date: Mon, 3 May 2021 18:23:31 +0200 Subject: [PATCH 21/22] FIX #17476 releve.php: Fix SQL statement Single quotes `'` should be uses instead of double quotes `"` for string values. --- htdocs/compta/bank/releve.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 9a534b76320..a58c85469b8 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -177,7 +177,7 @@ $sqlrequestforbankline = $sql; if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt)) { // TODO Add a test to check newbankreceipt does not exists yet - $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'" AND fk_account = '.$id; + $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = \''.$db->escape($newbankreceipt).'\' WHERE num_releve = \''.$db->escape($oldbankreceipt).'\' AND fk_account = '.$id; $result = $db->query($sqlupdate); if ($result < 0) dol_print_error($db); From 1d2f8b09d96c398faf7c1c15bab6c53859b21e48 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 May 2021 18:55:25 +0200 Subject: [PATCH 22/22] Update releve.php --- htdocs/compta/bank/releve.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index a58c85469b8..d0812ae4ea9 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -177,7 +177,7 @@ $sqlrequestforbankline = $sql; if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt)) { // TODO Add a test to check newbankreceipt does not exists yet - $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = \''.$db->escape($newbankreceipt).'\' WHERE num_releve = \''.$db->escape($oldbankreceipt).'\' AND fk_account = '.$id; + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."bank SET num_releve = '".$db->escape($newbankreceipt)."' WHERE num_releve = '".$db->escape($oldbankreceipt)."' AND fk_account = ".((int) $id); $result = $db->query($sqlupdate); if ($result < 0) dol_print_error($db);