Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 26, 2020
1 parent b52cfe5 commit 9f097b1
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions htdocs/accountancy/admin/account.php
Expand Up @@ -46,6 +46,8 @@
$search_pcgtype = GETPOST('search_pcgtype', 'alpha');
$search_pcgsubtype = GETPOST('search_pcgsubtype', 'alpha');

$chartofaccounts = GETPOST('chartofaccounts', 'int');

// Security check
if ($user->socid > 0) accessforbidden();
if (! $user->rights->accounting->chartofaccount) accessforbidden();
Expand Down Expand Up @@ -101,11 +103,9 @@
$search_pcgsubtype = "";
$search_array_options = array();
}

if (GETPOST('change_chart', 'alpha') && (GETPOST('valid_change_chart', 'int') || empty($conf->use_javascript_ajax)))
if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on
|| (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified
{
$chartofaccounts = GETPOST('chartofaccounts', 'int');

if ($chartofaccounts > 0)
{
// Get language code for this $chartofaccounts
Expand Down Expand Up @@ -274,21 +274,13 @@

if (!empty($conf->use_javascript_ajax))
{
print '<!-- Add javascript to update a flag when we select "Change plan" -->
print '<!-- Add javascript to reload page when we click "Change plan" -->
<script type="text/javascript">
$(document).ready(function () {
$("#searchFormList").on("submit", function (e) {
//event.preventDefault();
//var form = this;
console.log("chartofaccounts focus = "+$("#chartofaccounts").is(":focus"));
console.log("change_chart focus = "+$("#change_chart").is(":focus"));
if ($("#change_chart").is(":focus"))
{
console.log("We set valid_change_chart to 1");
$("#valid_change_chart").val(1);
}
//form.submit();
return true;
$("#change_chart").on("click", function (e) {
console.log("chartofaccounts seleted = "+$("#chartofaccounts").val());
// reload page
window.location.href = "'.$_SERVER["PHP_SELF"].'?valid_change_chart=1&chartofaccounts="+$("#chartofaccounts").val();
});
});
</script>';
Expand Down Expand Up @@ -335,8 +327,7 @@
else dol_print_error($db);
print "</select>";
print ajax_combobox("chartofaccounts");
print '<input type="submit" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
print '<input type="hidden" name="valid_change_chart" id="valid_change_chart" value="0">';
print '<input type="'.(empty($conf->use_javascript_ajax)?'submit':'button').'" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';

print '<br>';
print '<br>';
Expand Down

0 comments on commit 9f097b1

Please sign in to comment.