dolibarr/htdocs/projet/fiche.php

233 lines
6.6 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>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
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.
*
* $Id$
* $Source$
*/
2005-07-16 13:21:08 +02:00
/**
\file htdocs/projet/fiche.php
\ingroup projet
\brief Fiche projet
\version $Revision$
*/
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");
2003-09-04 13:08:03 +02:00
2005-04-05 13:46:55 +02:00
if (!$user->rights->projet->lire) accessforbidden();
2004-07-13 17:32:25 +02:00
2004-07-21 16:28:25 +02:00
if ($_POST["action"] == 'add' && $user->rights->projet->creer)
{
2005-08-21 14:27:54 +02:00
$pro = new Project($db);
$pro->socidp = $_GET["socidp"];
$pro->ref = $_POST["ref"];
$pro->title = $_POST["title"];
$result = $pro->create($user);
if ($result > 0)
{
2005-08-21 14:27:54 +02:00
Header("Location:fiche.php?id=".$pro->id);
exit;
}
2005-08-21 14:27:54 +02:00
else
2004-07-21 16:28:25 +02:00
{
2005-08-21 14:27:54 +02:00
$mesg='<div class="error">'.$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
{
2005-08-21 14:27:54 +02:00
if (! $_POST["cancel"])
{
2005-08-21 14:27:54 +02:00
if (!(empty($_POST["id"]) || empty($_POST["ref"]) || empty($_POST["title"])))
{
$projet = new Project($db);
$projet->id = $_POST["id"];
$projet->ref = $_POST["ref"];
$projet->title = $_POST["title"];
$projet->update();
$_GET["id"]=$projet->id; // On retourne sur la fiche projet
}
else
{
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
}
}
2005-08-21 14:27:54 +02:00
else
{
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
}
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"];
2005-07-30 22:24:13 +02:00
if ($projet->delete($user) == 0)
{
Header("Location: index.php");
}
else
{
Header("Location: fiche.php?id=".$projet->id);
}
2003-09-04 13:08:03 +02:00
}
llxHeader("",$langs->trans("Project"),"Projet");
2003-09-04 13:08:03 +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
{
print_titre($langs->trans("NewProject"));
2003-09-04 13:08:03 +02:00
if ($mesg) print $mesg;
2004-07-21 16:28:25 +02:00
print '<form action="fiche.php?socidp='.$_GET["socidp"].'" method="post">';
print '<table class="border" width="100%">';
print '<input type="hidden" name="action" value="add">';
print '<tr><td>'.$langs->trans("Company").'</td><td>';
2003-09-04 13:08:03 +02:00
$societe = new Societe($db);
2004-07-21 16:28:25 +02:00
$societe->fetch($_GET["socidp"]);
print $societe->nom_url;
2003-09-04 13:08:03 +02:00
print '</td></tr>';
print '<tr><td>'.$langs->trans("Author").'</td><td>'.$user->fullname.'</td></tr>';
print '<tr><td>'.$langs->trans("Ref").'</td><td><input size="10" type="text" name="ref"></td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" type="text" name="title"></td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Create").'"></td></tr>';
print '</table>';
print '</form>';
2003-09-04 13:08:03 +02:00
} else {
2003-09-04 13:08:03 +02:00
/*
* Fiche projet en mode visu
2003-09-04 13:08:03 +02:00
*
*/
$projet = new Project($db);
2004-07-13 17:12:09 +02:00
$projet->fetch($_GET["id"]);
2004-05-27 12:11:38 +02:00
$projet->societe->fetch($projet->societe->id);
2004-02-09 17:55:48 +01:00
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/projet/fiche.php?id='.$projet->id;
$head[$h][1] = $langs->trans("Project");
$hselected=$h;
$h++;
2004-02-09 17:55:48 +01:00
2005-08-21 14:27:54 +02:00
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$projet->id;
$head[$h][1] = $langs->trans("Tasks");
$h++;
2005-04-05 13:46:55 +02:00
if ($conf->propal->enabled)
{
$langs->load("propal");
$head[$h][0] = DOL_URL_ROOT.'/projet/propal.php?id='.$projet->id;
$head[$h][1] = $langs->trans("Proposals");
$h++;
2005-04-05 13:46:55 +02:00
}
if ($conf->commande->enabled)
{
$langs->load("orders");
$head[$h][0] = DOL_URL_ROOT.'/projet/commandes.php?id='.$projet->id;
$head[$h][1] = $langs->trans("Orders");
$h++;
2005-04-05 13:46:55 +02:00
}
2004-02-09 17:55:48 +01:00
2005-04-05 13:46:55 +02:00
if ($conf->facture->enabled)
{
$langs->load("bills");
$head[$h][0] = DOL_URL_ROOT.'/projet/facture.php?id='.$projet->id;
$head[$h][1] = $langs->trans("Bills");
$h++;
2005-04-05 13:46:55 +02:00
}
2004-02-09 17:55:48 +01:00
dolibarr_fiche_head($head, $hselected, $langs->trans("Project").": ".$projet->ref);
if ($_GET["action"] == 'delete')
{
$htmls = new Form($db);
$htmls->form_confirm("fiche.php?id=".$_GET["id"],$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete");
print "<br>";
}
2004-02-09 17:55:48 +01:00
2004-07-13 17:32:25 +02:00
if ($_GET["action"] == 'edit')
2003-09-04 13:08:03 +02:00
{
print '<form method="post" action="fiche.php">';
2003-09-04 13:08:03 +02:00
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
print '<table class="border" width="50%">';
2005-04-05 13:46:55 +02:00
print '<tr><td>'.$langs->trans("Company").'</td><td>'.$projet->societe->nom_url.'</td></tr>';
print '<tr><td>'.$langs->trans("Ref").'</td><td><input name="ref" value="'.$projet->ref.'"></td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td><input name="title" value="'.$projet->title.'"></td></tr>';
print '<tr><td align="center" colspan="2"><input name="update" type="submit" Value="'.$langs->trans("Modify").'"> &nbsp; <input type="submit" name="cancel" Value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '</form>';
2003-09-04 13:08:03 +02:00
}
else
{
print '<table class="border" width="100%">';
2005-04-05 13:46:55 +02:00
print '<tr><td>'.$langs->trans("Company").'</td><td>'.$projet->societe->nom_url.'</td></tr>';
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
2003-09-04 13:08:03 +02:00
print '</table>';
2003-11-07 10:35:12 +01:00
}
2003-09-04 13:08:03 +02:00
2004-07-13 17:32:25 +02:00
print '</div>';
2003-09-04 13:08:03 +02:00
/*
* Boutons actions
*/
print '<div class="tabsAction">';
2004-07-13 17:32:25 +02:00
if ($user->rights->projet->creer == 1)
2003-11-07 10:35:12 +01:00
{
if ($_GET["action"] != "edit")
2004-07-13 17:32:25 +02:00
{
2005-04-05 13:46:55 +02:00
print '<a class="butAction" href="fiche.php?id='.$projet->id.'&amp;action=edit">'.$langs->trans("Edit").'</a>';
print '<a class="butActionDelete" href="fiche.php?id='.$projet->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
2004-07-13 17:32:25 +02:00
}
2003-11-07 10:35:12 +01:00
}
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
?>