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);
$formcompany= new FormCompany($db);
$contactstatic=new Contact($db);
$userstatic=new User($db);
/* *************************************************************************** */
@ -172,14 +174,14 @@ if ($id > 0 || ! empty($ref))
if ( $project->fetch($id,$ref) > 0)
{
if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
// To verify role of users
$userAccess = 0;
foreach(array('internal','external') as $source)
{
$userRole = $project->liste_contact(4,$source);
$num=sizeof($userRole);
$i = 0;
while ($i < $num)
{
@ -217,6 +219,34 @@ if ($id > 0 || ! empty($ref))
else print '&nbsp;';
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 '</div>';

View File

@ -87,7 +87,7 @@ if ($_POST["action"] == 'add' && $user->rights->projet->creer)
if ($result > 0)
{
$result = $project->add_contact($_POST["officer_project"], 'PROJECTLEADER', 'internal');
Header("Location:fiche.php?id=".$project->id);
exit;
}
@ -129,8 +129,8 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->projet-
$project->title = $_POST["title"];
$project->socid = $_POST["socid"];
$project->description = $_POST["description"];
$project->date_start = 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_start = empty($_POST["project"])?'':dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']);
$project->date_end = empty($_POST["projectend"])?'':dol_mktime(12,0,0,$_POST['projectendmonth'],$_POST['projectendday'],$_POST['projectendyear']);
$result=$project->update($user);
@ -296,7 +296,7 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
print $html->select_date(-1,'projectend');
print '</td></tr>';
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
print '<td>';
@ -320,22 +320,27 @@ else
$project->fetch($projectid,$projectref);
if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
// To verify role of users
$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);
$num=sizeof($userRole);
$i = 0;
while ($i < $num)
foreach(array('internal','external') as $source)
{
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++;
}
}
@ -427,7 +432,7 @@ else
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
print $html->select_date($project->date_end?$project->date_end:-1,'projectend');
print '</td></tr>';
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
print '<td>';
@ -442,7 +447,7 @@ else
}
else
{
print '<table class="border" width="100%">';
// Ref
@ -496,7 +501,7 @@ else
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($project->date_end,'day');
print '</td></tr>';
// Description
print '<td valign="top">'.$langs->trans("Description").'</td><td>';
print nl2br($project->description);

View File

@ -80,15 +80,17 @@ if ($_POST['action'] == 'update_private' && $user->rights->projet->creer)
}
/******************************************************************************/
/* Affichage fiche */
/******************************************************************************/
/*
* View
*/
llxHeader();
$html = new Form($db);
$userstatic=new User($db);
$id = $_GET['id'];
$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref))
@ -99,18 +101,18 @@ if ($id > 0 || ! empty($ref))
$project = new Project($db);
$userstatic = new User($db);
if ($project->fetch($id, $ref))
{
if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
// To verify role of users
$userAccess = 0;
foreach(array('internal','external') as $source)
{
$userRole = $project->liste_contact(4,$source);
$num=sizeof($userRole);
$i = 0;
while ($i < $num)
{
@ -121,7 +123,7 @@ if ($id > 0 || ! empty($ref))
$i++;
}
}
$head = project_prepare_head($project);
dol_fiche_head($head, 'note', $langs->trans('Project'), 0, 'project');
@ -133,7 +135,7 @@ if ($id > 0 || ! empty($ref))
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
print $html->showrefnav($project,'ref','',1,'ref','ref');
print '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
@ -142,7 +144,7 @@ if ($id > 0 || ! empty($ref))
if ($project->societe->id > 0) print $project->societe->getNomUrl(1);
else print'&nbsp;';
print '</td></tr>';
// Project leader
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
$contact = $project->liste_contact(4,'internal');
@ -168,6 +170,9 @@ if ($id > 0 || ! empty($ref))
}
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
// Note publique
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
print '<td valign="top" colspan="3">';

View File

@ -48,7 +48,8 @@ class Project extends CommonObject
var $date_start;
var $date_end;
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_public;
@ -68,7 +69,7 @@ class Project extends CommonObject
$this->statuts=array(0=>'Draft',1=>'Validated',2=>'Closed');
}
/*
/**
* \brief Cree un projet en base
* \param user Id utilisateur qui cree
* \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->description)."'";
$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->dateo!=''?$this->db->idate($this->dateo):'null');
$sql.= ", ".($this->datee!=''?$this->db->idate($this->datee):'null');