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