dolibarr 21.0.0-alpha
modBookCal.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2018-2019 Nicolas ZABOURI <info@inovea-conseil.com>
4 * Copyright (C) 2019-2024 Frédéric France <frederic.france@netlogic.fr>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
29include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30
35{
41 public function __construct($db)
42 {
43 global $langs, $conf;
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 = 2430;
50
51 // Key text used to identify module (for permissions, menus, etc...)
52 $this->rights_class = 'bookcal';
53
54 // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
55 // It is used to group modules by family in module setup page
56 $this->family = "projects";
57
58 // Module position in the family on 2 digits ('01', '10', '20', ...)
59 $this->module_position = '50';
60
61 // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
62 //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
63 // Module label (no space allowed), used if translation string 'ModuleBookCalName' not found (BookCal is name of module).
64 $this->name = preg_replace('/^mod/i', '', get_class($this));
65
66 // Module description, used if translation string 'ModuleBookCalDesc' not found (BookCal is name of module).
67 $this->description = "BookCalDescription";
68 // Used only if file README.md and README-LL.md not found.
69 $this->descriptionlong = "BookCalDescription";
70
71 // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
72 $this->version = 'experimental';
73
74 // Key used in llx_const table to save module status enabled/disabled (where BOOKCAL is value of property name of module in uppercase)
75 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
76
77 // Name of image file used for this module.
78 // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
79 // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
80 // To use a supported fa-xxx css style of font awesome, use this->picto='xxx'
81 $this->picto = 'bookcal';
82
83 // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
84 $this->module_parts = array(
85 // Set this to 1 if module has its own trigger directory (core/triggers)
86 'triggers' => 0,
87 // Set this to 1 if module has its own login method file (core/login)
88 'login' => 0,
89 // Set this to 1 if module has its own substitution function file (core/substitutions)
90 'substitutions' => 0,
91 // Set this to 1 if module has its own menus handler directory (core/menus)
92 'menus' => 0,
93 // Set this to 1 if module overwrite template dir (core/tpl)
94 'tpl' => 0,
95 // Set this to 1 if module has its own barcode directory (core/modules/barcode)
96 'barcode' => 0,
97 // Set this to 1 if module has its own models directory (core/modules/xxx)
98 'models' => 0,
99 // Set this to 1 if module has its own printing directory (core/modules/printing)
100 'printing' => 0,
101 // Set this to 1 if module has its own theme directory (theme)
102 'theme' => 0,
103 // Set this to relative path of css file if module has its own css file
104 'css' => array(
105 // '/bookcal/css/bookcal.css.php',
106 ),
107 // Set this to relative path of js file if module must load a js on all pages
108 'js' => array(
109 // '/bookcal/js/bookcal.js.php',
110 ),
111 // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
112 'hooks' => array(
113 // 'data' => array(
114 // 'hookcontext1',
115 // 'hookcontext2',
116 // ),
117 // 'entity' => '0',
118 ),
119 // Set this to 1 if features of module are opened to external users
120 'moduleforexternal' => 0,
121 );
122
123 // Data directories to create when module is enabled.
124 // Example: this->dirs = array("/bookcal/temp","/bookcal/subdir");
125 $this->dirs = array("/bookcal/temp");
126
127 // Config pages. Put here list of php page, stored into bookcal/admin directory, to use to setup module.
128 $this->config_page_url = array("setup.php@bookcal");
129
130 // Dependencies
131 // A condition to hide module
132 $this->hidden = false;
133 // List of module class names as string that must be enabled if this module is enabled. Example: array('always'=>array('modModuleToEnable1','modModuleToEnable2'), 'FR'=>array('modModuleToEnableFR'...))
134 $this->depends = array();
135 $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
136 $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
137
138 // The language file dedicated to your module
139 $this->langfiles = array("agenda");
140
141 // Messages at activation
142 $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','MX'='textmx'...)
143 $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','MX'='textmx'...)
144 //$this->automatic_activation = array('FR'=>'BookCalWasAutomaticallyActivatedBecauseOfYourCountryChoice');
145 //$this->always_enabled = true; // If true, can't be disabled
146
147 // Constants
148 // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
149 // Example: $this->const=array(1 => array('BOOKCAL_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
150 // 2 => array('BOOKCAL_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
151 // );
152 $this->const = array();
153
154 // Some keys to add into the overwriting translation tables
155 /*$this->overwrite_translation = array(
156 'en_US:ParentCompany'=>'Parent company or reseller',
157 'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
158 )*/
159
160 if (!isset($conf->bookcal) || !isset($conf->bookcal->enabled)) {
161 $conf->bookcal = new stdClass();
162 $conf->bookcal->enabled = 0;
163 }
164
165 // Array to add new pages in new tabs
166 $this->tabs = array();
167 // Example:
168 // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@bookcal:$user->rights->bookcal->read:/bookcal/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
169 // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@bookcal:$user->rights->othermodule->read:/bookcal/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
170 // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
171 //
172 // Where objecttype can be
173 // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
174 // 'contact' to add a tab in contact view
175 // 'contract' to add a tab in contract view
176 // 'group' to add a tab in group view
177 // 'intervention' to add a tab in intervention view
178 // 'invoice' to add a tab in customer invoice view
179 // 'invoice_supplier' to add a tab in supplier invoice view
180 // 'member' to add a tab in foundation member view
181 // 'opensurveypoll' to add a tab in opensurvey poll view
182 // 'order' to add a tab in customer order view
183 // 'order_supplier' to add a tab in supplier order view
184 // 'payment' to add a tab in payment view
185 // 'payment_supplier' to add a tab in supplier payment view
186 // 'product' to add a tab in product view
187 // 'propal' to add a tab in propal view
188 // 'project' to add a tab in project view
189 // 'stock' to add a tab in stock view
190 // 'thirdparty' to add a tab in third party view
191 // 'user' to add a tab in user view
192
193 // Dictionaries
194 $this->dictionaries = array();
195 /* Example:
196 $this->dictionaries=array(
197 'langs'=>'bookcal@bookcal',
198 // List of tables we want to see into dictonnary editor
199 'tabname'=>array("table1", "table2", "table3"),
200 // Label of tables
201 'tablib'=>array("Table1", "Table2", "Table3"),
202 // Request to select fields
203 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),
204 // Sort order
205 'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"),
206 // List of fields (result of select to show dictionary)
207 'tabfield'=>array("code,label", "code,label", "code,label"),
208 // List of fields (list of fields to edit a record)
209 'tabfieldvalue'=>array("code,label", "code,label", "code,label"),
210 // List of fields (list of fields for insert)
211 'tabfieldinsert'=>array("code,label", "code,label", "code,label"),
212 // Name of columns with primary key (try to always name it 'rowid')
213 'tabrowid'=>array("rowid", "rowid", "rowid"),
214 // Condition to show each dictionary
215 'tabcond'=>array($conf->bookcal->enabled, $conf->bookcal->enabled, $conf->bookcal->enabled)
216 // Help tooltip for each fields of the dictionary
217 'tabhelp'=>array(array('code'=>$langs->trans('CodeTooltipHelp')))
218 );
219 */
220
221 // Boxes/Widgets
222 // Add here list of php file(s) stored in bookcal/core/boxes that contains a class to show a widget.
223 $this->boxes = array(
224 // 0 => array(
225 // 'file' => 'bookcalwidget1.php@bookcal',
226 // 'note' => 'Widget provided by BookCal',
227 // 'enabledbydefaulton' => 'Home',
228 // ),
229 // ...
230 );
231
232 // Cronjobs (List of cron jobs entries to add when module is enabled)
233 // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
234 $this->cronjobs = array(
235 // 0 => array(
236 // 'label' => 'MyJob label',
237 // 'jobtype' => 'method',
238 // 'class' => '/bookcal/class/availabilities.class.php',
239 // 'objectname' => 'Availabilities',
240 // 'method' => 'doScheduledJob',
241 // 'parameters' => '',
242 // 'comment' => 'Comment',
243 // 'frequency' => 2,
244 // 'unitfrequency' => 3600,
245 // 'status' => 0,
246 // 'test' => '$conf->bookcal->enabled',
247 // 'priority' => 50,
248 // ),
249 );
250 // Example: $this->cronjobs=array(
251 // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->bookcal->enabled', 'priority'=>50),
252 // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->bookcal->enabled', 'priority'=>50)
253 // );
254
255 // Permissions provided by this module
256 $this->rights = array();
257 $r = 0;
258 // Add here entries to declare new permissions
259 /* BEGIN MODULEBUILDER PERMISSIONS */
260 $this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 1);
261 $this->rights[$r][1] = 'Read objects of BookCal';
262 $this->rights[$r][4] = 'availabilities';
263 $this->rights[$r][5] = 'read';
264 $r++;
265 $this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 2);
266 $this->rights[$r][1] = 'Create/Update objects of BookCal';
267 $this->rights[$r][4] = 'availabilities';
268 $this->rights[$r][5] = 'write';
269 $r++;
270 $this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 3);
271 $this->rights[$r][1] = 'Delete objects of BookCal';
272 $this->rights[$r][4] = 'availabilities';
273 $this->rights[$r][5] = 'delete';
274 $r++;
275 $this->rights[$r][0] = $this->numero . sprintf('%02d', (1 * 10) + 1);
276 $this->rights[$r][1] = 'Read Calendar object of BookCal';
277 $this->rights[$r][4] = 'calendar';
278 $this->rights[$r][5] = 'read';
279 $r++;
280 $this->rights[$r][0] = $this->numero . sprintf('%02d', (1 * 10) + 2);
281 $this->rights[$r][1] = 'Create/Update Calendar object of BookCal';
282 $this->rights[$r][4] = 'calendar';
283 $this->rights[$r][5] = 'write';
284 $r++;
285 $this->rights[$r][0] = $this->numero . sprintf('%02d', (1 * 10) + 3);
286 $this->rights[$r][1] = 'Delete Calendar object of BookCal';
287 $this->rights[$r][4] = 'calendar';
288 $this->rights[$r][5] = 'delete';
289 $r++;
290
291 /* END MODULEBUILDER PERMISSIONS */
292
293 // Main menu entries to add
294 $this->menu = array();
295 $r = 0;
296 // Add here entries to declare new menus
297 /* BEGIN MODULEBUILDER TOPMENU */
298 /*$this->menu[$r++] = array(
299 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
300 'type'=>'top', // This is a Top menu entry
301 'titre'=>'ModuleBookCalName',
302 'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth valignmiddle"'),
303 'mainmenu'=>'bookcal',
304 'leftmenu'=>'',
305 'url'=>'/bookcal/bookcalindex.php',
306 'langs'=>'bookcal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
307 'position'=>1000 + $r,
308 'enabled'=>'$conf->bookcal->enabled', // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled.
309 'perms'=>'$user->rights->bookcal->availabilities->read', // Use 'perms'=>'$user->rights->bookcal->availabilities->read' if you want your menu with a permission rules
310 'target'=>'',
311 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
312 );*/
313 /* END MODULEBUILDER TOPMENU */
314
315 /* BEGIN MODULEBUILDER LEFTMENU CALENDAR */
316 $this->menu[$r++] = array(
317 'fk_menu' => 'fk_mainmenu=agenda',
318 'type' => 'left',
319 'titre' => 'MenuBookcalIndex',
320 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em92"'),
321 'mainmenu' => 'agenda',
322 'leftmenu' => 'bookcal',
323 'url' => '/bookcal/bookcalindex.php',
324 'langs' => 'bookcal',
325 'position' => 1100 + $r,
326 'enabled' => '1',
327 'perms' => '$user->rights->bookcal->calendar->read',
328 'user' => 0
329 );
330
331 $this->menu[$r++] = array(
332 // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
333 'fk_menu' => 'fk_mainmenu=agenda,fk_leftmenu=bookcal',
334 // This is a Left menu entry
335 'type' => 'left',
336 'titre' => 'Calendar',
337 'mainmenu' => 'agenda',
338 'leftmenu' => 'bookcal_calendar_list',
339 'url' => '/bookcal/calendar_list.php',
340 // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
341 'langs' => 'bookcal',
342 'position' => 1100 + $r,
343 // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
344 'enabled' => '$conf->bookcal->enabled',
345 // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules
346 'perms' => '$user->rights->bookcal->calendar->read',
347 'target' => '',
348 // 0=Menu for internal users, 1=external users, 2=both
349 'user' => 2,
350 );
351 $this->menu[$r++] = array(
352 // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
353 'fk_menu' => 'fk_mainmenu=agenda,fk_leftmenu=bookcal_calendar_list',
354 // This is a Left menu entry
355 'type' => 'left',
356 'titre' => 'NewCalendar',
357 'mainmenu' => 'agenda',
358 'leftmenu' => 'bookcal_new',
359 'url' => '/bookcal/calendar_card.php?action=create',
360 // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
361 'langs' => 'bookcal',
362 'position' => 1100 + $r,
363 // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
364 'enabled' => '$conf->bookcal->enabled',
365 // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules
366 'perms' => '$user->rights->bookcal->calendar->read',
367 'target' => '',
368 // 0=Menu for internal users, 1=external users, 2=both
369 'user' => 2
370 );
371 /* END MODULEBUILDER LEFTMENU CALENDAR */
372
373 /* BEGIN MODULEBUILDER LEFTMENU AVAILABILITIES
374 $this->menu[$r++]=array(
375 'fk_menu'=>'fk_mainmenu=bookcal', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
376 'type'=>'left', // This is a Left menu entry
377 'titre'=>'Availabilities',
378 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth valignmiddle"'),
379 'mainmenu'=>'bookcal',
380 'leftmenu'=>'availabilities',
381 'url'=>'/bookcal/bookcalindex.php',
382 'langs'=>'bookcal@bookcal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
383 'position'=>1000+$r,
384 'enabled'=>'$conf->bookcal->enabled', // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled.
385 'perms'=>'$user->rights->bookcal->availabilities->read', // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules
386 'target'=>'',
387 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
388 );
389 $this->menu[$r++]=array(
390 'fk_menu'=>'fk_mainmenu=bookcal,fk_leftmenu=availabilities', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
391 'type'=>'left', // This is a Left menu entry
392 'titre'=>'List_Availabilities',
393 'mainmenu'=>'bookcal',
394 'leftmenu'=>'bookcal_availabilities_list',
395 'url'=>'/bookcal/availabilities_list.php',
396 'langs'=>'bookcal@bookcal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
397 'position'=>1000+$r,
398 'enabled'=>'$conf->bookcal->enabled', // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
399 'perms'=>'$user->rights->bookcal->availabilities->read', // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules
400 'target'=>'',
401 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
402 );
403 $this->menu[$r++]=array(
404 'fk_menu'=>'fk_mainmenu=bookcal,fk_leftmenu=availabilities', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
405 'type'=>'left', // This is a Left menu entry
406 'titre'=>'New_Availabilities',
407 'mainmenu'=>'bookcal',
408 'leftmenu'=>'bookcal_availabilities_new',
409 'url'=>'/bookcal/availabilities_card.php?action=create',
410 'langs'=>'bookcal@bookcal', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
411 'position'=>1000+$r,
412 'enabled'=>'$conf->bookcal->enabled', // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
413 'perms'=>'$user->rights->bookcal->availabilities->write', // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules
414 'target'=>'',
415 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
416 );
417 */
418
419 $this->menu[$r++] = array(
420 // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
421 'fk_menu' => 'fk_mainmenu=agenda,fk_leftmenu=bookcal',
422 // This is a Left menu entry
423 'type' => 'left',
424 'titre' => 'Availabilities',
425 'mainmenu' => 'agenda',
426 'leftmenu' => 'bookcal_availabilities',
427 'url' => '/bookcal/availabilities_list.php',
428 // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
429 'langs' => 'bookcal',
430 'position' => 1200 + $r,
431 // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
432 'enabled' => '$conf->bookcal->enabled',
433 // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules
434 'perms' => '$user->rights->bookcal->availabilities->read',
435 'target' => '',
436 // 0=Menu for internal users, 1=external users, 2=both
437 'user' => 2,
438 );
439 $this->menu[$r++] = array(
440 // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
441 'fk_menu' => 'fk_mainmenu=agenda,fk_leftmenu=bookcal_availabilities',
442 // This is a Left menu entry
443 'type' => 'left',
444 'titre' => 'NewAvailabilities',
445 'mainmenu' => 'agenda',
446 'leftmenu' => 'bookcal_availabilities',
447 'url' => '/bookcal/availabilities_card.php?action=create',
448 // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
449 'langs' => 'bookcal',
450 'position' => 1200 + $r,
451 // Define condition to show or hide menu entry. Use '$conf->bookcal->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
452 'enabled' => '$conf->bookcal->enabled',
453 // Use 'perms'=>'$user->rights->bookcal->level1->level2' if you want your menu with a permission rules
454 'perms' => '$user->rights->bookcal->availabilities->read',
455 'target' => '',
456 // 0=Menu for internal users, 1=external users, 2=both
457 'user' => 2
458 );
459
460 /* END MODULEBUILDER LEFTMENU AVAILABILITIES */
461 // Exports profiles provided by this module
462 $r = 1;
463 /* BEGIN MODULEBUILDER EXPORT AVAILABILITIES */
464 /*
465 $langs->load("agenda");
466 $this->export_code[$r]=$this->rights_class.'_'.$r;
467 $this->export_label[$r]='AvailabilitiesLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
468 $this->export_icon[$r]='availabilities@bookcal';
469 // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array
470 $keyforclass = 'Availabilities'; $keyforclassfile='/bookcal/class/availabilities.class.php'; $keyforelement='availabilities@bookcal';
471 include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
472 //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
473 //unset($this->export_fields_array[$r]['t.fieldtoremove']);
474 //$keyforclass = 'AvailabilitiesLine'; $keyforclassfile='/bookcal/class/availabilities.class.php'; $keyforelement='availabilitiesline@bookcal'; $keyforalias='tl';
475 //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
476 $keyforselect='availabilities'; $keyforaliasextra='extra'; $keyforelement='availabilities@bookcal';
477 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
478 //$keyforselect='availabilitiesline'; $keyforaliasextra='extraline'; $keyforelement='availabilitiesline@bookcal';
479 //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
480 //$this->export_dependencies_array[$r] = array('availabilitiesline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
481 //$this->export_special_array[$r] = array('t.field'=>'...');
482 //$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
483 //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
484 $this->export_sql_start[$r]='SELECT DISTINCT ';
485 $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'availabilities as t';
486 //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'availabilities_line as tl ON tl.fk_availabilities = t.rowid';
487 $this->export_sql_end[$r] .=' WHERE 1 = 1';
488 $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('availabilities').')';
489 $r++; */
490 /* END MODULEBUILDER EXPORT AVAILABILITIES */
491
492 // Imports profiles provided by this module
493
494 $r = 1;
495 /* BEGIN MODULEBUILDER IMPORT AVAILABILITIES */
496 /*
497 $langs->load("agenda");
498 $this->import_code[$r]=$this->rights_class.'_'.$r;
499 $this->import_label[$r]='AvailabilitiesLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
500 $this->import_icon[$r]='availabilities@bookcal';
501 $this->import_tables_array[$r] = array('t' => MAIN_DB_PREFIX.'bookcal_availabilities', 'extra' => MAIN_DB_PREFIX.'bookcal_availabilities_extrafields');
502 $this->import_tables_creator_array[$r] = array('t' => 'fk_user_author'); // Fields to store import user id
503 $import_sample = array();
504 $keyforclass = 'Availabilities'; $keyforclassfile='/bookcal/class/availabilities.class.php'; $keyforelement='availabilities@bookcal';
505 include DOL_DOCUMENT_ROOT.'/core/commonfieldsinimport.inc.php';
506 $import_extrafield_sample = array();
507 $keyforselect='availabilities'; $keyforaliasextra='extra'; $keyforelement='availabilities@bookcal';
508 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php';
509 $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'bookcal_availabilities');
510 $this->import_regex_array[$r] = array();
511 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
512 $this->import_updatekeys_array[$r] = array('t.ref' => 'Ref');
513 $this->import_convertvalue_array[$r] = array(
514 't.ref' => array(
515 'rule'=>'getrefifauto',
516 'class'=>(empty($conf->global->BOOKCAL_AVAILABILITIES_ADDON) ? 'mod_availabilities_standard' : $conf->global->BOOKCAL_AVAILABILITIES_ADDON),
517 'path'=>"/core/modules/commande/".(empty($conf->global->BOOKCAL_AVAILABILITIES_ADDON) ? 'mod_availabilities_standard' : $conf->global->BOOKCAL_AVAILABILITIES_ADDON).'.php'
518 'classobject'=>'Availabilities',
519 'pathobject'=>'/bookcal/class/availabilities.class.php',
520 ),
521 't.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'),
522 't.fk_user_valid' => array('rule' => 'fetchidfromref', 'file' => '/user/class/user.class.php', 'class' => 'User', 'method' => 'fetch', 'element' => 'user'),
523 't.fk_mode_reglement' => array('rule' => 'fetchidfromcodeorlabel', 'file' => '/compta/paiement/class/cpaiement.class.php', 'class' => 'Cpaiement', 'method' => 'fetch', 'element' => 'cpayment'),
524 );
525 $r++; */
526 /* END MODULEBUILDER IMPORT AVAILABILITIES */
527 }
528
537 public function init($options = '')
538 {
539 global $conf, $langs;
540
541 $result = $this->_load_tables('/install/mysql/', 'bookcal');
542 if ($result < 0) {
543 return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
544 }
545
546 // Permissions
547 $this->remove($options);
548
549 $sql = array();
550
551 return $this->_init($sql, $options);
552 }
553
562 public function remove($options = '')
563 {
564 $sql = array();
565 return $this->_remove($sql, $options);
566 }
567}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_remove($array_sql, $options='')
Disable function.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Description and activation class for module BookCal.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:142