25 include_once DOL_DOCUMENT_ROOT.
"/core/boxes/modules_boxes.php";
26 require_once DOL_DOCUMENT_ROOT.
"/core/lib/date.lib.php";
34 public $boxcode =
"projettask";
35 public $boximg =
"object_projecttask";
37 public $depends = array(
"projet");
49 global $conf, $user, $langs;
52 $langs->loadLangs(array(
'boxes',
'projects'));
54 $this->boxlabel =
"Tasks";
57 $this->hidden = (
getDolGlobalString(
'PROJECT_HIDE_TASKS') || !$user->hasRight(
'projet',
'lire'));
68 global $conf, $user, $langs;
71 include_once DOL_DOCUMENT_ROOT.
"/projet/class/task.class.php";
72 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
73 require_once DOL_DOCUMENT_ROOT.
"/core/lib/project.lib.php";
74 $projectstatic =
new Project($this->db);
75 $taskstatic =
new Task($this->db);
77 $cookie_name =
'DOLUSERCOOKIE_boxfilter_task';
79 $socid = $user->socid;
81 $textHead = $langs->trans(
"CurentlyOpenedTasks");
84 if (in_array(
GETPOST($cookie_name), array(
'all',
'im_project_contact',
'im_task_contact'))) {
85 $filterValue =
GETPOST($cookie_name);
86 } elseif (!empty($_COOKIE[$cookie_name])) {
87 $filterValue = preg_replace(
'/[^a-z_]/',
'', $_COOKIE[$cookie_name]);
90 if ($filterValue ==
'im_task_contact') {
91 $textHead .=
' : '.$langs->trans(
"WhichIamLinkedTo");
92 } elseif ($filterValue ==
'im_project_contact') {
93 $textHead .=
' : '.$langs->trans(
"WhichIamLinkedToProject");
97 $this->info_box_head = array(
101 'subtext'=>$langs->trans(
"Filter"),
102 'subpicto'=>
'filter.png',
103 'subclass'=>
'linkobject boxfilter',
108 if ($user->hasRight(
'projet',
'lire')) {
109 $boxcontent .=
'<div id="ancor-idfilter'.$this->boxcode.
'" style="display: block; position: absolute; margin-top: -100px"></div>'.
"\n";
110 $boxcontent .=
'<div id="idfilter'.$this->boxcode.
'" class="center" >'.
"\n";
111 $boxcontent .=
'<form class="flat " method="POST" action="'.$_SERVER[
"PHP_SELF"].
'#ancor-idfilter'.$this->boxcode.
'">'.
"\n";
112 $boxcontent .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
113 $selectArray = array(
'all' => $langs->trans(
"NoFilter"),
'im_task_contact' => $langs->trans(
"WhichIamLinkedTo"),
'im_project_contact' => $langs->trans(
"WhichIamLinkedToProject"));
114 $boxcontent .=
$form->selectArray($cookie_name, $selectArray, $filterValue);
115 $boxcontent .=
'<button type="submit" class="button buttongen button-save">'.$langs->trans(
"Refresh").
'</button>';
116 $boxcontent .=
'</form>'.
"\n";
117 $boxcontent .=
'</div>'.
"\n";
118 if (!empty($conf->use_javascript_ajax)) {
119 $boxcontent .=
'<script nonce="'.getNonce().
'" type="text/javascript">
120 jQuery(document).ready(function() {
121 jQuery("#idsubimg'.$this->boxcode.
'").click(function() {
122 jQuery(".showiffilter'.$this->boxcode.
'").toggle();
127 $boxcontent .=
'<script nonce="'.getNonce().
'">date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "'.$cookie_name.
'='.$filterValue.
'; expires= " + date.toGMTString() + "; path=/ "; </script>';
129 $this->info_box_contents[0][] = array(
130 'tr' =>
'class="nohover showiffilter'.$this->boxcode.
' hideobject"',
131 'td' =>
'class="nohover"',
132 'textnoformat' => $boxcontent,
137 $projectsListId =
'';
138 if (!$user->hasRight(
'projet',
'all',
'lire')) {
139 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
142 $sql =
"SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress";
143 $sql .=
", p.rowid project_id, p.ref project_ref, p.title project_title, p.fk_statut";
145 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task as pt";
146 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"projet as p ON (pt.fk_projet = p.rowid)";
148 if ($filterValue ===
'im_task_contact') {
149 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = ".((int) $user->id).
")";
150 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )";
151 } elseif ($filterValue ===
'im_project_contact') {
152 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = ".((int) $user->id).
")";
153 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )";
157 $sql .=
" pt.entity = ".$conf->entity;
158 $sql .=
" AND p.fk_statut = ".Project::STATUS_VALIDATED;
159 $sql .=
" AND (pt.progress < 100 OR pt.progress IS NULL ) ";
160 $sql .=
" AND p.usage_task = 1 ";
161 if (!$user->hasRight(
'projet',
'all',
'lire')) {
162 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
165 $sql .=
" ORDER BY pt.datee ASC, pt.dateo ASC";
166 $sql .= $this->db->plimit($max, 0);
168 $result = $this->db->query(
$sql);
171 $num = $this->db->num_rows($result);
172 while ($objp = $this->db->fetch_object($result)) {
173 $taskstatic->id = $objp->rowid;
174 $taskstatic->ref = $objp->ref;
175 $taskstatic->label = $objp->label;
176 $taskstatic->progress = $objp->progress;
177 $taskstatic->status = $objp->fk_statut;
178 $taskstatic->date_end = $this->db->jdate($objp->datee);
179 $taskstatic->planned_workload = $objp->planned_workload;
180 $taskstatic->duration_effective = $objp->duration_effective;
182 $projectstatic->id = $objp->project_id;
183 $projectstatic->ref = $objp->project_ref;
184 $projectstatic->title = $objp->project_title;
186 $label = $projectstatic->getNomUrl(1).
' '.$taskstatic->getNomUrl(1).
' '.
dol_htmlentities($taskstatic->label);
190 $this->info_box_contents[$i][] = array(
192 'text' => $boxcontent,
210 public function showBox($head =
null, $contents =
null, $nooutput = 0)
212 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage projects.
Class to manage the box to show last task.
loadBox($max=5)
Load data for box to show them later.
__construct($db, $param='')
Constructor.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getTaskProgressView($task, $label=true, $progressNumber=true, $hideOnProgressNull=false, $spaced=false)