dolibarr  13.0.2
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 <https://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', 'aZ09');
38 $cancel = GETPOST('cancel', 'alpha');
39 
40 $search_event = GETPOST('search_event', 'alpha');
41 
42 // Get list of triggers available
43 $triggers = array();
44 $sql = "SELECT a.rowid, a.code, a.label, a.elementtype, a.rang as position";
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  $triggers[$i]['position'] = $obj->position;
60 
61  $i++;
62  }
63  $db->free($resql);
64 } else {
65  dol_print_error($db);
66 }
67 
68 //$triggers = dol_sort_array($triggers, 'code', 'asc', 0, 0, 1);
69 
70 
71 /*
72  * Actions
73  */
74 
75 // Purge search criteria
76 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
77 {
78  $search_event = '';
79  $action = '';
80 }
81 
82 if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) // To avoid the save when we click on search
83 {
84  $action = '';
85 }
86 
87 if ($action == "save" && empty($cancel))
88 {
89  $i = 0;
90 
91  $db->begin();
92 
93  foreach ($triggers as $trigger)
94  {
95  $keyparam = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
96  //print "param=".$param." - ".$_POST[$param];
97  if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam))
98  {
99  $res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha') ?GETPOST($keyparam, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
100  if (!($res > 0)) $error++;
101  }
102  }
103 
104  if (!$error)
105  {
106  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
107  $db->commit();
108  } else {
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="'.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 print dol_get_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action');
136 
137 print '<span class="opacitymedium">'.$langs->trans("AgendaAutoActionDesc")." ".$langs->trans("OnlyActiveElementsAreShown", 'modules.php').'</span><br>';
138 print "<br>\n";
139 
140 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
141 print '<table class="noborder centpercent">';
142 print '<tr class="liste_titre">';
143 print '<td class="liste_titre"><input type="text" name="search_event" value="'.dol_escape_htmltag($search_event).'"></td>';
144 print '<td class="liste_titre"></td>';
145 // Action column
146 print '<td class="liste_titre maxwidthsearch">';
147 $searchpicto = $form->showFilterButtons();
148 print $searchpicto;
149 print '</td>';
150 print '</tr>';
151 print '</tr>'."\n";
152 
153 print '<tr class="liste_titre">';
154 print '<th class="liste_titre" colspan="2">'.$langs->trans("ActionsEvents").'</th>';
155 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>';
156 print '</tr>'."\n";
157 // Show each trigger (list is in c_action_trigger)
158 if (!empty($triggers))
159 {
160  foreach ($triggers as $trigger)
161  {
162  $module = $trigger['element'];
163  if ($module == 'order_supplier' || $module == 'invoice_supplier') $module = 'fournisseur';
164  if ($module == 'shipping') $module = 'expedition_bon';
165  if ($module == 'member') $module = 'adherent';
166  if ($module == 'project') $module = 'projet';
167  if ($module == 'proposal_supplier') $module = 'supplier_proposal';
168  if ($module == 'contact') $module = 'societe';
169 
170  // If 'element' value is myobject@mymodule instead of mymodule
171  $tmparray = explode('@', $module);
172  if (!empty($tmparray[1])) {
173  $module = $tmparray[1];
174  }
175 
176  //print 'module='.$module.' code='.$trigger['code'].'<br>';
177  if (!empty($conf->$module->enabled))
178  {
179  // Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED
180  if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue;
181  if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue;
182 
183  if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $trigger['code']))
184  {
185  print '<tr class="oddeven">';
186  print '<td>'.$trigger['code'].'</td>';
187  print '<td>'.$trigger['label'].'</td>';
188  print '<td class="right" width="40">';
189  $key = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
190  $value = $conf->global->$key;
191  print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.((($action == 'selectall' || $value) && $action != "selectnone") ? ' checked' : '').'>';
192  print '</td></tr>'."\n";
193  }
194  }
195  }
196 }
197 print '</table>';
198 print '</div>';
199 
201 
202 print '<div class="center">';
203 print '<input type="submit" name="save" class="button button-save" value="'.$langs->trans("Save").'">';
204 print "</div>";
205 
206 print "</form>\n";
207 
208 
209 print "<br>";
210 
211 // End of page
212 llxFooter();
213 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
agenda_prepare_head()
Prepare array with list of tabs.
Definition: agenda.lib.php:358
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:575
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
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59