New: Third party for projects is not always required.

This commit is contained in:
Laurent Destailleur 2008-09-10 09:43:48 +00:00
parent 5e51b2cb13
commit 94e29ce7c1
2 changed files with 79 additions and 53 deletions

View File

@ -71,7 +71,7 @@ class Project extends CommonObject
$sql.= " ".$user->id.","; $sql.= " ".$user->id.",";
$sql.= " ".$this->user_resp_id.", ".$this->db->idate(mktime()).", 0)"; $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); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -96,9 +96,11 @@ class Project extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."projet"; $sql = "UPDATE ".MAIN_DB_PREFIX."projet";
$sql.= " SET ref='".$this->ref."'"; $sql.= " SET ref='".$this->ref."'";
$sql.= ", title = '".$this->title."'"; $sql.= ", title = '".$this->title."'";
$sql.= ", fk_soc = ".($this->socid > 0?$this->socid:"null");
$sql.= ", fk_user_resp = ".$this->user_resp_id; $sql.= ", fk_user_resp = ".$this->user_resp_id;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
dolibarr_syslog("Project::update sql=".$sql,LOG_DEBUG);
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
$result = 0; $result = 0;
@ -142,7 +144,8 @@ class Project extends CommonObject
$this->title = $obj->title; $this->title = $obj->title;
$this->titre = $obj->title; $this->titre = $obj->title;
$this->note = $obj->note; $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_author_id = $obj->fk_user_creat;
$this->user_resp_id = $obj->fk_user_resp; $this->user_resp_id = $obj->fk_user_resp;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;

View File

@ -19,12 +19,11 @@
*/ */
/** /**
\file htdocs/projet/fiche.php * \file htdocs/projet/fiche.php
\ingroup projet * \ingroup projet
\brief Fiche projet * \brief Fiche projet
\version $Id$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/facture.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) if ($_POST["action"] == 'add' && $user->rights->projet->creer)
{ {
//print $_POST["socid"]; //print $_POST["socid"];
$pro = new Project($db); $pro = new Project($db);
$pro->socid = $_POST["socid"];
$pro->ref = $_POST["ref"]; $pro->ref = $_POST["ref"];
$pro->title = $_POST["title"]; $pro->title = $_POST["title"];
$pro->socid = $_POST["socid"];
$pro->user_resp_id = $_POST["officer_project"]; $pro->user_resp_id = $_POST["officer_project"];
$result = $pro->create($user); $result = $pro->create($user);
if ($result > 0) if ($result > 0)
@ -78,21 +77,31 @@ if ($_POST["action"] == 'update' && $user->rights->projet->creer)
{ {
if (! $_POST["cancel"]) 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='<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 = new Project($db);
$projet->id = $_POST["id"]; $projet->id = $_POST["id"];
$projet->ref = $_POST["ref"]; $projet->ref = $_POST["ref"];
$projet->title = $_POST["title"]; $projet->title = $_POST["title"];
$projet->socid = $_POST["socid"];
$projet->user_resp_id = $_POST["officer_project"]; $projet->user_resp_id = $_POST["officer_project"];
$projet->update($user); $projet->update($user);
$_GET["id"]=$projet->id; // On retourne sur la fiche projet $_GET["id"]=$projet->id; // On retourne sur la fiche projet
} }
else
{
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
}
} }
else else
{ {
@ -118,8 +127,8 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user-
/* /*
* View * View
*/ */
llxHeader("",$langs->trans("Project"),"Projet"); llxHeader("",$langs->trans("Project"),"Projet");
@ -127,45 +136,50 @@ $html = new Form($db);
if ($_GET["action"] == 'create' && $user->rights->projet->creer) if ($_GET["action"] == 'create' && $user->rights->projet->creer)
{ {
print_titre($langs->trans("NewProject")); /*
* Create
*/
print_titre($langs->trans("NewProject"));
if ($mesg) print $mesg; if ($mesg) print $mesg;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
//if ($_REQUEST["socid"]) print '<input type="hidden" name="socid" value="'.$_REQUEST["socid"].'">'; //if ($_REQUEST["socid"]) print '<input type="hidden" name="socid" value="'.$_REQUEST["socid"].'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
// Ref // Ref
print '<tr><td>'.$langs->trans("Ref").'</td><td><input size="8" type="text" name="ref" value="'.$_POST["ref"].'"></td></tr>'; print '<tr><td>'.$langs->trans("Ref").'</td><td><input size="8" type="text" name="ref" value="'.$_POST["ref"].'"></td></tr>';
// Label // Label
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" type="text" name="title" value="'.$_POST["title"].'"></td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" type="text" name="title" value="'.$_POST["title"].'"></td></tr>';
// Client // Client
print '<tr><td>'.$langs->trans("Company").'</td><td>'; print '<tr><td>'.$langs->trans("Company").'</td><td>';
//print $_REQUEST["socid"]; //print $_REQUEST["socid"];
print $html->select_societes($_REQUEST["socid"],'socid','',1); print $html->select_societes($_REQUEST["socid"],'socid','',1);
print '</td></tr>'; print '</td></tr>';
// Auteur du projet // Auteur du projet
print '<tr><td>'.$langs->trans("Author").'</td><td>'.$user->fullname.'</td></tr>'; print '<tr><td>'.$langs->trans("Author").'</td><td>'.$user->fullname.'</td></tr>';
// Responsable du projet // Responsable du projet
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>'; print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
$html->select_users($projet->user_resp_id,'officer_project',1); $html->select_users($projet->user_resp_id,'officer_project',1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>'; print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
print '</table>'; print '</table>';
print '</form>'; print '</form>';
} else {
}
else
{
/* /*
* Fiche projet en mode visu * Show or edit
* */
*/
if ($mesg) print $mesg;
$projet = new Project($db); $projet = new Project($db);
$projet->fetch($_GET["id"]); $projet->fetch($_GET["id"]);
@ -196,7 +210,7 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
// Client // Client
print '<tr><td>'.$langs->trans("Company").'</td><td>'; print '<tr><td>'.$langs->trans("Company").'</td><td>';
print $projet->societe->getNomUrl(1); print $html->select_societes($projet->societe->id,'socid','',1);
print '</td></tr>'; print '</td></tr>';
// Responsable du projet // Responsable du projet
@ -213,21 +227,30 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
$projet->fetch_user($projet->user_resp_id); $projet->fetch_user($projet->user_resp_id);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>'; print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
// Third party
print '<tr><td>'.$langs->trans("Company").'</td><td>'; print '<tr><td>'.$langs->trans("Company").'</td><td>';
if ($projet->societe->id) print $projet->societe->getNomUrl(1); if ($projet->societe->id > 0) print $projet->societe->getNomUrl(1);
else print'&nbsp;'; else print'&nbsp;';
print '</td></tr>'; print '</td></tr>';
// Project leader
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>'.$projet->user->fullname.'</td></tr>'; print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>'.$projet->user->fullname.'</td></tr>';
print '</table>'; print '</table>';
} }
print '</div>'; print '</div>';
/* /*
* Boutons actions * Boutons actions
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($_GET["action"] != "edit") if ($_GET["action"] != "edit")