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