default: die('Illegal Access'); } /************** include page specific files *********************/ require DIR_FS_MODULES . 'banking/language/' . $_SESSION['language'] . '/language.php'; require DIR_FS_MODULES . 'gen_ledger/language/' . $_SESSION['language'] . '/language.php'; require DIR_FS_MODULES . 'orders/language/' . $_SESSION['language'] . '/language.php'; require DIR_FS_MODULES . 'banking/functions/banking.php'; require DIR_FS_MODULES . 'banking/classes/banking.php'; require DIR_FS_MODULES . 'orders/functions/orders.php'; require DIR_FS_MODULES . 'orders/classes/orders.php'; /************** page specific initialization *************************/ $error = false; $post_success = false; $installed_modules = array(); $order = new banking(); $action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo']; $gl_acct_id = $_POST['gl_acct_id'] ? db_prepare_input($_POST['gl_acct_id']) : $order->gl_acct_id; $order->gl_acct_id = $gl_acct_id; $order->acct_1 = DEF_DEP_GL_ACCT; $default_dep_acct = JOURNAL_ID == 18 ? AR_DEF_DEPOSIT_ACCT : AP_DEF_DEPOSIT_ACCT; $post_date = $_POST['post_date'] ? gen_db_date_short($_POST['post_date']) : date('Y-m-d', time()); $period = gen_calculate_period($post_date); if (!$period) { // bad post_date was submitted $action = ''; $post_date = date('Y-m-d', time()); $period = 0; } // load available payment modules, receipts only if (JOURNAL_ID == 18) {
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'; require_once DIR_FS_MODULES . 'phreebooks/classes/orders.php'; //if (file_exists(DIR_FS_MODULES . 'phreepos/custom/classes/journal/journal_'.JOURNAL_ID.'.php')) { // require_once(DIR_FS_MODULES . 'phreepos/custom/classes/journal/journal_'.JOURNAL_ID.'.php') ; //}else{ // require_once(DIR_FS_MODULES . 'phreepos/classes/journal/journal_'.JOURNAL_ID.'.php'); // is needed here for the defining of the class and retriving the security_token //} //$class = 'journal_'.JOURNAL_ID; /************** page specific initialization *************************/ $error = false; $post_success = false; $default_dep_acct = JOURNAL_ID == 18 ? AR_DEF_DEPOSIT_ACCT : AP_DEF_DEPOSIT_ACCT; //$order = new $class(); $order = new banking(); $gl_acct_id = isset($_POST['gl_acct_id']) ? db_prepare_input($_POST['gl_acct_id']) : $order->gl_acct_id; $next_inv_ref = isset($_POST['purchase_invoice_id']) ? db_prepare_input($_POST['purchase_invoice_id']) : $order->purchase_invoice_id; $post_date = isset($_POST['post_date']) ? gen_db_date($_POST['post_date']) : date('Y-m-d'); $period = gen_calculate_period($post_date); if (!$period) { // bad post_date was submitted $_REQUEST['action'] = ''; $post_date = date('Y-m-d'); $period = 0; } $order->gl_acct_id = $gl_acct_id; $order->acct_1 = DEF_DEP_GL_ACCT; // load available payment modules, receipts only $payment_modules = array(); if (JOURNAL_ID == 18) {
$payment_list[$_POST['bill_acct_id_' . $i]][] = array('id' => $_POST['id_' . $i], 'amt' => $currencies->clean_value($_POST['amt_' . $i]), 'desc' => $_POST['desc_' . $i], 'dscnt' => $currencies->clean_value($_POST['dscnt_' . $i]), 'total' => $currencies->clean_value($_POST['total_' . $i]), 'acct' => $currencies->clean_value($_POST['acct_' . $i]), 'inv' => $_POST['inv_' . $i]); } } // error check input if (!count($payment_list)) { $messageStack->add(GL_ERROR_NO_ITEMS, 'error'); $error = true; break; } // ***************************** START TRANSACTION ******************************* $first_payment_ref = $purchase_invoice_id; // first check number, needed for printing $db->transStart(); // post each payment by vendor (save journal record id) foreach ($payment_list as $account => $values) { $order = new banking(); // load journal main data $order->id = ''; $order->journal_id = JOURNAL_ID; $order->post_date = $post_date; $order->period = $period; $order->admin_id = $_SESSION['admin_id']; $order->purchase_invoice_id = $purchase_invoice_id; // PhreeBooks payment number $order->shipper_code = ''; $order->purch_order_id = $purch_order_id; $order->description = constant('GEN_ADM_TOOLS_J' . JOURNAL_ID); $order->gl_acct_id = $gl_acct_id; $order->gl_disc_acct_id = $gl_disc_acct_id; // retrieve billing information $result = $db->Execute("select * from " . TABLE_ADDRESS_BOOK . " where type = 'vm' and ref_id = " . $account);
if (DEBUG) { $messageStack->write_debug(); } $order = new objectInfo($_POST); $order->post_date = gen_db_date($_POST['post_date']); // fix the date to original format $order->id = $_POST['id'] != '' ? $_POST['id'] : ''; // will be null unless opening an existing purchase/receive } break; case 'delete': validate_security($security_level, 4); $id = $_POST['id'] != '' ? $_POST['id'] : ''; // will be null unless opening an existing purchase/receive if ($id) { $delOrd = new banking(); $delOrd->journal($id); // load the posted record based on the id submitted if ($delOrd->delete_payment()) { gen_add_audit_log(AUDIT_LOG_DEL_DESC, $order->purchase_invoice_id, $order->total_amount); if (DEBUG) { $messageStack->write_debug(); } gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('action')), 'SSL')); } } else { $messageStack->add(GL_ERROR_NEVER_POSTED, 'error'); } $messageStack->add(GL_ERROR_NO_DELETE, 'error'); // if we are here, there was an error, reload page $order = new objectInfo($_POST);