dolibarr/htdocs/projet/fiche.php

274 lines
7.7 KiB
PHP
Raw Normal View History

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>
2008-03-17 05:10:35 +01:00
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 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.
*/
2005-07-16 13:21:08 +02:00
/**
* \file htdocs/projet/fiche.php
* \ingroup projet
* \brief Fiche projet
* \version $Id$
*/
2003-09-04 13:08:03 +02:00
require("./pre.inc.php");
2005-08-21 14:27:54 +02:00
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
2003-09-04 13:08:03 +02:00
2006-03-10 18:19:14 +01:00
$projetid='';
if ($_GET["id"]) { $projetid=$_GET["id"]; }
2008-03-17 05:10:35 +01:00
// If socid provided by ajax company selector
if (! empty($_POST['socid_id']))
{
$_POST['socid'] = $_POST['socid_id'];
$_REQUEST['socid'] = $_REQUEST['socid_id'];
}
if ($projetid == '' && ($_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
/*
* Actions
*/
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"];
$pro = new Project($db);
$pro->ref = $_POST["ref"];
$pro->title = $_POST["title"];
$pro->socid = $_POST["socid"];
$pro->user_resp_id = $_POST["officer_project"];
$result = $pro->create($user);
if ($result > 0)
{
Header("Location:fiche.php?id=".$pro->id);
exit;
}
else
{
$langs->load("errors");
$mesg='<div class="error">'.$langs->trans($pro->error).'</div>';
$_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
{
if (! $_POST["cancel"])
2005-08-21 14:27:54 +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)
{
$projet = new Project($db);
$projet->id = $_POST["id"];
$projet->ref = $_POST["ref"];
$projet->title = $_POST["title"];
$projet->socid = $_POST["socid"];
$projet->user_resp_id = $_POST["officer_project"];
$projet->update($user);
$_GET["id"]=$projet->id; // On retourne sur la fiche projet
}
2005-08-21 14:27:54 +02:00
}
else
2005-08-21 14:27:54 +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
}
2005-07-30 22:24:13 +02:00
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->projet->supprimer)
2003-09-04 13:08:03 +02:00
{
$projet = new Project($db);
$projet->id = $_GET["id"];
if ($projet->delete($user) == 0)
{
Header("Location: index.php");
exit;
}
else
{
Header("Location: fiche.php?id=".$projet->id);
exit;
}
2003-09-04 13:08:03 +02:00
}
/*
* View
*/
llxHeader("",$langs->trans("Project"),"Projet");
2003-09-04 13:08:03 +02:00
$html = new Form($db);
2004-07-21 16:28:25 +02:00
if ($_GET["action"] == 'create' && $user->rights->projet->creer)
2003-09-04 13:08:03 +02:00
{
/*
* Create
*/
print_titre($langs->trans("NewProject"));
if ($mesg) print $mesg;
print '<br>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
//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">';
// 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
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"];
print $html->select_societes($_REQUEST["socid"],'socid','',1);
print '</td></tr>';
// Responsable du projet
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
$html->select_users($projet->user_resp_id,'officer_project',1);
print '</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
print '</table>';
print '</form>';
}
else
{
/*
* Show or edit
*/
2003-09-04 13:08:03 +02:00
if ($mesg) print $mesg;
$projet = new Project($db);
$projet->fetch($_GET["id"]);
$projet->societe->fetch($projet->societe->id);
2006-09-23 01:12:50 +02:00
$head=project_prepare_head($projet);
dolibarr_fiche_head($head, 'project', $langs->trans("Project"));
if ($_GET["action"] == 'delete')
{
$html->form_confirm("fiche.php?id=".$_GET["id"],$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete");
print "<br>";
}
if ($_GET["action"] == 'edit')
{
print '<form method="post" action="fiche.php">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td><input size="8" name="ref" value="'.$projet->ref.'"></td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" name="title" value="'.$projet->title.'"></td></tr>';
// Client
print '<tr><td>'.$langs->trans("Company").'</td><td>';
print $html->select_societes($projet->societe->id,'socid','',1);
print '</td></tr>';
// Responsable du projet
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
$html->select_users($projet->user_resp_id,'officer_project',1);
print '</td></tr>';
print '<tr><td align="center" colspan="2"><input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> &nbsp; <input type="submit" class="button" name="cancel" Value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '</form>';
}
else
{
$projet->fetch_user($projet->user_resp_id);
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
// Third party
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if ($projet->societe->id > 0) print $projet->societe->getNomUrl(1);
else print'&nbsp;';
print '</td></tr>';
// Project leader
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>'.$projet->user->fullname.'</td></tr>';
print '</table>';
}
print '</div>';
/*
* Boutons actions
*/
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)
{
print '<a class="butAction" href="fiche.php?id='.$projet->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
}
if ($user->rights->projet->supprimer)
{
print '<a class="butActionDelete" href="fiche.php?id='.$projet->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
}
print "</div>";
2003-09-04 13:08:03 +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
?>