dolibarr  17.0.4
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 $form = new Form($db);
114 $userstatic = new User($db);
115 
116 $now = dol_now();
117 
118 $title = $object->ref . ' - ' . $langs->trans("Notes");
119 if (!empty($withproject)) {
120  $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ;
121 }
122 $help_url = '';
123 
124 llxHeader('', $title, $help_url);
125 
126 if ($object->id > 0) {
127  $userWrite = $projectstatic->restrictedProjectArea($user, 'write');
128 
129  if (!empty($withproject)) {
130  // Tabs for project
131  $tab = 'tasks';
132  $head = project_prepare_head($projectstatic);
133  print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'));
134 
135  $param = ($mode == 'mine' ? '&mode=mine' : '');
136  // Project card
137 
138  $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
139 
140  $morehtmlref = '<div class="refidno">';
141  // Title
142  $morehtmlref .= $projectstatic->title;
143  // Thirdparty
144  if ($projectstatic->thirdparty->id > 0) {
145  $morehtmlref .= '<br>'.$projectstatic->thirdparty->getNomUrl(1, 'project');
146  }
147  $morehtmlref .= '</div>';
148 
149  // Define a complementary filter for search of next/prev ref.
150  if (empty($user->rights->projet->all->lire)) {
151  $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
152  $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
153  }
154 
155  dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
156 
157  print '<div class="fichecenter">';
158  print '<div class="fichehalfleft">';
159  print '<div class="underbanner clearboth"></div>';
160 
161  print '<table class="border tableforfield centpercent">';
162 
163  // Usage
164  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) {
165  print '<tr><td class="tdtop">';
166  print $langs->trans("Usage");
167  print '</td>';
168  print '<td>';
169  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
170  print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
171  $htmltext = $langs->trans("ProjectFollowOpportunity");
172  print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
173  print '<br>';
174  }
175  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
176  print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
177  $htmltext = $langs->trans("ProjectFollowTasks");
178  print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
179  print '<br>';
180  }
181  if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
182  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"' : '')).'"> ';
183  $htmltext = $langs->trans("ProjectBillTimeDescription");
184  print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
185  print '<br>';
186  }
187  if (isModEnabled('eventorganization')) {
188  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"' : '')).'"> ';
189  $htmltext = $langs->trans("EventOrganizationDescriptionLong");
190  print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
191  }
192  print '</td></tr>';
193  }
194 
195  // Visibility
196  print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
197  if ($projectstatic->public) {
198  print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
199  print $langs->trans('SharedProject');
200  } else {
201  print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
202  print $langs->trans('PrivateProject');
203  }
204  print '</td></tr>';
205 
206  // Budget
207  print '<tr><td>'.$langs->trans("Budget").'</td><td>';
208  if (strcmp($projectstatic->budget_amount, '')) {
209  print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
210  }
211  print '</td></tr>';
212 
213  // Date start - end project
214  print '<tr><td>'.$langs->trans("Dates").'</td><td>';
215  $start = dol_print_date($projectstatic->date_start, 'day');
216  print ($start ? $start : '?');
217  $end = dol_print_date($projectstatic->date_end, 'day');
218  print ' - ';
219  print ($end ? $end : '?');
220  if ($projectstatic->hasDelay()) {
221  print img_warning("Late");
222  }
223  print '</td></tr>';
224 
225  // Other attributes
226  $cols = 2;
227  //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
228 
229  print '</table>';
230 
231  print '</div>';
232  print '<div class="fichehalfright">';
233  print '<div class="underbanner clearboth"></div>';
234 
235  print '<table class="border centpercent tableforfield">';
236 
237  // Description
238  print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
239  print nl2br($projectstatic->description);
240  print '</td></tr>';
241 
242  // Categories
243  if (isModEnabled('categorie')) {
244  print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
245  print $form->showCategories($projectstatic->id, 'project', 1);
246  print "</td></tr>";
247  }
248 
249  print '</table>';
250 
251  print '</div>';
252  print '</div>';
253 
254  print '<div class="clearboth"></div>';
255 
256  print dol_get_fiche_end();
257 
258  print '<br>';
259  }
260 
261  $head = task_prepare_head($object);
262  print dol_get_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask', 0, '', 'reposition');
263 
264 
265  $param = (GETPOST('withproject') ? '&withproject=1' : '');
266  $linkback = GETPOST('withproject') ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : '';
267 
268  if (!GETPOST('withproject') || empty($projectstatic->id)) {
269  $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
270  $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
271  } else {
272  $object->next_prev_filter = " fk_projet = ".$projectstatic->id;
273  }
274 
275  $morehtmlref = '';
276 
277  // Project
278  if (empty($withproject)) {
279  $morehtmlref .= '<div class="refidno">';
280  $morehtmlref .= $langs->trans("Project").': ';
281  $morehtmlref .= $projectstatic->getNomUrl(1);
282  $morehtmlref .= '<br>';
283 
284  // Third party
285  $morehtmlref .= $langs->trans("ThirdParty").': ';
286  $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
287  $morehtmlref .= '</div>';
288  }
289 
290  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
291 
292  print '<div class="fichecenter">';
293 
294  print '<div class="underbanner clearboth"></div>';
295 
296  $cssclass = 'titlefield';
297  $moreparam = $param;
298  include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
299 
300  print '</div>';
301 
302  print dol_get_fiche_end();
303 }
304 
305 // End of page
306 llxFooter();
307 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage tasks.
Definition: task.class.php:38
Class to manage Dolibarr users.
Definition: user.class.php:47
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
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_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
isModEnabled($module)
Is Dolibarr module enabled.
task_prepare_head($object)
Prepare array with list of tabs.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
Definition: project.lib.php:38
restrictedArea(User $user, $features, $object=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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.