31 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
51 $this->family =
"projects";
52 $this->module_position =
'14';
54 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
57 $this->version =
'dolibarr';
59 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
60 $this->config_page_url = array(
"project.php@projet");
61 $this->picto =
'project';
64 $this->dirs = array(
"/projet/temp");
67 $this->hidden =
false;
68 $this->depends = array();
69 $this->requiredby = array();
70 $this->conflictwith = array();
71 $this->phpmin = array(5, 4);
72 $this->langfiles = array(
'projects');
75 $this->
const = array();
78 $this->
const[$r][0] =
"PROJECT_ADDON_PDF";
79 $this->
const[$r][1] =
"chaine";
80 $this->
const[$r][2] =
"baleine";
81 $this->
const[$r][3] =
'Name of PDF/ODT project manager class';
82 $this->
const[$r][4] = 0;
85 $this->
const[$r][0] =
"PROJECT_ADDON";
86 $this->
const[$r][1] =
"chaine";
87 $this->
const[$r][2] =
"mod_project_simple";
88 $this->
const[$r][3] =
'Name of Numbering Rule project manager class';
89 $this->
const[$r][4] = 0;
92 $this->
const[$r][0] =
"PROJECT_ADDON_PDF_ODT_PATH";
93 $this->
const[$r][1] =
"chaine";
94 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/projects";
95 $this->
const[$r][3] =
"";
96 $this->
const[$r][4] = 0;
99 $this->
const[$r][0] =
"PROJECT_TASK_ADDON_PDF";
100 $this->
const[$r][1] =
"chaine";
101 $this->
const[$r][2] =
"";
102 $this->
const[$r][3] =
'Name of PDF/ODT tasks manager class';
103 $this->
const[$r][4] = 0;
106 $this->
const[$r][0] =
"PROJECT_TASK_ADDON";
107 $this->
const[$r][1] =
"chaine";
108 $this->
const[$r][2] =
"mod_task_simple";
109 $this->
const[$r][3] =
'Name of Numbering Rule task manager class';
110 $this->
const[$r][4] = 0;
113 $this->
const[$r][0] =
"PROJECT_TASK_ADDON_PDF_ODT_PATH";
114 $this->
const[$r][1] =
"chaine";
115 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/tasks";
116 $this->
const[$r][3] =
"";
117 $this->
const[$r][4] = 0;
120 $this->
const[$r][0] =
"PROJECT_USE_OPPORTUNITIES";
121 $this->
const[$r][1] =
"chaine";
122 $this->
const[$r][2] =
"1";
123 $this->
const[$r][3] =
"";
124 $this->
const[$r][4] = 0;
127 $this->
const[$r][0] =
"MAIN_DELAY_PROJECT_TO_CLOSE";
128 $this->
const[$r][1] =
"chaine";
129 $this->
const[$r][2] =
"7";
130 $this->
const[$r][3] =
"";
131 $this->
const[$r][4] = 0;
133 $this->
const[$r][0] =
"MAIN_DELAY_TASKS_TODO";
134 $this->
const[$r][1] =
"chaine";
135 $this->
const[$r][2] =
"7";
136 $this->
const[$r][3] =
"";
137 $this->
const[$r][4] = 0;
141 $this->boxes = array(
142 0=>array(
'file'=>
'box_project.php',
'enabledbydefaulton'=>
'Home'),
143 1=>array(
'file'=>
'box_task.php',
'enabledbydefaulton'=>
'Home'),
144 2=>array(
'file'=>
'box_validated_projects.php',
'enabledbydefaulton'=>
'Home'),
145 3=>array(
'file'=>
'box_funnel_of_prospection.php',
'enabledbydefaulton'=>
'Home'),
149 $this->rights = array();
150 $this->rights_class =
'projet';
154 $this->rights[$r][0] = 41;
155 $this->rights[$r][1] =
"Read projects and tasks (shared projects or projects I am contact for). Can also enter time consumed on assigned tasks (timesheet)";
156 $this->rights[$r][2] =
'r';
157 $this->rights[$r][3] = 0;
158 $this->rights[$r][4] =
'lire';
161 $this->rights[$r][0] = 42;
162 $this->rights[$r][1] =
"Create/modify projects and tasks (shared projects or projects I am contact for)";
163 $this->rights[$r][2] =
'w';
164 $this->rights[$r][3] = 0;
165 $this->rights[$r][4] =
'creer';
168 $this->rights[$r][0] = 44;
169 $this->rights[$r][1] =
"Delete project and tasks (shared projects or projects I am contact for)";
170 $this->rights[$r][2] =
'd';
171 $this->rights[$r][3] = 0;
172 $this->rights[$r][4] =
'supprimer';
175 $this->rights[$r][0] = 45;
176 $this->rights[$r][1] =
"Export projects";
177 $this->rights[$r][2] =
'd';
178 $this->rights[$r][3] = 0;
179 $this->rights[$r][4] =
'export';
182 $this->rights[$r][0] = 141;
183 $this->rights[$r][1] =
"Read all projects and tasks (also private projects I am not contact for)";
184 $this->rights[$r][2] =
'r';
185 $this->rights[$r][3] = 0;
186 $this->rights[$r][4] =
'all';
187 $this->rights[$r][5] =
'lire';
190 $this->rights[$r][0] = 142;
191 $this->rights[$r][1] =
"Create/modify all projects and tasks (also private projects I am not contact for). Can also enter time consumed on assigned tasks (timesheet)";
192 $this->rights[$r][2] =
'w';
193 $this->rights[$r][3] = 0;
194 $this->rights[$r][4] =
'all';
195 $this->rights[$r][5] =
'creer';
198 $this->rights[$r][0] = 144;
199 $this->rights[$r][1] =
"Delete all projects and tasks (also private projects I am not contact for)";
200 $this->rights[$r][2] =
'd';
201 $this->rights[$r][3] = 0;
202 $this->rights[$r][4] =
'all';
203 $this->rights[$r][5] =
'supprimer';
215 $this->export_code[$r] = $this->rights_class.
'_'.$r;
216 $this->export_label[$r] =
'ProjectsAndTasksLines';
217 $this->export_permission[$r] = array(array(
"projet",
"export"));
218 $this->export_dependencies_array[$r] = array(
'projecttask'=>
'pt.rowid',
'task_time'=>
'ptt.rowid');
220 $this->export_TypeFields_array[$r] = array(
221 's.rowid'=>
"List:societe:nom::thirdparty",
's.nom'=>
'Text',
's.address'=>
'Text',
's.zip'=>
'Text',
's.town'=>
'Text',
's.fk_pays'=>
'List:c_country:label',
222 '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',
223 'p.rowid'=>
"List:projet:ref::project",
'p.ref'=>
"Text",
'p.title'=>
"Text",
224 'p.usage_opportunity'=>
'Boolean',
'p.usage_task'=>
'Boolean',
'p.usage_bill_time'=>
'Boolean',
225 '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',
226 '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",
227 'ptt.rowid'=>
'Numeric',
'ptt.task_date'=>
'Date',
'ptt.task_duration'=>
"Duree",
'ptt.fk_user'=>
"List:user:CONCAT(lastname,' ',firstname)",
'ptt.note'=>
"Text"
229 $this->export_entities_array[$r] = array(
230 's.rowid'=>
"company",
's.nom'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
's.fk_pays'=>
'company',
231 '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'
233 $this->export_fields_array[$r] = array(
234 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
's.fk_pays'=>
'Country',
235 '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',
236 'p.rowid'=>
"ProjectId",
'p.ref'=>
"RefProject",
'p.title'=>
'ProjectLabel',
237 'p.usage_opportunity'=>
'ProjectFollowOpportunity',
'p.usage_task'=>
'ProjectFollowTasks',
'p.usage_bill_time'=>
'BillTime',
238 '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"
241 if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
243 $nbofallowedentities = count(explode(
',',
getEntity(
'project')));
244 if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array(
'p.entity'=>
'Entity');
246 if (empty($conf->global->PROJECT_USE_OPPORTUNITIES))
248 unset($this->export_fields_array[$r][
'p.opp_percent']);
249 unset($this->export_fields_array[$r][
'p.opp_amount']);
250 unset($this->export_fields_array[$r][
'cls.code']);
254 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array());
256 $keyforselect =
'projet'; $keyforelement =
'project'; $keyforaliasextra =
'extra';
257 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
259 $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"));
260 $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"));
262 $keyforselect =
'projet_task'; $keyforelement =
'projecttask'; $keyforaliasextra =
'extra2';
263 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
265 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'ptt.rowid'=>
'IdTaskTime',
'ptt.task_date'=>
'TaskTimeDate',
'ptt.task_duration'=>
"TimesSpent",
'ptt.fk_user'=>
"TaskTimeUser",
'ptt.note'=>
"TaskTimeNote"));
266 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'ptt.rowid'=>
'task_time',
'ptt.task_date'=>
'task_time',
'ptt.task_duration'=>
"task_time",
'ptt.fk_user'=>
"task_time",
'ptt.note'=>
"task_time"));
267 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
268 $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array(
'f.ref'=>
"Billed"));
269 $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array(
'f.ref'=>
"task_time"));
271 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
272 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'projet as p';
273 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet_extrafields as extra ON p.rowid = extra.fk_object';
274 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
275 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"projet_task as pt ON p.rowid = pt.fk_projet";
276 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
277 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"projet_task_time as ptt ON pt.rowid = ptt.fk_task";
278 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON p.fk_soc = s.rowid';
279 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
280 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture as f ON ptt.invoice_id = f.rowid';
282 $this->export_sql_end[$r] .=
" WHERE p.entity IN (".getEntity(
'project').
")";
286 if (empty($conf->global->PROJECT_HIDE_TASKS))
289 $this->import_code[$r] =
'tasksofprojects';
290 $this->import_label[$r] =
'ImportDatasetTasks';
291 $this->import_icon[$r] =
'task';
292 $this->import_entities_array[$r] = array(
't.fk_projet'=>
'project');
293 $this->import_tables_array[$r] = array(
't'=>MAIN_DB_PREFIX.
'projet_task',
'extra'=>MAIN_DB_PREFIX.
'projet_task_extrafields');
294 $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");
296 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.
")";
300 while ($obj = $this->
db->fetch_object(
$resql))
302 $fieldname =
'extra.'.$obj->name;
303 $fieldlabel = ucfirst($obj->label);
304 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
308 $this->import_fieldshidden_array[$r] = array(
't.fk_user_creat'=>
'user->id',
'extra.fk_object'=>
'lastrowid-'.MAIN_DB_PREFIX.
'projet_task');
309 $this->import_convertvalue_array[$r] = array(
310 't.fk_projet'=>array(
'rule'=>
'fetchidfromref',
'classfile'=>
'/projet/class/project.class.php',
'class'=>
'Project',
'method'=>
'fetch',
'element'=>
'Project'),
311 't.ref'=>array(
'rule'=>
'getrefifauto')
314 $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])?$');
315 $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");
328 public function init($options =
'')
330 global $conf, $langs;
333 $this->
remove($options);
336 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/projects/template_project.odt';
337 $dirodt = DOL_DATA_ROOT.
'/doctemplates/projects';
338 $dest = $dirodt.
'/template_project.odt';
340 if (file_exists($src) && !file_exists($dest))
342 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
344 $result =
dol_copy($src, $dest, 0, 0);
347 $langs->load(
"errors");
348 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
354 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/tasks/template_task_summary.odt';
355 $dirodt = DOL_DATA_ROOT.
'/doctemplates/tasks';
356 $dest = $dirodt.
'/template_task_summary.odt';
358 if (file_exists($src) && !file_exists($dest))
360 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
362 $result =
dol_copy($src, $dest, 0, 0);
365 $langs->load(
"errors");
366 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
372 $sql[] =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = '".$this->
db->escape($this->
const[3][2]).
"' AND type = 'task' AND entity = ".$conf->entity;
373 $sql[] =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('".$this->
db->escape($this->
const[3][2]).
"','task',".$conf->entity.
")";
374 $sql[] =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity;
375 $sql[] =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.
")";
376 $sql[] =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity;
377 $sql[] =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.
")";
380 return $this->
_init($sql, $options);
init($options= '')
Function called when module is enabled.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
_init($array_sql, $options= '')
Enables a module.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
__construct($db)
Constructor.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
Class to describe and enable module Projet.