34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/expensereport.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
49$langs->loadLangs(array(
'admin',
'errors',
'trips',
'other'));
55$action =
GETPOST(
'action',
'aZ09');
56$value =
GETPOST(
'value',
'alpha');
57$modulepart =
GETPOST(
'modulepart',
'aZ09');
59$label =
GETPOST(
'label',
'alpha');
60$scandir =
GETPOST(
'scan_dir',
'alpha');
61$type =
'expensereport';
69include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
71if ($action ==
'updateMask') {
72 $maskconst =
GETPOST(
'maskconst',
'aZ09');
73 $maskvalue =
GETPOST(
'maskvalue',
'alpha');
77 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
90} elseif ($action ==
'specimen') {
91 $modele =
GETPOST(
'module',
'alpha');
94 $expensespecimen->initAsSpecimen();
95 $expensespecimen->status = 0;
100 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
101 foreach ($dirmodels as $reldir) {
102 $file =
dol_buildpath($reldir.
"core/modules/expensereport/doc/pdf_".$modele.
".modules.php", 0);
103 if (file_exists($file)) {
104 $classname =
"pdf_".$modele;
109 if ($classname !==
'') {
112 $module =
new $classname($db);
113 '@phan-var-force ModeleExpenseReport $module';
115 if ($module->write_file($expensespecimen, $langs) > 0) {
116 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=expensereport&file=SPECIMEN.pdf");
124 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
126} elseif ($action ==
'set') {
132} elseif ($action ==
'del') {
135 if (
$conf->global->EXPENSEREPORT_ADDON_PDF ==
"$value") {
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);
167 if (isModEnabled(
'project') && GETPOSTISSET(
'EXPENSEREPORT_PROJECT_IS_REQUIRED')) {
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)) {
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="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</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
'<table class="noborder centpercent">';
219print
'<tr class="liste_titre">';
220print
'<td>'.$langs->trans(
"Name").
'</td>';
221print
'<td>'.$langs->trans(
"Description").
'</td>';
222print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
223print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
224print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
229foreach ($dirmodels as $reldir) {
233 $handle = opendir($dir);
234 if (is_resource($handle)) {
235 while (($file = readdir($handle)) !==
false) {
236 if (substr($file, 0, 18) ==
'mod_expensereport_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
237 $file = substr($file, 0,
dol_strlen($file) - 4);
239 require_once $dir.$file.
'.php';
241 $module =
new $file($db);
243 '@phan-var-force ModeleNumRefExpenseReport $module';
246 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
249 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
253 if ($module->isEnabled()) {
254 print
'<tr class="oddeven"><td>'.$module->getName($langs).
"</td><td>\n";
255 print $module->info($langs);
259 print
'<td class="nowrap">';
260 $tmp = $module->getExample();
261 if (preg_match(
'/^Error/', $tmp)) {
262 $langs->load(
"errors");
263 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
264 } elseif ($tmp ==
'NotConfigured') {
265 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
271 print
'<td class="center">';
272 if (
$conf->global->EXPENSEREPORT_ADDON == $file) {
273 print
img_picto($langs->trans(
"Activated"),
'switch_on');
275 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
276 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
282 $exp->initAsSpecimen();
286 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
287 $nextval = $module->getNextValue($exp);
288 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
289 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
291 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
292 $nextval = $langs->trans($nextval);
294 $htmltooltip .= $nextval.
'<br>';
296 $htmltooltip .= $langs->trans($module->error).
'<br>';
300 print
'<td class="center">';
301 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
312print
"</table><br>\n";
321$type =
'expensereport';
324$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
325$sql .=
" WHERE type = '".$db->escape($type).
"'";
326$sql .=
" AND entity = ".$conf->entity;
327$resql = $db->query($sql);
330 $num_rows = $db->num_rows($resql);
331 while ($i < $num_rows) {
332 $array = $db->fetch_array($resql);
333 if (is_array($array)) {
334 array_push($def, $array[0]);
342print
'<table class="noborder centpercent">';
343print
'<tr class="liste_titre">';
344print
'<td>'.$langs->trans(
"Name").
'</td>';
345print
'<td>'.$langs->trans(
"Description").
'</td>';
346print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
347print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
348print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
349print
'<td class="center" width="80">'.$langs->trans(
"Preview").
'</td>';
354foreach ($dirmodels as $reldir) {
355 $dir =
dol_buildpath($reldir.
"core/modules/expensereport/doc");
358 $handle = opendir($dir);
359 if (is_resource($handle)) {
361 while (($file = readdir($handle)) !==
false) {
367 foreach ($filelist as $file) {
368 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
369 if (file_exists($dir.
'/'.$file)) {
370 $name = substr($file, 4,
dol_strlen($file) - 16);
371 $classname = substr($file, 0,
dol_strlen($file) - 12);
373 require_once $dir.
'/'.$file;
374 $module =
new $classname($db);
376 '@phan-var-force ModeleExpenseReport $module';
378 $modulequalified = 1;
379 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
380 $modulequalified = 0;
382 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
383 $modulequalified = 0;
386 if ($modulequalified) {
387 print
'<tr class="oddeven"><td width="100">';
388 print(empty($module->name) ? $name : $module->
name);
390 if (method_exists($module,
'info')) {
391 print $module->info($langs);
393 print $module->description;
398 if (in_array($name, $def)) {
399 print
'<td class="center">'.
"\n";
400 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">';
401 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
405 print
'<td class="center">'.
"\n";
406 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>';
411 print
'<td class="center">';
412 if (
$conf->global->EXPENSEREPORT_ADDON_PDF ==
"$name") {
413 print
img_picto($langs->trans(
"Default"),
'on');
415 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>';
420 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
421 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
422 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
423 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
424 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
425 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
426 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
427 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
428 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
429 print
'<td class="center">';
430 print $form->textwithpicto(
'', $htmltooltip, -1, 0);
434 print
'<td class="center">';
435 if ($module->type ==
'pdf') {
436 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
438 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
462print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
463print
'<input type="hidden" name="token" value="'.newToken().
'">';
464print
'<input type="hidden" name="action" value="setoptions">';
467print
'<table class="noborder centpercent">';
468print
'<tr class="liste_titre">';
469print
'<td>'.$langs->trans(
"Parameter").
'</td>';
470print
'<td class="center" width="60"></td>';
474$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
475$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
476foreach ($substitutionarray as $key => $val) {
477 $htmltext .= $key.
'<br>';
481print
'<tr class="oddeven"><td colspan="2">';
482print $form->textwithpicto($langs->trans(
"FreeLegalTextOnExpenseReports"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
483$variablename =
'EXPENSEREPORT_FREE_TEXT';
485 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
487 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
489 print $doleditor->Create();
491print
'</td></tr>'.
"\n";
495print
'<tr class="oddeven"><td colspan="2">';
496print $form->textwithpicto($langs->trans(
"WatermarkOnDraftExpenseReports"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
497print
'<input class="flat minwidth200" type="text" name="EXPENSEREPORT_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'EXPENSEREPORT_DRAFT_WATERMARK')).
'">';
498print
'</td></tr>'.
"\n";
500if (isModEnabled(
'project')) {
501 print
'<tr class="oddeven"><td>';
502 print $langs->trans(
'ProjectIsRequiredOnExpenseReports');
503 print
'</td><td class="right">';
504 print $form->selectyesno(
'EXPENSEREPORT_PROJECT_IS_REQUIRED',
getDolGlobalString(
'EXPENSEREPORT_PROJECT_IS_REQUIRED') ? 1 : 0, 1);
508print
'<tr class="oddeven"><td>';
509print $langs->trans(
'PrefillExpenseReportDatesWithCurrentMonth');
510print
'</td><td class="right">';
511print $form->selectyesno(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH',
getDolGlobalString(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH') ? 1 : 0, 1);
514print
'<tr class="oddeven"><td>';
515print $langs->trans(
'ForceExpenseReportsLineAmountsIncludingTaxesOnly');
516print
'</td><td class="right">';
517print $form->selectyesno(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY',
getDolGlobalString(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY') ? 1 : 0, 1);
520print
'<tr class="oddeven"><td>';
521print $langs->trans(
'BlockExpenseReportLineCreationIfNotBetweenDates');
522print
'</td><td class="right">';
523print $form->selectyesno(
'EXPENSEREPORT_BLOCK_LINE_CREATION_IF_NOT_BETWEEN_DATES',
getDolGlobalString(
'EXPENSEREPORT_BLOCK_LINE_CREATION_IF_NOT_BETWEEN_DATES') ? 1 : 0, 1);
528print $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 to manage Trips and Expenses.
expensereport_admin_prepare_head()
Return array head with list of tabs to view object information.
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)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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.