28include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
51 $this->rights_class =
'bookcal';
55 $this->family =
"projects";
58 $this->module_position =
'50';
63 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
68 $this->descriptionlong =
"BookCalDescription";
71 $this->version =
'development';
74 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
80 $this->picto =
'fa-calendar-check';
83 $this->module_parts = array(
119 'moduleforexternal' => 0,
124 $this->dirs = array(
"/bookcal/temp");
127 $this->config_page_url = array(
"setup.php@bookcal");
131 $this->hidden =
false;
133 $this->depends = array();
134 $this->requiredby = array();
135 $this->conflictwith = array();
138 $this->langfiles = array(
"agenda");
141 $this->phpmin = array(7, 0);
144 $this->warnings_activation = array();
145 $this->warnings_activation_ext = array();
154 $this->
const = array();
162 if (!isset($conf->bookcal) || !isset($conf->bookcal->enabled)) {
164 $conf->bookcal->enabled = 0;
168 $this->tabs = array();
196 $this->dictionaries = array();
225 $this->boxes = array(
236 $this->cronjobs = array(
258 $this->rights = array();
262 $this->rights[$r][0] = $this->numero . sprintf(
'%02d', (0 * 10) + 1);
263 $this->rights[$r][1] =
'Read objects of BookCal';
264 $this->rights[$r][4] =
'availabilities';
265 $this->rights[$r][5] =
'read';
267 $this->rights[$r][0] = $this->numero . sprintf(
'%02d', (0 * 10) + 2);
268 $this->rights[$r][1] =
'Create/Update objects of BookCal';
269 $this->rights[$r][4] =
'availabilities';
270 $this->rights[$r][5] =
'write';
272 $this->rights[$r][0] = $this->numero . sprintf(
'%02d', (0 * 10) + 3);
273 $this->rights[$r][1] =
'Delete objects of BookCal';
274 $this->rights[$r][4] =
'availabilities';
275 $this->rights[$r][5] =
'delete';
277 $this->rights[$r][0] = $this->numero . sprintf(
'%02d', (1 * 10) + 1);
278 $this->rights[$r][1] =
'Read Calendar object of BookCal';
279 $this->rights[$r][4] =
'calendar';
280 $this->rights[$r][5] =
'read';
282 $this->rights[$r][0] = $this->numero . sprintf(
'%02d', (1 * 10) + 2);
283 $this->rights[$r][1] =
'Create/Update Calendar object of BookCal';
284 $this->rights[$r][4] =
'calendar';
285 $this->rights[$r][5] =
'write';
287 $this->rights[$r][0] = $this->numero . sprintf(
'%02d', (1 * 10) + 3);
288 $this->rights[$r][1] =
'Delete Calendar object of BookCal';
289 $this->rights[$r][4] =
'calendar';
290 $this->rights[$r][5] =
'delete';
296 $this->menu = array();
318 $this->menu[$r++] = array(
319 'fk_menu'=>
'fk_mainmenu=agenda',
321 'titre'=>
'MenuBookcalIndex',
322 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth em92"'),
323 'mainmenu'=>
'agenda',
324 'leftmenu'=>
'bookcal',
325 'url'=>
'/bookcal/bookcalindex.php',
327 'position'=> 1100+$r,
329 'perms'=>
'$user->rights->bookcal->calendar->read',
333 $this->menu[$r++]=array(
335 'fk_menu'=>
'fk_mainmenu=agenda,fk_leftmenu=bookcal',
339 'mainmenu'=>
'agenda',
340 'leftmenu'=>
'bookcal_calendar_list',
341 'url'=>
'/bookcal/calendar_list.php',
346 'enabled'=>
'$conf->bookcal->enabled',
348 'perms'=>
'$user->rights->bookcal->calendar->read',
353 $this->menu[$r++]=array(
355 'fk_menu'=>
'fk_mainmenu=agenda,fk_leftmenu=bookcal_calendar_list',
358 'titre'=>
'NewCalendar',
359 'mainmenu'=>
'agenda',
360 'leftmenu'=>
'bookcal_new',
361 'url'=>
'/bookcal/calendar_card.php?action=create',
366 'enabled'=>
'$conf->bookcal->enabled',
368 'perms'=>
'$user->rights->bookcal->calendar->read',
421 $this->menu[$r++]=array(
423 'fk_menu'=>
'fk_mainmenu=agenda,fk_leftmenu=bookcal',
426 'titre'=>
'Availabilities',
427 'mainmenu'=>
'agenda',
428 'leftmenu'=>
'bookcal_availabilities',
429 'url'=>
'/bookcal/availabilities_list.php',
434 'enabled'=>
'$conf->bookcal->enabled',
436 'perms'=>
'$user->rights->bookcal->availabilities->read',
441 $this->menu[$r++]=array(
443 'fk_menu'=>
'fk_mainmenu=agenda,fk_leftmenu=bookcal_availabilities',
446 'titre'=>
'NewAvailabilities',
447 'mainmenu'=>
'agenda',
448 'leftmenu'=>
'bookcal_availabilities',
449 'url'=>
'/bookcal/availabilities_card.php?action=create',
454 'enabled'=>
'$conf->bookcal->enabled',
456 'perms'=>
'$user->rights->bookcal->availabilities->read',
538 public function init($options =
'')
540 global $conf, $langs;
542 $result = $this->
_load_tables(
'/install/mysql/',
'bookcal');
557 $this->
remove($options);
563 $myTmpObjects = array();
564 $myTmpObjects[
'Availabilities'] = array(
'includerefgeneration'=>0,
'includedocgeneration'=>0);
566 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
567 if ($myTmpObjectKey ==
'Availabilities') {
570 if ($myTmpObjectArray[
'includerefgeneration']) {
571 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/'.$moduledir.
'/template_availabilitiess.odt';
572 $dirodt = DOL_DATA_ROOT.
'/doctemplates/'.$moduledir;
573 $dest = $dirodt.
'/template_availabilitiess.odt';
575 if (file_exists($src) && !file_exists($dest)) {
576 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
578 $result =
dol_copy($src, $dest, 0, 0);
580 $langs->load(
"errors");
581 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
586 $sql = array_merge($sql, array(
587 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey).
"' AND type = '".$this->db->escape(strtolower($myTmpObjectKey)).
"' AND entity = ".((
int) $conf->entity),
588 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey).
"', '".$this->db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")",
589 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey).
"_odt' AND type = '".$this->db->escape(strtolower($myTmpObjectKey)).
"' AND entity = ".((
int) $conf->entity),
590 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey).
"_odt', '".$this->db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")"
595 return $this->
_init($sql, $options);
606 public function remove($options =
'')
609 return $this->
_remove($sql, $options);
_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.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.