X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fgl_journal.php;h=5a77bb84e7a433e5defe8e1cf8a125deeb388c92;hb=e91772a2716825a6aeb358d1defba47d5f3892c1;hp=1e820f5f393c336f1baf4455587cc3fb77f85b47;hpb=4805d26604f8fac454e33eebf13686b57908f557;p=fa-stable.git diff --git a/gl/gl_journal.php b/gl/gl_journal.php index 1e820f5f..5a77bb84 100644 --- a/gl/gl_journal.php +++ b/gl/gl_journal.php @@ -1,5 +1,14 @@ . +***********************************************************************/ $page_security = 3; $path_to_root=".."; include_once($path_to_root . "/includes/ui/items_cart.inc"); @@ -21,6 +30,13 @@ if ($use_date_picker) page(_("Journal Entry"), false, false,'', $js); +//-------------------------------------------------------------------------------------------------- +function line_start_focus() { + global $Ajax; + + $Ajax->activate('items_table'); + set_focus('_code_id_edit'); +} //----------------------------------------------------------------------------------------------- if (isset($_GET['AddedID'])) @@ -30,33 +46,14 @@ if (isset($_GET['AddedID'])) display_notification_centered( _("Journal entry has been entered") . " #$trans_no"); - display_note(get_gl_view_str($trans_type, $trans_no, _("View this Journal Entry"))); + display_note(get_gl_view_str($trans_type, $trans_no, _("&View this Journal Entry"))); - hyperlink_no_params($_SERVER['PHP_SELF'], _("Enter Another Journal Entry")); + hyperlink_no_params($_SERVER['PHP_SELF'], _("Enter &Another Journal Entry")); display_footer_exit(); } - -//-------------------------------------------------------------------------------------------------- - -function copy_to_je() -{ - $_SESSION['journal_items']->tran_date = $_POST['date_']; - $_SESSION['journal_items']->transfer_type = check_value('Reverse'); - $_SESSION['journal_items']->memo_ = $_POST['memo_']; -} - //-------------------------------------------------------------------------------------------------- -function copy_from_je() -{ - $_POST['date_'] = $_SESSION['journal_items']->tran_date; - $_POST['Reverse'] = $_SESSION['journal_items']->transfer_type; - $_POST['memo_'] = $_SESSION['journal_items']->memo_; -} - -//---------------------------------------------------------------------------------------- - function handle_new_order() { if (isset($_SESSION['journal_items'])) @@ -67,9 +64,9 @@ function handle_new_order() session_register("journal_items"); - $_SESSION['journal_items'] = new items_cart; + $_SESSION['journal_items'] = new items_cart(systypes::journal_entry()); - $_POST['date_'] = Today(); + $_POST['date_'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['date_'])) $_POST['date_'] = end_fiscalyear(); $_SESSION['journal_items']->tran_date = $_POST['date_']; @@ -82,6 +79,19 @@ if (isset($_POST['Process'])) $input_error = 0; + if ($_SESSION['journal_items']->count_gl_items() < 1) { + display_error(_("You must enter at least one journal line.")); + set_focus('code_id'); + $input_error = 1; + } + if (abs($_SESSION['journal_items']->gl_items_total()) > 0.0001) + { + display_error(_("The journal must balance (debits equal to credits) before it can be processed.")); + set_focus('code_id'); + $input_error = 1; + } + + if (!is_date($_POST['date_'])) { display_error(_("The entered date is invalid.")); @@ -94,7 +104,7 @@ if (isset($_POST['Process'])) set_focus('date_'); $input_error = 1; } - elseif (!references::is_valid($_POST['ref'])) + if (!references::is_valid($_POST['ref'])) { display_error( _("You must enter a reference.")); set_focus('ref'); @@ -118,6 +128,7 @@ if (isset($_POST['Process'])) $_POST['date_'], $_POST['ref'], check_value('Reverse'), $_POST['memo_']); $_SESSION['journal_items']->clear_items(); + new_doc_date($_POST['date_']); unset($_SESSION['journal_items']); meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no"); @@ -185,13 +196,15 @@ function handle_update_item() $_SESSION['journal_items']->update_gl_item($_POST['Index'], $_POST['dimension_id'], $_POST['dimension2_id'], $amount, $_POST['LineMemo']); } + line_start_focus(); } //----------------------------------------------------------------------------------------------- -function handle_delete_item() +function handle_delete_item($id) { - $_SESSION['journal_items']->remove_gl_item($_GET['Delete']); + $_SESSION['journal_items']->remove_gl_item($id); + line_start_focus(); } //----------------------------------------------------------------------------------------------- @@ -208,34 +221,29 @@ function handle_new_item() $_SESSION['journal_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], $_POST['dimension2_id'], $amount, $_POST['LineMemo']); + line_start_focus(); } //----------------------------------------------------------------------------------------------- -if (isset($_GET['Edit'])) { - copy_from_je(); - set_focus('dimension_id'); -} -if (isset($_GET['Delete'])) { - copy_from_je(); - handle_delete_item(); - set_focus('_code_id_edit'); -} -if (isset($_POST['AddItem'])) { - copy_to_je(); +$id = find_submit('Delete'); +if ($id != -1) + handle_delete_item($id); + +if (isset($_POST['AddItem'])) handle_new_item(); - set_focus('_code_id_edit'); -} -if (isset($_POST['UpdateItem'])) { - copy_to_je(); + +if (isset($_POST['UpdateItem'])) handle_update_item(); - set_focus('_code_id_edit'); -} + if (isset($_POST['CancelItemChanges'])) - set_focus('_code_id_edit'); - -if (isset($_POST['EditItem'])) - set_focus('dimension_id'); + line_start_focus(); +if (isset($_POST['go'])) +{ + display_quick_entries($_SESSION['journal_items'], $_POST['person_id'], input_num('totamount'), QE_JOURNAL); + $_POST['totamount'] = price_format(0); $Ajax->activate('totamount'); + line_start_focus(); +} //----------------------------------------------------------------------------------------------- if (isset($_GET['NewJournal']) || !isset($_SESSION['journal_items'])) @@ -258,18 +266,10 @@ echo ""; end_row(); end_table(1); -if ($_SESSION['journal_items']->count_gl_items() >= 1 && - abs($_SESSION['journal_items']->gl_items_total()) < 0.0001) -{ - submit_center('Process', _("Process Journal Entry")); -} -else -{ - display_note(_("The journal must balance (debits equal to credits) before it can be processed."), 0, 1); -} +submit_center('Process', _("Process Journal Entry"), true , + _('Process journal entry only if debits equal to credits'), 'default'); end_form(); - //------------------------------------------------------------------------------------------------ end_page();