Add: on peut définir le responsable du projet

This commit is contained in:
Regis Houssin 2007-05-28 11:30:44 +00:00
parent d029ebe44f
commit bfc2ec5754
4 changed files with 52 additions and 24 deletions

View File

@ -6,6 +6,7 @@ ProjectsArea=Projects area
NewProject=New project NewProject=New project
AddProject=Add project AddProject=Add project
DeleteAProject=Supprimer un projet DeleteAProject=Supprimer un projet
OfficerProject=Officer project
ConfirmDeleteAProject=Are you sure you want to delete this project ? ConfirmDeleteAProject=Are you sure you want to delete this project ?
LastProjects=Last %s projects LastProjects=Last %s projects
AllProjects=All projects AllProjects=All projects

View File

@ -6,6 +6,7 @@ ProjectsArea=Espace projet
NewProject=Nouveau projet NewProject=Nouveau projet
AddProject=Créer projet AddProject=Créer projet
DeleteAProject=Supprimer un projet DeleteAProject=Supprimer un projet
OfficerProject=Responsable du projet
ConfirmDeleteAProject=Êtes-vous sûr de vouloir supprimer ce projet ? ConfirmDeleteAProject=Êtes-vous sûr de vouloir supprimer ce projet ?
LastProjects=Les %s derniers projets LastProjects=Les %s derniers projets
AllProjects=Tous les projets AllProjects=Tous les projets

View File

@ -27,17 +27,20 @@
\version $Revision$ \version $Revision$
*/ */
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
/** /**
\class Project \class Project
\brief Classe permettant la gestion des projets \brief Classe permettant la gestion des projets
*/ */
class Project class Project extends CommonObject
{ {
var $id; var $id;
var $db; var $db;
var $ref; var $ref;
var $title; var $title;
var $socid; var $socid;
var $user_resp_id;
/** /**
* \brief Constructeur de la classe * \brief Constructeur de la classe
@ -58,8 +61,9 @@ class Project
{ {
if (trim($this->ref)) if (trim($this->ref))
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet (ref, title, fk_soc, fk_user_creat, dateo) "; $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)."', $this->socid, ".$user->id.",now()) ;"; $sql.= " VALUES ('".addslashes($this->ref)."', '".addslashes($this->title)."'";
$sql.= ", ".$this->socid.", ".$user->id.", ".$this->user_resp_id.", now()) ;";
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
@ -88,9 +92,10 @@ class Project
if (strlen(trim($this->ref)) > 0) if (strlen(trim($this->ref)) > 0)
{ {
$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 .= " WHERE rowid = ".$this->id; $sql.= ", fk_user_resp = ".$this->user_resp_id;
$sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
@ -119,8 +124,9 @@ class Project
function fetch($rowid) function fetch($rowid)
{ {
$sql = "SELECT title, ref, fk_soc FROM ".MAIN_DB_PREFIX."projet"; $sql = "SELECT title, ref, fk_soc, fk_user_creat, fk_user_resp, fk_statut, note";
$sql .= " WHERE rowid=".$rowid; $sql.= " FROM ".MAIN_DB_PREFIX."projet";
$sql.= " WHERE rowid=".$rowid;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -129,11 +135,15 @@ class Project
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $rowid; $this->id = $rowid;
$this->ref = $obj->ref; $this->ref = $obj->ref;
$this->title = $obj->title; $this->title = $obj->title;
$this->titre = $obj->title; $this->titre = $obj->title;
$this->societe->id = $obj->fk_soc; $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); $this->db->free($resql);

View File

@ -68,9 +68,10 @@ if ($projetid && !$user->rights->commercial->client->voir)
if ($_POST["action"] == 'add' && $user->rights->projet->creer) if ($_POST["action"] == 'add' && $user->rights->projet->creer)
{ {
$pro = new Project($db); $pro = new Project($db);
$pro->socid = $_GET["socid"]; $pro->socid = $_GET["socid"];
$pro->ref = $_POST["ref"]; $pro->ref = $_POST["ref"];
$pro->title = $_POST["title"]; $pro->title = $_POST["title"];
$pro->user_resp_id = $_POST["officer_project"];
$result = $pro->create($user); $result = $pro->create($user);
if ($result > 0) 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"]))) if (!(empty($_POST["id"]) || empty($_POST["ref"]) || empty($_POST["title"])))
{ {
$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->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
@ -129,6 +131,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user-
llxHeader("",$langs->trans("Project"),"Projet"); llxHeader("",$langs->trans("Project"),"Projet");
$html = new Form($db);
if ($_GET["action"] == 'create' && $user->rights->projet->creer) if ($_GET["action"] == 'create' && $user->rights->projet->creer)
{ {
@ -147,14 +150,21 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
// Label // Label
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" type="text" name="title"></td></tr>'; 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>'; print '<tr><td>'.$langs->trans("Company").'</td><td>';
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($_GET["socid"]); $societe->fetch($_GET["socid"]);
print $societe->getNomUrl(1); print $societe->getNomUrl(1);
print '</td></tr>'; print '</td></tr>';
// 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
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 '<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>';
@ -173,11 +183,9 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
$head=project_prepare_head($projet); $head=project_prepare_head($projet);
dolibarr_fiche_head($head, 'project', $langs->trans("Project")); dolibarr_fiche_head($head, 'project', $langs->trans("Project"));
if ($_GET["action"] == 'delete') if ($_GET["action"] == 'delete')
{ {
$htmls = new Form($db); $html->form_confirm("fiche.php?id=".$_GET["id"],$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete");
$htmls->form_confirm("fiche.php?id=".$_GET["id"],$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete");
print "<br>"; print "<br>";
} }
@ -195,19 +203,27 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
// Label // Label
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" name="title" value="'.$projet->title.'"></td></tr>'; 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>'; 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 '<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 '</table>';
print '</form>'; print '</form>';
} }
else else
{ {
print '<table class="border" width="100%">'; $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("Ref").'</td><td>'.$projet->ref.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</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("Company").'</td><td>'.$projet->societe->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>'.$projet->user->fullname.'</td></tr>';
print '</table>'; print '</table>';
} }