28require 
'../../main.inc.php';
 
   29require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
 
   30require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
 
   31require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
 
   32require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
 
   33require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
 
   34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
 
   37$langs->loadLangs(array(
'projects', 
'other'));
 
   39$action = 
GETPOST(
'action', 
'aZ09');
 
   40$confirm = 
GETPOST(
'confirm', 
'alpha');
 
   41$mine = 
GETPOST(
'mode') == 
'mine' ? 1 : 0;
 
   45$withproject = 
GETPOST(
'withproject', 
'int');
 
   46$project_ref = 
GETPOST(
'project_ref', 
'alpha');
 
   49$limit = 
GETPOST(
'limit', 
'int') ? 
GETPOST(
'limit', 
'int') : $conf->liste_limit;
 
   50$sortfield = 
GETPOST(
'sortfield', 
'aZ09comma');
 
   51$sortorder = 
GETPOST(
'sortorder', 
'aZ09comma');
 
   52$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) : 
GETPOST(
"page", 
'int');
 
   53if (empty($page) || $page == -1) {
 
   56$offset = $limit * $page;
 
   66$object = 
new Task($db);
 
   67$projectstatic = 
new Project($db);
 
   70  $object->fetch($id, $ref);
 
   76restrictedArea($user, 
'projet', $object->fk_project, 
'projet&project');
 
   78$permissiontoadd = $user->hasRight(
'projet', 
'creer'); 
 
   86if (!empty($project_ref) && !empty($withproject)) {
 
   87  if ($projectstatic->fetch(0, $project_ref) > 0) {
 
   88    $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
 
   89    if (count($tasksarray) > 0) {
 
   90      $id = $tasksarray[0]->id;
 
   93      header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ? 
'&withproject=1' : 
'').(empty($mode) ? 
'' : 
'&mode='.$mode));
 
   99if ($id > 0 || !empty($ref)) {
 
  100  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 
'fetchComments') && empty($object->comments)) {
 
  101    $object->fetchComments();
 
  103  $projectstatic->fetch($object->fk_project);
 
  104  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 
'fetchComments') && empty($projectstatic->comments)) {
 
  105    $projectstatic->fetchComments();
 
  108  if (!empty($projectstatic->socid)) {
 
  109    $projectstatic->fetch_thirdparty();
 
  112  $object->project = clone $projectstatic;
 
  117include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
 
  123$form = 
new Form($db);
 
  125$title = $object->ref . 
' - ' . $langs->trans(
"Documents");
 
  126if (!empty($withproject)) {
 
  127  $title .= 
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ? 
': '.$projectstatic->ref : 
'')  ;
 
  133if ($object->id > 0) {
 
  134  $projectstatic->fetch_thirdparty();
 
  136  $userWrite = $projectstatic->restrictedProjectArea($user, 
'write');
 
  138  if (!empty($withproject)) {
 
  143    print 
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ? 
'projectpub' : 
'project'));
 
  145    $param = (isset($mode) && $mode == 
'mine' ? 
'&mode=mine' : 
'');
 
  149    $linkback = 
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
 
  151    $morehtmlref = 
'<div class="refidno">';
 
  153    $morehtmlref .= $projectstatic->title;
 
  155    if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
 
  156      $morehtmlref .= 
'<br>'.$projectstatic->thirdparty->getNomUrl(1, 
'project');
 
  158    $morehtmlref .= 
'</div>';
 
  161    if (empty($user->rights->projet->all->lire)) {
 
  162      $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
 
  163      $projectstatic->next_prev_filter = 
"rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) : 
'0').
")";
 
  166    dol_banner_tab($projectstatic, 
'project_ref', $linkback, 1, 
'ref', 
'ref', $morehtmlref);
 
  168    print 
'<div class="fichecenter">';
 
  169    print 
'<div class="fichehalfleft">';
 
  170    print 
'<div class="underbanner clearboth"></div>';
 
  172    print 
'<table class="border tableforfield centpercent">';
 
  175    if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled(
'eventorganization')) {
 
  176      print 
'<tr><td class="tdtop">';
 
  177      print $langs->trans(
"Usage");
 
  180      if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
 
  181        print 
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity', 
'alpha') != 
'' ? 
' checked="checked"' : 
'') : ($projectstatic->usage_opportunity ? 
' checked="checked"' : 
'')).
'"> ';
 
  182        $htmltext = $langs->trans(
"ProjectFollowOpportunity");
 
  183        print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
 
  186      if (empty($conf->global->PROJECT_HIDE_TASKS)) {
 
  187        print 
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task', 
'alpha') != 
'' ? 
' checked="checked"' : 
'') : ($projectstatic->usage_task ? 
' checked="checked"' : 
'')).
'"> ';
 
  188        $htmltext = $langs->trans(
"ProjectFollowTasks");
 
  189        print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
 
  192      if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
 
  193        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"' : 
'')).
'"> ';
 
  194        $htmltext = $langs->trans(
"ProjectBillTimeDescription");
 
  195        print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
 
  198      if (isModEnabled(
'eventorganization')) {
 
  199        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"' : 
'')).
'"> ';
 
  200        $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
 
  201        print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
 
  207    print 
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
 
  208    if ($projectstatic->public) {
 
  209      print 
img_picto($langs->trans(
'SharedProject'), 
'world', 
'class="paddingrightonly"');
 
  210      print $langs->trans(
'SharedProject');
 
  212      print 
img_picto($langs->trans(
'PrivateProject'), 
'private', 
'class="paddingrightonly"');
 
  213      print $langs->trans(
'PrivateProject');
 
  218    print 
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
 
  219    if (strcmp($projectstatic->budget_amount, 
'')) {
 
  220      print 
price($projectstatic->budget_amount, 
'', $langs, 1, 0, 0, $conf->currency);
 
  225    print 
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
 
  227    print ($start ? $start : 
'?');
 
  230    print ($end ? $end : 
'?');
 
  231    if ($projectstatic->hasDelay()) {
 
  243    print 
'<div class="fichehalfright">';
 
  244    print 
'<div class="underbanner clearboth"></div>';
 
  246    print 
'<table class="border tableforfield centpercent">';
 
  249    print 
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
 
  250    print nl2br($projectstatic->description);
 
  254    if (isModEnabled(
'categorie')) {
 
  255      print 
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
 
  256      print $form->showCategories($projectstatic->id, 
'project', 1);
 
  265    print 
'<div class="clearboth"></div>';
 
  273  print 
dol_get_fiche_head($head, 
'task_document', $langs->trans(
"Task"), -1, 
'projecttask', 0, 
'', 
'reposition');
 
  276  $filearray = 
dol_dir_list($upload_dir, 
"files", 0, 
'', 
'(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 
'desc' ?SORT_DESC:SORT_ASC), 1);
 
  278  foreach ($filearray as $key => $file) {
 
  279    $totalsize += $file[
'size'];
 
  282  $param = (
GETPOST(
'withproject') ? 
'&withproject=1' : 
'');
 
  283  $linkback = 
GETPOST(
'withproject') ? 
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' : 
'';
 
  285  if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
 
  286    $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
 
  287    $object->next_prev_filter = 
"fk_projet IN (".$db->sanitize($projectsListId).
")";
 
  289    $object->next_prev_filter = 
"fk_projet = ".((int) $projectstatic->id);
 
  295  if (empty($withproject)) {
 
  296    $morehtmlref .= 
'<div class="refidno">';
 
  297    $morehtmlref .= $langs->trans(
"Project").
': ';
 
  298    $morehtmlref .= $projectstatic->getNomUrl(1);
 
  299    $morehtmlref .= 
'<br>';
 
  302    $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
 
  303    if (is_object($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) {
 
  304      $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
 
  306    $morehtmlref .= 
'</div>';
 
  309  dol_banner_tab($object, 
'ref', $linkback, 1, 
'ref', 
'ref', $morehtmlref, $param);
 
  311  print 
'<div class="fichecenter">';
 
  313  print 
'<div class="underbanner clearboth"></div>';
 
  314  print 
'<table class="border tableforfield centpercent">';
 
  317  print 
'<tr><td class="titlefield">'.$langs->trans(
"NbOfAttachedFiles").
'</td><td colspan="3">'.count($filearray).
'</td></tr>';
 
  318  print 
'<tr><td>'.$langs->trans(
"TotalSizeOfAttachedFiles").
'</td><td colspan="3">'.$totalsize.
' '.$langs->trans(
"bytes").
'</td></tr>';
 
  330    $param .= 
'&withproject=1';
 
  332  $modulepart = 
'project_task';
 
  333  $permissiontoadd = $user->hasRight(
'projet', 
'creer');
 
  334  $permtoedit = $user->hasRight(
'projet', 
'creer');
 
  336  include DOL_DOCUMENT_ROOT.
'/core/tpl/document_actions_post_headers.tpl.php';
 
  338  header(
'Location: index.php');
 
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
 
Class to manage projects.
 
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
 
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.
 
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
 
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.
 
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
 
task_prepare_head($object)
Prepare array with list of tabs.
 
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
 
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.