2004-10-20 22:06:49 +02:00
|
|
|
<?php
|
2005-04-05 13:46:55 +02:00
|
|
|
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2009-01-31 02:17:53 +01:00
|
|
|
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
2009-04-27 22:37:50 +02:00
|
|
|
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
2003-09-04 13:08:03 +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 2 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
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*/
|
2004-08-14 15:16:01 +02:00
|
|
|
|
2005-07-16 13:21:08 +02:00
|
|
|
/**
|
2008-09-10 11:43:48 +02:00
|
|
|
* \file htdocs/projet/fiche.php
|
|
|
|
|
* \ingroup projet
|
|
|
|
|
* \brief Fiche projet
|
|
|
|
|
* \version $Id$
|
|
|
|
|
*/
|
2009-01-10 04:40:06 +01:00
|
|
|
|
2003-09-04 13:08:03 +02:00
|
|
|
require("./pre.inc.php");
|
2006-09-23 02:27:47 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
|
2009-04-27 22:37:50 +02:00
|
|
|
if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
|
|
|
|
|
if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
|
|
|
|
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
2003-09-04 13:08:03 +02:00
|
|
|
|
2006-03-10 18:19:14 +01:00
|
|
|
$projetid='';
|
2009-01-12 21:26:06 +01:00
|
|
|
$ref='';
|
|
|
|
|
if (isset($_GET["id"])) { $projetid=$_GET["id"]; }
|
|
|
|
|
if (isset($_GET["ref"])) { $ref=$_GET["ref"]; }
|
2006-03-10 18:19:14 +01:00
|
|
|
|
2009-08-28 03:14:35 +02:00
|
|
|
//var_dump($_REQUEST);exit;
|
|
|
|
|
|
2008-03-17 05:10:35 +01:00
|
|
|
// If socid provided by ajax company selector
|
2009-08-28 03:14:35 +02:00
|
|
|
if (! empty($_REQUEST['socid_id']))
|
2008-03-17 05:10:35 +01:00
|
|
|
{
|
2009-08-28 03:14:35 +02:00
|
|
|
$_GET['socid'] = $_GET['socid_id'];
|
2008-03-17 05:10:35 +01:00
|
|
|
$_POST['socid'] = $_POST['socid_id'];
|
|
|
|
|
$_REQUEST['socid'] = $_REQUEST['socid_id'];
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-28 03:14:35 +02:00
|
|
|
|
2009-01-12 21:26:06 +01:00
|
|
|
if ($projetid == '' && $ref == '' && ($_GET['action'] != "create" && $_POST['action'] != "add" && $_POST["action"] != "update" && !$_POST["cancel"])) accessforbidden();
|
2006-03-10 18:19:14 +01:00
|
|
|
|
2008-02-24 14:18:40 +01:00
|
|
|
// Security check
|
2008-02-25 21:03:21 +01:00
|
|
|
if ($user->societe_id) $socid=$user->societe_id;
|
2008-02-24 14:18:40 +01:00
|
|
|
$result = restrictedArea($user, 'projet', $projetid);
|
|
|
|
|
|
2006-03-10 18:19:14 +01:00
|
|
|
|
2008-02-24 14:18:40 +01:00
|
|
|
/*
|
2008-09-10 11:43:48 +02:00
|
|
|
* Actions
|
|
|
|
|
*/
|
2007-11-29 22:19:21 +01:00
|
|
|
|
2004-07-21 16:28:25 +02:00
|
|
|
if ($_POST["action"] == 'add' && $user->rights->projet->creer)
|
|
|
|
|
{
|
2008-03-17 05:10:35 +01:00
|
|
|
//print $_POST["socid"];
|
2009-07-28 20:12:47 +02:00
|
|
|
$project = new Project($db);
|
|
|
|
|
$project->ref = $_POST["ref"];
|
|
|
|
|
$project->title = $_POST["title"];
|
|
|
|
|
$project->socid = $_POST["socid"];
|
|
|
|
|
$project->user_resp_id = $_POST["officer_project"];
|
|
|
|
|
$project->dateo=dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']);
|
|
|
|
|
$project->datec=dol_now('tzserver');
|
|
|
|
|
|
|
|
|
|
$result = $project->create($user);
|
2006-09-23 02:27:47 +02:00
|
|
|
if ($result > 0)
|
|
|
|
|
{
|
2009-07-28 20:12:47 +02:00
|
|
|
Header("Location:fiche.php?id=".$project->id);
|
2006-09-23 02:27:47 +02:00
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-12-19 18:41:59 +01:00
|
|
|
$langs->load("errors");
|
2009-07-28 20:12:47 +02:00
|
|
|
$mesg='<div class="error">'.$langs->trans($project->error).'</div>';
|
2006-09-23 02:27:47 +02:00
|
|
|
$_GET["action"] = 'create';
|
|
|
|
|
}
|
2004-07-21 16:28:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($_POST["action"] == 'update' && $user->rights->projet->creer)
|
2003-09-04 13:08:03 +02:00
|
|
|
{
|
2006-09-23 02:27:47 +02:00
|
|
|
if (! $_POST["cancel"])
|
2005-08-21 14:27:54 +02:00
|
|
|
{
|
2008-09-10 11:43:48 +02:00
|
|
|
$error=0;
|
|
|
|
|
if (empty($_POST["ref"]))
|
|
|
|
|
{
|
|
|
|
|
$error++;
|
|
|
|
|
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
|
|
|
|
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
|
|
|
|
|
}
|
|
|
|
|
if (empty($_POST["title"]))
|
|
|
|
|
{
|
|
|
|
|
$error++;
|
|
|
|
|
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
|
|
|
|
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>';
|
|
|
|
|
}
|
|
|
|
|
if (! $error)
|
2006-09-23 02:27:47 +02:00
|
|
|
{
|
|
|
|
|
$projet = new Project($db);
|
2007-05-28 13:30:44 +02:00
|
|
|
$projet->id = $_POST["id"];
|
|
|
|
|
$projet->ref = $_POST["ref"];
|
|
|
|
|
$projet->title = $_POST["title"];
|
2008-09-10 11:43:48 +02:00
|
|
|
$projet->socid = $_POST["socid"];
|
2007-05-28 13:30:44 +02:00
|
|
|
$projet->user_resp_id = $_POST["officer_project"];
|
2009-07-28 20:12:47 +02:00
|
|
|
$projet->dateo = dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']);
|
|
|
|
|
|
2006-09-23 02:27:47 +02:00
|
|
|
$projet->update($user);
|
|
|
|
|
|
|
|
|
|
$_GET["id"]=$projet->id; // On retourne sur la fiche projet
|
|
|
|
|
}
|
2005-08-21 14:27:54 +02:00
|
|
|
}
|
2006-09-23 02:27:47 +02:00
|
|
|
else
|
2005-08-21 14:27:54 +02:00
|
|
|
{
|
2006-09-23 02:27:47 +02:00
|
|
|
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
|
2005-08-21 14:27:54 +02:00
|
|
|
}
|
2003-09-04 13:08:03 +02:00
|
|
|
}
|
|
|
|
|
|
2009-07-27 02:11:33 +02:00
|
|
|
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == "yes" && $user->rights->projet->supprimer)
|
2003-09-04 13:08:03 +02:00
|
|
|
{
|
2006-09-23 02:27:47 +02:00
|
|
|
$projet = new Project($db);
|
|
|
|
|
$projet->id = $_GET["id"];
|
2009-01-31 02:17:53 +01:00
|
|
|
$result=$projet->delete($user);
|
|
|
|
|
if ($result >= 0)
|
2006-09-23 02:27:47 +02:00
|
|
|
{
|
|
|
|
|
Header("Location: index.php");
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-01-31 02:17:53 +01:00
|
|
|
$mesg='<div class="error">'.$langs->trans("CantRemoveProject").'</div>';
|
2006-09-23 02:27:47 +02:00
|
|
|
}
|
2003-09-04 13:08:03 +02:00
|
|
|
}
|
|
|
|
|
|
2005-08-14 03:38:12 +02:00
|
|
|
|
2008-03-02 23:20:44 +01:00
|
|
|
/*
|
2008-09-10 11:43:48 +02:00
|
|
|
* View
|
|
|
|
|
*/
|
2008-03-02 23:20:44 +01:00
|
|
|
|
2009-08-31 00:08:21 +02:00
|
|
|
$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos";
|
|
|
|
|
llxHeader("",$langs->trans("Projects"),$help_url);
|
2003-09-04 13:08:03 +02:00
|
|
|
|
2007-05-28 13:30:44 +02:00
|
|
|
$html = new Form($db);
|
2004-08-07 03:25:00 +02:00
|
|
|
|
2004-07-21 16:28:25 +02:00
|
|
|
if ($_GET["action"] == 'create' && $user->rights->projet->creer)
|
2003-09-04 13:08:03 +02:00
|
|
|
{
|
2008-09-10 11:43:48 +02:00
|
|
|
/*
|
|
|
|
|
* Create
|
|
|
|
|
*/
|
2009-01-10 04:40:06 +01:00
|
|
|
print_fiche_titre($langs->trans("NewProject"));
|
2008-09-10 11:43:48 +02:00
|
|
|
|
2009-01-10 04:40:06 +01:00
|
|
|
if ($mesg) print $mesg.'<br>';
|
2009-01-15 00:36:51 +01:00
|
|
|
|
2008-09-10 11:43:48 +02:00
|
|
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
2009-05-17 10:01:54 +02:00
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
2008-09-10 11:43:48 +02:00
|
|
|
//if ($_REQUEST["socid"]) print '<input type="hidden" name="socid" value="'.$_REQUEST["socid"].'">';
|
|
|
|
|
print '<table class="border" width="100%">';
|
|
|
|
|
print '<input type="hidden" name="action" value="add">';
|
2004-10-23 17:09:29 +02:00
|
|
|
|
2008-09-10 11:43:48 +02:00
|
|
|
// Ref
|
|
|
|
|
print '<tr><td>'.$langs->trans("Ref").'</td><td><input size="8" type="text" name="ref" value="'.$_POST["ref"].'"></td></tr>';
|
2006-09-23 01:12:50 +02:00
|
|
|
|
|
|
|
|
// Label
|
2008-09-10 11:43:48 +02:00
|
|
|
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" type="text" name="title" value="'.$_POST["title"].'"></td></tr>';
|
|
|
|
|
|
|
|
|
|
// Client
|
|
|
|
|
print '<tr><td>'.$langs->trans("Company").'</td><td>';
|
|
|
|
|
//print $_REQUEST["socid"];
|
2009-08-05 18:58:18 +02:00
|
|
|
print $html->select_societes($_REQUEST["socid"],'socid','',1,1);
|
2007-05-28 13:30:44 +02:00
|
|
|
print '</td></tr>';
|
2004-10-23 17:09:29 +02:00
|
|
|
|
2008-09-10 11:43:48 +02:00
|
|
|
// Responsable du projet
|
|
|
|
|
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
|
2009-01-15 00:36:51 +01:00
|
|
|
if ($_REQUEST["mode"] != 'mine')
|
|
|
|
|
{
|
|
|
|
|
$html->select_users($projet->user_resp_id,'officer_project',1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print $user->getNomUrl(1);
|
|
|
|
|
print '<input type="hidden" name="officer_project" value="'.$user->id.'">';
|
|
|
|
|
}
|
2008-09-10 11:43:48 +02:00
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2009-07-28 20:12:47 +02:00
|
|
|
// Date
|
|
|
|
|
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
|
|
|
|
|
print $html->select_date('','project');
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2008-09-10 11:43:48 +02:00
|
|
|
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
|
|
|
|
|
print '</table>';
|
|
|
|
|
print '</form>';
|
2005-01-14 21:30:49 +01:00
|
|
|
|
2008-09-10 11:43:48 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-09-23 02:27:47 +02:00
|
|
|
/*
|
2008-09-10 11:43:48 +02:00
|
|
|
* Show or edit
|
|
|
|
|
*/
|
2003-09-04 13:08:03 +02:00
|
|
|
|
2008-09-10 11:43:48 +02:00
|
|
|
if ($mesg) print $mesg;
|
2009-01-15 00:36:51 +01:00
|
|
|
|
2006-09-23 02:27:47 +02:00
|
|
|
$projet = new Project($db);
|
2009-01-12 21:26:06 +01:00
|
|
|
$projet->fetch($_GET["id"],$_GET["ref"]);
|
2009-01-31 02:17:53 +01:00
|
|
|
|
|
|
|
|
if ($projet->societe->id > 0) $result=$projet->societe->fetch($projet->societe->id);
|
|
|
|
|
if ($projet->user_resp_id > 0) $result=$projet->fetch_user($projet->user_resp_id);
|
2006-09-23 01:12:50 +02:00
|
|
|
|
2006-09-23 02:27:47 +02:00
|
|
|
$head=project_prepare_head($projet);
|
2009-07-28 15:37:28 +02:00
|
|
|
dol_fiche_head($head, 'project', $langs->trans("Project"),0,'project');
|
2006-09-23 02:27:47 +02:00
|
|
|
|
|
|
|
|
if ($_GET["action"] == 'delete')
|
|
|
|
|
{
|
2009-07-27 02:11:33 +02:00
|
|
|
$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete",'','',1);
|
2009-05-06 15:39:43 +02:00
|
|
|
if ($ret == 'html') print '<br>';
|
2006-09-23 02:27:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($_GET["action"] == 'edit')
|
|
|
|
|
{
|
|
|
|
|
print '<form method="post" action="fiche.php">';
|
2009-05-17 10:01:54 +02:00
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
2006-09-23 02:27:47 +02:00
|
|
|
print '<input type="hidden" name="action" value="update">';
|
|
|
|
|
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
|
|
|
|
|
|
|
|
|
|
print '<table class="border" width="100%">';
|
|
|
|
|
|
|
|
|
|
// Ref
|
2008-09-10 22:49:21 +02:00
|
|
|
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td><input size="8" name="ref" value="'.$projet->ref.'"></td></tr>';
|
2006-09-23 02:27:47 +02:00
|
|
|
|
|
|
|
|
// Label
|
|
|
|
|
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" name="title" value="'.$projet->title.'"></td></tr>';
|
|
|
|
|
|
2007-05-28 13:30:44 +02:00
|
|
|
// Client
|
2008-03-02 23:20:44 +01:00
|
|
|
print '<tr><td>'.$langs->trans("Company").'</td><td>';
|
2009-08-05 18:58:18 +02:00
|
|
|
print $html->select_societes($projet->societe->id,'socid','',1,1);
|
2008-03-02 23:20:44 +01:00
|
|
|
print '</td></tr>';
|
2008-09-10 11:43:48 +02:00
|
|
|
|
2007-05-28 13:30:44 +02:00
|
|
|
// Responsable du projet
|
|
|
|
|
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
|
|
|
|
|
$html->select_users($projet->user_resp_id,'officer_project',1);
|
|
|
|
|
print '</td></tr>';
|
2008-09-10 11:43:48 +02:00
|
|
|
|
2009-07-28 20:12:47 +02:00
|
|
|
// Date
|
|
|
|
|
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
|
|
|
|
|
print $html->select_date($projet->date_start,'project');
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2006-09-23 02:27:47 +02:00
|
|
|
print '<tr><td align="center" colspan="2"><input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> <input type="submit" class="button" name="cancel" Value="'.$langs->trans("Cancel").'"></td></tr>';
|
|
|
|
|
print '</table>';
|
|
|
|
|
print '</form>';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print '<table class="border" width="100%">';
|
2009-01-15 00:36:51 +01:00
|
|
|
|
2008-09-10 11:43:48 +02:00
|
|
|
// Ref
|
2009-01-12 21:26:06 +01:00
|
|
|
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
|
|
|
|
|
print $html->showrefnav($projet,'ref','',1,'ref','ref');
|
|
|
|
|
print '</td></tr>';
|
2009-01-15 00:36:51 +01:00
|
|
|
|
2008-09-10 11:43:48 +02:00
|
|
|
// Label
|
2006-09-23 02:27:47 +02:00
|
|
|
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
|
2009-01-15 00:36:51 +01:00
|
|
|
|
2008-09-10 11:43:48 +02:00
|
|
|
// Third party
|
2008-03-02 23:20:44 +01:00
|
|
|
print '<tr><td>'.$langs->trans("Company").'</td><td>';
|
2008-09-10 11:43:48 +02:00
|
|
|
if ($projet->societe->id > 0) print $projet->societe->getNomUrl(1);
|
2008-03-02 23:20:44 +01:00
|
|
|
else print' ';
|
|
|
|
|
print '</td></tr>';
|
2009-01-15 00:36:51 +01:00
|
|
|
|
2008-09-10 11:43:48 +02:00
|
|
|
// Project leader
|
2009-01-12 21:29:35 +01:00
|
|
|
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
|
|
|
|
|
if ($projet->user->id) print $projet->user->getNomUrl(1);
|
2009-01-15 00:36:51 +01:00
|
|
|
else print $langs->trans('SharedProject');
|
2009-01-12 21:29:35 +01:00
|
|
|
print '</td></tr>';
|
2008-09-10 11:43:48 +02:00
|
|
|
|
2009-07-28 20:12:47 +02:00
|
|
|
// Date
|
|
|
|
|
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
|
|
|
|
|
print dol_print_date($projet->date_start,'day');
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2006-09-23 02:27:47 +02:00
|
|
|
print '</table>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print '</div>';
|
|
|
|
|
|
|
|
|
|
/*
|
2008-09-10 11:43:48 +02:00
|
|
|
* Boutons actions
|
|
|
|
|
*/
|
2006-09-23 02:27:47 +02:00
|
|
|
print '<div class="tabsAction">';
|
|
|
|
|
|
|
|
|
|
if ($_GET["action"] != "edit")
|
2004-07-13 17:32:25 +02:00
|
|
|
{
|
2006-04-14 11:58:28 +02:00
|
|
|
if ($user->rights->projet->creer)
|
2006-09-23 02:27:47 +02:00
|
|
|
{
|
2008-01-11 00:59:58 +01:00
|
|
|
print '<a class="butAction" href="fiche.php?id='.$projet->id.'&action=edit">'.$langs->trans("Modify").'</a>';
|
2006-09-23 02:27:47 +02:00
|
|
|
}
|
|
|
|
|
if ($user->rights->projet->supprimer)
|
|
|
|
|
{
|
|
|
|
|
print '<a class="butActionDelete" href="fiche.php?id='.$projet->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print "</div>";
|
2005-10-02 21:48:55 +02:00
|
|
|
|
2003-09-04 13:08:03 +02:00
|
|
|
}
|
2004-10-23 17:09:29 +02:00
|
|
|
|
2003-09-04 13:08:03 +02:00
|
|
|
$db->close();
|
|
|
|
|
|
2005-07-16 13:21:08 +02:00
|
|
|
llxFooter('$Date$ - $Revision$');
|
2003-09-04 13:08:03 +02:00
|
|
|
?>
|