From 94e29ce7c15e08cf2e44b8a6b13ec9339d745d52 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Sep 2008 09:43:48 +0000 Subject: [PATCH] New: Third party for projects is not always required. --- htdocs/project.class.php | 7 ++- htdocs/projet/fiche.php | 125 +++++++++++++++++++++++---------------- 2 files changed, 79 insertions(+), 53 deletions(-) diff --git a/htdocs/project.class.php b/htdocs/project.class.php index 3ffa6f365b2..3f5143792c9 100644 --- a/htdocs/project.class.php +++ b/htdocs/project.class.php @@ -71,7 +71,7 @@ class Project extends CommonObject $sql.= " ".$user->id.","; $sql.= " ".$this->user_resp_id.", ".$this->db->idate(mktime()).", 0)"; - dolibarr_syslog("Project::create sql=".$sql); + dolibarr_syslog("Project::create sql=".$sql,LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -96,9 +96,11 @@ class Project extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."projet"; $sql.= " SET ref='".$this->ref."'"; $sql.= ", title = '".$this->title."'"; + $sql.= ", fk_soc = ".($this->socid > 0?$this->socid:"null"); $sql.= ", fk_user_resp = ".$this->user_resp_id; $sql.= " WHERE rowid = ".$this->id; + dolibarr_syslog("Project::update sql=".$sql,LOG_DEBUG); if ($this->db->query($sql) ) { $result = 0; @@ -142,7 +144,8 @@ class Project extends CommonObject $this->title = $obj->title; $this->titre = $obj->title; $this->note = $obj->note; - $this->societe->id = $obj->fk_soc; + $this->socid = $obj->fk_soc; + $this->societe->id = $obj->fk_soc; // For backward compatibility $this->user_author_id = $obj->fk_user_creat; $this->user_resp_id = $obj->fk_user_resp; $this->statut = $obj->fk_statut; diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index 6a1b4b888fd..c90e7c93dbc 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -19,12 +19,11 @@ */ /** - \file htdocs/projet/fiche.php - \ingroup projet - \brief Fiche projet - \version $Id$ -*/ - + * \file htdocs/projet/fiche.php + * \ingroup projet + * \brief Fiche projet + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); @@ -49,16 +48,16 @@ $result = restrictedArea($user, 'projet', $projetid); /* -* Actions -*/ + * Actions + */ if ($_POST["action"] == 'add' && $user->rights->projet->creer) { //print $_POST["socid"]; $pro = new Project($db); - $pro->socid = $_POST["socid"]; $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) @@ -78,21 +77,31 @@ if ($_POST["action"] == 'update' && $user->rights->projet->creer) { if (! $_POST["cancel"]) { - if (!(empty($_POST["id"]) || empty($_POST["ref"]) || empty($_POST["title"]))) + $error=0; + if (empty($_POST["ref"])) + { + $error++; + $_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'
'; + } + if (empty($_POST["title"])) + { + $error++; + $_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'
'; + } + 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 } - else - { - $_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet - } } else { @@ -118,8 +127,8 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user- /* -* View -*/ + * View + */ llxHeader("",$langs->trans("Project"),"Projet"); @@ -127,46 +136,51 @@ $html = new Form($db); if ($_GET["action"] == 'create' && $user->rights->projet->creer) { - print_titre($langs->trans("NewProject")); + /* + * Create + */ + print_titre($langs->trans("NewProject")); - if ($mesg) print $mesg; - - print '
'; - //if ($_REQUEST["socid"]) print ''; - print ''; - print ''; + if ($mesg) print $mesg; - // Ref - print ''; + print ''; + //if ($_REQUEST["socid"]) print ''; + print '
'.$langs->trans("Ref").'
'; + print ''; + + // Ref + print ''; // Label - print ''; + print ''; - // Client - print ''; + // Client + print ''; - // Auteur du projet - print ''; - - // Responsable du projet - print ''; + + // Responsable du projet + print ''; - print ''; - print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Company").''; - //print $_REQUEST["socid"]; - print $html->select_societes($_REQUEST["socid"],'socid','',1); - print '
'.$langs->trans("Company").''; + //print $_REQUEST["socid"]; + print $html->select_societes($_REQUEST["socid"],'socid','',1); + print '
'.$langs->trans("Author").''.$user->fullname.'
'.$langs->trans("OfficerProject").''; + // Auteur du projet + print '
'.$langs->trans("Author").''.$user->fullname.'
'.$langs->trans("OfficerProject").''; $html->select_users($projet->user_resp_id,'officer_project',1); print '
'; - print '
'; - -} else { + print ''; + print ''; + print ''; +} +else +{ /* - * Fiche projet en mode visu - * - */ + * Show or edit + */ + if ($mesg) print $mesg; + $projet = new Project($db); $projet->fetch($_GET["id"]); $projet->societe->fetch($projet->societe->id); @@ -196,14 +210,14 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) // Client print ''.$langs->trans("Company").''; - print $projet->societe->getNomUrl(1); + print $html->select_societes($projet->societe->id,'socid','',1); print ''; - + // Responsable du projet print ''.$langs->trans("OfficerProject").''; $html->select_users($projet->user_resp_id,'officer_project',1); print ''; - + print '   '; print ''; print ''; @@ -211,23 +225,32 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) else { $projet->fetch_user($projet->user_resp_id); - + print ''; + + // Ref print ''; + + // Label print ''; + + // Third party print ''; + + // Project leader print ''; + print '
'.$langs->trans("Ref").''.$projet->ref.'
'.$langs->trans("Label").''.$projet->title.'
'.$langs->trans("Company").''; - if ($projet->societe->id) print $projet->societe->getNomUrl(1); + if ($projet->societe->id > 0) print $projet->societe->getNomUrl(1); else print' '; print '
'.$langs->trans("OfficerProject").''.$projet->user->fullname.'
'; } print ''; /* - * Boutons actions - */ + * Boutons actions + */ print '
'; if ($_GET["action"] != "edit")