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/lib/files.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
36 $langs->loadLangs(array(
'projects',
'other'));
38 $action =
GETPOST(
'action',
'aZ09');
39 $confirm =
GETPOST(
'confirm',
'alpha');
40 $mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
44 $withproject =
GETPOST(
'withproject',
'int');
45 $project_ref =
GETPOST(
'project_ref',
'alpha');
48 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
49 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52 if (empty($page) || $page == -1) {
55 $offset = $limit * $page;
56 $pageprev = $page - 1;
57 $pagenext = $page + 1;
65 $object =
new Task($db);
66 $projectstatic =
new Project($db);
68 if ($id > 0 || $ref) {
69 $object->fetch($id, $ref);
75 restrictedArea($user,
'projet', $object->fk_project,
'projet&project');
77 $permissiontoadd = $user->rights->projet->creer;
85 if (!empty($project_ref) && !empty($withproject)) {
86 if ($projectstatic->fetch(0, $project_ref) > 0) {
87 $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
88 if (count($tasksarray) > 0) {
89 $id = $tasksarray[0]->id;
92 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ?
'&withproject=1' :
'').(empty($mode) ?
'' :
'&mode='.$mode));
98 if ($id > 0 || !empty($ref)) {
99 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) {
100 $object->fetchComments();
102 $projectstatic->fetch($object->fk_project);
103 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
104 $projectstatic->fetchComments();
107 if (!empty($projectstatic->socid)) {
108 $projectstatic->fetch_thirdparty();
111 $object->project = clone $projectstatic;
116 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
127 if ($object->id > 0) {
128 $projectstatic->fetch_thirdparty();
130 $userWrite = $projectstatic->restrictedProjectArea($user,
'write');
132 if (!empty($withproject)) {
137 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
139 $param = ($mode ==
'mine' ?
'&mode=mine' :
'');
143 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
145 $morehtmlref =
'<div class="refidno">';
147 $morehtmlref .= $projectstatic->title;
149 if ($projectstatic->thirdparty->id > 0) {
150 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$projectstatic->thirdparty->getNomUrl(1,
'project');
152 $morehtmlref .=
'</div>';
155 if (empty($user->rights->projet->all->lire)) {
156 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
157 $projectstatic->next_prev_filter =
" rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
160 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
162 print
'<div class="fichecenter">';
163 print
'<div class="fichehalfleft">';
164 print
'<div class="underbanner clearboth"></div>';
166 print
'<table class="border tableforfield centpercent">';
169 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
170 print
'<tr><td class="tdtop">';
171 print $langs->trans(
"Usage");
174 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
175 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
176 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
177 print
$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
180 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
181 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
182 $htmltext = $langs->trans(
"ProjectFollowTasks");
183 print
$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
186 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
187 print
'<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET(
'usage_bill_time') ? (
GETPOST(
'usage_bill_time',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_bill_time ?
' checked="checked"' :
'')).
'"> ';
188 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
189 print
$form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
192 if (!empty($conf->eventorganization->enabled)) {
193 print
'<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET(
'usage_organize_event') ? (
GETPOST(
'usage_organize_event',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_organize_event ?
' checked="checked"' :
'')).
'"> ';
194 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
195 print
$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
201 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
202 if ($projectstatic->public) {
203 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
204 print $langs->trans(
'SharedProject');
206 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
207 print $langs->trans(
'PrivateProject');
212 print
'<tr><td>'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"DateEnd").
'</td><td>';
214 print ($start ? $start :
'?');
217 print ($end ? $end :
'?');
218 if ($projectstatic->hasDelay()) {
224 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
225 if (strcmp($projectstatic->budget_amount,
'')) {
226 print
price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency);
237 print
'<div class="fichehalfright">';
238 print
'<div class="underbanner clearboth"></div>';
240 print
'<table class="border tableforfield centpercent">';
243 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
244 print nl2br($projectstatic->description);
249 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
250 print
$form->showCategories($projectstatic->id,
'project', 1);
259 print
'<div class="clearboth"></div>';
267 print
dol_get_fiche_head($head,
'task_document', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
270 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) ==
'desc' ?SORT_DESC:SORT_ASC), 1);
272 foreach ($filearray as $key => $file) {
273 $totalsize += $file[
'size'];
276 $param = (
GETPOST(
'withproject') ?
'&withproject=1' :
'');
277 $linkback =
GETPOST(
'withproject') ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
279 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
280 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
281 $object->next_prev_filter =
" fk_projet IN (".$db->sanitize($projectsListId).
")";
283 $object->next_prev_filter =
" fk_projet = ".$projectstatic->id;
289 if (empty($withproject)) {
290 $morehtmlref .=
'<div class="refidno">';
291 $morehtmlref .= $langs->trans(
"Project").
': ';
292 $morehtmlref .= $projectstatic->getNomUrl(1);
293 $morehtmlref .=
'<br>';
296 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
297 if (is_object($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
298 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
300 $morehtmlref .=
'</div>';
303 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
305 print
'<div class="fichecenter">';
307 print
'<div class="underbanner clearboth"></div>';
308 print
'<table class="border tableforfield centpercent">';
311 print
'<tr><td class="titlefield">'.$langs->trans(
"NbOfAttachedFiles").
'</td><td colspan="3">'.count($filearray).
'</td></tr>';
312 print
'<tr><td>'.$langs->trans(
"TotalSizeOfAttachedFiles").
'</td><td colspan="3">'.$totalsize.
' '.$langs->trans(
"bytes").
'</td></tr>';
324 $param .=
'&withproject=1';
326 $modulepart =
'project_task';
327 $permissiontoadd = $user->rights->projet->creer;
328 $permtoedit = $user->rights->projet->creer;
330 include DOL_DOCUMENT_ROOT.
'/core/tpl/document_actions_post_headers.tpl.php';
332 header(
'Location: index.php');