2
0
forked from Wavyzz/dolibarr

Fix: Select cheque for cheque receipt works when there is more than on bank accounts.

This commit is contained in:
Laurent Destailleur
2011-05-05 21:22:40 +00:00
parent 559a798407
commit d8b2d03e1b
4 changed files with 80 additions and 66 deletions

View File

@@ -39,6 +39,7 @@ $langs->load('compta');
$id =GETPOST("id"); $id =GETPOST("id");
$ref=GETPOST("ref"); $ref=GETPOST("ref");
$action=GETPOST('action');
// Security check // Security check
$fieldid = isset($_GET["ref"])?'number':'rowid'; $fieldid = isset($_GET["ref"])?'number':'rowid';
@@ -63,7 +64,7 @@ $dir=$conf->banque->dir_output.'/bordereau/';
* Actions * Actions
*/ */
if ($_POST['action'] == 'setdate' && $user->rights->banque->cheque) if ($action == 'setdate' && $user->rights->banque->cheque)
{ {
$remisecheque = new RemiseCheque($db); $remisecheque = new RemiseCheque($db);
$result = $remisecheque->fetch(GETPOST('id')); $result = $remisecheque->fetch(GETPOST('id'));
@@ -84,7 +85,7 @@ 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'])) if (is_array($_POST['toRemise']))
{ {
@@ -118,12 +119,12 @@ if ($_POST['action'] == 'create' && $_POST["accountid"] > 0 && $user->rights->ba
} }
else else
{ {
Header("Location: ".$_SERVER["PHP_SELF"]."?action=new"); $mesg=$langs->trans("ErrorSelectAtLeastOne");
exit; $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 = new RemiseCheque($db);
$remisecheque->id = $_GET["id"]; $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 = new RemiseCheque($db);
$remisecheque->id = $_GET["id"]; $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); $remisecheque = new RemiseCheque($db);
$result = $remisecheque->fetch($_GET["id"]); $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); $remisecheque = new RemiseCheque($db);
$result = $remisecheque->fetch($_GET["id"]); $result = $remisecheque->fetch($_GET["id"]);
@@ -226,23 +227,7 @@ $html = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
?> if ($action == 'new')
<script language="javascript" type="text/javascript">
jQuery(document).ready(function()
{
jQuery("#checkall").click(function()
{
jQuery(".checkforremise").attr('checked', true);
});
jQuery("#checknone").click(function()
{
jQuery(".checkforremise").attr('checked', false);
});
});
</script>
<?php
if ($_GET['action'] == 'new')
{ {
$h=0; $h=0;
$head[$h][0] = $_SERVER["PHP_SELF"].'?action=new'; $head[$h][0] = $_SERVER["PHP_SELF"].'?action=new';
@@ -276,7 +261,7 @@ else
/* /*
* Confirmation de la suppression du bordereau * Confirmation de la suppression du bordereau
*/ */
if ($_GET['action'] == 'delete') if ($action == 'delete')
{ {
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$remisecheque->id, $langs->trans("DeleteCheckReceipt"), $langs->trans("ConfirmDeleteCheckReceipt"), 'confirm_delete','','',1); $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$remisecheque->id, $langs->trans("DeleteCheckReceipt"), $langs->trans("ConfirmDeleteCheckReceipt"), 'confirm_delete','','',1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
@@ -285,7 +270,7 @@ else
/* /*
* Confirmation de la validation du bordereau * Confirmation de la validation du bordereau
*/ */
if ($_GET['action'] == 'valide') if ($action == 'valide')
{ {
$facid = $_GET['facid']; $facid = $_GET['facid'];
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$remisecheque->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide','','',1); $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.'<br>'; //if ($mesg) print $mesg.'<br>';
dol_htmloutput_errors($mesg);
if ($_GET['action'] == 'new') if ($action == 'new')
{ {
$accounts = array(); $accounts = array();
$lines = array(); $lines = array();
@@ -342,6 +328,23 @@ if ($_GET['action'] == 'new')
foreach ($accounts as $bid => $account_label) foreach ($accounts as $bid => $account_label)
{ {
print '
<script language="javascript" type="text/javascript">
jQuery(document).ready(function()
{
jQuery("#checkall_'.$bid.'").click(function()
{
jQuery(".checkforremise_'.$bid.'").attr(\'checked\', true);
});
jQuery("#checknone_'.$bid.'").click(function()
{
jQuery(".checkforremise_'.$bid.'").attr(\'checked\', false);
});
});
</script>
';
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
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'].'">';
@@ -356,7 +359,7 @@ if ($_GET['action'] == 'new')
print '<td style="min-width: 200px">'.$langs->trans("Bank")."</td>\n"; print '<td style="min-width: 200px">'.$langs->trans("Bank")."</td>\n";
print '<td align="right" width="100px">'.$langs->trans("Amount")."</td>\n"; print '<td align="right" width="100px">'.$langs->trans("Amount")."</td>\n";
print '<td align="center" width="100px">'.$langs->trans("Select")."<br>"; print '<td align="center" width="100px">'.$langs->trans("Select")."<br>";
if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a>'; if ($conf->use_javascript_ajax) print '<a href="#" id="checkall_'.$bid.'">'.$langs->trans("All").'</a> / <a href="#" id="checknone_'.$bid.'">'.$langs->trans("None").'</a>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@@ -377,7 +380,7 @@ if ($_GET['action'] == 'new')
print '<td>'.$value["banque"]."</td>\n"; print '<td>'.$value["banque"]."</td>\n";
print '<td align="right">'.price($value["amount"]).'</td>'; print '<td align="right">'.price($value["amount"]).'</td>';
print '<td align="center">'; print '<td align="center">';
print '<input id="'.$value["id"].'" class="flat checkforremise" checked="true" type="checkbox" name="toRemise[]" value="'.$value["id"].'">'; print '<input id="'.$value["id"].'" class="flat checkforremise_'.$bid.'" checked="true" type="checkbox" name="toRemise[]" value="'.$value["id"].'">';
print '</td>' ; print '</td>' ;
print '</tr>'; print '</tr>';
@@ -423,10 +426,10 @@ else
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Date'); print $langs->trans('Date');
print '</td>'; print '</td>';
if ($_GET['action'] != 'editdate') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>'; if ($action != 'editdate') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="2">'; print '</td><td colspan="2">';
if ($_GET['action'] == 'editdate') if ($action == 'editdate')
{ {
print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -551,7 +554,7 @@ else
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($user->societe_id == 0 && sizeof($accounts) == 1 && $_GET['action'] == 'new' && $user->rights->banque->cheque) if ($user->societe_id == 0 && sizeof($accounts) == 1 && $action == 'new' && $user->rights->banque->cheque)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create&amp;accountid='.$account_id.'">'.$langs->trans('NewCheckReceipt').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create&amp;accountid='.$account_id.'">'.$langs->trans('NewCheckReceipt').'</a>';
} }
@@ -570,7 +573,7 @@ print '</div>';
if ($_GET['action'] != 'new') if ($action != 'new')
{ {
if ($remisecheque->statut == 1) if ($remisecheque->statut == 1)
{ {

View File

@@ -77,4 +77,5 @@ ErrorQtyTooLowForThisSupplier=Quantity too low for this supplier or no price def
ErrorModuleSetupNotComplete=Setup of module looks to be uncomplete. Go on Setup - Modules to complete. ErrorModuleSetupNotComplete=Setup of module looks to be uncomplete. Go on Setup - Modules to complete.
ErrorBadMask=Error on mask ErrorBadMask=Error on mask
ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number
ErrorBadMaskBadRazMonth=Erreur, bad reset value ErrorBadMaskBadRazMonth=Error, bad reset value
ErrorSelectAtLeastOne=Error. Select at least one entry.

View File

@@ -79,3 +79,4 @@ ErrorModuleSetupNotComplete=La configuration du module semble incomplète. Aller
ErrorBadMask=Erreur sur le masque ErrorBadMask=Erreur sur le masque
ErrorBadMaskFailedToLocatePosOfSequence=Erreur, masque sans numéro de séquence ErrorBadMaskFailedToLocatePosOfSequence=Erreur, masque sans numéro de séquence
ErrorBadMaskBadRazMonth=Erreur, mauvais valeur de remise à zéro ErrorBadMaskBadRazMonth=Erreur, mauvais valeur de remise à zéro
ErrorSelectAtLeastOne=Erreur. Sélectionnez au moins une entrée.

View File

@@ -3444,27 +3444,36 @@ function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
$ret=''; $ret='';
$out=''; $out='';
$divstart=$divend='';
if (is_array($mesgarray) && sizeof($mesgarray)) if (empty($conf->global->MAIN_USE_JQUERY_JNOTIFY) && ! preg_match('/<div class=".*">/i',$out))
{
$divstart='<div class="'.$style.'">';
$divend='</div>';
}
if ((is_array($mesgarray) && sizeof($mesgarray)) || $mesgstring)
{ {
$langs->load("errors"); $langs->load("errors");
if (empty($conf->global->MAIN_USE_JQUERY_JNOTIFY)) $out.= '<div class="'.$style.'">'; $out.=$divstart;
if (is_array($mesgarray) && sizeof($mesgarray))
{
foreach($mesgarray as $message) foreach($mesgarray as $message)
{ {
$ret++; $ret++;
$out.= $langs->trans($message); $out.= $langs->trans($message);
if ($ret < sizeof($mesgarray)) $out.= "<br>\n"; if ($ret < sizeof($mesgarray)) $out.= "<br>\n";
} }
if (empty($conf->global->MAIN_USE_JQUERY_JNOTIFY)) $out.= '</div>';
} }
if ($mesgstring) if ($mesgstring)
{ {
$langs->load("errors"); $langs->load("errors");
$ret++; $ret++;
if (empty($conf->global->MAIN_USE_JQUERY_JNOTIFY)) $out.= '<div class="'.$style.'">';
$out.= $langs->trans($mesgstring); $out.= $langs->trans($mesgstring);
if (empty($conf->global->MAIN_USE_JQUERY_JNOTIFY)) $out.= '</div>';
} }
$out.=$divend;
}
if ($out) if ($out)
{ {
if (! empty($conf->global->MAIN_USE_JQUERY_JNOTIFY) && ! $keepembedded) if (! empty($conf->global->MAIN_USE_JQUERY_JNOTIFY) && ! $keepembedded)