dolibarr/htdocs/projet/info.php

199 lines
6.5 KiB
PHP
Raw Normal View History

2016-07-09 15:30:42 +02:00
<?php
/* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
2016-07-09 15:30:42 +02:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2016-07-09 15:30:42 +02:00
*/
/**
* \file htdocs/projet/info.php
2018-12-08 16:37:41 +01:00
* \ingroup project
* \brief Page with events on project
2016-07-09 15:30:42 +02:00
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
2016-10-25 10:53:25 +02:00
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
2016-07-09 15:30:42 +02:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
2016-07-09 15:30:42 +02:00
$langs->load("projects");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
2020-12-03 10:13:13 +01:00
$sortfield = GETPOST("sortfield", "aZ09comma");
$sortorder = GETPOST("sortorder", 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
$page = is_numeric($page) ? $page : 0;
$page = $page == -1 ? 0 : $page;
2021-02-26 18:49:22 +01:00
if (!$sortfield) {
$sortfield = "a.datep,a.id";
}
if (!$sortorder) {
$sortorder = "DESC";
}
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
2021-02-26 18:49:22 +01:00
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
2021-02-26 18:49:22 +01:00
if (!count($actioncode)) {
$actioncode = '0';
}
2020-05-21 15:05:19 +02:00
} else {
$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));
2016-10-17 17:52:58 +02:00
}
$search_agenda_label = GETPOST('search_agenda_label');
2016-10-17 17:52:58 +02:00
2022-03-07 14:31:19 +01:00
$hookmanager->initHooks(array('projectcardinfo'));
2016-07-09 15:30:42 +02:00
// Security check
$id = GETPOST("id", 'int');
$socid = 0;
//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.
$result = restrictedArea($user, 'projet', $id, 'projet&project');
2016-07-09 15:30:42 +02:00
2021-02-26 18:49:22 +01:00
if (!$user->rights->projet->lire) {
accessforbidden();
}
2016-10-17 17:52:58 +02:00
/*
2018-12-08 16:37:41 +01:00
* Actions
2016-10-17 17:52:58 +02:00
*/
$parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2021-02-26 18:49:22 +01:00
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
2016-10-17 17:52:58 +02:00
// Purge search criteria
2021-02-26 18:49:22 +01:00
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
$actioncode = '';
$search_agenda_label = '';
2016-10-17 17:52:58 +02:00
}
2016-07-09 15:30:42 +02:00
/*
* View
*/
2016-10-25 10:53:25 +02:00
$form = new Form($db);
$object = new Project($db);
2016-10-25 10:53:25 +02:00
2021-02-26 18:49:22 +01:00
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
$object->fetch_thirdparty();
2021-02-26 18:49:22 +01:00
if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
$object->fetchComments();
}
$object->info($object->id);
}
2016-07-09 15:30:42 +02:00
$title = $langs->trans("Project").' - '.$object->ref.' '.$object->name;
2021-02-26 18:49:22 +01:00
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");
}
$help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
llxHeader("", $title, $help_url);
2016-12-26 18:21:18 +01:00
2016-10-17 17:52:58 +02:00
$head = project_prepare_head($object);
2016-07-09 15:30:42 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
2016-07-09 15:30:42 +02:00
2016-10-17 18:18:06 +02:00
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
2016-10-17 18:18:06 +02:00
$morehtmlref = '<div class="refidno">';
2016-10-17 18:18:06 +02:00
// Title
$morehtmlref .= $object->title;
2016-10-17 18:18:06 +02:00
// Thirdparty
2021-10-24 10:02:12 +02:00
if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
2016-10-17 18:18:06 +02:00
}
$morehtmlref .= '</div>';
2016-10-17 18:18:06 +02:00
// Define a complementary filter for search of next/prev ref.
2021-10-24 10:02:12 +02:00
if (empty($user->rights->projet->all->lire)) {
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
2021-03-22 12:47:23 +01:00
$object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
2016-10-17 18:18:06 +02:00
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
2016-10-17 17:52:58 +02:00
dol_print_object_info($object, 1);
2016-10-17 18:18:06 +02:00
print '</div>';
print '<div class="clearboth"></div>';
2016-07-09 15:30:42 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
2016-10-17 17:52:58 +02:00
// Actions buttons
$out = '';
$permok = $user->rights->agenda->myactions->create;
2021-02-26 18:49:22 +01:00
if ($permok) {
$out .= '&projectid='.$object->id;
2016-10-17 17:52:58 +02:00
}
2017-10-04 12:58:13 +02:00
//print '<div class="tabsAction">';
$morehtmlcenter = '';
2022-06-09 22:16:48 +02:00
if (isModEnabled('agenda')) {
$addActionBtnRight = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create);
2021-02-26 18:49:22 +01:00
$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);
2016-10-17 17:52:58 +02:00
}
2017-10-04 12:58:13 +02:00
//print '</div>';
2016-10-17 17:52:58 +02:00
2021-02-26 18:49:22 +01:00
if (!empty($object->id)) {
2017-10-04 12:58:13 +02:00
print '<br>';
$param = '&id='.$object->id;
2021-02-26 18:49:22 +01:00
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.$contextpage;
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
}
2016-12-26 18:21:18 +01:00
print_barre_liste($langs->trans("ActionsOnProject"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1);
2017-10-04 12:58:13 +02:00
// List of all actions
$filters = array();
$filters['search_agenda_label'] = $search_agenda_label;
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
2016-10-17 17:52:58 +02:00
}
2018-08-15 12:48:13 +02:00
// End of page
2016-07-09 15:30:42 +02:00
llxFooter();
$db->close();