Пример #1
0
function display_item_form()
{
    global $table_style2;
    start_table($table_style2, 5, 7);
    echo "<tr><td valign=top>";
    // outer table
    echo "<table>";
    if (!isset($_POST['customer_id'])) {
        $_POST['customer_id'] = get_global_customer(false);
    }
    if (!isset($_POST['DateBanked'])) {
        $_POST['DateBanked'] = Today();
        if (!is_date_in_fiscalyear($_POST['DateBanked'])) {
            $_POST['DateBanked'] = end_fiscalyear();
        }
    }
    customer_list_row(tr("From Customer:"), 'customer_id', null, false, true);
    if (db_customer_has_branches($_POST['customer_id'])) {
        customer_branches_list_row(tr("Branch:"), $_POST['customer_id'], 'BranchID', null, false, true, true);
    } else {
        hidden('BranchID', reserved_words::get_any_numeric());
    }
    read_customer_data();
    set_global_customer($_POST['customer_id']);
    if (isset($_POST['HoldAccount']) && $_POST['HoldAccount'] != 0) {
        echo "</table></table>";
        display_note(tr("This customer account is on hold."), 0, 0, "class='redfb'");
    } else {
        $display_discount_percent = percent_format($_POST['pymt_discount'] * 100) . "%";
        amount_row(tr("Amount:"), 'amount');
        amount_row(tr("Amount of Discount:"), 'discount');
        label_row(tr("Customer prompt payment discount :"), $display_discount_percent);
        date_row(tr("Date of Deposit:"), 'DateBanked');
        echo "</table>";
        echo "</td><td valign=top class='tableseparator'>";
        // outer table
        echo "<table>";
        bank_accounts_list_row(tr("Into Bank Account:"), 'bank_account', null, true);
        $cust_currency = get_customer_currency($_POST['customer_id']);
        $bank_currency = get_bank_account_currency($_POST['bank_account']);
        if ($cust_currency != $bank_currency) {
            exchange_rate_display($cust_currency, $bank_currency, $_POST['DateBanked']);
        }
        bank_trans_types_list_row(tr("Type:"), 'ReceiptType', null);
        text_row(tr("Reference:"), 'ref', null, 20, 40);
        textarea_row(tr("Memo:"), 'memo_', null, 22, 4);
        echo "</table>";
        echo "</td></tr>";
        end_table();
        // outer table
        if ($cust_currency != $bank_currency) {
            display_note(tr("Amount and discount are in customer's currency."));
        }
        echo "<br>";
        submit_center('AddPaymentItem', tr("Add Payment"));
    }
    echo "<br>";
}
Пример #2
0
function can_process()
{
    global $Refs;
    if (!get_post('customer_id')) {
        display_error(_("There is no customer selected."));
        set_focus('customer_id');
        return false;
    }
    if (!get_post('BranchID')) {
        display_error(_("This customer has no branch defined."));
        set_focus('BranchID');
        return false;
    }
    if (!isset($_POST['DateBanked']) || !is_date($_POST['DateBanked'])) {
        display_error(_("The entered date is invalid. Please enter a valid date for the payment."));
        set_focus('DateBanked');
        return false;
    } elseif (!is_date_in_fiscalyear($_POST['DateBanked'])) {
        display_error(_("The entered date is not in fiscal year."));
        set_focus('DateBanked');
        return false;
    }
    if (!$Refs->is_valid($_POST['ref'])) {
        display_error(_("You must enter a reference."));
        set_focus('ref');
        return false;
    }
    //Chaitanya : 13-OCT-2011 - To support Edit feature
    if (isset($_POST['trans_no']) && $_POST['trans_no'] == 0 && !is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) {
        display_error(_("The entered reference is already in use."));
        set_focus('ref');
        return false;
    } elseif ($_POST['ref'] != $_POST['old_ref'] && !is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) {
        display_error(_("The entered reference is already in use."));
        set_focus('ref');
        return false;
    }
    if (!check_num('amount', 0)) {
        display_error(_("The entered amount is invalid or negative and cannot be processed."));
        set_focus('amount');
        return false;
    }
    if (isset($_POST['charge']) && !check_num('charge', 0)) {
        display_error(_("The entered amount is invalid or negative and cannot be processed."));
        set_focus('charge');
        return false;
    }
    if (isset($_POST['charge']) && input_num('charge') > 0) {
        $charge_acct = get_company_pref('bank_charge_act');
        if (get_gl_account($charge_acct) == false) {
            display_error(_("The Bank Charge Account has not been set in System and General GL Setup."));
            set_focus('charge');
            return false;
        }
    }
    if (isset($_POST['_ex_rate']) && !check_num('_ex_rate', 1.0E-6)) {
        display_error(_("The exchange rate must be numeric and greater than zero."));
        set_focus('_ex_rate');
        return false;
    }
    if ($_POST['discount'] == "") {
        $_POST['discount'] = 0;
    }
    if (!check_num('discount')) {
        display_error(_("The entered discount is not a valid number."));
        set_focus('discount');
        return false;
    }
    //if ((input_num('amount') - input_num('discount') <= 0)) {
    if (input_num('amount') <= 0) {
        display_error(_("The balance of the amount and discout is zero or negative. Please enter valid amounts."));
        set_focus('discount');
        return false;
    }
    if (!db_has_currency_rates(get_customer_currency($_POST['customer_id']), $_POST['DateBanked'], true)) {
        return false;
    }
    $_SESSION['alloc']->amount = input_num('amount');
    if (isset($_POST["TotalNumberOfAllocs"])) {
        return check_allocations();
    } else {
        return true;
    }
}
Пример #3
0
function print_inventory_sales()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $category = $_POST['PARAM_2'];
    $location = $_POST['PARAM_3'];
    $fromcust = $_POST['PARAM_4'];
    $comments = $_POST['PARAM_5'];
    $orientation = $_POST['PARAM_6'];
    $destination = $_POST['PARAM_7'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == '') {
        $loc = _('All');
    } else {
        $loc = get_location_name($location);
    }
    if ($fromcust == '') {
        $fromc = _('All');
    } else {
        $fromc = get_customer_name($fromcust);
    }
    $cols = array(0, 75, 175, 250, 300, 375, 450, 515);
    $headers = array(_('Category'), _('Description'), _('Customer'), _('Qty'), _('Sales'), _('Cost'), _('Contribution'));
    if ($fromcust != '') {
        $headers[2] = '';
    }
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => ''), 4 => array('text' => _('Customer'), 'from' => $fromc, 'to' => ''));
    $rep = new FrontReport(_('Inventory Sales Report'), "InventorySalesReport", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $res = getTransactions($category, $location, $fromcust, $from, $to);
    $total = $grandtotal = 0.0;
    $total1 = $grandtotal1 = 0.0;
    $total2 = $grandtotal2 = 0.0;
    $catt = '';
    while ($trans = db_fetch($res)) {
        if ($catt != $trans['cat_description']) {
            if ($catt != '') {
                $rep->NewLine(2, 3);
                $rep->TextCol(0, 4, _('Total'));
                $rep->AmountCol(4, 5, $total, $dec);
                $rep->AmountCol(5, 6, $total1, $dec);
                $rep->AmountCol(6, 7, $total2, $dec);
                $rep->Line($rep->row - 2);
                $rep->NewLine();
                $rep->NewLine();
                $total = $total1 = $total2 = 0.0;
            }
            $rep->TextCol(0, 1, $trans['category_id']);
            $rep->TextCol(1, 6, $trans['cat_description']);
            $catt = $trans['cat_description'];
            $rep->NewLine();
        }
        $curr = get_customer_currency($trans['debtor_no']);
        $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['tran_date']));
        $trans['amt'] *= $rate;
        $cb = $trans['amt'] - $trans['cost'];
        $rep->NewLine();
        $rep->fontSize -= 2;
        $rep->TextCol(0, 1, $trans['stock_id']);
        if ($fromcust == ALL_TEXT) {
            $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1);
            $rep->TextCol(2, 3, $trans['debtor_name']);
        } else {
            $rep->TextCol(1, 3, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1);
        }
        $rep->AmountCol(3, 4, $trans['qty'], get_qty_dec($trans['stock_id']));
        $rep->AmountCol(4, 5, $trans['amt'], $dec);
        $rep->AmountCol(5, 6, $trans['cost'], $dec);
        $rep->AmountCol(6, 7, $cb, $dec);
        $rep->fontSize += 2;
        $total += $trans['amt'];
        $total1 += $trans['cost'];
        $total2 += $cb;
        $grandtotal += $trans['amt'];
        $grandtotal1 += $trans['cost'];
        $grandtotal2 += $cb;
    }
    $rep->NewLine(2, 3);
    $rep->TextCol(0, 4, _('Total'));
    $rep->AmountCol(4, 5, $total, $dec);
    $rep->AmountCol(5, 6, $total1, $dec);
    $rep->AmountCol(6, 7, $total2, $dec);
    $rep->Line($rep->row - 2);
    $rep->NewLine();
    $rep->NewLine(2, 1);
    $rep->TextCol(0, 4, _('Grand Total'));
    $rep->AmountCol(4, 5, $grandtotal, $dec);
    $rep->AmountCol(5, 6, $grandtotal1, $dec);
    $rep->AmountCol(6, 7, $grandtotal2, $dec);
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}