2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 $page_security = 'SA_EXCHANGERATE';
13 $path_to_root = "../..";
14 include_once($path_to_root . "/includes/session.inc");
16 include_once($path_to_root . "/includes/date_functions.inc");
17 include_once($path_to_root . "/includes/ui.inc");
18 include_once($path_to_root . "/includes/banking.inc");
22 $js .= get_js_date_picker();
23 page(_($help_context = "Revaluation of Currency Accounts"), false, false, "", $js);
25 if (isset($_GET['AddedID']))
27 $trans_no = $_GET['AddedID'];
29 $trans_type = ST_JOURNAL;
32 display_notification_centered( _("No Revaluation was needed"));
35 display_notification_centered( _("Transfer has been entered"));
37 display_note(get_gl_view_str($trans_type, $trans_no, _("&View the GL Journal Entries for this Transfer")));
40 display_notification_centered(sprintf(_("%d Journal Entries for AR/AP accounts have been added"), $JE));
42 //display_footer_exit();
46 //---------------------------------------------------------------------------------------------
51 if (!is_date($_POST['date']))
53 display_error( _("The entered date is invalid."));
57 if (!is_date_in_fiscalyear($_POST['date']))
59 display_error(_("The entered date is out of fiscal year or is closed for further data entry."));
63 if (!$Refs->is_valid($_POST['ref']))
65 display_error(_("You must enter a reference."));
70 if (!is_new_reference($_POST['ref'], ST_JOURNAL))
72 display_error(_("The entered reference is already in use."));
80 //---------------------------------------------------------------------------------------------
82 function handle_submit()
87 $trans = add_exchange_variation_all($_POST['date'], $_POST['ref'], $_POST['memo_']);
89 meta_forward($_SERVER['PHP_SELF'], "AddedID=".$trans[0]."&JE=".$trans[1]);
94 //---------------------------------------------------------------------------------------------
96 function display_reval()
100 start_table(TABLESTYLE2);
102 if (!isset($_POST['date']))
103 $_POST['date'] = Today();
104 date_row(_("Date for Revaluation:"), 'date', '', null, 0, 0, 0, null, true);
105 ref_row(_("Reference:"), 'ref', '', $Refs->get_next(ST_JOURNAL));
106 textarea_row(_("Memo:"), 'memo_', null, 40,4);
109 submit_center('submit', _("Revaluate Currencies"), true, false);
113 //---------------------------------------------------------------------------------------------
115 function clear_data()
117 unset($_POST['date_']);
118 unset($_POST['memo_']);
121 //---------------------------------------------------------------------------------------------
123 if (get_post('submit'))
126 //---------------------------------------------------------------------------------------------