dolibarr  9.0.0
agenda.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2008-2015 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
5  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
30 
31 if (!$user->admin)
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array('admin', 'other', 'agenda'));
36 
37 $action = GETPOST('action','alpha');
38 $cancel = GETPOST('cancel','alpha');
39 
40 $search_event = GETPOST('search_event', 'alpha');
41 
42 // Get list of triggers available
43 $sql = "SELECT a.rowid, a.code, a.label, a.elementtype";
44 $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
45 $sql.= " ORDER BY a.rang ASC";
46 $resql=$db->query($sql);
47 if ($resql)
48 {
49  $num = $db->num_rows($resql);
50  $i = 0;
51  while ($i < $num)
52  {
53  $obj = $db->fetch_object($resql);
54  $triggers[$i]['rowid'] = $obj->rowid;
55  $triggers[$i]['code'] = $obj->code;
56  $triggers[$i]['element'] = $obj->elementtype;
57  $triggers[$i]['label'] = ($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
58 
59  $i++;
60  }
61  $db->free($resql);
62 }
63 else
64 {
65  dol_print_error($db);
66 }
67 
68 
69 /*
70  * Actions
71  */
72 
73 // Purge search criteria
74 if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
75 {
76  $search_event = '';
77  $action = '';
78 }
79 
80 if (GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') ||GETPOST('button_search','alpha')) // To avoid the save when we click on search
81 {
82  $action = '';
83 }
84 
85 if ($action == "save" && empty($cancel))
86 {
87  $i=0;
88 
89  $db->begin();
90 
91  foreach ($triggers as $trigger)
92  {
93  $keyparam='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
94  //print "param=".$param." - ".$_POST[$param];
95  if ($search_event === '' || preg_match('/'.preg_quote($search_event,'/').'/i', $keyparam))
96  {
97  $res = dolibarr_set_const($db,$keyparam,(GETPOST($keyparam,'alpha')?GETPOST($keyparam,'alpha'):''),'chaine',0,'',$conf->entity);
98  if (! $res > 0) $error++;
99  }
100  }
101 
102  if (! $error)
103  {
104  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
105  $db->commit();
106  }
107  else
108  {
109  setEventMessages($langs->trans("Error"),null, 'errors');
110  $db->rollback();
111  }
112 }
113 
114 
115 
120 $wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
121 llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
122 
123 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
124 print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
125 
126 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
127 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
128 print '<input type="hidden" name="action" value="save">';
129 
130 $param = '';
131 $param.= '&search_event='.urlencode($search_event);
132 
133 $head=agenda_prepare_head();
134 
135 dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action');
136 
137 print $langs->trans("AgendaAutoActionDesc")."<br>\n";
138 print $langs->trans("OnlyActiveElementsAreShown", 'modules.php').'<br>';
139 print "<br>\n";
140 
141 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
142 print '<table class="noborder" width="100%">';
143 print '<tr class="liste_titre">';
144 print '<td class="liste_titre"><input type="text" name="search_event" value="'.dol_escape_htmltag($search_event).'"></td>';
145 print '<td class="liste_titre"></td>';
146 // Action column
147 print '<td class="liste_titre" align="right">';
148 $searchpicto=$form->showFilterButtons();
149 print $searchpicto;
150 print '</td>';
151 print '</tr>';
152 print '</tr>'."\n";
153 
154 print '<tr class="liste_titre">';
155 print '<th class="liste_titre" colspan="2">'.$langs->trans("ActionsEvents").'</th>';
156 print '<th class="liste_titre"><a href="'.$_SERVER["PHP_SELF"].'?action=selectall'.($param?$param:'').'">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone'.($param?$param:'').'">'.$langs->trans("None").'</a></th>';
157 print '</tr>'."\n";
158 // Show each trigger (list is in c_action_trigger)
159 if (! empty($triggers))
160 {
161  foreach ($triggers as $trigger)
162  {
163  $module = $trigger['element'];
164  if ($module == 'order_supplier' || $module == 'invoice_supplier') $module = 'fournisseur';
165  if ($module == 'shipping') $module = 'expedition_bon';
166  if ($module == 'member') $module = 'adherent';
167  if ($module == 'project') $module = 'projet';
168  if ($module == 'proposal_supplier') $module = 'supplier_proposal';
169 
170  //print 'module='.$module.'<br>';
171  if (! empty($conf->$module->enabled))
172  {
173  // Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED
174  if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue;
175  if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue;
176 
177  if ($search_event === '' || preg_match('/'.preg_quote($search_event,'/').'/i', $trigger['code']))
178  {
179  print '<tr class="oddeven">';
180  print '<td>'.$trigger['code'].'</td>';
181  print '<td>'.$trigger['label'].'</td>';
182  print '<td align="right" width="40">';
183  $key='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
184  $value=$conf->global->$key;
185  print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.((($action=='selectall'||$value) && $action!="selectnone")?' checked':'').'>';
186  print '</td></tr>'."\n";
187  }
188  }
189  }
190 }
191 print '</table>';
192 print '</div>';
193 
194 dol_fiche_end();
195 
196 print '<div class="center">';
197 print '<input type="submit" name="save" class="button" value="'.$langs->trans("Save").'">';
198 print "</div>";
199 
200 print "</form>\n";
201 
202 
203 print "<br>";
204 
205 // End of page
206 llxFooter();
207 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
agenda_prepare_head()
Prepare array with list of tabs.
Definition: agenda.lib.php:399
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).
Definition: admin.lib.php:510
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:44
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $wikihelp
View.
Definition: agenda.php:120