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
20/**
21 *	\file       htdocs/projet/tasks/task.php
22 *	\ingroup    project
23 *	\brief      Page of a project task
24 */
25
26require '../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
28require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
35require_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
48// Security check
49$socid = 0;
50//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.
51if (!$user->rights->projet->lire) {
52	accessforbidden();
53}
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
65if ($id > 0 || !empty($ref)) {
66	$ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database
67	if ($ret > 0) {
68		$object->fetch_thirdparty();
69		if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
70			$object->fetchComments();
71		}
72		$id = $object->id;
73	}
74}
75
76// include comment actions
77include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php';
78
79/*
80 * View
81*/
82
83$title = $langs->trans('CommentPage');
84
85llxHeader('', $title, '');
86
87$form = new Form($db);
88$formother = new FormOther($db);
89$formfile = new FormFile($db);
90
91// Tabs for project
92$tab = 'project_comment';
93$head = project_prepare_head($object);
94print dol_get_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project'));
95
96$param = ($mode == 'mine' ? '&mode=mine' : '');
97
98// Project card
99
100$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
101
102$morehtmlref = '<div class="refidno">';
103// Title
104$morehtmlref .= $object->title;
105// Thirdparty
106if ($object->thirdparty->id > 0) {
107	$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
108}
109$morehtmlref .= '</div>';
110
111// Define a complementary filter for search of next/prev ref.
112if (!$user->rights->projet->all->lire) {
113	$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
114	$object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
115}
116
117dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
118
119print '<div class="fichecenter">';
120print '<div class="fichehalfleft">';
121print '<div class="underbanner clearboth"></div>';
122
123print '<table class="border centpercent">';
124
125// Visibility
126print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
127if ($object->public) {
128	print $langs->trans('SharedProject');
129} else {
130	print $langs->trans('PrivateProject');
131}
132print '</td></tr>';
133
134// Date start - end
135print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
136print dol_print_date($object->date_start, 'day');
137$end = dol_print_date($object->date_end, 'day');
138if ($end) {
139	print ' - '.$end;
140}
141print '</td></tr>';
142
143// Budget
144print '<tr><td>'.$langs->trans("Budget").'</td><td>';
145if (strcmp($object->budget_amount, '')) {
146	print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
147}
148print '</td></tr>';
149
150// Other attributes
151$cols = 2;
152// include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
153
154print '</table>';
155
156print '</div>';
157print '<div class="fichehalfright">';
158print '<div class="ficheaddleft">';
159print '<div class="underbanner clearboth"></div>';
160
161print '<table class="border centpercent">';
162
163// Description
164print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
165print nl2br($object->description);
166print '</td></tr>';
167
168// Categories
169if ($conf->categorie->enabled) {
170	print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
171	print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
172	print "</td></tr>";
173}
174
175// Nb comments
176print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
177print $object->getNbComments();
178print '</td></tr>';
179
180print '</table>';
181
182print '</div>';
183print '</div>';
184print '</div>';
185
186print '<div class="clearboth"></div>';
187
188print dol_get_fiche_end();
189
190print '<br>';
191
192// Include comment tpl view
193include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_comment.tpl.php';
194
195// End of page
196llxFooter();
197$db->close();
198