info.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. /* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/projet/info.php
  20. * \ingroup commande
  21. * \brief Page with info on project
  22. */
  23. require '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  28. // Load translation files required by the page
  29. $langs->load("projects");
  30. $id = GETPOST('id','int');
  31. $ref = GETPOST('ref','alpha');
  32. $socid = GETPOST('socid','int');
  33. $action = GETPOST('action','alpha');
  34. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  35. $sortfield = GETPOST("sortfield","alpha");
  36. $sortorder = GETPOST("sortorder");
  37. $page = GETPOST("page");
  38. $page = is_numeric($page) ? $page : 0;
  39. $page = $page == -1 ? 0 : $page;
  40. if (! $sortfield) $sortfield="a.datep,a.id";
  41. if (! $sortorder) $sortorder="DESC";
  42. $offset = $limit * $page ;
  43. $pageprev = $page - 1;
  44. $pagenext = $page + 1;
  45. if (GETPOST('actioncode','array'))
  46. {
  47. $actioncode=GETPOST('actioncode','array',3);
  48. if (! count($actioncode)) $actioncode='0';
  49. }
  50. else
  51. {
  52. $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
  53. }
  54. $search_agenda_label=GETPOST('search_agenda_label');
  55. // Security check
  56. $id = GETPOST("id",'int');
  57. $socid=0;
  58. //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
  59. $result=restrictedArea($user,'projet',$id,'');
  60. if (!$user->rights->projet->lire) accessforbidden();
  61. /*
  62. * Actions
  63. */
  64. $parameters=array('id'=>$socid);
  65. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  66. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  67. // Purge search criteria
  68. if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers
  69. {
  70. $actioncode='';
  71. $search_agenda_label='';
  72. }
  73. /*
  74. * View
  75. */
  76. $form = new Form($db);
  77. $object = new Project($db);
  78. if ($id > 0 || ! empty($ref))
  79. {
  80. $object->fetch($id, $ref);
  81. $object->fetch_thirdparty();
  82. if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments();
  83. $object->info($object->id);
  84. }
  85. $title=$langs->trans("Project").' - '.$object->ref.' '.$object->name;
  86. if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("Info");
  87. $help_url="EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  88. llxHeader("",$title,$help_url);
  89. $head = project_prepare_head($object);
  90. dol_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public?'projectpub':'project'));
  91. // Project card
  92. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  93. $morehtmlref='<div class="refidno">';
  94. // Title
  95. $morehtmlref.=$object->title;
  96. // Thirdparty
  97. if ($object->thirdparty->id > 0)
  98. {
  99. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project');
  100. }
  101. $morehtmlref.='</div>';
  102. // Define a complementary filter for search of next/prev ref.
  103. if (! $user->rights->projet->all->lire)
  104. {
  105. $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0);
  106. $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
  107. }
  108. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  109. print '<div class="fichecenter">';
  110. print '<div class="underbanner clearboth"></div>';
  111. dol_print_object_info($object, 1);
  112. print '</div>';
  113. print '<div class="clearboth"></div>';
  114. dol_fiche_end();
  115. // Actions buttons
  116. $out='';
  117. $permok=$user->rights->agenda->myactions->create;
  118. if ($permok)
  119. {
  120. $out.='&projectid='.$object->id;
  121. }
  122. //print '<div class="tabsAction">';
  123. $morehtmlcenter='';
  124. if (! empty($conf->agenda->enabled))
  125. {
  126. if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
  127. {
  128. $morehtmlcenter.='<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'"><span class="valignmiddle">'.$langs->trans("AddAction").'</span>';
  129. $morehtmlcenter.='<span class="fa fa-plus-circle valignmiddle"></span>';
  130. $morehtmlcenter.='</a>';
  131. }
  132. else
  133. {
  134. $morehtmlcenter.='<a class="butActionRefused" href="#">'.$langs->trans("AddAction").'</a>';
  135. }
  136. }
  137. //print '</div>';
  138. if (!empty($object->id))
  139. {
  140. print '<br>';
  141. $param='&id='.$object->id;
  142. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  143. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  144. print_barre_liste($langs->trans("ActionsOnProject"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1);
  145. // List of all actions
  146. $filters=array();
  147. $filters['search_agenda_label']=$search_agenda_label;
  148. show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
  149. }
  150. // End of page
  151. llxFooter();
  152. $db->close();