dolibarr  7.0.0-beta
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@capnetworks.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 $langs->load("admin");
35 $langs->load("other");
36 $langs->load("agenda");
37 
38 $action = GETPOST('action','alpha');
39 $cancel = GETPOST('cancel','alpha');
40 
41 $search_event = GETPOST('search_event', 'alpha');
42 
43 // Get list of triggers available
44 $sql = "SELECT a.rowid, a.code, a.label, a.elementtype";
45 $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
46 $sql.= " ORDER BY a.rang ASC";
47 $resql=$db->query($sql);
48 if ($resql)
49 {
50  $num = $db->num_rows($resql);
51  $i = 0;
52  while ($i < $num)
53  {
54  $obj = $db->fetch_object($resql);
55  $triggers[$i]['rowid'] = $obj->rowid;
56  $triggers[$i]['code'] = $obj->code;
57  $triggers[$i]['element'] = $obj->elementtype;
58  $triggers[$i]['label'] = ($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
59 
60  $i++;
61  }
62  $db->free($resql);
63 }
64 else
65 {
66  dol_print_error($db);
67 }
68 
69 
70 /*
71  * Actions
72  */
73 
74 // Purge search criteria
75 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
76 {
77  $search_event = '';
78 }
79 
80 if ($action == "save" && empty($cancel))
81 {
82  $i=0;
83 
84  $db->begin();
85 
86  foreach ($triggers as $trigger)
87  {
88  $keyparam='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
89  //print "param=".$param." - ".$_POST[$param];
90  if ($search_event === '' || preg_match('/'.preg_quote($search_event,'/').'/i', $keyparam))
91  {
92  $res = dolibarr_set_const($db,$keyparam,(GETPOST($keyparam,'alpha')?GETPOST($keyparam,'alpha'):''),'chaine',0,'',$conf->entity);
93  if (! $res > 0) $error++;
94  }
95  }
96 
97  if (! $error)
98  {
99  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
100  $db->commit();
101  }
102  else
103  {
104  setEventMessages($langs->trans("Error"),null, 'errors');
105  $db->rollback();
106  }
107 }
108 
109 if (preg_match('/set_(.*)/',$action,$reg))
110 {
111  $code=$reg[1];
112  $value=(GETPOST($code) ? GETPOST($code) : 1);
113  if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
114  {
115  Header("Location: ".$_SERVER["PHP_SELF"]);
116  exit;
117  }
118  else
119  {
120  dol_print_error($db);
121  }
122 }
123 
124 if (preg_match('/del_(.*)/',$action,$reg))
125 {
126  $code=$reg[1];
127  if (dolibarr_del_const($db, $code, $conf->entity) > 0)
128  {
129  Header("Location: ".$_SERVER["PHP_SELF"]);
130  exit;
131  }
132  else
133  {
134  dol_print_error($db);
135  }
136 }
137 
138 
143 $wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
144 llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
145 
146 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
147 print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
148 
149 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
150 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
151 print '<input type="hidden" name="action" value="save">';
152 
153 $param = '';
154 $param.= '&search_event='.urlencode($search_event);
155 
156 $head=agenda_prepare_head();
157 
158 dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action');
159 
160 print $langs->trans("AgendaAutoActionDesc")."<br>\n";
161 print $langs->trans("OnlyActiveElementsAreShown", 'modules.php').'<br>';
162 print "<br>\n";
163 
164 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
165 print '<table class="noborder" width="100%">';
166 print '<tr class="liste_titre">';
167 print '<td class="liste_titre"><input type="text" name="search_event" value="'.dol_escape_htmltag($search_event).'"></td>';
168 print '<td class="liste_titre"></td>';
169 // Action column
170 print '<td class="liste_titre" align="right">';
171 $searchpicto=$form->showFilterButtons();
172 print $searchpicto;
173 print '</td>';
174 print '</tr>';
175 print '</tr>'."\n";
176 
177 print '<tr class="liste_titre">';
178 print '<th class="liste_titre" colspan="2">'.$langs->trans("ActionsEvents").'</th>';
179 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>';
180 print '</tr>'."\n";
181 // Show each trigger (list is in c_action_trigger)
182 if (! empty($triggers))
183 {
184  foreach ($triggers as $trigger)
185  {
186  $module = $trigger['element'];
187  if ($module == 'order_supplier' || $module == 'invoice_supplier') $module = 'fournisseur';
188  if ($module == 'shipping') $module = 'expedition_bon';
189  if ($module == 'member') $module = 'adherent';
190  if ($module == 'project') $module = 'projet';
191  if ($module == 'proposal_supplier') $module = 'supplier_proposal';
192 
193  //print 'module='.$module.'<br>';
194  if (! empty($conf->$module->enabled))
195  {
196  // Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED
197  if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue;
198  if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue;
199 
200  if ($search_event === '' || preg_match('/'.preg_quote($search_event,'/').'/i', $trigger['code']))
201  {
202  print '<tr class="oddeven">';
203  print '<td>'.$trigger['code'].'</td>';
204  print '<td>'.$trigger['label'].'</td>';
205  print '<td align="right" width="40">';
206  $key='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
207  $value=$conf->global->$key;
208  print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.((($action=='selectall'||$value) && $action!="selectnone")?' checked':'').'>';
209  print '</td></tr>'."\n";
210  }
211  }
212  }
213 }
214 print '</table>';
215 print '</div>';
216 
217 dol_fiche_end();
218 
219 print '<div class="center">';
220 print '<input type="submit" name="save" class="button" value="'.$langs->trans("Save").'">';
221 print "</div>";
222 
223 print "</form>\n";
224 
225 
226 print "<br>";
227 
228 llxFooter();
229 
230 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
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:485
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
if(GETPOST('button_removefilter_x','alpha')||GETPOST('button_removefilter.x','alpha')||GETPOST('button_removefilter','alpha')) if($action=="save"&&empty($cancel)) if(preg_match('/set_(.*)/', $action, $reg)) if(preg_match('/del_(.*)/', $action, $reg) $wikihelp)
View.
Definition: agenda.php:143
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
Definition: admin.lib.php:410
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91
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:1013