Fix input lost when error

This commit is contained in:
Laurent Destailleur 2018-04-07 12:28:10 +02:00
parent ebb418fe3a
commit 15c7bbf9d8

View File

@ -49,8 +49,8 @@ if ($action == 'add')
$dateo = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int')); $dateo = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));
$label = GETPOST('label','alpha'); $label = GETPOST('label','alpha');
$amount= GETPOST('amount'); $amount= GETPOST('amount','alpha');
$amountto= GETPOST('amountto'); $amountto= GETPOST('amountto','alpha');
if (! $label) if (! $label)
{ {
@ -125,7 +125,7 @@ if ($action == 'add')
if (! $error) if (! $error)
{ {
$mesgs = $langs->trans("TransferFromToDone",'<a href="bankentries_list.php?id='.$accountfrom->id.'&sortfield=b.datev,b.dateo,b.rowid&sortorder=desc">'.$accountfrom->label."</a>",'<a href="bankentries_list.php?id='.$accountto->id.'">'.$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency)); $mesgs = $langs->trans("TransferFromToDone", '<a href="bankentries_list.php?id='.$accountfrom->id.'&sortfield=b.datev,b.dateo,b.rowid&sortorder=desc">'.$accountfrom->label."</a>", '<a href="bankentries_list.php?id='.$accountto->id.'">'.$accountto->label."</a>", $amount, $langs->transnoentities("Currency".$conf->currency));
setEventMessages($mesgs, null, 'mesgs'); setEventMessages($mesgs, null, 'mesgs');
$db->commit(); $db->commit();
} }
@ -153,6 +153,12 @@ llxHeader();
print ' <script type="text/javascript"> print ' <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
$(".selectbankaccount").change(function() { $(".selectbankaccount").change(function() {
console.log("We change bank account");
init_page();
});
function init_page() {
console.log("Set fields according to currency");
var account1 = $("#selectaccount_from").val(); var account1 = $("#selectaccount_from").val();
var account2 = $("#selectaccount_to").val(); var account2 = $("#selectaccount_to").val();
var currencycode1=""; var currencycode1="";
@ -199,7 +205,9 @@ print ' <script type="text/javascript">
}).fail(function( data ) { }).fail(function( data ) {
console.error("Error: has returned an empty page. Should be an empty json array."); console.error("Error: has returned an empty page. Should be an empty json array.");
}); });
}); }
init_page();
}); });
</script>'; </script>';
@ -210,12 +218,12 @@ $account_to='';
$label=''; $label='';
$amount=''; $amount='';
if($error) if ($error)
{ {
$account_from = GETPOST('account_from','int'); $account_from = GETPOST('account_from','int');
$account_to = GETPOST('account_to','int'); $account_to = GETPOST('account_to','int');
$label = GETPOST('label','alpha'); $label = GETPOST('label','alpha');
$amount = GETPOST('amount','int'); $amount = GETPOST('amount','alpha');
} }
print load_fiche_titre($langs->trans("MenuBankInternalTransfer"), '', 'title_bank.png'); print load_fiche_titre($langs->trans("MenuBankInternalTransfer"), '', 'title_bank.png');
@ -246,9 +254,9 @@ print "</td>\n";
print "<td>"; print "<td>";
$form->select_date((! empty($dateo)?$dateo:''),'','','','','add'); $form->select_date((! empty($dateo)?$dateo:''),'','','','','add');
print "</td>\n"; print "</td>\n";
print '<td><input name="label" class="flat quatrevingtpercent" type="text" value="'.$label.'"></td>'; print '<td><input name="label" class="flat quatrevingtpercent" type="text" value="'.dol_escape_htmltag($label).'"></td>';
print '<td><input name="amount" class="flat" type="text" size="6" value="'.$amount.'"></td>'; print '<td><input name="amount" class="flat" type="text" size="6" value="'.dol_escape_htmltag($amount).'"></td>';
print '<td style="display:none" class="multicurrency"><input name="amountto" class="flat" type="text" size="6" value="'.$amountto.'"></td>'; print '<td style="display:none" class="multicurrency"><input name="amountto" class="flat" type="text" size="6" value="'.dol_escape_htmltag($amountto).'"></td>';
print "</table>"; print "</table>";