From c79b9b97043b05f156114265c5db3fb149189e86 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Mon, 27 May 2019 11:18:29 +0200 Subject: [PATCH 01/12] Fix create bills on mass action does not retrieve the original currency code --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 0c66d51d589..00ffe03c7ed 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -510,7 +510,7 @@ if ($massaction == 'confirm_createbills') $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; $objecttmp->fk_project = $cmd->fk_project; - + $objecttmp->multicurrency_code = $cmd->multicurrency_code; $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($datefacture)) { From 3c05cfe6901a6aeaa1dcee41fd45a380317344a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 May 2019 10:50:33 +0200 Subject: [PATCH 02/12] Fix useless test --- htdocs/core/class/commonobject.class.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b64ae066cb1..b9c58477757 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3718,8 +3718,6 @@ abstract class CommonObject $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); foreach($dirtpls as $module => $reldir) { - if (!empty($module) && empty($conf->$module->enabled)) continue; - if (!empty($module)) { $tpl = dol_buildpath($reldir.'/objectline_create.tpl.php'); @@ -3979,8 +3977,6 @@ abstract class CommonObject $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); foreach($dirtpls as $module => $reldir) { - if (!empty($module) && empty($conf->$module->enabled)) continue; - if (!empty($module)) { $tpl = dol_buildpath($reldir.'/objectline_view.tpl.php'); @@ -4011,8 +4007,6 @@ abstract class CommonObject $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); foreach($dirtpls as $module => $reldir) { - if (!empty($module) && empty($conf->$module->enabled)) continue; - if (!empty($module)) { $tpl = dol_buildpath($reldir.'/objectline_edit.tpl.php'); @@ -4216,8 +4210,6 @@ abstract class CommonObject $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); foreach($dirtpls as $module => $reldir) { - if (!empty($module) && empty($conf->$module->enabled)) continue; - if (!empty($module)) { $tpl = dol_buildpath($reldir.'/originproductline.tpl.php'); From 912e29a746cd02e6e8d001bc5779ac3d52e969b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 May 2019 11:06:01 +0200 Subject: [PATCH 03/12] FIX #11244 --- htdocs/core/class/commonobject.class.php | 48 ++++++------------------ htdocs/main.inc.php | 10 ++++- 2 files changed, 20 insertions(+), 38 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b9c58477757..1a6d5018eae 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3716,16 +3716,10 @@ abstract class CommonObject // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach($dirtpls as $module => $reldir) + foreach($dirtpls as $reldir) { - if (!empty($module)) - { - $tpl = dol_buildpath($reldir.'/objectline_create.tpl.php'); - } - else - { - $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_create.tpl.php'; - } + $tpl = dol_buildpath($reldir.'/objectline_create.tpl.php'); + if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { @@ -3975,16 +3969,10 @@ abstract class CommonObject // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach($dirtpls as $module => $reldir) + foreach($dirtpls as $reldir) { - if (!empty($module)) - { - $tpl = dol_buildpath($reldir.'/objectline_view.tpl.php'); - } - else - { - $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_view.tpl.php'; - } + $tpl = dol_buildpath($reldir.'/objectline_view.tpl.php'); + if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { @@ -4005,16 +3993,10 @@ abstract class CommonObject // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach($dirtpls as $module => $reldir) + foreach($dirtpls as $reldir) { - if (!empty($module)) - { - $tpl = dol_buildpath($reldir.'/objectline_edit.tpl.php'); - } - else - { - $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_edit.tpl.php'; - } + $tpl = dol_buildpath($reldir.'/objectline_edit.tpl.php'); + if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { @@ -4208,16 +4190,10 @@ abstract class CommonObject // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach($dirtpls as $module => $reldir) + foreach($dirtpls as $reldir) { - if (!empty($module)) - { - $tpl = dol_buildpath($reldir.'/originproductline.tpl.php'); - } - else - { - $tpl = DOL_DOCUMENT_ROOT.$reldir.'/originproductline.tpl.php'; - } + $tpl = dol_buildpath($reldir.'/originproductline.tpl.php'); + if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ca182c7b337..c73daa011a5 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -383,13 +383,19 @@ if ((! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($conf-> if (GETPOST('disablemodules','alpha')) $_SESSION["disablemodules"]=GETPOST('disablemodules','alpha'); if (! empty($_SESSION["disablemodules"])) { - $disabled_modules=explode(',',$_SESSION["disablemodules"]); + $modulepartkeys = array('css', 'js', 'tabs', 'triggers', 'login', 'substitutions', 'menus', 'theme', 'sms', 'tpl', 'barcode', 'models', 'societe', 'hooks', 'dir', 'syslog', 'tpllinkable', 'contactelement', 'moduleforexternal'); + + $disabled_modules=explode(',',$_SESSION["disablemodules"]); foreach($disabled_modules as $module) { if ($module) { - if (empty($conf->$module)) $conf->$module=new stdClass(); + if (empty($conf->$module)) $conf->$module=new stdClass(); // To avoid warnings $conf->$module->enabled=false; + foreach($modulepartkeys as $modulepartkey) + { + unset($conf->modules_parts[$modulepartkey][$module]); + } if ($module == 'fournisseur') // Special case { $conf->supplier_order->enabled=0; From 15fd24a511056862996296d4eb4fdc137a3640c6 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 31 May 2019 12:14:51 +0200 Subject: [PATCH 04/12] Fix : remove hardcoded llx_ prefix --- .../core/modules/modReceiptPrinter.class.php | 4 ++-- htdocs/core/modules/modStock.class.php | 2 +- htdocs/install/repair.php | 2 +- htdocs/install/upgrade2.php | 22 +++++++++---------- htdocs/website/class/website.class.php | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 50c93f07220..49a12b5942c 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -138,8 +138,8 @@ class modReceiptPrinter extends DolibarrModules // Clean before activation $this->remove($options); $sql = array( - "CREATE TABLE IF NOT EXISTS llx_printer_receipt (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), fk_type integer, fk_profile integer, parameter varchar(128), entity integer) ENGINE=innodb;", - "CREATE TABLE IF NOT EXISTS llx_printer_receipt_template (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), template text, entity integer) ENGINE=innodb;", + "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), fk_type integer, fk_profile integer, parameter varchar(128), entity integer) ENGINE=innodb;", + "CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt_template (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), template text, entity integer) ENGINE=innodb;", ); return $this->_init($sql,$options); } diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 1c0393b3653..5e358c68841 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -274,7 +274,7 @@ class modStock extends DolibarrModules 'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10" ); $this->import_run_sql_after_array[$r]=array( // Because we may change data that are denormalized, we must update dernormalized data after. - 'UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid);' + 'UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);' ); } diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 229ae0a3c3e..2e4847e2a97 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -774,7 +774,7 @@ if ($ok && GETPOST('clean_product_stock_batch','alpha')) if ($resql2) { // We update product_stock, so we must field stock into product too. - $sql3='UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid)'; + $sql3='UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid)'; $resql3=$db->query($sql3); if (! $resql3) { diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index be31b1f6452..1c87d333795 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -660,8 +660,8 @@ function migrate_paiements_orphelins_1($db,$langs,$conf) $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; $sql.= " bu2.url_id as socid"; $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; - $sql.= " LEFT JOIN llx_paiement_facture as pf ON pf.fk_paiement = p.rowid"; - $sql.= " LEFT JOIN llx_bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')"; $sql.= " WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid"; $sql.= " AND b.rappro = 1"; $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; @@ -787,8 +787,8 @@ function migrate_paiements_orphelins_2($db,$langs,$conf) $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; $sql.= " bu2.url_id as socid"; $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; - $sql.= " LEFT JOIN llx_paiement_facture as pf ON pf.fk_paiement = p.rowid"; - $sql.= " LEFT JOIN llx_bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')"; $sql.= " WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid"; $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; @@ -1104,7 +1104,7 @@ function migrate_contracts_date1($db,$langs,$conf) print '
'; print ''.$langs->trans('MigrationContractsEmptyDatesUpdate')."
\n"; - $sql="update llx_contrat set date_contrat=tms where date_contrat is null"; + $sql="update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); if (! $resql) dol_print_error($db); @@ -1113,7 +1113,7 @@ function migrate_contracts_date1($db,$langs,$conf) else print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')."
\n"; - $sql="update llx_contrat set datec=tms where datec is null"; + $sql="update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); if (! $resql) dol_print_error($db); @@ -1204,7 +1204,7 @@ function migrate_contracts_date3($db,$langs,$conf) print '
'; print ''.$langs->trans('MigrationContractsIncoherentCreationDateUpdate')."
\n"; - $sql="update llx_contrat set datec=date_contrat where datec is null or datec > date_contrat"; + $sql="update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_date3"); $resql = $db->query($sql); if (! $resql) dol_print_error($db); @@ -1231,7 +1231,7 @@ function migrate_contracts_open($db,$langs,$conf) print '
'; print ''.$langs->trans('MigrationReopeningContracts')."
\n"; - $sql = "SELECT c.rowid as cref FROM llx_contrat as c, llx_contratdet as cd"; + $sql = "SELECT c.rowid as cref FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."contratdet as cd"; $sql.= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_open"); $resql = $db->query($sql); @@ -1964,7 +1964,7 @@ function migrate_modeles($db,$langs,$conf) if (count($modellist)==0) { // Aucun model par defaut. - $sql=" insert into llx_document_model(nom,type) values('crabe','invoice')"; + $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')"; $resql = $db->query($sql); if (! $resql) dol_print_error($db); } @@ -1977,7 +1977,7 @@ function migrate_modeles($db,$langs,$conf) if (count($modellist)==0) { // Aucun model par defaut. - $sql=" insert into llx_document_model(nom,type) values('einstein','order')"; + $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')"; $resql = $db->query($sql); if (! $resql) dol_print_error($db); } @@ -1990,7 +1990,7 @@ function migrate_modeles($db,$langs,$conf) if (count($modellist)==0) { // Aucun model par defaut. - $sql=" insert into llx_document_model(nom,type) values('rouget','shipping')"; + $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')"; $resql = $db->query($sql); if (! $resql) dol_print_error($db); } diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 432851b4bd4..bfd6a0dcb9e 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -850,7 +850,7 @@ class Website extends CommonObject } foreach($listofpages as $pageid => $objectpageold) { - $line = 'INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, title, description, keyword, status, date_creation, tms, lang, import_key, grabbed_from, content)'; + $line = 'INSERT INTO '.MAIN_DB_PREFIX.'website_page(rowid, fk_page, fk_website, pageurl, title, description, keyword, status, date_creation, tms, lang, import_key, grabbed_from, content)'; $line.= " VALUES("; $line.= $objectpageold->newid."+__MAXROWID__, "; $line.= ($objectpageold->newfk_page ? $this->db->escape($objectpageold->newfk_page)."+__MAXROWID__" : "null").", "; From 9ab2f4494644d6e9ea2b8558767be1a41204ecc8 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 31 May 2019 15:14:56 +0200 Subject: [PATCH 05/12] Fix : missing rights test to display tag create link --- htdocs/categories/index.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 9f41c0b016a..d6a314791c8 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -65,9 +65,12 @@ $arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css') llxHeader('',$title,'','',0,0,$arrayofjs,$arrayofcss); -$newcardbutton = ''.$langs->trans("NewCategory").''; -$newcardbutton.= ''; -$newcardbutton.= ''; +$newcardbutton=''; +if($user->rights->categorie->creer) { + $newcardbutton = ''.$langs->trans("NewCategory").''; + $newcardbutton.= ''; + $newcardbutton.= ''; +} print load_fiche_titre($title, $newcardbutton); From 6dd01e86e9834c783a5a0a150050c905cec64aab Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 31 May 2019 15:53:23 +0200 Subject: [PATCH 06/12] Fix : avoid warning and uniformize var use --- htdocs/comm/action/list.php | 2 +- htdocs/comm/action/rapport/index.php | 2 +- htdocs/compta/paiement.php | 2 +- htdocs/compta/sociales/document.php | 2 +- htdocs/compta/tva/document.php | 3 ++- htdocs/fourn/facture/paiement.php | 2 +- htdocs/hrm/admin/admin_establishment.php | 2 +- htdocs/loan/document.php | 2 +- htdocs/resource/list.php | 3 +-- htdocs/societe/notify/index.php | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index ae411addb25..048308c9c20 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -87,7 +87,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1 || $page == null) { $page = 0 ; } +if (empty($page) || $page == -1) { $page = 0 ; } $offset = $limit * $page ; if (! $sortorder) { diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 7e4108b470b..703d35c8480 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -42,7 +42,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1 || $page == null) { $page = 0 ; } +if (empty($page) || $page == -1) { $page = 0 ; } $offset = $limit * $page ; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="a.datep"; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 805bdbdf79e..4888b758cc1 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -817,7 +817,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie */ if (! GETPOST('action','aZ09')) { - if ($page == -1) $page = 0 ; + if (empty($page) || $page == -1) $page = 0 ; $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 490dbf3a1fe..36d51ff9f01 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -55,7 +55,7 @@ $result = restrictedArea($user, 'tax', $id, 'chargesociales','charges'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { +if (empty($page) || $page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index b83cad80bdd..1653cc28460 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -56,9 +56,10 @@ $result = restrictedArea($user, 'tax', $id, 'vat','charges'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { +if (empty($page) || $page == -1) { $page = 0; } + $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 57ca70dfa98..3a47b496394 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -753,7 +753,7 @@ if (empty($action)) $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); - if ($page == -1 || $page == null) { $page = 0 ; } + if (empty($page) || $page == -1) { $page = 0 ; } $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 996ddd58ed3..d28323240dd 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -54,7 +54,7 @@ $sortfield = GETPOST("sortfield"); if (!$sortorder) $sortorder="DESC"; if (!$sortfield) $sortfield="e.rowid"; -if ($page == -1) { +if (empty($page) || $page == -1) { $page = 0 ; } diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index f9d17c563fa..69050a5e10d 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -47,7 +47,7 @@ $result = restrictedArea($user, 'loan', $id, '',''); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { +if (empty($page) || $page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 68f91327f6d..f6e81b89773 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -97,8 +97,7 @@ if (empty($arch)) $arch = 0; $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page"); -$page = is_numeric($page) ? $page : 0; -$page = $page == -1 ? 0 : $page; +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/societe/notify/index.php b/htdocs/societe/notify/index.php index 3326e431178..c1d99620b89 100644 --- a/htdocs/societe/notify/index.php +++ b/htdocs/societe/notify/index.php @@ -42,7 +42,7 @@ if ($sortfield == "") $sortfield="s.nom"; } -if ($page == -1 || $page == null) { $page = 0 ; } +if (empty($page) || $page == -1) { $page = 0 ; } $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; From 0372276a7bb77a124b81890af2104c3964cf8b4b Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 31 May 2019 16:04:12 +0200 Subject: [PATCH 07/12] Fix : warnings in resource module --- htdocs/resource/class/dolresource.class.php | 6 ++++-- htdocs/resource/class/html.formresource.class.php | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 7c3999db7c9..9a595a5b650 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -530,13 +530,13 @@ class Dolresource extends CommonObject if ($limit) $sql.= $this->db->plimit($limit, $offset); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); + $this->lines=array(); $resql=$this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); if ($num) { - $this->lines=array(); while ($obj = $this->db->fetch_object($resql)) { $line = new Dolresource($this->db); @@ -829,6 +829,8 @@ class Dolresource extends CommonObject $sql .= ' ORDER BY resource_type'; dol_syslog(get_class($this)."::getElementResources", LOG_DEBUG); + + $resources = array(); $resql = $this->db->query($sql); if ($resql) { @@ -879,7 +881,7 @@ class Dolresource extends CommonObject { global $langs; - if (count($this->cache_code_type_resource)) return 0; // Cache deja charge + if (!empty($this->cache_code_type_resource) && count($this->cache_code_type_resource)) return 0; // Cache deja charge $sql = "SELECT rowid, code, label, active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_resource"; diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 19bed957f74..06d253493c0 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -85,8 +85,6 @@ class FormResource $out = '
'; $out.= ''; } - //$out.= ''; - //$out.= ''; if ($resourcestat) { From 916d3ce9311a1fb8f130cc65be706cfec474d710 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 2 Jun 2019 11:00:58 +0200 Subject: [PATCH 08/12] Fix : only invoice active lines of a contract --- htdocs/compta/facture/card.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 10a8296c144..9f96e9ee7f7 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1378,8 +1378,9 @@ if (empty($reshook)) { // Don't add lines with qty 0 when coming from a shipment including all order lines if($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; - // Don't add closed lines when coming from a contract - if($srcobject->element == 'contrat' && $lines[$i]->statut == 5) continue; + // Don't add inactive or closed lines when coming from a contract + if (! isset( $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '0,5'; + if($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE))) continue; $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); From 3e9fbf0148c6c324e89c3ca962bb2481d82d4f10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Jun 2019 12:14:07 +0200 Subject: [PATCH 09/12] Update index.php --- htdocs/categories/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index d6a314791c8..06b70616792 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -66,7 +66,7 @@ $arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css') llxHeader('',$title,'','',0,0,$arrayofjs,$arrayofcss); $newcardbutton=''; -if($user->rights->categorie->creer) { +if (! empty($user->rights->categorie->creer)) { $newcardbutton = ''.$langs->trans("NewCategory").''; $newcardbutton.= ''; $newcardbutton.= ''; From cb927847ab288500bc626d4e08464dc081dc482b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Jun 2019 12:16:12 +0200 Subject: [PATCH 10/12] Update dolresource.class.php --- htdocs/resource/class/dolresource.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 9a595a5b650..43e697a101a 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -881,7 +881,7 @@ class Dolresource extends CommonObject { global $langs; - if (!empty($this->cache_code_type_resource) && count($this->cache_code_type_resource)) return 0; // Cache deja charge + if (is_array($this->cache_code_type_resource) && count($this->cache_code_type_resource)) return 0; // Cache deja charge $sql = "SELECT rowid, code, label, active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_resource"; From 7020e1ef29bb95a347ebc4d15af6a2450bf71771 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Jun 2019 12:27:32 +0200 Subject: [PATCH 11/12] Update card.php --- htdocs/compta/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9f96e9ee7f7..04cb48f4c09 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1378,8 +1378,8 @@ if (empty($reshook)) { // Don't add lines with qty 0 when coming from a shipment including all order lines if($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; - // Don't add inactive or closed lines when coming from a contract - if (! isset( $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '0,5'; + // Don't add closed lines when coming from a contract (Set constant to '0,5' to exclude also inactive lines) + if (! isset( $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '5'; if($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE))) continue; $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); From 4bbef9b4787f2238f9bd0844c9803df59379aebf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Jun 2019 12:29:05 +0200 Subject: [PATCH 12/12] Update card.php --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 04cb48f4c09..df6aa92ff54 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1380,7 +1380,7 @@ if (empty($reshook)) if($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; // Don't add closed lines when coming from a contract (Set constant to '0,5' to exclude also inactive lines) if (! isset( $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '5'; - if($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE))) continue; + if ($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE))) continue; $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle);