dolibarr 19.0.3
agenda_other.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2008-2016 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
6 * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
7 * Copyright (C) 2017 Open-DSI <support@open-dsi.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/defaultvalues.class.php';
35
36if (!$user->admin) {
38}
39
40// Load translation files required by the page
41$langs->loadLangs(array('admin', 'other', 'agenda', 'users'));
42
43$action = GETPOST('action', 'aZ09');
44$value = GETPOST('value', 'alpha');
45$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
46
47$param = GETPOST('param', 'alpha');
48$cancel = GETPOST('cancel', 'alpha');
49$scandir = GETPOST('scan_dir', 'alpha');
50$type = 'action';
51
52
53/*
54 * Actions
55 */
56
57$error = 0;
58$errors = array();
59
60include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
61
62$reg = array();
63if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
64 $code = $reg[1];
65 $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
66 if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
67 Header("Location: ".$_SERVER["PHP_SELF"]);
68 exit;
69 } else {
70 dol_print_error($db);
71 }
72}
73
74if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
75 $code = $reg[1];
76 if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
77 Header("Location: ".$_SERVER["PHP_SELF"]);
78 exit;
79 } else {
80 dol_print_error($db);
81 }
82}
83if ($action == 'set') {
84 $getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE');
85 $defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter;
86 dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
87 dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity);
88 dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
89 dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
90
91 $defaultValues = new DefaultValues($db);
92 $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));
93 if (!is_array($result) && $result < 0) {
94 setEventMessages($defaultValues->error, $defaultValues->errors, 'errors');
95 } elseif (count($result) > 0) {
96 foreach ($result as $defval) {
97 $defaultValues->id = $defval->id;
98 $resultDel = $defaultValues->delete($user);
99 if ($resultDel < 0) {
100 setEventMessages($defaultValues->error, $defaultValues->errors, 'errors');
101 }
102 }
103 }
104 $defaultValues->type = 'createform';
105 $defaultValues->entity = $conf->entity;
106 $defaultValues->user_id = 0;
107 $defaultValues->page = 'comm/action/card.php';
108 $defaultValues->param = 'complete';
109 $defaultValues->value = GETPOST('AGENDA_EVENT_DEFAULT_STATUS');
110 $resultCreat = $defaultValues->create($user);
111 if ($resultCreat < 0) {
112 setEventMessages($defaultValues->error, $defaultValues->errors, 'errors');
113 } else {
114 setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
115 }
116} elseif ($action == 'specimen') { // For orders
117 $modele = GETPOST('module', 'alpha');
118
119 $commande = new CommandeFournisseur($db);
120 $commande->initAsSpecimen();
121 $commande->thirdparty = $specimenthirdparty;
122
123 // Search template files
124 $file = '';
125 $classname = '';
126 $filefound = 0;
127 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
128 foreach ($dirmodels as $reldir) {
129 $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
130 if (file_exists($file)) {
131 $filefound = 1;
132 $classname = "pdf_".$modele;
133 break;
134 }
135 }
136
137 if ($filefound) {
138 require_once $file;
139
140 $module = new $classname($db, $commande);
141
142 if ($module->write_file($commande, $langs) > 0) {
143 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
144 return;
145 } else {
146 setEventMessages($module->error, $module->errors, 'errors');
147 dol_syslog($module->error, LOG_ERR);
148 }
149 } else {
150 setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
151 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
152 }
153} elseif ($action == 'setmodel') {
154 // Activate a model
155 //print "sssd".$value;
156 $ret = addDocumentModel($value, $type, $label, $scandir);
157} elseif ($action == 'del') {
158 $ret = delDocumentModel($value, $type);
159 if ($ret > 0) {
160 if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") {
161 dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
162 }
163 }
164} elseif ($action == 'setdoc') {
165 // Set default model
166 if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
167 // La constante qui a ete lue en avant du nouveau set
168 // on passe donc par une variable pour avoir un affichage coherent
169 $conf->global->ACTION_EVENT_ADDON_PDF = $value;
170 }
171
172 // On active le modele
173 $ret = delDocumentModel($value, $type);
174 if ($ret > 0) {
175 $ret = addDocumentModel($value, $type, $label, $scandir);
176 }
177}
178
179
185$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
186
187$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung';
188llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
189
190$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
191print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup');
192
193
194
195$head = agenda_prepare_head();
196
197print dol_get_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action');
198
199
200/*
201 * Miscellaneous
202 */
203
204// Define array def of models
205$def = array();
206
207$sql = "SELECT nom";
208$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
209$sql .= " WHERE type = 'action'";
210$sql .= " AND entity = ".$conf->entity;
211
212$resql = $db->query($sql);
213if ($resql) {
214 $i = 0;
215 $num_rows = $db->num_rows($resql);
216 while ($i < $num_rows) {
217 $array = $db->fetch_array($resql);
218 array_push($def, $array[0]);
219 $i++;
220 }
221} else {
222 dol_print_error($db);
223}
224
225if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
226 print load_fiche_titre($langs->trans("AgendaModelModule"), '', '');
227
228 print '<table class="noborder centpercent">'."\n";
229 print '<tr class="liste_titre">'."\n";
230 print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
231 print '<td>'.$langs->trans("Description").'</td>'."\n";
232 print '<td class="center" width="60">'.$langs->trans("Status").'</td>'."\n";
233 print '<td class="center" width="60">'.$langs->trans("Default").'</td>'."\n";
234 print '<td class="center" width="40">'.$langs->trans("ShortInfo").'</td>';
235 print '<td class="center" width="40">'.$langs->trans("Preview").'</td>';
236 print '</tr>'."\n";
237
238 clearstatcache();
239
240 foreach ($dirmodels as $reldir) {
241 $dir = dol_buildpath($reldir."core/modules/action/doc");
242
243 if (is_dir($dir)) {
244 $handle = opendir($dir);
245 if (is_resource($handle)) {
246 while (($file = readdir($handle)) !== false) {
247 if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
248 $name = substr($file, 4, dol_strlen($file) - 16);
249 $classname = substr($file, 0, dol_strlen($file) - 12);
250
251 require_once $dir.'/'.$file;
252 $module = new $classname($db, new ActionComm($db));
253
254 print '<tr class="oddeven">'."\n";
255 print "<td>";
256 print(empty($module->name) ? $name : $module->name);
257 print "</td>\n";
258 print "<td>\n";
259 require_once $dir.'/'.$file;
260 $module = new $classname($db, $specimenthirdparty);
261 if (method_exists($module, 'info')) {
262 print $module->info($langs);
263 } else {
264 print $module->description;
265 }
266 print "</td>\n";
267
268 // Active
269 if (in_array($name, $def)) {
270 print '<td class="center">'."\n";
271 if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") {
272 print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=action">';
273 print img_picto($langs->trans("Enabled"), 'switch_on');
274 print '</a>';
275 } else {
276 print img_picto($langs->trans("Enabled"), 'switch_on');
277 }
278 print "</td>";
279 } else {
280 print '<td class="center">'."\n";
281 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>';
282 print "</td>";
283 }
284
285 // Default
286 print '<td class="center">';
287 if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") {
288 print img_picto($langs->trans("Default"), 'on');
289 } else {
290 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.urlencode($name).'&amp;scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'&amp;type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
291 }
292 print '</td>';
293
294 // Info
295 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
296 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
297 $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
298 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
299 $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
300 print '<td class="center">';
301 print $form->textwithpicto('', $htmltooltip, 1, 0);
302 print '</td>';
303 print '<td class="center">';
304 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
305 print '</td>';
306
307 print "</tr>\n";
308 }
309 }
310 closedir($handle);
311 }
312 }
313 }
314 print '</table><br>';
315
316 print load_fiche_titre($langs->trans('MiscellaneousOptions'), '', '');
317}
318
319
320print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
321print '<input type="hidden" name="token" value="'.newToken().'">';
322print '<input type="hidden" name="action" value="set">';
323
324print '<table class="noborder allwidth">'."\n";
325print '<tr class="liste_titre">'."\n";
326print '<td>'.$langs->trans("Parameters").'</td>'."\n";
327print '<td class="center">&nbsp;</td>'."\n";
328print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
329print '</tr>'."\n";
330
331// AGENDA_DEFAULT_VIEW
332print '<tr class="oddeven">'."\n";
333$htmltext = $langs->trans("ThisValueCanOverwrittenOnUserLevel", $langs->transnoentitiesnoconv("UserGUISetup"));
334print '<td>'.$form->textwithpicto($langs->trans("AGENDA_DEFAULT_VIEW"), $htmltext).'</td>'."\n";
335print '<td class="center">&nbsp;</td>'."\n";
336print '<td class="right">'."\n";
337$tmplist = array(''=>'&nbsp;', '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"));
338print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, getDolGlobalString('AGENDA_DEFAULT_VIEW'));
339print '</td></tr>'."\n";
340
341// Manual or automatic
342
343print '<tr class="oddeven">'."\n";
344print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE").'</td>'."\n";
345print '<td class="center">&nbsp;</td>'."\n";
346print '<td class="right">'."\n";
347//print ajax_constantonoff('AGENDA_USE_EVENT_TYPE'); Do not use ajax here, we need to reload page to change other combo list
348if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) {
349 print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_USE_EVENT_TYPE&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
350} else {
351 print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_USE_EVENT_TYPE&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';
352}
353print '</td></tr>'."\n";
354
355if (getDolGlobalString('AGENDA_USE_EVENT_TYPE')) {
356 print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
357 print '<tr class="oddeven">'."\n";
358 print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n";
359 print '<td class="center">&nbsp;</td>'."\n";
360 print '<td class="right nowrap">'."\n";
361 $formactions->select_type_actions(getDolGlobalString('AGENDA_USE_EVENT_TYPE_DEFAULT'), "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1);
362 print '</td></tr>'."\n";
363}
364
365// AGENDA_EVENT_DEFAULT_STATUS
366print '<tr class="oddeven">'."\n";
367print '<td>'.$langs->trans("AGENDA_EVENT_DEFAULT_STATUS").'</td>'."\n";
368print '<td class="center">&nbsp;</td>'."\n";
369print '<td class="right nowrap">'."\n";
370$defval = 'na';
371$defaultValues = new DefaultValues($db);
372$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));
373if (!is_array($result) && $result < 0) {
374 setEventMessages($defaultValues->error, $defaultValues->errors, 'errors');
375} elseif (count($result) > 0) {
376 $defval = reset($result)->value;
377}
378$formactions->form_select_status_action('agenda', $defval, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200 onrightofpage');
379print '</td></tr>'."\n";
380
381// AGENDA_DEFAULT_FILTER_TYPE
382print '<tr class="oddeven">'."\n";
383print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_TYPE").'</td>'."\n";
384print '<td class="center">&nbsp;</td>'."\n";
385print '<td class="right nowrap">'."\n";
386$multiselect = 0;
387if (getDolGlobalString('MAIN_ENABLE_MULTISELECT_TYPE')) {
388 // We use an option here because it adds bugs when used on agenda page "peruser" and "list"
389 $multiselect = (getDolGlobalString('AGENDA_USE_EVENT_TYPE'));
390}
391$formactions->select_type_actions(getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE'), "AGENDA_DEFAULT_FILTER_TYPE", '', (getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? -1 : 1), 1, $multiselect);
392print '</td></tr>'."\n";
393
394// AGENDA_DEFAULT_FILTER_STATUS
395// TODO Remove to use the default generic feature
396print '<tr class="oddeven">'."\n";
397print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_STATUS").'</td>'."\n";
398print '<td class="center">&nbsp;</td>'."\n";
399print '<td class="right">'."\n";
400$formactions->form_select_status_action('agenda', getDolGlobalString('AGENDA_DEFAULT_FILTER_STATUS'), 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2, 'minwidth100');
401print '</td></tr>'."\n";
402
403print '</table>';
404
405print $form->buttonsSaveCancel("Save", '');
406
407print '</form>';
408
409
410print dol_get_fiche_end();
411
412// End of page
413llxFooter();
414$db->close();
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.
agenda_prepare_head()
Prepare array with list of tabs.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage agenda events (actions)
Class to manage predefined suppliers products.
Class for MyObject.
Class to manage building of HTML components.
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.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:124
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.