Fix: Project navigation forgot some project when permission see all was on

This commit is contained in:
Laurent Destailleur 2010-11-11 12:16:55 +00:00
parent 29e3e16280
commit 0d14009f4b
2 changed files with 395 additions and 391 deletions

View File

@ -805,6 +805,7 @@ class Project extends CommonObject
{ {
// No filter. Use this if user has permission to see all project // No filter. Use this if user has permission to see all project
} }
//print $sql;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)

View File

@ -34,12 +34,12 @@ require_once(DOL_DOCUMENT_ROOT."/includes/modules/project/modules_project.php");
$langs->load("projects"); $langs->load("projects");
$langs->load('companies'); $langs->load('companies');
$projectid = (isset($_GET["id"])?$_GET["id"]:(isset($_POST["id"])?$_POST["id"]:'')); $projectid = GETPOST('id','int');
$projectref = (isset($_GET["ref"])?$_GET["ref"]:''); $projectref = GETPOST('ref');
if ($projectid == '' && $projectref == '' && ($_GET['action'] != "create" && $_POST['action'] != "add" && $_POST["action"] != "update" && !$_POST["cancel"])) accessforbidden(); if ($projectid == '' && $projectref == '' && ($_GET['action'] != "create" && $_POST['action'] != "add" && $_POST["action"] != "update" && !$_POST["cancel"])) accessforbidden();
$mine = $_REQUEST['mode']=='mine' ? 1 : 0; $mine = GETPOST('mode')=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
// Security check // Security check
@ -56,170 +56,170 @@ $result = restrictedArea($user, 'projet', $projectid);
if ($_POST["action"] == 'add' && $user->rights->projet->creer) if ($_POST["action"] == 'add' && $user->rights->projet->creer)
{ {
$error=0; $error=0;
if (empty($_POST["ref"])) if (empty($_POST["ref"]))
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
$error++; $error++;
} }
if (empty($_POST["title"])) if (empty($_POST["title"]))
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>';
$error++; $error++;
} }
if (! $error) if (! $error)
{ {
$project = new Project($db); $project = new Project($db);
$project->ref = $_POST["ref"]; $project->ref = $_POST["ref"];
$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->public = $_POST["public"]; $project->public = $_POST["public"];
$project->datec=dol_now('tzserver'); $project->datec=dol_now('tzserver');
$project->dateo=dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']); $project->dateo=dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']);
$project->datee=dol_mktime(12,0,0,$_POST['projectendmonth'],$_POST['projectendday'],$_POST['projectendyear']); $project->datee=dol_mktime(12,0,0,$_POST['projectendmonth'],$_POST['projectendday'],$_POST['projectendyear']);
$result = $project->create($user); $result = $project->create($user);
if ($result > 0) if ($result > 0)
{ {
// Add myself as project leader // Add myself as project leader
$result = $project->add_contact($user->id, 'PROJECTLEADER', 'internal'); $result = $project->add_contact($user->id, 'PROJECTLEADER', 'internal');
Header("Location:fiche.php?id=".$project->id); Header("Location:fiche.php?id=".$project->id);
exit; exit;
} }
else else
{ {
$langs->load("errors"); $langs->load("errors");
$mesg='<div class="error">'.$langs->trans($project->error).'</div>'; $mesg='<div class="error">'.$langs->trans($project->error).'</div>';
$_GET["action"] = 'create'; $_GET["action"] = 'create';
} }
} }
else else
{ {
$_GET["action"] = 'create'; $_GET["action"] = 'create';
} }
} }
if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
{ {
$error=0; $error=0;
if (empty($_POST["ref"])) if (empty($_POST["ref"]))
{ {
$error++; $error++;
//$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet //$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
} }
if (empty($_POST["title"])) if (empty($_POST["title"]))
{ {
$error++; $error++;
//$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet //$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>';
} }
if (! $error) if (! $error)
{ {
$project = new Project($db); $project = new Project($db);
$project->fetch($_POST["id"]); $project->fetch($_POST["id"]);
$project->ref = $_POST["ref"]; $project->ref = $_POST["ref"];
$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->public = $_POST["public"]; $project->public = $_POST["public"];
$project->date_start = empty($_POST["project"])?'':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 = empty($_POST["projectend"])?'':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);
$_GET["id"]=$project->id; // On retourne sur la fiche projet $_GET["id"]=$project->id; // On retourne sur la fiche projet
} }
else else
{ {
$_GET["id"]=$_POST["id"]; $_GET["id"]=$_POST["id"];
$_GET['action']='edit'; $_GET['action']='edit';
} }
} }
// Build doc // Build doc
if ($_REQUEST['action'] == 'builddoc' && $user->rights->projet->creer) if (GETPOST('action') == 'builddoc' && $user->rights->projet->creer)
{ {
$project = new Project($db); $project = new Project($db);
$project->fetch($_GET['id']); $project->fetch($_GET['id']);
if ($_REQUEST['model']) if (GETPOST('model'))
{ {
$project->setDocModel($user, $_REQUEST['model']); $project->setDocModel($user, GETPOST('model'));
} }
$outputlangs = $langs; $outputlangs = $langs;
if (! empty($_REQUEST['lang_id'])) if (GETPOST('lang_id'))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang(GETPOST('lang_id'));
} }
$result=project_pdf_create($db, $project, $project->modelpdf, $outputlangs); $result=project_pdf_create($db, $project, $project->modelpdf, $outputlangs);
if ($result <= 0) if ($result <= 0)
{ {
dol_print_error($db,$result); dol_print_error($db,$result);
exit; exit;
} }
else else
{ {
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$project->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$project->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
exit; exit;
} }
} }
if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes') if (GETPOST('action') == 'confirm_validate' && GETPOST('confirm') == 'yes')
{ {
$project = new Project($db); $project = new Project($db);
$project->fetch($_GET["id"]); $project->fetch(GETPOST("id"));
$result = $project->setValid($user, $conf->projet->outputdir); $result = $project->setValid($user, $conf->projet->outputdir);
if ($result <= 0) if ($result <= 0)
{ {
$mesg='<div class="error">'.$project->error.'</div>'; $mesg='<div class="error">'.$project->error.'</div>';
} }
} }
if ($_REQUEST['action'] == 'confirm_close' && $_REQUEST['confirm'] == 'yes') if (GETPOST('action') == 'confirm_close' && GETPOST('confirm') == 'yes')
{ {
$project = new Project($db); $project = new Project($db);
$project->fetch($_GET["id"]); $project->fetch(GETPOST("id"));
$result = $project->setClose($user, $conf->projet->outputdir); $result = $project->setClose($user, $conf->projet->outputdir);
if ($result <= 0) if ($result <= 0)
{ {
$mesg='<div class="error">'.$project->error.'</div>'; $mesg='<div class="error">'.$project->error.'</div>';
} }
} }
if ($_REQUEST['action'] == 'confirm_reopen' && $_REQUEST['confirm'] == 'yes') if (GETPOST('action') == 'confirm_reopen' && GETPOST('confirm') == 'yes')
{ {
$project = new Project($db); $project = new Project($db);
$project->fetch($_GET["id"]); $project->fetch(GETPOST("id"));
$result = $project->setValid($user, $conf->projet->outputdir); $result = $project->setValid($user, $conf->projet->outputdir);
if ($result <= 0) if ($result <= 0)
{ {
$mesg='<div class="error">'.$project->error.'</div>'; $mesg='<div class="error">'.$project->error.'</div>';
} }
} }
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == "yes" && $user->rights->projet->supprimer) if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer)
{ {
$project = new Project($db); $project = new Project($db);
$project->fetch($_GET["id"]); $project->fetch(GETPOST("id"));
$result=$project->delete($user); $result=$project->delete($user);
if ($result > 0) if ($result > 0)
{ {
Header("Location: index.php"); Header("Location: index.php");
exit; exit;
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans("CantRemoveProject").'</div>'; $mesg='<div class="error">'.$langs->trans("CantRemoveProject").'</div>';
} }
} }
@ -238,322 +238,325 @@ llxHeader("",$langs->trans("Projects"),$help_url);
if ($_GET["action"] == 'create' && $user->rights->projet->creer) if ($_GET["action"] == 'create' && $user->rights->projet->creer)
{ {
/* /*
* Create * Create
*/ */
print_fiche_titre($langs->trans("NewProject")); print_fiche_titre($langs->trans("NewProject"));
if ($mesg) print $mesg.'<br>'; if ($mesg) print $mesg.'<br>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
$project = new Project($db); $project = new Project($db);
$defaultref=''; $defaultref='';
$obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; $obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON;
if (! empty($conf->global->PROJECT_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/project/".$conf->global->PROJECT_ADDON.".php")) if (! empty($conf->global->PROJECT_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/project/".$conf->global->PROJECT_ADDON.".php"))
{ {
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/project/".$conf->global->PROJECT_ADDON.".php"); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/project/".$conf->global->PROJECT_ADDON.".php");
$modProject = new $obj; $modProject = new $obj;
$defaultref = $modProject->getNextValue($soc,$project); $defaultref = $modProject->getNextValue($soc,$project);
} }
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
// Ref // Ref
print '<tr><td><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td><input size="12" type="text" name="ref" value="'.($_POST["ref"]?$_POST["ref"]:$defaultref).'"></td></tr>'; print '<tr><td><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td><input size="12" type="text" name="ref" value="'.($_POST["ref"]?$_POST["ref"]:$defaultref).'"></td></tr>';
// Label // Label
print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td><td><input size="30" type="text" name="title" value="'.$_POST["title"].'"></td></tr>'; print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td><td><input size="30" type="text" name="title" value="'.$_POST["title"].'"></td></tr>';
// Customer // Customer
print '<tr><td>'.$langs->trans("Company").'</td><td>'; print '<tr><td>'.$langs->trans("Company").'</td><td>';
print $html->select_societes($_REQUEST["socid"],'socid','',1,1); print $html->select_societes(GETPOST("socid"),'socid','',1,1);
print '</td></tr>'; print '</td></tr>';
// Public // Public
print '<tr><td>'.$langs->trans("Visibility").'</td><td>'; print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
$array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject")); $array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject"));
print $html->selectarray('public',$array,$project->public); print $html->selectarray('public',$array,$project->public);
print '</td></tr>'; print '</td></tr>';
// Date start // Date start
print '<tr><td>'.$langs->trans("DateStart").'</td><td>'; print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
print $html->select_date('','project'); print $html->select_date('','project');
print '</td></tr>'; print '</td></tr>';
// Date end // Date end
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>'; print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
print $html->select_date(-1,'projectend'); print $html->select_date(-1,'projectend');
print '</td></tr>'; print '</td></tr>';
// Description // Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td>'; print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
print '<td>'; print '<td>';
print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'">'.$_POST["description"].'</textarea>'; print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'">'.$_POST["description"].'</textarea>';
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '<br><center><input type="submit" class="button" value="'.$langs->trans("Create").'"></center>'; print '<br><center><input type="submit" class="button" value="'.$langs->trans("Create").'"></center>';
print '</form>'; print '</form>';
} }
else else
{ {
/* /*
* Show or edit * Show or edit
*/ */
if ($mesg) print $mesg; if ($mesg) print $mesg;
$project = new Project($db); $project = new Project($db);
$project->fetch($projectid,$projectref); $project->fetch($projectid,$projectref);
if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id); if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
// To verify role of users // To verify role of users
$userAccess = $project->restrictedProjectArea($user); $userAccess = $project->restrictedProjectArea($user);
$head=project_prepare_head($project); $head=project_prepare_head($project);
dol_fiche_head($head, 'project', $langs->trans("Project"),0,($project->public?'projectpub':'project')); dol_fiche_head($head, 'project', $langs->trans("Project"),0,($project->public?'projectpub':'project'));
// Confirmation validation // Confirmation validation
if ($_GET['action'] == 'validate') if ($_GET['action'] == 'validate')
{ {
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$project->id, $langs->trans('ValidateProject'), $langs->trans('ConfirmValidateProject'), 'confirm_validate','',0,1); $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$project->id, $langs->trans('ValidateProject'), $langs->trans('ConfirmValidateProject'), 'confirm_validate','',0,1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
// Confirmation close // Confirmation close
if ($_GET["action"] == 'close') if ($_GET["action"] == 'close')
{ {
$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("CloseAProject"),$langs->trans("ConfirmCloseAProject"),"confirm_close",'','',1); $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("CloseAProject"),$langs->trans("ConfirmCloseAProject"),"confirm_close",'','',1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
// Confirmation reopen // Confirmation reopen
if ($_GET["action"] == 'reopen') if ($_GET["action"] == 'reopen')
{ {
$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("ReOpenAProject"),$langs->trans("ConfirmReOpenAProject"),"confirm_reopen",'','',1); $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("ReOpenAProject"),$langs->trans("ConfirmReOpenAProject"),"confirm_reopen",'','',1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
// Confirmation delete // Confirmation delete
if ($_GET["action"] == 'delete') if ($_GET["action"] == 'delete')
{ {
$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete",'','',1); $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete",'','',1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
if ($_GET["action"] == 'edit' && $userAccess) if ($_GET["action"] == 'edit' && $userAccess)
{ {
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$project->id.'">'; print '<input type="hidden" name="id" value="'.$project->id.'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td>'; print '<tr><td width="30%">'.$langs->trans("Ref").'</td>';
print '<td><input size="12" name="ref" value="'.$project->ref.'"></td></tr>'; print '<td><input size="12" name="ref" value="'.$project->ref.'"></td></tr>';
// Label // Label
print '<tr><td>'.$langs->trans("Label").'</td>'; print '<tr><td>'.$langs->trans("Label").'</td>';
print '<td><input size="30" name="title" value="'.$project->title.'"></td></tr>'; print '<td><input size="30" name="title" value="'.$project->title.'"></td></tr>';
// Customer // Customer
print '<tr><td>'.$langs->trans("Company").'</td><td>'; print '<tr><td>'.$langs->trans("Company").'</td><td>';
print $html->select_societes($project->societe->id,'socid','',1,1); print $html->select_societes($project->societe->id,'socid','',1,1);
print '</td></tr>'; print '</td></tr>';
// Visibility // Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>'; print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
$array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject")); $array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject"));
print $html->selectarray('public',$array,$project->public); print $html->selectarray('public',$array,$project->public);
print '</td></tr>'; print '</td></tr>';
// Statut // Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>'; print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
// Date start // Date start
print '<tr><td>'.$langs->trans("DateStart").'</td><td>'; print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
print $html->select_date($project->date_start,'project'); print $html->select_date($project->date_start,'project');
print '</td></tr>'; print '</td></tr>';
// Date end // Date end
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>'; print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
print $html->select_date($project->date_end?$project->date_end:-1,'projectend'); print $html->select_date($project->date_end?$project->date_end:-1,'projectend');
print '</td></tr>'; print '</td></tr>';
// Description // Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td>'; print '<tr><td valign="top">'.$langs->trans("Description").'</td>';
print '<td>'; print '<td>';
print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'">'.$project->description.'</textarea>'; print '<textarea name="description" wrap="soft" cols="80" rows="'.ROWS_3.'">'.$project->description.'</textarea>';
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center" colspan="2">'; print '<tr><td align="center" colspan="2">';
print '<input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> &nbsp; '; print '<input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> &nbsp; ';
print '<input type="submit" class="button" name="cancel" Value="'.$langs->trans("Cancel").'"></td></tr>'; print '<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%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>'; print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
// Define a complementary filter for search of next/prev ref. // Define a complementary filter for search of next/prev ref.
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1); if (! $user->rights->projet->all->lire)
$project->next_prev_filter=" rowid in (".$projectsListId.")"; {
print $html->showrefnav($project,'ref','',1,'ref','ref'); $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
print '</td></tr>'; $project->next_prev_filter=" rowid in (".$projectsListId.")";
}
print $html->showrefnav($project,'ref','',1,'ref','ref');
print '</td></tr>';
// Label // Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
// Third party // Third party
print '<tr><td>'.$langs->trans("Company").'</td><td>'; print '<tr><td>'.$langs->trans("Company").'</td><td>';
if ($project->societe->id > 0) print $project->societe->getNomUrl(1); if ($project->societe->id > 0) print $project->societe->getNomUrl(1);
else print'&nbsp;'; else print'&nbsp;';
print '</td></tr>'; print '</td></tr>';
// Visibility // Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>'; print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($project->public) print $langs->trans('SharedProject'); if ($project->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject'); else print $langs->trans('PrivateProject');
print '</td></tr>'; print '</td></tr>';
// Statut // Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>'; print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
// Date start // Date start
print '<tr><td>'.$langs->trans("DateStart").'</td><td>'; print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
print dol_print_date($project->date_start,'day'); print dol_print_date($project->date_start,'day');
print '</td></tr>'; print '</td></tr>';
// Date end // Date end
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>'; print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($project->date_end,'day'); print dol_print_date($project->date_end,'day');
print '</td></tr>'; print '</td></tr>';
// Description // Description
print '<td valign="top">'.$langs->trans("Description").'</td><td>'; print '<td valign="top">'.$langs->trans("Description").'</td><td>';
print nl2br($project->description); print nl2br($project->description);
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
} }
print '</div>'; dol_fiche_end();
/* /*
* Boutons actions * Boutons actions
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($_GET["action"] != "edit" ) if ($_GET["action"] != "edit" )
{ {
// Validate // Validate
if ($project->statut == 0 && $user->rights->projet->creer) if ($project->statut == 0 && $user->rights->projet->creer)
{ {
if ($userAccess) if ($userAccess)
{ {
print '<a class="butAction" href="fiche.php?id='.$project->id.'&action=validate">'.$langs->trans("Valid").'</a>'; print '<a class="butAction" href="fiche.php?id='.$project->id.'&action=validate">'.$langs->trans("Valid").'</a>';
} }
else else
{ {
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Valid').'</a>'; print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Valid').'</a>';
} }
} }
// Modify // Modify
if ($project->statut != 2 && $user->rights->projet->creer) if ($project->statut != 2 && $user->rights->projet->creer)
{ {
if ($userAccess) if ($userAccess)
{ {
print '<a class="butAction" href="fiche.php?id='.$project->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'; print '<a class="butAction" href="fiche.php?id='.$project->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
} }
else else
{ {
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Modify').'</a>'; print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Modify').'</a>';
} }
} }
// Close // Close
if ($project->statut == 1 && $user->rights->projet->creer) if ($project->statut == 1 && $user->rights->projet->creer)
{ {
if ($userAccess) if ($userAccess)
{ {
print '<a class="butAction" href="fiche.php?id='.$project->id.'&amp;action=close">'.$langs->trans("Close").'</a>'; print '<a class="butAction" href="fiche.php?id='.$project->id.'&amp;action=close">'.$langs->trans("Close").'</a>';
} }
else else
{ {
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Close').'</a>'; print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Close').'</a>';
} }
} }
// Reopen // Reopen
if ($project->statut == 2 && $user->rights->projet->creer) if ($project->statut == 2 && $user->rights->projet->creer)
{ {
if ($userAccess) if ($userAccess)
{ {
print '<a class="butAction" href="fiche.php?id='.$project->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>'; print '<a class="butAction" href="fiche.php?id='.$project->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>';
} }
else else
{ {
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('ReOpen').'</a>'; print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('ReOpen').'</a>';
} }
} }
// Delete // Delete
if ($user->rights->projet->supprimer) if ($user->rights->projet->supprimer)
{ {
if ($userAccess) if ($userAccess)
{ {
print '<a class="butActionDelete" href="fiche.php?id='.$project->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>'; print '<a class="butActionDelete" href="fiche.php?id='.$project->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
} }
else else
{ {
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Delete').'</a>';
} }
} }
} }
print "</div>"; print "</div>";
print "<br>\n"; print "<br>\n";
if ($_GET['action'] != 'presend') if ($_GET['action'] != 'presend')
{ {
print '<table width="100%"><tr><td width="50%" valign="top">'; print '<table width="100%"><tr><td width="50%" valign="top">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
/* /*
* Documents generes * Documents generes
*/ */
$filename=dol_sanitizeFileName($project->ref); $filename=dol_sanitizeFileName($project->ref);
$filedir=$conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref); $filedir=$conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref);
$urlsource=$_SERVER["PHP_SELF"]."?id=".$project->id; $urlsource=$_SERVER["PHP_SELF"]."?id=".$project->id;
$genallowed=($user->rights->projet->creer && $userAccess); $genallowed=($user->rights->projet->creer && $userAccess);
$delallowed=($user->rights->projet->supprimer && $userAccess); $delallowed=($user->rights->projet->supprimer && $userAccess);
$var=true; $var=true;
$somethingshown=$formfile->show_documents('project',$filename,$filedir,$urlsource,$genallowed,$delallowed,$project->modelpdf); $somethingshown=$formfile->show_documents('project',$filename,$filedir,$urlsource,$genallowed,$delallowed,$project->modelpdf);
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';
// List of actions on element // List of actions on element
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php');
$formactions=new FormActions($db); $formactions=new FormActions($db);
$somethingshown=$formactions->showactions($project,'project',$socid); $somethingshown=$formactions->showactions($project,'project',$socid);
print '</td></tr></table>'; print '</td></tr></table>';
} }
} }