function create_cart($type, $trans_no)
{
    global $Refs;
    if (isset($_SESSION['pay_items'])) {
        unset($_SESSION['pay_items']);
    }
    $cart = new items_cart($type);
    $cart->order_id = $trans_no;
    if ($trans_no) {
        $bank_trans = db_fetch(get_bank_trans($type, $trans_no));
        $_POST['bank_account'] = $bank_trans["bank_act"];
        $_POST['PayType'] = $bank_trans["person_type_id"];
        if ($bank_trans["person_type_id"] == PT_CUSTOMER) {
            $trans = get_customer_trans($trans_no, $type);
            $_POST['person_id'] = $trans["debtor_no"];
            $_POST['PersonDetailID'] = $trans["branch_code"];
        } elseif ($bank_trans["person_type_id"] == PT_SUPPLIER) {
            $trans = get_supp_trans($trans_no, $type);
            $_POST['person_id'] = $trans["supplier_id"];
        } elseif ($bank_trans["person_type_id"] == PT_MISC) {
            $_POST['person_id'] = $bank_trans["person_id"];
        } elseif ($bank_trans["person_type_id"] == PT_QUICKENTRY) {
            $_POST['person_id'] = $bank_trans["person_id"];
        } else {
            $_POST['person_id'] = $bank_trans["person_id"];
        }
        $cart->memo_ = get_comments_string($type, $trans_no);
        $cart->tran_date = sql2date($bank_trans['trans_date']);
        $cart->reference = $Refs->get($type, $trans_no);
        $cart->original_amount = $bank_trans['amount'];
        $result = get_gl_trans($type, $trans_no);
        if ($result) {
            while ($row = db_fetch($result)) {
                if (is_bank_account($row['account'])) {
                    // date exchange rate is currenly not stored in bank transaction,
                    // so we have to restore it from original gl amounts
                    $ex_rate = $bank_trans['amount'] / $row['amount'];
                } else {
                    $date = $row['tran_date'];
                    $cart->add_gl_item($row['account'], $row['dimension_id'], $row['dimension2_id'], $row['amount'], $row['memo_']);
                }
            }
        }
        // apply exchange rate
        foreach ($cart->gl_items as $line_no => $line) {
            $cart->gl_items[$line_no]->amount *= $ex_rate;
        }
    } else {
        $cart->reference = $Refs->get_next($cart->trans_type);
        $cart->tran_date = new_doc_date();
        if (!is_date_in_fiscalyear($cart->tran_date)) {
            $cart->tran_date = end_fiscalyear();
        }
    }
    $_POST['memo_'] = $cart->memo_;
    $_POST['ref'] = $cart->reference;
    $_POST['date_'] = $cart->tran_date;
    $_SESSION['pay_items'] =& $cart;
}
        set_focus('date_');
        return false;
    }
    if (date_diff2(sql2date($wo_details["released_date"]), $_POST['date_'], "d") > 0) {
        display_error(_("The additional cost date cannot be before the release date of the work order."));
        set_focus('date_');
        return false;
    }
    return true;
}
//--------------------------------------------------------------------------------------------------
if (isset($_POST['process']) && can_process() == true) {
    $date = $_POST['date_'];
    begin_transaction();
    add_gl_trans_std_cost(ST_WORKORDER, $_POST['selected_id'], $_POST['date_'], $_POST['cr_acc'], 0, 0, $date . ": " . $wo_cost_types[$_POST['PaymentType']], -input_num('costs'), PT_WORKORDER, $_POST['PaymentType']);
    $is_bank_to = is_bank_account($_POST['cr_acc']);
    if ($is_bank_to) {
        add_bank_trans(ST_WORKORDER, $_POST['selected_id'], $is_bank_to, "", $_POST['date_'], -input_num('costs'), PT_WORKORDER, $_POST['PaymentType'], get_company_currency(), "Cannot insert a destination bank transaction");
    }
    add_gl_trans_std_cost(ST_WORKORDER, $_POST['selected_id'], $_POST['date_'], $_POST['db_acc'], $_POST['dim1'], $_POST['dim2'], $date . ": " . $wo_cost_types[$_POST['PaymentType']], input_num('costs'), PT_WORKORDER, $_POST['PaymentType']);
    //Chaitanya : Apply the costs to manfuctured stock item as adjustement
    $wo = get_work_order($_POST['selected_id']);
    if ($_POST['PaymentType'] == 0) {
        add_labour_cost($wo['stock_id'], 0, $_POST['date_'], input_num('costs'), true);
    } else {
        add_overhead_cost($wo['stock_id'], 0, $_POST['date_'], input_num('costs'), true);
    }
    commit_transaction();
    meta_forward($_SERVER['PHP_SELF'], "AddedID=" . $_POST['selected_id']);
}
//-------------------------------------------------------------------------------------
Example #3
0
function check_item_data()
{
    if (isset($_POST['dimension_id']) && $_POST['dimension_id'] != 0 && dimension_is_closed($_POST['dimension_id'])) {
        display_error(_("Dimension is closed."));
        set_focus('dimension_id');
        return false;
    }
    if (isset($_POST['dimension2_id']) && $_POST['dimension2_id'] != 0 && dimension_is_closed($_POST['dimension2_id'])) {
        display_error(_("Dimension is closed."));
        set_focus('dimension2_id');
        return false;
    }
    if (!(input_num('AmountDebit') != 0 ^ input_num('AmountCredit') != 0)) {
        display_error(_("You must enter either a debit amount or a credit amount."));
        set_focus('AmountDebit');
        return false;
    }
    if (strlen($_POST['AmountDebit']) && !check_num('AmountDebit', 0)) {
        display_error(_("The debit amount entered is not a valid number or is less than zero."));
        set_focus('AmountDebit');
        return false;
    } elseif (strlen($_POST['AmountCredit']) && !check_num('AmountCredit', 0)) {
        display_error(_("The credit amount entered is not a valid number or is less than zero."));
        set_focus('AmountCredit');
        return false;
    }
    if (!is_tax_gl_unique(get_post('code_id'))) {
        display_error(_("Cannot post to GL account used by more than one tax type."));
        set_focus('code_id');
        return false;
    }
    if (!$_SESSION["wa_current_user"]->can_access('SA_BANKJOURNAL') && is_bank_account($_POST['code_id'])) {
        display_error(_("You cannot make a journal entry for a bank account. Please use one of the banking functions for bank transactions."));
        set_focus('code_id');
        return false;
    }
    return true;
}
Example #4
0
     display_error(_("The account name cannot be empty."));
     set_focus('account_name');
 } elseif (!$accounts_alpha && !preg_match("/^[0-9.]+\$/", $_POST['account_code'])) {
     $input_error = 1;
     display_error(_("The account code must be numeric."));
     set_focus('account_code');
 }
 if ($input_error != 1) {
     if ($accounts_alpha == 2) {
         $_POST['account_code'] = strtoupper($_POST['account_code']);
     }
     if (!isset($_POST['account_tags'])) {
         $_POST['account_tags'] = array();
     }
     if ($selected_account) {
         if (get_post('inactive') == 1 && is_bank_account($_POST['account_code'])) {
             display_error(_("The account belongs to a bank account and cannot be inactivated."));
         } elseif (update_gl_account($_POST['account_code'], $_POST['account_name'], $_POST['account_type'], $_POST['account_code2'])) {
             update_record_status($_POST['account_code'], $_POST['inactive'], 'chart_master', 'account_code');
             update_tag_associations(TAG_ACCOUNT, $_POST['account_code'], $_POST['account_tags']);
             $Ajax->activate('account_code');
             // in case of status change
             display_notification(_("Account data has been updated."));
         }
     } else {
         if (add_gl_account($_POST['account_code'], $_POST['account_name'], $_POST['account_type'], $_POST['account_code2'])) {
             add_tag_associations($_POST['account_code'], $_POST['account_tags']);
             display_notification(_("New account has been added."));
             $selected_account = $_POST['AccountList'] = $_POST['account_code'];
         } else {
             display_error(_("Account not added, possible duplicate Account Code."));
Example #5
0
function check_item_data()
{
    if (!check_num('amount', 0)) {
        display_error(tr("The amount entered is not a valid number or is less than zero."));
        set_focus('amount');
        return false;
    }
    if ($_POST['code_id'] == $_POST['bank_account']) {
        display_error(tr("The source and destination accouts cannot be the same."));
        set_focus('code_id');
        return false;
    }
    if (is_bank_account($_POST['code_id'])) {
        display_error(tr("You cannot make a deposit from a bank account. Please use the transfer funds facility for this."));
        set_focus('code_id');
        return false;
    }
    return true;
}
function print_inventory_sales()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $destination = $_POST['PARAM_2'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $dec = user_price_dec();
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    $cols = array(0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200);
    $headers = array(_('DATE'), _('PAYEES'), _('PARTICULARS'), _('GV NO'), _('CHECK NO'), _('CASH IN'), _('PURCHASES'), _('SALARIES &'), _('SUPPLIES'), _('GASOLINE &'), _('LIGHT &'), _('TELECOMS'), _('REPAIRS'), _('REPRESENTATION'), _('TRANSPORTATION'), _('POSTAGE'), _('AD &'), _('PROF.'), _('INSURANCE'), _('CASH'), _('SUNDRY'), _('DEBIT'), _('CREDIT'));
    $header2 = array(_(''), '', '', '', _(''), _('BANK'), _(''), _('WAGES'), _(''), _('OIL'), _('WATER'), _(''), _('& MAINT.'), _('EXPENSE'), _('EXPENSE'), _('& COURIER'), _('PROMO'), _('FEES'), _(''), _('ADVANCE'), _('ACCOUNTS'));
    $aligns = array('left', 'center', 'center', 'center', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''));
    $rep = new FrontReport(_('Cash Disbursement Summary'), "CashDisbursementSummary", user_pagesize(), 8, 'L');
    $rep->Font();
    $rep->Info($params, $cols, $header2, $aligns, $cols, $headers, $aligns);
    $rep->NewPage();
    $salary = '6-1010';
    $purchase = '5-1010';
    $supplies = '6-1175';
    $gas_oil = '6-1110';
    $light_water = '6-1075';
    $tel = '6-1080';
    $repair = '6-1085';
    $representation = '6-1055';
    $transport = '6-1070';
    $postage = '6-1155';
    $ad_promo = '6-1230';
    $prof_fee = '6-1185';
    $insurance = '6-1105';
    $cash_advance = '1-2045';
    $petty_cash = '1-1010';
    $res = getTransactions($from, $to);
    $previous = '';
    $var = array($salary, $purchase, $gas_oil, $light_water, $tel, $repair, $representation, $transport, $postage, $ad_promo, $prof_fee, $insurance, $cash_advance);
    $total = 0;
    $purchase_total = 0;
    $sal_total = 0;
    $sup_total = 0;
    $gas_total = 0;
    $light_total = 0;
    $tel_total = 0;
    $repair_total = 0;
    $rep_total = 0;
    $trans_total = 0;
    $post_total = 0;
    $ad_total = 0;
    $prof_total = 0;
    $ins_total = 0;
    $adv_total = 0;
    $dr = 0;
    $cr = 0;
    $sun_bank_name = '';
    $sun_bank_amount = '';
    while ($myrow = db_fetch($res)) {
        $check = $myrow['customized_no'];
        $current = $check;
        $name = payment_person_name($myrow["person_type_id"], $myrow["person_id"]);
        $comment = get_comments_string($myrow['type'], $myrow['type_no']);
        $account_name = get_gl_account_name($myrow['account']);
        //$rep->NewLine();
        if ($current != '') {
            if ($previous == $current) {
                if ($myrow['type'] == '') {
                    if (is_bank_account($myrow['account'])) {
                        if ($myrow['account'] != $petty_cash) {
                            $rep->AmountCol(5, 6, abs($myrow['amount']), 2);
                            $total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $purchase) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(6, 7, abs($myrow['amount']), 2);
                            $purchase_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $salary) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(7, 8, abs($myrow['amount']), 2);
                            $sal_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $supplies) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(8, 9, abs($myrow['amount']), 2);
                            $sup_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $gas_oil) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(9, 10, abs($myrow['amount']), 2);
                            $gas_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $light_water) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(10, 11, abs($myrow['amount']), 2);
                            $light_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $tel) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(11, 12, abs($myrow['amount']), 2);
                            $tel_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $repair) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(12, 13, abs($myrow['amount']), 2);
                            $repair_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $representation) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(13, 14, abs($myrow['amount']), 2);
                            $rep_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $transport) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(14, 15, abs($myrow['amount']), 2);
                            $trans_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $postage) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(15, 16, abs($myrow['amount']), 2);
                            $post_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $ad_promo) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(16, 17, abs($myrow['amount']), 2);
                            $ad_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $prof_fee) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(17, 18, abs($myrow['amount']), 2);
                            $prof_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $insurance) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(18, 19, abs($myrow['amount']), 2);
                            $ins_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $cash_advance) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(19, 20, abs($myrow['amount']), 2);
                            $adv_total += abs($myrow['amount']);
                        }
                    }
                }
            } else {
                if ($sun_bank_amount != 0 && $sun_bank_name != '') {
                    $rep->TextCol(20, 21, $account_name);
                    $rep->AmountCol(21, 22, $myrow['amount'], 2);
                    $rep->NewLine();
                }
                $result = get_sundry($previous);
                $ctr = 0;
                while ($row = db_fetch($result)) {
                    if ($row['type'] == "") {
                        if (!is_bank_account($row['account'])) {
                            $yes = check_account($row['account'], $row['amount']);
                            if ($yes) {
                                // $rep->TextCol(22, 23, $check_account($row['account']));
                                $ctr++;
                                if ($ctr > 1) {
                                    $rep->NewLine();
                                }
                                $account_name2 = get_gl_account_name($row['account']);
                                $rep->TextCol(20, 21, $account_name2);
                                if ($row['amount'] > 0) {
                                    $rep->AmountCol(21, 22, $row['amount'], 2);
                                    $dr += abs($myrow['amount']);
                                } else {
                                    $rep->AmountCol(22, 23, abs($row['amount']), 2);
                                    $cr += abs($myrow['amount']);
                                }
                            }
                        }
                    }
                }
                $rep->NewLine();
                if ($myrow['type'] == '') {
                    $rep->TextCol(0, 1, $myrow['tranDate']);
                    $rep->TextCol(1, 2, $name);
                    $rep->TextCol(2, 3, $comment);
                    $rep->TextCol(3, 4, $myrow['customized_no']);
                    $rep->TextCol(4, 5, $myrow['check_num']);
                    if (is_bank_account($myrow['account'])) {
                        if ($myrow['account'] != $petty_cash) {
                            $rep->AmountCol(5, 6, abs($myrow['amount']), 2);
                            $total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $purchase) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(6, 7, abs($myrow['amount']), 2);
                            $purchase_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $salary) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(7, 8, abs($myrow['amount']), 2);
                            $sal_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $supplies) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(8, 9, abs($myrow['amount']), 2);
                            $sup_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $gas_oil) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(9, 10, abs($myrow['amount']), 2);
                            $gas_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $light_water) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(10, 11, abs($myrow['amount']), 2);
                            $light_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $tel) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(11, 12, abs($myrow['amount']), 2);
                            $tel_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $repair) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(12, 13, abs($myrow['amount']), 2);
                            $repair_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $representation) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(13, 14, abs($myrow['amount']), 2);
                            $rep_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $transport) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(14, 15, abs($myrow['amount']), 2);
                            $trans_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $postage) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(15, 16, abs($myrow['amount']), 2);
                            $post_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $ad_promo) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(16, 17, abs($myrow['amount']), 2);
                            $ad_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $prof_fee) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(17, 18, abs($myrow['amount']), 2);
                            $prof_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $insurance) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(18, 19, abs($myrow['amount']), 2);
                            $ins_total += abs($myrow['amount']);
                        }
                    }
                    if ($myrow['account'] == $cash_advance) {
                        if ($myrow['amount'] > 0) {
                            $rep->AmountCol(19, 20, abs($myrow['amount']), 2);
                            $adv_total += abs($myrow['amount']);
                        }
                    }
                } else {
                    $rep->TextCol(0, 1, $myrow['tranDate']);
                    $rep->TextCol(1, 2, "Cancelled");
                    $rep->TextCol(2, 3, "");
                    $rep->TextCol(3, 4, $myrow['customized_no']);
                    $rep->TextCol(4, 5, $myrow['check_num']);
                }
            }
            $previous = $current;
        }
    }
    $rep->NewLine();
    $rep->Font('bold');
    $rep->AmountCol(5, 6, $total, 2);
    $rep->AmountCol(6, 7, $purchase_total, 2);
    $rep->AmountCol(7, 8, $sal_total, 2);
    $rep->AmountCol(8, 9, $sup_total, 2);
    $rep->AmountCol(9, 10, $gas_total, 2);
    $rep->AmountCol(10, 11, $light_total, 2);
    $rep->AmountCol(11, 12, $tel_total, 2);
    $rep->AmountCol(12, 13, $repair_total, 2);
    $rep->AmountCol(13, 14, $rep_total, 2);
    $rep->AmountCol(14, 15, $trans_total, 2);
    $rep->AmountCol(15, 16, $post_total, 2);
    $rep->AmountCol(16, 17, $ad_total, 2);
    $rep->AmountCol(17, 18, $prof_total, 2);
    $rep->AmountCol(18, 19, $ins_total, 2);
    $rep->AmountCol(19, 20, $adv_total, 2);
    $rep->AmountCol(21, 22, $dr, 2);
    $rep->AmountCol(22, 23, $cr, 2);
    /* $i = 0;
       $k = 1;
       foreach($var as $vars)
       {
           $tots = getTotal($vars);
           $rep->AmountCol($i, $k, $tots, 2);
           $i++;
           $j++;
       }*/
    $rep->End();
}
Example #7
0
function check_item_data()
{
    if (isset($_POST['dimension_id']) && $_POST['dimension_id'] != 0 && dimension_is_closed($_POST['dimension_id'])) {
        display_error(tr("Dimension is closed."));
        set_focus('dimension_id');
        return false;
    }
    if (isset($_POST['dimension2_id']) && $_POST['dimension2_id'] != 0 && dimension_is_closed($_POST['dimension2_id'])) {
        display_error(tr("Dimension is closed."));
        set_focus('dimension2_id');
        return false;
    }
    if (!(input_num('AmountDebit') != 0 ^ input_num('AmountCredit') != 0)) {
        display_error(tr("You must enter either a debit amount or a credit amount."));
        set_focus('Amount_Debit');
        return false;
    }
    if (strlen($_POST['AmountDebit']) && !check_num('AmountDebit', 0)) {
        display_error(tr("The debit amount entered is not a valid number or is less than zero."));
        set_focus('AmountDebit');
        return false;
    } elseif (strlen($_POST['AmountCredit']) && !check_num('AmountCredit', 0)) {
        display_error(tr("The credit amount entered is not a valid number or is less than zero."));
        set_focus('AmountCredit');
        return false;
    }
    if ($_SESSION["wa_current_user"]->access != 2 && is_bank_account($_POST['code_id'])) {
        display_error(tr("You cannot make a journal entry for a bank account. Please use one of the banking functions for bank transactions."));
        set_focus('code_id');
        return false;
    }
    return true;
}
Example #8
0
function print_check_voucher()
{
    global $path_to_root, $systypes_array;
    $trans_no = $_POST['PARAM_0'];
    $trans_num = $_POST['PARAM_1'];
    $cv_no = $_POST['PARAM_2'];
    $account = $_POST['PARAM_3'];
    $orientation = $_POST['PARAM_4'];
    $destination = $_POST['PARAM_5'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report2.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $rep = new FrontReport(_('CHECK VOUCHER'), "CheckVoucher", user_pagesize(), '', $orientation);
    $dec = user_price_dec();
    $cols = array(0, 30, 50, 125, 175, 200, 265, 285, 360, 425, 460, 542, 550);
    $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'left', 'left', 'right', 'right', 'right');
    $rep->SetHeaderType(0);
    $rep->Font();
    $rep->Info(null, $cols, null, $aligns);
    $rep->NewPage();
    $ty = explode("-", $trans_no);
    $t_type = $ty[1];
    if ($t_type != 0) {
        $res = get_transaction($trans_no, $t_type);
        $res1 = get_heading($trans_no, $t_type);
    } else {
        $res = get_transaction($trans_no, ST_DISBURSEMENT);
        $res1 = get_heading($trans_no, ST_DISBURSEMENT);
    }
    $myrow = db_fetch($res);
    $myrow1 = db_fetch($res1);
    $credit = $debit = 0;
    //$transtype = ST_DISBURSEMENT;
    if ($t_type != 0 || $t_type != '') {
        $res2 = get_gl_trans($t_type, $trans_num);
        $res3 = get_gl_trans($t_type, $trans_num);
    } else {
        $res2 = get_gl_trans(ST_DISBURSEMENT, $trans_num);
        $res3 = get_gl_trans(ST_DISBURSEMENT, $trans_num);
    }
    $new_ret = 0;
    $return = 0;
    //$fiscal = get_year(); //to be use
    // $year_no = substr(sql2date($fiscal['begin']), 8); //to be use
    // $ser = db_fetch(get_used_series($year_no, $transtype));
    // $num = substr($ser['year'], 2);
    /* $rep->Font('bold');
       $rep->TextCol(7,11, _("ST. MATTHEW'S PUBLISHING CORPORATION"));
       $rep->Font();
       $rep->NewLine();
       $rep->TextCol(7,11, _("Tel. Nos. 426-5611 * 433-5385 Telefax: 426-1274"));
       $rep->NewLine(3);
       $rep->Font('bold');
       $rep->SetFontSize(14);
       $rep->TextCol(5,8, _("CHECK VOUCHER"));*/
    $rep->NewLine(7);
    $rep->SetFontSize(12);
    $num = substr($myrow['yearDate'], 2);
    $name = payment_person_name($myrow["person_type_id"], $myrow["person_id"]);
    $rep->TextCol(2, 6, $name);
    $rep->TextCol(9, 11, $num . "-" . str_pad($myrow1['customized_no'], 4, 0, STR_PAD_LEFT));
    $rep->NewLine();
    if ($myrow1['customized_field'] != 0 || $myrow1['customized_field'] != '') {
        $rep->TextCol(0, 4, $myrow1['customized_field']);
    } else {
        $rep->TextCol(0, 4, _(""));
    }
    $rep->NewLine(1);
    $rep->TextCol(8, 10, $myrow['sqldate']);
    $rep->NewLine(5);
    // $rep->Line($rep->row  - -10);
    //  $rep->TextCol(4,6, _("PARTICULARS"));
    // $rep->TextCol(9,10, _("AMOUNT"));
    //  $rep->Line($rep->row  - 4);
    $var = array();
    $pos = array();
    $neg = array();
    $pos_amt = array();
    $neg_amt = array();
    $tots = 0;
    $comment = get_comments_string($cv_no, $trans_num);
    while ($myrow2 = db_fetch($res2)) {
        $tots = 0;
        if (is_bank_account($myrow2['account'])) {
            $var = array($myrow2['account']);
            $rep->TextCol(1, 8, $comment);
            $tots += abs($myrow2['amount']);
        }
    }
    $rep->AmountCol(9, 11, $tots, 2);
    $rep->NewLine(2);
    // $rep->Line($rep->row  - -10);
    // $rep->TextCol(1,3, _("DEBIT"));
    // $rep->TextCol(7,8, _("CREDIT"));
    // $rep->Line($rep->row  - 4);
    $rep->NewLine(5);
    $rep->SetFontSize(12);
    while ($myrow3 = db_fetch($res3)) {
        $accounts = get_gl_accounts($myrow3['account']);
        $account = db_fetch($accounts);
        if ($myrow3['amount'] > 0) {
            // $rep->Line($rep->row  - -10);
            //$rep->TextCol(0,4, $account['account_name']);
            //  $rep->AmountCol(5,6, $myrow3['amount'],2);
            //  $rep->NewLine();
            //  $rep->Line($rep->row  + 8);
            array_push($pos, $account['account_name']);
            array_push($pos_amt, $myrow3['amount']);
            $debit += $myrow3['amount'];
        } else {
            array_push($neg, $account['account_name']);
            array_push($neg_amt, $myrow3['amount']);
            //  $rep->Line($rep->row  - 4);
            //  $rep->TextCol(6,8, $account['account_name']);
            //  $rep->AmountCol(9,11, abs($myrow3['amount']), 2);
            //  $rep->NewLine();
            // $rep->Line($rep->row  - 4);
        }
    }
    $result = array_merge($pos, $neg);
    $new = array();
    for ($i = 0; $i < count($result); $i++) {
        $new[] = $pos[$i];
        $new[] = $neg[$i];
    }
    $result2 = array_merge($pos_amt, $neg_amt);
    $new2 = array();
    for ($j = 0; $j < count($result2); $j++) {
        $new2[] = $pos_amt[$j];
        $new2[] = $neg_amt[$j];
    }
    $final_res = array_merge($new, $new2);
    $final_array = array();
    $final = array();
    for ($k = 0; $k < count($final_res); $k++) {
        $final[] = $new[$k];
        $final[] = $new2[$k];
    }
    $enter = 0;
    for ($i = 0; $i <= count($final_res); $i++) {
        //if ($final[$i] != 0)
        //{
        $rep->TextCol(0, 4, $pos[$i]);
        if ($pos_amt[$i] != 0) {
            $rep->AmountCol(4, 6, $pos_amt[$i], 2);
        }
        $rep->TextCol(7, 9, $neg[$i]);
        if ($neg_amt[$i] != 0) {
            $rep->AmountCol(9, 11, abs($neg_amt[$i]), 2);
        }
        if ($pos[$i] != "") {
            $rep->NewLine();
            $enter++;
        }
        // }
    }
    $return = 11 - $enter;
    //$rep->Line($rep->row  - 4);
    $rep->NewLine($return);
    //$rep->TextCol(0,2, count($final_res));
    //$rep->TextCol(4,5, $enter);
    //else
    //  $rep->NewLine($return);
    $rep->SetFontSize(10);
    // $rep->TextCol(0,2, _("Cash"));
    $words = price_in_words($tots, ST_CHEQUE);
    $_word = strlen($words);
    $first_word = substr($words, 0, 34);
    $second_word = substr($words, 34);
    // if ($words != "")
    // {
    //$rep->TextCol(5,7, _("Received the sum of :"));
    // $oldrow = $rep->row;
    $rep->TextColLines(8, 11, $first_word . "-", -2);
    //$newrow = $rep->row;
    // $rep->row = $oldrow;
    // }
    $rep->SetFontSize(10);
    $rep->TextCol(1, 3, $myrow1['check_num']);
    $tots_dec = price_format($tots);
    $rep->TextCol(3, 7, "                       " . $tots_dec);
    $rep->SetFontSize(10);
    $rep->TextCol(7, 11, $second_word);
    //$rep->TextCol(7,10, _("as payment of the above particulars."));
    $rep->NewLine();
    $rep->SetFontSize(10);
    //$rep->TextCol(0,10, _("Bank/Branch: "));
    foreach ($var as $vars) {
        // $bank_name = get_bank_name($vars);
        $rep->TextCol(2, 10, get_bank_name($vars) . " ");
    }
    //  $rep->TextCol(1,5, $myrow['bank_address']);
    $rep->TextCol(7, 9, "     " . $tots_dec);
    $rep->End();
}