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