dolibarr  7.0.0-beta
modHoliday.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
5  * Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
6  * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  * or see http://www.gnu.org/
21  */
22 
30 include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php");
31 
32 
37 {
43  function __construct($db)
44  {
45  $this->db = $db;
46 
47  // Id for module (must be unique).
48  // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
49  $this->numero = 20000;
50  // Key text used to identify module (for permissions, menus, etc...)
51  $this->rights_class = 'holiday';
52 
53  // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
54  // It is used to group modules in module setup page
55  $this->family = "hr";
56  $this->module_position = 30;
57  // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
58  $this->name = preg_replace('/^mod/i','',get_class($this));
59  // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
60  $this->description = "Leave management";
61  // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
62  $this->version = 'dolibarr';
63  // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
64  $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
65  // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
66  $this->special = 0;
67  // Name of image file used for this module.
68  // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
69  // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
70  $this->picto='holiday';
71 
72  // Data directories to create when module is enabled.
73  // Example: this->dirs = array("/mymodule/temp");
74  $this->dirs = array();
75  $r=0;
76 
77  // Config pages. Put here list of php page names stored in admmin directory used to setup module.
78  // $this->config_page_url = array("holiday.php?leftmenu=setup@holiday");
79 
80  // Dependencies
81  $this->depends = array(); // List of modules id that must be enabled if this module is enabled
82  $this->requiredby = array(); // List of modules id to disable if this one is disabled
83  $this->phpmin = array(4,3); // Minimum version of PHP required by module
84  $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module
85  $this->langfiles = array("holiday");
86 
87  // Constants
88  // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
89  // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
90  // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0)
91  $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')
92 
93  // Array to add new pages in new tabs
94  $this->tabs[] = array('data'=>'user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=hrm&id=__ID__'); // To add a new tab identified by code tabname1
95 
96  // Boxes
97  $this->boxes = array(); // List of boxes
98  $r=0;
99 
100  // Add here list of php file(s) stored in includes/boxes that contains class to show a box.
101  // Example:
102  //$this->boxes[$r][1] = "myboxa.php";
103  //$r++;
104  //$this->boxes[$r][1] = "myboxb.php";
105  //$r++;
106 
107 
108  // Permissions
109  $this->rights = array(); // Permission array used by this module
110  $r=0;
111 
112  $this->rights[$r][0] = 20001; // Permission id (must not be already used)
113  $this->rights[$r][1] = 'Read your own holidays'; // Permission label
114  $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
115  $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
116  $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
117  $r++;
118 
119  $this->rights[$r][0] = 20002; // Permission id (must not be already used)
120  $this->rights[$r][1] = 'Create/modify your own holidays'; // Permission label
121  $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
122  $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
123  $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
124  $r++;
125 
126  $this->rights[$r][0] = 20003; // Permission id (must not be already used)
127  $this->rights[$r][1] = 'Delete holidays'; // Permission label
128  $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
129  $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
130  $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
131  $r++;
132 
133  $this->rights[$r][0] = 20004; // Permission id (must not be already used)
134  $this->rights[$r][1] = 'Read holidays for everybody'; // Permission label
135  $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
136  $this->rights[$r][4] = 'read_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
137  $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
138  $r++;
139 
140  $this->rights[$r][0] = 20005; // Permission id (must not be already used)
141  $this->rights[$r][1] = 'Create/modify holidays for everybody'; // Permission label
142  $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
143  $this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
144  $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
145  $r++;
146 
147  $this->rights[$r][0] = 20006; // Permission id (must not be already used)
148  $this->rights[$r][1] = 'Setup holidays of users (setup and update balance)'; // Permission label
149  $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
150  $this->rights[$r][4] = 'define_holiday'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
151  $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
152  $r++;
153 
154 
155  // Menus
156  //-------
157  $this->menu = 1; // This module add menu entries. They are coded into menu manager.
158 
159 
160  // Exports
161  $r=1;
162 
163  // Example:
164  // $this->export_code[$r]=$this->rights_class.'_'.$r;
165  // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
166  // $this->export_permission[$r]=array(array("facture","facture","export"));
167  // $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef');
168  // $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product');
169  // $this->export_alias_array[$r]=array('s.rowid'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.zip'=>'soc_zip','s.town'=>'soc_town','s.fk_pays'=>'soc_pays','s.phone'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','s.code_compta'=>'soc_customer_accountancy','s.code_compta_fournisseur'=>'soc_supplier_accountancy','f.rowid'=>"invoiceid",'f.facnumber'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice",'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.tva'=>"totalvat",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid','fd.description'=>"linedescription",'fd.price'=>"lineprice",'fd.total_ht'=>"linetotalht",'fd.total_tva'=>"linetotaltva",'fd.total_ttc'=>"linetotalttc",'fd.tva_tx'=>"linevatrate",'fd.qty'=>"lineqty",'fd.date_start'=>"linedatestart",'fd.date_end'=>"linedateend",'fd.fk_product'=>'productid','p.ref'=>'productref');
170  // $this->export_sql_start[$r]='SELECT DISTINCT ';
171  // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)';
172  // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
173  // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
174  // $r++;
175  }
176 }
177 
Class DolibarrModules.
</td >< tdclass="liste_titre"align="right"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="'.$i.'"'.$disabled.'></td >< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"></td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:554
Description and activation class for module holiday.
__construct($db)
Constructor.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104