X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fgl_budget.php;h=b503a61c5f3db15fccafdad1cfa6c7ad81796b9c;hb=51d383df668c17328e3f0562ba294a103362bf80;hp=988e6026cb36c5c0f3ba86ba7ed8cd72a3304e2f;hpb=37f4a02e0f4bea58e5b2097d583bf9395ffc515f;p=fa-stable.git diff --git a/gl/gl_budget.php b/gl/gl_budget.php index 988e6026..b503a61c 100644 --- a/gl/gl_budget.php +++ b/gl/gl_budget.php @@ -4,6 +4,8 @@ $page_security = 10; $path_to_root=".."; include($path_to_root . "/includes/session.inc"); +add_js_file('budget.js'); + page(_("Budget Entry")); include($path_to_root . "/includes/ui.inc"); @@ -71,7 +73,7 @@ if (isset($_POST['add']) || isset($_POST['delete'])) for ($i = 0, $da = $_POST['begin']; date1_greater_date2($_POST['end'], $da); $i++) { if (isset($_POST['add'])) - add_update_gl_budget_trans($da, $_POST['account'], $_POST['dim1'], $_POST['dim2'], $_POST['amount'.$i]); + add_update_gl_budget_trans($da, $_POST['account'], $_POST['dim1'], $_POST['dim2'], input_num('amount'.$i)); else delete_gl_budget_trans($da, $_POST['account'], $_POST['dim1'], $_POST['dim2']); $da = add_months($da, 1); @@ -84,7 +86,10 @@ if (isset($_POST['add']) || isset($_POST['delete'])) display_notification_centered(_("The Budget has been deleted.")); //meta_forward($_SERVER['PHP_SELF']); + $Ajax->activate('budget_tbl'); } +if (isset($_POST['submit']) || isset($_POST['update'])) + $Ajax->activate('budget_tbl'); //------------------------------------------------------------------------------------- @@ -115,8 +120,9 @@ if (db_has_gl_accounts()) hidden('dim1', 0); hidden('dim2', 0); } - submit_row('submit', _("Get")); + submit_row('submit', _("Get"), true, '', '', true); end_table(1); + div_start('budget_tbl'); start_table($table_style2); $showdims = (($dim == 1 && $_POST['dim1'] == 0) || ($dim == 2 && $_POST['dim1'] == 0 && $_POST['dim2'] == 0)); @@ -126,25 +132,27 @@ if (db_has_gl_accounts()) $th = array(_("Period"), _("Amount"), _("Last Year")); table_header($th); $year = $_POST['fyear']; - $sql = "SELECT * FROM ".TB_PREF."fiscal_year WHERE id=$year"; + if (get_post('update') == '') { + $sql = "SELECT * FROM ".TB_PREF."fiscal_year WHERE id=$year"; - $result = db_query($sql, "could not get current fiscal year"); + $result = db_query($sql, "could not get current fiscal year"); - $fyear = db_fetch($result); - $begin = sql2date($fyear['begin']); - $end = sql2date($fyear['end']); - hidden('begin', $begin); - hidden('end', $end); + $fyear = db_fetch($result); + $_POST['begin'] = sql2date($fyear['begin']); + $_POST['end'] = sql2date($fyear['end']); + } + hidden('begin'); + hidden('end'); $total = $btotal = $ltotal = 0; - for ($i = 0, $date_ = $begin; date1_greater_date2($end, $date_); $i++) + for ($i = 0, $date_ = $_POST['begin']; date1_greater_date2($_POST['end'], $date_); $i++) { start_row(); - $_POST['amount'.$i] = get_only_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']); + if (get_post('update') == '') + $_POST['amount'.$i] = number_format2(get_only_budget_trans_from_to( + $date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']), 0); label_cell($date_); - if (!isset($_POST['amount'.$i])) - $_POST['amount'.$i] = "0"; - text_cells(null, 'amount'.$i, null, 15); + amount_cells(null, 'amount'.$i, null, 15, null, 0); if ($showdims) { $d = get_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']); @@ -152,7 +160,7 @@ if (db_has_gl_accounts()) $btotal += $d; } $lamount = get_gl_trans_from_to(add_years($date_, -1), add_years(end_month($date_), -1), $_POST['account'], $_POST['dim1'], $_POST['dim2']); - $total += $_POST['amount'.$i]; + $total += input_num('amount'.$i); $ltotal += $lamount; label_cell(number_format2($lamount, 0), "nowrap align=right"); $date_ = add_months($date_, 1); @@ -160,14 +168,16 @@ if (db_has_gl_accounts()) } start_row(); label_cell(""._("Total").""); - label_cell("".number_format2($total, 0).""); + label_cell(number_format2($total, 0), 'align=right style="font-weight:bold"', 'Total'); if ($showdims) label_cell("".number_format2($btotal, 0)."", "nowrap align=right"); label_cell("".number_format2($ltotal, 0)."", "nowrap align=right"); end_row(); end_table(1); - submit_center_first('add', _("Save")); - submit_center_last('delete', _("Delete")); + div_end(); + submit_center_first('update', _("Update"), '', null); + submit('add', _("Save"), true, '', true); + submit_center_last('delete', _("Delete"), '', true); } end_form();