32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/expensereport.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
39$langs->loadLangs(array(
'admin',
'errors',
'trips',
'other'));
45$action =
GETPOST(
'action',
'aZ09');
46$value =
GETPOST(
'value',
'alpha');
47$modulepart =
GETPOST(
'modulepart',
'aZ09');
49$label =
GETPOST(
'label',
'alpha');
50$scandir =
GETPOST(
'scan_dir',
'alpha');
51$type =
'expensereport';
58include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
60if ($action ==
'updateMask') {
61 $maskconst =
GETPOST(
'maskconst',
'aZ09');
62 $maskvalue =
GETPOST(
'maskvalue',
'alpha');
63 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
64 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
76} elseif ($action ==
'specimen') {
77 $modele =
GETPOST(
'module',
'alpha');
80 $expensespecimen->initAsSpecimen();
81 $expensespecimen->status = 0;
84 $file =
''; $classname =
''; $filefound = 0;
85 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
86 foreach ($dirmodels as $reldir) {
87 $file =
dol_buildpath($reldir.
"core/modules/expensereport/doc/pdf_".$modele.
".modules.php", 0);
88 if (file_exists($file)) {
90 $classname =
"pdf_".$modele;
98 $module =
new $classname($db);
100 if ($module->write_file($expensespecimen, $langs) > 0) {
101 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=expensereport&file=SPECIMEN.pdf");
109 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
111} elseif ($action ==
'set') {
114 if ($ret > 0 && empty($conf->global->EXPENSEREPORT_ADDON_PDF)) {
115 dolibarr_set_const($db,
'EXPENSEREPORT_ADDON_PDF', $value,
'chaine', 0,
'', $conf->entity);
117} elseif ($action ==
'del') {
120 if ($conf->global->EXPENSEREPORT_ADDON_PDF ==
"$value") {
124} elseif ($action ==
'setdoc') {
126 if (
dolibarr_set_const($db,
"EXPENSEREPORT_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
129 $conf->global->EXPENSEREPORT_ADDON_PDF = $value;
137} elseif ($action ==
'setmod') {
141 dolibarr_set_const($db,
"EXPENSEREPORT_ADDON", $value,
'chaine', 0,
'', $conf->entity);
142} elseif ($action ==
'setoptions') {
145 $freetext =
GETPOST(
'EXPENSEREPORT_FREE_TEXT',
'restricthtml');
146 $res1 =
dolibarr_set_const($db,
"EXPENSEREPORT_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
148 $draft =
GETPOST(
'EXPENSEREPORT_DRAFT_WATERMARK',
'alpha');
149 $res2 =
dolibarr_set_const($db,
"EXPENSEREPORT_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
152 if (isModEnabled(
'project') && GETPOSTISSET(
'EXPENSEREPORT_PROJECT_IS_REQUIRED')) {
153 $res3 =
dolibarr_set_const($db,
'EXPENSEREPORT_PROJECT_IS_REQUIRED',
GETPOST(
'EXPENSEREPORT_PROJECT_IS_REQUIRED',
'int'),
'chaine', 0,
'', $conf->entity);
156 $dates =
GETPOST(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH',
'int');
157 $res4 =
dolibarr_set_const($db,
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH', intval($dates),
'chaine', 0,
'', $conf->entity);
159 $amounts =
GETPOST(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY',
'int');
160 $res5 =
dolibarr_set_const($db,
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY', intval($amounts),
'chaine', 0,
'', $conf->entity);
162 if (!($res1 > 0) || !($res2 > 0) || !($res3 >= 0) || !($res4 >0) || !($res5 >0)) {
180$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
182llxHeader(
'', $langs->trans(
"ExpenseReportsSetup"));
184$form =
new Form($db);
186$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
187print
load_fiche_titre($langs->trans(
"ExpenseReportsSetup"), $linkback,
'title_setup');
192print
dol_get_fiche_head($head,
'expensereport', $langs->trans(
"ExpenseReports"), -1,
'trip');
198print
load_fiche_titre($langs->trans(
"ExpenseReportNumberingModules"),
'',
'');
200print
'<table class="noborder centpercent">';
201print
'<tr class="liste_titre">';
202print
'<td>'.$langs->trans(
"Name").
'</td>';
203print
'<td>'.$langs->trans(
"Description").
'</td>';
204print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
205print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
206print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
211foreach ($dirmodels as $reldir) {
215 $handle = opendir($dir);
216 if (is_resource($handle)) {
217 while (($file = readdir($handle)) !==
false) {
218 if (substr($file, 0, 18) ==
'mod_expensereport_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
219 $file = substr($file, 0,
dol_strlen($file) - 4);
221 require_once $dir.$file.
'.php';
223 $module =
new $file($db);
226 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
229 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
233 if ($module->isEnabled()) {
234 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
235 print $module->info();
239 print
'<td class="nowrap">';
240 $tmp = $module->getExample();
241 if (preg_match(
'/^Error/', $tmp)) {
242 $langs->load(
"errors");
243 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
244 } elseif ($tmp ==
'NotConfigured') {
245 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
251 print
'<td class="center">';
252 if ($conf->global->EXPENSEREPORT_ADDON == $file) {
253 print
img_picto($langs->trans(
"Activated"),
'switch_on');
255 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&value='.urlencode($file).
'">';
256 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
262 $exp->initAsSpecimen();
266 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
267 $nextval = $module->getNextValue($exp);
268 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
269 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
271 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
272 $nextval = $langs->trans($nextval);
274 $htmltooltip .= $nextval.
'<br>';
276 $htmltooltip .= $langs->trans($module->error).
'<br>';
280 print
'<td class="center">';
281 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
292print
"</table><br>\n";
301$type =
'expensereport';
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);
310 $num_rows = $db->num_rows($resql);
311 while ($i < $num_rows) {
312 $array = $db->fetch_array($resql);
313 array_push($def, $array[0]);
320print
'<table class="noborder centpercent">';
321print
'<tr class="liste_titre">';
322print
'<td>'.$langs->trans(
"Name").
'</td>';
323print
'<td>'.$langs->trans(
"Description").
'</td>';
324print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
325print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
326print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
327print
'<td class="center" width="80">'.$langs->trans(
"Preview").
'</td>';
332foreach ($dirmodels as $reldir) {
333 $dir =
dol_buildpath($reldir.
"core/modules/expensereport/doc");
336 $handle = opendir($dir);
337 if (is_resource($handle)) {
338 while (($file = readdir($handle)) !==
false) {
344 foreach ($filelist as $file) {
345 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
346 if (file_exists($dir.
'/'.$file)) {
347 $name = substr($file, 4,
dol_strlen($file) - 16);
348 $classname = substr($file, 0,
dol_strlen($file) - 12);
350 require_once $dir.
'/'.$file;
351 $module =
new $classname($db);
353 $modulequalified = 1;
354 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
355 $modulequalified = 0;
357 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
358 $modulequalified = 0;
361 if ($modulequalified) {
362 print
'<tr class="oddeven"><td width="100">';
363 print (empty($module->name) ? $name : $module->
name);
365 if (method_exists($module,
'info')) {
366 print $module->info($langs);
368 print $module->description;
373 if (in_array($name, $def)) {
374 print
'<td class="center">'.
"\n";
375 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">';
376 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
380 print
'<td class="center">'.
"\n";
381 print
'<a 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>';
386 print
'<td class="center">';
387 if ($conf->global->EXPENSEREPORT_ADDON_PDF ==
"$name") {
388 print
img_picto($langs->trans(
"Default"),
'on');
390 print
'<a 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>';
395 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
396 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
397 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
398 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
399 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
400 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
401 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
402 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
403 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
404 print
'<td class="center">';
405 print $form->textwithpicto(
'', $htmltooltip, -1, 0);
409 print
'<td class="center">';
410 if ($module->type ==
'pdf') {
411 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
413 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
437print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
438print
'<input type="hidden" name="token" value="'.newToken().
'">';
439print
'<input type="hidden" name="action" value="setoptions">';
442print
'<table class="noborder centpercent">';
443print
'<tr class="liste_titre">';
444print
'<td>'.$langs->trans(
"Parameter").
'</td>';
445print
'<td class="center" width="60"></td>';
449$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
450$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
451foreach ($substitutionarray as $key => $val) {
452 $htmltext .= $key.
'<br>';
456print
'<tr class="oddeven"><td colspan="2">';
457print $form->textwithpicto($langs->trans(
"FreeLegalTextOnExpenseReports"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
458$variablename =
'EXPENSEREPORT_FREE_TEXT';
459if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
460 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
462 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
464 print $doleditor->Create();
466print
'</td></tr>'.
"\n";
470print
'<tr class="oddeven"><td colspan="2">';
471print $form->textwithpicto($langs->trans(
"WatermarkOnDraftExpenseReports"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
472print
'<input class="flat minwidth200" type="text" name="EXPENSEREPORT_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'EXPENSEREPORT_DRAFT_WATERMARK')).
'">';
473print
'</td></tr>'.
"\n";
475if (isModEnabled(
'project')) {
476 print
'<tr class="oddeven"><td>';
477 print $langs->trans(
'ProjectIsRequiredOnExpenseReports');
478 print
'</td><td class="right">';
479 print $form->selectyesno(
'EXPENSEREPORT_PROJECT_IS_REQUIRED', empty($conf->global->EXPENSEREPORT_PROJECT_IS_REQUIRED) ? 0 : 1, 1);
483print
'<tr class="oddeven"><td>';
484print $langs->trans(
'PrefillExpenseReportDatesWithCurrentMonth');
485print
'</td><td class="right">';
486print $form->selectyesno(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH', empty($conf->global->EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH) ? 0 : 1, 1);
489print
'<tr class="oddeven"><td>';
490print $langs->trans(
'ForceExpenseReportsLineAmountsIncludingTaxesOnly');
491print
'</td><td class="right">';
492print $form->selectyesno(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY', empty($conf->global->EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY) ? 0 : 1, 1);
497print $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()
Empty header.
Class to manage a WYSIWYG editor.
Class to manage Trips and Expenses.
expensereport_admin_prepare_head()
Return array head with list of tabs to view object informations.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.