53 $this->family =
"projects";
54 $this->module_position =
'14';
56 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
59 $this->version =
'dolibarr';
61 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
62 $this->config_page_url = array(
"project.php@projet");
63 $this->picto =
'project';
66 $this->dirs = array(
"/projet/temp");
69 $this->hidden =
false;
70 $this->depends = array();
71 $this->requiredby = array(
'modEventOrganization');
72 $this->conflictwith = array();
73 $this->phpmin = array(7, 0);
74 $this->langfiles = array(
'projects');
77 $this->
const = array();
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;
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;
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;
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;
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;
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;
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;
130 $this->boxes = array(
131 0=>array(
'file'=>
'box_project.php',
'enabledbydefaulton'=>
'Home'),
132 1=>array(
'file'=>
'box_project_opportunities.php',
'enabledbydefaulton'=>
'Home'),
133 2=>array(
'file'=>
'box_task.php',
'enabledbydefaulton'=>
'Home'),
134 3=>array(
'file'=>
'box_validated_projects.php',
'enabledbydefaulton'=>
'Home'),
135 4=>array(
'file'=>
'box_funnel_of_prospection.php',
'enabledbydefaulton'=>
'Home'),
138 $this->cronjobs[] = array(
139 'label' =>
'WeeklyWorkingHoursReport',
140 'jobtype' =>
'method',
141 'class' =>
'projet/class/project.class.php',
142 'objectname' =>
'Project',
143 'method' =>
'createWeeklyReport',
145 'comment' =>
'Generates and sends a weekly report on time worked',
147 'unitfrequency' => 86400 * 7,
149 'test' =>
'$conf->projet->enabled',
152 $this->rights = array();
153 $this->rights_class =
'projet';
157 $this->rights[$r][0] = 41;
158 $this->rights[$r][1] =
"Read projects and tasks (shared projects or projects I am contact for)";
159 $this->rights[$r][2] =
'r';
160 $this->rights[$r][3] = 0;
161 $this->rights[$r][4] =
'lire';
164 $this->rights[$r][0] = 42;
165 $this->rights[$r][1] =
"Create/modify projects and tasks (shared projects or projects I am contact for)";
166 $this->rights[$r][2] =
'w';
167 $this->rights[$r][3] = 0;
168 $this->rights[$r][4] =
'creer';
171 $this->rights[$r][0] = 44;
172 $this->rights[$r][1] =
"Delete project and tasks (shared projects or projects I am contact for)";
173 $this->rights[$r][2] =
'd';
174 $this->rights[$r][3] = 0;
175 $this->rights[$r][4] =
'supprimer';
178 $this->rights[$r][0] = 45;
179 $this->rights[$r][1] =
"Export projects";
180 $this->rights[$r][2] =
'd';
181 $this->rights[$r][3] = 0;
182 $this->rights[$r][4] =
'export';
185 $this->rights[$r][0] = 141;
186 $this->rights[$r][1] =
"Read all projects and tasks (also private projects I am not contact for)";
187 $this->rights[$r][2] =
'r';
188 $this->rights[$r][3] = 0;
189 $this->rights[$r][4] =
'all';
190 $this->rights[$r][5] =
'lire';
193 $this->rights[$r][0] = 142;
194 $this->rights[$r][1] =
"Create/modify all projects and tasks (also private projects I am not contact for)";
195 $this->rights[$r][2] =
'w';
196 $this->rights[$r][3] = 0;
197 $this->rights[$r][4] =
'all';
198 $this->rights[$r][5] =
'creer';
201 $this->rights[$r][0] = 144;
202 $this->rights[$r][1] =
"Delete all projects and tasks (also private projects I am not contact for)";
203 $this->rights[$r][2] =
'd';
204 $this->rights[$r][3] = 0;
205 $this->rights[$r][4] =
'all';
206 $this->rights[$r][5] =
'supprimer';
209 $this->rights[$r][0] = 145;
210 $this->rights[$r][1] =
"Can enter time consumed on assigned tasks (timesheet)";
211 $this->rights[$r][2] =
'w';
212 $this->rights[$r][3] = 0;
213 $this->rights[$r][4] =
'time';
224 $this->export_code[$r] = $this->rights_class.
'_'.$r;
225 $this->export_label[$r] =
'ProjectsAndTasksLines';
226 $this->export_permission[$r] = array(array(
"projet",
"export"));
227 $this->export_dependencies_array[$r] = array(
'projecttask'=>
'pt.rowid',
'task_time'=>
'ptt.rowid');
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"
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'
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"
251 $nbofallowedentities = count(explode(
',',
getEntity(
'project')));
252 if (isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
253 $this->export_fields_array[$r] += array(
'p.entity'=>
'Entity');
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']);
263 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array());
265 $keyforselect =
'projet';
266 $keyforelement =
'project';
267 $keyforaliasextra =
'extra';
268 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
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"));
273 $keyforselect =
'projet_task';
274 $keyforelement =
'projecttask';
275 $keyforaliasextra =
'extra2';
276 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
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"));
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"));
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';
293 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture as f ON ptt.invoice_id = f.rowid';
295 $this->export_sql_end[$r] .=
" WHERE p.entity IN (".getEntity(
'project').
")";
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();
303 $this->import_tables_array[$r] = array(
't'=>MAIN_DB_PREFIX.
'projet',
'extra'=>MAIN_DB_PREFIX.
'projet_extrafields');
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"));
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);
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 ?
'*' :
'');
317 $this->import_fieldshidden_array[$r] = array(
't.fk_user_creat'=>
'user->id',
'extra.fk_object'=>
'lastrowid-'.MAIN_DB_PREFIX.
'projet');
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'),
321 'rule' =>
'fetchidfromref',
322 'file' =>
'/societe/class/societe.class.php',
323 'class' =>
'Societe',
325 'element' =>
'ThirdParty'
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");
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');
339 $this->import_tables_array[$r] = array(
't'=>MAIN_DB_PREFIX.
'projet_task',
'extra'=>MAIN_DB_PREFIX.
'projet_task_extrafields');
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");
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);
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 ?
'*' :
'');
352 $this->import_fieldshidden_array[$r] = array(
't.fk_user_creat'=>
'user->id',
'extra.fk_object'=>
'lastrowid-'.MAIN_DB_PREFIX.
'projet_task');
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')
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");