27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/holiday.lib.php';
34 $langs->loadLangs(array(
"admin",
"errors",
"holiday"));
38 $action =
GETPOST(
'action',
'aZ09');
39 $value =
GETPOST(
'value',
'alpha');
40 $label =
GETPOST(
'label',
'alpha');
41 $scandir =
GETPOST(
'scan_dir',
'alpha');
44 if (empty($conf->global->HOLIDAY_ADDON))
46 $conf->global->HOLIDAY_ADDON =
'mod_holiday_madonna';
54 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
56 if ($action ==
'updateMask')
58 $maskconst =
GETPOST(
'maskconstholiday',
'alpha');
59 $maskvalue =
GETPOST(
'maskholiday',
'alpha');
60 if ($maskconst) $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
62 if (!($res > 0)) $error++;
70 } elseif ($action ==
'specimen')
72 $modele =
GETPOST(
'module',
'alpha');
75 $holiday->initAsSpecimen();
78 $file =
''; $classname =
''; $filefound = 0;
79 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
80 foreach ($dirmodels as $reldir)
82 $file =
dol_buildpath($reldir.
"core/modules/holiday/doc/pdf_".$modele.
".modules.php", 0);
83 if (file_exists($file))
86 $classname =
"pdf_".$modele;
95 $module =
new $classname($db);
97 if ($module->write_file($holiday, $langs) > 0)
99 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=holiday&file=SPECIMEN.pdf");
107 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
112 elseif ($action ==
'set')
115 } elseif ($action ==
'del')
120 if ($conf->global->HOLIDAY_ADDON_PDF ==
"$value")
dolibarr_del_const($db,
'HOLIDAY_ADDON_PDF', $conf->entity);
125 elseif ($action ==
'setdoc')
127 if (
dolibarr_set_const($db,
"HOLIDAY_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity))
131 $conf->global->HOLIDAY_ADDON_PDF = $value;
140 } elseif ($action ==
'setmod')
146 } elseif ($action ==
'set_other')
148 $freetext =
GETPOST(
'HOLIDAY_FREE_TEXT',
'restricthtml');
149 $res1 =
dolibarr_set_const($db,
"HOLIDAY_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
151 $draft =
GETPOST(
'HOLIDAY_DRAFT_WATERMARK',
'alpha');
152 $res2 =
dolibarr_set_const($db,
"HOLIDAY_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
154 if (!$res1 > 0 || !$res2 > 0) $error++;
169 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
173 $form =
new Form($db);
175 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php">'.$langs->trans(
"BackToModuleList").
'</a>';
188 print '<div class="div-table-responsive-no-min">';
189 print
'<table class="noborder centpercent">';
190 print
'<tr class="liste_titre">';
191 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
192 print
'<td>'.$langs->trans(
"Description").
'</td>';
193 print
'<td>'.$langs->trans(
"Example").
'</td>';
194 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
195 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
200 foreach ($dirmodels as $reldir)
206 $handle = opendir($dir);
207 if (is_resource($handle))
209 while (($file = readdir($handle)) !==
false)
211 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);
220 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
221 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
223 if ($module->isEnabled())
225 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
226 print $module->info();
230 print
'<td class="nowrap">';
231 $tmp = $module->getExample();
232 if (preg_match(
'/^Error/', $tmp)) {
233 $langs->load(
"errors");
234 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
235 } elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
239 print '<td class="center">';
240 if ($conf->global->HOLIDAY_ADDON == "$file")
242 print
img_picto($langs->trans(
"Activated"),
'switch_on');
244 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
245 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
251 $holiday->initAsSpecimen();
255 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
256 $nextval = $module->getNextValue($mysoc, $holiday);
257 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
258 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
260 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
261 $nextval = $langs->trans($nextval);
262 $htmltooltip .= $nextval.
'<br>';
264 $htmltooltip .= $langs->trans($module->error).
'<br>';
268 print
'<td class="center">';
269 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
287 if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
304 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
305 $sql .=
" WHERE type = '".$db->escape($type).
"'";
306 $sql .=
" AND entity = ".$conf->entity;
307 $resql = $db->query($sql);
311 $num_rows = $db->num_rows(
$resql);
312 while ($i < $num_rows)
314 $array = $db->fetch_array(
$resql);
315 array_push($def, $array[0]);
323 print
'<div class="div-table-responsive-no-min">';
324 print
'<table class="noborder centpercent">';
325 print
'<tr class="liste_titre">';
326 print
'<td>'.$langs->trans(
"Name").
'</td>';
327 print
'<td>'.$langs->trans(
"Description").
'</td>';
328 print
'<td align="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
329 print
'<td align="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
330 print
'<td align="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
331 print
'<td align="center" width="80">'.$langs->trans(
"Preview").
'</td>';
336 foreach ($dirmodels as $reldir)
338 foreach (array(
'',
'/doc') as $valdir)
340 $realpath = $reldir.
"core/modules/holiday".$valdir;
345 $handle = opendir($dir);
346 if (is_resource($handle))
348 while (($file = readdir($handle)) !==
false)
355 foreach ($filelist as $file)
357 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file))
359 if (file_exists($dir.
'/'.$file))
361 $name = substr($file, 4,
dol_strlen($file) - 16);
362 $classname = substr($file, 0,
dol_strlen($file) - 12);
364 require_once $dir.
'/'.$file;
365 $module =
new $classname($db);
367 $modulequalified = 1;
368 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
369 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
371 if ($modulequalified)
373 print
'<tr class="oddeven"><td width="100">';
374 print (empty($module->name) ? $name : $module->name);
376 if (method_exists($module,
'info')) print $module->info($langs);
377 else print $module->description;
381 if (in_array($name, $def))
383 print
'<td class="center">'.
"\n";
384 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.$name.
'">';
385 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
389 print
'<td class="center">'.
"\n";
390 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
395 print
'<td class="center">';
396 if ($conf->global->HOLIDAY_ADDON_PDF == $name)
398 print
img_picto($langs->trans(
"Default"),
'on');
400 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
405 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
406 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
407 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')
429 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
431 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
454 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
455 print
'<input type="hidden" name="token" value="'.newToken().
'">';
456 print
'<input type="hidden" name="action" value="set_other">';
460 print
'<div class="div-table-responsive-no-min">';
461 print
'<table class="noborder centpercent">';
462 print
'<tr class="liste_titre">';
463 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
464 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
468 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
469 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
470 foreach ($substitutionarray as $key => $val) $htmltext .= $key.
'<br>';
473 print
'<tr class="oddeven"><td colspan="2">';
474 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnHolidays"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'tooltiphelp');
476 $variablename =
'HOLIDAY_FREE_TEXT';
477 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
479 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.$conf->global->$variablename.
'</textarea>';
481 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
482 $doleditor =
new DolEditor($variablename, $conf->global->$variablename,
'', 80,
'dolibarr_notes');
483 print $doleditor->Create();
485 print
'</td></tr>'.
"\n";
489 print
'<tr class="oddeven"><td>';
490 print $form->textwithpicto($langs->trans(
"WatermarkOnDraftHolidayCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
492 print
'<input size="50" class="flat" type="text" name="HOLIDAY_DRAFT_WATERMARK" value="'.$conf->global->HOLIDAY_DRAFT_WATERMARK.
'">';
493 print
'</td></tr>'.
"\n";
499 print
'<div class="center">';
500 print
'<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
delDocumentModel($name, $type)
Delete document model used by doc generator.
Class of the module paid holiday.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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).
addDocumentModel($name, $type, $label= '', $description= '')
Add document model used by doc generator.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Class to manage a WYSIWYG editor.
holiday_admin_prepare_head()
Return array head with list of tabs to view object informations.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.