dolibarr 18.0.6
comment.php
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 *
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';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
36
37// Load translation files required by the page
38$langs->loadLangs(array('projects', 'companies'));
39
40$id = GETPOST('id', 'int');
41$idcomment = GETPOST('idcomment', 'int');
42$ref = GETPOST("ref", 'alpha', 1); // task ref
43$objectref = GETPOST("taskref", 'alpha'); // task ref
44$action = GETPOST('action', 'aZ09');
45$confirm = GETPOST('confirm', 'alpha');
46$withproject = GETPOST('withproject', 'int');
47$project_ref = GETPOST('project_ref', 'alpha');
48$planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : '');
49
50// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
51$hookmanager->initHooks(array('projecttaskcommentcard', 'globalcard'));
52
53$object = new Task($db);
54$extrafields = new ExtraFields($db);
55$projectstatic = new Project($db);
56
57// fetch optionals attributes and labels
58$extrafields->fetch_name_optionals_label($object->table_element);
59
60// include comment actions
61include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php';
62
63// Retrieve First Task ID of Project if withprojet is on to allow project prev next to work
64if (!empty($project_ref) && !empty($withproject)) {
65 if ($projectstatic->fetch('', $project_ref) > 0) {
66 $objectsarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
67 if (count($objectsarray) > 0) {
68 $id = $objectsarray[0]->id;
69 } else {
70 header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode));
71 }
72 }
73}
74
75
76if ($id > 0 || $ref) {
77 $object->fetch($id, $ref);
78}
79
80// Security check
81$socid = 0;
82
83restrictedArea($user, 'projet', $object->fk_project, 'projet&project');
84
85
86
87/*
88 * View
89 */
90
91llxHeader('', $langs->trans("CommentPage"));
92
93$form = new Form($db);
94$formother = new FormOther($db);
95$formfile = new FormFile($db);
96
97if ($id > 0 || !empty($ref)) {
98 if ($object->fetch($id, $ref) > 0) {
99 $result = $object->fetch_optionals();
100
101 $result = $object->fetchComments();
102 if ($result < 0) {
103 setEventMessages($object->error, $object->errors, 'errors');
104 }
105
106 $result = $projectstatic->fetch($object->fk_project);
107 if (!empty($projectstatic->socid)) {
108 $projectstatic->fetch_thirdparty();
109 }
110 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) {
111 $projectstatic->fetchComments();
112 }
113
114 $object->project = clone $projectstatic;
115
116 $userWrite = $projectstatic->restrictedProjectArea($user, 'write');
117
118 if (!empty($withproject)) {
119 // Tabs for project
120 $tab = 'tasks';
121 $head = project_prepare_head($projectstatic);
122 print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'));
123
124 $param = ($mode == 'mine' ? '&mode=mine' : '');
125
126 // Project card
127
128 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
129
130 $morehtmlref = '<div class="refidno">';
131 // Title
132 $morehtmlref .= $projectstatic->title;
133 // Thirdparty
134 if ($projectstatic->thirdparty->id > 0) {
135 $morehtmlref .= '<br>'.$projectstatic->thirdparty->getNomUrl(1, 'project');
136 }
137 $morehtmlref .= '</div>';
138
139 // Define a complementary filter for search of next/prev ref.
140 if (empty($user->rights->projet->all->lire)) {
141 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
142 $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
143 }
144
145 dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
146
147 print '<div class="fichecenter">';
148 print '<div class="fichehalfleft">';
149 print '<div class="underbanner clearboth"></div>';
150
151 print '<table class="border centpercent">';
152
153 // Usage
154 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) {
155 print '<tr><td class="tdtop">';
156 print $langs->trans("Usage");
157 print '</td>';
158 print '<td>';
159 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
160 print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> ';
161 $htmltext = $langs->trans("ProjectFollowOpportunity");
162 print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
163 print '<br>';
164 }
165 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
166 print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> ';
167 $htmltext = $langs->trans("ProjectFollowTasks");
168 print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
169 print '<br>';
170 }
171 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
172 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"' : '')).'"> ';
173 $htmltext = $langs->trans("ProjectBillTimeDescription");
174 print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
175 print '<br>';
176 }
177 if (isModEnabled('eventorganization')) {
178 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"' : '')).'"> ';
179 $htmltext = $langs->trans("EventOrganizationDescriptionLong");
180 print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
181 }
182 print '</td></tr>';
183 }
184
185 // Visibility
186 print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
187 if ($projectstatic->public) {
188 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
189 print $langs->trans('SharedProject');
190 } else {
191 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
192 print $langs->trans('PrivateProject');
193 }
194 print '</td></tr>';
195
196 // Opportunities
197 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) {
198 // Opportunity status
199 print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>';
200 $code = dol_getIdFromCode($db, $projectstatic->opp_status, 'c_lead_status', 'rowid', 'code');
201 if ($code) {
202 print $langs->trans("OppStatus".$code);
203 }
204 print '</td></tr>';
205
206 // Opportunity percent
207 print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>';
208 if (strcmp($projectstatic->opp_percent, '')) {
209 print price($projectstatic->opp_percent, 0, $langs, 1, 0).' %';
210 }
211 print '</td></tr>';
212
213 // Opportunity Amount
214 print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>';
215 if (strcmp($projectstatic->opp_amount, '')) {
216 print price($projectstatic->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
217 if (strcmp($projectstatic->opp_percent, '')) {
218 print ' &nbsp; &nbsp; &nbsp; <span title="'.dol_escape_htmltag($langs->trans('OpportunityWeightedAmount')).'"><span class="opacitymedium">'.$langs->trans("Weighted").'</span>: <span class="amount">'.price($projectstatic->opp_amount * $projectstatic->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).'</span></span>';
219 }
220 }
221 print '</td></tr>';
222 }
223
224 // Budget
225 print '<tr><td>'.$langs->trans("Budget").'</td><td>';
226 if (strcmp($projectstatic->budget_amount, '')) {
227 print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
228 }
229 print '</td></tr>';
230
231 // Date start - end project
232 print '<tr><td>'.$langs->trans("Dates").'</td><td>';
233 $start = dol_print_date($projectstatic->date_start, 'day');
234 print ($start ? $start : '?');
235 $end = dol_print_date($projectstatic->date_end, 'day');
236 print ' - ';
237 print ($end ? $end : '?');
238 if ($projectstatic->hasDelay()) {
239 print img_warning("Late");
240 }
241 print '</td></tr>';
242
243 // Other attributes
244 $cols = 2;
245 //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
246
247 print '</table>';
248
249 print '</div>';
250 print '<div class="fichehalfright">';
251 print '<div class="underbanner clearboth"></div>';
252
253 print '<table class="border centpercent">';
254
255 // Description
256 print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
257 print nl2br($projectstatic->description);
258 print '</td></tr>';
259
260 // Categories
261 if (isModEnabled('categorie')) {
262 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
263 print $form->showCategories($projectstatic->id, 'project', 1);
264 print "</td></tr>";
265 }
266
267 print '</table>';
268
269 print '</div>';
270 print '</div>';
271
272 print '<div class="clearboth"></div>';
273
274 print dol_get_fiche_end();
275
276 print '<br>';
277 }
278
279 $head = task_prepare_head($object);
280
281 /*
282 * Fiche tache en mode visu
283 */
284 $param = ($withproject ? '&withproject=1' : '');
285 $linkback = $withproject ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'&restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>' : '';
286
287 print dol_get_fiche_head($head, 'task_comment', $langs->trans("Task"), -1, 'projecttask');
288
289 if ($action == 'delete') {
290 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".GETPOST("id", "int").'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete");
291 }
292
293 if (!GETPOST('withproject') || empty($projectstatic->id)) {
294 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
295 $object->next_prev_filter = "fk_projet IN (".$db->sanitize($projectsListId).")";
296 } else {
297 $object->next_prev_filter = "fk_projet = ".((int) $projectstatic->id);
298 }
299
300 $morehtmlref = '';
301
302 // Project
303 if (empty($withproject)) {
304 $morehtmlref .= '<div class="refidno">';
305 $morehtmlref .= $langs->trans("Project").': ';
306 $morehtmlref .= $projectstatic->getNomUrl(1);
307 $morehtmlref .= '<br>';
308
309 // Third party
310 $morehtmlref .= $langs->trans("ThirdParty").': ';
311 if (!empty($projectstatic->thirdparty)) {
312 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
313 }
314 $morehtmlref .= '</div>';
315 }
316
317 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
318
319 print '<div class="fichecenter">';
320
321 print '<div class="underbanner clearboth"></div>';
322 print '<table class="border centpercent">';
323
324 // Nb comments
325 print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
326 print $object->getNbComments();
327 print '</td></tr>';
328
329 // Other attributes
330 $cols = 3;
331 $parameters = array('socid'=>$socid);
332 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
333
334 print '</table>';
335
336 print '</div>';
337
338 print dol_get_fiche_end();
339
340
341 // Include comment tpl view
342 include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_comment.tpl.php';
343 }
344}
345
346// End of page
347llxFooter();
348$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
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.
Classe permettant la generation de composants html autre Only common components are here.
Class to manage projects.
Class to manage tasks.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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.
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.