29require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/holiday.lib.php';
44$langs->loadLangs(array(
"admin",
"errors",
"holiday",
"other"));
50$action =
GETPOST(
'action',
'aZ09');
51$value =
GETPOST(
'value',
'alpha');
52$modulepart =
GETPOST(
'modulepart',
'aZ09');
54$label =
GETPOST(
'label',
'alpha');
55$scandir =
GETPOST(
'scan_dir',
'alpha');
59 $conf->global->HOLIDAY_ADDON =
'mod_holiday_madonna';
68include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
70if ($action ==
'updateMask') {
71 $maskconst =
GETPOST(
'maskconstholiday',
'aZ09');
72 $maskvalue =
GETPOST(
'maskholiday',
'alpha');
74 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
75 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
87} elseif ($action ==
'specimen') {
88 $modele =
GETPOST(
'module',
'alpha');
91 $holiday->initAsSpecimen();
96 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
97 foreach ($dirmodels as $reldir) {
98 $file =
dol_buildpath($reldir.
"core/modules/holiday/doc/pdf_".$modele.
".modules.php", 0);
99 if (file_exists($file)) {
100 $classname =
"pdf_".$modele;
105 if ($classname !==
'') {
108 $module =
new $classname($db);
109 '@phan-var-force ModelePDFHoliday $module';
111 if ($module->write_file($holiday, $langs) > 0) {
112 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=holiday&file=SPECIMEN.pdf");
120 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
122} elseif ($action ==
'set') {
125} elseif ($action ==
'del') {
132} elseif ($action ==
'setdoc') {
134 if (
dolibarr_set_const($db,
"HOLIDAY_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
137 $conf->global->HOLIDAY_ADDON_PDF = $value;
145} elseif ($action ==
'setmod') {
150} elseif ($action ==
'set_other') {
151 $freetext =
GETPOST(
'HOLIDAY_FREE_TEXT',
'restricthtml');
152 $res1 =
dolibarr_set_const($db,
"HOLIDAY_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
154 $draft =
GETPOST(
'HOLIDAY_DRAFT_WATERMARK',
'alpha');
155 $res2 =
dolibarr_set_const($db,
"HOLIDAY_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
157 if (!($res1 > 0) || !($res2 > 0)) {
173$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
175llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-holiday');
177$form =
new Form($db);
179$linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'restore_lastsearch_values' => 1]).
'">'.
img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
181print
load_fiche_titre($langs->trans(
"HolidaySetup"), $linkback,
'title_setup');
193print
'<div class="div-table-responsive-no-min">';
194print
'<table class="noborder centpercent">';
195print
'<tr class="liste_titre">';
196print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
197print
'<td>'.$langs->trans(
"Description").
'</td>';
198print
'<td>'.$langs->trans(
"Example").
'</td>';
199print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
200print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
205foreach ($dirmodels as $reldir) {
209 $handle = opendir($dir);
210 if (is_resource($handle)) {
211 while (($file = readdir($handle)) !==
false) {
212 if (substr($file, 0, 12) ==
'mod_holiday_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
213 $file = substr($file, 0,
dol_strlen($file) - 4);
215 require_once $dir.$file.
'.php';
217 $module =
new $file($db);
219 '@phan-var-force ModelNumRefHolidays $module';
222 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
225 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
229 if ($module->isEnabled()) {
230 print
'<tr class="oddeven"><td>'.$module->getName($langs).
"</td><td>\n";
231 print $module->info($langs);
235 print
'<td class="nowrap">';
236 $tmp = $module->getExample();
237 if (preg_match(
'/^Error/', $tmp)) {
238 $langs->load(
"errors");
239 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
240 } elseif ($tmp ==
'NotConfigured') {
241 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
247 print
'<td class="center">';
249 print
img_picto($langs->trans(
"Activated"),
'switch_on');
251 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
252 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
258 $holiday->initAsSpecimen();
262 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
263 $nextval = $module->getNextValue(
$mysoc, $holiday);
264 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
265 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
267 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
268 $nextval = $langs->trans($nextval);
270 $htmltooltip .= $nextval.
'<br>';
272 $htmltooltip .= $langs->trans($module->error).
'<br>';
276 print
'<td class="center">';
277 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
305 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
306 $sql .=
" WHERE type = '".$db->escape($type).
"'";
307 $sql .=
" AND entity = ".((int) $conf->entity);
308 $resql = $db->query($sql);
311 $num_rows = $db->num_rows($resql);
312 while ($i < $num_rows) {
313 $array = $db->fetch_array($resql);
314 if (is_array($array)) {
315 array_push($def, $array[0]);
324 print
'<div class="div-table-responsive-no-min">';
325 print
'<table class="noborder centpercent">';
326 print
'<tr class="liste_titre">';
327 print
'<td>'.$langs->trans(
"Name").
'</td>';
328 print
'<td>'.$langs->trans(
"Description").
'</td>';
329 print
'<td align="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
330 print
'<td align="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
331 print
'<td align="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
332 print
'<td align="center" width="80">'.$langs->trans(
"Preview").
'</td>';
337 foreach ($dirmodels as $reldir) {
338 foreach (array(
'',
'/doc') as $valdir) {
339 $realpath = $reldir.
"core/modules/holiday".$valdir;
343 $handle = opendir($dir);
344 if (is_resource($handle)) {
346 while (($file = readdir($handle)) !==
false) {
352 foreach ($filelist as $file) {
353 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
354 if (file_exists($dir.
'/'.$file)) {
355 $name = substr($file, 4,
dol_strlen($file) - 16);
356 $classname = substr($file, 0,
dol_strlen($file) - 12);
358 require_once $dir.
'/'.$file;
359 $module =
new $classname($db);
362 '@phan-var-force ModelePDFHoliday $module';
364 $modulequalified = 1;
365 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
366 $modulequalified = 0;
368 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
369 $modulequalified = 0;
372 if ($modulequalified) {
373 print
'<tr class="oddeven"><td width="100">';
374 print(empty($module->name) ? $name : $module->
name);
376 if (method_exists($module,
'info')) {
377 print $module->info($langs);
379 print $module->description;
384 if (in_array($name, $def)) {
385 print
'<td class="center">'.
"\n";
386 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
387 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
391 print
'<td class="center">'.
"\n";
392 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
397 print
'<td class="center">';
399 print
img_picto($langs->trans(
"Default"),
'on');
401 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
406 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
407 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
408 if ($module->type ==
'pdf') {
409 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
411 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
413 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
414 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
415 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
416 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
417 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
418 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
421 print
'<td class="center">';
422 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
426 print
'<td class="center">';
427 if ($module->type ==
'pdf') {
428 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
430 print
img_object($langs->transnoentitiesnoconv(
"PreviewNotAvailable"),
'generic');
456print
'<div class="urllink">';
457print
img_picto(
'',
'url',
'class="pictofixedwidth"').
' <a href="'.DOL_URL_ROOT.
'/admin/dict.php?id=28&search_country_id='.($conf->entity).
'">'.$langs->trans(
"ClickHereToGoToDictionary", $langs->transnoentitiesnoconv(
"Setup"), $langs->transnoentitiesnoconv(
"Dictionary"), $langs->transnoentitiesnoconv(
"LeaveType")).
'</a>';
469print
'<div class="urllink">';
470print
img_picto(
'',
'url',
'class="pictofixedwidth"').
' <a href="'.DOL_URL_ROOT.
'/admin/dict.php?id=32&search_country_id='.($conf->entity).
'">'.$langs->trans(
"ClickHereToGoToDictionary", $langs->transnoentitiesnoconv(
"Setup"), $langs->transnoentitiesnoconv(
"Dictionary"), $langs->transnoentitiesnoconv(
"DictionaryPublicHolidays")).
'</a>';
480print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
481print
'<input type="hidden" name="token" value="'.newToken().
'">';
482print
'<input type="hidden" name="action" value="set_other">';
486print
'<div class="div-table-responsive-no-min">';
487print
'<table class="noborder centpercent">';
488print
'<tr class="liste_titre">';
489print
'<td>'.$langs->trans(
"Parameter").
'</td>';
490print
'<td align="center" width="60"></td>';
494print
'<tr class="oddeven">';
495print
"<td>".$langs->trans(
"XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv(
"Monday")).
"</td>";
496print
'<td class="center">';
497if ($conf->use_javascript_ajax) {
498 print ajax_constantonoff(
'MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY', array(),
null, 0);
501 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_other&token='.
newToken().
'&MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY=1">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
503 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_other&token='.
newToken().
'&MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY=0">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
510print
'<tr class="oddeven">';
511print
"<td>".$langs->trans(
"XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv(
"Friday")).
"</td>";
512print
'<td class="center">';
513if ($conf->use_javascript_ajax) {
514 print ajax_constantonoff(
'MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY', array(),
null, 0);
517 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_other&token='.
newToken().
'&MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY=1">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
519 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_other&token='.
newToken().
'&MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY=0">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
526print
'<tr class="oddeven">';
527print
"<td>".$langs->trans(
"XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv(
"Saturday")).
"</td>";
528print
'<td class="center">';
529if ($conf->use_javascript_ajax) {
530 print ajax_constantonoff(
'MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', array(),
null, 0, 0, 0, 2, 0, 1);
533 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_other&token='.
newToken().
'&MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY=1">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
535 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_other&token='.
newToken().
'&MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY=0">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
542print
'<tr class="oddeven">';
543print
"<td>".$langs->trans(
"XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv(
"Sunday")).
"</td>";
544print
'<td class="center">';
545if ($conf->use_javascript_ajax) {
546 print ajax_constantonoff(
'MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', array(),
null, 0, 0, 0, 2, 0, 1);
549 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_other&token='.
newToken().
'&MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY=1">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
551 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_other&token='.
newToken().
'&MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY=0">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
558print
'<tr class="oddeven">';
559print
"<td>".$langs->trans(
"ConsumeHolidaysAtTheEndOfTheMonthTheyAreTakenAt").
' <span class="opacitymedium">('.$langs->trans(
"ConsumeHolidaysAtTheEndOfTheMonthTheyAreTakenAtBis").
')</span></td>';
560print
'<td class="center">';
561if ($conf->use_javascript_ajax) {
562 print ajax_constantonoff(
'HOLIDAY_DECREASE_AT_END_OF_MONTH', array(),
null, 0, 0, 0, 2, 0, 1);
565 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_other&token='.
newToken().
'&HOLIDAY_DECREASE_AT_END_OF_MONTH=1">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
567 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_other&token='.
newToken().
'&HOLIDAY_DECREASE_AT_END_OF_MONTH=0">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
575 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
576 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
577 foreach ($substitutionarray as $key => $val) {
578 $htmltext .= $key.
'<br>';
582 print
'<tr class="oddeven"><td colspan="2">';
583 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnHolidays"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'tooltiphelp');
585 $variablename =
'HOLIDAY_FREE_TEXT';
587 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
589 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
591 print $doleditor->Create();
593 print
'</td></tr>'.
"\n";
597 print
'<tr class="oddeven"><td>';
598 print $form->textwithpicto($langs->trans(
"WatermarkOnDraftHolidayCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
600 print
'<input class="flat minwidth200" type="text" name="HOLIDAY_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'HOLIDAY_DRAFT_WATERMARK')).
'">';
601 print
'</td></tr>'.
"\n";
607print $form->buttonsSaveCancel(
"Save",
'');
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
delDocumentModel($name, $type)
Delete document model used by doc generator.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage a WYSIWYG editor.
Class of the module paid holiday.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
holiday_admin_prepare_head()
Return array head with list of tabs to view object information.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
$conf db name
Only used if Module[ID]Name translation string is not found.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.