dolibarr/htdocs/projet/info.php

189 lines
6.2 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;
$sortfield = GETPOST("sortfield", "alpha");
$sortorder = GETPOST("sortorder");
$page = GETPOST("page");
$page = is_numeric($page) ? $page : 0;
$page = $page == -1 ? 0 : $page;
if (! $sortfield) $sortfield="a.datep,a.id";
2017-01-02 12:41:33 +01:00
if (! $sortorder) $sortorder="DESC";
$offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (GETPOST('actioncode', 'array'))
2016-10-17 17:52:58 +02:00
{
$actioncode=GETPOST('actioncode', 'array', 3);
2018-12-08 16:37:41 +01:00
if (! count($actioncode)) $actioncode='0';
2016-10-17 17:52:58 +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
2016-07-09 15:30:42 +02:00
// Security check
$id = GETPOST("id", 'int');
2016-07-09 15:30:42 +02:00
$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, '');
2016-07-09 15:30:42 +02:00
2016-10-17 17:52:58 +02:00
if (!$user->rights->projet->lire) accessforbidden();
/*
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
2016-10-17 17:52:58 +02:00
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Purge search criteria
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
2016-10-17 17:52:58 +02:00
{
2018-12-08 16:37:41 +01:00
$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
if ($id > 0 || ! empty($ref))
{
$object->fetch($id, $ref);
$object->fetch_thirdparty();
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
2016-12-26 18:21:18 +01:00
$title=$langs->trans("Project").' - '.$object->ref.' '.$object->name;
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");
2016-12-26 18:21:18 +01:00
$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
2017-03-23 19:26:28 +01:00
dol_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">';
// Title
$morehtmlref.=$object->title;
// Thirdparty
if ($object->thirdparty->id > 0)
{
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
$object->next_prev_filter=" rowid in (".(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
2016-10-17 17:52:58 +02:00
dol_fiche_end();
// Actions buttons
$out='';
$permok=$user->rights->agenda->myactions->create;
if ($permok)
{
$out.='&projectid='.$object->id;
}
2017-10-04 12:58:13 +02:00
//print '<div class="tabsAction">';
$morehtmlcenter='';
2016-10-17 17:52:58 +02:00
if (! empty($conf->agenda->enabled))
{
2019-04-15 21:33:31 +02:00
$addActionBtnRight = ! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create);
$morehtmlcenter.= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&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
if (!empty($object->id))
{
2017-10-04 12:58:13 +02:00
print '<br>';
$param='&id='.$object->id;
2016-12-26 18:21:18 +01:00
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
2017-12-04 20:17:07 +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
2016-10-17 17:52:58 +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();