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'),
138 $this->rights = array();
139 $this->rights_class =
'projet';
143 $this->rights[$r][0] = 41;
144 $this->rights[$r][1] =
"Read projects and tasks (shared projects or projects I am contact for)";
145 $this->rights[$r][2] =
'r';
146 $this->rights[$r][3] = 0;
147 $this->rights[$r][4] =
'lire';
150 $this->rights[$r][0] = 42;
151 $this->rights[$r][1] =
"Create/modify projects and tasks (shared projects or projects I am contact for)";
152 $this->rights[$r][2] =
'w';
153 $this->rights[$r][3] = 0;
154 $this->rights[$r][4] =
'creer';
157 $this->rights[$r][0] = 44;
158 $this->rights[$r][1] =
"Delete project and tasks (shared projects or projects I am contact for)";
159 $this->rights[$r][2] =
'd';
160 $this->rights[$r][3] = 0;
161 $this->rights[$r][4] =
'supprimer';
164 $this->rights[$r][0] = 45;
165 $this->rights[$r][1] =
"Export projects";
166 $this->rights[$r][2] =
'd';
167 $this->rights[$r][3] = 0;
168 $this->rights[$r][4] =
'export';
171 $this->rights[$r][0] = 141;
172 $this->rights[$r][1] =
"Read all projects and tasks (also private projects I am not contact for)";
173 $this->rights[$r][2] =
'r';
174 $this->rights[$r][3] = 0;
175 $this->rights[$r][4] =
'all';
176 $this->rights[$r][5] =
'lire';
179 $this->rights[$r][0] = 142;
180 $this->rights[$r][1] =
"Create/modify all projects and tasks (also private projects I am not contact for)";
181 $this->rights[$r][2] =
'w';
182 $this->rights[$r][3] = 0;
183 $this->rights[$r][4] =
'all';
184 $this->rights[$r][5] =
'creer';
187 $this->rights[$r][0] = 144;
188 $this->rights[$r][1] =
"Delete all projects and tasks (also private projects I am not contact for)";
189 $this->rights[$r][2] =
'd';
190 $this->rights[$r][3] = 0;
191 $this->rights[$r][4] =
'all';
192 $this->rights[$r][5] =
'supprimer';
195 $this->rights[$r][0] = 145;
196 $this->rights[$r][1] =
"Can enter time consumed on assigned tasks (timesheet)";
197 $this->rights[$r][2] =
'w';
198 $this->rights[$r][3] = 0;
199 $this->rights[$r][4] =
'time';
210 $this->export_code[$r] = $this->rights_class.
'_'.$r;
211 $this->export_label[$r] =
'ProjectsAndTasksLines';
212 $this->export_permission[$r] = array(array(
"projet",
"export"));
213 $this->export_dependencies_array[$r] = array(
'projecttask'=>
'pt.rowid',
'task_time'=>
'ptt.rowid');
215 $this->export_TypeFields_array[$r] = array(
216 's.rowid'=>
"Numeric",
's.nom'=>
'Text',
's.address'=>
'Text',
's.zip'=>
'Text',
's.town'=>
'Text',
's.fk_pays'=>
'List:c_country:label',
217 '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',
218 'p.rowid'=>
"Numeric",
'p.ref'=>
"Text",
'p.title'=>
"Text",
219 'p.usage_opportunity'=>
'Boolean',
'p.usage_task'=>
'Boolean',
'p.usage_bill_time'=>
'Boolean',
220 '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',
221 '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",
222 'ptt.rowid'=>
'Numeric',
'ptt.element_date'=>
'Date',
'ptt.element_duration'=>
"Duree",
'ptt.fk_user'=>
"FormSelect:select_dolusers",
'ptt.note'=>
"Text"
224 $this->export_entities_array[$r] = array(
225 's.rowid'=>
"company",
's.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
's.fk_pays'=>
'company',
226 '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'
228 $this->export_fields_array[$r] = array(
229 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
's.fk_pays'=>
'Country',
230 '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',
231 'p.rowid'=>
"ProjectId",
'p.ref'=>
"RefProject",
'p.title'=>
'ProjectLabel',
232 'p.usage_opportunity'=>
'ProjectFollowOpportunity',
'p.usage_task'=>
'ProjectFollowTasks',
'p.usage_bill_time'=>
'BillTime',
233 '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"
237 $nbofallowedentities = count(explode(
',',
getEntity(
'project')));
238 if (isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
239 $this->export_fields_array[$r] += array(
'p.entity'=>
'Entity');
243 unset($this->export_fields_array[$r][
'p.opp_percent']);
244 unset($this->export_fields_array[$r][
'p.opp_amount']);
245 unset($this->export_fields_array[$r][
'cls.code']);
249 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array());
251 $keyforselect =
'projet';
252 $keyforelement =
'project';
253 $keyforaliasextra =
'extra';
254 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
256 $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"));
257 $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"));
259 $keyforselect =
'projet_task';
260 $keyforelement =
'projecttask';
261 $keyforaliasextra =
'extra2';
262 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
264 $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"));
265 $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"));
267 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'f.ref'=>
"Billed"));
268 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'f.ref'=>
"task_time"));
270 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
271 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'projet as p';
272 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet_extrafields as extra ON p.rowid = extra.fk_object';
273 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
274 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"projet_task as pt ON p.rowid = pt.fk_projet";
275 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
276 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"element_time as ptt ON (pt.rowid = ptt.fk_element AND ptt.elementtype = 'task')";
277 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON p.fk_soc = s.rowid';
279 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture as f ON ptt.invoice_id = f.rowid';
281 $this->export_sql_end[$r] .=
" WHERE p.entity IN (".getEntity(
'project').
")";
285 $this->import_code[$r] =
'projects';
286 $this->import_label[$r] =
'ImportDatasetProjects';
287 $this->import_icon[$r] =
'project';
288 $this->import_entities_array[$r] = array();
289 $this->import_tables_array[$r] = array(
't'=>MAIN_DB_PREFIX.
'projet',
'extra'=>MAIN_DB_PREFIX.
'projet_extrafields');
290 $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");
291 $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"));
293 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'projet' AND entity IN (0,".$conf->entity.
")";
294 $resql = $this->db->query($sql);
296 while ($obj = $this->db->fetch_object($resql)) {
297 $fieldname =
'extra.'.$obj->name;
298 $fieldlabel = ucfirst($obj->label);
299 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
303 $this->import_fieldshidden_array[$r] = array(
't.fk_user_creat'=>
'user->id',
'extra.fk_object'=>
'lastrowid-'.MAIN_DB_PREFIX.
'projet');
304 $this->import_convertvalue_array[$r] = array(
305 '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'),
307 'rule' =>
'fetchidfromref',
308 'file' =>
'/societe/class/societe.class.php',
309 'class' =>
'Societe',
311 'element' =>
'ThirdParty'
315 $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])?$');
316 $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");
321 $this->import_code[$r] =
'tasksofprojects';
322 $this->import_label[$r] =
'ImportDatasetTasks';
323 $this->import_icon[$r] =
'task';
324 $this->import_entities_array[$r] = array(
't.fk_projet'=>
'project');
325 $this->import_tables_array[$r] = array(
't'=>MAIN_DB_PREFIX.
'projet_task',
'extra'=>MAIN_DB_PREFIX.
'projet_task_extrafields');
326 $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");
328 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'projet_task' AND entity IN (0,".$conf->entity.
")";
329 $resql = $this->db->query($sql);
331 while ($obj = $this->db->fetch_object($resql)) {
332 $fieldname =
'extra.'.$obj->name;
333 $fieldlabel = ucfirst($obj->label);
334 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
338 $this->import_fieldshidden_array[$r] = array(
't.fk_user_creat'=>
'user->id',
'extra.fk_object'=>
'lastrowid-'.MAIN_DB_PREFIX.
'projet_task');
339 $this->import_convertvalue_array[$r] = array(
340 't.fk_projet'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/projet/class/project.class.php',
'class'=>
'Project',
'method'=>
'fetch',
'element'=>
'Project'),
341 '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')
344 $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])?$');
345 $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");