Fix: Control of input values

This commit is contained in:
Laurent Destailleur 2009-11-02 19:17:58 +00:00
parent 8922b93395
commit 771a8f7dc8

View File

@ -34,6 +34,7 @@ if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande
$projetid=''; $projetid='';
$ref=''; $ref='';
if (isset($_GET["id"])) { $projetid=$_GET["id"]; } if (isset($_GET["id"])) { $projetid=$_GET["id"]; }
else $_GET["id"]=$_POST["id"];
if (isset($_GET["ref"])) { $ref=$_GET["ref"]; } if (isset($_GET["ref"])) { $ref=$_GET["ref"]; }
//var_dump($_REQUEST);exit; //var_dump($_REQUEST);exit;
@ -60,6 +61,20 @@ $result = restrictedArea($user, 'projet', $projetid);
if ($_POST["action"] == 'add' && $user->rights->projet->creer) if ($_POST["action"] == 'add' && $user->rights->projet->creer)
{ {
$error=0;
if (empty($_POST["ref"]))
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
$error++;
}
if (empty($_POST["title"]))
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>';
$error++;
}
if (! $error)
{
//print $_POST["socid"]; //print $_POST["socid"];
$project = new Project($db); $project = new Project($db);
$project->ref = $_POST["ref"]; $project->ref = $_POST["ref"];
@ -81,23 +96,27 @@ if ($_POST["action"] == 'add' && $user->rights->projet->creer)
$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
{
$_GET["action"] = 'create';
}
} }
if ($_POST["action"] == 'update' && $user->rights->projet->creer) if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
{ {
if (! $_POST["cancel"])
{
$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)
@ -110,14 +129,14 @@ if ($_POST["action"] == 'update' && $user->rights->projet->creer)
$projet->user_resp_id = $_POST["officer_project"]; $projet->user_resp_id = $_POST["officer_project"];
$projet->dateo = dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']); $projet->dateo = dol_mktime(12,0,0,$_POST['projectmonth'],$_POST['projectday'],$_POST['projectyear']);
$projet->update($user); $result=$projet->update($user);
$_GET["id"]=$projet->id; // On retourne sur la fiche projet $_GET["id"]=$projet->id; // On retourne sur la fiche projet
} }
}
else else
{ {
$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet $_GET["id"]=$_POST["id"];
$_GET['action']='edit';
} }
} }
@ -163,10 +182,10 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
// Ref // Ref
print '<tr><td>'.$langs->trans("Ref").'</td><td><input size="8" type="text" name="ref" value="'.$_POST["ref"].'"></td></tr>'; print '<tr><td>'.$langs->trans("Ref").'*</td><td><input size="8" type="text" name="ref" value="'.$_POST["ref"].'"></td></tr>';
// Label // Label
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" type="text" name="title" value="'.$_POST["title"].'"></td></tr>'; print '<tr><td>'.$langs->trans("Label").'*</td><td><input size="30" type="text" name="title" value="'.$_POST["title"].'"></td></tr>';
// Client // Client
print '<tr><td>'.$langs->trans("Company").'</td><td>'; print '<tr><td>'.$langs->trans("Company").'</td><td>';