54 $this->family =
"projects";
55 $this->module_position =
'14';
57 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
60 $this->version =
'dolibarr';
62 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
63 $this->config_page_url = array(
"project.php@projet");
64 $this->picto =
'project';
67 $this->dirs = array(
"/projet/temp");
70 $this->hidden =
false;
71 $this->depends = array();
72 $this->requiredby = array(
'modEventOrganization');
73 $this->conflictwith = array();
74 $this->phpmin = array(7, 0);
75 $this->langfiles = array(
'projects');
83 "Name of PDF/ODT project manager class",
90 "Name of Numbering Rule project manager class",
94 "PROJECT_ADDON_PDF_ODT_PATH",
96 "DOL_DATA_ROOT".($conf->entity > 1 ?
'/'.$conf->entity :
'').
"/doctemplates/projects",
101 "PROJECT_TASK_ADDON_PDF",
104 "Name of PDF/ODT tasks manager class",
108 "PROJECT_TASK_ADDON",
111 "Name of Numbering Rule task manager class",
115 "PROJECT_TASK_ADDON_PDF_ODT_PATH",
117 "DOL_DATA_ROOT".($conf->entity > 1 ?
'/'.$conf->entity :
'').
"/doctemplates/tasks",
122 "PROJECT_USE_OPPORTUNITIES",
131 $this->boxes = array(
132 0 => array(
'file' =>
'box_project.php',
'enabledbydefaulton' =>
'Home'),
133 1 => array(
'file' =>
'box_project_opportunities.php',
'enabledbydefaulton' =>
'Home'),
134 2 => array(
'file' =>
'box_task.php',
'enabledbydefaulton' =>
'Home'),
135 3 => array(
'file' =>
'box_validated_projects.php',
'enabledbydefaulton' =>
'Home'),
136 4 => array(
'file' =>
'box_funnel_of_prospection.php',
'enabledbydefaulton' =>
'Home'),
139 $this->cronjobs[] = array(
140 'label' =>
'WeeklyWorkingHoursReport',
141 'jobtype' =>
'method',
142 'class' =>
'projet/class/project.class.php',
143 'objectname' =>
'Project',
144 'method' =>
'createWeeklyReport',
146 'comment' =>
'Generates and sends a weekly report on time worked',
148 'unitfrequency' => 86400 * 7,
150 'test' =>
'isModEnabled("project")',
153 $this->rights = array();
154 $this->rights_class =
'projet';
158 $this->rights[$r][0] = 41;
159 $this->rights[$r][1] =
"Read projects and tasks (shared projects or projects I am contact for)";
160 $this->rights[$r][2] =
'r';
161 $this->rights[$r][3] = 0;
162 $this->rights[$r][4] =
'lire';
165 $this->rights[$r][0] = 42;
166 $this->rights[$r][1] =
"Create/modify projects and tasks (shared projects or projects I am contact for)";
167 $this->rights[$r][2] =
'w';
168 $this->rights[$r][3] = 0;
169 $this->rights[$r][4] =
'creer';
172 $this->rights[$r][0] = 44;
173 $this->rights[$r][1] =
"Delete project and tasks (shared projects or projects I am contact for)";
174 $this->rights[$r][2] =
'd';
175 $this->rights[$r][3] = 0;
176 $this->rights[$r][4] =
'supprimer';
179 $this->rights[$r][0] = 45;
180 $this->rights[$r][1] =
"Export projects";
181 $this->rights[$r][2] =
'd';
182 $this->rights[$r][3] = 0;
183 $this->rights[$r][4] =
'export';
186 $this->rights[$r][0] = 141;
187 $this->rights[$r][1] =
"Read all projects and tasks (also private projects I am not contact for)";
188 $this->rights[$r][2] =
'r';
189 $this->rights[$r][3] = 0;
190 $this->rights[$r][4] =
'all';
191 $this->rights[$r][5] =
'lire';
194 $this->rights[$r][0] = 142;
195 $this->rights[$r][1] =
"Create/modify all projects and tasks (also private projects I am not contact for)";
196 $this->rights[$r][2] =
'w';
197 $this->rights[$r][3] = 0;
198 $this->rights[$r][4] =
'all';
199 $this->rights[$r][5] =
'creer';
202 $this->rights[$r][0] = 144;
203 $this->rights[$r][1] =
"Delete all projects and tasks (also private projects I am not contact for)";
204 $this->rights[$r][2] =
'd';
205 $this->rights[$r][3] = 0;
206 $this->rights[$r][4] =
'all';
207 $this->rights[$r][5] =
'supprimer';
210 $this->rights[$r][0] = 145;
211 $this->rights[$r][1] =
"Can enter time consumed on assigned tasks (timesheet)";
212 $this->rights[$r][2] =
'w';
213 $this->rights[$r][3] = 0;
214 $this->rights[$r][4] =
'time';
225 $this->export_code[$r] = $this->rights_class.
'_'.$r;
226 $this->export_label[$r] =
'ProjectsAndTasksLines';
227 $this->export_permission[$r] = array(array(
"projet",
"export"));
228 $this->export_dependencies_array[$r] = array(
'projecttask' =>
'pt.rowid',
'task_time' =>
'ptt.rowid');
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"
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'
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',
254 $nbofallowedentities = count(explode(
',',
getEntity(
'project')));
255 if (
isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
256 $this->export_fields_array[$r] += array(
'p.entity' =>
'Entity');
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']);
266 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array());
268 $keyforselect =
'projet';
269 $keyforelement =
'project';
270 $keyforaliasextra =
'extra';
271 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
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'));
276 $keyforselect =
'projet_task';
277 $keyforelement =
'projecttask';
278 $keyforaliasextra =
'extra2';
279 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
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"));
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"));
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';
296 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture as f ON ptt.invoice_id = f.rowid';
298 $this->export_sql_end[$r] .=
" WHERE p.entity IN (".getEntity(
'project').
")";
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();
306 $this->import_tables_array[$r] = array(
't' => MAIN_DB_PREFIX.
'projet',
'extra' => MAIN_DB_PREFIX.
'projet_extrafields');
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'));
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);
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 ?
'*' :
'');
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');
321 $this->import_convertvalue_array[$r] = array(
323 'rule' =>
'getrefifauto',
325 'path' =>
"/core/modules/project/".
getDolGlobalString(
'PROJECT_ADDON',
'mod_project_simple').
'.php'
328 'rule' =>
'fetchidfromref',
329 'file' =>
'/societe/class/societe.class.php',
330 'class' =>
'Societe',
332 'element' =>
'ThirdParty'
334 't.fk_opp_status' => array(
335 'rule' =>
'fetchidfromcodeid',
336 'file' =>
'/core/class/cleadstatus.class.php',
337 'class' =>
'CLeadStatus',
339 'dict' =>
'DictionaryOpportunityStatus'
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');
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');
353 $this->import_tables_array[$r] = array(
't' => MAIN_DB_PREFIX.
'projet_task',
'extra' => MAIN_DB_PREFIX.
'projet_task_extrafields');
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");
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);
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 ?
'*' :
'');
366 $this->import_fieldshidden_array[$r] = array(
't.fk_user_creat' =>
'user->id',
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'projet_task');
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')
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");