29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/defaultvalues.class.php';
40 $langs->loadLangs(array(
'admin',
'other',
'agenda',
'users'));
42 $action =
GETPOST(
'action',
'aZ09');
43 $value =
GETPOST(
'value',
'alpha');
44 $modulepart =
GETPOST(
'modulepart',
'aZ09');
46 $param =
GETPOST(
'param',
'alpha');
47 $cancel =
GETPOST(
'cancel',
'alpha');
48 $scandir =
GETPOST(
'scan_dir',
'alpha');
56 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
59 if (preg_match(
'/set_([a-z0-9_\-]+)/i', $action, $reg)) {
63 Header(
"Location: ".$_SERVER[
"PHP_SELF"]);
70 if (preg_match(
'/del_([a-z0-9_\-]+)/i', $action, $reg)) {
73 Header(
"Location: ".$_SERVER[
"PHP_SELF"]);
79 if ($action ==
'set') {
80 $getDefaultFilter =
GETPOST(
'AGENDA_DEFAULT_FILTER_TYPE');
81 $defaultfilter = (is_array($getDefaultFilter)) ? implode(
',', $getDefaultFilter) : $getDefaultFilter;
82 dolibarr_set_const($db,
'AGENDA_USE_EVENT_TYPE_DEFAULT',
GETPOST(
'AGENDA_USE_EVENT_TYPE_DEFAULT'),
'chaine', 0,
'', $conf->entity);
83 dolibarr_set_const($db,
'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter,
'chaine', 0,
'', $conf->entity);
84 dolibarr_set_const($db,
'AGENDA_DEFAULT_FILTER_STATUS',
GETPOST(
'AGENDA_DEFAULT_FILTER_STATUS'),
'chaine', 0,
'', $conf->entity);
88 $result = $defaultValues->fetchAll(
'',
'', 0, 0, array(
't.page'=>
'comm/action/card.php',
't.param'=>
'complete',
't.user_id'=>
'0',
't.type'=>
'createform',
't.entity'=>$conf->entity));
89 if (!is_array($result) && $result < 0) {
91 } elseif (count($result) > 0) {
92 foreach ($result as $defval) {
93 $defaultValues->id = $defval->id;
94 $resultDel = $defaultValues->delete($user);
100 $defaultValues->type =
'createform';
101 $defaultValues->entity = $conf->entity;
102 $defaultValues->user_id = 0;
103 $defaultValues->page =
'comm/action/card.php';
104 $defaultValues->param =
'complete';
105 $defaultValues->value =
GETPOST(
'AGENDA_EVENT_DEFAULT_STATUS');
106 $resultCreat = $defaultValues->create($user);
107 if ($resultCreat < 0) {
112 } elseif ($action ==
'specimen') {
113 $modele =
GETPOST(
'module',
'alpha');
116 $commande->initAsSpecimen();
117 $commande->thirdparty = $specimenthirdparty;
120 $file =
''; $classname =
''; $filefound = 0;
121 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
122 foreach ($dirmodels as $reldir) {
123 $file =
dol_buildpath($reldir.
"core/modules/action/doc/pdf_".$modele.
".modules.php", 0);
124 if (file_exists($file)) {
126 $classname =
"pdf_".$modele;
134 $module =
new $classname($db, $commande);
136 if ($module->write_file($commande, $langs) > 0) {
137 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=action&file=SPECIMEN.pdf");
145 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
147 } elseif ($action ==
'setmodel') {
151 } elseif ($action ==
'del') {
154 if ($conf->global->ACTION_EVENT_ADDON_PDF ==
"$value") {
158 } elseif ($action ==
'setdoc') {
160 if (
dolibarr_set_const($db,
"ACTION_EVENT_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
163 $conf->global->ACTION_EVENT_ADDON_PDF = $value;
179 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
181 $wikihelp =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
184 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
185 print
load_fiche_titre($langs->trans(
"AgendaSetup"), $linkback,
'title_setup');
203 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
204 $sql .=
" WHERE type = 'action'";
205 $sql .=
" AND entity = ".$conf->entity;
207 $resql = $db->query($sql);
210 $num_rows = $db->num_rows(
$resql);
211 while ($i < $num_rows) {
212 $array = $db->fetch_array(
$resql);
213 array_push($def, $array[0]);
220 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
223 print
'<table class="noborder centpercent">'.
"\n";
224 print
'<tr class="liste_titre">'.
"\n";
225 print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
226 print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
227 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
228 print
'<td class="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
229 print
'<td class="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
230 print
'<td class="center" width="40">'.$langs->trans(
"Preview").
'</td>';
235 foreach ($dirmodels as $reldir) {
239 $handle = opendir($dir);
240 if (is_resource($handle)) {
241 while (($file = readdir($handle)) !==
false) {
242 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
243 $name = substr($file, 4,
dol_strlen($file) - 16);
244 $classname = substr($file, 0,
dol_strlen($file) - 12);
246 require_once $dir.
'/'.$file;
247 $module =
new $classname($db,
new ActionComm($db));
249 print
'<tr class="oddeven">'.
"\n";
251 print (empty($module->name) ? $name : $module->name);
254 require_once $dir.
'/'.$file;
255 $module =
new $classname($db, $specimenthirdparty);
256 if (method_exists($module,
'info')) {
257 print $module->info($langs);
259 print $module->description;
264 if (in_array($name, $def)) {
265 print
'<td class="center">'.
"\n";
266 if ($conf->global->ACTION_EVENT_ADDON_PDF !=
"$name") {
267 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=action">';
268 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
271 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
275 print
'<td class="center">'.
"\n";
276 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setmodel&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=action">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
281 print
'<td class="center">';
282 if ($conf->global->ACTION_EVENT_ADDON_PDF ==
"$name") {
283 print
img_picto($langs->trans(
"Default"),
'on');
285 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=action"" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
290 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
291 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
292 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
293 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
294 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
295 print
'<td class="center">';
296 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
298 print
'<td class="center">';
299 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
309 print
'</table><br>';
312 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" name="agenda">';
313 print
'<input type="hidden" name="token" value="'.newToken().
'">';
314 print
'<input type="hidden" name="action" value="set">';
316 print
'<table class="noborder allwidth">'.
"\n";
317 print
'<tr class="liste_titre">'.
"\n";
318 print
'<td>'.$langs->trans(
"Parameters").
'</td>'.
"\n";
319 print
'<td class="center"> </td>'.
"\n";
320 print
'<td class="right">'.$langs->trans(
"Value").
'</td>'.
"\n";
324 print
'<tr class="oddeven">'.
"\n";
325 $htmltext = $langs->trans(
"ThisValueCanOverwrittenOnUserLevel", $langs->transnoentitiesnoconv(
"UserGUISetup"));
326 print
'<td>'.$form->textwithpicto($langs->trans(
"AGENDA_DEFAULT_VIEW"), $htmltext).
'</td>'.
"\n";
327 print
'<td class="center"> </td>'.
"\n";
328 print
'<td class="right">'.
"\n";
329 $tmplist = array(
''=>
' ',
'show_list'=>$langs->trans(
"ViewList"),
'show_month'=>$langs->trans(
"ViewCal"),
'show_week'=>$langs->trans(
"ViewWeek"),
'show_day'=>$langs->trans(
"ViewDay"),
'show_peruser'=>$langs->trans(
"ViewPerUser"));
330 print
$form->selectarray(
'AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
331 print
'</td></tr>'.
"\n";
335 print
'<tr class="oddeven">'.
"\n";
336 print
'<td>'.$langs->trans(
"AGENDA_USE_EVENT_TYPE").
'</td>'.
"\n";
337 print
'<td class="center"> </td>'.
"\n";
338 print
'<td class="right">'.
"\n";
340 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
341 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_AGENDA_USE_EVENT_TYPE&token='.
newToken().
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
343 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=del_AGENDA_USE_EVENT_TYPE&token='.
newToken().
'">'.
img_picto($langs->trans(
"Enabled"),
'switch_on').
'</a>';
345 print
'</td></tr>'.
"\n";
347 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
348 print
'<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
349 print
'<tr class="oddeven">'.
"\n";
350 print
'<td>'.$langs->trans(
"AGENDA_USE_EVENT_TYPE_DEFAULT").
'</td>'.
"\n";
351 print
'<td class="center"> </td>'.
"\n";
352 print
'<td class="right nowrap">'.
"\n";
353 $formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT,
"AGENDA_USE_EVENT_TYPE_DEFAULT",
'systemauto', 0, 1);
354 print
'</td></tr>'.
"\n";
358 print
'<tr class="oddeven">'.
"\n";
359 print
'<td>'.$langs->trans(
"AGENDA_EVENT_DEFAULT_STATUS").
'</td>'.
"\n";
360 print
'<td class="center"> </td>'.
"\n";
361 print
'<td class="right nowrap">'.
"\n";
364 $result = $defaultValues->fetchAll(
'',
'', 0, 0, array(
't.page'=>
'comm/action/card.php',
't.param'=>
'complete',
't.user_id'=>
'0',
't.type'=>
'createform',
't.entity'=>$conf->entity));
365 if (!is_array($result) && $result < 0) {
367 } elseif (count($result) > 0) {
368 $defval = reset($result)->value;
370 $formactions->form_select_status_action(
'agenda', $defval, 1,
"AGENDA_EVENT_DEFAULT_STATUS", 0, 1,
'maxwidth200');
371 print
'</td></tr>'.
"\n";
374 print
'<tr class="oddeven">'.
"\n";
375 print
'<td>'.$langs->trans(
"AGENDA_DEFAULT_FILTER_TYPE").
'</td>'.
"\n";
376 print
'<td class="center"> </td>'.
"\n";
377 print
'<td class="right nowrap">'.
"\n";
379 if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) {
381 $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE));
383 $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE,
"AGENDA_DEFAULT_FILTER_TYPE",
'', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 1, $multiselect);
384 print
'</td></tr>'.
"\n";
388 print
'<tr class="oddeven">'.
"\n";
389 print
'<td>'.$langs->trans(
"AGENDA_DEFAULT_FILTER_STATUS").
'</td>'.
"\n";
390 print
'<td class="center"> </td>'.
"\n";
391 print
'<td class="right">'.
"\n";
392 $formactions->form_select_status_action(
'agenda', $conf->global->AGENDA_DEFAULT_FILTER_STATUS, 1,
'AGENDA_DEFAULT_FILTER_STATUS', 1, 2,
'minwidth100');
393 print
'</td></tr>'.
"\n";
399 print
$form->buttonsSaveCancel(
"Save",
'');