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 MDW <mdeweerd@users.noreply.github.com>
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
27// Load Dolibarr environment
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.formprojet.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
37require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.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
50// Security check
51$socid = 0;
52//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.
53if (!$user->hasRight('projet', 'lire')) {
55}
56
57// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
58$hookmanager->initHooks(array('projectcard', 'globalcard'));
59
60$extrafields = new ExtraFields($db);
61$object = new Project($db);
62
63// fetch optionals attributes and labels
64$extrafields->fetch_name_optionals_label($object->table_element);
65
66// Load object
67if ($id > 0 || !empty($ref)) {
68 $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database
69 if ($ret > 0) {
70 $object->fetch_thirdparty();
71 if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object, 'fetchComments') && empty($object->comments)) {
72 $object->fetchComments();
73 }
74 $id = $object->id;
75 }
76}
77
78// include comment actions
79include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php';
80
81/*
82 * View
83*/
84
85$title = $langs->trans('CommentPage');
86
87llxHeader('', $title, '');
88
89$form = new Form($db);
90$formother = new FormOther($db);
91$formfile = new FormFile($db);
92
93// Tabs for project
94$tab = 'project_comment';
95$head = project_prepare_head($object);
96print dol_get_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project'));
97
98$param = ($mode == 'mine' ? '&mode=mine' : '');
99
100// Project card
101
102if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
103 $tmpurl = $_SESSION['pageforbacktolist']['project'];
104 $tmpurl = preg_replace('/__SOCID__/', (string) $object->socid, $tmpurl);
105 $linkback = '<a href="'.$tmpurl.(preg_match('/\?/', $tmpurl) ? '&' : '?'). 'restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
106} else {
107 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
108}
109
110$morehtmlref = '<div class="refidno">';
111// Title
112$morehtmlref .= $object->title;
113// Thirdparty
114if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
115 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
116}
117$morehtmlref .= '</div>';
118
119// Define a complementary filter for search of next/prev ref.
120if (!$user->hasRight('projet', 'all', 'lire')) {
121 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
122 $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0').")";
123}
124
125dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
126
127print '<div class="fichecenter">';
128print '<div class="fichehalfleft">';
129print '<div class="underbanner clearboth"></div>';
130
131print '<table class="border centpercent">';
132
133// Visibility
134print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
135if ($object->public) {
136 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
137 print $langs->trans('SharedProject');
138} else {
139 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
140 print $langs->trans('PrivateProject');
141}
142print '</td></tr>';
143
144// Budget
145print '<tr><td>'.$langs->trans("Budget").'</td><td>';
146if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) {
147 print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
148}
149print '</td></tr>';
150
151// Date start - end project
152print '<tr><td>'.$langs->trans("Dates").'</td><td>';
153print dol_print_date($object->date_start, 'day');
154$end = dol_print_date($object->date_end, 'day');
155if ($end) {
156 print ' - '.$end;
157}
158print '</td></tr>';
159
160// Other attributes
161$cols = 2;
162// include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
163
164print '</table>';
165
166print '</div>';
167print '<div class="fichehalfright">';
168print '<div class="underbanner clearboth"></div>';
169
170print '<table class="border centpercent">';
171
172// Description
173print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
174print nl2br($object->description);
175print '</td></tr>';
176
177// Categories
178if (isModEnabled('category')) {
179 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
180 print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
181 print "</td></tr>";
182}
183
184// Nb comments
185print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
186print $object->getNbComments();
187print '</td></tr>';
188
189print '</table>';
190
191print '</div>';
192print '</div>';
193
194print '<div class="clearboth"></div>';
195
196print dol_get_fiche_end();
197
198print '<br>';
199
200// Include comment tpl view
201include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_comment.tpl.php';
202
203// End of page
204llxFooter();
205$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.
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_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 dolibarr global constant string value.
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.