dolibarr  16.0.5
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 = GETPOST('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) {
46 }
47 
48 $hookmanager->initHooks(array('projettasknote'));
49 
50 
51 $object = new Task($db);
52 $projectstatic = new Project($db);
53 
54 if ($id > 0 || !empty($ref)) {
55  if ($object->fetch($id, $ref) > 0) {
56  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) {
57  $object->fetchComments();
58  }
59  $projectstatic->fetch($object->fk_project);
60  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) {
61  $projectstatic->fetchComments();
62  }
63  if (!empty($projectstatic->socid)) {
64  $projectstatic->fetch_thirdparty();
65  }
66 
67  $object->project = clone $projectstatic;
68  } else {
69  dol_print_error($db);
70  }
71 }
72 
73 
74 // Retrieve First Task ID of Project if withprojet is on to allow project prev next to work
75 if (!empty($project_ref) && !empty($withproject)) {
76  if ($projectstatic->fetch(0, $project_ref) > 0) {
77  $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
78  if (count($tasksarray) > 0) {
79  $id = $tasksarray[0]->id;
80  $object->fetch($id);
81  } else {
82  header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode));
83  }
84  }
85 }
86 
87 if ($id > 0 || $ref) {
88  $object->fetch($id, $ref);
89 }
90 
91 //$result = restrictedArea($user, 'projet', $id, '', 'task'); // TODO ameliorer la verification
92 restrictedArea($user, 'projet', $object->fk_project, 'projet&project');
93 
94 $permissionnote = ($user->rights->projet->creer || $user->rights->projet->all->creer);
95 
96 
97 /*
98  * Actions
99  */
100 
101 $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
102 if ($reshook < 0) {
103  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
104 }
105 if (empty($reshook)) {
106  include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
107 }
108 
109 
110 /*
111  * View
112  */
113 
114 llxHeader('', $langs->trans("Task"));
115 
116 $form = new Form($db);
117 $userstatic = new User($db);
118 
119 $now = dol_now();
120 
121 if ($object->id > 0) {
122  $userWrite = $projectstatic->restrictedProjectArea($user, 'write');
123 
124  if (!empty($withproject)) {
125  // Tabs for project
126  $tab = 'tasks';
127  $head = project_prepare_head($projectstatic);
128  print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'));
129 
130  $param = ($mode == 'mine' ? '&mode=mine' : '');
131  // Project card
132 
133  $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
134 
135  $morehtmlref = '<div class="refidno">';
136  // Title
137  $morehtmlref .= $projectstatic->title;
138  // Thirdparty
139  if ($projectstatic->thirdparty->id > 0) {
140  $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project');
141  }
142  $morehtmlref .= '</div>';
143 
144  // Define a complementary filter for search of next/prev ref.
145  if (empty($user->rights->projet->all->lire)) {
146  $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
147  $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
148  }
149 
150  dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
151 
152  print '<div class="fichecenter">';
153  print '<div class="fichehalfleft">';
154  print '<div class="underbanner clearboth"></div>';
155 
156  print '<table class="border tableforfield centpercent">';
157 
158  // Usage
159  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
160  print '<tr><td class="tdtop">';
161  print $langs->trans("Usage");
162  print '</td>';
163  print '<td>';
164  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
165  print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
166  $htmltext = $langs->trans("ProjectFollowOpportunity");
167  print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
168  print '<br>';
169  }
170  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
171  print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
172  $htmltext = $langs->trans("ProjectFollowTasks");
173  print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
174  print '<br>';
175  }
176  if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
177  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"' : '')).'"> ';
178  $htmltext = $langs->trans("ProjectBillTimeDescription");
179  print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
180  print '<br>';
181  }
182  if (!empty($conf->eventorganization->enabled)) {
183  print '<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_organize_event ? ' checked="checked"' : '')).'"> ';
184  $htmltext = $langs->trans("EventOrganizationDescriptionLong");
185  print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
186  }
187  print '</td></tr>';
188  }
189 
190  // Visibility
191  print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
192  if ($projectstatic->public) {
193  print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
194  print $langs->trans('SharedProject');
195  } else {
196  print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
197  print $langs->trans('PrivateProject');
198  }
199  print '</td></tr>';
200 
201  // Date start - end
202  print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
203  $start = dol_print_date($projectstatic->date_start, 'day');
204  print ($start ? $start : '?');
205  $end = dol_print_date($projectstatic->date_end, 'day');
206  print ' - ';
207  print ($end ? $end : '?');
208  if ($projectstatic->hasDelay()) {
209  print img_warning("Late");
210  }
211  print '</td></tr>';
212 
213  // Budget
214  print '<tr><td>'.$langs->trans("Budget").'</td><td>';
215  if (strcmp($projectstatic->budget_amount, '')) {
216  print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
217  }
218  print '</td></tr>';
219 
220  // Other attributes
221  $cols = 2;
222  //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
223 
224  print '</table>';
225 
226  print '</div>';
227  print '<div class="fichehalfright">';
228  print '<div class="underbanner clearboth"></div>';
229 
230  print '<table class="border centpercent tableforfield">';
231 
232  // Description
233  print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
234  print nl2br($projectstatic->description);
235  print '</td></tr>';
236 
237  // Categories
238  if (isModEnabled('categorie')) {
239  print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
240  print $form->showCategories($projectstatic->id, 'project', 1);
241  print "</td></tr>";
242  }
243 
244  print '</table>';
245 
246  print '</div>';
247  print '</div>';
248 
249  print '<div class="clearboth"></div>';
250 
251  print dol_get_fiche_end();
252 
253  print '<br>';
254  }
255 
256  $head = task_prepare_head($object);
257  print dol_get_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask', 0, '', 'reposition');
258 
259 
260  $param = (GETPOST('withproject') ? '&withproject=1' : '');
261  $linkback = GETPOST('withproject') ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : '';
262 
263  if (!GETPOST('withproject') || empty($projectstatic->id)) {
264  $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
265  $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
266  } else {
267  $object->next_prev_filter = " fk_projet = ".$projectstatic->id;
268  }
269 
270  $morehtmlref = '';
271 
272  // Project
273  if (empty($withproject)) {
274  $morehtmlref .= '<div class="refidno">';
275  $morehtmlref .= $langs->trans("Project").': ';
276  $morehtmlref .= $projectstatic->getNomUrl(1);
277  $morehtmlref .= '<br>';
278 
279  // Third party
280  $morehtmlref .= $langs->trans("ThirdParty").': ';
281  $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
282  $morehtmlref .= '</div>';
283  }
284 
285  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
286 
287  print '<div class="fichecenter">';
288 
289  print '<div class="underbanner clearboth"></div>';
290 
291  $cssclass = 'titlefield';
292  $moreparam = $param;
293  include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
294 
295  print '</div>';
296 
297  print dol_get_fiche_end();
298 }
299 
300 // End of page
301 llxFooter();
302 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
Task
Class to manage tasks.
Definition: task.class.php:37
project_prepare_head
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
Definition: project.lib.php:38
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_banner_tab
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.
Definition: functions.lib.php:2046
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
task_prepare_head
task_prepare_head($object)
Prepare array with list of tabs.
Definition: project.lib.php:335
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
User
Class to manage Dolibarr users.
Definition: user.class.php:44
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
price
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.
Definition: functions.lib.php:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
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 ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59