dolibarr  13.0.2
note.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
24 require "../../main.inc.php";
25 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
26 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
28 
29 // Load translation files required by the page
30 $langs->load('projects');
31 
32 $action = GETPOST('action', 'aZ09');
33 $confirm = GETPOST('confirm', 'alpha');
34 $mine = $_REQUEST['mode'] == 'mine' ? 1 : 0;
35 //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
36 $id = GETPOST('id', 'int');
37 $ref = GETPOST('ref', 'alpha');
38 $withproject = GETPOST('withproject', 'int');
39 $project_ref = GETPOST('project_ref', 'alpha');
40 
41 // Security check
42 $socid = 0;
43 //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
44 if (!$user->rights->projet->lire) accessforbidden();
45 //$result = restrictedArea($user, 'projet', $id, '', 'task'); // TODO ameliorer la verification
46 
47 $object = new Task($db);
48 $projectstatic = new Project($db);
49 
50 if ($id > 0 || !empty($ref))
51 {
52  if ($object->fetch($id, $ref) > 0)
53  {
54  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments();
55  $projectstatic->fetch($object->fk_project);
56  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments();
57  if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
58 
59  $object->project = clone $projectstatic;
60  } else {
61  dol_print_error($db);
62  }
63 }
64 
65 
66 // Retrieve First Task ID of Project if withprojet is on to allow project prev next to work
67 if (!empty($project_ref) && !empty($withproject))
68 {
69  if ($projectstatic->fetch(0, $project_ref) > 0)
70  {
71  $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
72  if (count($tasksarray) > 0)
73  {
74  $id = $tasksarray[0]->id;
75  $object->fetch($id);
76  } else {
77  header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode));
78  }
79  }
80 }
81 
82 $permissionnote = ($user->rights->projet->creer || $user->rights->projet->all->creer);
83 
84 
85 /*
86  * Actions
87  */
88 
89 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php';
90 
91 
92 /*
93  * View
94  */
95 
96 llxHeader('', $langs->trans("Task"));
97 
98 $form = new Form($db);
99 $userstatic = new User($db);
100 
101 $now = dol_now();
102 
103 if ($object->id > 0)
104 {
105  $userWrite = $projectstatic->restrictedProjectArea($user, 'write');
106 
107  if (!empty($withproject))
108  {
109  // Tabs for project
110  $tab = 'tasks';
111  $head = project_prepare_head($projectstatic);
112  print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'));
113 
114  $param = ($mode == 'mine' ? '&mode=mine' : '');
115  // Project card
116 
117  $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
118 
119  $morehtmlref = '<div class="refidno">';
120  // Title
121  $morehtmlref .= $projectstatic->title;
122  // Thirdparty
123  if ($projectstatic->thirdparty->id > 0)
124  {
125  $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project');
126  }
127  $morehtmlref .= '</div>';
128 
129  // Define a complementary filter for search of next/prev ref.
130  if (!$user->rights->projet->all->lire)
131  {
132  $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
133  $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
134  }
135 
136  dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
137 
138  print '<div class="fichecenter">';
139  print '<div class="fichehalfleft">';
140  print '<div class="underbanner clearboth"></div>';
141 
142  print '<table class="border tableforfield centpercent">';
143 
144  // Usage
145  print '<tr><td class="tdtop">';
146  print $langs->trans("Usage");
147  print '</td>';
148  print '<td>';
149  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
150  {
151  print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
152  $htmltext = $langs->trans("ProjectFollowOpportunity");
153  print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
154  print '<br>';
155  }
156  if (empty($conf->global->PROJECT_HIDE_TASKS))
157  {
158  print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
159  $htmltext = $langs->trans("ProjectFollowTasks");
160  print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
161  print '<br>';
162  }
163  if (!empty($conf->global->PROJECT_BILL_TIME_SPENT))
164  {
165  print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> ';
166  $htmltext = $langs->trans("ProjectBillTimeDescription");
167  print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
168  print '<br>';
169  }
170  print '</td></tr>';
171 
172  // Visibility
173  print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
174  if ($projectstatic->public) print $langs->trans('SharedProject');
175  else print $langs->trans('PrivateProject');
176  print '</td></tr>';
177 
178  // Date start - end
179  print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
180  $start = dol_print_date($projectstatic->date_start, 'day');
181  print ($start ? $start : '?');
182  $end = dol_print_date($projectstatic->date_end, 'day');
183  print ' - ';
184  print ($end ? $end : '?');
185  if ($projectstatic->hasDelay()) print img_warning("Late");
186  print '</td></tr>';
187 
188  // Budget
189  print '<tr><td>'.$langs->trans("Budget").'</td><td>';
190  if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
191  print '</td></tr>';
192 
193  // Other attributes
194  $cols = 2;
195  //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
196 
197  print '</table>';
198 
199  print '</div>';
200  print '<div class="fichehalfright">';
201  print '<div class="ficheaddleft">';
202  print '<div class="underbanner clearboth"></div>';
203 
204  print '<table class="border centpercent tableforfield">';
205 
206  // Description
207  print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
208  print nl2br($projectstatic->description);
209  print '</td></tr>';
210 
211  // Categories
212  if ($conf->categorie->enabled) {
213  print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
214  print $form->showCategories($projectstatic->id, 'project', 1);
215  print "</td></tr>";
216  }
217 
218  print '</table>';
219 
220  print '</div>';
221  print '</div>';
222  print '</div>';
223 
224  print '<div class="clearboth"></div>';
225 
227 
228  print '<br>';
229  }
230 
231  $head = task_prepare_head($object);
232  print dol_get_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask', 0, '', 'reposition');
233 
234 
235  $param = (GETPOST('withproject') ? '&withproject=1' : '');
236  $linkback = GETPOST('withproject') ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : '';
237 
238  if (!GETPOST('withproject') || empty($projectstatic->id))
239  {
240  $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
241  $object->next_prev_filter = " fk_projet in (".$projectsListId.")";
242  } else $object->next_prev_filter = " fk_projet = ".$projectstatic->id;
243 
244  $morehtmlref = '';
245 
246  // Project
247  if (empty($withproject))
248  {
249  $morehtmlref .= '<div class="refidno">';
250  $morehtmlref .= $langs->trans("Project").': ';
251  $morehtmlref .= $projectstatic->getNomUrl(1);
252  $morehtmlref .= '<br>';
253 
254  // Third party
255  $morehtmlref .= $langs->trans("ThirdParty").': ';
256  $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
257  $morehtmlref .= '</div>';
258  }
259 
260  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
261 
262  print '<div class="fichecenter">';
263 
264  print '<div class="underbanner clearboth"></div>';
265 
266  $cssclass = 'titlefield';
267  $moreparam = $param;
268  include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
269 
270  print '</div>';
271 
273 }
274 
275 // End of page
276 llxFooter();
277 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Definition: user.class.php:44
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
project_prepare_head(Project $project)
Prepare array with list of tabs.
Definition: project.lib.php:36
print
Draft customers invoices.
Definition: index.php:89
Class to manage tasks.
Definition: task.class.php:35
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59
task_prepare_head($object)
Prepare array with list of tabs.