dolibarr 21.0.0-alpha
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
32include_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 projects";
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 // Cronjobs
137 $this->cronjobs[] = array(
138 'label' => 'WeeklyWorkingHoursReport',
139 'jobtype' => 'method',
140 'class' => 'projet/class/project.class.php',
141 'objectname' => 'Project',
142 'method' => 'createWeeklyReport',
143 'parameters' => '',
144 'comment' => 'Generates and sends a weekly report on time worked',
145 'frequency' => 1,
146 'unitfrequency' => 86400 * 7,
147 'status' => 0,
148 'test' => '$conf->projet->enabled',
149 );
150 // Permissions
151 $this->rights = array();
152 $this->rights_class = 'projet';
153 $r = 0;
154
155 $r++;
156 $this->rights[$r][0] = 41; // id de la permission
157 $this->rights[$r][1] = "Read projects and tasks (shared projects or projects I am contact for)"; // libelle de la permission
158 $this->rights[$r][2] = 'r'; // type de la permission (deprecated)
159 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
160 $this->rights[$r][4] = 'lire';
161
162 $r++;
163 $this->rights[$r][0] = 42; // id de la permission
164 $this->rights[$r][1] = "Create/modify projects and tasks (shared projects or projects I am contact for)"; // libelle de la permission
165 $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
166 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
167 $this->rights[$r][4] = 'creer';
168
169 $r++;
170 $this->rights[$r][0] = 44; // id de la permission
171 $this->rights[$r][1] = "Delete project and tasks (shared projects or projects I am contact for)"; // libelle de la permission
172 $this->rights[$r][2] = 'd'; // type de la permission (deprecated)
173 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
174 $this->rights[$r][4] = 'supprimer';
175
176 $r++;
177 $this->rights[$r][0] = 45; // id de la permission
178 $this->rights[$r][1] = "Export projects"; // libelle de la permission
179 $this->rights[$r][2] = 'd'; // type de la permission (deprecated)
180 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
181 $this->rights[$r][4] = 'export';
182
183 $r++;
184 $this->rights[$r][0] = 141; // id de la permission
185 $this->rights[$r][1] = "Read all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
186 $this->rights[$r][2] = 'r'; // type de la permission (deprecated)
187 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
188 $this->rights[$r][4] = 'all';
189 $this->rights[$r][5] = 'lire';
190
191 $r++;
192 $this->rights[$r][0] = 142; // id de la permission
193 $this->rights[$r][1] = "Create/modify all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
194 $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
195 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
196 $this->rights[$r][4] = 'all';
197 $this->rights[$r][5] = 'creer';
198
199 $r++;
200 $this->rights[$r][0] = 144; // id de la permission
201 $this->rights[$r][1] = "Delete all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
202 $this->rights[$r][2] = 'd'; // type de la permission (deprecated)
203 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
204 $this->rights[$r][4] = 'all';
205 $this->rights[$r][5] = 'supprimer';
206
207 $r++;
208 $this->rights[$r][0] = 145; // id de la permission
209 $this->rights[$r][1] = "Can enter time consumed on assigned tasks (timesheet)"; // libelle de la permission
210 $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
211 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
212 $this->rights[$r][4] = 'time';
213
214 // Menus
215 //-------
216 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
217
218
219 // Exports
220 //--------
221 $r = 1;
222
223 $this->export_code[$r] = $this->rights_class.'_'.$r;
224 $this->export_label[$r] = 'ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
225 $this->export_permission[$r] = array(array("projet", "export"));
226 $this->export_dependencies_array[$r] = array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
227
228 $this->export_TypeFields_array[$r] = array(
229 's.rowid'=>"Numeric", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label',
230 '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',
231 'p.rowid'=>"Numeric", 'p.ref'=>"Text", 'p.title'=>"Text",
232 'p.usage_opportunity'=>'Boolean', 'p.usage_task'=>'Boolean', 'p.usage_bill_time'=>'Boolean',
233 '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',
234 '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",
235 'ptt.rowid'=>'Numeric', 'ptt.element_date'=>'Date', 'ptt.element_duration'=>"Duree", 'ptt.fk_user'=>"FormSelect:select_dolusers", 'ptt.note'=>"Text"
236 );
237 $this->export_entities_array[$r] = array(
238 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company',
239 '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'
240 );
241 $this->export_fields_array[$r] = array(
242 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 's.fk_pays'=>'Country',
243 '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',
244 'p.rowid'=>"ProjectId", 'p.ref'=>"RefProject", 'p.title'=>'ProjectLabel',
245 'p.usage_opportunity'=>'ProjectFollowOpportunity', 'p.usage_task'=>'ProjectFollowTasks', 'p.usage_bill_time'=>'BillTime',
246 '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"
247 );
248 // Add multicompany field
249 if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) {
250 $nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1
251 if (isModEnabled('multicompany') && $nbofallowedentities > 1) {
252 $this->export_fields_array[$r] += array('p.entity'=>'Entity');
253 }
254 }
255 if (!getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
256 unset($this->export_fields_array[$r]['p.opp_percent']);
257 unset($this->export_fields_array[$r]['p.opp_amount']);
258 unset($this->export_fields_array[$r]['cls.code']);
259 }
260
261 // Add fields for project
262 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array());
263 // Add extra fields for project
264 $keyforselect = 'projet';
265 $keyforelement = 'project';
266 $keyforaliasextra = 'extra';
267 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
268 // Add fields for tasks
269 $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", 'pt.billable'=>"Billable"));
270 $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"));
271 // Add extra fields for task
272 $keyforselect = 'projet_task';
273 $keyforelement = 'projecttask';
274 $keyforaliasextra = 'extra2';
275 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
276 // End add extra fields
277 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime', 'ptt.element_date'=>'TaskTimeDate', 'ptt.element_duration'=>"TimeSpent", 'ptt.fk_user'=>"TaskTimeUser", 'ptt.note'=>"TaskTimeNote"));
278 $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"));
279 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
280 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('f.ref'=>"Billed"));
281 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('f.ref'=>"task_time"));
282 }
283 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
284 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'projet as p';
285 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
286 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
287 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
288 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
289 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."element_time as ptt ON (pt.rowid = ptt.fk_element AND ptt.elementtype = 'task')";
290 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
291 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
292 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON ptt.invoice_id = f.rowid';
293 }
294 $this->export_sql_end[$r] .= " WHERE p.entity IN (".getEntity('project').")";
295
296 // Import project/opportunities
297 $r++;
298 $this->import_code[$r] = 'projects';
299 $this->import_label[$r] = 'ImportDatasetProjects';
300 $this->import_icon[$r] = 'project';
301 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
302 $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)
303 $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");
304 $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"));
305 // Add extra fields
306 $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'projet' AND entity IN (0,".$conf->entity.")";
307 $resql = $this->db->query($sql);
308 if ($resql) { // This can fail when class is used on old database (during migration for example)
309 while ($obj = $this->db->fetch_object($resql)) {
310 $fieldname = 'extra.'.$obj->name;
311 $fieldlabel = ucfirst($obj->label);
312 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
313 }
314 }
315 // End add extra fields
316 $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)
317 $this->import_convertvalue_array[$r] = array(
318 't.ref'=>array('rule'=>'getrefifauto', 'class'=>(!getDolGlobalString('PROJECT_ADDON') ? 'mod_project_simple' : $conf->global->PROJECT_ADDON), 'path'=>"/core/modules/project/".(!getDolGlobalString('PROJECT_ADDON') ? 'mod_project_simple' : $conf->global->PROJECT_ADDON).'.php'),
319 't.fk_soc' => array(
320 'rule' => 'fetchidfromref',
321 'file' => '/societe/class/societe.class.php',
322 'class' => 'Societe',
323 'method' => 'fetch',
324 'element' => 'ThirdParty'
325 ),
326 );
327 //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
328 $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])?$');
329 $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");
330
331 // Import list of tasks
332 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
333 $r++;
334 $this->import_code[$r] = 'tasksofprojects';
335 $this->import_label[$r] = 'ImportDatasetTasks';
336 $this->import_icon[$r] = 'task';
337 $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
338 $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)
339 $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");
340 // Add extra fields
341 $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";
342 $resql = $this->db->query($sql);
343 if ($resql) { // This can fail when class is used on old database (during migration for example)
344 while ($obj = $this->db->fetch_object($resql)) {
345 $fieldname = 'extra.'.$obj->name;
346 $fieldlabel = ucfirst($obj->label);
347 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
348 }
349 }
350 // End add extra fields
351 $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)
352 $this->import_convertvalue_array[$r] = array(
353 't.fk_projet'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project'),
354 't.ref'=>array('rule'=>'getrefifauto', 'class'=>(!getDolGlobalString('PROJECT_TASK_ADDON') ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON), 'path'=>"/core/modules/project/task/".(!getDolGlobalString('PROJECT_TASK_ADDON') ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON).'.php')
355 );
356 //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
357 $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])?$');
358 $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");
359 }
360 }
361
362
371 public function init($options = '')
372 {
373 global $conf, $langs;
374
375 // Permissions
376 $this->remove($options);
377
378 //ODT template for project
379 $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt';
380 $dirodt = DOL_DATA_ROOT.'/doctemplates/projects';
381 $dest = $dirodt.'/template_project.odt';
382
383 if (file_exists($src) && !file_exists($dest)) {
384 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
385 dol_mkdir($dirodt);
386 $result = dol_copy($src, $dest, 0, 0);
387 if ($result < 0) {
388 $langs->load("errors");
389 $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
390 return 0;
391 }
392 }
393
394 //ODT template for tasks
395 $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt';
396 $dirodt = DOL_DATA_ROOT.'/doctemplates/tasks';
397 $dest = $dirodt.'/template_task_summary.odt';
398
399 if (file_exists($src) && !file_exists($dest)) {
400 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
401 dol_mkdir($dirodt);
402 $result = dol_copy($src, $dest, 0, 0);
403 if ($result < 0) {
404 $langs->load("errors");
405 $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
406 return 0;
407 }
408 }
409
410 $sql = array();
411 $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);
412 $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".((int) $conf->entity).")";
413 $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".((int) $conf->entity);
414 $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".((int) $conf->entity).")";
415 $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".((int) $conf->entity);
416 $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".((int) $conf->entity).")";
417
418
419 return $this->_init($sql, $options);
420 }
421}
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.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after 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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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:142