6 include_once($path_to_root . "/purchasing/includes/supp_trans_class.inc");
7 include_once($path_to_root . "/includes/session.inc");
9 include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc");
12 $js .= get_js_date_picker();
13 page(_("Add GL Items"), false, false, "", $js);
16 if (!isset($_SESSION['supp_trans']))
18 display_note(_("To enter a supplier invoice or credit note the supplier must first be selected."));
20 /*It all stops here if there aint no supplier selected and transaction initiated ie $_SESSION['supp_trans'] started off*/
23 //------------------------------------------------------------------------------------------------
24 function clear_fields()
28 unset($_POST['gl_code']);
29 unset($_POST['dimension_id']);
30 unset($_POST['dimension2_id']);
31 unset($_POST['amount']);
32 unset($_POST['memo_']);
33 unset($_POST['AddGLCodeToTrans']);
34 $Ajax->activate('gl_ctrls');
37 //------------------------------------------------------------------------------------------------
38 // GL postings are often entered in the same form to two accounts
39 // so fileds are cleared only on user demand.
41 if (isset($_POST['ClearFields']))
46 if (isset($_POST['AddGLCodeToTrans'])){
48 $Ajax->activate('gl_items');
51 $sql = "SELECT account_code, account_name FROM ".TB_PREF."chart_master WHERE account_code='" . $_POST['gl_code'] . "'";
52 $result = db_query($sql,"get account information");
53 if (db_num_rows($result) == 0)
55 display_error(_("The account code entered is not a valid code, this line cannot be added to the transaction."));
61 $myrow = db_fetch_row($result);
62 $gl_act_name = $myrow[1];
63 if (!check_num('amount'))
65 display_error(_("The amount entered is not numeric. This line cannot be added to the transaction."));
71 if ($input_error == false)
73 $_SESSION['supp_trans']->add_gl_codes_to_trans($_POST['gl_code'], $gl_act_name,
74 $_POST['dimension_id'], $_POST['dimension2_id'],
75 input_num('amount'), $_POST['memo_']);
80 //------------------------------------------------------------------------------------------------
82 $id = find_submit('Delete');
85 $_SESSION['supp_trans']->remove_gl_codes_from_trans($id);
87 $Ajax->activate('gl_items');
90 //------------------------------------------------------------------------------------------------
92 display_heading($_SESSION['supp_trans']->supplier_name);
94 display_gl_items($_SESSION['supp_trans'], 1);
98 if ($_SESSION['supp_trans']->is_invoice == true)
100 hyperlink_no_params("$path_to_root/purchasing/supplier_invoice.php", _("Back to Invoice Entry"));
104 hyperlink_no_params("$path_to_root/purchasing/supplier_credit.php", _("Back to Credit Note Entry"));
109 //------------------------------------------------------------------------------------------------
111 /*Set up a form to allow input of new GL entries */
112 start_form(false, true);
114 display_heading2(_("Enter a GL Line"));
116 div_start('gl_ctrls');
117 start_table($table_style2);
119 $accs = get_supplier_accounts($_SESSION['supp_trans']->supplier_id);
120 $_POST['gl_code'] = $accs['purchase_account'];
121 gl_all_accounts_list_row(_("GL Account Selection:"), 'gl_code', null);
122 $dim = get_company_pref('use_dimension');
124 dimensions_list_row(_("Dimension")." 1", 'dimension_id', null, true, " ", false, 1);
126 dimensions_list_row(_("Dimension")." 2", 'dimension2_id', null, true, " ", false, 2);
128 hidden('dimension_id', 0);
130 hidden('dimension2_id', 0);
131 amount_row( _("Amount:"), 'amount');
133 textarea_row(_("Memo:"), "memo_", null, 40, 2);
138 submit_center_first('AddGLCodeToTrans', _("Add GL Line"), '', true);
139 submit_center_last('ClearFields', _('Reset'), _("Clear all GL entry fields"), true);
142 //------------------------------------------------------------------------------------------------
144 end_page(false, true);