Skip to content
Snippets Groups Projects
Commit 94e29ce7 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

New: Third party for projects is not always required.

parent 5e51b2cb
No related branches found
No related tags found
No related merge requests found
...@@ -71,7 +71,7 @@ class Project extends CommonObject ...@@ -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 ...@@ -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 ...@@ -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;
......
...@@ -19,12 +19,11 @@ ...@@ -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");
...@@ -56,9 +55,9 @@ if ($_POST["action"] == 'add' && $user->rights->projet->creer) ...@@ -56,9 +55,9 @@ 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) ...@@ -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
{ {
...@@ -127,6 +136,9 @@ $html = new Form($db); ...@@ -127,6 +136,9 @@ $html = new Form($db);
if ($_GET["action"] == 'create' && $user->rights->projet->creer) if ($_GET["action"] == 'create' && $user->rights->projet->creer)
{ {
/*
* Create
*/
print_titre($langs->trans("NewProject")); print_titre($langs->trans("NewProject"));
if ($mesg) print $mesg; if ($mesg) print $mesg;
...@@ -160,13 +172,15 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) ...@@ -160,13 +172,15 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
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"]);
$projet->societe->fetch($projet->societe->id); $projet->societe->fetch($projet->societe->id);
...@@ -196,7 +210,7 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) ...@@ -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,13 +227,22 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer) ...@@ -213,13 +227,22 @@ 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>';
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment