From c79b9b97043b05f156114265c5db3fb149189e86 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Mon, 27 May 2019 11:18:29 +0200 Subject: [PATCH 01/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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 d47913ed197fdaa20e5f229c4bed82d6fba8d0a0 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 31 May 2019 16:33:32 +0200 Subject: [PATCH 08/29] Fix : add refclient on bulk invoicing --- htdocs/core/actions_massactions.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 381adbff567..9ca7fa03cca 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -565,6 +565,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; + if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($datefacture)) From 916d3ce9311a1fb8f130cc65be706cfec474d710 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 2 Jun 2019 11:00:58 +0200 Subject: [PATCH 09/29] 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 10/29] 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 11/29] 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 12/29] 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 13/29] 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); From 094719e0990be574ecb54aa9d94f2d74b04f0a6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Jun 2019 15:53:16 +0200 Subject: [PATCH 14/29] Fix prefix --- htdocs/website/class/website.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 48319b02cab..f05dd0723b4 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -844,8 +844,10 @@ class Website extends CommonObject } foreach($listofpages as $pageid => $objectpageold) { - $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("; + // Warning: We must keep llx_ here. It is a generic SQL. + $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.= " VALUES("; $line.= $objectpageold->newid."+__MAXROWID__, "; $line.= ($objectpageold->newfk_page ? $this->db->escape($objectpageold->newfk_page)."+__MAXROWID__" : "null").", "; $line.= "__WEBSITE_ID__, "; From 664e0b81d8feb03ab7a9a116f44f71baca22d483 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jun 2019 22:07:34 +0200 Subject: [PATCH 15/29] Debug module BOM --- htdocs/bom/class/bom.class.php | 109 ++++++------------ htdocs/bom/tpl/objectline_view.tpl.php | 11 +- htdocs/core/actions_addupdatedelete.inc.php | 1 - htdocs/core/ajax/row.php | 5 + htdocs/core/class/commonobject.class.php | 28 ++++- .../install/mysql/migration/9.0.0-10.0.0.sql | 4 + .../install/mysql/tables/llx_bom_bom.key.sql | 2 +- .../mysql/tables/llx_bom_bomline.key.sql | 2 +- .../template/class/myobject.class.php | 32 ++++- 9 files changed, 110 insertions(+), 84 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 8442a640fc0..e7083e767a2 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -41,6 +41,12 @@ class BOM extends CommonObject */ public $table_element = 'bom_bom'; + /** + * @var string Name of subtable if this object has sub lines + */ + public $table_element_line = 'bom_bomline'; + public $fk_element = 'fk_bom'; + /** * @var int Does bom support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ @@ -57,9 +63,6 @@ class BOM extends CommonObject public $picto = 'bom'; - public $table_element_line = 'bom_bomline'; - - const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; const STATUS_CANCELED = 9; @@ -222,7 +225,13 @@ class BOM extends CommonObject $this->db->begin(); // Load source object - $object->fetchCommon($fromid); + $result = $object->fetchCommon($fromid); + if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); + + // Get lines so they will be clone + //foreach($object->lines as $line) + // $line->fetch_optionals(); + // Reset some properties unset($object->id); unset($object->fk_user_creat); @@ -231,7 +240,7 @@ class BOM extends CommonObject // Clear fields $object->ref = "copy_of_".$object->ref; $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... + // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { @@ -256,6 +265,29 @@ class BOM extends CommonObject $this->errors = $object->errors; } + if (! $error) + { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) + { + $error++; + } + } + + if (! $error) + { + // copy external contacts if same company + if (property_exists($this, 'socid') && $this->socid == $object->socid) + { + if ($this->copy_linked_contact($object, 'external') < 0) + $error++; + } + } + + // If there is lines, create lines too + + + unset($object->context['createfromclone']); // End @@ -854,7 +886,7 @@ class BOM extends CommonObject $this->lines=array(); $objectline = new BOMLine($this->db); - $result = $objectline->fetchAll('', '', 0, 0, array('customsql'=>'fk_bom = '.$this->id)); + $result = $objectline->fetchAll('ASC', 'rank', 0, 0, array('customsql'=>'fk_bom = '.$this->id)); if (is_numeric($result)) { @@ -1071,71 +1103,6 @@ class BOMLine extends CommonObject return $this->createCommon($user, $notrigger); } - /** - * Clone an object into another one - * - * @param User $user User that creates - * @param int $fromid Id of object to clone - * @return mixed New object created, <0 if KO - */ - public function createFromClone(User $user, $fromid) - { - global $langs, $hookmanager, $extrafields; - $error = 0; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $object = new self($this->db); - - $this->db->begin(); - - // Load source object - $object->fetchCommon($fromid); - // Reset some properties - unset($object->id); - unset($object->fk_user_creat); - unset($object->import_key); - - // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... - // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) - { - $extrafields->fetch_name_optionals_label($this->element); - foreach($object->array_options as $key => $option) - { - $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) - { - //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; - unset($object->array_options[$key]); - } - } - } - - // Create clone - $object->context['createfromclone'] = 'createfromclone'; - $result = $object->createCommon($user); - if ($result < 0) { - $error++; - $this->error = $object->error; - $this->errors = $object->errors; - } - - unset($object->context['createfromclone']); - - // End - if (!$error) { - $this->db->commit(); - return $object; - } else { - $this->db->rollback(); - return -1; - } - } - /** * Load object in memory from the database * diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index d3fb1f7607b..6df0362d1c4 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -57,7 +57,7 @@ $domData .= ' data-qty="'.$line->qty.'"'; $domData .= ' data-product_type="'.$line->product_type.'"'; // Lines for extrafield -$objectline = new BOMLine($this->db); +$objectline = new BOMLine($object->db); ?> @@ -68,12 +68,9 @@ $objectline = new BOMLine($this->db);
textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) - { - print (! empty($line->description) && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; - } + $tmpproduct = new Product($object->db); + $tmpproduct->fetch($line->fk_product); + print $tmpproduct->getNomUrl(1); ?> diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 40529413bbe..20e4d6a03ca 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -244,7 +244,6 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd) $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); // ... - $result=$objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); if (is_object($result) || $result > 0) { diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 7270409a47a..2e2c8891b62 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -20,6 +20,11 @@ * \file htdocs/core/ajax/row.php * \brief File to return Ajax response on Row move. * This ajax page is called when doing an up or down drag and drop. + * Parameters: + * roworder (Example: '1,3,2,4'), + * table_element_line (Example: 'commandedet') + * fk_element (Example: 'fk_order') + * element_id (Example: 1) */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disable token renewal diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9852e2f2fb0..8754200117e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2443,8 +2443,9 @@ abstract class CommonObject */ public function updateRangOfLine($rowid, $rang) { - $fieldposition = 'rang'; + $fieldposition = 'rang'; // @TODO Rename 'rang' and 'position' into 'rank' if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; + if (in_array($this->table_element_line, array('bom_bomline'))) $fieldposition = 'rank'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; $sql.= ' WHERE rowid = '.$rowid; @@ -7245,6 +7246,31 @@ abstract class CommonObject if ($result < 0) $error++; } + // Create lines + if (! empty($this->table_element_line) && ! empty($this->fk_element)) + { + $num=(is_array($this->lines) ? count($this->lines) : 0); + for ($i = 0; $i < $num; $i++) + { + $line = $this->lines[$i]; + + $keyforparent = $this->fk_element; + $line->$keyforparent = $this->id; + + // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array + //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. + if (! is_object($line)) $line = (object) $line; + + $result = $line->create($user, 1); + if ($result < 0) + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + } + // Triggers if (! $error && ! $notrigger) { diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 81a1e315751..ac546b3249a 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -272,6 +272,10 @@ ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_rowid (rowid); ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_product (fk_product); ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_bom (fk_bom); +ALTER TABLE llx_bom_bom ADD UNIQUE INDEX uk_bom_bom_ref(ref, entity); +ALTER TABLE llx_bom_bomline ADD CONSTRAINT llx_bom_bomline_fk_bom FOREIGN KEY (fk_bom) REFERENCES llx_bom_bom(rowid); + + ALTER TABLE llx_product_fournisseur_price ADD COLUMN barcode varchar(180) DEFAULT NULL; ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_barcode_type integer DEFAULT NULL; ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_barcode (barcode); diff --git a/htdocs/install/mysql/tables/llx_bom_bom.key.sql b/htdocs/install/mysql/tables/llx_bom_bom.key.sql index 72631851e1b..aed37c7ce47 100644 --- a/htdocs/install/mysql/tables/llx_bom_bom.key.sql +++ b/htdocs/install/mysql/tables/llx_bom_bom.key.sql @@ -22,7 +22,7 @@ ALTER TABLE llx_bom_bom ADD INDEX idx_bom_bom_status (status); ALTER TABLE llx_bom_bom ADD INDEX idx_bom_bom_fk_product (fk_product); -- END MODULEBUILDER INDEXES ---ALTER TABLE llx_bom_bom ADD UNIQUE INDEX uk_bom_bom_fieldxy(fieldx, fieldy); +ALTER TABLE llx_bom_bom ADD UNIQUE INDEX uk_bom_bom_ref(ref, entity); --ALTER TABLE llx_bom_bom ADD CONSTRAINT llx_bom_bom_fk_field FOREIGN KEY (fk_field) REFERENCES llx_bom_myotherobject(rowid); diff --git a/htdocs/install/mysql/tables/llx_bom_bomline.key.sql b/htdocs/install/mysql/tables/llx_bom_bomline.key.sql index 89c65f78644..ee8eaaeeb6c 100644 --- a/htdocs/install/mysql/tables/llx_bom_bomline.key.sql +++ b/htdocs/install/mysql/tables/llx_bom_bomline.key.sql @@ -22,5 +22,5 @@ ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_bom (fk_bom); --ALTER TABLE llx_bom_bomline ADD UNIQUE INDEX uk_bom_bomline_fieldxy(fieldx, fieldy); ---ALTER TABLE llx_bom_bomline ADD CONSTRAINT llx_bom_bomline_fk_field FOREIGN KEY (fk_field) REFERENCES llx_bom_myotherobject(rowid); +ALTER TABLE llx_bom_bomline ADD CONSTRAINT llx_bom_bomline_fk_bom FOREIGN KEY (fk_bom) REFERENCES llx_bom_bom(rowid); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index a3e1f43b619..266b8d1925f 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -46,6 +46,7 @@ class MyObject extends CommonObject * @var string Name of subtable if this object has sub lines */ //public $table_element_line = 'mymodule_myobjectline'; + //public $fk_element = 'fk_myobject'; /** * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -267,12 +268,19 @@ class MyObject extends CommonObject $this->db->begin(); // Load source object - $object->fetchCommon($fromid); + $result = $object->fetchCommon($fromid); + if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); + + // get lines so they will be clone + //foreach($this->lines as $line) + // $line->fetch_optionals(); + // Reset some properties unset($object->id); unset($object->fk_user_creat); unset($object->import_key); + // Clear fields $object->ref = "copy_of_".$object->ref; $object->title = $langs->trans("CopyOf")." ".$object->title; @@ -301,6 +309,25 @@ class MyObject extends CommonObject $this->errors = $object->errors; } + if (! $error) + { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) + { + $error++; + } + } + + if (! $error) + { + // copy external contacts if same company + if (property_exists($this, 'socid') && $this->socid == $object->socid) + { + if ($this->copy_linked_contact($object, 'external') < 0) + $error++; + } + } + unset($object->context['createfromclone']); // End @@ -671,7 +698,7 @@ class MyObject extends CommonObject $this->lines=array(); $objectline = new MyObjectLine($this->db); - $result = $objectline->fetchAll('', '', 0, 0, array('customsql'=>'fk_myobject = '.$this->id)); + $result = $objectline->fetchAll('ASC', 'rank', 0, 0, array('customsql'=>'fk_myobject = '.$this->id)); if (is_numeric($result)) { @@ -756,4 +783,5 @@ class MyObject extends CommonObject class MyObjectLine { // To complete with content of an object MyObjectLine + // We should have a field rowid, fk_myobject and rank } From 29d9983669516be49b55b460f544fa4955af1910 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 01:22:26 +0200 Subject: [PATCH 16/29] Fix look and feel v10 --- .../accountancy/journal/purchasesjournal.php | 1 + htdocs/accountancy/journal/sellsjournal.php | 1 + htdocs/core/menus/standard/eldy.lib.php | 116 +++++++++--------- 3 files changed, 60 insertions(+), 58 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 6bbc4ad9c62..12e76882adc 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -743,6 +743,7 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { + print '
'; print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 25c53863162..08df2e71b32 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -680,6 +680,7 @@ if (empty($action) || $action == 'view') { // Button to write into Ledger if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + print '
'; print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 3710cc2cf91..3073ffe6032 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1153,35 +1153,67 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $permtoshowmenu=(! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire); //$newmenu->add("/accountancy/index.php?leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy'); + // Configuration + $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/', $leftmenu)) { + $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10); + + // Fiscal year - Not really yet used. In a future will lock some periods. + if ($conf->global->MAIN_FEATURES_LEVEL > 1) { + $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear', 20); + } + + $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 30); + $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 40); + $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 41); + $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 50); + $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 60); + if (! empty($conf->banque->enabled)) { + $newmenu->add("/compta/bank/list.php?mainmenu=accountancy&leftmenu=accountancy_admin&search_status=-1", $langs->trans("MenuBankAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 70); + } + if (! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)) { + $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 80); + } + if (! empty($conf->tax->enabled)) { + $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 90); + } + if (! empty($conf->expensereport->enabled)) { + $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 100); + } + $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 110); + $newmenu->add("/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuClosureAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_closure', 120); + $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 130); + } + // Transfer in accounting $newmenu->add("/accountancy/index.php?leftmenu=accountancy_transfer", $langs->trans("TransferInAccounting"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'transfer', 1); - // Binding - // $newmenu->add("", $langs->trans("Binding"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch'); - if (! empty($conf->facture->enabled)) - { - $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy", $langs->trans("CustomersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/', $leftmenu)) { - $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); - $newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); - } - } - if (! empty($conf->supplier_invoice->enabled)) - { - $newmenu->add("/accountancy/supplier/index.php?leftmenu=accountancy_dispatch_supplier&mainmenu=accountancy", $langs->trans("SuppliersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_supplier'); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_supplier/', $leftmenu)) { - $newmenu->add("/accountancy/supplier/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); - $newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); - } - } - if (! empty($conf->expensereport->enabled)) - { - $newmenu->add("/accountancy/expensereport/index.php?leftmenu=accountancy_dispatch_expensereport&mainmenu=accountancy", $langs->trans("ExpenseReportsVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_expensereport'); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/', $leftmenu)) { - $newmenu->add("/accountancy/expensereport/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); - $newmenu->add("/accountancy/expensereport/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); - } - } + // Binding + // $newmenu->add("", $langs->trans("Binding"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch'); + if (! empty($conf->facture->enabled)) + { + $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy", $langs->trans("CustomersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/', $leftmenu)) { + $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); + $newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); + } + } + if (! empty($conf->supplier_invoice->enabled)) + { + $newmenu->add("/accountancy/supplier/index.php?leftmenu=accountancy_dispatch_supplier&mainmenu=accountancy", $langs->trans("SuppliersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_supplier'); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_supplier/', $leftmenu)) { + $newmenu->add("/accountancy/supplier/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); + $newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); + } + } + if (! empty($conf->expensereport->enabled)) + { + $newmenu->add("/accountancy/expensereport/index.php?leftmenu=accountancy_dispatch_expensereport&mainmenu=accountancy", $langs->trans("ExpenseReportsVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_expensereport'); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/', $leftmenu)) { + $newmenu->add("/accountancy/expensereport/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); + $newmenu->add("/accountancy/expensereport/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); + } + } // Journals if(! empty($conf->accounting->enabled) && ! empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') @@ -1292,38 +1324,6 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM //$newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByVatRate"),3,$user->rights->accounting->comptarapport->lire); } } - - // Configuration - $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/', $leftmenu)) { - $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10); - - // Fiscal year - Not really yet used. In a future will lock some periods. - if ($conf->global->MAIN_FEATURES_LEVEL > 1) { - $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 1, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear', 20); - } - - $newmenu->add("/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 30); - $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 40); - $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 41); - $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 50); - $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 60); - if (! empty($conf->banque->enabled)) { - $newmenu->add("/compta/bank/list.php?mainmenu=accountancy&leftmenu=accountancy_admin&search_status=-1", $langs->trans("MenuBankAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 70); - } - if (! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)) { - $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 80); - } - if (! empty($conf->tax->enabled)) { - $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 90); - } - if (! empty($conf->expensereport->enabled)) { - $newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 100); - } - $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 110); - $newmenu->add("/accountancy/admin/closure.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuClosureAccounts"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_closure', 120); - $newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 130); - } } // Accountancy (simple) From cb859b7dfb04cbd461230410679cbed0b6f70709 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 01:30:17 +0200 Subject: [PATCH 17/29] Look and feel v10 --- htdocs/accountancy/bookkeeping/list.php | 6 +++--- htdocs/accountancy/bookkeeping/listbyaccount.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 073d180cd16..7de500ba690 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -447,11 +447,11 @@ $listofformat=AccountancyExport::getType(); if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList"); else $buttonLabel = $langs->trans("ExportList"); -$newcardbutton = dolGetButtonTitle($buttonLabel, '', 'fa fa-file-export', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'')); +$newcardbutton = dolGetButtonTitle($buttonLabel, '', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'')); -$newcardbutton.= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-object-group', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param); +$newcardbutton.= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param); -$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle', './card.php?action=create'); +$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create'); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index a2cf4864df8..0b9bebcea78 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -256,8 +256,8 @@ if ($action == 'delbookkeepingyear') { print ''; -$newcardbutton.= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); -$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle', './card.php?action=create'); +$newcardbutton.= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); +$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create'); if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); From ba2b07917bfea6804252d40eb76d74fc9896df93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 02:11:03 +0200 Subject: [PATCH 18/29] Fix look and feel v10 --- htdocs/accountancy/customer/index.php | 4 ++-- htdocs/accountancy/customer/lines.php | 2 +- htdocs/accountancy/customer/list.php | 2 +- htdocs/accountancy/expensereport/index.php | 4 ++-- htdocs/accountancy/expensereport/lines.php | 2 +- htdocs/accountancy/expensereport/list.php | 2 +- htdocs/accountancy/supplier/index.php | 4 ++-- htdocs/accountancy/supplier/lines.php | 2 +- htdocs/accountancy/supplier/list.php | 2 +- htdocs/compta/stats/index.php | 6 ++++-- htdocs/langs/en_US/accountancy.lang | 2 +- 11 files changed, 17 insertions(+), 15 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index aa8161b9c52..039b7076c3e 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -143,9 +143,9 @@ $textnextyear = ' trans("DescVentilCustomer") . '
'; +print ''.$langs->trans("DescVentilCustomer") . '
'; print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; -print '
'; +print '

'; $y = $year_current; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index f7a53c9e210..83bceb04026 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -294,7 +294,7 @@ if ($result) { print ''; print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print $langs->trans("DescVentilDoneCustomer") . '
'; + print ''.$langs->trans("DescVentilDoneCustomer") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 4b3906d60da..61c22eb2912 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -356,7 +356,7 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print $langs->trans("DescVentilTodoCustomer") . '

'; + print ''.$langs->trans("DescVentilTodoCustomer") . '

'; /*$topicmail="Information"; $modelmail="project"; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index e350a3011a0..696f947b63f 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -139,9 +139,9 @@ $textnextyear = ' 
trans("DescVentilExpenseReport") . '
'; +print ''.$langs->trans("DescVentilExpenseReport") . '
'; print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; -print '
'; +print '

'; $y = $year_current; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 3a322c07ef3..734bbfb65d2 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -248,7 +248,7 @@ if ($result) { print_barre_liste($langs->trans("ExpenseReportLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print $langs->trans("DescVentilDoneExpenseReport") . '
'; + print ''.$langs->trans("DescVentilDoneExpenseReport") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 4f037f3c72b..4c739a218b9 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -289,7 +289,7 @@ if ($result) { print_barre_liste($langs->trans("ExpenseReportLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print $langs->trans("DescVentilTodoExpenseReport") . '

'; + print ''.$langs->trans("DescVentilTodoExpenseReport") . '

'; /*$topicmail="Information"; $modelmail="project"; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index ab85507a7b4..6f178c755d3 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -140,9 +140,9 @@ $textnextyear = ' 
trans("DescVentilSupplier") . '
'; +print ''.$langs->trans("DescVentilSupplier") . '
'; print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '
'; -print '
'; +print '

'; $y = $year_current; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 4af51060b4b..9b704e21eb3 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -297,7 +297,7 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print $langs->trans("DescVentilDoneSupplier") . '
'; + print ''.$langs->trans("DescVentilDoneSupplier") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 27cccdb7eb2..47e3570bcbe 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -355,7 +355,7 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print $langs->trans("DescVentilTodoCustomer") . '

'; + print ''.$langs->trans("DescVentilTodoCustomer") . '

'; /*$topicmail="Information"; $modelmail="project"; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index fe31f68380a..64d115b6b4a 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -318,7 +318,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) $case = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage), "%Y-%m"); $caseprev = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage-1), "%Y-%m"); - if ($annee >= $year_start) + if ($annee >= $year_start) // We ignore $annee < $year_start, we loop on it to be able to make delta, nothing is output. { if ($modecompta == 'CREANCES-DETTES') { // Valeur CA du mois w/o VAT @@ -386,7 +386,9 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) else { print ' '; } print ''; } - if ($annee_decalage != $year_end) print ' '; + + if ($annee_decalage < $year_end || ($annee_decalage == $year_end && $mois > 12 && $annee < $year_end)) print ' '; + } $total_ht[$annee]+=!empty($cum_ht[$case]) ? $cum_ht[$case] : 0; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 20b9862e187..a7f6cfd87de 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -107,7 +107,7 @@ ExpenseReportsVentilation=Expense report binding CreateMvts=Create new transaction UpdateMvts=Modification of a transaction ValidTransaction=Validate transaction -WriteBookKeeping=Journalize transactions in Ledger +WriteBookKeeping=Register transactions in Ledger Bookkeeping=Ledger AccountBalance=Account balance ObjectsRef=Source object ref From fd50e68f9a3b0aa4c27ac1ca1b951bfa4750c310 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 02:15:52 +0200 Subject: [PATCH 19/29] Fix look and feel v10 --- htdocs/admin/company.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 32398f05ada..a6be1d181c5 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2018 Laurent Destailleur +/* Copyright (C) 2001-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2011-2017 Philippe Grand @@ -588,9 +588,8 @@ if ($action == 'edit' || $action == 'updateedit') print ''.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").''; print "\n"; - print ''; - print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START, 'SOCIETE_FISCAL_MONTH_START', 0, 1) . ''; + print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START, 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100') . ''; print ""; From 2c04a480a23b1216a27d8da97f5a9fbd286a7120 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 02:31:19 +0200 Subject: [PATCH 20/29] Fix phpcs --- htdocs/compta/stats/index.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 64d115b6b4a..cd17fbba233 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -388,11 +388,10 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) } if ($annee_decalage < $year_end || ($annee_decalage == $year_end && $mois > 12 && $annee < $year_end)) print ' '; - } - $total_ht[$annee]+=!empty($cum_ht[$case]) ? $cum_ht[$case] : 0; - $total[$annee]+=$cum[$case]; + $total_ht[$annee] += ((! empty($cum_ht[$case])) ? $cum_ht[$case] : 0); + $total[$annee] += $cum[$case]; } print ''; From 969e139d5cdd736300975f26debfd7fb32f0f435 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 12:21:27 +0200 Subject: [PATCH 21/29] Fix parameters of accessforbidden --- htdocs/asset/document.php | 2 +- htdocs/bom/bom_document.php | 2 +- htdocs/compta/facture/card.php | 4 +- .../template/myobject_document.php | 2 +- htdocs/public/ifttt/index.php | 88 ------------------- htdocs/public/opensurvey/studs.php | 8 +- htdocs/resource/card.php | 3 +- htdocs/ticket/agenda.php | 4 +- htdocs/ticket/card.php | 2 +- htdocs/ticket/document.php | 2 +- htdocs/user/document.php | 2 +- htdocs/viewimage.php | 4 +- 12 files changed, 18 insertions(+), 105 deletions(-) delete mode 100644 htdocs/public/ifttt/index.php diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index 61be1ad51d6..1de1030dec9 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -145,7 +145,7 @@ if ($object->id) } else { - accessforbidden('', 0, 0); + accessforbidden('', 0, 1); } // End of page diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index 012094fbb05..3cc042941b2 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -143,7 +143,7 @@ if ($object->id) } else { - accessforbidden('', 0, 0); + accessforbidden('', 0, 1); } // End of page diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 260edb5f61c..05350fcbef8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3382,7 +3382,9 @@ elseif ($id > 0 || ! empty($ref)) $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); if ($user->societe_id > 0 && $user->societe_id != $object->socid) - accessforbidden('', 0); + { + accessforbidden('', 0, 1); + } $result = $object->fetch_thirdparty(); diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 6c956826e4c..0f4df0012f4 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -158,7 +158,7 @@ if ($object->id) } else { - accessforbidden('', 0, 0); + accessforbidden('', 0, 1); } // End of page diff --git a/htdocs/public/ifttt/index.php b/htdocs/public/ifttt/index.php deleted file mode 100644 index 27a1b169c7c..00000000000 --- a/htdocs/public/ifttt/index.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/public/ifttt/index.php - * \ingroup ifttt - * \brief Page to IFTTT endpoint agenda - * http://127.0.0.1/dolibarr/public/ifttt/index.php?securekey=... - */ - -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (! defined('NOLOGIN')) define("NOLOGIN", 1); // This means this output page does not require to be logged. -if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - -// This is a wrapper, so header is empty - -/** - * Header function - * - * @return void - */ -function llxHeaderIFTTT() -{ - print 'IFTTT API'; -} -/** - * Footer function - * - * @return void - */ -function llxFooterIFTTT() -{ - print ''; -} - - -require '../../main.inc.php'; - -// Security check -if (empty($conf->ifttt->enabled)) accessforbidden('', 0, 0, 1); - -// Check config -if (empty($conf->global->IFTTT_DOLIBARR_ENDPOINT_SECUREKEY)) -{ - $user->getrights(); - - llxHeaderIFTTT(); - print '
Module Agenda was not configured properly.
'; - llxFooterIFTTT(); - exit; -} - -// Check exportkey -if (empty($_GET["securekey"]) || $conf->global->IFTTT_DOLIBARR_ENDPOINT_SECUREKEY != $_GET["securekey"]) -{ - $user->getrights(); - - llxHeaderIFTTT(); - print '
Bad value for securekey.
'; - llxFooterIFTTT(); - exit; -} - - -// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks -$hookmanager->initHooks(array('iftttapi')); - - -llxHeaderIFTTT(); -print '
TODO
'; -llxFooterIFTTT(); diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index d242b2df3c1..56c43556c6e 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -62,7 +62,7 @@ $listofvoters=explode(',', $_SESSION["savevoter"]); // Add comment if (GETPOST('ajoutcomment', 'alpha')) { - if (!$canbemodified) accessforbidden(); + if (!$canbemodified) accessforbidden('', 0, 0, 1); $error=0; @@ -97,7 +97,7 @@ if (GETPOST('ajoutcomment', 'alpha')) // Add vote if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrome, boutonp_x for firefox { - if (!$canbemodified) accessforbidden(); + if (!$canbemodified) accessforbidden('', 0, 0, 1); //Si le nom est bien entré if (GETPOST('nom', 'nohtml')) @@ -220,7 +220,7 @@ if ($testmodifier) } } - if (!$canbemodified) accessforbidden(); + if (!$canbemodified) accessforbidden('', 0, 0, 1); $idtomodify=$_POST["idtomodify".$modifier]; $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs"; @@ -235,7 +235,7 @@ if ($testmodifier) $idcomment=GETPOST('deletecomment', 'int'); if ($idcomment) { - if (!$canbemodified) accessforbidden(); + if (!$canbemodified) accessforbidden('', 0, 0, 1); $resql = $object->deleteComment($idcomment); } diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 880c4feb7f5..44a727f6e4c 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -237,8 +237,7 @@ if ($action == 'create' || $object->fetch($id) > 0) if ($action == 'create' || $action == 'edit') { - if ( ! $user->rights->resource->write ) - accessforbidden('', 0); + if (! $user->rights->resource->write) accessforbidden('', 0, 1); // Create/Edit object diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index bad8e58497b..ed689b4e966 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -86,11 +86,11 @@ if (!$user->rights->ticket->read) { // restrict access for externals users if ($user->societe_id > 0 && ($object->fk_soc != $user->societe_id)) { - accessforbidden('', 0); + accessforbidden(); } // or for unauthorized internals users if (!$user->societe_id && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { - accessforbidden('', 0); + accessforbidden(); } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 475c9f5beae..94c0aec8d90 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -647,7 +647,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd { // or for unauthorized internals users if (!$user->societe_id && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { - accessforbidden('', 0); + accessforbidden('', 0, 1); } // Confirmation close diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php index 16fabc6943c..779b97657e1 100644 --- a/htdocs/ticket/document.php +++ b/htdocs/ticket/document.php @@ -196,7 +196,7 @@ if ($object->id) } else { - accessforbidden('', 0, 0); + accessforbidden('', 0, 1); } // End of page diff --git a/htdocs/user/document.php b/htdocs/user/document.php index 63d527dc33c..91d0e7219ce 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -174,7 +174,7 @@ if ($object->id) } else { - accessforbidden('', 0, 0); + accessforbidden('', 0, 1); } // End of page diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index b25cc076836..4d13b182fd4 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -170,7 +170,7 @@ if (GETPOST('type', 'alpha')) $type=GETPOST('type', 'alpha'); else $type=dol_mimetype($original_file); // Security: This wrapper is for images. We do not allow type/html -if (preg_match('/html/', $type)) accessforbidden('Error: Using the image wrapper to output a file with a mime type HTML is not possible.', 1, 1, 1); +if (preg_match('/html/', $type)) accessforbidden('Error: Using the image wrapper to output a file with a mime type HTML is not possible.', 0, 0, 1); // Security: Delete string ../ into $original_file $original_file = str_replace("../", "/", $original_file); @@ -179,7 +179,7 @@ $original_file = str_replace("../", "/", $original_file); $refname=basename(dirname($original_file)."/"); // Security check -if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart', 1, 1, 1); +if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart', 0, 0, 1); $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); $accessallowed = $check_access['accessallowed']; From 79a3e414187f48364368ffda39f097196afbb692 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 12:48:06 +0200 Subject: [PATCH 22/29] Hook 'getAccessForbiddenMessage' --- ChangeLog | 1 + htdocs/core/class/hookmanager.class.php | 7 ++++--- htdocs/core/lib/security.lib.php | 25 +++++++++++++++++++------ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index b641ec2029e..e0f4159c49e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -128,6 +128,7 @@ NEW: Upgrade jquery lib to 3.3.1 NEW: Add hook 'addHtmlHeader()' NEW: Add hook 'createRecurringInvoices()' NEW: Add hook 'afterSelectContactOptions' +NEW: Add hook 'getAccessForbiddenMessage' NEW: Add hook support in accountancy index NEW: Add hook support in list of template invoices NEW: Add parameter 'replaceambiguouschars' on getRandomPassword function diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index f23aa1da5a3..f1abc148291 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -165,11 +165,12 @@ class HookManager 'formattachOptions', 'formBuilddocLineOptions', 'formatNotificationMessage', - 'getFormMail', - 'getIdProfUrl', + 'getAccessForbiddenMessage', 'getDirList', - 'getFormatedCustomerRef', + 'getFormMail', + 'getFormatedCustomerRef', 'getFormatedSupplierRef', + 'getIdProfUrl', 'moveUploadedFile', 'moreHtmlStatus', 'pdf_build_address', diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 0dbbb7f0829..11866ea6782 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -659,7 +659,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand */ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0) { - global $conf, $db, $user, $langs; + global $conf, $db, $user, $langs, $hookmanager; if (! is_object($langs)) { include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; @@ -681,14 +681,27 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho print '
'; if (empty($showonlymessage)) { - if ($user->login) + global $action, $object; + if (empty($hookmanager)) { - print $langs->trans("CurrentLogin").': '.$user->login.'
'; - print $langs->trans("ErrorForbidden2", $langs->trans("Home"), $langs->trans("Users")); + $hookmanager = new HookManager($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + $hookmanager->initHooks(array('main')); } - else + $parameters = array('message'=>$message); + $reshook=$hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + print $hookmanager->resPrint; + if (empty($reshook)) { - print $langs->trans("ErrorForbidden3"); + if ($user->login) + { + print $langs->trans("CurrentLogin").': '.$user->login.'
'; + print $langs->trans("ErrorForbidden2",$langs->trans("Home"),$langs->trans("Users")); + } + else + { + print $langs->trans("ErrorForbidden3"); + } } } if ($printfooter && function_exists("llxFooter")) llxFooter(); From 7b3242693b764a7ff9f6883416ef8492a6c34d47 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 18:17:07 +0200 Subject: [PATCH 23/29] FIX default value for duration of validity can be set from generic feature. --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index ba68e3324bb..86d6244f81d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1533,7 +1533,7 @@ if ($action == 'create') print ''; // Validaty duration - print '' . $langs->trans("ValidityDuration") . ' ' . $langs->trans("days") . ''; + print '' . $langs->trans("ValidityDuration") . ' ' . $langs->trans("days") . ''; // Terms of payment print '' . $langs->trans('PaymentConditionsShort') . ''; From 36df2f10261b8b5aa99d6ad2942fdc17aedc4031 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 18:45:01 +0200 Subject: [PATCH 24/29] Fix css --- htdocs/comm/propal/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 86d6244f81d..8f186c0bc2e 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -320,7 +320,7 @@ if (empty($reshook)) $datep = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $date_delivery = dol_mktime(12, 0, 0, GETPOST('date_livraisonmonth'), GETPOST('date_livraisonday'), GETPOST('date_livraisonyear')); - $duration = GETPOST('duree_validite'); + $duration = GETPOST('duree_validite', 'int'); if (empty($datep)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); @@ -1533,7 +1533,7 @@ if ($action == 'create') print ''; // Validaty duration - print '' . $langs->trans("ValidityDuration") . ' ' . $langs->trans("days") . ''; + print '' . $langs->trans("ValidityDuration") . ' ' . $langs->trans("days") . ''; // Terms of payment print '' . $langs->trans('PaymentConditionsShort') . ''; From 210b2f37dc730bd58fee4cabba9540124e5b2879 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 19:18:20 +0200 Subject: [PATCH 25/29] Fix error message --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 11866ea6782..dcdc70c3fe6 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -696,7 +696,7 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho if ($user->login) { print $langs->trans("CurrentLogin").': '.$user->login.'
'; - print $langs->trans("ErrorForbidden2",$langs->trans("Home"),$langs->trans("Users")); + print $langs->trans("ErrorForbidden2", $langs->transnoentitiesnoconv("Home"), $langs->transnoentitiesnoconv("Users")); } else { From 4a63c6d38a33857a0dcb79f0de27fdebad557f59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 19:20:08 +0200 Subject: [PATCH 26/29] Fix phpcs --- 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 d260ba89a3c..0e882c9afdf 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1409,7 +1409,7 @@ 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 (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 (! 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 a08dcec7fc001cc5c2213f53d7aeeb7f3394c7da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 20:02:29 +0200 Subject: [PATCH 27/29] Fix doc --- htdocs/core/lib/functions.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 19b39fd776d..a25fd098f9a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5274,10 +5274,10 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart) /** * Creation of a directory (this can create recursive subdir) * - * @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir') - * @param string $dataroot Data root directory (To avoid having the data root in the loop. Using this will also lost the warning on first dir PHP has no permission when open_basedir is used) - * @param int $newmask Mask for new file (Defaults to $conf->global->MAIN_UMASK or 0755 if unavailable). Example: '0444' - * @return int < 0 if KO, 0 = already exists, > 0 if OK + * @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir') + * @param string $dataroot Data root directory (To avoid having the data root in the loop. Using this will also lost the warning on first dir PHP has no permission when open_basedir is used) + * @param string|null $newmask Mask for new file (Defaults to $conf->global->MAIN_UMASK or 0755 if unavailable). Example: '0444' + * @return int < 0 if KO, 0 = already exists, > 0 if OK */ function dol_mkdir($dir, $dataroot = '', $newmask = null) { From ab77051317a54c20f4b7ff8b3cf67c317f7b45ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 20:03:27 +0200 Subject: [PATCH 28/29] Fix time delay for purge --- htdocs/admin/tools/purge.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index 48968ff1d27..b83399b9853 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -48,6 +48,17 @@ if (! empty($conf->syslog->enabled)) */ if ($action=='purge' && ! preg_match('/^confirm/i',$choice) && ($choice != 'allfiles' || $confirm == 'yes') ) { + // Increase limit of time. Works only if we are not in safe mode + $ExecTimeLimit=600; + if (!empty($ExecTimeLimit)) + { + $err=error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); + } + require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php'; $utils = new Utils($db); $result = $utils->purgeFiles($choice); From a70a14b14503691266326045c12d52658f6b025b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Jun 2019 20:06:44 +0200 Subject: [PATCH 29/29] Fix migration --- htdocs/install/mysql/migration/9.0.0-10.0.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index ac546b3249a..96b1f68fa9a 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -227,6 +227,7 @@ CREATE TABLE llx_bom_bom( ) ENGINE=innodb; ALTER TABLE llx_bom_bom ADD COLUMN efficiency double(8,4) DEFAULT 1; +ALTER TABLE llx_bom_bom ADD COLUMN entity integer DEFAULT 1 NOT NULL; create table llx_bom_bom_extrafields (