28 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
47 $this->numero = 500000;
50 $this->rights_class =
'bookcal';
54 $this->family =
"projects";
57 $this->module_position =
'50';
62 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
67 $this->descriptionlong =
"BookCalDescription";
70 $this->version =
'development';
73 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
79 $this->picto =
'fa-generic';
82 $this->module_parts = array(
118 'moduleforexternal' => 0,
123 $this->dirs = array(
"/bookcal/temp");
126 $this->config_page_url = array(
"setup.php@bookcal");
130 $this->hidden =
false;
132 $this->depends = array();
133 $this->requiredby = array();
134 $this->conflictwith = array();
137 $this->langfiles = array(
"bookcal@bookcal");
140 $this->phpmin = array(7, 0);
143 $this->warnings_activation = array();
144 $this->warnings_activation_ext = array();
153 $this->
const = array();
161 if (!isset($conf->bookcal) || !isset($conf->bookcal->enabled)) {
162 $conf->bookcal =
new stdClass();
163 $conf->bookcal->enabled = 0;
167 $this->tabs = array();
195 $this->dictionaries = array();
224 $this->boxes = array(
235 $this->cronjobs = array(
257 $this->rights = array();
261 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
262 $this->rights[$r][1] =
'Read objects of BookCal';
263 $this->rights[$r][4] =
'availabilities';
264 $this->rights[$r][5] =
'read';
266 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
267 $this->rights[$r][1] =
'Create/Update objects of BookCal';
268 $this->rights[$r][4] =
'availabilities';
269 $this->rights[$r][5] =
'write';
271 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
272 $this->rights[$r][1] =
'Delete objects of BookCal';
273 $this->rights[$r][4] =
'availabilities';
274 $this->rights[$r][5] =
'delete';
279 $this->menu = array();
283 $this->menu[$r++] = array(
286 'titre'=>
'ModuleBookCalName',
287 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth valignmiddle"'),
288 'mainmenu'=>
'bookcal',
290 'url'=>
'/bookcal/bookcalindex.php',
291 'langs'=>
'bookcal@bookcal',
292 'position'=>1000 + $r,
293 'enabled'=>
'$conf->bookcal->enabled',
345 $this->menu[$r++]=array(
347 'fk_menu'=>
'fk_mainmenu=bookcal',
350 'titre'=>
'List Availabilities',
351 'mainmenu'=>
'bookcal',
352 'leftmenu'=>
'bookcal_availabilities',
353 'url'=>
'/bookcal/availabilities_list.php',
355 'langs'=>
'bookcal@bookcal',
358 'enabled'=>
'$conf->bookcal->enabled',
365 $this->menu[$r++]=array(
367 'fk_menu'=>
'fk_mainmenu=bookcal,fk_leftmenu=bookcal_availabilities',
370 'titre'=>
'New Availabilities',
371 'mainmenu'=>
'bookcal',
372 'leftmenu'=>
'bookcal_availabilities',
373 'url'=>
'/bookcal/availabilities_card.php?action=create',
375 'langs'=>
'bookcal@bookcal',
378 'enabled'=>
'$conf->bookcal->enabled',
462 public function init($options =
'')
464 global $conf, $langs;
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(".$version.") pid 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)
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.
$conf db
API class for accounts.