From 85ce1f3332a77909584eee86ef5f9b0253b25eec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Jun 2017 09:20:16 +0200 Subject: [PATCH 01/38] Fix missing var init --- htdocs/admin/tools/export.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index ebc4061fe6d..7e2fa8ee79d 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -88,6 +88,7 @@ if (!empty($ExecTimeLimit)) @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 error_reporting($err); } +$MemoryLimit=0; if (!empty($MemoryLimit)) { @ini_set('memory_limit', $MemoryLimit); @@ -120,10 +121,10 @@ $utils = new Utils($db); // MYSQL if ($what == 'mysql') { - + $cmddump=GETPOST("mysqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump=dol_sanitizePathName($cmddump); - + if (! empty($dolibarr_main_restrict_os_commands)) { $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); @@ -142,13 +143,13 @@ if ($what == 'mysql') $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); } } - + if (! $errormsg && $cmddump) { dolibarr_set_const($db, 'SYSTEMTOOLS_MYSQLDUMP', $cmddump,'chaine',0,'',$conf->entity); } - if (! $errormsg) + if (! $errormsg) { $utils->dumpDatabase(GETPOST('compression','alpha'), $what, 0, $file); $errormsg=$utils->error; @@ -172,13 +173,13 @@ if ($what == 'postgresql') { $cmddump=GETPOST("postgresqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump=dol_sanitizePathName($cmddump); - + if (! $errormsg && $cmddump) { dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump,'chaine',0,'',$conf->entity); } - if (! $errormsg) + if (! $errormsg) { $utils->dumpDatabase(GETPOST('compression','alpha'), $what, 0, $file); $errormsg=$utils->error; From 4a21457b8a7b7980ef3f8ddc0683804312c3b542 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Jun 2017 09:28:02 +0200 Subject: [PATCH 02/38] Fix position of page nb --- htdocs/core/lib/pdf.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index c4257c3c7f8..1b79cc9163d 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1039,10 +1039,10 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass // Show page nb only on iso languages (so default Helvetica font) if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { - $pdf->SetXY(-20,-$posy); + $pdf->SetXY($dims['wk']-$dims['rm']-15, -$posy); //print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; - if (empty($conf->global->MAIN_USE_FPDF)) $pdf->MultiCell(13, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); - else $pdf->MultiCell(13, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); + if (empty($conf->global->MAIN_USE_FPDF)) $pdf->MultiCell(15, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); + else $pdf->MultiCell(15, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); } return $marginwithfooter; @@ -1246,7 +1246,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if (empty($hideref)) { - if ($issupplierline) + if ($issupplierline) { //$ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref if (! empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) $ref_prodserv =$ref_supplier; From 3a6314b1a02b6634b948e5a2f8158731c125c2fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Jun 2017 13:29:18 +0200 Subject: [PATCH 03/38] Fix data --- htdocs/install/mysql/migration/4.0.0-5.0.0.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index b5978efac99..5f62c766a01 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -270,3 +270,8 @@ ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10 ALTER TABLE llx_events MODIFY COLUMN ip varchar(250); + + +UPDATE llx_bank SET label= '(SupplierInvoicePayment)' WHERE label= 'Règlement fournisseur'; +UPDATE llx_bank SET label= '(CustomerInvoicePayment)' WHERE label= 'Règlement client'; + From cb93770d6b6babace7c93fa8f3b6dc7be9a84155 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Jun 2017 13:29:43 +0200 Subject: [PATCH 04/38] Add php unit --- test/phpunit/CompanyLibTest.php | 144 -------------------------------- 1 file changed, 144 deletions(-) delete mode 100644 test/phpunit/CompanyLibTest.php diff --git a/test/phpunit/CompanyLibTest.php b/test/phpunit/CompanyLibTest.php deleted file mode 100644 index 1d61d5925e3..00000000000 --- a/test/phpunit/CompanyLibTest.php +++ /dev/null @@ -1,144 +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 . - * or see http://www.gnu.org/ - */ - -/** - * \file test/phpunit/CompanyLibTest.php - * \ingroup test - * \brief PHPUnit test - * \remarks To run this script as CLI: phpunit filename.php - */ - -global $conf,$user,$langs,$db; -//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver -//require_once 'PHPUnit/Autoload.php'; -require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; -require_once dirname(__FILE__).'/../../htdocs/core/lib/company.lib.php'; - -if (empty($user->id)) { - print "Load permissions for admin user nb 1\n"; - $user->fetch(1); - $user->getrights(); -} -$conf->global->MAIN_DISABLE_ALL_MAILS=1; - - -/** - * Class for PHPUnit tests - * - * @backupGlobals disabled - * @backupStaticAttributes enabled - * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. - */ -class CompanyLibTest extends PHPUnit_Framework_TestCase -{ - protected $savconf; - protected $savuser; - protected $savlangs; - protected $savdb; - - /** - * Constructor - * We save global variables into local variables - * - * @return AdminLibTest - */ - function __construct() - { - //$this->sharedFixture - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; - - print __METHOD__." db->type=".$db->type." user->id=".$user->id; - //print " - db ".$db->db; - print "\n"; - } - - // Static methods - public static function setUpBeforeClass() - { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - - print __METHOD__."\n"; - } - - // tear down after class - public static function tearDownAfterClass() - { - global $conf,$user,$langs,$db; - $db->rollback(); - - print __METHOD__."\n"; - } - - /** - * Init phpunit tests - * - * @return void - */ - protected function setUp() - { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; - - print __METHOD__."\n"; - } - /** - * End phpunit tests - * - * @return void - */ - protected function tearDown() - { - print __METHOD__."\n"; - } - - /** - * testNameCurrency - * - * @return void - */ - public function testNameCurrency() - { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; - - $result=currency_name('USD'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('United States Dollar',$result); - - $outputlangs=new Translate('', $conf); - $outputlangs->setDefaultLang('fr_FR'); - $outputlangs->load("dict"); - - $result=currency_name('USD', 1, $outputlangs); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('USD - Dollars US',$result); - - return $result; - } -} From 75006f9970a0f518103898f0257a8b6e504541ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Jun 2017 13:30:14 +0200 Subject: [PATCH 05/38] Fix data --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 096b82a7768..0867aba9c38 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -500,3 +500,5 @@ ALTER TABLE llx_blockedlog_authority ADD INDEX signature (signature); -- VMYSQL4.1 INSERT IGNORE INTO llx_product_lot (entity, fk_product, batch, eatby, sellby, datec, fk_user_creat, fk_user_modif) SELECT DISTINCT e.entity, ps.fk_product, pb.batch, pb.eatby, pb.sellby, pb.tms, e.fk_user_author, e.fk_user_author from llx_product_batch as pb, llx_product_stock as ps, llx_entrepot as e WHERE pb.fk_product_stock = ps.rowid AND ps.fk_entrepot = e.rowid +UPDATE llx_bank SET label= '(SupplierInvoicePayment)' WHERE label= 'Règlement fournisseur'; +UPDATE llx_bank SET label= '(CustomerInvoicePayment)' WHERE label= 'Règlement client'; From 9b951c5d1bf954eda70da700cec175a8f2b5e615 Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 26 Jun 2017 21:37:36 +0200 Subject: [PATCH 06/38] Add missing end tag `form` into fichinter setup The setup for option `FICHINTER_PRINT_PRODUCTS` was broken. --- htdocs/admin/fichinter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 926a3651362..64257225719 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -559,6 +559,7 @@ print '/>'; print ''; print ''; print "\n"; +print ''; // Use services duration print '
'; print ''; From 3fdfebf7ef437ff7d050dede9d0c92740e51827a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Jun 2017 04:25:41 +0200 Subject: [PATCH 07/38] Fix position of top menu does not follow 'position' field. --- htdocs/comm/action/peruser.php | 4 +- htdocs/core/class/menu.class.php | 18 +- htdocs/core/class/menubase.class.php | 2 +- htdocs/core/get_menudiv.php | 2 +- htdocs/core/menus/standard/auguria.lib.php | 25 ++- htdocs/core/menus/standard/eldy.lib.php | 76 +++---- htdocs/core/menus/standard/empty.php | 247 ++++++++++++++++++--- htdocs/core/modules/modAgenda.class.php | 10 +- htdocs/hrm/index.php | 19 +- htdocs/theme/eldy/style.css.php | 1 + htdocs/theme/md/style.css.php | 1 + 11 files changed, 298 insertions(+), 107 deletions(-) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 42fb67c8bde..7453b84d477 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -729,8 +729,8 @@ foreach ($usernames as $username) { $var = ! $var; echo ""; - echo ''; - print $username->getNomUrl(-1,'',0,0,24,1,''); + echo ''; + print $username->getNomUrl(-1,'',0,0,20,1,''); print ''; $tmpday = $sav; diff --git a/htdocs/core/class/menu.class.php b/htdocs/core/class/menu.class.php index 58e93ec5544..d4570218ff2 100644 --- a/htdocs/core/class/menu.class.php +++ b/htdocs/core/class/menu.class.php @@ -51,7 +51,7 @@ class Menu /** * Add a menu entry into this->liste (at end) * - * @param string $url Url to follow on click + * @param string $url Url to follow on click (does not include DOL_URL_ROOT) * @param string $titre Label of menu to add * @param integer $level Level of menu to add * @param int $enabled Menu active or not (0=Not active, 1=Active, 2=Active but grey) @@ -59,11 +59,14 @@ class Menu * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) * @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...) * @param int $position Position (not used yet) + * @param string $id Id + * @param string $idsel Id sel + * @param string $classname Class name * @return void */ - function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0) + function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0, $id='', $idsel='', $classname='') { - $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position); + $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname); } /** @@ -78,12 +81,15 @@ class Menu * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) * @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...) * @param int $position Position (not used yet) + * @param string $id Id + * @param string $idsel Id sel + * @param string $classname Class name * @return void */ - function insert($idafter, $url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0) + function insert($idafter, $url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0, $id='', $idsel='', $classname='') { $array_start = array_slice($this->liste,0,($idafter+1)); - $array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu,'position'=>$position)); + $array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu,'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname)); $array_end = array_slice($this->liste,($idafter+1)); $this->liste=array_merge($array_start,$array_new,$array_end); } @@ -100,7 +106,7 @@ class Menu /** * Return number of visible entries (gray or not) - * + * * @return int Number of visible (gray or not) menu entries */ function getNbOfVisibleMenuEntries() diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index a6770b57c37..137a5517231 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -602,7 +602,7 @@ class Menubase //$tabMenu[$b]['langs'] = $menu['langs']; $tabMenu[$b]['fk_mainmenu'] = $menu['fk_mainmenu']; $tabMenu[$b]['fk_leftmenu'] = $menu['fk_leftmenu']; - $tabMenu[$b]['position'] = $menu['position']; + $tabMenu[$b]['position'] = (int) $menu['position']; $b++; } diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index d2712de201f..4ffee2caad9 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -194,7 +194,7 @@ if (! class_exists('MenuManager')) } $menumanager = new MenuManager($db, empty($user->societe_id)?0:1); $menumanager->loadMenu('all','all'); -//var_dump($menumanager->tabMenu);exit; +//var_dump($menumanager);exit; $menumanager->showmenu('jmobile'); print ''; diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index b51d303765b..7b7adc76901 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -62,10 +62,7 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$m $classname = 'class="tmenu menuhider"'; $idsel='menu'; - if (empty($noout)) print_start_menu_entry_auguria($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry_auguria('', 1, '#', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry_auguria($showmode); - $menu->add('#', '', 0, $showmode, $atarget, "xxx", ''); + $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } $num = count($newTabMenu); @@ -95,7 +92,9 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$m } //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad $url = dol_buildpath($url,1).($param?'?'.$param:''); - $shorturl = $shorturl.($param?'?'.$param:''); + //$shorturl = $shorturl.($param?'?'.$param:''); + $shorturl = $url; + if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/','',$shorturl); } $url=preg_replace('/__LOGIN__/',$user->login,$url); @@ -118,10 +117,18 @@ function print_auguria_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$m } else if ($showmode == 2) $classname='class="tmenu"'; - if (empty($noout)) print_start_menu_entry_auguria($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry_auguria($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget)); - if (empty($noout)) print_end_menu_entry_auguria($showmode); - $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), ''); + $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), ($newTabMenu[$i]['leftmenu']?$newTabMenu[$i]['leftmenu']:''), $newTabMenu[$i]['position'], $id, $idsel, $classname); + } + + // Sort on position + $menu->liste = dol_sort_array($menu->liste, 'position'); + + // Output menu entries + foreach($menu->liste as $menkey => $menuval) + { + if (empty($noout)) print_start_menu_entry_auguria($menuval['idsel'],$menuval['classname'],$menuval['enabled']); + if (empty($noout)) print_text_menu_entry_auguria($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); + if (empty($noout)) print_end_menu_entry_auguria($menuval['enabled']); } $showmode=1; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index cd53f913780..ad0bce68f86 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -60,10 +60,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $classname = 'class="tmenu menuhider"'; $idsel='menu'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry('', 1, '#', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('#', '', 0, $showmode, $atarget, "xxx", ''); + $menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } // Home @@ -73,10 +70,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='home'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("Home"), 1, DOL_URL_ROOT.'/index.php?mainmenu=home&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/index.php?mainmenu=home&leftmenu=home', $langs->trans("Home"), 0, $showmode, $atarget, "home", ''); + $menu->add('/index.php?mainmenu=home&leftmenu=home', $langs->trans("Home"), 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname); // Third parties $tmpentry=array('enabled'=>(( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)), 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), 'module'=>'societe|fournisseur'); @@ -91,10 +85,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='companies'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("ThirdParties"), $showmode, DOL_URL_ROOT.'/societe/index.php?mainmenu=companies&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/societe/index.php?mainmenu=companies&leftmenu=', $langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", ''); + $menu->add('/societe/index.php?mainmenu=companies&leftmenu=', $langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", '', 20, $id, $idsel, $classname); } // Products-Services @@ -120,10 +111,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $chaine.=$langs->trans("TMenuServices"); } - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($chaine, $showmode, DOL_URL_ROOT.'/product/index.php?mainmenu=products&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", ''); + $menu->add('/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", '', 30, $id, $idsel, $classname); } // Commercial @@ -147,10 +135,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='commercial'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("Commercial"), $showmode, DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/comm/index.php?mainmenu=commercial&leftmenu=', $langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", ""); + $menu->add('/comm/index.php?mainmenu=commercial&leftmenu=', $langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", "", 40, $id, $idsel, $classname); } // Financial @@ -177,10 +162,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='accountancy'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("MenuFinancial"), $showmode, DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/compta/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("MenuFinancial"), 0, $showmode, $atarget, "accountancy", ''); + $menu->add('/compta/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("MenuFinancial"), 0, $showmode, $atarget, "accountancy", '', 50, $id, $idsel, $classname); } // Bank @@ -198,10 +180,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='bank'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("MenuBankCash"), $showmode, DOL_URL_ROOT.'/compta/bank/index.php?mainmenu=bank&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/compta/bank/index.php?mainmenu=bank&leftmenu=', $langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", ''); + $menu->add('/compta/bank/index.php?mainmenu=bank&leftmenu=', $langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", '', 60, $id, $idsel, $classname); } // Projects @@ -218,10 +197,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='project'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("Projects"), $showmode, DOL_URL_ROOT.'/projet/index.php?mainmenu=project&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/projet/index.php?mainmenu=project&leftmenu=', $langs->trans("Projects"), 0, $showmode, $atarget, "project", ''); + $menu->add('/projet/index.php?mainmenu=project&leftmenu=', $langs->trans("Projects"), 0, $showmode, $atarget, "project", '', 70, $id, $idsel, $classname); } // HRM @@ -238,10 +214,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='hrm'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("HRM"), $showmode, DOL_URL_ROOT.'/hrm/index.php?mainmenu=hrm&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/hrm/index.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", ''); + $menu->add('/hrm/index.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", '', 80, $id, $idsel, $classname); } @@ -260,10 +233,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='tools'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("TMenuTools"), $showmode, DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", ''); + $menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", '', 90, $id, $idsel, $classname); } // Members @@ -278,10 +248,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='members'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($langs->trans("MenuMembers"), $showmode, DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&leftmenu=', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('/adherents/index.php?mainmenu=members&leftmenu=', $langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", ''); + $menu->add('/adherents/index.php?mainmenu=members&leftmenu=', $langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", '', 100, $id, $idsel, $classname); } @@ -297,6 +264,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $showmode=dol_eldy_showmenu($type_user,$newTabMenu[$i],$listofmodulesforexternal); if ($showmode == 1) { + // url = url from host, shorturl = relative path into dolibarr sources $url = $shorturl = $newTabMenu[$i]['url']; if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) { @@ -307,7 +275,9 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode if (! preg_match('/mainmenu/i',$param) || ! preg_match('/leftmenu/i',$param)) $param.=($param?'&':'').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad $url = dol_buildpath($url,1).($param?'?'.$param:''); - $shorturl = $shorturl.($param?'?'.$param:''); + //$shorturl = $shorturl.($param?'?'.$param:''); + $shorturl = $url; + if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/','',$shorturl); } $url=preg_replace('/__LOGIN__/',$user->login,$url); $shorturl=preg_replace('/__LOGIN__/',$user->login,$shorturl); @@ -321,10 +291,18 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode } else if ($showmode == 2) $classname='class="tmenu"'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget)); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), ''); + $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), ($newTabMenu[$i]['leftmenu']?$newTabMenu[$i]['leftmenu']:''), $newTabMenu[$i]['position'], $id, $idsel, $classname); + } + + // Sort on position + $menu->liste = dol_sort_array($menu->liste, 'position'); + + // Output menu entries + foreach($menu->liste as $menkey => $menuval) + { + if (empty($noout)) print_start_menu_entry($menuval['idsel'],$menuval['classname'],$menuval['enabled']); + if (empty($noout)) print_text_menu_entry($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); + if (empty($noout)) print_end_menu_entry($menuval['enabled']); } $showmode=1; diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index e4424712625..dafc0486145 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -76,39 +76,47 @@ class MenuManager $res='ErrorBadParameterForMode'; $noout=0; - if ($mode == 'jmobile') $noout=1; + //if ($mode == 'jmobile') $noout=1; if ($mode == 'topnb') { return 1; } - if ($mode == 'top' || $mode == 'jmobile') + if ($mode == 'top') { if (empty($noout)) print_start_menu_array_empty(); - // Home - $showmode=1; - $idsel='home'; - $classname='class="tmenusel"'; + $usemenuhider = (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)); // Show/Hide vertical menu - if ($mode != 'jmobile' && $mode != 'topnb' && (GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $showmode=1; $classname = 'class="tmenu menuhider"'; $idsel='menu'; - if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); - if (empty($noout)) print_text_menu_entry('', 1, '#', $id, $idsel, $classname, $atarget); - if (empty($noout)) print_end_menu_entry($showmode); - $menu->add('#', '', 0, $showmode, $atarget, "xxx", ''); + $this->menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname); } - if (empty($noout)) print_start_menu_entry_empty($idsel, $classname, $showmode); - if (empty($noout)) print_text_menu_entry_empty($langs->trans("Home"), 1, dol_buildpath('/index.php',1).'?mainmenu=home&leftmenu=', $id, $idsel, $classname, $this->atarget); - if (empty($noout)) print_end_menu_entry_empty($showmode); - $this->menu->add(dol_buildpath('/index.php',1), $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', ''); + // Home + $showmode=1; + $classname='class="tmenusel"'; + $idsel='home'; + + $this->menu->add('/index.php', $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '', 10, $id, $idsel, $classname); + + + // Sort on position + $this->menu->liste = dol_sort_array($this->menu->liste, 'position'); + + // Output menu entries + foreach($this->menu->liste as $menkey => $menuval) + { + if (empty($noout)) print_start_menu_entry_empty($menuval['idsel'],$menuval['classname'],$menuval['enabled']); + if (empty($noout)) print_text_menu_entry_empty($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); + if (empty($noout)) print_end_menu_entry_empty($menuval['enabled']); + } $showmode=1; if (empty($noout)) print_start_menu_entry_empty('','class="tmenuend"',$showmode); @@ -123,7 +131,195 @@ class MenuManager } } - if ($mode == 'left' || $mode == 'jmobile') + if ($mode == 'jmobile') // Used to get menu in xml ul/li + { + // Home + $showmode=1; + $classname='class="tmenusel"'; + $idsel='home'; + + $this->menu->add('/index.php', $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '', 10, $id, $idsel, $classname); + + + // $this->menu->liste is top menu + //var_dump($this->menu->liste);exit; + $lastlevel = array(); + print ''."\n"; + foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' + { + print '
    '; + print '
  • '; + + if ($val['enabled'] == 1) + { + $relurl=dol_buildpath($val['url'],1); + $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl); + $relurl=preg_replace('/__USERID__/',$user->id,$relurl); + $canonurl=preg_replace('/\?.*$/','',$val['url']); + + print ''; + + // Add font-awesome + if ($val['level'] == 0 && $val['mainmenu'] == 'home') print ''; + + print $val['titre']; + print ''."\n"; + + // Search submenu fot this mainmenu entry + $tmpmainmenu=$val['mainmenu']; + $tmpleftmenu='all'; + $submenu=new Menu(); + + $langs->load("admin"); // Load translation file admin.lang + $submenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"),0); + $submenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1); + $submenu->add("/admin/modules.php", $langs->trans("Modules"),1); + $submenu->add("/admin/menus.php", $langs->trans("Menus"),1); + $submenu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); + $submenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"),1); + $submenu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"),1); + + $submenu->add("/admin/boxes.php", $langs->trans("Boxes"),1); + $submenu->add("/admin/delais.php",$langs->trans("Alerts"),1); + $submenu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1); + $submenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1); + $submenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"),1); + $submenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1); + $submenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1); + $submenu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionarySetup"),1); + $submenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1); + + //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; } + //if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; } + $nexturl=dol_buildpath($submenu->liste[0]['url'],1); + + $canonrelurl=preg_replace('/\?.*$/','',$relurl); + $canonnexturl=preg_replace('/\?.*$/','',$nexturl); + //var_dump($canonrelurl); + //var_dump($canonnexturl); + print ''; + } + if ($val['enabled'] == 2) + { + print ''.$val['titre'].''; + } + print '
  • '; + print '
'."\n"; + } + } + + if ($mode == 'left') { // Put here left menu entries // ***** START ***** @@ -134,8 +330,10 @@ class MenuManager $this->menu->add("/admin/modules.php", $langs->trans("Modules"),1); $this->menu->add("/admin/menus.php", $langs->trans("Menus"),1); $this->menu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); - $this->menu->add("/admin/fiscalyear.php", $langs->trans("Fiscalyear"),1); - $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"),1); + $this->menu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"),1); + $this->menu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"),1); + + $this->menu->add("/admin/boxes.php", $langs->trans("Boxes"),1); $this->menu->add("/admin/delais.php",$langs->trans("Alerts"),1); $this->menu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1); $this->menu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1); @@ -143,7 +341,6 @@ class MenuManager $this->menu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1); $this->menu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1); $this->menu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionarySetup"),1); - if (! empty($conf->accounting->enabled)) $this->menu->add("/accountancy/admin/account.php", $langs->trans("Chartofaccounts"),1); $this->menu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1); // ***** END ***** @@ -170,15 +367,15 @@ class MenuManager $lastopened = 1; // For menu manager "empty", we force to not have blockvmenulast defined if (($alt%2==0)) { - print '
'."\n"; + print '
'."\n"; } else { - print '
'."\n"; + print '
'."\n"; } } - // Place tabulation + // Add tabulation $tabstring=''; $tabul=($this->menu->liste[$i]['level'] - 1); if ($tabul > 0) @@ -243,10 +440,10 @@ class MenuManager unset($this->menu->liste); } } - +/* if ($mode == 'jmobile') { - foreach($this->topmenu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' + foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' { print '