dolibarr  13.0.2
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 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
36 
37 // Load translation files required by the page
38 $langs->loadLangs(array('projects', 'companies'));
39 
40 $id = GETPOST('id', 'int');
41 $idcomment = GETPOST('idcomment', 'int');
42 $ref = GETPOST("ref", 'alpha', 1); // task ref
43 $objectref = GETPOST("taskref", 'alpha'); // task ref
44 $action = GETPOST('action', 'aZ09');
45 $confirm = GETPOST('confirm', 'alpha');
46 $withproject = GETPOST('withproject', 'int');
47 $project_ref = GETPOST('project_ref', 'alpha');
48 $planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : '');
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 assignement.
53 if (!$user->rights->projet->lire) accessforbidden();
54 
55 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
56 $hookmanager->initHooks(array('projectcard', 'globalcard'));
57 
58 $extrafields = new ExtraFields($db);
59 $object = new Project($db);
60 
61 // fetch optionals attributes and labels
62 $extrafields->fetch_name_optionals_label($object->table_element);
63 
64 // Load object
65 if ($id > 0 || !empty($ref))
66 {
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)) $object->fetchComments();
71  $id = $object->id;
72  }
73 }
74 
75 // include comment actions
76 include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php';
77 
78 /*
79  * View
80 */
81 
82 
83 llxHeader('', $langs->trans("CommentPage"));
84 
85 $form = new Form($db);
86 $formother = new FormOther($db);
87 $formfile = new FormFile($db);
88 
89 // Tabs for project
90 $tab = 'project_comment';
91 $head = project_prepare_head($object);
92 print dol_get_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project'));
93 
94 $param = ($mode == 'mine' ? '&mode=mine' : '');
95 
96 // Project card
97 
98 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
99 
100 $morehtmlref = '<div class="refidno">';
101 // Title
102 $morehtmlref .= $object->title;
103 // Thirdparty
104 if ($object->thirdparty->id > 0) {
105  $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
106 }
107 $morehtmlref .= '</div>';
108 
109 // Define a complementary filter for search of next/prev ref.
110 if (!$user->rights->projet->all->lire) {
111  $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
112  $object->next_prev_filter = " rowid in (".(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
113 }
114 
115 dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
116 
117 print '<div class="fichecenter">';
118 print '<div class="fichehalfleft">';
119 print '<div class="underbanner clearboth"></div>';
120 
121 print '<table class="border centpercent">';
122 
123 // Visibility
124 print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
125 if ($object->public) print $langs->trans('SharedProject');
126 else print $langs->trans('PrivateProject');
127 print '</td></tr>';
128 
129 // Date start - end
130 print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
131 print dol_print_date($object->date_start, 'day');
132 $end = dol_print_date($object->date_end, 'day');
133 if ($end) print ' - '.$end;
134 print '</td></tr>';
135 
136 // Budget
137 print '<tr><td>'.$langs->trans("Budget").'</td><td>';
138 if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
139 print '</td></tr>';
140 
141 // Other attributes
142 $cols = 2;
143 // include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
144 
145 print '</table>';
146 
147 print '</div>';
148 print '<div class="fichehalfright">';
149 print '<div class="ficheaddleft">';
150 print '<div class="underbanner clearboth"></div>';
151 
152 print '<table class="border centpercent">';
153 
154 // Description
155 print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
156 print nl2br($object->description);
157 print '</td></tr>';
158 
159 // Categories
160 if ($conf->categorie->enabled) {
161  print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
162  print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
163  print "</td></tr>";
164 }
165 
166 // Nb comments
167 print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
168 print $object->getNbComments();
169 print '</td></tr>';
170 
171 print '</table>';
172 
173 print '</div>';
174 print '</div>';
175 print '</div>';
176 
177 print '<div class="clearboth"></div>';
178 
180 
181 print '<br>';
182 
183 // Include comment tpl view
184 include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_comment.tpl.php';
185 
186 // End of page
187 llxFooter();
188 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Classe permettant la generation de composants html autre Only common components are here...
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to offer components to list and upload files.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
project_prepare_head(Project $project)
Prepare array with list of tabs.
Definition: project.lib.php:36
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59