dolibarr  16.0.5
info.php
Go to the documentation of this file.
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 <https://www.gnu.org/licenses/>.
17  */
18 
25 require '../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
30 
31 // Load translation files required by the page
32 $langs->load("projects");
33 
34 $id = GETPOST('id', 'int');
35 $ref = GETPOST('ref', 'alpha');
36 $socid = GETPOST('socid', 'int');
37 $action = GETPOST('action', 'aZ09');
38 
39 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
40 $sortfield = GETPOST("sortfield", "aZ09comma");
41 $sortorder = GETPOST("sortorder", 'aZ09comma');
42 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
43 $page = is_numeric($page) ? $page : 0;
44 $page = $page == -1 ? 0 : $page;
45 if (!$sortfield) {
46  $sortfield = "a.datep,a.id";
47 }
48 if (!$sortorder) {
49  $sortorder = "DESC";
50 }
51 $offset = $limit * $page;
52 $pageprev = $page - 1;
53 $pagenext = $page + 1;
54 
55 if (GETPOST('actioncode', 'array')) {
56  $actioncode = GETPOST('actioncode', 'array', 3);
57  if (!count($actioncode)) {
58  $actioncode = '0';
59  }
60 } else {
61  $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));
62 }
63 $search_agenda_label = GETPOST('search_agenda_label');
64 
65 $hookmanager->initHooks(array('projectcardinfo'));
66 
67 // Security check
68 $id = GETPOST("id", 'int');
69 $socid = 0;
70 //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.
71 $result = restrictedArea($user, 'projet', $id, 'projet&project');
72 
73 if (!$user->rights->projet->lire) {
75 }
76 
77 
78 
79 /*
80  * Actions
81  */
82 
83 $parameters = array('id'=>$socid);
84 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
85 if ($reshook < 0) {
86  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
87 }
88 
89 // Purge search criteria
90 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
91  $actioncode = '';
92  $search_agenda_label = '';
93 }
94 
95 
96 
97 /*
98  * View
99  */
100 
101 $form = new Form($db);
102 $object = new Project($db);
103 
104 if ($id > 0 || !empty($ref)) {
105  $object->fetch($id, $ref);
106  $object->fetch_thirdparty();
107  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
108  $object->fetchComments();
109  }
110  $object->info($object->id);
111 }
112 
113 $title = $langs->trans("Project").' - '.$object->ref.' '.$object->name;
114 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
115  $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
116 }
117 $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
118 llxHeader("", $title, $help_url);
119 
120 $head = project_prepare_head($object);
121 
122 print dol_get_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
123 
124 
125 // Project card
126 
127 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
128 
129 $morehtmlref = '<div class="refidno">';
130 // Title
131 $morehtmlref .= $object->title;
132 // Thirdparty
133 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
134  $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
135 }
136 $morehtmlref .= '</div>';
137 
138 // Define a complementary filter for search of next/prev ref.
139 if (empty($user->rights->projet->all->lire)) {
140  $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
141  $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
142 }
143 
144 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
145 
146 
147 print '<div class="fichecenter">';
148 print '<div class="underbanner clearboth"></div>';
149 
150 dol_print_object_info($object, 1);
151 
152 print '</div>';
153 
154 print '<div class="clearboth"></div>';
155 
156 print dol_get_fiche_end();
157 
158 
159 // Actions buttons
160 
161 $out = '';
162 $permok = $user->rights->agenda->myactions->create;
163 if ($permok) {
164  $out .= '&projectid='.$object->id;
165 }
166 
167 
168 //print '<div class="tabsAction">';
169 $morehtmlcenter = '';
170 if (isModEnabled('agenda')) {
171  $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create);
172  $morehtmlcenter .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&socid='.$object->socid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight);
173 }
174 
175 //print '</div>';
176 
177 if (!empty($object->id)) {
178  print '<br>';
179 
180  $param = '&id='.$object->id;
181  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
182  $param .= '&contextpage='.$contextpage;
183  }
184  if ($limit > 0 && $limit != $conf->liste_limit) {
185  $param .= '&limit='.$limit;
186  }
187 
188  print_barre_liste($langs->trans("ActionsOnProject"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1);
189 
190  // List of all actions
191  $filters = array();
192  $filters['search_agenda_label'] = $search_agenda_label;
193  show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
194 }
195 
196 // End of page
197 llxFooter();
198 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
project_prepare_head
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
Definition: project.lib.php:38
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_banner_tab
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.
Definition: functions.lib.php:2046
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
show_actions_done
show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC', $module='')
Show html area with actions (done or not, ignore the name of function).
Definition: company.lib.php:1389
print_barre_liste
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
Definition: functions.lib.php:5257
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_print_object_info
dol_print_object_info($object, $usetable=0)
Show informations on an object TODO Move this into html.formother.
Definition: functions2.lib.php:205
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
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 ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59