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