6 include_once($path_to_root . "/includes/session.inc");
8 include_once($path_to_root . "/includes/date_functions.inc");
9 include_once($path_to_root . "/includes/data_checks.inc");
11 include_once($path_to_root . "/gl/includes/gl_db.inc");
12 include_once($path_to_root . "/gl/includes/gl_ui.inc");
15 if ($use_popup_windows)
16 $js .= get_js_open_window(800, 500);
18 $js .= get_js_date_picker();
19 page(_("Transfer between Bank Accounts"), false, false, "", $js);
21 check_db_has_bank_accounts(_("There are no bank accounts defined in the system."));
23 //----------------------------------------------------------------------------------------
25 if (isset($_GET['AddedID']))
27 $trans_no = $_GET['AddedID'];
28 $trans_type = systypes::bank_transfer();
30 display_notification_centered( _("Transfer has been entered"));
32 display_note(get_gl_view_str($trans_type, $trans_no, _("&View the GL Journal Entries for this Transfer")));
34 hyperlink_no_params($_SERVER['PHP_SELF'], _("Enter &Another Transfer"));
39 if (isset($_POST['_DatePaid_changed'])) {
40 $Ajax->activate('_ex_rate');
43 //----------------------------------------------------------------------------------------
45 function gl_payment_controls()
48 $home_currency = get_company_currency();
50 start_form(false, true);
52 start_table($table_style2, 5, 7);
53 echo "<tr><td valign=top>"; // outer table
56 bank_accounts_list_row(_("From Account:"), 'FromBankAccount', null, true);
58 bank_accounts_list_row(_("To Account:"), 'ToBankAccount', null, true);
60 date_row(_("Transfer Date:"), 'DatePaid', '', null, 0, 0, 0, null, true);
62 $from_currency = get_bank_account_currency($_POST['FromBankAccount']);
63 $to_currency = get_bank_account_currency($_POST['ToBankAccount']);
64 if ($from_currency != "" && $to_currency != "" && $from_currency != $to_currency)
66 amount_row(_("Amount:"), 'amount', null, null, $from_currency);
68 exchange_rate_display($from_currency, $to_currency, $_POST['DatePaid']);
72 amount_row(_("Amount:"), 'amount');
76 echo "</td><td valign=top class='tableseparator'>"; // outer table
79 ref_row(_("Reference:"), 'ref', '', references::get_next(systypes::bank_transfer()));
81 textarea_row(_("Memo:"), 'memo_', null, 40,4);
86 end_table(1); // outer table
88 submit_center('AddPayment',_("Enter Transfer"), true, '', true);
93 //----------------------------------------------------------------------------------------
95 function check_valid_entries()
97 if (!is_date($_POST['DatePaid']))
99 display_error(_("The entered date is invalid."));
100 set_focus('DatePaid');
103 if (!is_date_in_fiscalyear($_POST['DatePaid']))
105 display_error(_("The entered date is not in fiscal year."));
106 set_focus('DatePaid');
110 if (!check_num('amount', 0))
112 display_error(_("The entered amount is invalid or less than zero."));
117 if (!references::is_valid($_POST['ref']))
119 display_error(_("You must enter a reference."));
124 if (!is_new_reference($_POST['ref'], systypes::bank_transfer()))
126 display_error(_("The entered reference is already in use."));
131 if ($_POST['FromBankAccount'] == $_POST['ToBankAccount'])
133 display_error(_("The source and destination bank accouts cannot be the same."));
134 set_focus('ToBankAccount');
141 //----------------------------------------------------------------------------------------
143 function handle_add_deposit()
145 global $path_to_root;
147 $trans_no = add_bank_transfer($_POST['FromBankAccount'], $_POST['ToBankAccount'],
148 $_POST['DatePaid'], input_num('amount'), $_POST['ref'], $_POST['memo_']);
150 meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no");
153 //----------------------------------------------------------------------------------------
157 global $path_to_root;
163 //----------------------------------------------------------------------------------------
165 if (isset($_POST['AddPayment']))
167 if (check_valid_entries() == true)
169 handle_add_deposit();
174 gl_payment_controls();