52 $this->family =
"projects";
53 $this->module_position =
'14';
55 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
58 $this->version =
'dolibarr';
60 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
61 $this->config_page_url = array(
"project.php@projet");
62 $this->picto =
'project';
65 $this->dirs = array(
"/projet/temp");
68 $this->hidden =
false;
69 $this->depends = array();
70 $this->requiredby = array(
'modEventOrganization');
71 $this->conflictwith = array();
72 $this->phpmin = array(7, 0);
73 $this->langfiles = array(
'projects');
76 $this->
const = array();
79 $this->
const[$r][0] =
"PROJECT_ADDON_PDF";
80 $this->
const[$r][1] =
"chaine";
81 $this->
const[$r][2] =
"baleine";
82 $this->
const[$r][3] =
'Name of PDF/ODT project manager class';
83 $this->
const[$r][4] = 0;
86 $this->
const[$r][0] =
"PROJECT_ADDON";
87 $this->
const[$r][1] =
"chaine";
88 $this->
const[$r][2] =
"mod_project_simple";
89 $this->
const[$r][3] =
'Name of Numbering Rule project manager class';
90 $this->
const[$r][4] = 0;
93 $this->
const[$r][0] =
"PROJECT_ADDON_PDF_ODT_PATH";
94 $this->
const[$r][1] =
"chaine";
95 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/projects";
96 $this->
const[$r][3] =
"";
97 $this->
const[$r][4] = 0;
100 $this->
const[$r][0] =
"PROJECT_TASK_ADDON_PDF";
101 $this->
const[$r][1] =
"chaine";
102 $this->
const[$r][2] =
"";
103 $this->
const[$r][3] =
'Name of PDF/ODT tasks manager class';
104 $this->
const[$r][4] = 0;
107 $this->
const[$r][0] =
"PROJECT_TASK_ADDON";
108 $this->
const[$r][1] =
"chaine";
109 $this->
const[$r][2] =
"mod_task_simple";
110 $this->
const[$r][3] =
'Name of Numbering Rule task manager class';
111 $this->
const[$r][4] = 0;
114 $this->
const[$r][0] =
"PROJECT_TASK_ADDON_PDF_ODT_PATH";
115 $this->
const[$r][1] =
"chaine";
116 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/tasks";
117 $this->
const[$r][3] =
"";
118 $this->
const[$r][4] = 0;
121 $this->
const[$r][0] =
"PROJECT_USE_OPPORTUNITIES";
122 $this->
const[$r][1] =
"chaine";
123 $this->
const[$r][2] =
"1";
124 $this->
const[$r][3] =
"";
125 $this->
const[$r][4] = 0;
129 $this->boxes = array(
130 0=>array(
'file'=>
'box_project.php',
'enabledbydefaulton'=>
'Home'),
131 1=>array(
'file'=>
'box_project_opportunities.php',
'enabledbydefaulton'=>
'Home'),
132 2=>array(
'file'=>
'box_task.php',
'enabledbydefaulton'=>
'Home'),
133 3=>array(
'file'=>
'box_validated_projects.php',
'enabledbydefaulton'=>
'Home'),
134 4=>array(
'file'=>
'box_funnel_of_prospection.php',
'enabledbydefaulton'=>
'Home'),
137 $this->cronjobs[] = array(
138 'label' =>
'WeeklyWorkingHoursReport',
139 'jobtype' =>
'method',
140 'class' =>
'projet/class/project.class.php',
141 'objectname' =>
'Project',
142 'method' =>
'createWeeklyReport',
144 'comment' =>
'Generates and sends a weekly report on time worked',
146 'unitfrequency' => 86400 * 7,
148 'test' =>
'$conf->projet->enabled',
151 $this->rights = array();
152 $this->rights_class =
'projet';
156 $this->rights[$r][0] = 41;
157 $this->rights[$r][1] =
"Read projects and tasks (shared projects or projects I am contact for)";
158 $this->rights[$r][2] =
'r';
159 $this->rights[$r][3] = 0;
160 $this->rights[$r][4] =
'lire';
163 $this->rights[$r][0] = 42;
164 $this->rights[$r][1] =
"Create/modify projects and tasks (shared projects or projects I am contact for)";
165 $this->rights[$r][2] =
'w';
166 $this->rights[$r][3] = 0;
167 $this->rights[$r][4] =
'creer';
170 $this->rights[$r][0] = 44;
171 $this->rights[$r][1] =
"Delete project and tasks (shared projects or projects I am contact for)";
172 $this->rights[$r][2] =
'd';
173 $this->rights[$r][3] = 0;
174 $this->rights[$r][4] =
'supprimer';
177 $this->rights[$r][0] = 45;
178 $this->rights[$r][1] =
"Export projects";
179 $this->rights[$r][2] =
'd';
180 $this->rights[$r][3] = 0;
181 $this->rights[$r][4] =
'export';
184 $this->rights[$r][0] = 141;
185 $this->rights[$r][1] =
"Read all projects and tasks (also private projects I am not contact for)";
186 $this->rights[$r][2] =
'r';
187 $this->rights[$r][3] = 0;
188 $this->rights[$r][4] =
'all';
189 $this->rights[$r][5] =
'lire';
192 $this->rights[$r][0] = 142;
193 $this->rights[$r][1] =
"Create/modify all projects and tasks (also private projects I am not contact for)";
194 $this->rights[$r][2] =
'w';
195 $this->rights[$r][3] = 0;
196 $this->rights[$r][4] =
'all';
197 $this->rights[$r][5] =
'creer';
200 $this->rights[$r][0] = 144;
201 $this->rights[$r][1] =
"Delete all projects and tasks (also private projects I am not contact for)";
202 $this->rights[$r][2] =
'd';
203 $this->rights[$r][3] = 0;
204 $this->rights[$r][4] =
'all';
205 $this->rights[$r][5] =
'supprimer';
208 $this->rights[$r][0] = 145;
209 $this->rights[$r][1] =
"Can enter time consumed on assigned tasks (timesheet)";
210 $this->rights[$r][2] =
'w';
211 $this->rights[$r][3] = 0;
212 $this->rights[$r][4] =
'time';
223 $this->export_code[$r] = $this->rights_class.
'_'.$r;
224 $this->export_label[$r] =
'ProjectsAndTasksLines';
225 $this->export_permission[$r] = array(array(
"projet",
"export"));
226 $this->export_dependencies_array[$r] = array(
'projecttask'=>
'pt.rowid',
'task_time'=>
'ptt.rowid');
228 $this->export_TypeFields_array[$r] = array(
229 's.rowid'=>
"Numeric",
's.nom'=>
'Text',
's.address'=>
'Text',
's.zip'=>
'Text',
's.town'=>
'Text',
's.fk_pays'=>
'List:c_country:label',
230 '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',
231 'p.rowid'=>
"Numeric",
'p.ref'=>
"Text",
'p.title'=>
"Text",
232 'p.usage_opportunity'=>
'Boolean',
'p.usage_task'=>
'Boolean',
'p.usage_bill_time'=>
'Boolean',
233 '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',
234 '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",
235 'ptt.rowid'=>
'Numeric',
'ptt.element_date'=>
'Date',
'ptt.element_duration'=>
"Duree",
'ptt.fk_user'=>
"FormSelect:select_dolusers",
'ptt.note'=>
"Text"
237 $this->export_entities_array[$r] = array(
238 's.rowid'=>
"company",
's.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
's.fk_pays'=>
'company',
239 '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 $this->export_fields_array[$r] = array(
242 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
's.fk_pays'=>
'Country',
243 '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',
244 'p.rowid'=>
"ProjectId",
'p.ref'=>
"RefProject",
'p.title'=>
'ProjectLabel',
245 'p.usage_opportunity'=>
'ProjectFollowOpportunity',
'p.usage_task'=>
'ProjectFollowTasks',
'p.usage_bill_time'=>
'BillTime',
246 '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"
250 $nbofallowedentities = count(explode(
',',
getEntity(
'project')));
251 if (isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
252 $this->export_fields_array[$r] += array(
'p.entity'=>
'Entity');
256 unset($this->export_fields_array[$r][
'p.opp_percent']);
257 unset($this->export_fields_array[$r][
'p.opp_amount']);
258 unset($this->export_fields_array[$r][
'cls.code']);
262 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array());
264 $keyforselect =
'projet';
265 $keyforelement =
'project';
266 $keyforaliasextra =
'extra';
267 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
269 $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"));
270 $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 $keyforselect =
'projet_task';
273 $keyforelement =
'projecttask';
274 $keyforaliasextra =
'extra2';
275 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
277 $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"));
278 $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 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'f.ref'=>
"Billed"));
281 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'f.ref'=>
"task_time"));
283 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
284 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'projet as p';
285 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet_extrafields as extra ON p.rowid = extra.fk_object';
286 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
287 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"projet_task as pt ON p.rowid = pt.fk_projet";
288 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
289 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"element_time as ptt ON (pt.rowid = ptt.fk_element AND ptt.elementtype = 'task')";
290 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON p.fk_soc = s.rowid';
292 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture as f ON ptt.invoice_id = f.rowid';
294 $this->export_sql_end[$r] .=
" WHERE p.entity IN (".getEntity(
'project').
")";
298 $this->import_code[$r] =
'projects';
299 $this->import_label[$r] =
'ImportDatasetProjects';
300 $this->import_icon[$r] =
'project';
301 $this->import_entities_array[$r] = array();
302 $this->import_tables_array[$r] = array(
't'=>MAIN_DB_PREFIX.
'projet',
'extra'=>MAIN_DB_PREFIX.
'projet_extrafields');
303 $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");
304 $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 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'projet' AND entity IN (0,".$conf->entity.
")";
307 $resql = $this->db->query($sql);
309 while ($obj = $this->db->fetch_object($resql)) {
310 $fieldname =
'extra.'.$obj->name;
311 $fieldlabel = ucfirst($obj->label);
312 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
316 $this->import_fieldshidden_array[$r] = array(
't.fk_user_creat'=>
'user->id',
'extra.fk_object'=>
'lastrowid-'.MAIN_DB_PREFIX.
'projet');
317 $this->import_convertvalue_array[$r] = array(
318 't.ref'=>array(
'rule'=>
'getrefifauto',
'class'=>(!
getDolGlobalString(
'PROJECT_ADDON') ?
'mod_project_simple' : $conf->global->PROJECT_ADDON),
'path'=>
"/core/modules/project/".(!
getDolGlobalString(
'PROJECT_ADDON') ?
'mod_project_simple' : $conf->global->PROJECT_ADDON).
'.php'),
320 'rule' =>
'fetchidfromref',
321 'file' =>
'/societe/class/societe.class.php',
322 'class' =>
'Societe',
324 'element' =>
'ThirdParty'
328 $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])?$');
329 $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");
334 $this->import_code[$r] =
'tasksofprojects';
335 $this->import_label[$r] =
'ImportDatasetTasks';
336 $this->import_icon[$r] =
'task';
337 $this->import_entities_array[$r] = array(
't.fk_projet'=>
'project');
338 $this->import_tables_array[$r] = array(
't'=>MAIN_DB_PREFIX.
'projet_task',
'extra'=>MAIN_DB_PREFIX.
'projet_task_extrafields');
339 $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 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'projet_task' AND entity IN (0,".$conf->entity.
")";
342 $resql = $this->db->query($sql);
344 while ($obj = $this->db->fetch_object($resql)) {
345 $fieldname =
'extra.'.$obj->name;
346 $fieldlabel = ucfirst($obj->label);
347 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
351 $this->import_fieldshidden_array[$r] = array(
't.fk_user_creat'=>
'user->id',
'extra.fk_object'=>
'lastrowid-'.MAIN_DB_PREFIX.
'projet_task');
352 $this->import_convertvalue_array[$r] = array(
353 't.fk_projet'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/projet/class/project.class.php',
'class'=>
'Project',
'method'=>
'fetch',
'element'=>
'Project'),
354 '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')
357 $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])?$');
358 $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");