dolibarr  9.0.0
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@inodbox.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->picto='action';
63 
64  // Data directories to create when module is enabled
65  $this->dirs = array("/agenda/temp");
66 
67  // Config pages
68  $this->config_page_url = array("agenda_other.php");
69 
70  // Dependencies
71  $this->hidden = false; // A condition to hide module
72  $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
73  $this->requiredby = array(); // List of module ids to disable if this one is disabled
74  $this->conflictwith = array(); // List of module class names as string this module is in conflict with
75  $this->langfiles = array("companies");
76  $this->phpmin = array(5,4); // Minimum version of PHP required by module
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($resql))
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  $datestart=dol_now();
117  $this->cronjobs = array(
118  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'=>'$conf->agenda->enabled', 'datestart'=>$datestart),
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'=>86,
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'=>'Calendar',
248  'mainmenu'=>'agenda',
249  'url'=>'/comm/action/index.php?action=default&amp;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?action=default&amp;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?action=default&amp;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?action=default&amp;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?action=default&amp;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 
305  // List
306  $r++;
307  $this->menu[$r]=array('fk_menu'=>'r=1',
308  'type'=>'left',
309  'titre'=>'List',
310  'mainmenu'=>'agenda',
311  'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda',
312  'langs'=>'agenda',
313  'position'=>110,
314  'perms'=>'$user->rights->agenda->myactions->read',
315  'enabled'=>'$conf->agenda->enabled',
316  'target'=>'',
317  'user'=>2);
318  $r++;
319  $this->menu[$r]=array('fk_menu'=>'r=8',
320  'type'=>'left',
321  'titre'=>'MenuToDoMyActions',
322  'mainmenu'=>'agenda',
323  'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filter=mine',
324  'langs'=>'agenda',
325  'position'=>111,
326  'perms'=>'$user->rights->agenda->myactions->read',
327  'enabled'=>'$conf->agenda->enabled',
328  'target'=>'',
329  'user'=>2);
330  $r++;
331  $this->menu[$r]=array('fk_menu'=>'r=8',
332  'type'=>'left',
333  'titre'=>'MenuDoneMyActions',
334  'mainmenu'=>'agenda',
335  'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filter=mine',
336  'langs'=>'agenda',
337  'position'=>112,
338  'perms'=>'$user->rights->agenda->myactions->read',
339  'enabled'=>'$conf->agenda->enabled',
340  'target'=>'',
341  'user'=>2);
342  $r++;
343  $this->menu[$r]=array('fk_menu'=>'r=8',
344  'type'=>'left',
345  'titre'=>'MenuToDoActions',
346  'mainmenu'=>'agenda',
347  'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filtert=-1',
348  'langs'=>'agenda',
349  'position'=>113,
350  'perms'=>'$user->rights->agenda->allactions->read',
351  'enabled'=>'$user->rights->agenda->allactions->read',
352  'target'=>'',
353  'user'=>2);
354  $r++;
355  $this->menu[$r]=array('fk_menu'=>'r=8',
356  'type'=>'left',
357  'titre'=>'MenuDoneActions',
358  'mainmenu'=>'agenda',
359  'url'=>'/comm/action/list.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filtert=-1',
360  'langs'=>'agenda',
361  'position'=>114,
362  'perms'=>'$user->rights->agenda->allactions->read',
363  'enabled'=>'$user->rights->agenda->allactions->read',
364  'target'=>'',
365  'user'=>2);
366  $r++;
367  // Reports
368  $this->menu[$r]=array('fk_menu'=>'r=1',
369  'type'=>'left',
370  'titre'=>'Reportings',
371  'mainmenu'=>'agenda',
372  'url'=>'/comm/action/rapport/index.php?mainmenu=agenda&amp;leftmenu=agenda',
373  'langs'=>'agenda',
374  'position'=>160,
375  'perms'=>'$user->rights->agenda->allactions->read',
376  'enabled'=>'$conf->agenda->enabled',
377  'target'=>'',
378  'user'=>2);
379  $r++;
380 
381 
382  // Exports
383  //--------
384  $r=0;
385 
386  $r++;
387  $this->export_code[$r]=$this->rights_class.'_'.$r;
388  $this->export_label[$r]="ExportDataset_event1";
389  $this->export_permission[$r]=array(array("agenda","export"));
390  $this->export_fields_array[$r]=array('ac.id'=>"IdAgenda",'ac.ref_ext'=>"ExternalRef",'ac.datec'=>"DateCreation",'ac.datep'=>"DateActionBegin",
391  'ac.datep2'=>"DateActionEnd",'ac.label'=>"Title",'ac.note'=>"Note",'ac.percent'=>"Percent",'ac.durationp'=>"Duration",
392  'cac.libelle'=>"ActionType",
393  's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town',
394  'co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
395  's.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra');
396  $this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date",
397  'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric",
398  'ac.durationp'=>"Duree",
399  'cac.libelle'=>"List:c_actioncomm:libelle:id",
400  's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text',
401  'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text',
402  's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text');
403  $this->export_entities_array[$r]=array('ac.id'=>"action",'ac.ref_ext'=>"action",'ac.datec'=>"action",'ac.datep'=>"action",
404  'ac.datep2'=>"action",'ac.label'=>"action",'ac.note'=>"action",'ac.percent'=>"action",'ac.durationp'=>"action",
405  'cac.libelle'=>"action",
406  's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company',
407  'co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company',
408  's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company',);
409 
410  $this->export_sql_start[$r]='SELECT DISTINCT ';
411  $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
412  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
413  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';
414  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
415  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
416  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';
417  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
418  $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda').')';
419  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)';
420  if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id);
421  $this->export_sql_end[$r] .=' ORDER BY ac.datep';
422  }
423 }
Class DolibarrModules.
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
</td >< td class="liste_titre" align="right"></td ></tr >< tr class="liste_titre">< input type="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< tr class="oddeven">< td >< input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td >< td >< input type="checkbox" class="check" name="choose'.$i.'"></td >< td class="nowrap"></td >< td >< input type="hidden" name="desc' . $i . '" value="' . dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:573
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
Class to describe and enable/disable module Agenda.
__construct($db)
Constructor.
dol_now($mode='gmt')
Return date for now.