2012-07-18 15:52:15 +02:00
< ? php
2012-07-20 09:57:50 +02:00
/* Copyright ( C ) 2012 Christophe Battarel < christophe . battarel @ altairis . fr >
2015-01-18 16:42:11 +01:00
* Copyright ( C ) 2015 Marcos García < marcosgdf @ gmail . com >
2012-07-18 15:52:15 +02:00
*
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2012-07-18 15:52:15 +02:00
* ( 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2012-07-18 15:52:15 +02:00
*/
2012-10-03 00:30:50 +02:00
/** \defgroup margin Module margin
2012-07-30 22:18:54 +02:00
* \brief Module to manage margins
2013-08-22 16:49:23 +02:00
* \file htdocs / core / modules / modMargin . class . php
2012-07-20 09:57:50 +02:00
* \ingroup margin
2021-03-20 13:55:43 +01:00
* \brief Description and activation file for the module Margin
2012-07-18 15:52:15 +02:00
*/
2020-04-10 10:59:32 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2012-07-18 15:52:15 +02:00
2012-07-20 09:57:50 +02:00
/**
2012-07-23 10:55:29 +02:00
* Class to describe module Margin
2012-07-18 15:52:15 +02:00
*/
2012-07-20 09:57:50 +02:00
class modMargin extends DolibarrModules
2012-07-18 15:52:15 +02:00
{
2012-07-20 09:57:50 +02:00
/**
* Constructor
*
* @ param DoliDB $db Database handler
*/
2019-02-25 20:35:59 +01:00
public function __construct ( $db )
2012-07-18 15:52:15 +02:00
{
2012-07-20 09:57:50 +02:00
$this -> db = $db ;
2012-07-18 15:52:15 +02:00
// Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
$this -> numero = 59000 ;
// Key text used to identify module (for permissions, menus, etc...)
2014-05-03 20:21:35 +02:00
$this -> rights_class = 'margins' ;
2012-07-20 09:57:50 +02:00
2012-07-18 15:52:15 +02:00
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
2012-07-20 09:57:50 +02:00
// It is used to group modules in module setup page
$this -> family = " financial " ;
2018-10-06 11:57:53 +02:00
$this -> module_position = '55' ;
2012-07-18 15:52:15 +02:00
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
2019-01-27 11:55:16 +01:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2012-07-18 15:52:15 +02:00
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
2012-07-20 09:57:50 +02:00
$this -> description = " Margin management " ;
2012-07-18 15:52:15 +02:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
2012-12-08 14:24:57 +01:00
$this -> version = 'dolibarr' ;
2012-07-18 15:52:15 +02:00
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
// Name of png file (without png) used for this module.
2012-07-20 09:57:50 +02:00
// Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
2020-04-10 10:59:32 +02:00
$this -> picto = 'margin' ;
2012-07-20 09:57:50 +02:00
2012-07-18 15:52:15 +02:00
// Data directories to create when module is enabled.
2012-07-20 09:57:50 +02:00
$this -> dirs = array ( '/margin/temp' );
2012-07-18 15:52:15 +02:00
// Config pages. Put here list of php page names stored in admmin directory used to setup module.
2012-07-23 16:10:54 +02:00
$this -> config_page_url = array ( " margin.php@margin " );
2012-07-20 09:57:50 +02:00
2012-07-18 15:52:15 +02:00
// Dependencies
2020-04-10 10:59:32 +02:00
$this -> hidden = false ; // A condition to hide module
$this -> depends = array ( " modPropale " , " modProduct " ); // List of module class names as string that must be enabled if this module is enabled
$this -> requiredby = array (); // List of module ids to disable if this one is disabled
$this -> conflictwith = array (); // List of module class names as string this module is in conflict with
2021-02-06 13:48:31 +01:00
$this -> phpmin = array ( 5 , 6 ); // Minimum version of PHP required by module
2020-04-10 10:59:32 +02:00
$this -> need_dolibarr_version = array ( 3 , 2 ); // Minimum version of Dolibarr required by module
2012-07-20 09:57:50 +02:00
$this -> langfiles = array ( " margins " );
2012-07-18 15:52:15 +02:00
// Constants
2016-01-13 13:36:44 +01:00
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
// );
2020-04-10 10:59:32 +02:00
$this -> const = array ( 0 => array ( 'MARGIN_TYPE' , 'chaine' , 'costprice' , 'Rule for margin calculation by default' , 0 , 'current' , 0 )); // List of particular constants to add when module is enabled
2012-07-20 09:57:50 +02:00
2012-07-18 15:52:15 +02:00
// New pages on tabs
$this -> tabs = array (
2013-08-20 12:00:16 +02:00
'product:+margin:Margins:margins:$user->rights->margins->liretous:/margin/tabs/productMargins.php?id=__ID__' ,
2019-10-31 20:46:31 +01:00
'thirdparty:+margin:Margins:margins:empty($user->socid) && $user->rights->margins->liretous && ($object->client > 0):/margin/tabs/thirdpartyMargins.php?socid=__ID__'
2012-07-20 09:57:50 +02:00
);
2012-07-18 15:52:15 +02:00
// Boxes
2020-04-10 10:59:32 +02:00
$this -> boxes = array (); // List of boxes
$r = 0 ;
2012-07-20 09:57:50 +02:00
2012-07-18 15:52:15 +02:00
// Permissions
2020-04-10 10:59:32 +02:00
$this -> rights = array (); // Permission array used by this module
$r = 0 ;
2012-07-20 09:57:50 +02:00
2012-07-18 15:52:15 +02:00
// Main menu entries
2020-04-10 10:59:32 +02:00
$this -> menu = array (); // List of menus to add
2012-07-18 15:52:15 +02:00
$r = 0 ;
2012-07-20 09:57:50 +02:00
// left menu entry
2020-04-10 10:59:32 +02:00
$this -> menu [ $r ] = array (
2021-02-06 10:52:03 +01:00
'fk_menu' => 'fk_mainmenu=billing' , // Put 0 if this is a top menu
'type' => 'left' , // This is a Top menu entry
'titre' => 'Margins' ,
2021-02-06 11:56:27 +01:00
'prefix' => img_picto ( '' , $this -> picto , 'class="paddingright pictofixedwidth"' ),
2021-02-06 10:52:03 +01:00
'mainmenu' => 'billing' ,
'leftmenu' => 'margins' ,
'url' => '/margin/index.php' ,
'langs' => 'margins' , // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position' => 100 ,
'enabled' => '$conf->margin->enabled' , // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
'perms' => '$user->rights->margins->liretous' , // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
'target' => '' ,
'user' => 2 , // 0=Menu for internal users, 1=external users, 2=both
);
2012-07-20 09:57:50 +02:00
$r ++ ;
2013-08-20 12:00:16 +02:00
// Permissions
$this -> rights = array ();
2020-04-10 10:59:32 +02:00
$r = 0 ;
2013-08-20 12:00:16 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 59001 ; // id de la permission
$this -> rights [ $r ][ 1 ] = 'Visualiser les marges' ; // libelle de la permission
$this -> rights [ $r ][ 2 ] = 'r' ; // type de la permission (deprecie a ce jour)
2016-06-04 12:16:30 +02:00
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
2013-08-20 12:00:16 +02:00
$this -> rights [ $r ][ 4 ] = 'liretous' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 59002 ; // id de la permission
$this -> rights [ $r ][ 1 ] = 'Définir les marges' ; // libelle de la permission
$this -> rights [ $r ][ 2 ] = 'w' ; // type de la permission (deprecie a ce jour)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
$this -> rights [ $r ][ 4 ] = 'creer' ;
2015-01-18 16:42:11 +01:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 59003 ; // id de la permission
$this -> rights [ $r ][ 1 ] = 'Read every user margin' ; // libelle de la permission
$this -> rights [ $r ][ 2 ] = 'r' ; // type de la permission (deprecie a ce jour)
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
$this -> rights [ $r ][ 4 ] = 'read' ;
$this -> rights [ $r ][ 5 ] = 'all' ;
2012-07-20 09:57:50 +02:00
}
2012-07-18 15:52:15 +02:00
}