dolibarr 21.0.0-alpha
comment.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2006-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28require "../../main.inc.php";
29require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
30require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
38
39// Load translation files required by the page
40$langs->loadLangs(array('projects', 'companies'));
41
42$id = GETPOSTINT('id');
43$idcomment = GETPOSTINT('idcomment');
44$ref = GETPOST("ref", 'alpha', 1); // task ref
45$objectref = GETPOST("taskref", 'alpha'); // task ref
46$action = GETPOST('action', 'aZ09');
47$confirm = GETPOST('confirm', 'alpha');
48$withproject = GETPOSTINT('withproject');
49$project_ref = GETPOST('project_ref', 'alpha');
50$planned_workload = ((GETPOSTINT('planned_workloadhour') != '' || GETPOSTINT('planned_workloadmin') != '') ? (GETPOSTINT('planned_workloadhour') > 0 ? GETPOSTINT('planned_workloadhour') * 3600 : 0) + (GETPOSTINT('planned_workloadmin') > 0 ? GETPOSTINT('planned_workloadmin') * 60 : 0) : '');
51
52// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
53$hookmanager->initHooks(array('projecttaskcommentcard', 'globalcard'));
54
55$object = new Task($db);
56$extrafields = new ExtraFields($db);
57$projectstatic = new Project($db);
58
59// fetch optionals attributes and labels
60$extrafields->fetch_name_optionals_label($object->table_element);
61
62// include comment actions
63include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php';
64
65// Retrieve First Task ID of Project if withprojet is on to allow project prev next to work
66if (!empty($project_ref) && !empty($withproject)) {
67 if ($projectstatic->fetch(0, $project_ref) > 0) {
68 $objectsarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
69 if (count($objectsarray) > 0) {
70 $id = $objectsarray[0]->id;
71 } else {
72 header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode));
73 }
74 }
75}
76
77
78if ($id > 0 || $ref) {
79 $object->fetch($id, $ref);
80}
81
82// Security check
83$socid = 0;
84
85restrictedArea($user, 'projet', $object->fk_project, 'projet&project');
86
87
88/*
89 * Actions
90 */
91
92// None
93
94
95/*
96 * View
97 */
98
99llxHeader('', $langs->trans("CommentPage"), '', '', 0, 0, '', '', '', 'mod-project project-tasks page-task_comment');
100
101$form = new Form($db);
102$formother = new FormOther($db);
103$formfile = new FormFile($db);
104
105if ($id > 0 || !empty($ref)) {
106 if ($object->fetch($id, $ref) > 0) {
107 $result = $object->fetch_optionals();
108
109 $result = $object->fetchComments();
110 if ($result < 0) {
111 setEventMessages($object->error, $object->errors, 'errors');
112 }
113
114 $result = $projectstatic->fetch($object->fk_project);
115 if (!empty($projectstatic->socid)) {
116 $projectstatic->fetch_thirdparty();
117 }
118 if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) {
119 $projectstatic->fetchComments();
120 }
121
122 $object->project = clone $projectstatic;
123
124 $userWrite = $projectstatic->restrictedProjectArea($user, 'write');
125
126 if (!empty($withproject)) {
127 // Tabs for project
128 $tab = 'tasks';
129 $head = project_prepare_head($projectstatic);
130 print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'));
131
132 $param = ($mode == 'mine' ? '&mode=mine' : '');
133
134 // Project card
135
136 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
137
138 $morehtmlref = '<div class="refidno">';
139 // Title
140 $morehtmlref .= $projectstatic->title;
141 // Thirdparty
142 if ($projectstatic->thirdparty->id > 0) {
143 $morehtmlref .= '<br>'.$projectstatic->thirdparty->getNomUrl(1, 'project');
144 }
145 $morehtmlref .= '</div>';
146
147 // Define a complementary filter for search of next/prev ref.
148 if (!$user->hasRight('projet', 'all', 'lire')) {
149 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
150 $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0').")";
151 }
152
153 dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
154
155 print '<div class="fichecenter">';
156 print '<div class="fichehalfleft">';
157 print '<div class="underbanner clearboth"></div>';
158
159 print '<table class="border centpercent">';
160
161 // Usage
162 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) {
163 print '<tr><td class="tdtop">';
164 print $langs->trans("Usage");
165 print '</td>';
166 print '<td>';
167 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) {
168 print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
169 $htmltext = $langs->trans("ProjectFollowOpportunity");
170 print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
171 print '<br>';
172 }
173 if (!getDolGlobalString('PROJECT_HIDE_TASKS')) {
174 print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
175 $htmltext = $langs->trans("ProjectFollowTasks");
176 print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
177 print '<br>';
178 }
179 if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) {
180 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"' : '')).'"> ';
181 $htmltext = $langs->trans("ProjectBillTimeDescription");
182 print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
183 print '<br>';
184 }
185 if (isModEnabled('eventorganization')) {
186 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"' : '')).'"> ';
187 $htmltext = $langs->trans("EventOrganizationDescriptionLong");
188 print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
189 }
190 print '</td></tr>';
191 }
192
193 // Visibility
194 print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
195 if ($projectstatic->public) {
196 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
197 print $langs->trans('SharedProject');
198 } else {
199 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
200 print $langs->trans('PrivateProject');
201 }
202 print '</td></tr>';
203
204 // Opportunities
205 if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') && !empty($object->usage_opportunity)) {
206 // Opportunity status
207 print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>';
208 $code = dol_getIdFromCode($db, $projectstatic->opp_status, 'c_lead_status', 'rowid', 'code');
209 if ($code) {
210 print $langs->trans("OppStatus".$code);
211 }
212 print '</td></tr>';
213
214 // Opportunity percent
215 print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>';
216 if (strcmp($projectstatic->opp_percent, '')) {
217 print price($projectstatic->opp_percent, 0, $langs, 1, 0).' %';
218 }
219 print '</td></tr>';
220
221 // Opportunity Amount
222 print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>';
223 if (strcmp($projectstatic->opp_amount, '')) {
224 print price($projectstatic->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
225 if (strcmp($projectstatic->opp_percent, '')) {
226 print ' &nbsp; &nbsp; &nbsp; <span title="'.dol_escape_htmltag($langs->trans('OpportunityWeightedAmount')).'"><span class="opacitymedium">'.$langs->trans("OpportunityWeightedAmountShort").'</span>: <span class="amount">'.price($projectstatic->opp_amount * $projectstatic->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).'</span></span>';
227 }
228 }
229 print '</td></tr>';
230 }
231
232 // Budget
233 print '<tr><td>'.$langs->trans("Budget").'</td><td>';
234 if (strcmp($projectstatic->budget_amount, '')) {
235 print price($projectstatic->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
236 }
237 print '</td></tr>';
238
239 // Date start - end project
240 print '<tr><td>'.$langs->trans("Dates").'</td><td>';
241 $start = dol_print_date($projectstatic->date_start, 'day');
242 print($start ? $start : '?');
243 $end = dol_print_date($projectstatic->date_end, 'day');
244 print ' - ';
245 print($end ? $end : '?');
246 if ($projectstatic->hasDelay()) {
247 print img_warning("Late");
248 }
249 print '</td></tr>';
250
251 // Other attributes
252 $cols = 2;
253 //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
254
255 print '</table>';
256
257 print '</div>';
258 print '<div class="fichehalfright">';
259 print '<div class="underbanner clearboth"></div>';
260
261 print '<table class="border centpercent">';
262
263 // Description
264 print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
265 print nl2br($projectstatic->description);
266 print '</td></tr>';
267
268 // Categories
269 if (isModEnabled('category')) {
270 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
271 print $form->showCategories($projectstatic->id, 'project', 1);
272 print "</td></tr>";
273 }
274
275 print '</table>';
276
277 print '</div>';
278 print '</div>';
279
280 print '<div class="clearboth"></div>';
281
282 print dol_get_fiche_end();
283
284 print '<br>';
285 }
286
287 $head = task_prepare_head($object);
288
289 /*
290 * Fiche tache en mode visu
291 */
292 $param = ($withproject ? '&withproject=1' : '');
293 $linkback = $withproject ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'&restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>' : '';
294
295 print dol_get_fiche_head($head, 'task_comment', $langs->trans("Task"), -1, 'projecttask');
296
297 if ($action == 'delete') {
298 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".GETPOSTINT("id").'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete");
299 }
300
301 if (!GETPOST('withproject') || empty($projectstatic->id)) {
302 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
303 $object->next_prev_filter = "fk_projet IN (".$db->sanitize($projectsListId).")";
304 } else {
305 $object->next_prev_filter = "fk_projet = ".((int) $projectstatic->id);
306 }
307
308 $morehtmlref = '';
309
310 // Project
311 if (empty($withproject)) {
312 $morehtmlref .= '<div class="refidno">';
313 $morehtmlref .= $langs->trans("Project").': ';
314 $morehtmlref .= $projectstatic->getNomUrl(1);
315 $morehtmlref .= '<br>';
316
317 // Third party
318 $morehtmlref .= $langs->trans("ThirdParty").': ';
319 if (!empty($projectstatic->thirdparty)) {
320 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
321 }
322 $morehtmlref .= '</div>';
323 }
324
325 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
326
327 print '<div class="fichecenter">';
328
329 print '<div class="underbanner clearboth"></div>';
330 print '<table class="border centpercent">';
331
332 // Nb comments
333 print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
334 print $object->getNbComments();
335 print '</td></tr>';
336
337 // Other attributes
338 $cols = 3;
339 $parameters = array('socid' => $socid);
340 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
341
342 print '</table>';
343
344 print '</div>';
345
346 print dol_get_fiche_end();
347
348
349 // Include comment tpl view
350 include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_comment.tpl.php';
351 }
352}
353
354// End of page
355llxFooter();
356$db->close();
$id
Definition account.php:39
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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage standard extra fields.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation de composants html autre Only common components are here.
Class to manage projects.
Class to manage tasks.
llxFooter()
Footer empty.
Definition document.php:107
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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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.
getDolGlobalString($key, $default='')
Return a 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.