2012-07-20 16:21:35 +02:00
< ? php
2012-10-22 13:08:55 +02:00
/* Copyright ( C ) 2012 Christophe Battarel < christophe . battarel @ altairis . fr >
* Copyright ( C ) 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-07-20 16:21:35 +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-20 16:21:35 +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
2012-10-22 13:08:55 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2012-07-20 16:21:35 +02:00
*/
/**
2012-10-03 00:30:50 +02:00
* \defgroup commissions Module commissions
* \brief Module commissions
2012-07-23 11:01:36 +02:00
* \file htdocs / core / modules / modCommissions . class . php
* \ingroup commissions
* \brief Description and activation file for module Commissions
2012-07-20 16:21:35 +02:00
*/
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2012-07-20 16:21:35 +02:00
2012-07-23 11:01:36 +02:00
/**
2012-07-23 10:55:29 +02:00
* Class to describe modude Commisions
2012-07-20 16:21:35 +02:00
*/
class modCommissions extends DolibarrModules
{
/**
2012-07-23 11:01:36 +02:00
* Constructor
*
* @ param DoliDB $db Database handler
*/
2012-07-23 11:07:53 +02:00
function __construct ( $db )
2012-07-20 16:21:35 +02:00
{
2012-07-23 11:01:36 +02:00
$this -> db = $db ;
2012-07-20 16:21:35 +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 = 60000 ;
// Key text used to identify module (for permissions, menus, etc...)
$this -> rights_class = 'Commissions' ;
2012-07-23 11:01:36 +02:00
2012-07-20 16:21:35 +02:00
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
2012-07-23 11:01:36 +02:00
// It is used to group modules in module setup page
$this -> family = " financial " ;
2012-07-20 16:21:35 +02:00
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
2012-07-23 11:01:36 +02:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2012-07-20 16:21:35 +02:00
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
2012-07-23 11:01:36 +02:00
$this -> description = " Commissions management " ;
2012-07-20 16:21:35 +02:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
2012-07-30 22:18:54 +02:00
$this -> version = 'experimental' ;
2012-07-20 16:21:35 +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 );
// Where to store the module in setup page (0=common,1=interface,2=other)
2012-07-30 22:18:54 +02:00
$this -> special = 2 ;
2012-07-20 16:21:35 +02:00
// Name of png file (without png) used for this module.
2012-07-23 11:01:36 +02:00
// Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
$this -> picto = 'commissions' ;
2012-07-20 16:21:35 +02:00
// Data directories to create when module is enabled.
$this -> dirs = array ();
// 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 ( " commissions.php@commissions " );
2012-07-23 11:01:36 +02:00
2012-07-20 16:21:35 +02:00
// Dependencies
2012-07-23 11:01:36 +02:00
$this -> depends = array ( " modFacture " , " modMargin " ); // List of modules id that must be enabled if this module is enabled
2012-07-20 16:21:35 +02:00
$this -> requiredby = array (); // List of modules id to disable if this one is disabled
2012-07-23 11:01:36 +02:00
$this -> phpmin = array ( 5 , 1 ); // Minimum version of PHP required by module
$this -> need_dolibarr_version = array ( 3 , 2 ); // Minimum version of Dolibarr required by module
2012-07-20 16:21:35 +02:00
$this -> langfiles = array ( " commissions " );
2012-07-23 11:01:36 +02:00
2012-07-20 16:21:35 +02:00
// Constants
2012-07-23 16:10:54 +02:00
$this -> const = array ( 0 => array ( 'COMMISSION_BASE' , " chaine " , " TURNOVER " , 'Default commission base' , 0 )); // List of particular constants to add when module is enabled
2012-07-23 11:01:36 +02:00
2012-07-20 16:21:35 +02:00
// New pages on tabs
2012-07-23 11:01:36 +02:00
$this -> tabs = array ();
2012-07-20 16:21:35 +02:00
// Boxes
2012-07-23 11:01:36 +02:00
$this -> boxes = array (); // List of boxes
2012-07-20 16:21:35 +02:00
$r = 0 ;
// Permissions
$this -> rights = array (); // Permission array used by this module
$r = 0 ;
2012-07-23 11:01:36 +02:00
2012-07-20 16:21:35 +02:00
// Add here list of permission defined by an id, a label, a boolean and two constant strings.
// Example:
// $this->rights[$r][0] = 2000; // Permission id (must not be already used)
// $this->rights[$r][1] = 'Permision label'; // Permission label
// $this->rights[$r][3] = 1; // Permission by default for new user (0/1)
// $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
// $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
// $r++;
2012-07-23 11:01:36 +02:00
2012-07-20 16:21:35 +02:00
// Main menu entries
$this -> menu = array (); // List of menus to add
$r = 0 ;
2012-07-23 11:01:36 +02:00
// left menu entry
$this -> menu [ $r ] = array (
2012-07-23 16:10:54 +02:00
'fk_menu' => 'fk_mainmenu=accountancy' , // Put 0 if this is a top menu
'type' => 'left' , // This is a Top menu entry
2012-07-20 16:21:35 +02:00
'titre' => 'Commissions' ,
2012-07-23 16:10:54 +02:00
'mainmenu' => 'accountancy' ,
'leftmenu' => 'commissions' , // Use 1 if you also want to add left menu entries using this descriptor. Use 0 if left menu entries are defined in a file pre.inc.php (old school).
2012-07-20 16:21:35 +02:00
'url' => '/commissions/index.php' ,
2012-07-23 16:10:54 +02:00
'langs' => 'commissions' , // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position' => 200 ,
'enabled' => '$conf->commissions->enabled' , // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
2012-07-20 16:21:35 +02:00
'perms' => '1' , // 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-23 11:01:36 +02:00
$r ++ ;
2012-07-20 16:21:35 +02:00
}
/**
2012-07-23 11:01:36 +02:00
* Function called when module is enabled .
* The init function add constants , boxes , permissions and menus ( defined in constructor ) into Dolibarr database .
* It also creates data directories .
*
2012-07-23 10:46:09 +02:00
* @ return int 1 if OK , 0 if KO
2012-07-20 16:21:35 +02:00
*/
function init ()
{
$sql = array ();
2012-07-23 11:01:36 +02:00
2012-07-20 16:21:35 +02:00
$result = $this -> load_tables ();
2012-07-23 11:01:36 +02:00
2012-07-20 16:21:35 +02:00
return $this -> _init ( $sql );
}
/**
2012-07-23 11:01:36 +02:00
* Function called when module is disabled .
2012-07-23 10:46:09 +02:00
* Remove from database constants , boxes and permissions from Dolibarr database .
* Data directories are not deleted .
*
* @ return int 1 if OK , 0 if KO
2012-07-20 16:21:35 +02:00
*/
function remove ()
{
$sql = array ();
return $this -> _remove ( $sql );
}
2012-07-23 11:01:36 +02:00
2012-07-20 16:21:35 +02:00
/**
2012-07-23 10:46:09 +02:00
* Create tables and keys required by module
2012-07-23 11:01:36 +02:00
* Files mymodule . sql and mymodule . key . sql with create table and create keys
* commands must be stored in directory / mymodule / sql /
2012-07-23 10:46:09 +02:00
* This function is called by this -> init .
2012-07-23 11:01:36 +02:00
*
2012-07-23 10:46:09 +02:00
* @ return int <= 0 if KO , > 0 if OK
2012-07-23 11:01:36 +02:00
*/
2012-07-20 16:21:35 +02:00
function load_tables ()
{
return ;
}
}
?>