28 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
47 $this->numero = 500000;
50 $this->rights_class =
'bookcal';
54 $this->family =
"other";
57 $this->module_position =
'50';
62 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
67 $this->descriptionlong =
"BookCalDescription";
70 $this->version =
'development';
75 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
81 $this->picto =
'fa-generic';
84 $this->module_parts = array(
120 'moduleforexternal' => 0,
125 $this->dirs = array(
"/bookcal/temp");
128 $this->config_page_url = array(
"setup.php@bookcal");
132 $this->hidden =
false;
134 $this->depends = array();
135 $this->requiredby = array();
136 $this->conflictwith = array();
139 $this->langfiles = array(
"bookcal@bookcal");
142 $this->phpmin = array(7, 0);
143 $this->need_dolibarr_version = array(17, -3);
146 $this->warnings_activation = array();
147 $this->warnings_activation_ext = array();
156 $this->
const = array();
164 if (!isset($conf->bookcal) || !isset($conf->bookcal->enabled)) {
165 $conf->bookcal =
new stdClass();
166 $conf->bookcal->enabled = 0;
170 $this->tabs = array();
198 $this->dictionaries = array();
227 $this->boxes = array(
238 $this->cronjobs = array(
260 $this->rights = array();
264 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
265 $this->rights[$r][1] =
'Read objects of BookCal';
266 $this->rights[$r][4] =
'availabilities';
267 $this->rights[$r][5] =
'read';
269 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
270 $this->rights[$r][1] =
'Create/Update objects of BookCal';
271 $this->rights[$r][4] =
'availabilities';
272 $this->rights[$r][5] =
'write';
274 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
275 $this->rights[$r][1] =
'Delete objects of BookCal';
276 $this->rights[$r][4] =
'availabilities';
277 $this->rights[$r][5] =
'delete';
282 $this->menu = array();
286 $this->menu[$r++] = array(
289 'titre'=>
'ModuleBookCalName',
290 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth valignmiddle"'),
291 'mainmenu'=>
'bookcal',
293 'url'=>
'/bookcal/bookcalindex.php',
294 'langs'=>
'bookcal@bookcal',
295 'position'=>1000 + $r,
296 'enabled'=>
'$conf->bookcal->enabled',
348 $this->menu[$r++]=array(
350 'fk_menu'=>
'fk_mainmenu=bookcal',
353 'titre'=>
'List Availabilities',
354 'mainmenu'=>
'bookcal',
355 'leftmenu'=>
'bookcal_availabilities',
356 'url'=>
'/bookcal/availabilities_list.php',
358 'langs'=>
'bookcal@bookcal',
361 'enabled'=>
'$conf->bookcal->enabled',
368 $this->menu[$r++]=array(
370 'fk_menu'=>
'fk_mainmenu=bookcal,fk_leftmenu=bookcal_availabilities',
373 'titre'=>
'New Availabilities',
374 'mainmenu'=>
'bookcal',
375 'leftmenu'=>
'bookcal_availabilities',
376 'url'=>
'/bookcal/availabilities_card.php?action=create',
378 'langs'=>
'bookcal@bookcal',
381 'enabled'=>
'$conf->bookcal->enabled',
465 public function init($options =
'')
467 global $conf, $langs;
485 $this->
remove($options);
491 $myTmpObjects = array();
492 $myTmpObjects[
'Availabilities'] = array(
'includerefgeneration'=>0,
'includedocgeneration'=>0);
494 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
495 if ($myTmpObjectKey ==
'Availabilities') {
498 if ($myTmpObjectArray[
'includerefgeneration']) {
499 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/'.$moduledir.
'/template_availabilitiess.odt';
500 $dirodt = DOL_DATA_ROOT.
'/doctemplates/'.$moduledir;
501 $dest = $dirodt.
'/template_availabilitiess.odt';
503 if (file_exists($src) && !file_exists($dest)) {
504 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
506 $result =
dol_copy($src, $dest, 0, 0);
508 $langs->load(
"errors");
509 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
514 $sql = array_merge($sql, array(
515 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey).
"' AND type = '".$this->
db->escape(strtolower($myTmpObjectKey)).
"' AND entity = ".((
int) $conf->entity),
516 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey).
"', '".$this->
db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")",
517 "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),
518 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey).
"_odt', '".$this->
db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")"
523 return $this->
_init($sql, $options);
534 public function remove($options =
'')
537 return $this->
_remove($sql, $options);