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',
'errors',
'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 setEventMessages($langs->trans(
"ErrorModuleNotFound"),
null,
'errors');
123 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
125} elseif ($action ==
'set') {
131} elseif ($action ==
'del') {
138} elseif ($action ==
'setdoc') {
143 $conf->global->EXPENSEREPORT_ADDON_PDF = $value;
151} elseif ($action ==
'setmod') {
156} elseif ($action ==
'setoptions') {
159 $freetext =
GETPOST(
'EXPENSEREPORT_FREE_TEXT',
'restricthtml');
162 $draft =
GETPOST(
'EXPENSEREPORT_DRAFT_WATERMARK',
'alpha');
163 $res2 =
dolibarr_set_const($db,
"EXPENSEREPORT_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'',
$conf->entity);
170 $dates =
GETPOSTINT(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH');
171 $res4 =
dolibarr_set_const($db,
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH', intval($dates),
'chaine', 0,
'',
$conf->entity);
173 $amounts =
GETPOSTINT(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY');
174 $res5 =
dolibarr_set_const($db,
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY', intval($amounts),
'chaine', 0,
'',
$conf->entity);
176 $linesblocked =
GETPOSTINT(
'EXPENSEREPORT_BLOCK_LINE_CREATION_IF_NOT_BETWEEN_DATES');
177 $res6 =
dolibarr_set_const($db,
'EXPENSEREPORT_BLOCK_LINE_CREATION_IF_NOT_BETWEEN_DATES', intval($linesblocked),
'chaine', 0,
'',
$conf->entity);
179 if (!($res1 > 0) || !($res2 > 0) || !($res3 >= 0) || !($res4 > 0) || !($res5 > 0) || !($res6 > 0)) {
185 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
188 setEventMessages($langs->trans(
"Error"),
null,
'errors');
197$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
199llxHeader(
'', $langs->trans(
"ExpenseReportsSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-expensereport');
201$form =
new Form($db);
203$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>';
205print
load_fiche_titre($langs->trans(
"ExpenseReportsSetup"), $linkback,
'title_setup');
210print
dol_get_fiche_head($head,
'expensereport', $langs->trans(
"ExpenseReports"), -1,
'trip');
216print
load_fiche_titre($langs->trans(
"ExpenseReportNumberingModules"),
'',
'');
218print
'<div class="div-table-responsive-no-min">';
219print
'<table class="noborder centpercent">';
220print
'<tr class="liste_titre">';
221print
'<td>'.$langs->trans(
"Name").
'</td>';
222print
'<td>'.$langs->trans(
"Description").
'</td>';
223print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
224print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
225print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
230foreach ($dirmodels as $reldir) {
234 $handle = opendir($dir);
235 if (is_resource($handle)) {
236 while (($file = readdir($handle)) !==
false) {
240 require_once $dir.$file.
'.php';
244 '@phan-var-force ModeleNumRefExpenseReport $module';
255 print
'<tr class="oddeven"><td>'.$module->getName($langs).
"</td><td>\n";
260 print
'<td class="nowrap">';
262 if (preg_match(
'/^Error/', $tmp)) {
263 $langs->load(
"errors");
264 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
265 } elseif ($tmp ==
'NotConfigured') {
266 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
272 print
'<td class="center">';
274 print img_picto($langs->trans(
"Activated"),
'switch_on');
276 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
277 print img_picto($langs->trans(
"Disabled"),
'switch_off');
283 $exp->initAsSpecimen();
287 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.
$module->getVersion().
'</b><br>';
288 $nextval =
$module->getNextValue($exp);
289 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
290 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
292 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
293 $nextval = $langs->trans($nextval);
295 $htmltooltip .= $nextval.
'<br>';
297 $htmltooltip .= $langs->trans(
$module->error).
'<br>';
301 print
'<td class="center">';
302 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
313print
"</table></div><br>\n";
319printDocumentModelList(
'expensereport',
'expensereport',
'EXPENSEREPORT_ADDON_PDF', $langs->trans(
"TemplatePDFExpenseReports"), array(
320 'Logo' =>
'option_logo',
321 'PaymentMode' =>
'option_modereg',
322 'PaymentConditions' =>
'option_condreg',
323 'MultiLanguage' =>
'option_multilang',
324 'WatermarkOnDraftOrders' =>
'option_draft_watermark',
335print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post" spellcheck="false">';
336print
'<input type="hidden" name="token" value="'.newToken().
'">';
337print
'<input type="hidden" name="action" value="setoptions">';
341print
'<div class="div-table-responsive-no-min">';
342print
'<table class="noborder centpercent">';
343print
'<tr class="liste_titre">';
344print
'<td>'.$langs->trans(
"Parameter").
'</td>';
345print
'<td class="center" width="60"></td>';
349$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
350$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
351foreach ($substitutionarray as $key => $val) {
352 $htmltext .= $key.
'<br>';
356print
'<tr class="oddeven"><td colspan="2">';
357print $form->textwithpicto($langs->trans(
"FreeLegalTextOnExpenseReports"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
358$variablename =
'EXPENSEREPORT_FREE_TEXT';
360 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
362 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
364 print $doleditor->Create();
366print
'</td></tr>'.
"\n";
370print
'<tr class="oddeven"><td colspan="2">';
371print $form->textwithpicto($langs->trans(
"WatermarkOnDraftExpenseReports"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
372print
'<input class="flat minwidth200" type="text" name="EXPENSEREPORT_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'EXPENSEREPORT_DRAFT_WATERMARK')).
'">';
373print
'</td></tr>'.
"\n";
376 print
'<tr class="oddeven"><td>';
377 print $langs->trans(
'ProjectIsRequiredOnExpenseReports');
378 print
'</td><td class="right">';
379 print $form->selectyesno(
'EXPENSEREPORT_PROJECT_IS_REQUIRED',
getDolGlobalString(
'EXPENSEREPORT_PROJECT_IS_REQUIRED') ? 1 : 0, 1);
383print
'<tr class="oddeven"><td>';
384print $langs->trans(
'PrefillExpenseReportDatesWithCurrentMonth');
385print
'</td><td class="right">';
386print $form->selectyesno(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH',
getDolGlobalString(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH') ? 1 : 0, 1);
389print
'<tr class="oddeven"><td>';
390print $langs->trans(
'ForceExpenseReportsLineAmountsIncludingTaxesOnly');
391print
'</td><td class="right">';
392print $form->selectyesno(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY',
getDolGlobalString(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY') ? 1 : 0, 1);
395print
'<tr class="oddeven"><td>';
396print $langs->trans(
'BlockExpenseReportLineCreationIfNotBetweenDates');
397print
'</td><td class="right">';
398print $form->selectyesno(
'EXPENSEREPORT_BLOCK_LINE_CREATION_IF_NOT_BETWEEN_DATES',
getDolGlobalString(
'EXPENSEREPORT_BLOCK_LINE_CREATION_IF_NOT_BETWEEN_DATES') ? 1 : 0, 1);
404print $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 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')
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.