X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fgl_journal.php;h=107c6d6328a21813fcb7186d0b4233139918a450;hb=f1fe277df787cdefb65142d66ce247b8757ba057;hp=3ce28e3aa4c91c8512fe0567ac202a2b42a7a4a7;hpb=2383d33373d6ddec06906658a0ed6398077c1147;p=fa-stable.git diff --git a/gl/gl_journal.php b/gl/gl_journal.php index 3ce28e3a..107c6d63 100644 --- a/gl/gl_journal.php +++ b/gl/gl_journal.php @@ -9,8 +9,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ -$page_security = 3; -$path_to_root=".."; +$page_security = 'SA_JOURNALENTRY'; +$path_to_root = ".."; include_once($path_to_root . "/includes/ui/items_cart.inc"); include_once($path_to_root . "/includes/session.inc"); @@ -31,9 +31,9 @@ if ($use_date_picker) if (isset($_GET['ModifyGL'])) { $_SESSION['page_title'] = sprintf(_("Modifying Journal Transaction # %d."), $_GET['trans_no']); - $help_page_title =_("Modifying Journal Transaction"); + $help_context = "Modifying Journal Entry"; } else - $_SESSION['page_title'] = _("Journal Entry"); + $_SESSION['page_title'] = _($help_context = "Journal Entry"); page($_SESSION['page_title'], false, false,'', $js); //-------------------------------------------------------------------------------------------------- @@ -41,6 +41,7 @@ page($_SESSION['page_title'], false, false,'', $js); function line_start_focus() { global $Ajax; + unset($_POST['Index']); $Ajax->activate('items_table'); set_focus('_code_id_edit'); } @@ -49,20 +50,22 @@ function line_start_focus() { if (isset($_GET['AddedID'])) { $trans_no = $_GET['AddedID']; - $trans_type = systypes::journal_entry(); + $trans_type = ST_JOURNAL; display_notification_centered( _("Journal entry has been entered") . " #$trans_no"); display_note(get_gl_view_str($trans_type, $trans_no, _("&View this Journal Entry"))); reset_focus(); - hyperlink_params($_SERVER['PHP_SELF'], _("Entry &New Journal Entry"), "NewJournal=Yes"); + hyperlink_params($_SERVER['PHP_SELF'], _("Enter &New Journal Entry"), "NewJournal=Yes"); + + hyperlink_params("$path_to_root/admin/attachments.php", _("Add an Attachment"), "filterType=$trans_type&trans_no=$trans_no"); display_footer_exit(); } elseif (isset($_GET['UpdatedID'])) { $trans_no = $_GET['UpdatedID']; - $trans_type = systypes::journal_entry(); + $trans_type = ST_JOURNAL; display_notification_centered( _("Journal entry has been updated") . " #$trans_no"); @@ -90,11 +93,14 @@ elseif (isset($_GET['ModifyGL'])) function create_cart($type=0, $trans_no=0) { + global $Refs; + if (isset($_SESSION['journal_items'])) { unset ($_SESSION['journal_items']); } + check_is_closed($type, $trans_no); $cart = new items_cart($type); $cart->order_id = $trans_no; @@ -106,21 +112,23 @@ function create_cart($type=0, $trans_no=0) if ($row['amount'] == 0) continue; $date = $row['tran_date']; $cart->add_gl_item($row['account'], $row['dimension_id'], - $row['dimension2_id'], $row['amount'], $row['memo_']); + $row['dimension2_id'], $row['amount'], $row['memo_'], '', $row['person_id']); } } $cart->memo_ = get_comments_string($type, $trans_no); $cart->tran_date = sql2date($date); - $cart->reference = references::get($type, $trans_no); + $cart->reference = $Refs->get($type, $trans_no); + $_POST['ref_original'] = $cart->reference; // Store for comparison when updating } else { - $cart->reference = references::get_next(0); + $cart->reference = $Refs->get_next(0); $cart->tran_date = new_doc_date(); + if (!is_date_in_fiscalyear($cart->tran_date)) + $cart->tran_date = end_fiscalyear(); + $_POST['ref_original'] = -1; } - if (!is_date_in_fiscalyear($cart->tran_date)) - $cart->tran_date = end_fiscalyear(); $_POST['memo_'] = $cart->memo_; - $_POST['ref'] = $cart->reference; + $_POST['ref'] = $cart->reference; $_POST['date_'] = $cart->tran_date; $_SESSION['journal_items'] = &$cart; @@ -153,23 +161,24 @@ if (isset($_POST['Process'])) } elseif (!is_date_in_fiscalyear($_POST['date_'])) { - display_error(_("The entered date is not in fiscal year.")); + display_error(_("The entered date is out of fiscal year or is closed for further data entry.")); set_focus('date_'); $input_error = 1; } - if ($_SESSION['journal_items']->order_id == 0) { - if (!references::is_valid($_POST['ref'])) - { - display_error( _("You must enter a reference.")); - set_focus('ref'); - $input_error = 1; - } - elseif (references::exists(systypes::journal_entry(), $_POST['ref'])) - { - display_error( _("The entered reference is already in use.")); - set_focus('ref'); - $input_error = 1; - } + if (!$Refs->is_valid($_POST['ref'])) + { + display_error( _("You must enter a reference.")); + set_focus('ref'); + $input_error = 1; + } + elseif ($Refs->exists(ST_JOURNAL, $_POST['ref'])) + { + // The reference can exist already so long as it's the same as the original (when modifying) + if ($_POST['ref'] != $_POST['ref_original']) { + display_error( _("The entered reference is already in use.")); + set_focus('ref'); + $input_error = 1; + } } if ($input_error == 1) unset($_POST['Process']); @@ -180,8 +189,7 @@ if (isset($_POST['Process'])) $cart = &$_SESSION['journal_items']; $new = $cart->order_id == 0; - if ($new) - $cart->reference = $_POST['ref']; + $cart->reference = $_POST['ref']; $cart->memo_ = $_POST['memo_']; $cart->tran_date = $_POST['date_']; @@ -239,7 +247,7 @@ function check_item_data() return false; } - if ($_SESSION["wa_current_user"]->access != 2 && is_bank_account($_POST['code_id'])) + if (!$_SESSION["wa_current_user"]->can_access('SA_BANKJOURNAL') && is_bank_account($_POST['code_id'])) { display_error(_("You cannot make a journal entry for a bank account. Please use one of the banking functions for bank transactions.")); set_focus('code_id'); @@ -260,8 +268,8 @@ function handle_update_item() else $amount = -input_num('AmountCredit'); - $_SESSION['journal_items']->update_gl_item($_POST['Index'], $_POST['dimension_id'], - $_POST['dimension2_id'], $amount, $_POST['LineMemo']); + $_SESSION['journal_items']->update_gl_item($_POST['Index'], $_POST['code_id'], + $_POST['dimension_id'], $_POST['dimension2_id'], $amount, $_POST['LineMemo'], '', get_post('person_id')); } line_start_focus(); } @@ -287,7 +295,7 @@ function handle_new_item() $amount = -input_num('AmountCredit'); $_SESSION['journal_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], - $_POST['dimension2_id'], $amount, $_POST['LineMemo']); + $_POST['dimension2_id'], $amount, $_POST['LineMemo'], '', get_post('person_id')); line_start_focus(); } @@ -317,7 +325,7 @@ start_form(); display_order_header($_SESSION['journal_items']); -start_table("$table_style2 width=90%", 10); +start_table(TABLESTYLE2, "width=90%", 10); start_row(); echo ""; display_gl_items(_("Rows"), $_SESSION['journal_items']);