Qual: Clean code for adding menu entries into Modules system admin
entry. New: Add entry for admin page Mass barcode init.
This commit is contained in:
parent
5780f14a65
commit
03d056319c
@ -110,11 +110,11 @@ class MenuManager
|
|||||||
|
|
||||||
// Modules system tools
|
// Modules system tools
|
||||||
// TODO Find a way to add parent menu only if child menu exists. For the moment, no other method than hard coded methods.
|
// TODO Find a way to add parent menu only if child menu exists. For the moment, no other method than hard coded methods.
|
||||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled) || ! empty($conf->global->MAIN_MENU_ENABLE_MODULETOOLS))
|
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled) || ! empty($conf->barcode->enabled) // TODO We should enabled module system tools entry without hardcoded test on some modules
|
||||||
|
|| ! empty($conf->global->MAIN_MENU_ENABLE_MODULETOOLS))
|
||||||
{
|
{
|
||||||
if (empty($user->societe_id))
|
if (empty($user->societe_id))
|
||||||
{
|
{
|
||||||
//$newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ModulesSystemTools"), 0, 1, '', 'home', 'modulesadmintools');
|
|
||||||
if ($leftmenu=="modulesadmintools" && $user->admin)
|
if ($leftmenu=="modulesadmintools" && $user->admin)
|
||||||
{
|
{
|
||||||
$langs->load("products");
|
$langs->load("products");
|
||||||
@ -131,9 +131,27 @@ class MenuManager
|
|||||||
'type'=>'left',
|
'type'=>'left',
|
||||||
'position'=>20
|
'position'=>20
|
||||||
);
|
);
|
||||||
array_unshift($tabMenu,$array_menu_product);
|
array_unshift($tabMenu,$array_menu_product); // add at beginning of array
|
||||||
//$newmenu->add("/product/admin/product_tools.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ProductVatMassChange"), 1, $user->admin);
|
|
||||||
}
|
}
|
||||||
|
if ($leftmenu=="modulesadmintools" && $user->admin)
|
||||||
|
{
|
||||||
|
$langs->load("admin");
|
||||||
|
$array_menu_product=array(
|
||||||
|
'url'=>"/barcode/codeinit.php?mainmenu=home&leftmenu=modulesadmintools",
|
||||||
|
'titre'=>$langs->trans("MassBarcodeInit"),
|
||||||
|
'enabled'=>($user->admin?true:false),
|
||||||
|
'perms'=>($user->admin?true:false),
|
||||||
|
'fk_mainmenu'=>'home',
|
||||||
|
'fk_leftmenu'=>'modulesadmintools',
|
||||||
|
'fk_menu'=>-1,
|
||||||
|
'mainmenu'=>'home',
|
||||||
|
'leftmenu'=>'modulesadmintools_massbarcode',
|
||||||
|
'type'=>'left',
|
||||||
|
'position'=>21
|
||||||
|
);
|
||||||
|
array_unshift($tabMenu,$array_menu_product); // add at beginning of array
|
||||||
|
}
|
||||||
|
// Main menu title
|
||||||
$array_menu_product=array(
|
$array_menu_product=array(
|
||||||
'url'=>"/admin/tools/index.php?mainmenu=home&leftmenu=modulesadmintools",
|
'url'=>"/admin/tools/index.php?mainmenu=home&leftmenu=modulesadmintools",
|
||||||
'titre'=>$langs->trans("ModulesSystemTools"),
|
'titre'=>$langs->trans("ModulesSystemTools"),
|
||||||
@ -146,7 +164,7 @@ class MenuManager
|
|||||||
'type'=>'left',
|
'type'=>'left',
|
||||||
'position'=>20
|
'position'=>20
|
||||||
);
|
);
|
||||||
array_unshift($tabMenu,$array_menu_product);
|
array_unshift($tabMenu,$array_menu_product); // add at beginning of array
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -539,11 +539,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Modules system tools
|
// Modules system tools
|
||||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled) || ! empty($conf->global->MAIN_MENU_ENABLE_MODULETOOLS))
|
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled) || ! empty($conf->barcode->enabled) // TODO We should enabled module system tools entry without hardcoded test on some modules
|
||||||
|
|| ! empty($conf->global->MAIN_MENU_ENABLE_MODULETOOLS)) // Some external modules may need to force to have this entry on.
|
||||||
{
|
{
|
||||||
if (empty($user->societe_id))
|
if (empty($user->societe_id))
|
||||||
{
|
{
|
||||||
$newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ModulesSystemTools"), 0, 1, '', $mainmenu, 'modulesadmintools');
|
$newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ModulesSystemTools"), 0, 1, '', $mainmenu, 'modulesadmintools');
|
||||||
|
// Special case: This entry can't be embedded into modules because we need it for both module service and products and we don't want duplicate lines.
|
||||||
if ((empty($leftmenu) || $leftmenu=="modulesadmintools") && $user->admin)
|
if ((empty($leftmenu) || $leftmenu=="modulesadmintools") && $user->admin)
|
||||||
{
|
{
|
||||||
$langs->load("products");
|
$langs->load("products");
|
||||||
|
|||||||
@ -101,14 +101,26 @@ class modBarcode extends DolibarrModules
|
|||||||
'leftmenu'=>'barcodeprint',
|
'leftmenu'=>'barcodeprint',
|
||||||
'type'=>'left', // This is a Left menu entry
|
'type'=>'left', // This is a Left menu entry
|
||||||
'titre'=>'BarCodePrintsheet',
|
'titre'=>'BarCodePrintsheet',
|
||||||
'url'=>'/barcode/printsheet.php',
|
'url'=>'/barcode/printsheet.php?mainmenu=home&leftmenu=modulesadmintools',
|
||||||
'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||||
'position'=>200,
|
'position'=>200,
|
||||||
'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
||||||
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||||
'target'=>'',
|
'target'=>'',
|
||||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||||
$r++;
|
$r++;
|
||||||
|
|
||||||
|
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||||
|
'type'=>'left', // This is a Left menu entry
|
||||||
|
'titre'=>'MassBarcodeInit',
|
||||||
|
'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=modulesadmintools',
|
||||||
|
'langs'=>'barcode', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||||
|
'position'=>300,
|
||||||
|
'enabled'=>'$conf->barcode->enabled && $leftmenu=="modulesadmintools"', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
||||||
|
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||||
|
'target'=>'',
|
||||||
|
'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
|
||||||
|
$r++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -129,6 +129,20 @@ class modProduct extends DolibarrModules
|
|||||||
$this->rights[$r][4] = 'export';
|
$this->rights[$r][4] = 'export';
|
||||||
$r++;
|
$r++;
|
||||||
|
|
||||||
|
/* We can't enable this here because it must be enabled in both product and service module and this create duplicate insert
|
||||||
|
$r=0;
|
||||||
|
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||||
|
'type'=>'left', // This is a Left menu entry
|
||||||
|
'titre'=>'ProductVatMassChange',
|
||||||
|
'url'=>'/product/admin/product_tools.php?mainmenu=home&leftmenu=modulesadmintools',
|
||||||
|
'langs'=>'admin', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||||
|
'position'=>300,
|
||||||
|
'enabled'=>'$conf->product->enabled && $leftmenu=="modulesadmintools"', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
||||||
|
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||||
|
'target'=>'',
|
||||||
|
'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
|
||||||
|
$r++;
|
||||||
|
*/
|
||||||
|
|
||||||
// Exports
|
// Exports
|
||||||
//--------
|
//--------
|
||||||
|
|||||||
@ -114,6 +114,22 @@ class modService extends DolibarrModules
|
|||||||
$r++;
|
$r++;
|
||||||
|
|
||||||
|
|
||||||
|
/* We can't enable this here because it must be enabled in both product and service module and this create duplicate insert
|
||||||
|
$r=0;
|
||||||
|
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
|
||||||
|
'type'=>'left', // This is a Left menu entry
|
||||||
|
'titre'=>'ProductVatMassChange',
|
||||||
|
'url'=>'/product/admin/product_tools.php?mainmenu=home&leftmenu=modulesadmintools',
|
||||||
|
'langs'=>'admin', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||||
|
'position'=>300,
|
||||||
|
'enabled'=>'$conf->product->enabled && $leftmenu=="modulesadmintools"', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
|
||||||
|
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
|
||||||
|
'target'=>'',
|
||||||
|
'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
|
||||||
|
$r++;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Exports
|
// Exports
|
||||||
//--------
|
//--------
|
||||||
$r=0;
|
$r=0;
|
||||||
|
|||||||
@ -347,6 +347,8 @@ GetSecuredUrl=Get calculated URL
|
|||||||
ButtonHideUnauthorized=Hide buttons for unauthorized actions instead of showing disabled buttons
|
ButtonHideUnauthorized=Hide buttons for unauthorized actions instead of showing disabled buttons
|
||||||
ProductVatMassChange=Mass VAT change
|
ProductVatMassChange=Mass VAT change
|
||||||
ProductVatMassChangeDesc=This page can be used to modify a VAT rate defined on products or services from a value to another. Warning, this change is done on all database.
|
ProductVatMassChangeDesc=This page can be used to modify a VAT rate defined on products or services from a value to another. Warning, this change is done on all database.
|
||||||
|
MassBarcodeInit=Mass barcode init
|
||||||
|
MassBarcodeInitDesc=This page can be used to initialize a barcode on objects that does not have barcode defined. Check before that setup of module barcode is complete.
|
||||||
OldVATRates=Old VAT rate
|
OldVATRates=Old VAT rate
|
||||||
NewVATRates=New VAT rate
|
NewVATRates=New VAT rate
|
||||||
PriceBaseTypeToChange=Modify on prices with base reference value defined on
|
PriceBaseTypeToChange=Modify on prices with base reference value defined on
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user