Some fix on project

This commit is contained in:
Laurent Destailleur 2010-02-03 21:48:16 +00:00
parent c0b2a86fe9
commit 3ab469f544
4 changed files with 73 additions and 32 deletions

View File

@ -153,7 +153,9 @@ llxHeader('', $langs->trans("Project"), "Project");
$html = new Form($db); $html = new Form($db);
$formcompany= new FormCompany($db); $formcompany= new FormCompany($db);
$contactstatic=new Contact($db); $contactstatic=new Contact($db);
$userstatic=new User($db);
/* *************************************************************************** */ /* *************************************************************************** */
@ -217,6 +219,34 @@ if ($id > 0 || ! empty($ref))
else print ' '; else print ' ';
print '</td></tr>'; print '</td></tr>';
// Project leader
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
$contact = $project->liste_contact(4,'internal');
$num=sizeof($contact);
if ($num)
{
$i = 0;
while ($i < $num)
{
if ($contact[$i]['code'] == 'PROJECTLEADER')
{
$userstatic->id = $contact[$i]['id'];
$userstatic->fetch();
print $userstatic->getNomUrl(1);
print '<br>';
}
$i++;
}
}
else
{
print $langs->trans('SharedProject');
}
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
print "</table>"; print "</table>";
print '</div>'; print '</div>';

View File

@ -129,8 +129,8 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->projet-
$project->title = $_POST["title"]; $project->title = $_POST["title"];
$project->socid = $_POST["socid"]; $project->socid = $_POST["socid"];
$project->description = $_POST["description"]; $project->description = $_POST["description"];
$project->date_start = dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']); $project->date_start = empty($_POST["project"])?'':dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']);
$project->date_end = dol_mktime(12,0,0,$_POST['projectendmonth'],$_POST['projectendday'],$_POST['projectendyear']); $project->date_end = empty($_POST["projectend"])?'':dol_mktime(12,0,0,$_POST['projectendmonth'],$_POST['projectendday'],$_POST['projectendyear']);
$result=$project->update($user); $result=$project->update($user);
@ -323,19 +323,24 @@ else
// To verify role of users // To verify role of users
$userAccess = 0; $userAccess = 0;
foreach(array('internal','external') as $source) var_dump($project);
if (empty($project->user_author_id)) $userAccess=1;
else
{ {
$userRole = $project->liste_contact(4,$source); foreach(array('internal','external') as $source)
$num=sizeof($userRole);
$i = 0;
while ($i < $num)
{ {
if ($userRole[$i]['code'] == 'PROJECTLEADER' && $user->id == $userRole[$i]['id']) $userRole = $project->liste_contact(4,$source);
$num=sizeof($userRole);
$i = 0;
while ($i < $num)
{ {
$userAccess++; if ($userRole[$i]['code'] == 'PROJECTLEADER' && $user->id == $userRole[$i]['id'])
{
$userAccess++;
}
$i++;
} }
$i++;
} }
} }

View File

@ -80,15 +80,17 @@ if ($_POST['action'] == 'update_private' && $user->rights->projet->creer)
} }
/*
/******************************************************************************/ * View
/* Affichage fiche */ */
/******************************************************************************/
llxHeader(); llxHeader();
$html = new Form($db); $html = new Form($db);
$userstatic=new User($db);
$id = $_GET['id']; $id = $_GET['id'];
$ref= $_GET['ref']; $ref= $_GET['ref'];
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
@ -168,6 +170,9 @@ if ($id > 0 || ! empty($ref))
} }
print '</td></tr>'; print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
// Note publique // Note publique
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>'; print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
print '<td valign="top" colspan="3">'; print '<td valign="top" colspan="3">';

View File

@ -48,7 +48,8 @@ class Project extends CommonObject
var $date_start; var $date_start;
var $date_end; var $date_end;
var $socid; var $socid;
var $user_resp_id; var $user_author_id; //!< Id of project creator. Not defined if shared project.
var $user_resp_id; //!< Id of project responsible. Not defined if shared project.
var $note_private; var $note_private;
var $note_public; var $note_public;
@ -68,7 +69,7 @@ class Project extends CommonObject
$this->statuts=array(0=>'Draft',1=>'Validated',2=>'Closed'); $this->statuts=array(0=>'Draft',1=>'Validated',2=>'Closed');
} }
/* /**
* \brief Cree un projet en base * \brief Cree un projet en base
* \param user Id utilisateur qui cree * \param user Id utilisateur qui cree
* \return int <0 si ko, id du projet cree si ok * \return int <0 si ko, id du projet cree si ok
@ -97,7 +98,7 @@ class Project extends CommonObject
$sql.= ", '".addslashes($this->title)."'"; $sql.= ", '".addslashes($this->title)."'";
$sql.= ", '".addslashes($this->description)."'"; $sql.= ", '".addslashes($this->description)."'";
$sql.= ", ".($this->socid > 0?$this->socid:"null"); $sql.= ", ".($this->socid > 0?$this->socid:"null");
$sql.= ", ".($this->user_resp_id>0?$this->user_resp_id:'null'); $sql.= ", ".$user->id;
$sql.= ", ".($this->datec!=''?$this->db->idate($this->datec):'null'); $sql.= ", ".($this->datec!=''?$this->db->idate($this->datec):'null');
$sql.= ", ".($this->dateo!=''?$this->db->idate($this->dateo):'null'); $sql.= ", ".($this->dateo!=''?$this->db->idate($this->dateo):'null');
$sql.= ", ".($this->datee!=''?$this->db->idate($this->datee):'null'); $sql.= ", ".($this->datee!=''?$this->db->idate($this->datee):'null');