dolibarr 25.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 MDW <mdeweerd@users.noreply.github.com>
6 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
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
28// Load Dolibarr environment
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
31require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
38require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
39
48// Load translation files required by the page
49$langs->loadLangs(array('projects', 'companies'));
50
51$id = GETPOSTINT('id');
52$idcomment = GETPOSTINT('idcomment');
53$ref = GETPOST("ref", 'alpha', 1); // task ref
54$objectref = GETPOST("taskref", 'alpha'); // task ref
55$action = GETPOST('action', 'aZ09');
56$confirm = GETPOST('confirm', 'alpha');
57$withproject = GETPOSTINT('withproject');
58$mode = GETPOST('mode', 'aZ');
59
60// Security check
61$socid = 0;
62//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.
63if (!$user->hasRight('projet', 'lire')) {
65}
66
67// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
68$hookmanager->initHooks(array('projectcard', 'globalcard'));
69
70$extrafields = new ExtraFields($db);
71$object = new Project($db);
72
73// fetch optionals attributes and labels
74$extrafields->fetch_name_optionals_label($object->table_element);
75
76// Load object
77if ($id > 0 || !empty($ref)) {
78 $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database
79 if ($ret > 0) {
80 $object->fetch_thirdparty();
81 if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object, 'fetchComments') && empty($object->comments)) {
82 $object->fetchComments();
83 }
84 $id = $object->id;
85 }
86}
87
88// include comment actions
89include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php';
90
91/*
92 * View
93*/
94
95$title = $langs->trans('CommentPage');
96
97llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-project page-card_comment');
98
99$form = new Form($db);
100$formother = new FormOther($db);
101$formfile = new FormFile($db);
102
103// Tabs for project
104$tab = 'project_comment';
105$head = project_prepare_head($object);
106print dol_get_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project'));
107
108$param = ($mode == 'mine' ? '&mode=mine' : '');
109
110// Project card
111
112if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
113 $tmpurl = $_SESSION['pageforbacktolist']['project'];
114 $tmpurl = preg_replace('/__SOCID__/', (string) $object->socid, $tmpurl);
115 $linkback = '<a href="'.$tmpurl.(preg_match('/\?/', $tmpurl) ? '&' : '?'). 'restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
116} else {
117 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
118}
119
120$morehtmlref = '<div class="refidno">';
121// Title
122$morehtmlref .= $object->title;
123// Thirdparty
124if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
125 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
126}
127$morehtmlref .= '</div>';
128
129// Define a complementary filter for search of next/prev ref.
130if (!$user->hasRight('projet', 'all', 'lire')) {
131 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
132 $object->next_prev_filter = "rowid:IN:".$db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0');
133}
134
135dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
136
137print '<div class="fichecenter">';
138print '<div class="fichehalfleft">';
139print '<div class="underbanner clearboth"></div>';
140
141print '<table class="border centpercent">';
142
143// Visibility
144print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
145if ($object->public) {
146 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
147 print $langs->trans('SharedProject');
148} else {
149 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
150 print $langs->trans('PrivateProject');
151}
152print '</td></tr>';
153
154// Budget
155print '<tr><td>'.$langs->trans("Budget").'</td><td>';
156if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) {
157 print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
158}
159print '</td></tr>';
160
161// Date start - end project
162print '<tr><td>'.$langs->trans("Dates").'</td><td>';
163print dol_print_date($object->date_start, 'day');
164$end = dol_print_date($object->date_end, 'day');
165if ($end) {
166 print ' - '.$end;
167}
168print '</td></tr>';
169
170// Other attributes
171$cols = 2;
172// include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
173
174print '</table>';
175
176print '</div>';
177print '<div class="fichehalfright">';
178print '<div class="underbanner clearboth"></div>';
179
180print '<table class="border centpercent">';
181
182// Description
183print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
184print nl2br($object->description);
185print '</td></tr>';
186
187// Categories
188if (isModEnabled('category')) {
189 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
190 print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
191 print "</td></tr>";
192}
193
194// Nb comments
195print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
196print $object->getNbComments();
197print '</td></tr>';
198
199print '</table>';
200
201print '</div>';
202print '</div>';
203
204print '<div class="clearboth"></div>';
205
206print dol_get_fiche_end();
207
208print '<br>';
209
210// Include comment tpl view
211include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_comment.tpl.php';
212
213// End of page
214llxFooter();
215$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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 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 to help generate other html components Only common components are here.
Class to manage projects.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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)
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.
Definition html.lib.php:519
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:717
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.