dolibarr  7.0.0-beta
modAgenda.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003,2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
7  * Copyright (C) 2009-2011 Regis Houssin <regis.houssin@capnetworks.com>
8  * Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
9  * Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
10  * Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
33 include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
34 
39 {
40 
46  function __construct($db)
47  {
48  global $conf, $user;
49 
50  $this->db = $db;
51  $this->numero = 2400;
52 
53  $this->family = "projects";
54  $this->module_position = 15;
55  // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
56  $this->name = preg_replace('/^mod/i','',get_class($this));
57  $this->description = "Follow events or rendez-vous. Record manual events into Agendas or let application record automatic events for log tracking.";
58  // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59  $this->version = 'dolibarr';
60  // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
61  $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62  $this->special = 0;
63  $this->picto='action';
64 
65  // Data directories to create when module is enabled
66  $this->dirs = array("/agenda/temp");
67 
68  // Config pages
69  //-------------
70  $this->config_page_url = array("agenda_other.php");
71 
72  // Dependancies
73  //-------------
74  $this->depends = array();
75  $this->requiredby = array();
76  $this->langfiles = array("companies");
77 
78  // Module parts
79  $this->module_parts = array();
80 
81  // Constants
82  //-----------
83  // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
84  // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
85  // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
86  // );
87  $this->const = array();
88  //$this->const[] = array('AGENDA_DEFAULT_FILTER_TYPE', 'chaine', 'AC_NON_AUTO', 'Default filter for type of event on agenda', 0, 'current');
89  $sqlreadactions="SELECT code, label, description FROM ".MAIN_DB_PREFIX."c_action_trigger ORDER by rang";
90  $resql = $this->db->query($sqlreadactions);
91  if ($resql)
92  {
93  while ($obj = $this->db->fetch_object($sqlreadactions))
94  {
95  //if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue; // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation).
96  if (preg_match('/^TASK_/',$obj->code)) continue; // We don't track such events by default.
97  //if (preg_match('/^_MODIFY/',$obj->code)) continue; // We don't track such events by default.
98  $this->const[] = array('MAIN_AGENDA_ACTIONAUTO_'.$obj->code, "chaine", "1", '', 0, 'current');
99  }
100  }
101  else
102  {
103  dol_print_error($this->db->lasterror());
104  }
105 
106  // New pages on tabs
107  // -----------------
108  $this->tabs = array();
109 
110  // Boxes
111  //------
112  $this->boxes = array(0=>array('file'=>'box_actions.php','enabledbydefaulton'=>'Home'));
113 
114  // Cronjobs
115  //------------
116  $this->cronjobs = array(
117  0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>10, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'1'),
118  // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24)
119  );
120 
121  // Permissions
122  //------------
123  $this->rights = array();
124  $this->rights_class = 'agenda';
125  $r=0;
126 
127  // $this->rights[$r][0] Id permission (unique tous modules confondus)
128  // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
129  // $this->rights[$r][2] Non utilise
130  // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut
131  // $this->rights[$r][4] Niveau 1 pour nommer permission dans code
132  // $this->rights[$r][5] Niveau 2 pour nommer permission dans code
133  // $r++;
134 
135  $this->rights[$r][0] = 2401;
136  $this->rights[$r][1] = 'Read actions/tasks linked to his account';
137  $this->rights[$r][2] = 'r';
138  $this->rights[$r][3] = 0;
139  $this->rights[$r][4] = 'myactions';
140  $this->rights[$r][5] = 'read';
141  $r++;
142 
143  $this->rights[$r][0] = 2402;
144  $this->rights[$r][1] = 'Create/modify actions/tasks linked to his account';
145  $this->rights[$r][2] = 'w';
146  $this->rights[$r][3] = 0;
147  $this->rights[$r][4] = 'myactions';
148  $this->rights[$r][5] = 'create';
149  $r++;
150 
151  $this->rights[$r][0] = 2403;
152  $this->rights[$r][1] = 'Delete actions/tasks linked to his account';
153  $this->rights[$r][2] = 'w';
154  $this->rights[$r][3] = 0;
155  $this->rights[$r][4] = 'myactions';
156  $this->rights[$r][5] = 'delete';
157  $r++;
158 
159  $this->rights[$r][0] = 2411;
160  $this->rights[$r][1] = 'Read actions/tasks of others';
161  $this->rights[$r][2] = 'r';
162  $this->rights[$r][3] = 0;
163  $this->rights[$r][4] = 'allactions';
164  $this->rights[$r][5] = 'read';
165  $r++;
166 
167  $this->rights[$r][0] = 2412;
168  $this->rights[$r][1] = 'Create/modify actions/tasks of others';
169  $this->rights[$r][2] = 'w';
170  $this->rights[$r][3] = 0;
171  $this->rights[$r][4] = 'allactions';
172  $this->rights[$r][5] = 'create';
173  $r++;
174 
175  $this->rights[$r][0] = 2413;
176  $this->rights[$r][1] = 'Delete actions/tasks of others';
177  $this->rights[$r][2] = 'w';
178  $this->rights[$r][3] = 0;
179  $this->rights[$r][4] = 'allactions';
180  $this->rights[$r][5] = 'delete';
181  $r++;
182 
183  $this->rights[$r][0] = 2414;
184  $this->rights[$r][1] = 'Export actions/tasks of others';
185  $this->rights[$r][2] = 'w';
186  $this->rights[$r][3] = 0;
187  $this->rights[$r][4] = 'export';
188 
189  // Main menu entries
190  $this->menu = array(); // List of menus to add
191  $r=0;
192 
193  // Add here entries to declare new menus
194  // Example to declare the Top Menu entry:
195  // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu
196  // 'type'=>'top', // This is a Top menu entry
197  // 'titre'=>'MyModule top menu',
198  // 'mainmenu'=>'mymodule',
199  // 'url'=>'/mymodule/pagetop.php',
200  // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
201  // 'position'=>100,
202  // 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
203  // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
204  // 'target'=>'',
205  // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
206  // $r++;
207  $this->menu[$r]=array('fk_menu'=>0,
208  'type'=>'top',
209  'titre'=>'TMenuAgenda',
210  'mainmenu'=>'agenda',
211  'url'=>'/comm/action/index.php',
212  'langs'=>'agenda',
213  'position'=>15,
214  'perms'=>'$user->rights->agenda->myactions->read',
215  'enabled'=>'$conf->agenda->enabled',
216  'target'=>'',
217  'user'=>2);
218  $r++;
219 
220  $this->menu[$r]=array('fk_menu'=>'r=0',
221  'type'=>'left',
222  'titre'=>'Actions',
223  'mainmenu'=>'agenda',
224  'url'=>'/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda',
225  'langs'=>'agenda',
226  'position'=>100,
227  'perms'=>'$user->rights->agenda->myactions->read',
228  'enabled'=>'$conf->agenda->enabled',
229  'target'=>'',
230  'user'=>2);
231  $r++;
232  $this->menu[$r]=array('fk_menu'=>'r=1',
233  'type'=>'left',
234  'titre'=>'NewAction',
235  'mainmenu'=>'agenda',
236  'url'=>'/comm/action/card.php?mainmenu=agenda&amp;leftmenu=agenda&amp;action=create',
237  'langs'=>'commercial',
238  'position'=>101,
239  'perms'=>'($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)',
240  'enabled'=>'$conf->agenda->enabled',
241  'target'=>'',
242  'user'=>2);
243  $r++;
244  // Calendar
245  $this->menu[$r]=array('fk_menu'=>'r=1',
246  'type'=>'left',
247  'titre'=>'Agenda',
248  'mainmenu'=>'agenda',
249  'url'=>'/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda',
250  'langs'=>'agenda',
251  'position'=>140,
252  'perms'=>'$user->rights->agenda->myactions->read',
253  'enabled'=>'$conf->agenda->enabled',
254  'target'=>'',
255  'user'=>2);
256  $r++;
257  $this->menu[$r]=array('fk_menu'=>'r=3',
258  'type'=>'left',
259  'titre'=>'MenuToDoMyActions',
260  'mainmenu'=>'agenda',
261  'url'=>'/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filter=mine',
262  'langs'=>'agenda',
263  'position'=>141,
264  'perms'=>'$user->rights->agenda->myactions->read',
265  'enabled'=>'$conf->agenda->enabled',
266  'target'=>'',
267  'user'=>2);
268  $r++;
269  $this->menu[$r]=array('fk_menu'=>'r=3',
270  'type'=>'left',
271  'titre'=>'MenuDoneMyActions',
272  'mainmenu'=>'agenda',
273  'url'=>'/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filter=mine',
274  'langs'=>'agenda',
275  'position'=>142,
276  'perms'=>'$user->rights->agenda->myactions->read',
277  'enabled'=>'$conf->agenda->enabled',
278  'target'=>'',
279  'user'=>2);
280  $r++;
281  $this->menu[$r]=array('fk_menu'=>'r=3',
282  'type'=>'left',
283  'titre'=>'MenuToDoActions',
284  'mainmenu'=>'agenda',
285  'url'=>'/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filtert=-1',
286  'langs'=>'agenda',
287  'position'=>143,
288  'perms'=>'$user->rights->agenda->allactions->read',
289  'enabled'=>'$user->rights->agenda->allactions->read',
290  'target'=>'',
291  'user'=>2);
292  $r++;
293  $this->menu[$r]=array('fk_menu'=>'r=3',
294  'type'=>'left',
295  'titre'=>'MenuDoneActions',
296  'mainmenu'=>'agenda',
297  'url'=>'/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filtert=-1',
298  'langs'=>'agenda',
299  'position'=>144,
300  'perms'=>'$user->rights->agenda->allactions->read',
301  'enabled'=>'$user->rights->agenda->allactions->read',
302  'target'=>'',
303  'user'=>2);
304  $r++;
305  // List
306  $this->menu[$r]=array('fk_menu'=>'r=1',
307  'type'=>'left',
308  'titre'=>'List',
309  'mainmenu'=>'agenda',
310  'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda',
311  'langs'=>'agenda',
312  'position'=>110,
313  'perms'=>'$user->rights->agenda->myactions->read',
314  'enabled'=>'$conf->agenda->enabled',
315  'target'=>'',
316  'user'=>2);
317  $r++;
318  $this->menu[$r]=array('fk_menu'=>'r=8',
319  'type'=>'left',
320  'titre'=>'MenuToDoMyActions',
321  'mainmenu'=>'agenda',
322  'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filter=mine',
323  'langs'=>'agenda',
324  'position'=>111,
325  'perms'=>'$user->rights->agenda->myactions->read',
326  'enabled'=>'$conf->agenda->enabled',
327  'target'=>'',
328  'user'=>2);
329  $r++;
330  $this->menu[$r]=array('fk_menu'=>'r=8',
331  'type'=>'left',
332  'titre'=>'MenuDoneMyActions',
333  'mainmenu'=>'agenda',
334  'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filter=mine',
335  'langs'=>'agenda',
336  'position'=>112,
337  'perms'=>'$user->rights->agenda->myactions->read',
338  'enabled'=>'$conf->agenda->enabled',
339  'target'=>'',
340  'user'=>2);
341  $r++;
342  $this->menu[$r]=array('fk_menu'=>'r=8',
343  'type'=>'left',
344  'titre'=>'MenuToDoActions',
345  'mainmenu'=>'agenda',
346  'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filtert=-1',
347  'langs'=>'agenda',
348  'position'=>113,
349  'perms'=>'$user->rights->agenda->allactions->read',
350  'enabled'=>'$user->rights->agenda->allactions->read',
351  'target'=>'',
352  'user'=>2);
353  $r++;
354  $this->menu[$r]=array('fk_menu'=>'r=8',
355  'type'=>'left',
356  'titre'=>'MenuDoneActions',
357  'mainmenu'=>'agenda',
358  'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filtert=-1',
359  'langs'=>'agenda',
360  'position'=>114,
361  'perms'=>'$user->rights->agenda->allactions->read',
362  'enabled'=>'$user->rights->agenda->allactions->read',
363  'target'=>'',
364  'user'=>2);
365  $r++;
366  // Reports
367  $this->menu[$r]=array('fk_menu'=>'r=1',
368  'type'=>'left',
369  'titre'=>'Reportings',
370  'mainmenu'=>'agenda',
371  'url'=>'/comm/action/rapport/index.php?mainmenu=agenda&amp;leftmenu=agenda',
372  'langs'=>'agenda',
373  'position'=>160,
374  'perms'=>'$user->rights->agenda->allactions->read',
375  'enabled'=>'$conf->agenda->enabled',
376  'target'=>'',
377  'user'=>2);
378  $r++;
379 
380 
381  // Exports
382  //--------
383  $r=0;
384 
385  $r++;
386  $this->export_code[$r]=$this->rights_class.'_'.$r;
387  $this->export_label[$r]="ExportDataset_event1";
388  $this->export_permission[$r]=array(array("agenda","export"));
389  $this->export_fields_array[$r]=array('ac.id'=>"IdAgenda",'ac.ref_ext'=>"ExternalRef",'ac.datec'=>"DateCreation",'ac.datep'=>"DateActionBegin",
390  'ac.datep2'=>"DateActionEnd",'ac.label'=>"Title",'ac.note'=>"Note",'ac.percent'=>"Percent",'ac.durationp'=>"Duration",
391  'cac.libelle'=>"ActionType",
392  's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town',
393  'co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
394  's.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra');
395  $this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date",
396  'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric",
397  'ac.durationp'=>"Duree",
398  'cac.libelle'=>"List:c_actioncomm:libelle:id",
399  's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text',
400  'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text',
401  's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text');
402  $this->export_entities_array[$r]=array('ac.id'=>"action",'ac.ref_ext'=>"action",'ac.datec'=>"action",'ac.datep'=>"action",
403  'ac.datep2'=>"action",'ac.label'=>"action",'ac.note'=>"action",'ac.percent'=>"action",'ac.durationp'=>"action",
404  'cac.libelle'=>"action",
405  's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company',
406  'co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company',
407  's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company',);
408 
409  $this->export_sql_start[$r]='SELECT DISTINCT ';
410  $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
411  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
412  if (! empty($user) && empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
413  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
414  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
415  if (! empty($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
416  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
417  $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda').')';
418  if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR ac.fk_soc IS NULL)';
419  if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id);
420  $this->export_sql_end[$r] .=' ORDER BY ac.datep';
421 
422  }
423 
424 }
Class DolibarrModules.
</td >< tdclass="liste_titre"align="right"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="'.$i.'"'.$disabled.'></td >< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"></td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:554
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
Class to describe and enable/disable module Agenda.
__construct($db)
Constructor.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
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