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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
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 <https://www.gnu.org/licenses/>.
24 */
25
33include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
34
35
40{
46 public function __construct($db)
47 {
48 global $conf;
49
50 $this->db = $db;
51 $this->numero = 400;
52
53 $this->family = "projects";
54 $this->module_position = '14';
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 = "Gestion des projects";
58 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59 $this->version = 'dolibarr';
60
61 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62 $this->config_page_url = array("project.php@projet");
63 $this->picto = 'project';
64
65 // Data directories to create when module is enabled
66 $this->dirs = array("/projet/temp");
67
68 // Dependencies
69 $this->hidden = false; // A condition to hide module
70 $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
71 $this->requiredby = array('modEventOrganization'); // List of module ids to disable if this one is disabled
72 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
73 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
74 $this->langfiles = array('projects');
75
76 // Constants
77 $this->const = array();
78 $r = 0;
79
80 $this->const[$r][0] = "PROJECT_ADDON_PDF";
81 $this->const[$r][1] = "chaine";
82 $this->const[$r][2] = "baleine";
83 $this->const[$r][3] = 'Name of PDF/ODT project manager class';
84 $this->const[$r][4] = 0;
85 $r++;
86
87 $this->const[$r][0] = "PROJECT_ADDON";
88 $this->const[$r][1] = "chaine";
89 $this->const[$r][2] = "mod_project_simple";
90 $this->const[$r][3] = 'Name of Numbering Rule project manager class';
91 $this->const[$r][4] = 0;
92 $r++;
93
94 $this->const[$r][0] = "PROJECT_ADDON_PDF_ODT_PATH";
95 $this->const[$r][1] = "chaine";
96 $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/projects";
97 $this->const[$r][3] = "";
98 $this->const[$r][4] = 0;
99 $r++;
100
101 $this->const[$r][0] = "PROJECT_TASK_ADDON_PDF";
102 $this->const[$r][1] = "chaine";
103 $this->const[$r][2] = "";
104 $this->const[$r][3] = 'Name of PDF/ODT tasks manager class';
105 $this->const[$r][4] = 0;
106 $r++;
107
108 $this->const[$r][0] = "PROJECT_TASK_ADDON";
109 $this->const[$r][1] = "chaine";
110 $this->const[$r][2] = "mod_task_simple";
111 $this->const[$r][3] = 'Name of Numbering Rule task manager class';
112 $this->const[$r][4] = 0;
113 $r++;
114
115 $this->const[$r][0] = "PROJECT_TASK_ADDON_PDF_ODT_PATH";
116 $this->const[$r][1] = "chaine";
117 $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/tasks";
118 $this->const[$r][3] = "";
119 $this->const[$r][4] = 0;
120 $r++;
121
122 $this->const[$r][0] = "PROJECT_USE_OPPORTUNITIES";
123 $this->const[$r][1] = "chaine";
124 $this->const[$r][2] = "1";
125 $this->const[$r][3] = "";
126 $this->const[$r][4] = 0;
127 $r++;
128
129 // Boxes
130 $this->boxes = array(
131 0=>array('file'=>'box_project.php', 'enabledbydefaulton'=>'Home'), // open projects
132 1=>array('file'=>'box_project_opportunities.php', 'enabledbydefaulton'=>'Home'), // open opportunities
133 2=>array('file'=>'box_task.php', 'enabledbydefaulton'=>'Home'),
134 3=>array('file'=>'box_validated_projects.php', 'enabledbydefaulton'=>'Home'), // task without timespent
135 4=>array('file'=>'box_funnel_of_prospection.php', 'enabledbydefaulton'=>'Home'),
136 );
137 // Cronjobs
138 $this->cronjobs[] = array(
139 'label' => 'WeeklyWorkingHoursReport',
140 'jobtype' => 'method',
141 'class' => 'projet/class/project.class.php',
142 'objectname' => 'Project',
143 'method' => 'createWeeklyReport',
144 'parameters' => '',
145 'comment' => 'Generates and sends a weekly report on time worked',
146 'frequency' => 1,
147 'unitfrequency' => 86400 * 7,
148 'status' => 0,
149 'test' => '$conf->projet->enabled',
150 );
151 // Permissions
152 $this->rights = array();
153 $this->rights_class = 'projet';
154 $r = 0;
155
156 $r++;
157 $this->rights[$r][0] = 41; // id de la permission
158 $this->rights[$r][1] = "Read projects and tasks (shared projects or projects I am contact for)"; // libelle de la permission
159 $this->rights[$r][2] = 'r'; // type de la permission (deprecated)
160 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
161 $this->rights[$r][4] = 'lire';
162
163 $r++;
164 $this->rights[$r][0] = 42; // id de la permission
165 $this->rights[$r][1] = "Create/modify projects and tasks (shared projects or projects I am contact for)"; // libelle de la permission
166 $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
167 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
168 $this->rights[$r][4] = 'creer';
169
170 $r++;
171 $this->rights[$r][0] = 44; // id de la permission
172 $this->rights[$r][1] = "Delete project and tasks (shared projects or projects I am contact for)"; // libelle de la permission
173 $this->rights[$r][2] = 'd'; // type de la permission (deprecated)
174 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
175 $this->rights[$r][4] = 'supprimer';
176
177 $r++;
178 $this->rights[$r][0] = 45; // id de la permission
179 $this->rights[$r][1] = "Export projects"; // libelle de la permission
180 $this->rights[$r][2] = 'd'; // type de la permission (deprecated)
181 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
182 $this->rights[$r][4] = 'export';
183
184 $r++;
185 $this->rights[$r][0] = 141; // id de la permission
186 $this->rights[$r][1] = "Read all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
187 $this->rights[$r][2] = 'r'; // type de la permission (deprecated)
188 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
189 $this->rights[$r][4] = 'all';
190 $this->rights[$r][5] = 'lire';
191
192 $r++;
193 $this->rights[$r][0] = 142; // id de la permission
194 $this->rights[$r][1] = "Create/modify all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
195 $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
196 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
197 $this->rights[$r][4] = 'all';
198 $this->rights[$r][5] = 'creer';
199
200 $r++;
201 $this->rights[$r][0] = 144; // id de la permission
202 $this->rights[$r][1] = "Delete all projects and tasks (also private projects I am not contact for)"; // libelle de la permission
203 $this->rights[$r][2] = 'd'; // type de la permission (deprecated)
204 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
205 $this->rights[$r][4] = 'all';
206 $this->rights[$r][5] = 'supprimer';
207
208 $r++;
209 $this->rights[$r][0] = 145; // id de la permission
210 $this->rights[$r][1] = "Can enter time consumed on assigned tasks (timesheet)"; // libelle de la permission
211 $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
212 $this->rights[$r][3] = 0; // La permission est-elle une permission par default
213 $this->rights[$r][4] = 'time';
214
215 // Menus
216 //-------
217 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
218
219
220 // Exports
221 //--------
222 $r = 1;
223
224 $this->export_code[$r] = $this->rights_class.'_'.$r;
225 $this->export_label[$r] = 'ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
226 $this->export_permission[$r] = array(array("projet", "export"));
227 $this->export_dependencies_array[$r] = array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
228
229 $this->export_TypeFields_array[$r] = array(
230 's.rowid'=>"Numeric", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label',
231 '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',
232 'p.rowid'=>"Numeric", 'p.ref'=>"Text", 'p.title'=>"Text",
233 'p.usage_opportunity'=>'Boolean', 'p.usage_task'=>'Boolean', 'p.usage_bill_time'=>'Boolean',
234 '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',
235 '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",
236 'ptt.rowid'=>'Numeric', 'ptt.element_date'=>'Date', 'ptt.element_duration'=>"Duree", 'ptt.fk_user'=>"FormSelect:select_dolusers", 'ptt.note'=>"Text"
237 );
238 $this->export_entities_array[$r] = array(
239 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company',
240 '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'
241 );
242 $this->export_fields_array[$r] = array(
243 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 's.fk_pays'=>'Country',
244 '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',
245 'p.rowid'=>"ProjectId", 'p.ref'=>"RefProject", 'p.title'=>'ProjectLabel',
246 'p.usage_opportunity'=>'ProjectFollowOpportunity', 'p.usage_task'=>'ProjectFollowTasks', 'p.usage_bill_time'=>'BillTime',
247 '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"
248 );
249 // Add multicompany field
250 if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) {
251 $nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1
252 if (isModEnabled('multicompany') && $nbofallowedentities > 1) {
253 $this->export_fields_array[$r] += array('p.entity'=>'Entity');
254 }
255 }
256 if (!getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
257 unset($this->export_fields_array[$r]['p.opp_percent']);
258 unset($this->export_fields_array[$r]['p.opp_amount']);
259 unset($this->export_fields_array[$r]['cls.code']);
260 }
261
262 // Add fields for project
263 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array());
264 // Add extra fields for project
265 $keyforselect = 'projet';
266 $keyforelement = 'project';
267 $keyforaliasextra = 'extra';
268 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
269 // Add fields for tasks
270 $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"));
271 $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"));
272 // Add extra fields for task
273 $keyforselect = 'projet_task';
274 $keyforelement = 'projecttask';
275 $keyforaliasextra = 'extra2';
276 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
277 // End add extra fields
278 $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"));
279 $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"));
280 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
281 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('f.ref'=>"Billed"));
282 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('f.ref'=>"task_time"));
283 }
284 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
285 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'projet as p';
286 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
287 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
288 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
289 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
290 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."element_time as ptt ON (pt.rowid = ptt.fk_element AND ptt.elementtype = 'task')";
291 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
292 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
293 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON ptt.invoice_id = f.rowid';
294 }
295 $this->export_sql_end[$r] .= " WHERE p.entity IN (".getEntity('project').")";
296
297 // Import project/opportunities
298 $r++;
299 $this->import_code[$r] = 'projects';
300 $this->import_label[$r] = 'ImportDatasetProjects';
301 $this->import_icon[$r] = 'project';
302 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
303 $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)
304 $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");
305 $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"));
306 // Add extra fields
307 $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'projet' AND entity IN (0,".$conf->entity.")";
308 $resql = $this->db->query($sql);
309 if ($resql) { // This can fail when class is used on old database (during migration for example)
310 while ($obj = $this->db->fetch_object($resql)) {
311 $fieldname = 'extra.'.$obj->name;
312 $fieldlabel = ucfirst($obj->label);
313 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
314 }
315 }
316 // End add extra fields
317 $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)
318 $this->import_convertvalue_array[$r] = array(
319 't.ref' => array('rule' => 'getrefifauto', 'class' => getDolGlobalString('PROJECT_ADDON', 'mod_project_simple'), 'path' => "/core/modules/project/".getDolGlobalString('PROJECT_ADDON', 'mod_project_simple').'.php'),
320 't.fk_soc' => array(
321 'rule' => 'fetchidfromref',
322 'file' => '/societe/class/societe.class.php',
323 'class' => 'Societe',
324 'method' => 'fetch',
325 'element' => 'ThirdParty'
326 ),
327 );
328 //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
329 $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])?$');
330 $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");
331
332 // Import list of tasks
333 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
334 $r++;
335 $this->import_code[$r] = 'tasksofprojects';
336 $this->import_label[$r] = 'ImportDatasetTasks';
337 $this->import_icon[$r] = 'task';
338 $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
339 $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)
340 $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");
341 // Add extra fields
342 $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";
343 $resql = $this->db->query($sql);
344 if ($resql) { // This can fail when class is used on old database (during migration for example)
345 while ($obj = $this->db->fetch_object($resql)) {
346 $fieldname = 'extra.'.$obj->name;
347 $fieldlabel = ucfirst($obj->label);
348 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
349 }
350 }
351 // End add extra fields
352 $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)
353 $this->import_convertvalue_array[$r] = array(
354 't.fk_projet'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project'),
355 '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')
356 );
357 //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
358 $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])?$');
359 $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");
360 }
361 }
362
363
372 public function init($options = '')
373 {
374 global $conf, $langs;
375
376 // Permissions
377 $this->remove($options);
378
379 //ODT template for project
380 $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt';
381 $dirodt = DOL_DATA_ROOT.'/doctemplates/projects';
382 $dest = $dirodt.'/template_project.odt';
383
384 if (file_exists($src) && !file_exists($dest)) {
385 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
386 dol_mkdir($dirodt);
387 $result = dol_copy($src, $dest, '0', 0);
388 if ($result < 0) {
389 $langs->load("errors");
390 $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
391 return 0;
392 }
393 }
394
395 //ODT template for tasks
396 $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt';
397 $dirodt = DOL_DATA_ROOT.'/doctemplates/tasks';
398 $dest = $dirodt.'/template_task_summary.odt';
399
400 if (file_exists($src) && !file_exists($dest)) {
401 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
402 dol_mkdir($dirodt);
403 $result = dol_copy($src, $dest, '0', 0);
404 if ($result < 0) {
405 $langs->load("errors");
406 $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
407 return 0;
408 }
409 }
410
411 $sql = array();
412 $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);
413 $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".((int) $conf->entity).")";
414 $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".((int) $conf->entity);
415 $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".((int) $conf->entity).")";
416 $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".((int) $conf->entity);
417 $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".((int) $conf->entity).")";
418
419
420 return $this->_init($sql, $options);
421 }
422}
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 a 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:140