dolibarr 21.0.0-beta
note.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25require "../../main.inc.php";
26require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
27require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
29
38// Load translation files required by the page
39$langs->load('projects');
40
41$action = GETPOST('action', 'aZ09');
42$confirm = GETPOST('confirm', 'alpha');
43$mine = GETPOST('mode') == 'mine' ? 1 : 0;
44//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
45$id = GETPOSTINT('id');
46$ref = GETPOST('ref', 'alpha');
47$withproject = GETPOSTINT('withproject');
48$project_ref = GETPOST('project_ref', 'alpha');
49
50// Security check
51$socid = 0;
52//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 assignment.
53if (!$user->hasRight('projet', 'lire')) {
55}
56
57$hookmanager->initHooks(array('projettasknote'));
58
59
60$object = new Task($db);
61$projectstatic = new Project($db);
62
63if ($id > 0 || !empty($ref)) {
64 if ($object->fetch($id, $ref) > 0) {
65 if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object, 'fetchComments') && empty($object->comments)) {
66 $object->fetchComments();
67 }
68 $projectstatic->fetch($object->fk_project);
69 if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) {
70 $projectstatic->fetchComments();
71 }
72 if (!empty($projectstatic->socid)) {
73 $projectstatic->fetch_thirdparty();
74 }
75
76 $object->project = clone $projectstatic;
77 } else {
78 dol_print_error($db);
79 }
80}
81
82
83// Retrieve First Task ID of Project if withprojet is on to allow project prev next to work
84if (!empty($project_ref) && !empty($withproject)) {
85 if ($projectstatic->fetch(0, $project_ref) > 0) {
86 $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
87 if (count($tasksarray) > 0) {
88 $id = $tasksarray[0]->id;
89 $object->fetch($id);
90 } else {
91 header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode));
92 }
93 }
94}
95
96if ($id > 0 || $ref) {
97 $object->fetch($id, $ref);
98}
99
100//$result = restrictedArea($user, 'projet', $id, '', 'task'); // TODO ameliorer la verification
101restrictedArea($user, 'projet', $object->fk_project, 'projet&project');
102
103$permissionnote = ($user->hasRight('projet', 'creer') || $user->hasRight('projet', 'all', 'creer'));
104
105
106/*
107 * Actions
108 */
109
110$parameters = array();
111$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
112if ($reshook < 0) {
113 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
114}
115if (empty($reshook)) {
116 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be 'include', not 'include_once'
117}
118
119
120/*
121 * View
122 */
123$form = new Form($db);
124$userstatic = new User($db);
125
126$now = dol_now();
127
128$title = $object->ref . ' - ' . $langs->trans("Notes");
129if (!empty($withproject)) {
130 $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ;
131}
132$help_url = '';
133
134llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-project project-tasks page-task_note');
135
136if ($object->id > 0) {
137 $userWrite = $projectstatic->restrictedProjectArea($user, 'write');
138
139 if (!empty($withproject)) {
140 // Tabs for project
141 $tab = 'tasks';
142 $head = project_prepare_head($projectstatic);
143 print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'));
144
145 $param = (isset($mode) && $mode == 'mine' ? '&mode=mine' : '');
146 // Project card
147
148 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
149
150 $morehtmlref = '<div class="refidno">';
151 // Title
152 $morehtmlref .= $projectstatic->title;
153 // Thirdparty
154 if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
155 $morehtmlref .= '<br>'.$projectstatic->thirdparty->getNomUrl(1, 'project');
156 }
157 $morehtmlref .= '</div>';
158
159 // Define a complementary filter for search of next/prev ref.
160 if (!$user->hasRight('projet', 'all', 'lire')) {
161 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
162 $projectstatic->next_prev_filter = "rowid:IN:".$db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0');
163 }
164
165 dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
166
167 print '<div class="fichecenter">';
168 print '<div class="fichehalfleft">';
169 print '<div class="underbanner clearboth"></div>';
170
171 print '<table class="border tableforfield centpercent">';
172
173 // Usage
174 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) {
175 print '<tr><td class="tdtop">';
176 print $langs->trans("Usage");
177 print '</td>';
178 print '<td>';
179 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
180 print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
181 $htmltext = $langs->trans("ProjectFollowOpportunity");
182 print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
183 print '<br>';
184 }
185 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
186 print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
187 $htmltext = $langs->trans("ProjectFollowTasks");
188 print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
189 print '<br>';
190 }
191 if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) {
192 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"' : '')).'"> ';
193 $htmltext = $langs->trans("ProjectBillTimeDescription");
194 print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
195 print '<br>';
196 }
197 if (isModEnabled('eventorganization')) {
198 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"' : '')).'"> ';
199 $htmltext = $langs->trans("EventOrganizationDescriptionLong");
200 print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
201 }
202 print '</td></tr>';
203 }
204
205 // Visibility
206 print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
207 if ($projectstatic->public) {
208 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
209 print $langs->trans('SharedProject');
210 } else {
211 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
212 print $langs->trans('PrivateProject');
213 }
214 print '</td></tr>';
215
216 // Budget
217 print '<tr><td>'.$langs->trans("Budget").'</td><td>';
218 if (isset($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount, '')) {
219 print price($projectstatic->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
220 }
221 print '</td></tr>';
222
223 // Date start - end project
224 print '<tr><td>'.$langs->trans("Dates").'</td><td>';
225 $start = dol_print_date($projectstatic->date_start, 'day');
226 print($start ? $start : '?');
227 $end = dol_print_date($projectstatic->date_end, 'day');
228 print ' - ';
229 print($end ? $end : '?');
230 if ($projectstatic->hasDelay()) {
231 print img_warning("Late");
232 }
233 print '</td></tr>';
234
235 // Other attributes
236 $cols = 2;
237 //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
238
239 print '</table>';
240
241 print '</div>';
242 print '<div class="fichehalfright">';
243 print '<div class="underbanner clearboth"></div>';
244
245 print '<table class="border centpercent tableforfield">';
246
247 // Description
248 print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
249 print nl2br($projectstatic->description);
250 print '</td></tr>';
251
252 // Categories
253 if (isModEnabled('category')) {
254 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
255 print $form->showCategories($projectstatic->id, 'project', 1);
256 print "</td></tr>";
257 }
258
259 print '</table>';
260
261 print '</div>';
262 print '</div>';
263
264 print '<div class="clearboth"></div>';
265
266 print dol_get_fiche_end();
267
268 print '<br>';
269 }
270
271 $head = task_prepare_head($object);
272 print dol_get_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask', 0, '', 'reposition');
273
274
275 $param = (GETPOST('withproject') ? '&withproject=1' : '');
276 $linkback = GETPOST('withproject') ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : '';
277
278 if (!GETPOST('withproject') || empty($projectstatic->id)) {
279 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
280 $object->next_prev_filter = " fk_projet:IN:".$db->sanitize($projectsListId);
281 } else {
282 $object->next_prev_filter = " fk_projet:=:".((int) $projectstatic->id);
283 }
284
285 $morehtmlref = '';
286
287 // Project
288 if (empty($withproject)) {
289 $morehtmlref .= '<div class="refidno">';
290 $morehtmlref .= $langs->trans("Project").': ';
291 $morehtmlref .= $projectstatic->getNomUrl(1);
292 $morehtmlref .= '<br>';
293
294 // Third party
295 $morehtmlref .= $langs->trans("ThirdParty").': ';
296 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
297 $morehtmlref .= '</div>';
298 }
299
300 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
301
302 print '<div class="fichecenter">';
303
304 print '<div class="underbanner clearboth"></div>';
305
306 $cssclass = 'titlefield';
307 $moreparam = $param;
308 include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
309
310 print '</div>';
311
312 print dol_get_fiche_end();
313}
314
315// End of page
316llxFooter();
317$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage tasks.
Class to manage Dolibarr users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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 a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
task_prepare_head($object)
Prepare array with list of tabs.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
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.