dolibarr 25.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-2026 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, $user;
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 "PROJECT_TASK_EMAIL_TEMPLATE_REMIND_OVERDUE",
130 "emailtemplate:project_task",
131 "(SendingReminderForOverdueTask)",
132 'Email template used to remind the task executives of an overdue task (see MAIN_DELAY_TASKS_TODO)',
133 0,
134 ],
135 ];
136
137 // Boxes
138 $this->boxes = array(
139 0 => array('file' => 'box_project.php', 'enabledbydefaulton' => 'Home'), // open projects
140 1 => array('file' => 'box_project_opportunities.php', 'enabledbydefaulton' => 'Home'), // open opportunities
141 2 => array('file' => 'box_task.php', 'enabledbydefaulton' => 'Home'),
142 3 => array('file' => 'box_validated_projects.php', 'enabledbydefaulton' => 'Home'), // task without timespent
143 4 => array('file' => 'box_funnel_of_prospection.php', 'enabledbydefaulton' => 'Home'),
144 );
145 // Cronjobs
146 $this->cronjobs[] = array(
147 'label' => 'WeeklyWorkingHoursReport',
148 'jobtype' => 'method',
149 'class' => 'projet/class/project.class.php',
150 'objectname' => 'Project',
151 'method' => 'createWeeklyReport',
152 'parameters' => '',
153 'comment' => 'Generates and sends a weekly report on time worked',
154 'frequency' => 1,
155 'unitfrequency' => 86400 * 7,
156 'status' => 0,
157 'test' => 'isModEnabled("project")',
158 );
159 $this->cronjobs[] = array(
160 'label' => 'SendReminderForOverdueTasksTitle',
161 'jobtype' => 'method',
162 'class' => 'projet/class/task.class.php',
163 'objectname' => 'Task',
164 'method' => 'sendReminderForOverdueTasks',
165 'parameters' => '',
166 'comment' => 'SendReminderForOverdueTasks',
167 'frequency' => 1,
168 'unitfrequency' => 86400,
169 'status' => 1,
170 'test' => 'isModEnabled("project")',
171 );
172 // Permissions
173 $this->rights = array();
174 $this->rights_class = 'projet';
175 $r = 0;
176
177 $r++;
178 $this->rights[$r][0] = 41; // Permission id (must not be already used)
179 $this->rights[$r][1] = "Read projects and tasks (shared projects or projects I am contact for)"; // Permission label
180 $this->rights[$r][2] = 'r'; // Permission type (deprecated)
181 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
182 $this->rights[$r][4] = 'lire';
183
184 $r++;
185 $this->rights[$r][0] = 42; // Permission id (must not be already used)
186 $this->rights[$r][1] = "Create/modify projects and tasks (shared projects or projects I am contact for)"; // Permission label
187 $this->rights[$r][2] = 'w'; // Permission type (deprecated)
188 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
189 $this->rights[$r][4] = 'creer';
190
191 $r++;
192 $this->rights[$r][0] = 44; // Permission id (must not be already used)
193 $this->rights[$r][1] = "Delete project and tasks (shared projects or projects I am contact for)"; // Permission label
194 $this->rights[$r][2] = 'd'; // Permission type (deprecated)
195 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
196 $this->rights[$r][4] = 'supprimer';
197
198 $r++;
199 $this->rights[$r][0] = 45; // Permission id (must not be already used)
200 $this->rights[$r][1] = "Export projects"; // Permission label
201 $this->rights[$r][2] = 'd'; // Permission type (deprecated)
202 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
203 $this->rights[$r][4] = 'export';
204
205 $r++;
206 $this->rights[$r][0] = 141; // Permission id (must not be already used)
207 $this->rights[$r][1] = "Read all projects and tasks (also private projects I am not contact for)"; // Permission label
208 $this->rights[$r][2] = 'r'; // Permission type (deprecated)
209 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
210 $this->rights[$r][4] = 'all';
211 $this->rights[$r][5] = 'lire';
212
213 $r++;
214 $this->rights[$r][0] = 142; // Permission id (must not be already used)
215 $this->rights[$r][1] = "Create/modify all projects and tasks (also private projects I am not contact for)"; // Permission label
216 $this->rights[$r][2] = 'w'; // Permission type (deprecated)
217 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
218 $this->rights[$r][4] = 'all';
219 $this->rights[$r][5] = 'creer';
220
221 $r++;
222 $this->rights[$r][0] = 144; // Permission id (must not be already used)
223 $this->rights[$r][1] = "Delete all projects and tasks (also private projects I am not contact for)"; // Permission label
224 $this->rights[$r][2] = 'd'; // Permission type (deprecated)
225 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
226 $this->rights[$r][4] = 'all';
227 $this->rights[$r][5] = 'supprimer';
228
229 $r++;
230 $this->rights[$r][0] = 145; // Permission id (must not be already used)
231 $this->rights[$r][1] = "Can enter time consumed on assigned tasks (timesheet)"; // Permission label
232 $this->rights[$r][2] = 'w'; // Permission type (deprecated)
233 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
234 $this->rights[$r][4] = 'time';
235
236 // Menus
237 //-------
238 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
239
240
241 // Exports
242 //--------
243 $r = 1;
244
245 $this->export_code[$r] = $this->rights_class.'_'.$r;
246 $this->export_label[$r] = 'ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
247 $this->export_permission[$r] = array(array("projet", "export"));
248 $this->export_dependencies_array[$r] = array('projecttask' => 'pt.rowid', 'task_time' => 'ptt.rowid');
249
250 $this->export_TypeFields_array[$r] = array(
251 's.rowid' => "Numeric", 's.nom' => 'Text', 's.address' => 'Text', 's.zip' => 'Text', 's.town' => 'Text', 's.fk_pays' => 'List:c_country:label',
252 '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',
253 'p.rowid' => "Numeric", 'p.ref' => "Text", 'p.title' => "Text",
254 'p.usage_opportunity' => 'Boolean', 'p.usage_task' => 'Boolean', 'p.usage_bill_time' => 'Boolean',
255 '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',
256 'p.note_public' => 'Text', 'p.note_private' => 'Text',
257 '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",
258 'ptt.rowid' => 'Numeric', 'ptt.element_date' => 'Date', 'ptt.element_duration' => "Duree", 'ptt.fk_user' => "FormSelect:select_dolusers", 'ptt.note' => "Text"
259 );
260 $this->export_entities_array[$r] = array(
261 's.rowid' => "company", 's.nom' => 'company', 's.address' => 'company', 's.zip' => 'company', 's.town' => 'company', 's.fk_pays' => 'company',
262 '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'
263 );
264 $this->export_fields_array[$r] = array(
265 's.rowid' => "IdCompany", 's.nom' => 'CompanyName', 's.address' => 'Address', 's.zip' => 'Zip', 's.town' => 'Town', 's.fk_pays' => 'Country',
266 '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',
267 'p.rowid' => "ProjectId", 'p.ref' => "RefProject", 'p.title' => 'ProjectLabel',
268 'p.usage_opportunity' => 'ProjectFollowOpportunity', 'p.usage_task' => 'ProjectFollowTasks', 'p.usage_bill_time' => 'BillTime',
269 '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',
270 'p.note_public' => 'NotePublic', 'p.note_private' => 'NotePrivate',
271 );
272 // Add multicompany field
273 if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) {
274 $nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1
275 if (isModEnabled('multicompany') && $nbofallowedentities > 1) {
276 $this->export_fields_array[$r] += array('p.entity' => 'Entity');
277 }
278 }
279 if (!getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
280 unset($this->export_fields_array[$r]['p.opp_percent']);
281 unset($this->export_fields_array[$r]['p.opp_amount']);
282 unset($this->export_fields_array[$r]['cls.code']);
283 }
284
285 // Add fields for project
286 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array());
287 // Add extra fields for project
288 $keyforselect = 'projet';
289 $keyforelement = 'project';
290 $keyforaliasextra = 'extra';
291 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
292 // Add fields for tasks
293 $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"));
294 $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'));
295 // Add extra fields for task
296 $keyforselect = 'projet_task';
297 $keyforelement = 'projecttask';
298 $keyforaliasextra = 'extra2';
299 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
300 // End add extra fields
301 $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"));
302 $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"));
303 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
304 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('f.ref' => "Billed"));
305 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('f.ref' => "task_time"));
306 }
307 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
308 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'projet as p';
309 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
310 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
311 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
312 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
313 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."element_time as ptt ON (pt.rowid = ptt.fk_element AND ptt.elementtype = 'task')";
314 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
315 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
316 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON ptt.invoice_id = f.rowid';
317 }
318 $this->export_sql_end[$r] .= " WHERE p.entity IN (".getEntity('project').")";
319 if (is_object($user) && !$user->hasRight('projet', 'all', 'lire')) {
320 // Restrict to projects the user is allowed to see (public projects and projects the user is linked to)
321 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
322 $projectstatic = new Project($this->db);
323 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
324 $this->export_sql_end[$r] .= ' AND p.rowid IN ('.$this->db->sanitize($projectsListId != '' ? $projectsListId : '0').')';
325 }
326
327 // Import project/opportunities
328 $r++;
329 $this->import_code[$r] = 'projects';
330 $this->import_label[$r] = 'ImportDatasetProjects';
331 $this->import_icon[$r] = 'project';
332 $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
333 $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)
334 $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");
335 $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'));
336 // Add extra fields
337 $keyforselect = 'projet';
338 $keyforelement = 'project';
339 $keyforaliasextra = 'extra';
340 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php';
341 $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)
342 $this->import_convertvalue_array[$r] = array(
343 't.ref' => array(
344 'rule' => 'getrefifauto',
345 'class' => getDolGlobalString('PROJECT_ADDON', 'mod_project_simple'),
346 'path' => "/core/modules/project/".getDolGlobalString('PROJECT_ADDON', 'mod_project_simple').'.php'
347 ),
348 't.fk_soc' => array(
349 'rule' => 'fetchidfromref',
350 'file' => '/societe/class/societe.class.php',
351 'class' => 'Societe',
352 'method' => 'fetch',
353 'element' => 'ThirdParty'
354 ),
355 't.fk_opp_status' => array(
356 'rule' => 'fetchidfromcodeid',
357 'file' => '/core/class/cleadstatus.class.php',
358 'class' => 'CLeadStatus',
359 'method' => 'fetch',
360 'dict' => 'DictionaryOpportunityStatus'
361 ),
362 );
363 //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
364 $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])?$');
365 $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');
366
367 // Import list of tasks
368 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
369 $r++;
370 $this->import_code[$r] = 'tasksofprojects';
371 $this->import_label[$r] = 'ImportDatasetTasks';
372 $this->import_icon[$r] = 'task';
373 $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
374 $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)
375 $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");
376 // Add extra fields
377 $keyforselect = 'projet_task';
378 $keyforelement = 'task';
379 $keyforaliasextra = 'extra';
380 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php';
381 $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)
382 $this->import_convertvalue_array[$r] = array(
383 't.fk_projet' => array('rule' => 'fetchidfromref', 'classfile' => '/projet/class/project.class.php', 'class' => 'Project', 'method' => 'fetch', 'element' => 'Project'),
384 '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')
385 );
386 //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
387 $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])?$');
388 $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");
389 }
390 }
391
392
401 public function init($options = '')
402 {
403 global $conf, $langs;
404
405 $result = $this->_load_tables('/install/mysql/', 'project');
406 if ($result < 0) {
407 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')
408 }
409
410 // Permissions
411 $this->remove($options);
412
413 //ODT template for project
414 $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt';
415 $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/projects';
416 $dest = $dirodt.'/template_project.odt';
417
418 if (file_exists($src) && !file_exists($dest)) {
419 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
420 dol_mkdir($dirodt);
421 $result = dol_copy($src, $dest, '0', 0);
422 if ($result < 0) {
423 $langs->load("errors");
424 $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
425 return 0;
426 }
427 }
428
429 //ODT template for tasks
430 $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt';
431 $dirodt = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/tasks';
432 $dest = $dirodt.'/template_task_summary.odt';
433
434 if (file_exists($src) && !file_exists($dest)) {
435 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
436 dol_mkdir($dirodt);
437 $result = dol_copy($src, $dest, '0', 0);
438 if ($result < 0) {
439 $langs->load("errors");
440 $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
441 return 0;
442 }
443 }
444
445 $sql = array();
446 $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);
447 $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".((int) $conf->entity).")";
448 $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".((int) $conf->entity);
449 $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".((int) $conf->entity).")";
450 $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".((int) $conf->entity);
451 $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".((int) $conf->entity).")";
452
453
454 return $this->_init($sql, $options);
455 }
456}
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Class to manage projects.
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.
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 browser version
Definition main.inc.php:229
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:165