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 = $_REQUEST[
'mode'] ==
'mine' ? 1 : 0;
44 $withproject =
GETPOST(
'withproject',
'int');
45 $project_ref =
GETPOST(
'project_ref',
'alpha');
54 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
55 $sortfield =
GETPOST(
"sortfield",
'alpha');
56 $sortorder =
GETPOST(
"sortorder",
'alpha');
58 if (empty($page) || $page == -1) { $page = 0; }
59 $offset = $limit * $page;
60 $pageprev = $page - 1;
61 $pagenext = $page + 1;
62 if (!$sortorder) $sortorder =
"ASC";
63 if (!$sortfield) $sortfield =
"name";
65 $object =
new Task($db);
66 $projectstatic =
new Project($db);
73 if (!empty($project_ref) && !empty($withproject))
75 if ($projectstatic->fetch(0, $project_ref) > 0)
77 $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
78 if (count($tasksarray) > 0)
80 $id = $tasksarray[0]->id;
83 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ?
'&withproject=1' :
'').(empty($mode) ?
'' :
'&mode='.$mode));
89 if ($id > 0 || !empty($ref))
91 if ($object->fetch($id, $ref) > 0)
93 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) $object->fetchComments();
94 $projectstatic->fetch($object->fk_project);
95 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments();
97 if (!empty($projectstatic->socid)) {
98 $projectstatic->fetch_thirdparty();
101 $object->project = clone $projectstatic;
109 include_once DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
116 $form =
new Form($db);
122 $projectstatic->fetch_thirdparty();
124 $userWrite = $projectstatic->restrictedProjectArea($user,
'write');
126 if (!empty($withproject))
132 print dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
134 $param = ($mode ==
'mine' ?
'&mode=mine' :
'');
138 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
140 $morehtmlref =
'<div class="refidno">';
142 $morehtmlref .= $projectstatic->title;
144 if ($projectstatic->thirdparty->id > 0)
146 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$projectstatic->thirdparty->getNomUrl(1,
'project');
148 $morehtmlref .=
'</div>';
151 if (!$user->rights->projet->all->lire)
153 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
154 $projectstatic->next_prev_filter =
" rowid in (".(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
157 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
159 print '<div class="fichecenter">';
160 print '<div class="fichehalfleft">';
161 print '<div class="underbanner clearboth"></div>';
163 print '<table class="border tableforfield centpercent">';
166 print '<tr><td class="tdtop">';
167 print $langs->trans(
"Usage");
170 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
172 print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
173 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
174 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
177 if (empty($conf->global->PROJECT_HIDE_TASKS))
179 print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
180 $htmltext = $langs->trans(
"ProjectFollowTasks");
181 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
184 if (!empty($conf->global->PROJECT_BILL_TIME_SPENT))
186 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"' :
'')).
'"> ';
187 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
188 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
194 print '<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
195 if ($projectstatic->public)
print $langs->trans(
'SharedProject');
196 else print $langs->trans(
'PrivateProject');
200 print '<tr><td>'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"DateEnd").
'</td><td>';
202 print ($start ? $start :
'?');
205 print ($end ? $end :
'?');
210 print '<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
211 if (strcmp($projectstatic->budget_amount,
''))
print price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency);
221 print '<div class="fichehalfright">';
222 print '<div class="ficheaddleft">';
223 print '<div class="underbanner clearboth"></div>';
225 print '<table class="border tableforfield centpercent">';
228 print '<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
229 print nl2br($projectstatic->description);
233 if ($conf->categorie->enabled) {
234 print '<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
235 print $form->showCategories($projectstatic->id,
'project', 1);
245 print '<div class="clearboth"></div>';
253 print dol_get_fiche_head($head,
'task_document', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
256 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) ==
'desc' ?SORT_DESC:SORT_ASC), 1);
258 foreach ($filearray as $key => $file)
260 $totalsize += $file[
'size'];
263 $param = (
GETPOST(
'withproject') ?
'&withproject=1' :
'');
264 $linkback =
GETPOST(
'withproject') ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
266 if (!
GETPOST(
'withproject') || empty($projectstatic->id))
268 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
269 $object->next_prev_filter =
" fk_projet in (".$projectsListId.
")";
270 }
else $object->next_prev_filter =
" fk_projet = ".$projectstatic->id;
275 if (empty($withproject))
277 $morehtmlref .=
'<div class="refidno">';
278 $morehtmlref .= $langs->trans(
"Project").
': ';
279 $morehtmlref .= $projectstatic->getNomUrl(1);
280 $morehtmlref .=
'<br>';
283 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
284 if (is_object($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
285 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
287 $morehtmlref .=
'</div>';
290 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
292 print '<div class="fichecenter">';
294 print '<div class="underbanner clearboth"></div>';
295 print '<table class="border tableforfield centpercent">';
298 print '<tr><td class="titlefield">'.$langs->trans(
"NbOfAttachedFiles").
'</td><td colspan="3">'.count($filearray).
'</td></tr>';
299 print '<tr><td>'.$langs->trans(
"TotalSizeOfAttachedFiles").
'</td><td colspan="3">'.$totalsize.
' '.$langs->trans(
"bytes").
'</td></tr>';
310 if ($withproject) $param .=
'&withproject=1';
311 $modulepart =
'project_task';
312 $permission = $user->rights->projet->creer;
313 $permtoedit = $user->rights->projet->creer;
315 include_once DOL_DOCUMENT_ROOT.
'/core/tpl/document_actions_post_headers.tpl.php';
317 header(
'Location: index.php');
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage projects.
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 ...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
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.
print
Draft customers invoices.
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_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
task_prepare_head($object)
Prepare array with list of tabs.