dolibarr 20.0.0
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
24require "../../main.inc.php";
25require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
26require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
27require_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 = GETPOSTINT('id');
37$ref = GETPOST('ref', 'alpha');
38$withproject = GETPOSTINT('withproject');
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 assignment.
44if (!$user->hasRight('projet', 'lire')) {
46}
47
48$hookmanager->initHooks(array('projettasknote'));
49
50
51$object = new Task($db);
52$projectstatic = new Project($db);
53
54if ($id > 0 || !empty($ref)) {
55 if ($object->fetch($id, $ref) > 0) {
56 if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object, 'fetchComments') && empty($object->comments)) {
57 $object->fetchComments();
58 }
59 $projectstatic->fetch($object->fk_project);
60 if (getDolGlobalString('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
75if (!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
87if ($id > 0 || $ref) {
88 $object->fetch($id, $ref);
89}
90
91//$result = restrictedArea($user, 'projet', $id, '', 'task'); // TODO ameliorer la verification
92restrictedArea($user, 'projet', $object->fk_project, 'projet&project');
93
94$permissionnote = ($user->hasRight('projet', 'creer') || $user->hasRight('projet', 'all', 'creer'));
95
96
97/*
98 * Actions
99 */
100
101$parameters = array();
102$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
103if ($reshook < 0) {
104 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
105}
106if (empty($reshook)) {
107 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
108}
109
110
111/*
112 * View
113 */
114$form = new Form($db);
115$userstatic = new User($db);
116
117$now = dol_now();
118
119$title = $object->ref . ' - ' . $langs->trans("Notes");
120if (!empty($withproject)) {
121 $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ;
122}
123$help_url = '';
124
125llxHeader('', $title, $help_url);
126
127if ($object->id > 0) {
128 $userWrite = $projectstatic->restrictedProjectArea($user, 'write');
129
130 if (!empty($withproject)) {
131 // Tabs for project
132 $tab = 'tasks';
133 $head = project_prepare_head($projectstatic);
134 print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'));
135
136 $param = (isset($mode) && $mode == 'mine' ? '&mode=mine' : '');
137 // Project card
138
139 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
140
141 $morehtmlref = '<div class="refidno">';
142 // Title
143 $morehtmlref .= $projectstatic->title;
144 // Thirdparty
145 if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
146 $morehtmlref .= '<br>'.$projectstatic->thirdparty->getNomUrl(1, 'project');
147 }
148 $morehtmlref .= '</div>';
149
150 // Define a complementary filter for search of next/prev ref.
151 if (!$user->hasRight('projet', 'all', 'lire')) {
152 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
153 $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0').")";
154 }
155
156 dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
157
158 print '<div class="fichecenter">';
159 print '<div class="fichehalfleft">';
160 print '<div class="underbanner clearboth"></div>';
161
162 print '<table class="border tableforfield centpercent">';
163
164 // Usage
165 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) {
166 print '<tr><td class="tdtop">';
167 print $langs->trans("Usage");
168 print '</td>';
169 print '<td>';
170 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
171 print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
172 $htmltext = $langs->trans("ProjectFollowOpportunity");
173 print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
174 print '<br>';
175 }
176 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
177 print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
178 $htmltext = $langs->trans("ProjectFollowTasks");
179 print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
180 print '<br>';
181 }
182 if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) {
183 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"' : '')).'"> ';
184 $htmltext = $langs->trans("ProjectBillTimeDescription");
185 print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
186 print '<br>';
187 }
188 if (isModEnabled('eventorganization')) {
189 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"' : '')).'"> ';
190 $htmltext = $langs->trans("EventOrganizationDescriptionLong");
191 print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
192 }
193 print '</td></tr>';
194 }
195
196 // Visibility
197 print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
198 if ($projectstatic->public) {
199 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
200 print $langs->trans('SharedProject');
201 } else {
202 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
203 print $langs->trans('PrivateProject');
204 }
205 print '</td></tr>';
206
207 // Budget
208 print '<tr><td>'.$langs->trans("Budget").'</td><td>';
209 if (isset($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount, '')) {
210 print price($projectstatic->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
211 }
212 print '</td></tr>';
213
214 // Date start - end project
215 print '<tr><td>'.$langs->trans("Dates").'</td><td>';
216 $start = dol_print_date($projectstatic->date_start, 'day');
217 print($start ? $start : '?');
218 $end = dol_print_date($projectstatic->date_end, 'day');
219 print ' - ';
220 print($end ? $end : '?');
221 if ($projectstatic->hasDelay()) {
222 print img_warning("Late");
223 }
224 print '</td></tr>';
225
226 // Other attributes
227 $cols = 2;
228 //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
229
230 print '</table>';
231
232 print '</div>';
233 print '<div class="fichehalfright">';
234 print '<div class="underbanner clearboth"></div>';
235
236 print '<table class="border centpercent tableforfield">';
237
238 // Description
239 print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
240 print nl2br($projectstatic->description);
241 print '</td></tr>';
242
243 // Categories
244 if (isModEnabled('category')) {
245 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
246 print $form->showCategories($projectstatic->id, 'project', 1);
247 print "</td></tr>";
248 }
249
250 print '</table>';
251
252 print '</div>';
253 print '</div>';
254
255 print '<div class="clearboth"></div>';
256
257 print dol_get_fiche_end();
258
259 print '<br>';
260 }
261
262 $head = task_prepare_head($object);
263 print dol_get_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask', 0, '', 'reposition');
264
265
266 $param = (GETPOST('withproject') ? '&withproject=1' : '');
267 $linkback = GETPOST('withproject') ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : '';
268
269 if (!GETPOST('withproject') || empty($projectstatic->id)) {
270 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
271 $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
272 } else {
273 $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id);
274 }
275
276 $morehtmlref = '';
277
278 // Project
279 if (empty($withproject)) {
280 $morehtmlref .= '<div class="refidno">';
281 $morehtmlref .= $langs->trans("Project").': ';
282 $morehtmlref .= $projectstatic->getNomUrl(1);
283 $morehtmlref .= '<br>';
284
285 // Third party
286 $morehtmlref .= $langs->trans("ThirdParty").': ';
287 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
288 $morehtmlref .= '</div>';
289 }
290
291 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
292
293 print '<div class="fichecenter">';
294
295 print '<div class="underbanner clearboth"></div>';
296
297 $cssclass = 'titlefield';
298 $moreparam = $param;
299 include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
300
301 print '</div>';
302
303 print dol_get_fiche_end();
304}
305
306// End of page
307llxFooter();
308$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 dolibarr global constant string value.
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.