From 6b90558b7ab9f0d89f6a04b1a800d4c5b09e8e2d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Apr 2018 11:20:56 +0200 Subject: [PATCH 01/17] FIX File name not visible in email preview --- htdocs/core/class/CMailFile.class.php | 2 +- htdocs/core/class/smtps.class.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index d9469c11559..6dbc622032d 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1128,7 +1128,7 @@ class CMailFile $out.= "Content-Disposition: attachment; filename=\"".$filename_list[$i]."\"".$this->eol; $out.= "Content-Type: " . $mimetype_list[$i] . "; name=\"".$filename_list[$i]."\"".$this->eol; $out.= "Content-Transfer-Encoding: base64".$this->eol; - $out.= "Content-Description: File Attachment".$this->eol; + $out.= "Content-Description: ".$filename_list[$i].$this->eol; $out.= $this->eol; $out.= $encoded; $out.= $this->eol; diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index c4176d2b81b..d83ff3110ba 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -1410,7 +1410,7 @@ class SMTPs $content = 'Content-Type: ' . $_msgData['mimeType'] . '; charset="' . $this->getCharSet() . '"' . "\r\n" . 'Content-Transfer-Encoding: ' . $this->getTransEncodeType() . "\r\n" . 'Content-Disposition: inline' . "\r\n" - . 'Content-Description: message' . "\r\n"; + . 'Content-Description: Message' . "\r\n"; if ( $this->getMD5flag() ) $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n"; @@ -1459,7 +1459,7 @@ class SMTPs . 'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n" . 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n" . 'Content-Transfer-Encoding: base64' . "\r\n" - . 'Content-Description: File Attachment' . "\r\n"; + . 'Content-Description: ' . $_data['fileName'] ."\r\n"; if ( $this->getMD5flag() ) $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; From e834eff049fa30ddcd34bab334f62360b1baeb7e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 20:03:24 +0200 Subject: [PATCH 02/17] FIX #8650 --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 6749d4be51c..efb47ede029 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -707,3 +707,6 @@ create table llx_facture_rec_extrafields ALTER TABLE llx_facture_rec_extrafields ADD INDEX idx_facture_rec_extrafields (fk_object); + +UPDATE llx_cronjob set entity = 1 where entity = 0 and label in ('RecurringInvoices', 'SendEmailsReminders'); +UPDATE llx_cronjob set entity = 0 where entity = 1 and label in ('PurgeDeleteTemporaryFilesShort', 'MakeLocalDatabaseDumpShort'); From 77d9ff033af3b49ab950371d971adb358a419214 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 15:06:30 +0200 Subject: [PATCH 03/17] FIX cron script disabled if module disabled --- scripts/cron/cron_run_jobs.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 246fd3d75b4..5113e5971b0 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -75,6 +75,13 @@ $now=dol_now(); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." ***** userlogin=" . $userlogin . " ***** " . $now . " *****\n"; +// Check module cron is activated +if (empty($conf->cron->enabled)) +{ + print "Error: module Scheduled jobs (cron) not activated\n"; + exit(-1); +} + // Check security key if ($key != $conf->global->CRON_KEY) { From 315d5bad3903e7c48dc1941163282b335b7c2ff5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 10:35:11 +0200 Subject: [PATCH 04/17] FIX Error in ContractLigne not return to Contract --- htdocs/contrat/class/contrat.class.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 85128ea8a69..a460f6aff51 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -237,7 +237,13 @@ class Contrat extends CommonObject */ function active_line($user, $line_id, $date, $date_end='', $comment='') { - return $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); + $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); + if ($result < 0) + { + $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; + $this->errors = $this->lines[$this->lines_id_index_mapper[$line_id]]->errors; + } + return $result; } @@ -252,7 +258,13 @@ class Contrat extends CommonObject */ function close_line($user, $line_id, $date_end, $comment='') { - return $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); + $result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); + if ($result < 0) + { + $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; + $this->errors = $this->lines[$this->lines_id_index_mapper[$line_id]]->errors; + } + return $result; } From 4aa822d0f6ca82b53d513c9a8a0514bca799cf12 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 16:49:27 +0200 Subject: [PATCH 05/17] better message --- scripts/cron/cron_run_jobs.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 5113e5971b0..5eb56defead 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -73,7 +73,7 @@ $error=0; $now=dol_now(); @set_time_limit(0); -print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." ***** userlogin=" . $userlogin . " ***** " . $now . " *****\n"; +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." ***** userlogin=" . $userlogin . " ***** " . dol_print_date($now, 'dayrfc') . " *****\n"; // Check module cron is activated if (empty($conf->cron->enabled)) @@ -161,7 +161,7 @@ $nbofjobs=count($qualifiedjobs); $nbofjobslaunchedok=0; $nbofjobslaunchedko=0; -if(is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) +if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) { // Loop over job foreach($qualifiedjobs as $line) @@ -215,6 +215,10 @@ if(is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) } } } +else +{ + echo "cron_run_jobs.php no qualified job found\n"; +} $db->close(); From 00c8ea6c316dba4e0a0fb60ea2ede3a058030824 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 16:52:50 +0200 Subject: [PATCH 06/17] better message --- scripts/cron/cron_run_jobs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 5eb56defead..d9d6b5f9b56 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -172,7 +172,7 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) { - dol_syslog("cron_run_jobs.php:: to run line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); + dol_syslog("cron_run_jobs.php line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); $cronjob=new Cronjob($db); $result=$cronjob->fetch($line->id); @@ -211,7 +211,7 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) } else { - dol_syslog("cron_run_jobs.php:: job not qualified line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); + dol_syslog("cron_run_jobs.php job not qualified line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); } } } From f95e5078c103a0f4a81fba85b37940a23df70802 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 21:33:49 +0200 Subject: [PATCH 07/17] FIX Can't edit option PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY --- htdocs/projet/admin/project.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index b1cf4d9773b..4135d547be3 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -274,12 +274,11 @@ elseif ($action == 'updateoptions') $conf->global->PROJECT_USE_SEARCH_TO_SELECT = $companysearch; } } -} -else if ($action == "linkOtherCompany") -{ - $projectToSelect = GETPOST('projectToSelect'); - - dolibarr_set_const($db, 'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY', $projectToSelect, 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value + if (GETPOST('PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY')) + { + $projectToSelect = GETPOST('projectToSelect','alpha'); + dolibarr_set_const($db, 'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY', $projectToSelect, 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value + } } From 0a5e6069375baf320383b23f1b9efff822b6e2fd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 22:53:57 +0200 Subject: [PATCH 08/17] FIX extrafields price and double were lost during a failed post. --- htdocs/core/class/commonobject.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a8e4956a10d..21631b86cac 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5783,9 +5783,9 @@ abstract class CommonObject } else { $value = $this->array_options["options_" . $key]; // No GET, no POST, no default value, so we take value of object. } + //var_dump($keyprefix.' - '.$key.' - '.$keysuffix.' - '.$keyprefix.'options_'.$key.$keysuffix.' - '.$this->array_options["options_".$key.$keysuffix].' - '.$getposttemp.' - '.$value); break; } - //var_dump($value); if ($extrafields->attribute_type[$key] == 'separate') { @@ -5810,12 +5810,12 @@ abstract class CommonObject // Convert date into timestamp format (value in memory must be a timestamp) if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) { - $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min",'int',3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year",'int',3)):$this->db->jdate($this->array_options['options_'.$key]); + $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min",'int',3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year",'int',3)):$this->db->jdate($this->array_options['options_'.$key]); } // Convert float submited string into real php numeric (value in memory must be a php numeric) if (in_array($extrafields->attribute_type[$key],array('price','double'))) { - $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix,'int',3)):$this->array_options['options_'.$key]; + $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix, 'alpha', 3)):$this->array_options['options_'.$key]; } $labeltoshow = $langs->trans($label); From fdb3a11f3492ce30bae8380fd29163d6b8812c22 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 22:56:40 +0200 Subject: [PATCH 09/17] FIX extrafields price and double were lost during a failed post. --- htdocs/core/class/extrafields.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 7d6de9bda7f..2216c0fd7aa 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1779,13 +1779,14 @@ class ExtraFields } else if (in_array($key_type,array('price','double'))) { - $value_arr=GETPOST("options_".$key); + $value_arr=GETPOST("options_".$key, 'alpha'); $value_key=price2num($value_arr); } else { $value_key=GETPOST("options_".$key); } + $object->array_options["options_".$key]=$value_key; } From 271e50ccf40d5c5139215c1015d5edf63877a97c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 10:06:13 +0200 Subject: [PATCH 10/17] CSS --- htdocs/theme/eldy/style.css.php | 11 +++++------ htdocs/theme/md/style.css.php | 5 ++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 93981a73c2e..b7fa85d5194 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -994,9 +994,6 @@ select.selectarrowonleft option { text-overflow: ellipsis; white-space: nowrap; } - div.fiche { - margin-top: px !important; - } div.titre { /* margin-top: 12px; */ /* line-height: 2em; */ @@ -1229,8 +1226,8 @@ div.fiche { div.fiche { margin-: dol_optimize_smallscreen)?'25':'6')); ?>px; margin-: dol_optimize_smallscreen)?'24':'6')); ?>px; - dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'."\n"; ?> - dol_hide_leftmenu)) print 'margin-bottom: 12px;'."\n"; ?> + + } body.onlinepaymentbody div.fiche { /* For online payment page */ margin: 20px !important; @@ -1280,7 +1277,6 @@ div.secondcolumn div.box { div.fiche { margin-: px; margin-: px; - dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> } div.fichecenter { width: 100%; @@ -3230,6 +3226,9 @@ span.boxstatstext img, a.dashboardlineindicatorlate img { a img { border: 0; } +.boxstatsindicator.thumbstat150 { /* If we remove this, box position is ko on ipad */ + display: inline-flex; +} span.boxstatsindicator { font-size: 130%; font-weight: normal; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5970ad6ef84..fdc0a3e908b 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1234,7 +1234,7 @@ div.fiche { div.fiche { margin-: dol_optimize_smallscreen)?'24':'6')); ?>px; margin-: dol_optimize_smallscreen)?'22':'6')); ?>px; - dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> + margin-bottom: 15px; } body.onlinepaymentbody div.fiche { /* For online payment page */ @@ -3190,6 +3190,9 @@ span.boxstatstext { color: #000; /* opacity: 0.7; */ /* a bug if browser make z-index infintie when opacity is set so we disable it */ } +.boxstatsindicator.thumbstat150 { /* If we remove this, box position is ko on ipad */ + display: inline-flex; +} span.boxstatsindicator { font-size: 110%; font-weight: normal; From decb93efa6f11db0e2eb02af37e6a00e7814f9b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 10:17:57 +0200 Subject: [PATCH 11/17] Fix NOIPCHECK --- htdocs/document.php | 21 ++++++++++++--------- htdocs/viewimage.php | 16 +++++++++++----- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/htdocs/document.php b/htdocs/document.php index 0a6e5593f62..725d079a9f6 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -38,22 +38,25 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // For bittorent link, we don't need to load/check we are into a login session -if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'bittorrent' && ! defined("NOLOGIN")) +if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'bittorrent') { - define("NOLOGIN",1); - define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOLOGIN")) define("NOLOGIN",1); + if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } // For direct external download link, we don't need to load/check we are into a login session -if (isset($_GET["hashp"]) && ! defined("NOLOGIN")) +if (isset($_GET["hashp"])) { - define("NOLOGIN",1); - define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOLOGIN")) define("NOLOGIN",1); + if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } // Some value of modulepart can be used to get resources that are public so no login are required. -if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias') && ! defined("NOLOGIN")) +if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias')) { - define("NOLOGIN",1); - define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOLOGIN")) define("NOLOGIN",1); + if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } /** diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index a53db61a83c..ffc0f3a6af5 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -37,19 +37,25 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Some value of modulepart can be used to get resources that are public so no login are required. -if ((isset($_GET["modulepart"]) && ($_GET["modulepart"] == 'mycompany' || $_GET["modulepart"] == 'companylogo')) && ! defined("NOLOGIN")) +if ((isset($_GET["modulepart"]) && ($_GET["modulepart"] == 'mycompany' || $_GET["modulepart"] == 'companylogo'))) { - define("NOLOGIN",'1'); + if (! defined("NOLOGIN")) define("NOLOGIN",1); + if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } // For direct external download link, we don't need to load/check we are into a login session if (isset($_GET["hashp"]) && ! defined("NOLOGIN")) { - define("NOLOGIN",1); + if (! defined("NOLOGIN")) define("NOLOGIN",1); + if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } // Some value of modulepart can be used to get resources that are public so no login are required. -if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias') && ! defined("NOLOGIN")) +if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias')) { - define("NOLOGIN",'1'); + if (! defined("NOLOGIN")) define("NOLOGIN",1); + if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip // For multicompany $entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); From be1089914e06add54b6d27ebdb07a82a98f1bedb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 10:27:57 +0200 Subject: [PATCH 12/17] Fix picto --- htdocs/barcode/codeinit.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 5e684b4091d..806a88325fb 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -212,7 +212,8 @@ if ($conf->societe->enabled) { $nbno=$nbtotal=0; - print load_fiche_titre($langs->trans("BarcodeInitForThirdparties"),'','object_company'); + print load_fiche_titre($langs->trans("BarcodeInitForThirdparties"),'','title_companies'); + print '
'."\n"; $sql="SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."societe where barcode IS NULL or barcode = ''"; $resql=$db->query($sql); @@ -253,7 +254,7 @@ if ($conf->product->enabled || $conf->product->service) $nbno=$nbtotal=0; - print load_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"),'','object_product'); + print load_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"),'','title_products'); print '
'."\n"; $sql ="SELECT count(rowid) as nb, fk_product_type, datec"; From fcf91b6c8c98a8250398cc98cdc55cbded2092b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 11:12:12 +0200 Subject: [PATCH 13/17] Look and feel v8 --- htdocs/societe/paymentmodes.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index fe1456fd820..0baffe090d2 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -784,6 +784,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; print ''; + dol_fiche_end(); + print '
'; // List of Stripe payment modes @@ -792,7 +794,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $morehtmlright=''; if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { - $morehtmlright=''.$langs->trans("Add").''; + $morehtmlright=''.$langs->trans("Add").' '; } print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc?' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); @@ -1041,12 +1043,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // List of bank accounts print '
'; - $morehtmlright=''.$langs->trans("Add").''; + $morehtmlright=''.$langs->trans("Add").' '; print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, ''); $rib_list = $object->get_all_rib(); - $var = false; if (is_array($rib_list)) { print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -1235,11 +1236,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' dol_print_error($db); } - dol_fiche_end(); - if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) { + print '
'; + print '
'; print ''; // ancre @@ -1251,8 +1252,6 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $genallowed=$user->rights->societe->lire; $delallowed=$user->rights->societe->creer; - $var=true; - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); // Show direct download link From 461ae46cc4eabedfdf17ebabb26e05ed8f68509e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 11:37:57 +0200 Subject: [PATCH 14/17] FIX When on a high page and searching for a small result, list was not visible. --- htdocs/accountancy/admin/account.php | 5 +++++ htdocs/accountancy/admin/fiscalyear.php | 5 +++++ htdocs/accountancy/admin/productaccount.php | 6 ++++++ htdocs/accountancy/customer/lines.php | 7 ++++++- htdocs/accountancy/customer/list.php | 5 +++++ htdocs/accountancy/expensereport/lines.php | 5 +++++ htdocs/accountancy/expensereport/list.php | 5 +++++ htdocs/accountancy/supplier/lines.php | 5 +++++ htdocs/accountancy/supplier/list.php | 5 +++++ htdocs/adherents/list.php | 5 +++++ htdocs/adherents/subscription/list.php | 5 +++++ htdocs/adherents/type.php | 11 +++++++++-- htdocs/admin/mails_senderprofile_list.php | 5 +++++ htdocs/admin/tools/listevents.php | 5 +++++ htdocs/assets/list.php | 5 +++++ htdocs/assets/type.php | 11 +++++++++-- htdocs/categories/class/categorie.class.php | 14 ++++++-------- htdocs/comm/action/list.php | 5 +++++ htdocs/comm/action/rapport/index.php | 5 +++++ htdocs/comm/mailing/cibles.php | 6 ++++++ htdocs/comm/propal/list.php | 6 ++++++ htdocs/commande/customer.php | 6 ++++++ htdocs/commande/list.php | 6 ++++++ htdocs/compta/facture/invoicetemplate_list.php | 8 +++++++- htdocs/compta/facture/list.php | 5 +++++ htdocs/compta/paiement/cheque/list.php | 5 +++++ htdocs/compta/paiement/list.php | 5 +++++ htdocs/compta/paiement/tovalidate.php | 5 +++++ htdocs/compta/prelevement/bons.php | 5 +++++ htdocs/compta/prelevement/card.php | 5 +++++ htdocs/compta/prelevement/factures.php | 5 +++++ htdocs/compta/prelevement/fiche-rejet.php | 5 +++++ htdocs/compta/prelevement/list.php | 5 +++++ htdocs/contact/list.php | 5 +++++ htdocs/contrat/list.php | 5 +++++ htdocs/contrat/services_list.php | 5 +++++ htdocs/cron/list.php | 5 +++++ htdocs/don/list.php | 7 +++++++ htdocs/expedition/list.php | 8 +++++++- htdocs/expensereport/list.php | 6 ++++++ htdocs/fichinter/list.php | 5 +++++ htdocs/fourn/commande/list.php | 5 +++++ htdocs/fourn/facture/list.php | 5 +++++ htdocs/fourn/facture/paiement.php | 5 +++++ htdocs/fourn/product/list.php | 10 +++++++++- htdocs/loan/index.php | 5 +++++ htdocs/margin/checkMargins.php | 9 +++++---- htdocs/modulebuilder/template/myobject_list.php | 13 ++++++------- htdocs/opensurvey/list.php | 12 +++++------- htdocs/product/inventory/list.php | 11 +++++------ htdocs/product/list.php | 7 +++++++ htdocs/product/reassort.php | 5 +++++ htdocs/product/reassortlot.php | 5 +++++ htdocs/product/stock/mouvement.php | 5 +++++ htdocs/product/stock/productlot_list.php | 5 +++++ htdocs/projet/list.php | 5 +++++ htdocs/projet/tasks/list.php | 5 +++++ htdocs/societe/agenda.php | 2 +- htdocs/societe/list.php | 5 +++++ htdocs/societe/notify/card.php | 5 +++++ htdocs/societe/website.php | 5 +++++ htdocs/supplier_proposal/list.php | 5 +++++ htdocs/ticketsup/class/api_ticketsups.class.php | 15 +++++++-------- htdocs/ticketsup/list.php | 11 +++++------ htdocs/user/notify/card.php | 5 +++++ 65 files changed, 352 insertions(+), 55 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index ac45b3993a4..690e9fad1f1 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -188,6 +188,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index f3a6c9feb75..3910e1148b4 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -94,6 +94,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 7f48ad81ef8..eb4d331f228 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -256,7 +256,13 @@ 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 + { + $page = 0; + $offset = 0; + } } + $sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG); diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index b62b4e8f5ca..7bc929a7e6b 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -242,6 +242,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -334,7 +339,7 @@ if ($result) { $facture_static->ref = $objp->ref; $facture_static->id = $objp->facid; $facture_static->type = $objp->ftype; - + $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; $product_static->type = $objp->type; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 378b62c05b8..f7485e701b7 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -289,6 +289,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 7ab29657172..93073a62bd4 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -208,6 +208,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index a4d2ed81b56..2abd3fdc776 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -237,6 +237,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index a55c15952dc..a3e71cea0af 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -241,6 +241,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index aad7f514d50..4a52cb9a0e4 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -288,6 +288,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index aa6763654e3..13d0cbd30c5 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -262,6 +262,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $resql = $db->query($sql); if ($resql) $nbtotalofrecords = $db->num_rows($resql); else dol_print_error($db); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } // Add limit $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 43311a0b1e2..bf15230d47e 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -145,6 +145,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 2ef18ca3ca8..b0b5eee67ed 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -487,6 +487,9 @@ if ($rowid > 0) { $sql.=" AND datefin < '".$db->idate($now)."'"; } + + $sql.= " ".$db->order($sortfield,$sortorder); + // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -494,9 +497,13 @@ if ($rowid > 0) $resql = $db->query($sql); if ($resql) $nbtotalofrecords = $db->num_rows($result); else dol_print_error($db); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } - // Add order and limit - $sql.= " ".$db->order($sortfield,$sortorder); + $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); $resql = $db->query($sql); diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 2221c05a6b2..5f0288525a0 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -230,6 +230,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index ac520ce22b3..48d3ef57fd5 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -184,6 +184,11 @@ $nbtotalofrecords = ''; { $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 + { + $page = 0; + $offset = 0; + } }*/ $sql.= $db->plimit($conf->liste_limit+1, $offset); diff --git a/htdocs/assets/list.php b/htdocs/assets/list.php index b3bc1886fc7..2b68a1b6782 100644 --- a/htdocs/assets/list.php +++ b/htdocs/assets/list.php @@ -225,6 +225,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/assets/type.php b/htdocs/assets/type.php index f9e725acafa..c1a6d849c01 100644 --- a/htdocs/assets/type.php +++ b/htdocs/assets/type.php @@ -464,6 +464,9 @@ if ($rowid > 0) { $sql.=" AND datefin < '".$db->idate($now)."'"; } + + $sql.= " ".$db->order($sortfield,$sortorder); + // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -471,9 +474,13 @@ if ($rowid > 0) $resql = $db->query($sql); if ($resql) $nbtotalofrecords = $db->num_rows($result); else dol_print_error($db); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } - // Add order and limit - $sql.= " ".$db->order($sortfield,$sortorder); + $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); $resql = $db->query($sql); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 71240d63d8f..5fa8d267830 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -895,24 +895,22 @@ class Categorie extends CommonObject $sql.= ' AND s.rowid = sub.fk_categorie'; $sql.= ' AND sub.'.$subcol_name.' = '.$id; + $sql.= $this->db->order($sortfield, $sortorder); + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $this->db->query($sql); $nbtotalofrecords = $this->db->num_rows($result); - } - - $sql.= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 { $page = 0; + $offset = 0; } - $offset = $limit * $page; - - $sql.= $this->db->plimit($limit + 1, $offset); } + $sql.= $this->db->plimit($limit + 1, $offset); + $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index ed8a27f2d3d..36630b93092 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -318,6 +318,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 84fb6c411c8..93cbae527f1 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -93,6 +93,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1,$offset); diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 48949881659..676c9c3e98e 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -425,7 +425,13 @@ if ($object->fetch($id) >= 0) { $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 + { + $page = 0; + $offset = 0; + } } + //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets $sql .= $db->plimit($limit+1, $offset); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 761107b73c3..78aa5a0d9cb 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -335,6 +335,12 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index 205efc3ad91..2d97b06238b 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -102,6 +102,12 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 19640dc0ec0..5e3f9bade62 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -342,6 +342,12 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 3e751d97b01..3e077e8a749 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -273,14 +273,20 @@ else if ($search_year_date_when > 0) $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,12,false))."'"; } +$sql.= $db->order($sortfield, $sortorder); + $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 + { + $page = 0; + $offset = 0; + } } -$sql.= $db->order($sortfield, $sortorder); $sql.= $db->plimit($limit+1,$offset); $resql = $db->query($sql); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index e8c34743441..61383941c10 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -515,6 +515,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1,$offset); diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index c936bfb4519..b9e8cac609a 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -117,6 +117,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 553c62b1d97..f001d84a27d 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -192,6 +192,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php index 43fa2e48212..031a0ff354a 100644 --- a/htdocs/compta/paiement/tovalidate.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -85,6 +85,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 2e20701db59..02c6e7b08f0 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -87,6 +87,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index ed0977ebabf..a6d739f1f0c 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -322,6 +322,11 @@ if ($id > 0 || $ref) { $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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 64811c7604a..d446e64fe9b 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -170,6 +170,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 82431e3bdd2..2fbaaf7fbcb 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -169,6 +169,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 3bed588e10e..10634670f5f 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -111,6 +111,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 3d1fa3dcaef..0660b394f1b 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -349,6 +349,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index d1f4dd262ed..b3ee34731cc 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -301,6 +301,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 9a4c21b145b..0fc475c19fb 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -257,6 +257,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 8d448d5f514..81e9d57c03b 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -276,6 +276,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/don/list.php b/htdocs/don/list.php index fff82b50179..334d1f219c2 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -113,12 +113,19 @@ if (trim($search_name) != '') if ($search_amount) $sql.= natural_search('d.amount', $search_amount, 1); $sql.= $db->order($sortfield,$sortorder); + $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 + { + $page = 0; + $offset = 0; + } } + $sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index bdf2607f803..a3d44d7072a 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -233,14 +233,20 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; +$sql.= $db->order($sortfield,$sortorder); + $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 + { + $page = 0; + $offset = 0; + } } -$sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit + 1,$offset); //print $sql; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 75ab5fc8b9b..2bc7a624514 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -329,7 +329,13 @@ 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 + { + $page = 0; + $offset = 0; + } } + $sql.= $db->plimit($limit+1, $offset); //print $sql; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index c6d052f08b1..87d8b366ef8 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -230,6 +230,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index f0c5acdcf3e..c72c31b3a99 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -584,6 +584,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index b8fd5d2f054..95bbfe48e19 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -412,6 +412,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index ca8983b8c92..a47b76e4af8 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -784,6 +784,11 @@ if (empty($action)) { $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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 9348a2a8b70..47bc949a758 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -157,14 +157,22 @@ if ($fourn_id > 0) { $sql .= " AND ppf.fk_soc = ".$fourn_id; } + +$sql .= $db->order($sortfield,$sortorder); + // Count total nb of records without orderby and limit $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 + { + $page = 0; + $offset = 0; + } } -$sql .= $db->order($sortfield,$sortorder); + $sql .= $db->plimit($limit + 1, $offset); dol_syslog("fourn/product/list.php:", LOG_DEBUG); diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index caefb7829a4..7a6bee5d79f 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -91,6 +91,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 0952efb2507..d1c682540ff 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -205,10 +205,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); - if ($result) { - $nbtotalofrecords = $db->num_rows($result); - } else { - setEventMessages($db->lasterror, null, 'errors'); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; } } diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 46a1f51b06f..cbac5339384 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -262,14 +262,13 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } -// if total resultset is smaller then paging size (filtering), goto and load page 0 -if (($page * $limit) > $nbtotalofrecords) -{ - $page = 0; - $offset = 0; -} -// if total resultset is smaller the limit, no need to do paging. +// if total resultset is smaller than limit, no need to do paging adn restart select with limits. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index eb7f827972e..77934e68744 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -115,13 +115,6 @@ $sql = "SELECT p.id_sondage, p.fk_user_creat, p.format, p.date_fin, p.status, p. $sql.= " u.login, u.firstname, u.lastname"; $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; -// Count total nb of records -$nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); -} $sql.= " WHERE p.entity IN (".getEntity('survey').")"; if ($search_status != '-1' && $search_status != '') $sql.=natural_search("p.status", $search_status, 2); if ($search_expired == 'expired') $sql.=" AND p.date_fin < '".$db->idate($now)."'"; @@ -136,6 +129,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index f1ecf079041..4a6ca485686 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -233,12 +233,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); -} -// if total resultset is smaller then paging size (filtering), goto and load page 0 -if (($page * $limit) > $nbtotalofrecords) -{ - $page = 0; - $offset = 0; + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } // if total resultset is smaller the limit, no need to do paging. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index e5d6b145fb1..11be839aa4f 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -338,12 +338,19 @@ else $sql.=$hookmanager->resPrint; //if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet $sql.= $db->order($sortfield,$sortorder); + $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 + { + $page = 0; + $offset = 0; + } } + $sql.= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 798038e0a91..88b9f2080aa 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -155,6 +155,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index aebfd368d1b..423d0f4015d 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -167,6 +167,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 3758f5e96c7..883cd316c76 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -473,6 +473,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 562bc23804a..c9ac6269dbd 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -253,6 +253,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 08c8bb0aa2f..94a3850fe33 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -373,6 +373,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 654fa4d805c..b15207513ef 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -327,6 +327,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 10a3221f546..f992206ef23 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -164,7 +164,7 @@ if ($socid > 0) { if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) { - $newcardbutton.=''.$langs->trans("AddAction"); + $newcardbutton.=''.$langs->trans("AddAction"); $newcardbutton.= ''; $newcardbutton.= ''; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 41484e2ea87..58043bc511c 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -485,6 +485,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 31622c1b9d9..cd8212ae327 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -432,6 +432,11 @@ if ($result > 0) { $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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 8f3ea9c2588..97b31e09010 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -292,6 +292,11 @@ 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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 15392dcb1c1..6cc5b54f050 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -332,6 +332,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/ticketsup/class/api_ticketsups.class.php b/htdocs/ticketsup/class/api_ticketsups.class.php index ee696b34505..98af42fd262 100644 --- a/htdocs/ticketsup/class/api_ticketsups.class.php +++ b/htdocs/ticketsup/class/api_ticketsups.class.php @@ -258,16 +258,15 @@ class Ticketsups extends DolibarrApi if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - } - - if ($limit) { - if ($page < 0) { - $page = 0; + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; } - $offset = $limit * $page; - - $sql.= $db->plimit($limit + 1, $offset); } + + $sql.= $db->plimit($limit + 1, $offset); + $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); diff --git a/htdocs/ticketsup/list.php b/htdocs/ticketsup/list.php index 61dcf45ba83..d2127fd875f 100644 --- a/htdocs/ticketsup/list.php +++ b/htdocs/ticketsup/list.php @@ -255,12 +255,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); -} -// if total resultset is smaller then paging size (filtering), goto and load page 0 -if (($page * $limit) > $nbtotalofrecords) -{ - $page = 0; - $offset = 0; + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } // if total resultset is smaller the limit, no need to do paging. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 096567d728a..2bcf4fc0663 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -411,6 +411,11 @@ if ($result > 0) { $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 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); From 9d070cac874387291eb8698f52cf4ce1bc21d352 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 12:57:31 +0200 Subject: [PATCH 15/17] NEW Can add product in supplier order/invoice even w/o predefined price Add option SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY, SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY and SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY to restore restricted old behaviour. --- htdocs/core/class/commonobject.class.php | 4 +- .../class/fournisseur.commande.class.php | 16 ++--- .../fourn/class/fournisseur.facture.class.php | 65 +++++++++++++++++++ htdocs/fourn/commande/card.php | 43 ++++++------ htdocs/fourn/facture/card.php | 31 ++++----- htdocs/supplier_proposal/card.php | 54 ++++++++------- .../class/supplier_proposal.class.php | 64 +++++++++++++++++- 7 files changed, 203 insertions(+), 74 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 612a76e2877..6b0b2573042 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3594,12 +3594,12 @@ abstract class CommonObject * @param Societe $buyer Object thirdparty who buy * @return void */ - function formAddObjectLine($dateSelector,$seller,$buyer) + function formAddObjectLine($dateSelector, $seller, $buyer) { global $conf,$user,$langs,$object,$hookmanager; global $form,$bcnd,$var; - //Line extrafield + // Line extrafield require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafieldsline = new ExtraFields($this->db); $extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 4bc5cdcc993..0a6792bf8d7 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1481,13 +1481,14 @@ class CommandeFournisseur extends CommonOrder } if ($type < 0) return -1; - if ($this->statut == 0) + if ($this->statut == self::STATUS_DRAFT) { $this->db->begin(); if ($fk_product > 0) { - if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) + //if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) + if (! empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) { // Check quantity is enough dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." ref_supplier=".$ref_supplier); @@ -1502,13 +1503,11 @@ class CommandeFournisseur extends CommonOrder $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc if ($result > 0) { - $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice - $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice - // is remise percent not keyed but present for the product we add it - if ($remise_percent == 0 && $prod->remise_percent !=0) + $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice + // is remise percent not keyed but present for the product we add it + if ($remise_percent == 0 && $prod->remise_percent !=0) $remise_percent =$prod->remise_percent; - - } if ($result == 0) // If result == 0, we failed to found the supplier reference price { @@ -1539,6 +1538,7 @@ class CommandeFournisseur extends CommonOrder else { $this->error=$prod->error; + $this->db->rollback(); return -1; } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 7d8b09a17ce..09fbd18c9fb 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1509,6 +1509,71 @@ class FactureFournisseur extends CommonInvoice if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax2)) $txlocaltax2=0; + $this->db->begin(); + + if ($fk_product > 0) + { + if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) + { + // Check quantity is enough + dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." ref_supplier=".$ref_supplier); + $prod = new Product($this->db, $fk_product); + if ($prod->fetch($fk_product) > 0) + { + $product_type = $prod->type; + $label = $prod->label; + + // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok. + // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. + $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc + if ($result > 0) + { + $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice + // is remise percent not keyed but present for the product we add it + if ($remise_percent == 0 && $prod->remise_percent !=0) + $remise_percent =$prod->remise_percent; + } + if ($result == 0) // If result == 0, we failed to found the supplier reference price + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); + //$pu = $prod->fourn_pu; // We do not overwrite unit price + //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price + return -1; + } + if ($result == -1) + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); + return -1; + } + if ($result < -1) + { + $this->error=$prod->error; + $this->db->rollback(); + dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); + return -1; + } + } + else + { + $this->error=$prod->error; + $this->db->rollback(); + return -1; + } + } + } + else + { + $product_type = $type; + } + + $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); // Clean vat code diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 033cf251d4e..cb89dd3c2d3 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -364,12 +364,9 @@ if (empty($reshook)) { $productsupplier = new ProductFournisseur($db); - if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) // TODO this test seems useless - { - $idprod=0; - if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) - } - if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg)) + $idprod=0; + if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice'), $reg)) { $idprod=$reg[1]; $res=$productsupplier->fetch($idprod); @@ -393,6 +390,9 @@ if (empty($reshook)) if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); $type = $productsupplier->type; + $price_base_type = ($productsupplier->fourn_price_base_type?$productsupplier->fourn_price_base_type:'HT'); + + $ref_supplier = $productsupplier->ref_supplier; $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); @@ -408,8 +408,8 @@ if (empty($reshook)) $localtax1_tx, $localtax2_tx, $idprod, - $productsupplier->product_fourn_price_id, - $productsupplier->fourn_ref, + 0, // We already have the $idprod always defined + $ref_supplier, $remise_percent, 'HT', $pu_ttc, @@ -438,7 +438,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); } } - else if (empty($error)) + else if (empty($error)) // $price_ht is already set { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); @@ -457,22 +457,19 @@ if (empty($reshook)) $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - if (GETPOST('price_ht')!=='') + if ($price_ht !== '') { - $price_base_type = 'HT'; - $ht = price2num(GETPOST('price_ht')); - $ttc = 0; + $pu_ht = price2num($price_ht, 'MU'); // $pu_ht must be rounded according to settings } else { - $ttc = price2num(GETPOST('price_ttc')); - $ht = $ttc / (1 + ($tva_tx / 100)); - $price_base_type = 'HT'; + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); // $pu_ht must be rounded according to settings } - + $price_base_type = 'HT'; $pu_ht_devise = price2num($price_ht_devise, 'MU'); - $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, $ref_supplier, $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit, $pu_ht_devise); + $result=$object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, $ref_supplier, $remise_percent, $price_base_type, $pu_ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit, $pu_ht_devise); } //print "xx".$tva_tx; exit; @@ -2165,8 +2162,10 @@ elseif (! empty($object->id)) // Add free products/services form global $forceall, $senderissupplier, $dateSelector; - $forceall=1; $senderissupplier=1; $dateSelector=0; - if (! empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) $senderissupplier=2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. + $forceall=1; $dateSelector=0; + $senderissupplier=2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. + //if (! empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) $senderissupplier=2; + if (! empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier=1; // Show object lines $inputalsopricewithtax=0; @@ -2176,12 +2175,10 @@ elseif (! empty($object->id)) $num = count($object->lines); // Form to add new line - if ($object->statut == 0 && $user->rights->fournisseur->commande->creer) + if ($object->statut == CommandeFournisseur::STATUS_DRAFT && $user->rights->fournisseur->commande->creer) { if ($action != 'editline') { - $var = true; - // Add free products/services $object->formAddObjectLine(1, $societe, $mysoc); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 131ab04c1f7..1944a6e28df 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1087,6 +1087,8 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef=''; $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { @@ -1105,9 +1107,6 @@ if (empty($reshook)) $remise_percent=GETPOST('remise_percent'.$predef); $price_ht_devise = GETPOST('multicurrency_price_ht'); - $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); @@ -1167,7 +1166,7 @@ if (empty($reshook)) $idprod=0; if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) - if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg)) + if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice'), $reg)) { $idprod=$reg[1]; $res=$productsupplier->fetch($idprod); @@ -1183,7 +1182,6 @@ if (empty($reshook)) $res=$productsupplier->fetch($idprod); } - //Replaces $fk_unit with the product's if ($idprod > 0) { $label = $productsupplier->label; @@ -1191,17 +1189,17 @@ if (empty($reshook)) $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); - $tva_tx=get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, $_POST['idprodfournprice']); - $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, $_POST['idprodfournprice']); + $type = $productsupplier->type; + $price_base_type = ($productsupplier->fourn_price_base_type?$productsupplier->fourn_price_base_type:'HT'); + + $ref_supplier = $productsupplier->ref_supplier; + + $tva_tx=get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); + $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); if (empty($tva_tx)) $tva_npr=0; $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); - $type = $productsupplier->type; - $price_base_type = 'HT'; - - $rang = $object->line_max() +1; - $result=$object->addline( $desc, $productsupplier->fourn_pu, @@ -1217,13 +1215,13 @@ if (empty($reshook)) $tva_npr, $price_base_type, $type, - $rang, + -1, 0, $array_options, $productsupplier->fk_unit, 0, $productsupplier->fourn_multicurrency_unitprice, - $productsupplier->fourn_ref + $ref_supplier ); } if ($idprod == -99 || $idprod == 0) @@ -2928,7 +2926,10 @@ else print ''; global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; - $forceall=1; $senderissupplier=1; $dateSelector=0; $inputalsopricewithtax=1; + $forceall=1; $dateSelector=0; $inputalsopricewithtax=1; + $senderissupplier=2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. + //if (! empty($conf->global->SUPPLIER_INVOICE_WITH_NOPRICEDEFINED)) $senderissupplier=2; + if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier=1; // Show object lines if (! empty($object->lines)) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 8e391b0f1dd..abeb611aeaa 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -527,8 +527,8 @@ if (empty($reshook)) $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $ref_supplier = GETPOST('fourn_ref','alpha'); - - if (GETPOST('prod_entry_mode') == 'free') + $prod_entry_mode = GETPOST('prod_entry_mode'); + if ($prod_entry_mode == 'free') { $idprod=0; $price_ht = GETPOST('price_ht'); @@ -543,6 +543,7 @@ if (empty($reshook)) $qty = GETPOST('qty' . $predef); $remise_percent = GETPOST('remise_percent' . $predef); + $price_ht_devise = GETPOST('multicurrency_price_ht'); // Extrafields $extrafieldsline = new ExtraFields($db); @@ -556,17 +557,17 @@ if (empty($reshook)) } } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { + if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); $error ++; } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. + if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error ++; } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { + if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); $error ++; } @@ -581,16 +582,14 @@ if (empty($reshook)) // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $txtva par celui du produit - if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' + if ($prod_entry_mode != 'free' && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' { $productsupplier = new ProductFournisseur($db); - if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) // TODO this test seems useless - { - $idprod=0; - if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) - } - if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg)) + $idprod=0; + if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + + if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice'), $reg)) { $idprod=$reg[1]; $res=$productsupplier->fetch($idprod); @@ -608,12 +607,16 @@ if (empty($reshook)) if ($idprod > 0) { - $pu_ht = $productsupplier->fourn_pu; - $price_base_type = $productsupplier->fourn_price_base_type; - $type = $productsupplier->type; $label = $productsupplier->label; + $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); + + $pu_ht = $productsupplier->fourn_pu; + + $type = $productsupplier->type; + $price_base_type = ($productsupplier->fourn_price_base_type?$productsupplier->fourn_price_base_type:'HT'); + $ref_supplier = $productsupplier->ref_supplier; $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); @@ -665,7 +668,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); } } - else if((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) // Free product + else if((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) // Free product. // $price_ht is already set { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); @@ -683,20 +686,19 @@ if (empty($reshook)) $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - if (GETPOST('price_ht')!=='') + if ($price_ht !== '') { - $price_base_type = 'HT'; - $ht = price2num(GETPOST('price_ht')); - $ttc = 0; + $pu_ht = price2num($price_ht, 'MU'); // $pu_ht must be rounded according to settings } else { - $ttc = price2num(GETPOST('price_ttc')); - $ht = $ttc / (1 + ($tva_tx / 100)); - $price_base_type = 'HT'; + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); // $pu_ht must be rounded according to settings } + $price_base_type = 'HT'; + $pu_ht_devise = price2num($price_ht_devise, 'MU'); - $result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_supplier, $fk_unit); + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_supplier, $fk_unit); //$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit); } @@ -1674,7 +1676,9 @@ if ($action == 'create') // Add free products/services form global $forceall, $senderissupplier, $dateSelector; - $forceall=1; $senderissupplier=2; $dateSelector=0; // $senderissupplier=2 is same than 1 but disable test on minimum qty. + $forceall=1; $dateSelector=0; + $senderissupplier=2; // $senderissupplier=2 is same than 1 but disable test on minimum qty. + if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier=1; if (! empty($object->lines)) $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index b88d24070c6..a39fba04b81 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -394,10 +394,72 @@ class SupplierProposal extends CommonObject // Check parameters if ($type < 0) return -1; - if ($this->statut == 0) + if ($this->statut == self::STATUS_DRAFT) { $this->db->begin(); + if ($fk_product > 0) + { + if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) + { + // Check quantity is enough + dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." ref_supplier=".$ref_supplier); + $prod = new Product($this->db, $fk_product); + if ($prod->fetch($fk_product) > 0) + { + $product_type = $prod->type; + $label = $prod->label; + + // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok. + // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. + $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc + if ($result > 0) + { + $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice + // is remise percent not keyed but present for the product we add it + if ($remise_percent == 0 && $prod->remise_percent !=0) + $remise_percent =$prod->remise_percent; + } + if ($result == 0) // If result == 0, we failed to found the supplier reference price + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); + //$pu = $prod->fourn_pu; // We do not overwrite unit price + //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price + return -1; + } + if ($result == -1) + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); + return -1; + } + if ($result < -1) + { + $this->error=$prod->error; + $this->db->rollback(); + dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); + return -1; + } + } + else + { + $this->error=$prod->error; + $this->db->rollback(); + return -1; + } + } + } + else + { + $product_type = $type; + } + // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker From 5eb7c7ffff8ffa9c326b3d17b7bf3623d0b065bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 13:22:34 +0200 Subject: [PATCH 16/17] FIX Edit of ref_supplier in supplier invoice --- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- htdocs/fourn/class/fournisseur.commande.class.php | 1 - htdocs/fourn/class/fournisseur.facture.class.php | 13 ++++++------- htdocs/fourn/commande/card.php | 7 +++++-- htdocs/fourn/facture/card.php | 13 +++++++++++-- htdocs/supplier_proposal/card.php | 11 +++++++++++ 6 files changed, 34 insertions(+), 13 deletions(-) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 63321d16506..a6f5fef5310 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -132,7 +132,7 @@ $coldisplay=-1; // We remove first td if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { ?> - + 0) { - //if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) if (! empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) { // Check quantity is enough diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 09fbd18c9fb..46075c5641f 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1490,8 +1490,6 @@ class FactureFournisseur extends CommonInvoice * @param double $pu_ht_devise Amount in currency * @param string $ref_supplier Supplier ref * @return int >0 if OK, <0 if KO - * - * FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order. */ public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0, $ref_supplier='') { @@ -1717,12 +1715,13 @@ class FactureFournisseur extends CommonInvoice * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Amount in currency + * @param string $ref_supplier Supplier ref * @return int <0 if KO, >0 if OK */ - public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null, $pu_ht_devise=0) + public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null, $pu_ht_devise=0, $ref_supplier='') { global $mysoc; - dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$fk_unit", LOG_DEBUG); + dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$fk_unit,$pu_ht_devise,$ref_supplier", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $pu = price2num($pu); @@ -1800,6 +1799,7 @@ class FactureFournisseur extends CommonInvoice $line->pu_ttc = $pu_ttc; $line->qty = $qty; $line->remise_percent = $remise_percent; + $line->ref_supplier = $ref_supplier; $line->vat_src_code=$vat_src_code; $line->tva_tx = $vatrate; @@ -2714,7 +2714,6 @@ class SupplierInvoiceLine extends CommonObjectLine $this->fk_facture_fourn = $obj->fk_facture_fourn; $this->description = $obj->description; $this->product_ref = $obj->product_ref; - $this->ref = $obj->product_ref; $this->ref_supplier = $obj->ref_supplier; $this->libelle = $obj->label; $this->label = $obj->label; @@ -2842,12 +2841,12 @@ class SupplierInvoiceLine extends CommonObjectLine $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET"; $sql.= " description ='".$this->db->escape($this->description)."'"; - $sql.= ", ref ='".$this->db->escape($this->ref)."'"; + $sql.= ", ref ='".$this->db->escape($this->ref_supplier ? $this->ref_supplier : $this->ref)."'"; $sql.= ", pu_ht = ".price2num($this->pu_ht); $sql.= ", pu_ttc = ".price2num($this->pu_ttc); $sql.= ", qty = ".price2num($this->qty); $sql.= ", remise_percent = ".price2num($this->remise_percent); - $sql.= ", vat_src_code = '".(empty($this->vat_src_code)?'':$this->vat_src_code)."'"; + $sql.= ", vat_src_code = '".$this->db->escape(empty($this->vat_src_code)?'':$this->vat_src_code)."'"; $sql.= ", tva_tx = ".price2num($this->tva_tx); $sql.= ", localtax1_tx = ".price2num($this->localtax1_tx); $sql.= ", localtax2_tx = ".price2num($this->localtax2_tx); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index cb89dd3c2d3..ae4ad7c25be 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -553,9 +553,12 @@ if (empty($reshook)) } $productsupplier = new ProductFournisseur($db); - if ($line->fk_product > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid','int')) < 0 ) + if (! empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) { - setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); + if ($line->fk_product > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid','int')) < 0 ) + { + setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); + } } $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 1944a6e28df..5cb8e42681e 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1000,8 +1000,17 @@ if (empty($reshook)) $price_base_type = 'TTC'; } - if (GETPOST('productid')) + if (GETPOST('productid') > 0) { + $productsupplier = new ProductFournisseur($db); + if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) + { + if (GETPOST('productid') > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), GETPOST('productid'), 'none', GETPOST('socid','int')) < 0 ) + { + setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); + } + } + $prod = new Product($db); $prod->fetch(GETPOST('productid')); $label = $prod->description; @@ -1042,7 +1051,7 @@ if (empty($reshook)) } } - $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise); + $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref','alpha')); if ($result >= 0) { unset($_POST['label']); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index abeb611aeaa..1c9b4afc5ec 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -774,6 +774,7 @@ if (empty($reshook)) // Mise a jour d'une ligne dans la demande de prix else if ($action == 'updateligne' && $user->rights->supplier_proposal->creer && GETPOST('save') == $langs->trans("Save")) { + // Define info_bits $info_bits = 0; if (preg_match('/\*/', GETPOST('tva_tx'))) @@ -812,6 +813,16 @@ if (empty($reshook)) // Check minimum price $productid = GETPOST('productid', 'int'); if (! empty($productid)) { + + $productsupplier = new ProductFournisseur($db); + if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) + { + if ($productid > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $productid, 'none', GETPOST('socid','int')) < 0 ) + { + setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); + } + } + $product = new Product($db); $res = $product->fetch($productid); From 90723357c415aa3d5feedbce3c44929a8116f113 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 13:50:05 +0200 Subject: [PATCH 17/17] Look and feel v8 --- htdocs/product/agenda.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index c544b68cf8d..166265ba247 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -175,11 +175,11 @@ if ($id > 0 || $ref) { if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) { - $morehtmlcenter.=''.$langs->trans("AddAction").''; + $morehtmlcenter.=''.$langs->trans("AddAction").''; } else { - $morehtmlcenter.=''.$langs->trans("AddAction").''; + $morehtmlcenter.=''.$langs->trans("AddAction").''; } }