34require
'../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/expensereport.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
48$langs->loadLangs(array(
'admin',
'trips',
'other'));
54$action =
GETPOST(
'action',
'aZ09');
55$value =
GETPOST(
'value',
'alpha');
56$modulepart =
GETPOST(
'modulepart',
'aZ09');
58$label =
GETPOST(
'label',
'alpha');
59$scandir =
GETPOST(
'scan_dir',
'alpha');
60$type =
'expensereport';
68include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
70if ($action ==
'updateMask') {
71 $maskconst =
GETPOST(
'maskconst',
'aZ09');
72 $maskvalue =
GETPOST(
'maskvalue',
'alpha');
76 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
85 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
87 setEventMessages($langs->trans(
"Error"),
null,
'errors');
89} elseif ($action ==
'specimen') {
90 $modele =
GETPOST(
'module',
'alpha');
93 $expensespecimen->initAsSpecimen();
94 $expensespecimen->status = 0;
99 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
100 foreach ($dirmodels as $reldir) {
101 $file =
dol_buildpath($reldir.
"core/modules/expensereport/doc/pdf_".$modele.
".modules.php", 0);
102 if (file_exists($file)) {
103 $classname =
"pdf_".$modele;
108 if ($classname !==
'') {
112 '@phan-var-force ModeleExpenseReport $module';
114 if (
$module->write_file($expensespecimen, $langs) > 0) {
115 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=expensereport&file=SPECIMEN.pdf");
122 $langs->load(
'errors');
123 setEventMessages($langs->trans(
"ErrorModuleNotFound"),
null,
'errors');
124 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
126} elseif ($action ==
'set') {
132} elseif ($action ==
'del') {
139} elseif ($action ==
'setdoc') {
144 $conf->global->EXPENSEREPORT_ADDON_PDF = $value;
152} elseif ($action ==
'setmod') {
157} elseif ($action ==
'setoptions') {
160 $freetext =
GETPOST(
'EXPENSEREPORT_FREE_TEXT',
'restricthtml');
163 $draft =
GETPOST(
'EXPENSEREPORT_DRAFT_WATERMARK',
'alpha');
164 $res2 =
dolibarr_set_const($db,
"EXPENSEREPORT_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'',
$conf->entity);
171 $dates =
GETPOSTINT(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH');
172 $res4 =
dolibarr_set_const($db,
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH', intval($dates),
'chaine', 0,
'',
$conf->entity);
174 $amounts =
GETPOSTINT(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY');
175 $res5 =
dolibarr_set_const($db,
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY', intval($amounts),
'chaine', 0,
'',
$conf->entity);
177 $linesblocked =
GETPOSTINT(
'EXPENSEREPORT_BLOCK_LINE_CREATION_IF_NOT_BETWEEN_DATES');
178 $res6 =
dolibarr_set_const($db,
'EXPENSEREPORT_BLOCK_LINE_CREATION_IF_NOT_BETWEEN_DATES', intval($linesblocked),
'chaine', 0,
'',
$conf->entity);
180 if (!($res1 > 0) || !($res2 > 0) || !($res3 >= 0) || !($res4 > 0) || !($res5 > 0) || !($res6 > 0)) {
186 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
189 setEventMessages($langs->trans(
"Error"),
null,
'errors');
198$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
200llxHeader(
'', $langs->trans(
"ExpenseReportsSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-expensereport');
202$form =
new Form($db);
204$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>';
206print
load_fiche_titre($langs->trans(
"ExpenseReportsSetup"), $linkback,
'title_setup');
211print
dol_get_fiche_head($head,
'expensereport', $langs->trans(
"ExpenseReports"), -1,
'trip');
217print
load_fiche_titre($langs->trans(
"ExpenseReportNumberingModules"),
'',
'');
219print
'<div class="div-table-responsive-no-min">';
220print
'<table class="noborder centpercent">';
221print
'<tr class="liste_titre">';
222print
'<td>'.$langs->trans(
"Name").
'</td>';
223print
'<td>'.$langs->trans(
"Description").
'</td>';
224print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
225print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
226print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
231foreach ($dirmodels as $reldir) {
235 $handle = opendir($dir);
236 if (is_resource($handle)) {
237 while (($file = readdir($handle)) !==
false) {
241 require_once $dir.$file.
'.php';
245 '@phan-var-force ModeleNumRefExpenseReport $module';
256 print
'<tr class="oddeven"><td>'.$module->getName($langs).
"</td><td>\n";
261 print
'<td class="nowrap">';
263 if (preg_match(
'/^Error/', $tmp)) {
264 $langs->load(
"errors");
265 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
266 } elseif ($tmp ==
'NotConfigured') {
267 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
273 print
'<td class="center">';
275 print img_picto($langs->trans(
"Activated"),
'switch_on');
277 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
278 print img_picto($langs->trans(
"Disabled"),
'switch_off');
284 $exp->initAsSpecimen();
288 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.
$module->getVersion().
'</b><br>';
289 $nextval =
$module->getNextValue($exp);
290 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
291 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
293 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
294 $langs->load(
'errors');
295 $nextval = $langs->trans($nextval);
297 $htmltooltip .= $nextval.
'<br>';
299 $langs->load(
'errors');
300 $htmltooltip .= $langs->trans(
$module->error).
'<br>';
304 print
'<td class="center">';
305 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
316print
"</table></div><br>\n";
322printDocumentModelList(
'expensereport',
'expensereport',
'EXPENSEREPORT_ADDON_PDF', $langs->trans(
"TemplatePDFExpenseReports"), array(
323 'Logo' =>
'option_logo',
324 'PaymentMode' =>
'option_modereg',
325 'PaymentConditions' =>
'option_condreg',
326 'MultiLanguage' =>
'option_multilang',
327 'WatermarkOnDraftOrders' =>
'option_draft_watermark',
338print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" spellcheck="false">';
339print
'<input type="hidden" name="token" value="'.newToken().
'">';
340print
'<input type="hidden" name="action" value="setoptions">';
344print
'<div class="div-table-responsive-no-min">';
345print
'<table class="noborder centpercent">';
346print
'<tr class="liste_titre">';
347print
'<td>'.$langs->trans(
"Parameter").
'</td>';
348print
'<td class="center" width="60"></td>';
352$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
353$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
354foreach ($substitutionarray as $key => $val) {
355 $htmltext .= $key.
'<br>';
359print
'<tr class="oddeven"><td colspan="2">';
360print $form->textwithpicto($langs->trans(
"FreeLegalTextOnExpenseReports"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
361$variablename =
'EXPENSEREPORT_FREE_TEXT';
363 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
365 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
367 print $doleditor->Create();
369print
'</td></tr>'.
"\n";
373print
'<tr class="oddeven"><td colspan="2">';
374print $form->textwithpicto($langs->trans(
"WatermarkOnDraftExpenseReports"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
375print
'<input class="flat minwidth200" type="text" name="EXPENSEREPORT_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'EXPENSEREPORT_DRAFT_WATERMARK')).
'">';
376print
'</td></tr>'.
"\n";
379 print
'<tr class="oddeven"><td>';
380 print $langs->trans(
'ProjectIsRequiredOnExpenseReports');
381 print
'</td><td class="right">';
382 print $form->selectyesno(
'EXPENSEREPORT_PROJECT_IS_REQUIRED',
getDolGlobalString(
'EXPENSEREPORT_PROJECT_IS_REQUIRED') ? 1 : 0, 1);
386print
'<tr class="oddeven"><td>';
387print $langs->trans(
'PrefillExpenseReportDatesWithCurrentMonth');
388print
'</td><td class="right">';
389print $form->selectyesno(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH',
getDolGlobalString(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH') ? 1 : 0, 1);
392print
'<tr class="oddeven"><td>';
393print $langs->trans(
'ForceExpenseReportsLineAmountsIncludingTaxesOnly');
394print
'</td><td class="right">';
395print $form->selectyesno(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY',
getDolGlobalString(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY') ? 1 : 0, 1);
398print
'<tr class="oddeven"><td>';
399print $langs->trans(
'BlockExpenseReportLineCreationIfNotBetweenDates');
400print
'</td><td class="right">';
401print $form->selectyesno(
'EXPENSEREPORT_BLOCK_LINE_CREATION_IF_NOT_BETWEEN_DATES',
getDolGlobalString(
'EXPENSEREPORT_BLOCK_LINE_CREATION_IF_NOT_BETWEEN_DATES') ? 1 : 0, 1);
407print $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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage a WYSIWYG editor.
Class to manage Trips and Expenses.
if(! $sortfield) if(! $sortorder) $module
expensereport_admin_prepare_head()
Return array head with list of tabs to view object information.
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
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'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.