$error = false;
$account_type = 'c';
$order = new journal();
$transaction = new other_transactions();
$tills = new tills();
/***************   hook for custom actions  ***************************/
$custom_path = DIR_FS_MODULES . 'phreepos/custom/ajax/other_transactions.php';
if (file_exists($custom_path)) {
    include $custom_path;
}
/***************   Act on the action request   *************************/
if ($security_level < 2) {
    $error .= ERROR_NO_PERMISSION;
}
$transaction->get_transaction_info($_POST['Other_trans_type']);
$tills->get_till_info($_POST['ot_till_id']);
// currency values (convert to DEFAULT_CURRENCY to store in db)
$order->currencies_code = db_prepare_input($_POST['ot_currencies_code']);
$order->currencies_value = db_prepare_input($_POST['ot_currencies_value']);
// load journal main data
$order->journal_main_array = array('period' => CURRENT_ACCOUNTING_PERIOD, 'journal_id' => JOURNAL_ID, 'post_date' => date('Y-m-d'), 'total_amount' => $total_amount, 'description' => GL_ENTRY_TITLE, 'bill_primary_name' => $transaction->description, 'purchase_invoice_id' => '', 'admin_id' => $_SESSION['admin_id'], 'store_id' => $tills->store_id, 'total_amount' => $currencies->clean_value(db_prepare_input($_POST['ot_amount']), $order->currencies_code) / $order->currencies_value);
switch ($transaction->type) {
    case 'cash_in':
        $credit_amount = '';
        $debit_amount = $currencies->clean_value(db_prepare_input($_POST['ot_amount']), $order->currencies_code) / $order->currencies_value;
        $tills->adjust_balance($debit_amount);
        break;
    default:
        $debit_amount = '';
        $credit_amount = $currencies->clean_value(db_prepare_input($_POST['ot_amount']), $order->currencies_code) / $order->currencies_value;
        $tills->adjust_balance(-$credit_amount);
require_once DIR_FS_MODULES . 'phreebooks/functions/phreebooks.php';
require_once DIR_FS_MODULES . 'phreebooks/classes/gen_ledger.php';
require_once DIR_FS_MODULES . 'phreebooks/classes/banking.php';
/**************   page specific initialization  *************************/
$error = false;
$till_known = false;
$cleared_items = array();
$current_cleard_items = unserialize($_POST['current_cleard_items']);
$all_items = array();
$gl_types = array('pmt', 'ttl', 'tpm');
$post_date = $_POST['post_date'] ? gen_db_date($_POST['post_date']) : '';
$payment_modules = load_all_methods('payment');
$tills = new tills();
$glEntry = new journal();
if (isset($_GET['till_id'])) {
    $tills->get_till_info(db_prepare_input($_GET['till_id']));
    $post_date = gen_db_date(gen_locale_date(date('Y-m-d')));
} else {
    if (isset($_POST['till_id'])) {
        $tills->get_till_info(db_prepare_input($_POST['till_id']));
    } else {
        if ($tills->showDropDown() == false) {
            $tills->get_default_till_info();
        } else {
            $post_date = '';
            $_REQUEST['action'] = '';
        }
    }
}
if ($post_date) {
    $period = gen_calculate_period($post_date);