diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php
index 1ce13c9b76e..c10348ca888 100644
--- a/htdocs/compta/paiement/cheque/fiche.php
+++ b/htdocs/compta/paiement/cheque/fiche.php
@@ -37,8 +37,9 @@ $langs->load('banks');
$langs->load('companies');
$langs->load('compta');
-$id = GETPOST("id");
-$ref= GETPOST("ref");
+$id =GETPOST("id");
+$ref=GETPOST("ref");
+$action=GETPOST('action');
// Security check
$fieldid = isset($_GET["ref"])?'number':'rowid';
@@ -63,7 +64,7 @@ $dir=$conf->banque->dir_output.'/bordereau/';
* Actions
*/
-if ($_POST['action'] == 'setdate' && $user->rights->banque->cheque)
+if ($action == 'setdate' && $user->rights->banque->cheque)
{
$remisecheque = new RemiseCheque($db);
$result = $remisecheque->fetch(GETPOST('id'));
@@ -84,11 +85,11 @@ if ($_POST['action'] == 'setdate' && $user->rights->banque->cheque)
}
}
-if ($_POST['action'] == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->cheque)
+if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->cheque)
{
if (is_array($_POST['toRemise']))
{
- $remisecheque = new RemiseCheque($db);
+ $remisecheque = new RemiseCheque($db);
$result = $remisecheque->create($user, $_POST["accountid"], 0, $_POST['toRemise']);
if ($result > 0)
{
@@ -118,12 +119,12 @@ if ($_POST['action'] == 'create' && $_POST["accountid"] > 0 && $user->rights->ba
}
else
{
- Header("Location: ".$_SERVER["PHP_SELF"]."?action=new");
- exit;
+ $mesg=$langs->trans("ErrorSelectAtLeastOne");
+ $action='new';
}
}
-if ($_GET['action'] == 'remove' && $_GET["id"] > 0 && $_GET["lineid"] > 0 && $user->rights->banque->cheque)
+if ($action == 'remove' && $_GET["id"] > 0 && $_GET["lineid"] > 0 && $user->rights->banque->cheque)
{
$remisecheque = new RemiseCheque($db);
$remisecheque->id = $_GET["id"];
@@ -139,7 +140,7 @@ if ($_GET['action'] == 'remove' && $_GET["id"] > 0 && $_GET["lineid"] > 0 && $us
}
}
-if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->banque->cheque)
+if ($action == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->banque->cheque)
{
$remisecheque = new RemiseCheque($db);
$remisecheque->id = $_GET["id"];
@@ -155,7 +156,7 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' &&
}
}
-if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $user->rights->banque->cheque)
+if ($action == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $user->rights->banque->cheque)
{
$remisecheque = new RemiseCheque($db);
$result = $remisecheque->fetch($_GET["id"]);
@@ -183,7 +184,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' &&
}
}
-if ($_POST['action'] == 'builddoc' && $user->rights->banque->cheque)
+if ($action == 'builddoc' && $user->rights->banque->cheque)
{
$remisecheque = new RemiseCheque($db);
$result = $remisecheque->fetch($_GET["id"]);
@@ -226,23 +227,7 @@ $html = new Form($db);
$formfile = new FormFile($db);
-?>
-
-form_confirm($_SERVER["PHP_SELF"].'?id='.$remisecheque->id, $langs->trans("DeleteCheckReceipt"), $langs->trans("ConfirmDeleteCheckReceipt"), 'confirm_delete','','',1);
if ($ret == 'html') print '
';
@@ -285,7 +270,7 @@ else
/*
* Confirmation de la validation du bordereau
*/
- if ($_GET['action'] == 'valide')
+ if ($action == 'valide')
{
$facid = $_GET['facid'];
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$remisecheque->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide','','',1);
@@ -293,10 +278,11 @@ else
}
}
-if ($mesg) print $mesg.'
';
+//if ($mesg) print $mesg.'
';
+dol_htmloutput_errors($mesg);
-if ($_GET['action'] == 'new')
+if ($action == 'new')
{
$accounts = array();
$lines = array();
@@ -342,12 +328,29 @@ if ($_GET['action'] == 'new')
foreach ($accounts as $bid => $account_label)
{
+
+ print '
+
+ ';
+
$num = $db->num_rows($resql);
print '