dolibarr  19.0.0-dev
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
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
36 require_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.
52 if (!$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
66 if ($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
78 include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php';
79 
80 /*
81  * View
82 */
83 
84 $title = $langs->trans('CommentPage');
85 
86 llxHeader('', $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);
95 print 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 
101 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
102 
103 $morehtmlref = '<div class="refidno">';
104 // Title
105 $morehtmlref .= $object->title;
106 // Thirdparty
107 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
108  $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
109 }
110 $morehtmlref .= '</div>';
111 
112 // Define a complementary filter for search of next/prev ref.
113 if (empty($user->rights->projet->all->lire)) {
114  $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
115  $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
116 }
117 
118 dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
119 
120 print '<div class="fichecenter">';
121 print '<div class="fichehalfleft">';
122 print '<div class="underbanner clearboth"></div>';
123 
124 print '<table class="border centpercent">';
125 
126 // Visibility
127 print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
128 if ($object->public) {
129  print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
130  print $langs->trans('SharedProject');
131 } else {
132  print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
133  print $langs->trans('PrivateProject');
134 }
135 print '</td></tr>';
136 
137 // Budget
138 print '<tr><td>'.$langs->trans("Budget").'</td><td>';
139 if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) {
140  print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
141 }
142 print '</td></tr>';
143 
144 // Date start - end project
145 print '<tr><td>'.$langs->trans("Dates").'</td><td>';
146 print dol_print_date($object->date_start, 'day');
147 $end = dol_print_date($object->date_end, 'day');
148 if ($end) {
149  print ' - '.$end;
150 }
151 print '</td></tr>';
152 
153 // Other attributes
154 $cols = 2;
155 // include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
156 
157 print '</table>';
158 
159 print '</div>';
160 print '<div class="fichehalfright">';
161 print '<div class="underbanner clearboth"></div>';
162 
163 print '<table class="border centpercent">';
164 
165 // Description
166 print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
167 print nl2br($object->description);
168 print '</td></tr>';
169 
170 // Categories
171 if (isModEnabled('categorie')) {
172  print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
173  print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
174  print "</td></tr>";
175 }
176 
177 // Nb comments
178 print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
179 print $object->getNbComments();
180 print '</td></tr>';
181 
182 print '</table>';
183 
184 print '</div>';
185 print '</div>';
186 
187 print '<div class="clearboth"></div>';
188 
189 print dol_get_fiche_end();
190 
191 print '<br>';
192 
193 // Include comment tpl view
194 include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_comment.tpl.php';
195 
196 // End of page
197 llxFooter();
198 $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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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.
isModEnabled($module)
Is Dolibarr module enabled.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
Definition: project.lib.php:39
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.