dolibarr  19.0.0-dev
modProjet.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
5  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
6  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
7  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
8  * Copyright (C) 2014 Charles-Fr BENKE <charles.fr@benke.fr>
9  * Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <https://www.gnu.org/licenses/>.
23  */
24 
32 include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
33 
34 
39 {
45  public function __construct($db)
46  {
47  global $conf;
48 
49  $this->db = $db;
50  $this->numero = 400;
51 
52  $this->family = "projects";
53  $this->module_position = '14';
54  // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
55  $this->name = preg_replace('/^mod/i', '', get_class($this));
56  $this->description = "Gestion des projets";
57  // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
58  $this->version = 'dolibarr';
59 
60  $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
61  $this->config_page_url = array("project.php@projet");
62  $this->picto = 'project';
63 
64  // Data directories to create when module is enabled
65  $this->dirs = array("/projet/temp");
66 
67  // Dependencies
68  $this->hidden = false; // A condition to hide module
69  $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
70  $this->requiredby = array('modEventOrganization'); // List of module ids to disable if this one is disabled
71  $this->conflictwith = array(); // List of module class names as string this module is in conflict with
72  $this->phpmin = array(7, 0); // Minimum version of PHP required by module
73  $this->langfiles = array('projects');
74 
75  // Constants
76  $this->const = array();
77  $r = 0;
78 
79  $this->const[$r][0] = "PROJECT_ADDON_PDF";
80  $this->const[$r][1] = "chaine";
81  $this->const[$r][2] = "baleine";
82  $this->const[$r][3] = 'Name of PDF/ODT project manager class';
83  $this->const[$r][4] = 0;
84  $r++;
85 
86  $this->const[$r][0] = "PROJECT_ADDON";
87  $this->const[$r][1] = "chaine";
88  $this->const[$r][2] = "mod_project_simple";
89  $this->const[$r][3] = 'Name of Numbering Rule project manager class';
90  $this->const[$r][4] = 0;
91  $r++;
92 
93  $this->const[$r][0] = "PROJECT_ADDON_PDF_ODT_PATH";
94  $this->const[$r][1] = "chaine";
95  $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/projects";
96  $this->const[$r][3] = "";
97  $this->const[$r][4] = 0;
98  $r++;
99 
100  $this->const[$r][0] = "PROJECT_TASK_ADDON_PDF";
101  $this->const[$r][1] = "chaine";
102  $this->const[$r][2] = "";
103  $this->const[$r][3] = 'Name of PDF/ODT tasks manager class';
104  $this->const[$r][4] = 0;
105  $r++;
106 
107  $this->const[$r][0] = "PROJECT_TASK_ADDON";
108  $this->const[$r][1] = "chaine";
109  $this->const[$r][2] = "mod_task_simple";
110  $this->const[$r][3] = 'Name of Numbering Rule task manager class';
111  $this->const[$r][4] = 0;
112  $r++;
113 
114  $this->const[$r][0] = "PROJECT_TASK_ADDON_PDF_ODT_PATH";
115  $this->const[$r][1] = "chaine";
116  $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/tasks";
117  $this->const[$r][3] = "";
118  $this->const[$r][4] = 0;
119  $r++;
120 
121  $this->const[$r][0] = "PROJECT_USE_OPPORTUNITIES";
122  $this->const[$r][1] = "chaine";
123  $this->const[$r][2] = "1";
124  $this->const[$r][3] = "";
125  $this->const[$r][4] = 0;
126  $r++;
127 
128  // Boxes
129  $this->boxes = array(
130  0=>array('file'=>'box_project.php', 'enabledbydefaulton'=>'Home'), // open projects
131  1=>array('file'=>'box_project_opportunities.php', 'enabledbydefaulton'=>'Home'), // open opportunities
132  2=>array('file'=>'box_task.php', 'enabledbydefaulton'=>'Home'),
133  3=>array('file'=>'box_validated_projects.php', 'enabledbydefaulton'=>'Home'), // task without timespent
134  4=>array('file'=>'box_funnel_of_prospection.php', 'enabledbydefaulton'=>'Home'),
135  );
136 
137  // Permissions
138  $this->rights = array();
139  $this->rights_class = 'projet';
140  $r = 0;
141 
142  $r++;
143  $this->rights[$r][0] = 41; // id de la permission
144  $this->rights[$r][1] = "Read projects and tasks (shared projects or projects I am contact for)"; // libelle de la permission
145  $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
146  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
147  $this->rights[$r][4] = 'lire';
148 
149  $r++;
150  $this->rights[$r][0] = 42; // id de la permission
151  $this->rights[$r][1] = "Create/modify projects and tasks (shared projects or projects I am contact for)"; // libelle de la permission
152  $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
153  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
154  $this->rights[$r][4] = 'creer';
155 
156  $r++;
157  $this->rights[$r][0] = 44; // id de la permission
158  $this->rights[$r][1] = "Delete project and tasks (shared projects or projects I am contact for)"; // libelle de la permission
159  $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
160  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
161  $this->rights[$r][4] = 'supprimer';
162 
163  $r++;
164  $this->rights[$r][0] = 45; // id de la permission
165  $this->rights[$r][1] = "Export projects"; // libelle de la permission
166  $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
167  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
168  $this->rights[$r][4] = 'export';
169 
170  $r++;
171  $this->rights[$r][0] = 141; // id de la permission
172  $this->rights[$r][1] = "Read all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
173  $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
174  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
175  $this->rights[$r][4] = 'all';
176  $this->rights[$r][5] = 'lire';
177 
178  $r++;
179  $this->rights[$r][0] = 142; // id de la permission
180  $this->rights[$r][1] = "Create/modify all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
181  $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
182  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
183  $this->rights[$r][4] = 'all';
184  $this->rights[$r][5] = 'creer';
185 
186  $r++;
187  $this->rights[$r][0] = 144; // id de la permission
188  $this->rights[$r][1] = "Delete all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
189  $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
190  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
191  $this->rights[$r][4] = 'all';
192  $this->rights[$r][5] = 'supprimer';
193 
194  $r++;
195  $this->rights[$r][0] = 145; // id de la permission
196  $this->rights[$r][1] = "Can enter time consumed on assigned tasks (timesheet)"; // libelle de la permission
197  $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
198  $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
199  $this->rights[$r][4] = 'time';
200 
201  // Menus
202  //-------
203  $this->menu = 1; // This module add menu entries. They are coded into menu manager.
204 
205 
206  // Exports
207  //--------
208  $r = 1;
209 
210  $this->export_code[$r] = $this->rights_class.'_'.$r;
211  $this->export_label[$r] = 'ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
212  $this->export_permission[$r] = array(array("projet", "export"));
213  $this->export_dependencies_array[$r] = array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
214 
215  $this->export_TypeFields_array[$r] = array(
216  's.rowid'=>"Numeric", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label',
217  's.phone'=>'Text', 's.email'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text',
218  'p.rowid'=>"Numeric", 'p.ref'=>"Text", 'p.title'=>"Text",
219  'p.usage_opportunity'=>'Boolean', 'p.usage_task'=>'Boolean', 'p.usage_bill_time'=>'Boolean',
220  'p.datec'=>"Date", 'p.dateo'=>"Date", 'p.datee'=>"Date", 'p.fk_statut'=>'Status', 'cls.code'=>"Text", 'p.opp_percent'=>'Numeric', 'p.opp_amount'=>'Numeric', 'p.description'=>"Text", 'p.entity'=>'Numeric', 'p.budget_amount'=>'Numeric',
221  'pt.rowid'=>'Numeric', 'pt.ref'=>'Text', 'pt.label'=>'Text', 'pt.dateo'=>"Date", 'pt.datee'=>"Date", 'pt.duration_effective'=>"Duree", 'pt.planned_workload'=>"Numeric", 'pt.progress'=>"Numeric", 'pt.description'=>"Text",
222  'ptt.rowid'=>'Numeric', 'ptt.element_date'=>'Date', 'ptt.element_duration'=>"Duree", 'ptt.fk_user'=>"FormSelect:select_dolusers", 'ptt.note'=>"Text"
223  );
224  $this->export_entities_array[$r] = array(
225  's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company',
226  's.phone'=>'company', 's.email'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company'
227  );
228  $this->export_fields_array[$r] = array(
229  's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 's.fk_pays'=>'Country',
230  's.phone'=>'Phone', 's.email'=>'Email', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode',
231  'p.rowid'=>"ProjectId", 'p.ref'=>"RefProject", 'p.title'=>'ProjectLabel',
232  'p.usage_opportunity'=>'ProjectFollowOpportunity', 'p.usage_task'=>'ProjectFollowTasks', 'p.usage_bill_time'=>'BillTime',
233  'p.datec'=>"DateCreation", 'p.dateo'=>"DateStart", 'p.datee'=>"DateEnd", 'p.fk_statut'=>'ProjectStatus', 'cls.code'=>'OpportunityStatus', 'p.opp_percent'=>'OpportunityProbability', 'p.opp_amount'=>'OpportunityAmount', 'p.budget_amount'=>'Budget', 'p.description'=>"Description"
234  );
235  // Add multicompany field
236  if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) {
237  $nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1
238  if (isModEnabled('multicompany') && $nbofallowedentities > 1) {
239  $this->export_fields_array[$r] += array('p.entity'=>'Entity');
240  }
241  }
242  if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
243  unset($this->export_fields_array[$r]['p.opp_percent']);
244  unset($this->export_fields_array[$r]['p.opp_amount']);
245  unset($this->export_fields_array[$r]['cls.code']);
246  }
247 
248  // Add fields for project
249  $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array());
250  // Add extra fields for project
251  $keyforselect = 'projet';
252  $keyforelement = 'project';
253  $keyforaliasextra = 'extra';
254  include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
255  // Add fields for tasks
256  $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pt.rowid'=>'TaskId', 'pt.ref'=>'RefTask', 'pt.label'=>'LabelTask', 'pt.dateo'=>"TaskDateStart", 'pt.datee'=>"TaskDateEnd", 'pt.duration_effective'=>"DurationEffective", 'pt.planned_workload'=>"PlannedWorkload", 'pt.progress'=>"Progress", 'pt.description'=>"TaskDescription"));
257  $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask', 'pt.ref'=>'projecttask', 'pt.label'=>'projecttask', 'pt.dateo'=>"projecttask", 'pt.datee'=>"projecttask", 'pt.duration_effective'=>"projecttask", 'pt.planned_workload'=>"projecttask", 'pt.progress'=>"projecttask", 'pt.description'=>"projecttask"));
258  // Add extra fields for task
259  $keyforselect = 'projet_task';
260  $keyforelement = 'projecttask';
261  $keyforaliasextra = 'extra2';
262  include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
263  // End add extra fields
264  $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime', 'ptt.element_date'=>'TaskTimeDate', 'ptt.element_duration'=>"TimesSpent", 'ptt.fk_user'=>"TaskTimeUser", 'ptt.note'=>"TaskTimeNote"));
265  $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time', 'ptt.element_date'=>'task_time', 'ptt.element_duration'=>"task_time", 'ptt.fk_user'=>"task_time", 'ptt.note'=>"task_time"));
266  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
267  $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('f.ref'=>"Billed"));
268  $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('f.ref'=>"task_time"));
269  }
270  $this->export_sql_start[$r] = 'SELECT DISTINCT ';
271  $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'projet as p';
272  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
273  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
274  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
275  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
276  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."element_time as ptt ON (pt.rowid = ptt.fk_element AND ptt.elementtype = 'task')";
277  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
278  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
279  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON ptt.invoice_id = f.rowid';
280  }
281  $this->export_sql_end[$r] .= " WHERE p.entity IN (".getEntity('project').")";
282 
283  // Import project/opportunities
284  $r++;
285  $this->import_code[$r] = 'projects';
286  $this->import_label[$r] = 'ImportDatasetProjects';
287  $this->import_icon[$r] = 'project';
288  $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
289  $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet', 'extra'=>MAIN_DB_PREFIX.'projet_extrafields'); // List of tables to insert into (insert done in same order)
290  $this->import_fields_array[$r] = array('t.ref'=>'ProjectRef*', 't.title'=>'Label*', 't.description'=>"Description", 't.fk_soc' => 'ThirdPartyName', 't.public'=>"Public", 't.fk_statut'=>"Status");
291  $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('t.fk_opp_status'=>"OpportunityStatus", 't.opp_percent'=>"OpportunityProbability", 't.opp_amount'=>"OpportunityAmount", 't.note_public'=>"NotePublic", 't.note_private'=>"NotePrivate", 't.budget_amount'=>"Budget", 't.dateo'=>"DateStart", 't.datee'=>"DateEnd"));
292  // Add extra fields
293  $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'projet' AND entity IN (0,".$conf->entity.")";
294  $resql = $this->db->query($sql);
295  if ($resql) { // This can fail when class is used on old database (during migration for example)
296  while ($obj = $this->db->fetch_object($resql)) {
297  $fieldname = 'extra.'.$obj->name;
298  $fieldlabel = ucfirst($obj->label);
299  $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
300  }
301  }
302  // End add extra fields
303  $this->import_fieldshidden_array[$r] = array('t.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
304  $this->import_convertvalue_array[$r] = array(
305  't.ref'=>array('rule'=>'getrefifauto', 'class'=>(empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON), 'path'=>"/core/modules/project/".(empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON).'.php'),
306  't.fk_soc' => array(
307  'rule' => 'fetchidfromref',
308  'file' => '/societe/class/societe.class.php',
309  'class' => 'Societe',
310  'method' => 'fetch',
311  'element' => 'ThirdParty'
312  ),
313  );
314  //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
315  $this->import_regex_array[$r] = array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
316  $this->import_examplevalues_array[$r] = array('t.fk_soc'=>'ThirdParty', 't.ref'=>"auto or PJ2010-1234", 't.title'=>"My project", 't.fk_statut'=>'0,1 or 2', 't.datec'=>'1972-10-10', 't.note_private'=>"My private note", 't.note_public'=>"My public note");
317 
318  // Import list of tasks
319  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
320  $r++;
321  $this->import_code[$r] = 'tasksofprojects';
322  $this->import_label[$r] = 'ImportDatasetTasks';
323  $this->import_icon[$r] = 'task';
324  $this->import_entities_array[$r] = array('t.fk_projet'=>'project'); // We define here only fields that use another icon that the one defined into import_icon
325  $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order)
326  $this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation");
327  // Add extra fields
328  $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";
329  $resql = $this->db->query($sql);
330  if ($resql) { // This can fail when class is used on old database (during migration for example)
331  while ($obj = $this->db->fetch_object($resql)) {
332  $fieldname = 'extra.'.$obj->name;
333  $fieldlabel = ucfirst($obj->label);
334  $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
335  }
336  }
337  // End add extra fields
338  $this->import_fieldshidden_array[$r] = array('t.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
339  $this->import_convertvalue_array[$r] = array(
340  't.fk_projet'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project'),
341  't.ref'=>array('rule'=>'getrefifauto', 'class'=>(empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON), 'path'=>"/core/modules/project/task/".(empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON).'.php')
342  );
343  //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
344  $this->import_regex_array[$r] = array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
345  $this->import_examplevalues_array[$r] = array('t.fk_projet'=>'MyProjectRef', 't.ref'=>"auto or TK2010-1234", 't.label'=>"My task", 't.progress'=>"0 (not started) to 100 (finished)", 't.datec'=>'1972-10-10', 't.note_private'=>"My private note", 't.note_public'=>"My public note");
346  }
347  }
348 
349 
358  public function init($options = '')
359  {
360  global $conf, $langs;
361 
362  // Permissions
363  $this->remove($options);
364 
365  //ODT template for project
366  $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt';
367  $dirodt = DOL_DATA_ROOT.'/doctemplates/projects';
368  $dest = $dirodt.'/template_project.odt';
369 
370  if (file_exists($src) && !file_exists($dest)) {
371  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
372  dol_mkdir($dirodt);
373  $result = dol_copy($src, $dest, 0, 0);
374  if ($result < 0) {
375  $langs->load("errors");
376  $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
377  return 0;
378  }
379  }
380 
381  //ODT template for tasks
382  $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt';
383  $dirodt = DOL_DATA_ROOT.'/doctemplates/tasks';
384  $dest = $dirodt.'/template_task_summary.odt';
385 
386  if (file_exists($src) && !file_exists($dest)) {
387  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
388  dol_mkdir($dirodt);
389  $result = dol_copy($src, $dest, 0, 0);
390  if ($result < 0) {
391  $langs->load("errors");
392  $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
393  return 0;
394  }
395  }
396 
397  $sql = array();
398  $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".((int) $conf->entity);
399  $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".((int) $conf->entity).")";
400  $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".((int) $conf->entity);
401  $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".((int) $conf->entity).")";
402  $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".((int) $conf->entity);
403  $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".((int) $conf->entity).")";
404 
405 
406  return $this->_init($sql, $options);
407  }
408 }
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
Class to describe and enable module Projet.
init($options='')
Function called when module is enabled.
__construct($db)
Constructor.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
Definition: files.lib.php:717
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:123