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(
"bookcal@bookcal");
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)) {
163 $conf->bookcal =
new stdClass();
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", $r + 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", $r + 1);
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", $r + 1);
273 $this->rights[$r][1] =
'Delete objects of BookCal';
274 $this->rights[$r][4] =
'availabilities';
275 $this->rights[$r][5] =
'delete';
280 $this->menu = array();
284 $this->menu[$r++] = array(
287 'titre'=>
'ModuleBookCalName',
288 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth valignmiddle"'),
289 'mainmenu'=>
'bookcal',
291 'url'=>
'/bookcal/bookcalindex.php',
292 'langs'=>
'bookcal@bookcal',
293 'position'=>1000 + $r,
294 'enabled'=>
'$conf->bookcal->enabled',
346 $this->menu[$r++]=array(
348 'fk_menu'=>
'fk_mainmenu=bookcal',
351 'titre'=>
'List Availabilities',
352 'mainmenu'=>
'bookcal',
353 'leftmenu'=>
'bookcal_availabilities',
354 'url'=>
'/bookcal/availabilities_list.php',
356 'langs'=>
'bookcal@bookcal',
359 'enabled'=>
'$conf->bookcal->enabled',
366 $this->menu[$r++]=array(
368 'fk_menu'=>
'fk_mainmenu=bookcal,fk_leftmenu=bookcal_availabilities',
371 'titre'=>
'New Availabilities',
372 'mainmenu'=>
'bookcal',
373 'leftmenu'=>
'bookcal_availabilities',
374 'url'=>
'/bookcal/availabilities_card.php?action=create',
376 'langs'=>
'bookcal@bookcal',
379 'enabled'=>
'$conf->bookcal->enabled',
463 public function init($options =
'')
465 global $conf, $langs;
467 $result = $this->
_load_tables(
'/install/mysql/',
'bookcal');
482 $this->
remove($options);
488 $myTmpObjects = array();
489 $myTmpObjects[
'Availabilities'] = array(
'includerefgeneration'=>0,
'includedocgeneration'=>0);
491 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
492 if ($myTmpObjectKey ==
'Availabilities') {
495 if ($myTmpObjectArray[
'includerefgeneration']) {
496 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/'.$moduledir.
'/template_availabilitiess.odt';
497 $dirodt = DOL_DATA_ROOT.
'/doctemplates/'.$moduledir;
498 $dest = $dirodt.
'/template_availabilitiess.odt';
500 if (file_exists($src) && !file_exists($dest)) {
501 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
503 $result =
dol_copy($src, $dest, 0, 0);
505 $langs->load(
"errors");
506 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
511 $sql = array_merge($sql, array(
512 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey).
"' AND type = '".$this->db->escape(strtolower($myTmpObjectKey)).
"' AND entity = ".((
int) $conf->entity),
513 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey).
"', '".$this->db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")",
514 "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),
515 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey).
"_odt', '".$this->db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")"
520 return $this->
_init($sql, $options);
531 public function remove($options =
'')
534 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.