diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index c0f895d7b15..496c8bdca3d 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -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 ' '; print ''; + // Project leader + print ''.$langs->trans("OfficerProject").''; + $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 '
'; + } + $i++; + } + } + else + { + print $langs->trans('SharedProject'); + } + print ''; + + // Statut + print ''.$langs->trans("Status").''.$project->getLibStatut(4).''; + print ""; print ''; diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index fed7ba50c9e..e9941961162 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -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 ''.$langs->trans("DateEnd").''; print $html->select_date(-1,'projectend'); print ''; - + // Description print ''.$langs->trans("Description").''; print ''; @@ -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 ''.$langs->trans("DateEnd").''; print $html->select_date($project->date_end?$project->date_end:-1,'projectend'); print ''; - + // Description print ''.$langs->trans("Description").''; print ''; @@ -442,7 +447,7 @@ else } else { - + print ''; // Ref @@ -496,7 +501,7 @@ else print ''; - + // Description print ''; - + // Label print ''; @@ -142,7 +144,7 @@ if ($id > 0 || ! empty($ref)) if ($project->societe->id > 0) print $project->societe->getNomUrl(1); else print' '; print ''; - + // Project leader print ''; + // Statut + print ''; + // Note publique print ''; print '
'.$langs->trans("DateEnd").''; print dol_print_date($project->date_end,'day'); print '
'.$langs->trans("Description").''; print nl2br($project->description); diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 1d609f0b36d..f5c234063c0 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -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 '
'.$langs->trans("Ref").''; print $html->showrefnav($project,'ref','',1,'ref','ref'); print '
'.$langs->trans("Label").''.$project->title.'
'.$langs->trans("OfficerProject").''; $contact = $project->liste_contact(4,'internal'); @@ -168,6 +170,9 @@ if ($id > 0 || ! empty($ref)) } print '
'.$langs->trans("Status").''.$project->getLibStatut(4).'
'.$langs->trans("NotePublic").' :'; diff --git a/htdocs/projet/project.class.php b/htdocs/projet/project.class.php index fd7f5daaa6d..d2d97345bba 100644 --- a/htdocs/projet/project.class.php +++ b/htdocs/projet/project.class.php @@ -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');