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