* Copyright (C) 2004-2006 Laurent Destailleur * * 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$ */ /** \file htdocs/projet/fiche.php \ingroup projet \brief Fiche projet \version $Revision$ */ require("./pre.inc.php"); 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"); if (!$user->rights->projet->lire) accessforbidden(); /* * Sécurité accés client */ $projetid=''; if ($_GET["id"]) { $projetid=$_GET["id"]; } if ($projetid == '' && ($_GET['action'] != "create" && $_POST['action'] != "add" && $_POST["action"] != "update" && !$_POST["cancel"])) accessforbidden(); if ($user->societe_id > 0) { $socid = $user->societe_id; } // Protection restriction commercial if ($projetid && !$user->rights->commercial->client->voir) { $sql = "SELECT p.rowid, p.fk_soc"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; if (!$user->rights->commercial->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc "; $sql.= " WHERE p.rowid = ".$projetid; if (!$user->rights->commercial->client->voir) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND p.fk_soc = ".$socid; if ( $db->query($sql) ) { if ( $db->num_rows() == 0) accessforbidden(); } } if ($_POST["action"] == 'add' && $user->rights->projet->creer) { $pro = new Project($db); $pro->socid = $_GET["socid"]; $pro->ref = $_POST["ref"]; $pro->title = $_POST["title"]; $result = $pro->create($user); if ($result > 0) { Header("Location:fiche.php?id=".$pro->id); exit; } else { $mesg='
'.$pro->error.'
'; $_GET["action"] = 'create'; } } if ($_POST["action"] == 'update' && $user->rights->projet->creer) { if (! $_POST["cancel"]) { 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($user); $_GET["id"]=$projet->id; // On retourne sur la fiche projet } else { $_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet } } else { $_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet } } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->projet->supprimer) { $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; } } llxHeader("",$langs->trans("Project"),"Projet"); if ($_GET["action"] == 'create' && $user->rights->projet->creer) { print_titre($langs->trans("NewProject")); if ($mesg) print $mesg; print '
'; print ''; print ''; // Ref print ''; // Label print ''; print ''; print ''; print ''; print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Company").''; $societe = new Societe($db); $societe->fetch($_GET["socid"]); print $societe->getNomUrl(1); print '
'.$langs->trans("Author").''.$user->fullname.'
'; print '
'; } else { /* * Fiche projet en mode visu * */ $projet = new Project($db); $projet->fetch($_GET["id"]); $projet->societe->fetch($projet->societe->id); $head=project_prepare_head($projet); dolibarr_fiche_head($head, 'project', $langs->trans("Project")); 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 "
"; } if ($_GET["action"] == 'edit') { print '
'; print ''; print ''; print ''; // Ref print ''; // Label print ''; print ''; print ''; print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Company").''.$projet->societe->getNomUrl(1).'
 
'; print '
'; } else { print ''; print ''; print ''; print ''; print '
'.$langs->trans("Ref").''.$projet->ref.'
'.$langs->trans("Label").''.$projet->title.'
'.$langs->trans("Company").''.$projet->societe->getNomUrl(1).'
'; } print ''; /* * Boutons actions */ print '
'; if ($_GET["action"] != "edit") { if ($user->rights->projet->creer) { print ''.$langs->trans("Edit").''; } if ($user->rights->projet->supprimer) { print ''.$langs->trans("Delete").''; } } print "
"; } $db->close(); llxFooter('$Date$ - $Revision$'); ?>