29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/holiday.lib.php';
45$langs->loadLangs(array(
"admin",
"errors",
"holiday"));
51$action =
GETPOST(
'action',
'aZ09');
52$value =
GETPOST(
'value',
'alpha');
53$modulepart =
GETPOST(
'modulepart',
'aZ09');
55$label =
GETPOST(
'label',
'alpha');
56$scandir =
GETPOST(
'scan_dir',
'alpha');
60 $conf->global->HOLIDAY_ADDON =
'mod_holiday_madonna';
69include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
71if ($action ==
'updateMask') {
72 $maskconst =
GETPOST(
'maskconstholiday',
'aZ09');
73 $maskvalue =
GETPOST(
'maskholiday',
'alpha');
75 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
88} elseif ($action ==
'specimen') {
89 $modele =
GETPOST(
'module',
'alpha');
92 $holiday->initAsSpecimen();
97 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
98 foreach ($dirmodels as $reldir) {
99 $file =
dol_buildpath($reldir.
"core/modules/holiday/doc/pdf_".$modele.
".modules.php", 0);
100 if (file_exists($file)) {
101 $classname =
"pdf_".$modele;
106 if ($classname !==
'') {
109 $module =
new $classname($db);
110 '@phan-var-force ModelePDFHoliday $module';
112 if ($module->write_file($holiday, $langs) > 0) {
113 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=holiday&file=SPECIMEN.pdf");
121 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
123} elseif ($action ==
'set') {
126} elseif ($action ==
'del') {
129 if (
$conf->global->HOLIDAY_ADDON_PDF ==
"$value") {
133} elseif ($action ==
'setdoc') {
138 $conf->global->HOLIDAY_ADDON_PDF = $value;
146} elseif ($action ==
'setmod') {
151} elseif ($action ==
'set_other') {
152 $freetext =
GETPOST(
'HOLIDAY_FREE_TEXT',
'restricthtml');
155 $draft =
GETPOST(
'HOLIDAY_DRAFT_WATERMARK',
'alpha');
158 if (!($res1 > 0) || !($res2 > 0)) {
174$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
176llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-holiday');
178$form =
new Form($db);
180$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php">'.$langs->trans(
"BackToModuleList").
'</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->name.
"</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">';
248 if (
$conf->global->HOLIDAY_ADDON ==
"$file") {
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, 0);
305 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
306 $sql .=
" WHERE type = '".$db->escape($type).
"'";
307 $sql .=
" AND entity = ".$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">';
398 if (
$conf->global->HOLIDAY_ADDON_PDF == $name) {
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, 0);
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->trans(
"PreviewNotAvailable"),
'generic');
454print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
455print
'<input type="hidden" name="token" value="'.newToken().
'">';
456print
'<input type="hidden" name="action" value="set_other">';
460print
'<div class="div-table-responsive-no-min">';
461print
'<table class="noborder centpercent">';
462print
'<tr class="liste_titre">';
463print
'<td>'.$langs->trans(
"Parameter").
'</td>';
464print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
472if (!isset(
$conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY)) {
473 $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY = 1;
475if (!isset(
$conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY)) {
476 $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY = 1;
486print
'<tr class="oddeven">';
487print
"<td>".$langs->trans(
"XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv(
"Monday")).
"</td>";
488print
'<td class="center">';
489if (
$conf->use_javascript_ajax) {
490 print ajax_constantonoff(
'MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY', array(),
null, 0);
493 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>';
495 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>';
502print
'<tr class="oddeven">';
503print
"<td>".$langs->trans(
"XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv(
"Friday")).
"</td>";
504print
'<td class="center">';
505if (
$conf->use_javascript_ajax) {
506 print ajax_constantonoff(
'MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY', array(),
null, 0);
509 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>';
511 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>';
518print
'<tr class="oddeven">';
519print
"<td>".$langs->trans(
"XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv(
"Saturday")).
"</td>";
520print
'<td class="center">';
521if (
$conf->use_javascript_ajax) {
522 print ajax_constantonoff(
'MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', array(),
null, 0, 0, 0, 2, 0, 1);
525 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>';
527 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>';
534print
'<tr class="oddeven">';
535print
"<td>".$langs->trans(
"XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv(
"Sunday")).
"</td>";
536print
'<td class="center">';
537if (
$conf->use_javascript_ajax) {
538 print ajax_constantonoff(
'MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', array(),
null, 0, 0, 0, 2, 0, 1);
541 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>';
543 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>';
550print
'<tr class="oddeven">';
551print
"<td>".$langs->trans(
"ConsumeHolidaysAtTheEndOfTheMonthTheyAreTakenAt").
"</td>";
552print
'<td class="center">';
553if (
$conf->use_javascript_ajax) {
554 print ajax_constantonoff(
'HOLIDAY_DECREASE_AT_END_OF_MONTH', array(),
null, 0, 0, 0, 2, 0, 1);
557 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>';
559 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>';
567 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
568 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
569 foreach ($substitutionarray as $key => $val) {
570 $htmltext .= $key.
'<br>';
574 print
'<tr class="oddeven"><td colspan="2">';
575 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnHolidays"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'tooltiphelp');
577 $variablename =
'HOLIDAY_FREE_TEXT';
579 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
581 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
583 print $doleditor->Create();
585 print
'</td></tr>'.
"\n";
589 print
'<tr class="oddeven"><td>';
590 print $form->textwithpicto($langs->trans(
"WatermarkOnDraftHolidayCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
592 print
'<input class="flat minwidth200" type="text" name="HOLIDAY_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'HOLIDAY_DRAFT_WATERMARK')).
'">';
593 print
'</td></tr>'.
"\n";
599print $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.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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)
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)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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...
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.