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;
87 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
88 foreach ($dirmodels as $reldir) {
89 $file =
dol_buildpath($reldir.
"core/modules/expensereport/doc/pdf_".$modele.
".modules.php", 0);
90 if (file_exists($file)) {
92 $classname =
"pdf_".$modele;
100 $module =
new $classname($db);
102 if ($module->write_file($expensespecimen, $langs) > 0) {
103 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=expensereport&file=SPECIMEN.pdf");
111 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
113} elseif ($action ==
'set') {
117 dolibarr_set_const($db,
'EXPENSEREPORT_ADDON_PDF', $value,
'chaine', 0,
'', $conf->entity);
119} elseif ($action ==
'del') {
122 if ($conf->global->EXPENSEREPORT_ADDON_PDF ==
"$value") {
126} elseif ($action ==
'setdoc') {
128 if (
dolibarr_set_const($db,
"EXPENSEREPORT_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
131 $conf->global->EXPENSEREPORT_ADDON_PDF = $value;
139} elseif ($action ==
'setmod') {
143 dolibarr_set_const($db,
"EXPENSEREPORT_ADDON", $value,
'chaine', 0,
'', $conf->entity);
144} elseif ($action ==
'setoptions') {
147 $freetext =
GETPOST(
'EXPENSEREPORT_FREE_TEXT',
'restricthtml');
148 $res1 =
dolibarr_set_const($db,
"EXPENSEREPORT_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
150 $draft =
GETPOST(
'EXPENSEREPORT_DRAFT_WATERMARK',
'alpha');
151 $res2 =
dolibarr_set_const($db,
"EXPENSEREPORT_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
154 if (isModEnabled(
'project') && GETPOSTISSET(
'EXPENSEREPORT_PROJECT_IS_REQUIRED')) {
155 $res3 =
dolibarr_set_const($db,
'EXPENSEREPORT_PROJECT_IS_REQUIRED',
GETPOST(
'EXPENSEREPORT_PROJECT_IS_REQUIRED',
'int'),
'chaine', 0,
'', $conf->entity);
158 $dates =
GETPOST(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH',
'int');
159 $res4 =
dolibarr_set_const($db,
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH', intval($dates),
'chaine', 0,
'', $conf->entity);
161 $amounts =
GETPOST(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY',
'int');
162 $res5 =
dolibarr_set_const($db,
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY', intval($amounts),
'chaine', 0,
'', $conf->entity);
164 if (!($res1 > 0) || !($res2 > 0) || !($res3 >= 0) || !($res4 >0) || !($res5 >0)) {
182$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
184llxHeader(
'', $langs->trans(
"ExpenseReportsSetup"));
186$form =
new Form($db);
188$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
189print
load_fiche_titre($langs->trans(
"ExpenseReportsSetup"), $linkback,
'title_setup');
194print
dol_get_fiche_head($head,
'expensereport', $langs->trans(
"ExpenseReports"), -1,
'trip');
200print
load_fiche_titre($langs->trans(
"ExpenseReportNumberingModules"),
'',
'');
202print
'<table class="noborder centpercent">';
203print
'<tr class="liste_titre">';
204print
'<td>'.$langs->trans(
"Name").
'</td>';
205print
'<td>'.$langs->trans(
"Description").
'</td>';
206print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
207print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
208print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
213foreach ($dirmodels as $reldir) {
217 $handle = opendir($dir);
218 if (is_resource($handle)) {
219 while (($file = readdir($handle)) !==
false) {
220 if (substr($file, 0, 18) ==
'mod_expensereport_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
221 $file = substr($file, 0,
dol_strlen($file) - 4);
223 require_once $dir.$file.
'.php';
225 $module =
new $file($db);
228 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
231 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
235 if ($module->isEnabled()) {
236 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
237 print $module->info($langs);
241 print
'<td class="nowrap">';
242 $tmp = $module->getExample();
243 if (preg_match(
'/^Error/', $tmp)) {
244 $langs->load(
"errors");
245 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
246 } elseif ($tmp ==
'NotConfigured') {
247 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
253 print
'<td class="center">';
254 if ($conf->global->EXPENSEREPORT_ADDON == $file) {
255 print
img_picto($langs->trans(
"Activated"),
'switch_on');
257 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&value='.urlencode($file).
'">';
258 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
264 $exp->initAsSpecimen();
268 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
269 $nextval = $module->getNextValue($exp);
270 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
271 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
273 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
274 $nextval = $langs->trans($nextval);
276 $htmltooltip .= $nextval.
'<br>';
278 $htmltooltip .= $langs->trans($module->error).
'<br>';
282 print
'<td class="center">';
283 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
294print
"</table><br>\n";
303$type =
'expensereport';
306$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
307$sql .=
" WHERE type = '".$db->escape($type).
"'";
308$sql .=
" AND entity = ".$conf->entity;
309$resql = $db->query($sql);
312 $num_rows = $db->num_rows($resql);
313 while ($i < $num_rows) {
314 $array = $db->fetch_array($resql);
315 array_push($def, $array[0]);
322print
'<table class="noborder centpercent">';
323print
'<tr class="liste_titre">';
324print
'<td>'.$langs->trans(
"Name").
'</td>';
325print
'<td>'.$langs->trans(
"Description").
'</td>';
326print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
327print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
328print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
329print
'<td class="center" width="80">'.$langs->trans(
"Preview").
'</td>';
334foreach ($dirmodels as $reldir) {
335 $dir =
dol_buildpath($reldir.
"core/modules/expensereport/doc");
338 $handle = opendir($dir);
339 if (is_resource($handle)) {
340 while (($file = readdir($handle)) !==
false) {
346 foreach ($filelist as $file) {
347 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
348 if (file_exists($dir.
'/'.$file)) {
349 $name = substr($file, 4,
dol_strlen($file) - 16);
350 $classname = substr($file, 0,
dol_strlen($file) - 12);
352 require_once $dir.
'/'.$file;
353 $module =
new $classname($db);
355 $modulequalified = 1;
356 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
357 $modulequalified = 0;
359 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
360 $modulequalified = 0;
363 if ($modulequalified) {
364 print
'<tr class="oddeven"><td width="100">';
365 print(empty($module->name) ? $name : $module->
name);
367 if (method_exists($module,
'info')) {
368 print $module->info($langs);
370 print $module->description;
375 if (in_array($name, $def)) {
376 print
'<td class="center">'.
"\n";
377 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">';
378 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
382 print
'<td class="center">'.
"\n";
383 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>';
388 print
'<td class="center">';
389 if ($conf->global->EXPENSEREPORT_ADDON_PDF ==
"$name") {
390 print
img_picto($langs->trans(
"Default"),
'on');
392 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>';
397 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
398 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
399 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
400 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
401 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
402 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
403 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
404 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
405 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
406 print
'<td class="center">';
407 print $form->textwithpicto(
'', $htmltooltip, -1, 0);
411 print
'<td class="center">';
412 if ($module->type ==
'pdf') {
413 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
415 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
439print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
440print
'<input type="hidden" name="token" value="'.newToken().
'">';
441print
'<input type="hidden" name="action" value="setoptions">';
444print
'<table class="noborder centpercent">';
445print
'<tr class="liste_titre">';
446print
'<td>'.$langs->trans(
"Parameter").
'</td>';
447print
'<td class="center" width="60"></td>';
451$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
452$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
453foreach ($substitutionarray as $key => $val) {
454 $htmltext .= $key.
'<br>';
458print
'<tr class="oddeven"><td colspan="2">';
459print $form->textwithpicto($langs->trans(
"FreeLegalTextOnExpenseReports"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
460$variablename =
'EXPENSEREPORT_FREE_TEXT';
462 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
464 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
466 print $doleditor->Create();
468print
'</td></tr>'.
"\n";
472print
'<tr class="oddeven"><td colspan="2">';
473print $form->textwithpicto($langs->trans(
"WatermarkOnDraftExpenseReports"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
474print
'<input class="flat minwidth200" type="text" name="EXPENSEREPORT_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'EXPENSEREPORT_DRAFT_WATERMARK')).
'">';
475print
'</td></tr>'.
"\n";
477if (isModEnabled(
'project')) {
478 print
'<tr class="oddeven"><td>';
479 print $langs->trans(
'ProjectIsRequiredOnExpenseReports');
480 print
'</td><td class="right">';
481 print $form->selectyesno(
'EXPENSEREPORT_PROJECT_IS_REQUIRED', !
getDolGlobalString(
'EXPENSEREPORT_PROJECT_IS_REQUIRED') ? 0 : 1, 1);
485print
'<tr class="oddeven"><td>';
486print $langs->trans(
'PrefillExpenseReportDatesWithCurrentMonth');
487print
'</td><td class="right">';
488print $form->selectyesno(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH', !
getDolGlobalString(
'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH') ? 0 : 1, 1);
491print
'<tr class="oddeven"><td>';
492print $langs->trans(
'ForceExpenseReportsLineAmountsIncludingTaxesOnly');
493print
'</td><td class="right">';
494print $form->selectyesno(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY', !
getDolGlobalString(
'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY') ? 0 : 1, 1);
499print $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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.