Skip to content
Snippets Groups Projects
Commit bfc2ec57 authored by Regis Houssin's avatar Regis Houssin
Browse files

Add: on peut définir le responsable du projet

parent d029ebe4
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ ProjectsArea=Projects area
NewProject=New project
AddProject=Add project
DeleteAProject=Supprimer un projet
OfficerProject=Officer project
ConfirmDeleteAProject=Are you sure you want to delete this project ?
LastProjects=Last %s projects
AllProjects=All projects
......
......@@ -6,6 +6,7 @@ ProjectsArea=Espace projet
NewProject=Nouveau projet
AddProject=Crer projet
DeleteAProject=Supprimer un projet
OfficerProject=Responsable du projet
ConfirmDeleteAProject=tes-vous sr de vouloir supprimer ce projet ?
LastProjects=Les %s derniers projets
AllProjects=Tous les projets
......
......@@ -27,17 +27,20 @@
\version $Revision$
*/
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
/**
\class Project
\brief Classe permettant la gestion des projets
*/
class Project
class Project extends CommonObject
{
var $id;
var $db;
var $ref;
var $title;
var $socid;
var $user_resp_id;
/**
* \brief Constructeur de la classe
......@@ -58,8 +61,9 @@ class Project
{
if (trim($this->ref))
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet (ref, title, fk_soc, fk_user_creat, dateo) ";
$sql .= " VALUES ('".addslashes($this->ref)."', '".addslashes($this->title)."', $this->socid, ".$user->id.",now()) ;";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet (ref, title, fk_soc, fk_user_creat, fk_user_resp, dateo) ";
$sql.= " VALUES ('".addslashes($this->ref)."', '".addslashes($this->title)."'";
$sql.= ", ".$this->socid.", ".$user->id.", ".$this->user_resp_id.", now()) ;";
if ($this->db->query($sql) )
{
......@@ -88,9 +92,10 @@ class Project
if (strlen(trim($this->ref)) > 0)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."projet";
$sql .= " SET ref='$this->ref'";
$sql .= " , title = '$this->title'";
$sql .= " WHERE rowid = ".$this->id;
$sql.= " SET ref='".$this->ref."'";
$sql.= ", title = '".$this->title."'";
$sql.= ", fk_user_resp = ".$this->user_resp_id;
$sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql) )
{
......@@ -119,8 +124,9 @@ class Project
function fetch($rowid)
{
$sql = "SELECT title, ref, fk_soc FROM ".MAIN_DB_PREFIX."projet";
$sql .= " WHERE rowid=".$rowid;
$sql = "SELECT title, ref, fk_soc, fk_user_creat, fk_user_resp, fk_statut, note";
$sql.= " FROM ".MAIN_DB_PREFIX."projet";
$sql.= " WHERE rowid=".$rowid;
$resql = $this->db->query($sql);
if ($resql)
......@@ -129,11 +135,15 @@ class Project
{
$obj = $this->db->fetch_object($resql);
$this->id = $rowid;
$this->ref = $obj->ref;
$this->title = $obj->title;
$this->titre = $obj->title;
$this->societe->id = $obj->fk_soc;
$this->id = $rowid;
$this->ref = $obj->ref;
$this->title = $obj->title;
$this->titre = $obj->title;
$this->note = $obj->note;
$this->societe->id = $obj->fk_soc;
$this->user_author_id = $obj->fk_user_creat;
$this->user_resp_id = $obj->fk_user_resp;
$this->statut = $obj->fk_statut;
$this->db->free($resql);
......
......@@ -68,9 +68,10 @@ if ($projetid && !$user->rights->commercial->client->voir)
if ($_POST["action"] == 'add' && $user->rights->projet->creer)
{
$pro = new Project($db);
$pro->socid = $_GET["socid"];
$pro->ref = $_POST["ref"];
$pro->title = $_POST["title"];
$pro->socid = $_GET["socid"];
$pro->ref = $_POST["ref"];
$pro->title = $_POST["title"];
$pro->user_resp_id = $_POST["officer_project"];
$result = $pro->create($user);
if ($result > 0)
......@@ -92,9 +93,10 @@ if ($_POST["action"] == 'update' && $user->rights->projet->creer)
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->id = $_POST["id"];
$projet->ref = $_POST["ref"];
$projet->title = $_POST["title"];
$projet->user_resp_id = $_POST["officer_project"];
$projet->update($user);
$_GET["id"]=$projet->id; // On retourne sur la fiche projet
......@@ -129,6 +131,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user-
llxHeader("",$langs->trans("Project"),"Projet");
$html = new Form($db);
if ($_GET["action"] == 'create' && $user->rights->projet->creer)
{
......@@ -147,13 +150,20 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" type="text" name="title"></td></tr>';
// Client
print '<tr><td>'.$langs->trans("Company").'</td><td>';
$societe = new Societe($db);
$societe->fetch($_GET["socid"]);
print $societe->getNomUrl(1);
print '</td></tr>';
// Auteur du projet
print '<tr><td>'.$langs->trans("Author").'</td><td>'.$user->fullname.'</td></tr>';
// Responsable du projet
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
$html->select_users($projet->user_resp_id,'officer_project',1);
print '</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
print '</table>';
......@@ -173,11 +183,9 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
$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");
$html->form_confirm("fiche.php?id=".$_GET["id"],$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete");
print "<br>";
}
......@@ -195,19 +203,27 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" name="title" value="'.$projet->title.'"></td></tr>';
// Client
print '<tr><td>'.$langs->trans("Company").'</td><td>'.$projet->societe->getNomUrl(1).'</td></tr>';
// Responsable du projet
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
$html->select_users($projet->user_resp_id,'officer_project',1);
print '</td></tr>';
print '<tr><td align="center" colspan="2"><input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> &nbsp; <input type="submit" class="button" name="cancel" Value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '</form>';
}
else
{
$projet->fetch_user($projet->user_resp_id);
print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans("Ref").'</td><td>'.$projet->ref.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Company").'</td><td>'.$projet->societe->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>'.$projet->user->fullname.'</td></tr>';
print '</table>';
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment