diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index 9efd8016338..51bb6d7e384 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -805,6 +805,7 @@ class Project extends CommonObject
{
// No filter. Use this if user has permission to see all project
}
+ //print $sql;
$resql = $this->db->query($sql);
if ($resql)
diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php
index c90713f0fba..ea892177d53 100644
--- a/htdocs/projet/fiche.php
+++ b/htdocs/projet/fiche.php
@@ -34,12 +34,12 @@ require_once(DOL_DOCUMENT_ROOT."/includes/modules/project/modules_project.php");
$langs->load("projects");
$langs->load('companies');
-$projectid = (isset($_GET["id"])?$_GET["id"]:(isset($_POST["id"])?$_POST["id"]:''));
-$projectref = (isset($_GET["ref"])?$_GET["ref"]:'');
+$projectid = GETPOST('id','int');
+$projectref = GETPOST('ref');
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
// Security check
@@ -56,170 +56,170 @@ $result = restrictedArea($user, 'projet', $projectid);
if ($_POST["action"] == 'add' && $user->rights->projet->creer)
{
- $error=0;
- if (empty($_POST["ref"]))
- {
- $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'
';
- $error++;
- }
- if (empty($_POST["title"]))
- {
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'
';
- $error++;
- }
+ $error=0;
+ if (empty($_POST["ref"]))
+ {
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'
';
+ $error++;
+ }
+ if (empty($_POST["title"]))
+ {
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'
';
+ $error++;
+ }
- if (! $error)
- {
- $project = new Project($db);
+ if (! $error)
+ {
+ $project = new Project($db);
- $project->ref = $_POST["ref"];
- $project->title = $_POST["title"];
- $project->socid = $_POST["socid"];
- $project->description = $_POST["description"];
- $project->public = $_POST["public"];
- $project->datec=dol_now('tzserver');
- $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->ref = $_POST["ref"];
+ $project->title = $_POST["title"];
+ $project->socid = $_POST["socid"];
+ $project->description = $_POST["description"];
+ $project->public = $_POST["public"];
+ $project->datec=dol_now('tzserver');
+ $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']);
- $result = $project->create($user);
- if ($result > 0)
- {
- // Add myself as project leader
- $result = $project->add_contact($user->id, 'PROJECTLEADER', 'internal');
+ $result = $project->create($user);
+ if ($result > 0)
+ {
+ // Add myself as project leader
+ $result = $project->add_contact($user->id, 'PROJECTLEADER', 'internal');
- Header("Location:fiche.php?id=".$project->id);
- exit;
- }
- else
- {
- $langs->load("errors");
- $mesg=''.$langs->trans($project->error).'
';
- $_GET["action"] = 'create';
- }
- }
- else
- {
- $_GET["action"] = 'create';
- }
+ Header("Location:fiche.php?id=".$project->id);
+ exit;
+ }
+ else
+ {
+ $langs->load("errors");
+ $mesg=''.$langs->trans($project->error).'
';
+ $_GET["action"] = 'create';
+ }
+ }
+ else
+ {
+ $_GET["action"] = 'create';
+ }
}
if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
{
- $error=0;
+ $error=0;
- if (empty($_POST["ref"]))
- {
- $error++;
- //$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'
';
- }
- if (empty($_POST["title"]))
- {
- $error++;
- //$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'
';
- }
- if (! $error)
- {
- $project = new Project($db);
- $project->fetch($_POST["id"]);
+ if (empty($_POST["ref"]))
+ {
+ $error++;
+ //$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'
';
+ }
+ if (empty($_POST["title"]))
+ {
+ $error++;
+ //$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'
';
+ }
+ if (! $error)
+ {
+ $project = new Project($db);
+ $project->fetch($_POST["id"]);
- $project->ref = $_POST["ref"];
- $project->title = $_POST["title"];
- $project->socid = $_POST["socid"];
- $project->description = $_POST["description"];
- $project->public = $_POST["public"];
- $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->ref = $_POST["ref"];
+ $project->title = $_POST["title"];
+ $project->socid = $_POST["socid"];
+ $project->description = $_POST["description"];
+ $project->public = $_POST["public"];
+ $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);
+ $result=$project->update($user);
- $_GET["id"]=$project->id; // On retourne sur la fiche projet
- }
- else
- {
- $_GET["id"]=$_POST["id"];
- $_GET['action']='edit';
- }
+ $_GET["id"]=$project->id; // On retourne sur la fiche projet
+ }
+ else
+ {
+ $_GET["id"]=$_POST["id"];
+ $_GET['action']='edit';
+ }
}
// Build doc
-if ($_REQUEST['action'] == 'builddoc' && $user->rights->projet->creer)
+if (GETPOST('action') == 'builddoc' && $user->rights->projet->creer)
{
- $project = new Project($db);
- $project->fetch($_GET['id']);
- if ($_REQUEST['model'])
- {
- $project->setDocModel($user, $_REQUEST['model']);
- }
+ $project = new Project($db);
+ $project->fetch($_GET['id']);
+ if (GETPOST('model'))
+ {
+ $project->setDocModel($user, GETPOST('model'));
+ }
- $outputlangs = $langs;
- if (! empty($_REQUEST['lang_id']))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($_REQUEST['lang_id']);
- }
- $result=project_pdf_create($db, $project, $project->modelpdf, $outputlangs);
- if ($result <= 0)
- {
- dol_print_error($db,$result);
- exit;
- }
- else
- {
- Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$project->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
- exit;
- }
+ $outputlangs = $langs;
+ if (GETPOST('lang_id'))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang(GETPOST('lang_id'));
+ }
+ $result=project_pdf_create($db, $project, $project->modelpdf, $outputlangs);
+ if ($result <= 0)
+ {
+ dol_print_error($db,$result);
+ exit;
+ }
+ else
+ {
+ Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$project->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
+ exit;
+ }
}
-if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes')
+if (GETPOST('action') == 'confirm_validate' && GETPOST('confirm') == 'yes')
{
- $project = new Project($db);
- $project->fetch($_GET["id"]);
+ $project = new Project($db);
+ $project->fetch(GETPOST("id"));
- $result = $project->setValid($user, $conf->projet->outputdir);
- if ($result <= 0)
- {
- $mesg=''.$project->error.'
';
- }
+ $result = $project->setValid($user, $conf->projet->outputdir);
+ if ($result <= 0)
+ {
+ $mesg=''.$project->error.'
';
+ }
}
-if ($_REQUEST['action'] == 'confirm_close' && $_REQUEST['confirm'] == 'yes')
+if (GETPOST('action') == 'confirm_close' && GETPOST('confirm') == 'yes')
{
- $project = new Project($db);
- $project->fetch($_GET["id"]);
- $result = $project->setClose($user, $conf->projet->outputdir);
- if ($result <= 0)
- {
- $mesg=''.$project->error.'
';
- }
+ $project = new Project($db);
+ $project->fetch(GETPOST("id"));
+ $result = $project->setClose($user, $conf->projet->outputdir);
+ if ($result <= 0)
+ {
+ $mesg=''.$project->error.'
';
+ }
}
-if ($_REQUEST['action'] == 'confirm_reopen' && $_REQUEST['confirm'] == 'yes')
+if (GETPOST('action') == 'confirm_reopen' && GETPOST('confirm') == 'yes')
{
- $project = new Project($db);
- $project->fetch($_GET["id"]);
- $result = $project->setValid($user, $conf->projet->outputdir);
- if ($result <= 0)
- {
- $mesg=''.$project->error.'
';
- }
+ $project = new Project($db);
+ $project->fetch(GETPOST("id"));
+ $result = $project->setValid($user, $conf->projet->outputdir);
+ if ($result <= 0)
+ {
+ $mesg=''.$project->error.'
';
+ }
}
-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->fetch($_GET["id"]);
- $result=$project->delete($user);
- if ($result > 0)
- {
- Header("Location: index.php");
- exit;
- }
- else
- {
- $mesg=''.$langs->trans("CantRemoveProject").'
';
- }
+ $project = new Project($db);
+ $project->fetch(GETPOST("id"));
+ $result=$project->delete($user);
+ if ($result > 0)
+ {
+ Header("Location: index.php");
+ exit;
+ }
+ else
+ {
+ $mesg=''.$langs->trans("CantRemoveProject").'
';
+ }
}
@@ -238,322 +238,325 @@ llxHeader("",$langs->trans("Projects"),$help_url);
if ($_GET["action"] == 'create' && $user->rights->projet->creer)
{
- /*
- * Create
- */
- print_fiche_titre($langs->trans("NewProject"));
+ /*
+ * Create
+ */
+ print_fiche_titre($langs->trans("NewProject"));
- if ($mesg) print $mesg.' ';
+ if ($mesg) print $mesg.' ';
- print '';
+ print ' ';
+ print '';
}
else
{
- /*
- * Show or edit
- */
+ /*
+ * Show or edit
+ */
- if ($mesg) print $mesg;
+ if ($mesg) print $mesg;
- $project = new Project($db);
- $project->fetch($projectid,$projectref);
+ $project = new Project($db);
+ $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
- $userAccess = $project->restrictedProjectArea($user);
+ // To verify role of users
+ $userAccess = $project->restrictedProjectArea($user);
- $head=project_prepare_head($project);
- dol_fiche_head($head, 'project', $langs->trans("Project"),0,($project->public?'projectpub':'project'));
+ $head=project_prepare_head($project);
+ dol_fiche_head($head, 'project', $langs->trans("Project"),0,($project->public?'projectpub':'project'));
- // Confirmation validation
- if ($_GET['action'] == 'validate')
- {
- $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$project->id, $langs->trans('ValidateProject'), $langs->trans('ConfirmValidateProject'), 'confirm_validate','',0,1);
- if ($ret == 'html') print ' ';
- }
- // Confirmation close
- if ($_GET["action"] == 'close')
- {
- $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("CloseAProject"),$langs->trans("ConfirmCloseAProject"),"confirm_close",'','',1);
- if ($ret == 'html') print ' ';
- }
- // Confirmation reopen
- if ($_GET["action"] == 'reopen')
- {
- $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("ReOpenAProject"),$langs->trans("ConfirmReOpenAProject"),"confirm_reopen",'','',1);
- if ($ret == 'html') print ' ';
- }
- // Confirmation delete
- if ($_GET["action"] == 'delete')
- {
- $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete",'','',1);
- if ($ret == 'html') print ' ';
- }
+ // Confirmation validation
+ if ($_GET['action'] == 'validate')
+ {
+ $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$project->id, $langs->trans('ValidateProject'), $langs->trans('ConfirmValidateProject'), 'confirm_validate','',0,1);
+ if ($ret == 'html') print ' ';
+ }
+ // Confirmation close
+ if ($_GET["action"] == 'close')
+ {
+ $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("CloseAProject"),$langs->trans("ConfirmCloseAProject"),"confirm_close",'','',1);
+ if ($ret == 'html') print ' ';
+ }
+ // Confirmation reopen
+ if ($_GET["action"] == 'reopen')
+ {
+ $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("ReOpenAProject"),$langs->trans("ConfirmReOpenAProject"),"confirm_reopen",'','',1);
+ if ($ret == 'html') print ' ';
+ }
+ // Confirmation delete
+ if ($_GET["action"] == 'delete')
+ {
+ $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete",'','',1);
+ if ($ret == 'html') print ' ';
+ }
- if ($_GET["action"] == 'edit' && $userAccess)
- {
- print '';
- print ' ';
- print ' ';
- print ' ';
+ if ($_GET["action"] == 'edit' && $userAccess)
+ {
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
- print '';
+ print '';
- // Ref
- print ''.$langs->trans("Ref").' ';
- print ' ';
+ // Ref
+ print ''.$langs->trans("Ref").' ';
+ print ' ';
- // Label
- print ''.$langs->trans("Label").' ';
- print ' ';
+ // Label
+ print ''.$langs->trans("Label").' ';
+ print ' ';
- // Customer
- print ''.$langs->trans("Company").' ';
- print $html->select_societes($project->societe->id,'socid','',1,1);
- print ' ';
+ // Customer
+ print ''.$langs->trans("Company").' ';
+ print $html->select_societes($project->societe->id,'socid','',1,1);
+ print ' ';
- // Visibility
- print ''.$langs->trans("Visibility").' ';
- $array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject"));
- print $html->selectarray('public',$array,$project->public);
- print ' ';
+ // Visibility
+ print ''.$langs->trans("Visibility").' ';
+ $array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject"));
+ print $html->selectarray('public',$array,$project->public);
+ print ' ';
- // Statut
- print ''.$langs->trans("Status").' '.$project->getLibStatut(4).' ';
+ // Statut
+ print ''.$langs->trans("Status").' '.$project->getLibStatut(4).' ';
- // Date start
- print ''.$langs->trans("DateStart").' ';
- print $html->select_date($project->date_start,'project');
- print ' ';
+ // Date start
+ print ''.$langs->trans("DateStart").' ';
+ print $html->select_date($project->date_start,'project');
+ print ' ';
- // Date end
- print ''.$langs->trans("DateEnd").' ';
- print $html->select_date($project->date_end?$project->date_end:-1,'projectend');
- print ' ';
+ // Date end
+ print ''.$langs->trans("DateEnd").' ';
+ print $html->select_date($project->date_end?$project->date_end:-1,'projectend');
+ print ' ';
- // Description
- print ''.$langs->trans("Description").' ';
- print '';
- print ''.$project->description.' ';
- print ' ';
+ // Description
+ print ''.$langs->trans("Description").' ';
+ print '';
+ print ''.$project->description.' ';
+ print ' ';
- print '';
- print ' ';
- print ' ';
- print '
';
- print '';
- }
- else
- {
- print '';
+ print '';
+ }
+ else
+ {
+ print '';
- // Ref
- print ''.$langs->trans("Ref").' ';
- // Define a complementary filter for search of next/prev ref.
- $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
- $project->next_prev_filter=" rowid in (".$projectsListId.")";
- print $html->showrefnav($project,'ref','',1,'ref','ref');
- print ' ';
+ // Ref
+ print ''.$langs->trans("Ref").' ';
+ // Define a complementary filter for search of next/prev ref.
+ if (! $user->rights->projet->all->lire)
+ {
+ $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
+ $project->next_prev_filter=" rowid in (".$projectsListId.")";
+ }
+ print $html->showrefnav($project,'ref','',1,'ref','ref');
+ print ' ';
- // Label
- print ''.$langs->trans("Label").' '.$project->title.' ';
+ // Label
+ print ''.$langs->trans("Label").' '.$project->title.' ';
- // Third party
- print ''.$langs->trans("Company").' ';
- if ($project->societe->id > 0) print $project->societe->getNomUrl(1);
- else print' ';
- print ' ';
+ // Third party
+ print ''.$langs->trans("Company").' ';
+ if ($project->societe->id > 0) print $project->societe->getNomUrl(1);
+ else print' ';
+ print ' ';
- // Visibility
- print ''.$langs->trans("Visibility").' ';
- if ($project->public) print $langs->trans('SharedProject');
- else print $langs->trans('PrivateProject');
- print ' ';
+ // Visibility
+ print ''.$langs->trans("Visibility").' ';
+ if ($project->public) print $langs->trans('SharedProject');
+ else print $langs->trans('PrivateProject');
+ print ' ';
- // Statut
- print ''.$langs->trans("Status").' '.$project->getLibStatut(4).' ';
+ // Statut
+ print ''.$langs->trans("Status").' '.$project->getLibStatut(4).' ';
- // Date start
- print ''.$langs->trans("DateStart").' ';
- print dol_print_date($project->date_start,'day');
- print ' ';
+ // Date start
+ print ''.$langs->trans("DateStart").' ';
+ print dol_print_date($project->date_start,'day');
+ print ' ';
- // Date end
- print ''.$langs->trans("DateEnd").' ';
- print dol_print_date($project->date_end,'day');
- print ' ';
+ // Date end
+ print ''.$langs->trans("DateEnd").' ';
+ print dol_print_date($project->date_end,'day');
+ print ' ';
- // Description
- print ''.$langs->trans("Description").' ';
- print nl2br($project->description);
- print ' ';
+ // Description
+ print ''.$langs->trans("Description").' ';
+ print nl2br($project->description);
+ print ' ';
- print '
';
- }
+ print '
';
+ }
- print '';
+ dol_fiche_end();
- /*
- * Boutons actions
- */
- print '';
+ /*
+ * Boutons actions
+ */
+ print '
";
- print "
\n";
+ print "
";
+ print " \n";
- if ($_GET['action'] != 'presend')
- {
- print '';
- print ' '; // ancre
+ if ($_GET['action'] != 'presend')
+ {
+ print '';
+ print ' '; // ancre
- /*
- * Documents generes
- */
- $filename=dol_sanitizeFileName($project->ref);
- $filedir=$conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref);
- $urlsource=$_SERVER["PHP_SELF"]."?id=".$project->id;
- $genallowed=($user->rights->projet->creer && $userAccess);
- $delallowed=($user->rights->projet->supprimer && $userAccess);
+ /*
+ * Documents generes
+ */
+ $filename=dol_sanitizeFileName($project->ref);
+ $filedir=$conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref);
+ $urlsource=$_SERVER["PHP_SELF"]."?id=".$project->id;
+ $genallowed=($user->rights->projet->creer && $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 ' ';
+ print ' ';
- // List of actions on element
- include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php');
- $formactions=new FormActions($db);
- $somethingshown=$formactions->showactions($project,'project',$socid);
+ // List of actions on element
+ include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php');
+ $formactions=new FormActions($db);
+ $somethingshown=$formactions->showactions($project,'project',$socid);
- print '
';
- }
+ print '
';
+ }
}