diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php
index 9fee3f401f1..679d43c74fc 100644
--- a/htdocs/compta/paiement/cheque/fiche.php
+++ b/htdocs/compta/paiement/cheque/fiche.php
@@ -35,11 +35,10 @@ $langs->load('bills');
$langs->load('banks');
$langs->load('companies');
+$id = isset($_REQUEST["id"])?$_REQUEST["id"]:'';
+$ref= isset($_REQUEST["ref"])?$_REQUEST["ref"]:'';
+
// Security check
-if (isset($_GET["id"]) || isset($_GET["ref"]))
-{
- $id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:'');
-}
$fieldid = isset($_GET["ref"])?'number':'rowid';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque','','',$fieldid);
@@ -77,7 +76,7 @@ if ($_GET['action'] == 'create' && $_GET["accountid"] > 0 && $user->rights->banq
}
}
-if ($_GET['action'] == 'remove' && $_GET["id"] > 0 && $_GET["lineid"] > 0 && $user->rights->banque)
+if ($_GET['action'] == 'remove' && $_GET["id"] > 0 && $_GET["lineid"] > 0 && $user->rights->banque->cheque)
{
$remisecheque = new RemiseCheque($db);
$remisecheque->id = $_GET["id"];
@@ -93,7 +92,7 @@ if ($_GET['action'] == 'remove' && $_GET["id"] > 0 && $_GET["lineid"] > 0 && $us
}
}
-if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->banque)
+if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->banque->cheque)
{
$remisecheque = new RemiseCheque($db);
$remisecheque->id = $_GET["id"];
@@ -109,7 +108,7 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user-
}
}
-if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->banque)
+if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $user->rights->banque->cheque)
{
$remisecheque = new RemiseCheque($db);
$result = $remisecheque->Fetch($_GET["id"]);
@@ -125,7 +124,7 @@ if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user-
}
}
-if ($_POST['action'] == 'builddoc' && $user->rights->banque)
+if ($_POST['action'] == 'builddoc' && $user->rights->banque->cheque)
{
$remisecheque = new RemiseCheque($db);
$result = $remisecheque->Fetch($_GET["id"]);
@@ -178,16 +177,12 @@ if ($_GET['action'] == 'new')
else
{
$remisecheque = new RemiseCheque($db);
- if ($_GET["id"])
+ $result = $remisecheque->fetch($_REQUEST["id"],$_REQUEST["ref"]);
+ if ($result < 0)
{
- $result = $remisecheque->Fetch($_GET["id"]);
+ dol_print_error($db,$remisecheque->error);
+ exit;
}
- if ($_GET["ref"])
- {
- $result = $remisecheque->Fetch('',$_GET["ref"]);
- }
-
-
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/fiche.php?id='.$remisecheque->id;
@@ -205,7 +200,7 @@ else
*/
if ($_GET['action'] == 'delete')
{
- $ret=$html->form_confirm('fiche.php?id='.$remisecheque->id, $langs->trans("DeleteCheckReceipt"), $langs->trans("ConfirmDeleteCheckReceipt"), 'confirm_delete');
+ $ret=$html->form_confirm('fiche.php?id='.$remisecheque->id, $langs->trans("DeleteCheckReceipt"), $langs->trans("ConfirmDeleteCheckReceipt"), 'confirm_delete','','',1);
if ($ret == 'html') print '
';
}
@@ -215,7 +210,7 @@ else
if ($_GET['action'] == 'valide')
{
$facid = $_GET['facid'];
- $ret=$html->form_confirm('fiche.php?id='.$remisecheque->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide');
+ $ret=$html->form_confirm('fiche.php?id='.$remisecheque->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide','','',1);
if ($ret == 'html') print '
';
}
}
@@ -344,6 +339,10 @@ else
print price($remisecheque->amount);
print '';
+ print '
| '.$langs->trans('Status').' | ';
+ print $remisecheque->getLibStatut(4);
+ print ' |
';
+
print '
';
@@ -369,15 +368,15 @@ else
$param="&id=".$remisecheque->id;
print '';
- '| '.$langs->trans("Num").' | ';
- print ''.$langs->trans("Cheque").' | ';
+ print_liste_field_titre($langs->trans("Cheque"),'','','','','width="30"');
print_liste_field_titre($langs->trans("Numero"),$_SERVER["PHP_SELF"],"b.num_chq", "",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CheckTransmitter"),$_SERVER["PHP_SELF"],"b.emetteur", "",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Bank"),$_SERVER["PHP_SELF"],"b.banque", "",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"b.amount", "",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("LineRecord"),$_SERVER["PHP_SELF"],"b.rowid", "",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateChequeReceived"),$_SERVER["PHP_SELF"],"b.datec", "",$param,'align="center"',$sortfield,$sortorder);
- print " |
\n";
+ print_liste_field_titre('','','');
+ print "\n";
$i=1;
$var=false;
while ( $objp = $db->fetch_object($resql) )
@@ -386,7 +385,7 @@ else
$accounts[$objp->bid] += 1;
print "";
- print '| '.$i.' | ';
+ print ''.$i.' | ';
print ''.($objp->num_chq?$objp->num_chq:' ').' | ';
print ''.dol_trunc($objp->emetteur,24).' | ';
print ''.dol_trunc($objp->banque,24).' | ';
@@ -433,19 +432,19 @@ print '';
print '';
-if ($user->societe_id == 0 && sizeof($accounts) == 1 && $_GET['action'] == 'new')
+if ($user->societe_id == 0 && sizeof($accounts) == 1 && $_GET['action'] == 'new' && $user->rights->banque->cheque)
{
print '
'.$langs->trans('NewCheckReceipt').'';
}
-if ($user->societe_id == 0 && $remisecheque->statut == 0 && $_GET['action'] == '')
+if ($user->societe_id == 0 && $remisecheque->statut == 0 && $remisecheque->id && $user->rights->banque->cheque)
{
- print '
'.$langs->trans('Valid').'';
+ print '
'.$langs->trans('Valid').'';
}
-if ($user->societe_id == 0 && $_GET['action'] == '')
+if ($user->societe_id == 0 && $remisecheque->id && $user->rights->banque->cheque)
{
- print '
'.$langs->trans('Delete').'';
+ print '
'.$langs->trans('Delete').'';
}
print '
';
@@ -456,9 +455,9 @@ if ($_GET['action'] != 'new')
{
if ($remisecheque->statut == 1)
{
- $dirchequereceipts = $dir.get_exdir($remisecheque->number,2,1).'/'.$remisecheque->ref;
+ $dirchequereceipts = $dir.get_exdir($remisecheque->number,2,1).$remisecheque->ref;
$gen = array('blochet'=>'blochet');
- $formfile->show_documents("remisecheque","",$dirchequereceipts,$_SERVER["PHP_SELF"].'?id='.$remisecheque->id,$gen,1);
+ $formfile->show_documents("remisecheque",$remisecheque->ref,$dirchequereceipts,$_SERVER["PHP_SELF"].'?id='.$remisecheque->id,$gen,1);
}
}
diff --git a/htdocs/compta/paiement/cheque/remisecheque.class.php b/htdocs/compta/paiement/cheque/remisecheque.class.php
index 5057362e66a..1d60770dbab 100644
--- a/htdocs/compta/paiement/cheque/remisecheque.class.php
+++ b/htdocs/compta/paiement/cheque/remisecheque.class.php
@@ -710,22 +710,22 @@ class RemiseCheque extends CommonObject
}
if ($mode == 2)
{
- if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
+ if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut0').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 3)
{
- if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
+ if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut0');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
}
if ($mode == 4)
{
- if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
+ if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut0').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 5)
{
- if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
+ if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut0');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}
return $langs->trans('Unknown');
diff --git a/htdocs/document.php b/htdocs/document.php
index 85a7de0a3ff..de4579c992b 100644
--- a/htdocs/document.php
+++ b/htdocs/document.php
@@ -363,12 +363,12 @@ if ($modulepart)
if ($modulepart == 'remisecheque')
{
$user->getrights('banque');
- if ($user->rights->banque || eregi('^specimen',$original_file))
+ if ($user->rights->banque->lire || eregi('^specimen',$original_file))
{
$accessallowed=1;
}
- $original_file=$conf->comptabilite->dir_output.'/bordereau/'.get_exdir(basename($original_file,".pdf")).$original_file;
+ $original_file=$conf->banque->dir_output.'/bordereau/'.get_exdir(basename($original_file,".pdf"),2,1).$original_file;
$sqlprotectagainstexternals = '';
}
diff --git a/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php
index 737b0fa6b97..1addf337f81 100644
--- a/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php
+++ b/htdocs/includes/modules/cheque/pdf/pdf_blochet.class.php
@@ -95,7 +95,7 @@ class BordereauChequeBlochet extends FPDF
$outputlangs->load("bills");
$outputlangs->load("products");
- $dir = $_dir . "/".get_exdir($number,2,1)."/".$number;
+ $dir = $_dir . "/".get_exdir($number,2,1).$number;
if (! is_dir($dir))
{
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index b5c3c599c31..4dcebf7fd2c 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -2376,10 +2376,11 @@ function yn($yesno, $case=1, $color=0)
/**
* \brief Return a path to class a directory according to an id
- * \remarks Examples: 1->"0/0/1/", 15->"0/1/5/"
* \param $num Id to develop
* \param $level Level of development (1, 2 or 3 level)
* \param $alpha Use alpha ref
+ * \remarks Examples: '001' with level 3->"0/0/1/", '015' with level 3->"0/1/5/"
+ * \remarks Examples: 'ABC-1' with level 3 ->"0/0/1/", '015' with level 1->"5/"
*/
function get_exdir($num,$level=3,$alpha=0)
{