start_table(TABLESTYLE, "width=70%");
$th = array(_("Description"), _("Template No"), _("Customer"), _("Branch") . "/" . _("Group"), _("Days"), _("Monthly"), _("Begin"), _("End"), _("Last Created"), "", "");
table_header($th);
$k = 0;
while ($myrow = db_fetch($result)) {
    $begin = sql2date($myrow["begin"]);
    $end = sql2date($myrow["end"]);
    $last_sent = $myrow["last_sent"] == '0000-00-00' ? '' : sql2date($myrow["last_sent"]);
    alt_table_row_color($k);
    label_cell($myrow["description"]);
    label_cell(get_customer_trans_view_str(ST_SALESORDER, $myrow["order_no"]));
    if ($myrow["debtor_no"] == 0) {
        label_cell("");
        label_cell(get_sales_group_name($myrow["group_no"]));
    } else {
        label_cell(get_customer_name($myrow["debtor_no"]));
        label_cell(get_branch_name($myrow['group_no']));
    }
    label_cell($myrow["days"]);
    label_cell($myrow['monthly']);
    label_cell($begin);
    label_cell($end);
    label_cell($last_sent);
    edit_button_cell("Edit" . $myrow["id"], _("Edit"));
    delete_button_cell("Delete" . $myrow["id"], _("Delete"));
    end_row();
}
end_table();
end_form();
echo '<br>';
//-------------------------------------------------------------------------------------------------
function print_royalty_sales()
{
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $item = $_POST['PARAM_2'];
    $status = $_POST['PARAM_3'];
    $destination = $_POST['PARAM_4'];
    $orientation = $_POST['PARAM_5'];
    global $path_to_root, $systypes_array;
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $result = fetchRoyalty($item);
    $name = "";
    while ($book = db_fetch($result)) {
        $name = $book[1];
    }
    $params = array(0 => $comments, 1 => array('text' => _('Item'), 'from' => $name));
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $cols = array(0, 200, 210, 300, 310, 360, 380, 430, 440, 490, 500, 550);
    $headers = array(_('Client'), '', _('IMC'), '', _('Invoice/CM #'), '', _('Date'), '', _('Quantity'), '', _('Status'));
    $aligns = array('left', 'left', 'left', 'left', 'right', 'right');
    $usr = get_user($user);
    $user_id = $usr['user_id'];
    $rep = new FrontReport(_('Royalty Sales'), "RoyaltySales", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->SetHeaderType('Header');
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    if ($item == '') {
        $no_title_print = false;
        $enter = true;
    } else {
        $no_title_print = true;
        $enter = false;
    }
    if ($no_title_print) {
        $rep->Font('bold');
        $rep->TextCol(0, 1, $item);
        $rep->TextCol(2, 10, fetchTitle($item));
        $rep->Font();
    }
    $total = 0;
    $total_invoice_qty = 0;
    $total_credit_qty = 0;
    $rep->NewLine();
    if ($item == "") {
        $code = array();
        $ItemCode = fetchItemCode();
        while ($r = db_fetch($ItemCode)) {
            array_push($code, $r[0]);
        }
        $total = 0;
        $total_invoice_qty = 0;
        $total_credit_qty = 0;
        foreach ($code as $codes) {
            $result = fetchRoyalty($codes, $status, $from, $to);
            $bookname = fetchTitle($codes);
            $rep->Font('bold');
            $rep->TextCol(0, 5, $codes . "-" . $bookname);
            $rep->Font();
            $rep->NewLine();
            while ($myrow = db_fetch($result)) {
                if ($myrow['alloc'] == $myrow['ov_amount']) {
                    $stat = 'Closed';
                }
                if ($myrow['alloc'] < $myrow['ov_amount']) {
                    $stat = 'Open';
                }
                $scode = get_code($myrow['salesman']);
                $salesman = get_salesman_name($myrow['salesman']);
                $total_invoice_qty += $myrow[3];
                $clientName = get_customer_name($myrow[0]);
                $rep->TextCol(0, 1, $clientName);
                $rep->TextCol(2, 3, $scode);
                $rep->TextCol(4, 5, '  ' . $myrow['customized_no']);
                $rep->TextCol(6, 7, $myrow['tranDate']);
                $rep->TextCol(8, 9, $myrow['quantity']);
                $rep->TextCol(10, 11, $stat);
                $rep->NewLine();
            }
            $result1 = fetchCreditMemo($codes, $status, $from, $to);
            while ($myrow1 = db_fetch($result1)) {
                if ($myrow1[3] > 0) {
                    if ($myrow1['alloc'] == $myrow1['ov_amount']) {
                        $stat = 'Closed';
                    }
                    if ($myrow1['alloc'] < $myrow1['ov_amount']) {
                        $stat = 'Open';
                    }
                }
                $qty = -$myrow1['quantity'];
                $total_credit_qty += $qty;
                $scode = get_code($myrow1['salesman']);
                $clientName2 = get_customer_name($myrow1[0]);
                $rep->TextCol(0, 1, $clientName2);
                $rep->TextCol(2, 3, $scode);
                $rep->TextCol(4, 5, '  ' . $myrow1['customized_no']);
                $rep->TextCol(6, 7, $myrow1['tranDate']);
                $rep->TextCol(8, 9, $qty);
                $rep->TextCol(10, 11, $stat);
                $rep->NewLine();
            }
            $rep->NewLine(1);
            $total = $total_invoice_qty + $total_credit_qty;
            $rep->Font('bold');
            $rep->TextCol(6, 7, _("Total"));
            $rep->TextCol(8, 9, $total);
            $rep->Line($rep->row + 10);
            $rep->Font();
            $rep->NewLine();
            $total = 0;
            $total_invoice_qty = 0;
            $total_credit_qty = 0;
        }
    } else {
        $result = fetchRoyalty($item, $status, $from, $to);
        while ($myrow = db_fetch($result)) {
            if ($myrow['alloc'] == $myrow['ov_amount']) {
                $stat = 'Closed';
            }
            if ($myrow['alloc'] < $myrow['ov_amount']) {
                $stat = 'Open';
            }
            $scode = get_code($myrow['salesman']);
            $salesman = get_salesman_name($myrow['salesman']);
            $total_invoice_qty += $myrow[3];
            $clientName = get_customer_name($myrow[0]);
            $rep->TextCol(0, 1, $clientName);
            $rep->TextCol(2, 3, $scode);
            $rep->TextCol(4, 5, '  ' . $myrow['customized_no']);
            $rep->TextCol(6, 7, $myrow['tranDate']);
            $rep->TextCol(8, 9, $myrow['quantity']);
            $rep->TextCol(10, 11, $stat);
            $rep->NewLine();
        }
        $result1 = fetchCreditMemo($item, $status, $from, $to);
        while ($myrow1 = db_fetch($result1)) {
            if ($myrow1[3] > 0) {
                if ($myrow1['alloc'] == $myrow1['ov_amount']) {
                    $stat = 'Closed';
                }
                if ($myrow1['alloc'] < $myrow1['ov_amount']) {
                    $stat = 'Open';
                }
                $qty = -$myrow1['quantity'];
                $total_credit_qty += $qty;
                $scode = get_code($myrow1['salesman']);
                $clientName2 = get_customer_name($myrow1[0]);
                $rep->TextCol(0, 1, $clientName2);
                $rep->TextCol(2, 3, $scode);
                $rep->TextCol(4, 5, '  ' . $myrow1['customized_no']);
                $rep->TextCol(6, 7, $myrow1['tranDate']);
                $rep->TextCol(8, 9, $qty);
                $rep->TextCol(10, 11, $stat);
                $rep->NewLine();
            }
        }
        $rep->NewLine(1);
        $total = $total_invoice_qty + $total_credit_qty;
        $rep->Font('bold');
        $rep->TextCol(6, 7, _("Total"));
        $rep->TextCol(8, 9, $total);
        $rep->Line($rep->row + 10);
        $rep->NewLine();
        $total = 0;
        $total_invoice_qty = 0;
        $total_credit_qty = 0;
    }
    $rep->End();
}
function client_view($row)
{
    return get_customer_name($row['client']);
}
Example #4
0
function print_order_status_list()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $from = $_REQUEST['PARAM_0'];
    $to = $_REQUEST['PARAM_1'];
    $category = $_REQUEST['PARAM_2'];
    $location = $_REQUEST['PARAM_3'];
    $backorder = $_REQUEST['PARAM_4'];
    $comments = $_REQUEST['PARAM_5'];
    $dec = user_qty_dec();
    if ($category == reserved_words::get_all_numeric()) {
        $category = 0;
    }
    if ($location == reserved_words::get_all()) {
        $location = null;
    }
    if ($category == 0) {
        $cat = tr('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == null) {
        $loc = tr('All');
    } else {
        $loc = $location;
    }
    if ($backorder == 0) {
        $back = tr('All Orders');
    } else {
        $back = tr('Back Orders Only');
    }
    $cols = array(0, 60, 150, 260, 325, 385, 450, 515);
    $headers2 = array(tr('Order'), tr('Customer'), tr('Branch'), tr('Customer Ref'), tr('Ord Date'), tr('Del Date'), tr('Loc'));
    $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right');
    $headers = array(tr('Code'), tr('Description'), tr('Ordered'), tr('Invoiced'), tr('Outstanding'), '');
    $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => tr('Location'), 'from' => $loc, 'to' => ''), 4 => array('text' => tr('Selection'), 'from' => $back, 'to' => ''));
    $cols2 = $cols;
    $aligns2 = $aligns;
    $rep = new FrontReport(tr('Order Status Listing'), "OrderStatusListing.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2);
    $rep->Header();
    $orderno = 0;
    $result = GetSalesOrders($from, $to, $category, $location, $backorder);
    while ($myrow = db_fetch($result)) {
        if ($rep->row < $rep->bottomMargin + 2 * $rep->lineHeight) {
            $orderno = 0;
            $rep->Header();
        }
        $rep->NewLine(0, 2, false, $orderno);
        if ($orderno != $myrow['order_no']) {
            if ($orderno != 0) {
                $rep->Line($rep->row);
                $rep->NewLine();
            }
            $rep->TextCol(0, 1, $myrow['order_no']);
            $rep->TextCol(1, 2, get_customer_name($myrow['debtor_no']));
            $rep->TextCol(2, 3, get_branch_name($myrow['branch_code']));
            $rep->TextCol(3, 4, $myrow['customer_ref']);
            $rep->TextCol(4, 5, sql2date($myrow['ord_date']));
            $rep->TextCol(5, 6, sql2date($myrow['delivery_date']));
            $rep->TextCol(6, 7, $myrow['from_stk_loc']);
            $rep->NewLine(2);
            $orderno = $myrow['order_no'];
        }
        $rep->TextCol(0, 1, $myrow['stk_code']);
        $rep->TextCol(1, 2, $myrow['description']);
        $rep->TextCol(2, 3, number_format2($myrow['quantity'], $dec));
        $rep->TextCol(3, 4, number_format2($myrow['qty_sent'], $dec));
        $rep->TextCol(4, 5, number_format2($myrow['quantity'] - $myrow['qty_sent'], $dec));
        if ($myrow['quantity'] - $myrow['qty_sent'] > 0) {
            $rep->Font('italic');
            $rep->TextCol(5, 6, tr('Outstanding'));
            $rep->Font();
        }
        $rep->NewLine();
        if ($rep->row < $rep->bottomMargin + 2 * $rep->lineHeight) {
            $orderno = 0;
            $rep->Header();
        }
    }
    $rep->Line($rep->row);
    $rep->End();
}
Example #5
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();
}
Example #6
0
function print_customer_balances()
{
    global $path_to_root, $systypes_array;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $fromcust = $_POST['PARAM_2'];
    $show_balance = $_POST['PARAM_3'];
    $currency = $_POST['PARAM_4'];
    $no_zeros = $_POST['PARAM_5'];
    $comments = $_POST['PARAM_6'];
    $orientation = $_POST['PARAM_7'];
    $destination = $_POST['PARAM_8'];
    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';
    if ($fromcust == ALL_TEXT) {
        $cust = _('All');
    } else {
        $cust = get_customer_name($fromcust);
    }
    $dec = user_price_dec();
    if ($currency == ALL_TEXT) {
        $convert = true;
        $currency = _('Balances in Home Currency');
    } else {
        $convert = false;
    }
    if ($no_zeros) {
        $nozeros = _('Yes');
    } else {
        $nozeros = _('No');
    }
    $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515);
    $headers = array(_('Trans Type'), _('#'), _('Date'), _('Due Date'), _('Charges'), _('Credits'), _('Allocated'), _('Outstanding'));
    if ($show_balance) {
        $headers[7] = _('Balance');
    }
    $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Customer'), 'from' => $cust, 'to' => ''), 3 => array('text' => _('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => ''));
    $rep = new FrontReport(_('Customer Balances'), "CustomerBalances", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $grandtotal = array(0, 0, 0, 0);
    $sql = "SELECT debtor_no, name, curr_code FROM " . TB_PREF . "debtors_master ";
    if ($fromcust != ALL_TEXT) {
        $sql .= "WHERE debtor_no=" . db_escape($fromcust);
    }
    $sql .= " ORDER BY name";
    $result = db_query($sql, "The customers could not be retrieved");
    while ($myrow = db_fetch($result)) {
        if (!$convert && $currency != $myrow['curr_code']) {
            continue;
        }
        $accumulate = 0;
        $rate = $convert ? get_exchange_rate_from_home_currency($myrow['curr_code'], Today()) : 1;
        $bal = get_open_balance($myrow['debtor_no'], $from, $convert);
        $init[0] = $init[1] = 0.0;
        $init[0] = round2(abs($bal['charges'] * $rate), $dec);
        $init[1] = round2(Abs($bal['credits'] * $rate), $dec);
        $init[2] = round2($bal['Allocated'] * $rate, $dec);
        if ($show_balance) {
            $init[3] = $init[0] - $init[1];
            $accumulate += $init[3];
        } else {
            $init[3] = round2($bal['OutStanding'] * $rate, $dec);
        }
        $res = get_transactions($myrow['debtor_no'], $from, $to);
        if ($no_zeros && db_num_rows($res) == 0) {
            continue;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 2, $myrow['name']);
        if ($convert) {
            $rep->TextCol(2, 3, $myrow['curr_code']);
        }
        $rep->fontSize -= 2;
        $rep->TextCol(3, 4, _("Open Balance"));
        $rep->AmountCol(4, 5, $init[0], $dec);
        $rep->AmountCol(5, 6, $init[1], $dec);
        $rep->AmountCol(6, 7, $init[2], $dec);
        $rep->AmountCol(7, 8, $init[3], $dec);
        $total = array(0, 0, 0, 0);
        for ($i = 0; $i < 4; $i++) {
            $total[$i] += $init[$i];
            $grandtotal[$i] += $init[$i];
        }
        $rep->NewLine(1, 2);
        $rep->Line($rep->row + 4);
        if (db_num_rows($res) == 0) {
            $rep->NewLine(1, 2);
            continue;
        }
        while ($trans = db_fetch($res)) {
            if ($no_zeros && floatcmp($trans['TotalAmount'], $trans['Allocated']) == 0) {
                continue;
            }
            $rep->NewLine(1, 2);
            $rep->TextCol(0, 1, $systypes_array[$trans['type']]);
            $rep->TextCol(1, 2, $trans['reference']);
            $rep->DateCol(2, 3, $trans['tran_date'], true);
            if ($trans['type'] == ST_SALESINVOICE) {
                $rep->DateCol(3, 4, $trans['due_date'], true);
            }
            $item[0] = $item[1] = 0.0;
            if ($trans['type'] == ST_CUSTCREDIT || $trans['type'] == ST_CUSTPAYMENT || $trans['type'] == ST_BANKDEPOSIT) {
                $trans['TotalAmount'] *= -1;
            }
            if ($trans['TotalAmount'] > 0.0) {
                $item[0] = round2(abs($trans['TotalAmount']) * $rate, $dec);
                $rep->AmountCol(4, 5, $item[0], $dec);
                $accumulate += $item[0];
            } else {
                $item[1] = round2(Abs($trans['TotalAmount']) * $rate, $dec);
                $rep->AmountCol(5, 6, $item[1], $dec);
                $accumulate -= $item[1];
            }
            $item[2] = round2($trans['Allocated'] * $rate, $dec);
            $rep->AmountCol(6, 7, $item[2], $dec);
            if ($trans['type'] == ST_SALESINVOICE || $trans['type'] == ST_BANKPAYMENT) {
                $item[3] = $item[0] + $item[1] - $item[2];
            } else {
                $item[3] = $item[0] - $item[1] + $item[2];
            }
            if ($show_balance) {
                $rep->AmountCol(7, 8, $accumulate, $dec);
            } else {
                $rep->AmountCol(7, 8, $item[3], $dec);
            }
            for ($i = 0; $i < 4; $i++) {
                $total[$i] += $item[$i];
                $grandtotal[$i] += $item[$i];
            }
            if ($show_balance) {
                $total[3] = $total[0] - $total[1];
            }
        }
        $rep->Line($rep->row - 8);
        $rep->NewLine(2);
        $rep->TextCol(0, 3, _('Total'));
        for ($i = 0; $i < 4; $i++) {
            $rep->AmountCol($i + 4, $i + 5, $total[$i], $dec);
        }
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, _('Grand Total'));
    $rep->fontSize -= 2;
    if ($show_balance) {
        $grandtotal[3] = $grandtotal[0] - $grandtotal[1];
    }
    for ($i = 0; $i < 4; $i++) {
        $rep->AmountCol($i + 4, $i + 5, $grandtotal[$i], $dec);
    }
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Example #7
0
function print_order_status_list()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $category = $_POST['PARAM_2'];
    $location = $_POST['PARAM_3'];
    $backorder = $_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';
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($location == ALL_TEXT) {
        $location = null;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == null) {
        $loc = _('All');
    } else {
        $loc = get_location_name($location);
    }
    if ($backorder == 0) {
        $back = _('All Orders');
    } else {
        $back = _('Back Orders Only');
    }
    $cols = array(0, 60, 150, 260, 325, 385, 450, 515);
    $headers2 = array(_('Order'), _('Customer'), _('Branch'), _('Customer Ref'), _('Ord Date'), _('Del Date'), _('Loc'));
    $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right');
    $headers = array(_('Code'), _('Description'), _('Ordered'), _('Delivered'), _('Outstanding'), '');
    $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' => _('Selection'), 'from' => $back, 'to' => ''));
    $aligns2 = $aligns;
    $rep = new FrontReport(_('Order Status Listing'), "OrderStatusListing", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $cols2 = $cols;
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2);
    $rep->NewPage();
    $orderno = 0;
    $result = GetSalesOrders($from, $to, $category, $location, $backorder);
    while ($myrow = db_fetch($result)) {
        $rep->NewLine(0, 2, false, $orderno);
        if ($orderno != $myrow['order_no']) {
            if ($orderno != 0) {
                $rep->Line($rep->row);
                $rep->NewLine();
            }
            $rep->TextCol(0, 1, $myrow['order_no']);
            $rep->TextCol(1, 2, get_customer_name($myrow['debtor_no']));
            $rep->TextCol(2, 3, get_branch_name($myrow['branch_code']));
            $rep->TextCol(3, 4, $myrow['customer_ref']);
            $rep->DateCol(4, 5, $myrow['ord_date'], true);
            $rep->DateCol(5, 6, $myrow['delivery_date'], true);
            $rep->TextCol(6, 7, $myrow['from_stk_loc']);
            $rep->NewLine(2);
            $orderno = $myrow['order_no'];
        }
        $rep->TextCol(0, 1, $myrow['stk_code']);
        $rep->TextCol(1, 2, $myrow['description']);
        $dec = get_qty_dec($myrow['stk_code']);
        $rep->AmountCol(2, 3, $myrow['quantity'], $dec);
        $rep->AmountCol(3, 4, $myrow['qty_sent'], $dec);
        $rep->AmountCol(4, 5, $myrow['quantity'] - $myrow['qty_sent'], $dec);
        if ($myrow['quantity'] - $myrow['qty_sent'] > 0) {
            $rep->Font('italic');
            $rep->TextCol(5, 6, _('Outstanding'));
            $rep->Font();
        }
        $rep->NewLine();
    }
    $rep->Line($rep->row);
    $rep->End();
}
Example #8
0
function print_voucher()
{
    global $path_to_root, $systypes_array;
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    $voucher_no = $_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_report2.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $rep = new FrontReport(_('COMMISSION VOUCHER'), "CommissionVoucherReport", user_pagesize(), 9, $orientation);
    $dec = user_price_dec();
    $cols = array(-15, 20, 40, 60, 90, 150, 200, 225, 220, 465, 525);
    //------------0--1---2---3----4----5----6----7----8----9----10-------
    //-----------------------dim1-dim2-----------------------------------
    //-----------------------dim1----------------------------------------
    //-------------------------------------------------------------------
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right', 'right', 'right');
    $headers = array('', _('Commission Voucher'), '', '', '', '', '');
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->SetHeaderType(0);
    $rep->Font();
    $rep->Info(null, $cols, null, $aligns);
    $rep->NewPage();
    $res = get_transaction($voucher_no);
    $myrow = db_fetch($res);
    $salesman = get_salesman_name($myrow['imc']);
    $client = get_customer_name($myrow['client']);
    $rep->Font('bold');
    // $rep->TextCol(4,8, _("ST. MATTHEW'S PUBLISHING CORPORATION"));
    $rep->Font();
    $rep->NewLine();
    // $rep->TextCol(4,8, _("Tel. Nos. 426-5611 * 433-5385 Telefax: 426-1274"));
    $rep->NewLine(5);
    $rep->Font('bold');
    $rep->SetFontSize(14);
    //$rep->TextCol(0,3, _("COMMISSION VOUCHER"));
    $rep->Font();
    $rep->SetFontSize(10);
    $rep->NewLine(4);
    $netgross = $myrow['gross'] * ($myrow['commission'] / 100);
    //$rep->TextCol(8,9, _("Date:"));
    $rep->TextCol(5, 6, $myrow['Dated']);
    $year = substr($myrow['dateYear'], 2);
    $rep->TextCol(6, 7, $year);
    $rep->NewLine(1);
    $rep->TextCol(1, 4, $salesman);
    $rep->NewLine(3);
    //$rep->Line($rep->row  - -10);
    //$rep->TextCol(2,5, _("EXPLANATION"));
    //$rep->TextCol(8,9, _("AMOUNT"));
    // $rep->Line($rep->row  - 4);
    $rep->NewLine(2);
    $rep->SetFontSize('8');
    $oldrow = $rep->row;
    $rep->TextColLines(2, 5, $client);
    $newrow = $rep->row;
    $rep->row = $oldrow;
    $rep->NewLine(3);
    $rep->SetFontSize('10');
    //$rep->TextCol(8,9, _("Gross: "));
    $rep->AmountCol(5, 7, $netgross, 2);
    $rep->NewLine(1);
    $rep->TextCol(2, 4, $myrow['commission']);
    $rep->AmountCol(5, 7, $myrow['with_tax'], 2);
    $rep->NewLine(2);
    $rep->TextCol(2, 4, $myrow['invoice_no']);
    $rep->NewLine(4);
    $rep->Font('bold');
    $rep->AmountCol(5, 7, $myrow['net_commission'], 2);
    $rep->NewLine();
    // $rep->Line($rep->row  - 4);
    // $rep->Line($rep->row  - 8);
    $rep->NewLine(3);
    $rep->Font();
    $rep->SetFontSize('9');
    //$rep->TextCol(1,4, _("Approved by:"));
    // $rep->TextCol(5,8, _("Received payment by:"));
    $rep->NewLine(2);
    $rep->TextCol(2, 4, _("Checked by:"));
    $rep->End();
}
Example #9
0
function print_aged_customer_analysis()
{
    global $path_to_root, $systypes_array;
    $to = $_POST['PARAM_0'];
    $fromcust = $_POST['PARAM_1'];
    $currency = $_POST['PARAM_2'];
    $show_all = $_POST['PARAM_3'];
    $summaryOnly = $_POST['PARAM_4'];
    $no_zeros = $_POST['PARAM_5'];
    $graphics = $_POST['PARAM_6'];
    $comments = $_POST['PARAM_7'];
    $orientation = $_POST['PARAM_8'];
    $destination = $_POST['PARAM_9'];
    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';
    if ($graphics) {
        include_once $path_to_root . "/reporting/includes/class.graphic.inc";
        $pg = new graph();
    }
    if ($fromcust == ALL_TEXT) {
        $from = _('All');
    } else {
        $from = get_customer_name($fromcust);
    }
    $dec = user_price_dec();
    if ($summaryOnly == 1) {
        $summary = _('Summary Only');
    } else {
        $summary = _('Detailed Report');
    }
    if ($currency == ALL_TEXT) {
        $convert = true;
        $currency = _('Balances in Home Currency');
    } else {
        $convert = false;
    }
    if ($no_zeros) {
        $nozeros = _('Yes');
    } else {
        $nozeros = _('No');
    }
    if ($show_all) {
        $show = _('Yes');
    } else {
        $show = _('No');
    }
    $PastDueDays1 = get_company_pref('past_due_days');
    $PastDueDays2 = 2 * $PastDueDays1;
    $nowdue = "1-" . $PastDueDays1 . " " . _('Days');
    $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . _('Days');
    $pastdue2 = _('Over') . " " . $PastDueDays2 . " " . _('Days');
    $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515);
    $headers = array(_('Customer'), '', '', _('Current'), $nowdue, $pastdue1, $pastdue2, _('Total Balance'));
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => _('Customer'), 'from' => $from, 'to' => ''), 3 => array('text' => _('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => _('Type'), 'from' => $summary, 'to' => ''), 5 => array('text' => _('Show Also Allocated'), 'from' => $show, 'to' => ''), 6 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => ''));
    if ($convert) {
        $headers[2] = _('Currency');
    }
    $rep = new FrontReport(_('Aged Customer Analysis'), "AgedCustomerAnalysis", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $total = array(0, 0, 0, 0, 0);
    $sql = "SELECT debtor_no, name, curr_code FROM " . TB_PREF . "debtors_master";
    if ($fromcust != ALL_TEXT) {
        $sql .= " WHERE debtor_no=" . db_escape($fromcust);
    }
    $sql .= " ORDER BY name";
    $result = db_query($sql, "The customers could not be retrieved");
    while ($myrow = db_fetch($result)) {
        if (!$convert && $currency != $myrow['curr_code']) {
            continue;
        }
        if ($convert) {
            $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to);
        } else {
            $rate = 1.0;
        }
        $custrec = get_customer_details($myrow['debtor_no'], $to, $show_all);
        if (!$custrec) {
            continue;
        }
        $custrec['Balance'] *= $rate;
        $custrec['Due'] *= $rate;
        $custrec['Overdue1'] *= $rate;
        $custrec['Overdue2'] *= $rate;
        $str = array($custrec["Balance"] - $custrec["Due"], $custrec["Due"] - $custrec["Overdue1"], $custrec["Overdue1"] - $custrec["Overdue2"], $custrec["Overdue2"], $custrec["Balance"]);
        if ($no_zeros && floatcmp(array_sum($str), 0) == 0) {
            continue;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 2, $myrow['name']);
        if ($convert) {
            $rep->TextCol(2, 3, $myrow['curr_code']);
        }
        $rep->fontSize -= 2;
        $total[0] += $custrec["Balance"] - $custrec["Due"];
        $total[1] += $custrec["Due"] - $custrec["Overdue1"];
        $total[2] += $custrec["Overdue1"] - $custrec["Overdue2"];
        $total[3] += $custrec["Overdue2"];
        $total[4] += $custrec["Balance"];
        for ($i = 0; $i < count($str); $i++) {
            $rep->AmountCol($i + 3, $i + 4, $str[$i], $dec);
        }
        $rep->NewLine(1, 2);
        if (!$summaryOnly) {
            $res = get_invoices($myrow['debtor_no'], $to, $show_all);
            if (db_num_rows($res) == 0) {
                continue;
            }
            $rep->Line($rep->row + 4);
            while ($trans = db_fetch($res)) {
                $rep->NewLine(1, 2);
                $rep->TextCol(0, 1, $systypes_array[$trans['type']], -2);
                $rep->TextCol(1, 2, $trans['reference'], -2);
                $rep->DateCol(2, 3, $trans['tran_date'], true, -2);
                if ($trans['type'] == ST_CUSTCREDIT || $trans['type'] == ST_CUSTPAYMENT || $trans['type'] == ST_BANKDEPOSIT) {
                    $trans['Balance'] *= -1;
                    $trans['Due'] *= -1;
                    $trans['Overdue1'] *= -1;
                    $trans['Overdue2'] *= -1;
                }
                foreach ($trans as $i => $value) {
                    $trans[$i] *= $rate;
                }
                $str = array($trans["Balance"] - $trans["Due"], $trans["Due"] - $trans["Overdue1"], $trans["Overdue1"] - $trans["Overdue2"], $trans["Overdue2"], $trans["Balance"]);
                for ($i = 0; $i < count($str); $i++) {
                    $rep->AmountCol($i + 3, $i + 4, $str[$i], $dec);
                }
            }
            $rep->Line($rep->row - 8);
            $rep->NewLine(2);
        }
    }
    if ($summaryOnly) {
        $rep->Line($rep->row + 4);
        $rep->NewLine();
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, _('Grand Total'));
    $rep->fontSize -= 2;
    for ($i = 0; $i < count($total); $i++) {
        $rep->AmountCol($i + 3, $i + 4, $total[$i], $dec);
        if ($graphics && $i < count($total) - 1) {
            $pg->y[$i] = abs($total[$i]);
        }
    }
    $rep->Line($rep->row - 8);
    if ($graphics) {
        global $decseps, $graph_skin;
        $pg->x = array(_('Current'), $nowdue, $pastdue1, $pastdue2);
        $pg->title = $rep->title;
        $pg->axis_x = _("Days");
        $pg->axis_y = _("Amount");
        $pg->graphic_1 = $to;
        $pg->type = $graphics;
        $pg->skin = $graph_skin;
        $pg->built_in = false;
        $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".";
        $filename = company_path() . "/pdf_files/" . uniqid("") . ".png";
        $pg->display($filename, true);
        $w = $pg->width / 1.5;
        $h = $pg->height / 1.5;
        $x = ($rep->pageWidth - $w) / 2;
        $rep->NewLine(2);
        if ($rep->row - $h < $rep->bottomMargin) {
            $rep->NewPage();
        }
        $rep->AddImage($filename, $x, $rep->row - $h, $w, $h);
    }
    $rep->NewLine();
    $rep->End();
}
Example #10
0
function print_customer_balances()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $to = $_REQUEST['PARAM_0'];
    $fromcust = $_REQUEST['PARAM_1'];
    $currency = $_REQUEST['PARAM_2'];
    $comments = $_REQUEST['PARAM_3'];
    if ($fromcust == reserved_words::get_all_numeric()) {
        $from = tr('All');
    } else {
        $from = get_customer_name($fromcust);
    }
    $dec = user_price_dec();
    if ($currency == reserved_words::get_all()) {
        $convert = true;
        $currency = tr('Balances in Home Currency');
    } else {
        $convert = false;
    }
    $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515);
    $headers = array(tr('Trans Type'), tr('#'), tr('Date'), tr('Due Date'), tr('Charges'), tr('Credits'), tr('Allocated'), tr('Outstanding'));
    $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => tr('Customer'), 'from' => $from, 'to' => ''), 3 => array('text' => tr('Currency'), 'from' => $currency, 'to' => ''));
    $rep = new FrontReport(tr('Customer Balances'), "CustomerBalances.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $grandtotal = array(0, 0, 0, 0);
    $sql = "SELECT debtor_no, name, curr_code FROM debtors_master ";
    if ($fromcust != reserved_words::get_all_numeric()) {
        $sql .= "WHERE debtor_no={$fromcust} ";
    }
    $sql .= "ORDER BY name";
    $result = db_query($sql, "The customers could not be retrieved");
    while ($myrow = db_fetch($result)) {
        if (!$convert && $currency != $myrow['curr_code']) {
            continue;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 3, $myrow['name']);
        if ($convert) {
            $rep->TextCol(3, 4, $myrow['curr_code']);
        }
        $rep->fontSize -= 2;
        $rep->NewLine(1, 2);
        $res = get_transactions($myrow['debtor_no'], $to);
        if (db_num_rows($res) == 0) {
            continue;
        }
        $rep->Line($rep->row + 4);
        $total = array(0, 0, 0, 0);
        while ($trans = db_fetch($res)) {
            $rep->NewLine(1, 2);
            $rep->TextCol(0, 1, $trans['type_name']);
            $rep->TextCol(1, 2, $trans['reference']);
            $date = sql2date($trans['tran_date']);
            $rep->TextCol(2, 3, $date);
            if ($trans['type'] == 10) {
                $rep->TextCol(3, 4, sql2date($trans['due_date']));
            }
            $item[0] = $item[1] = 0.0;
            if ($convert) {
                $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date);
            } else {
                $rate = 1.0;
            }
            if ($trans['type'] == 11 || $trans['type'] == 12 || $trans['type'] == 2) {
                $trans['TotalAmount'] *= -1;
            }
            if ($trans['TotalAmount'] > 0.0) {
                $item[0] = abs($trans['TotalAmount']) * $rate;
                $rep->TextCol(4, 5, number_format2($item[0], $dec));
            } else {
                $item[1] = Abs($trans['TotalAmount']) * $rate;
                $rep->TextCol(5, 6, number_format2($item[1], $dec));
            }
            $item[2] = $trans['Allocated'] * $rate;
            $rep->TextCol(6, 7, number_format2($item[2], $dec));
            if ($trans['type'] == 10) {
                $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate;
            } else {
                $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate;
            }
            $rep->TextCol(7, 8, number_format2($item[3], $dec));
            for ($i = 0; $i < 4; $i++) {
                $total[$i] += $item[$i];
                $grandtotal[$i] += $item[$i];
            }
        }
        $rep->Line($rep->row - 8);
        $rep->NewLine(2);
        $rep->TextCol(0, 3, tr('Total'));
        for ($i = 0; $i < 4; $i++) {
            $rep->TextCol($i + 4, $i + 5, number_format2($total[$i], $dec));
        }
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, tr('Grand Total'));
    $rep->fontSize -= 2;
    for ($i = 0; $i < 4; $i++) {
        $rep->TextCol($i + 4, $i + 5, number_format2($grandtotal[$i], $dec));
    }
    $rep->Line($rep->row - 4);
    $rep->End();
}
Example #11
0
function print_aged_customer_analysis()
{
    global $comp_path, $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $to = $_REQUEST['PARAM_0'];
    $fromcust = $_REQUEST['PARAM_1'];
    $currency = $_REQUEST['PARAM_2'];
    $summaryOnly = $_REQUEST['PARAM_3'];
    $graphics = $_REQUEST['PARAM_4'];
    $comments = $_REQUEST['PARAM_5'];
    if ($graphics) {
        include_once $path_to_root . "reporting/includes/class.graphic.inc";
        $pg = new graph();
    }
    if ($fromcust == reserved_words::get_all_numeric()) {
        $from = tr('All');
    } else {
        $from = get_customer_name($fromcust);
    }
    $dec = user_price_dec();
    if ($summaryOnly == 1) {
        $summary = tr('Summary Only');
    } else {
        $summary = tr('Detailed Report');
    }
    if ($currency == reserved_words::get_all()) {
        $convert = true;
        $currency = tr('Balances in Home Currency');
    } else {
        $convert = false;
    }
    $PastDueDays1 = get_company_pref('past_due_days');
    $PastDueDays2 = 2 * $PastDueDays1;
    $nowdue = "1-" . $PastDueDays1 . " " . tr('Days');
    $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . tr('Days');
    $pastdue2 = tr('Over') . " " . $PastDueDays2 . " " . tr('Days');
    $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515);
    $headers = array(tr('Customer'), '', '', tr('Current'), $nowdue, $pastdue1, $pastdue2, tr('Total Balance'));
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => tr('Customer'), 'from' => $from, 'to' => ''), 3 => array('text' => tr('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => tr('Type'), 'from' => $summary, 'to' => ''));
    if ($convert) {
        $headers[2] = tr('Currency');
    }
    $rep = new FrontReport(tr('Aged Customer Analysis'), "AgedCustomerAnalysis.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $total = array(0, 0, 0, 0, 0);
    $sql = "SELECT debtor_no, name, curr_code FROM debtors_master ";
    if ($fromcust != reserved_words::get_all_numeric()) {
        $sql .= "WHERE debtor_no={$fromcust} ";
    }
    $sql .= "ORDER BY name";
    $result = db_query($sql, "The customers could not be retrieved");
    while ($myrow = db_fetch($result)) {
        if (!$convert && $currency != $myrow['curr_code']) {
            continue;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 3, $myrow['name']);
        if ($convert) {
            $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to);
            $rep->TextCol(2, 4, $myrow['curr_code']);
        } else {
            $rate = 1.0;
        }
        $rep->fontSize -= 2;
        $custrec = get_customer_details($myrow['debtor_no'], $to);
        foreach ($custrec as $i => $value) {
            $custrec[$i] *= $rate;
        }
        $total[0] += $custrec["Balance"] - $custrec["Due"];
        $total[1] += $custrec["Due"] - $custrec["Overdue1"];
        $total[2] += $custrec["Overdue1"] - $custrec["Overdue2"];
        $total[3] += $custrec["Overdue2"];
        $total[4] += $custrec["Balance"];
        $str = array(number_format2($custrec["Balance"] - $custrec["Due"], $dec), number_format2($custrec["Due"] - $custrec["Overdue1"], $dec), number_format2($custrec["Overdue1"] - $custrec["Overdue2"], $dec), number_format2($custrec["Overdue2"], $dec), number_format2($custrec["Balance"], $dec));
        for ($i = 0; $i < count($str); $i++) {
            $rep->TextCol($i + 3, $i + 4, $str[$i]);
        }
        $rep->NewLine(1, 2);
        if (!$summaryOnly) {
            $res = get_invoices($myrow['debtor_no'], $to);
            if (db_num_rows($res) == 0) {
                continue;
            }
            $rep->Line($rep->row + 4);
            while ($trans = db_fetch($res)) {
                $rep->NewLine(1, 2);
                $rep->TextCol(0, 1, $trans['type_name'], -2);
                $rep->TextCol(1, 2, $trans['reference'], -2);
                $rep->TextCol(2, 3, sql2date($trans['tran_date']), -2);
                if ($trans['type'] == 11 || $trans['type'] == 12 || $trans['type'] == 2) {
                    $trans['Balance'] *= -1;
                    $trans['Due'] *= -1;
                    $trans['Overdue1'] *= -1;
                    $trans['Overdue2'] *= -1;
                }
                foreach ($trans as $i => $value) {
                    $trans[$i] *= $rate;
                }
                $str = array(number_format2($trans["Balance"] - $trans["Due"], $dec), number_format2($trans["Due"] - $trans["Overdue1"], $dec), number_format2($trans["Overdue1"] - $trans["Overdue2"], $dec), number_format2($trans["Overdue2"], $dec), number_format2($trans["Balance"], $dec));
                for ($i = 0; $i < count($str); $i++) {
                    $rep->TextCol($i + 3, $i + 4, $str[$i]);
                }
            }
            $rep->Line($rep->row - 8);
            $rep->NewLine(2);
        }
    }
    if ($summaryOnly) {
        $rep->Line($rep->row + 4);
        $rep->NewLine();
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, tr('Grand Total'));
    $rep->fontSize -= 2;
    for ($i = 0; $i < count($total); $i++) {
        $rep->TextCol($i + 3, $i + 4, number_format2($total[$i], $dec));
        if ($graphics && $i < count($total) - 1) {
            $pg->y[$i] = abs($total[$i]);
        }
    }
    $rep->Line($rep->row - 8);
    if ($graphics) {
        global $decseps, $graph_skin;
        $pg->x = array(tr('Current'), $nowdue, $pastdue1, $pastdue2);
        $pg->title = $rep->title;
        $pg->axis_x = tr("Days");
        $pg->axis_y = tr("Amount");
        $pg->graphic_1 = $to;
        $pg->type = $graphics;
        $pg->skin = $graph_skin;
        $pg->built_in = false;
        $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf";
        $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".";
        $filename = $comp_path . '/' . user_company() . "/images/test.png";
        $pg->display($filename, true);
        $w = $pg->width / 1.5;
        $h = $pg->height / 1.5;
        $x = ($rep->pageWidth - $w) / 2;
        $rep->NewLine(2);
        if ($rep->row - $h < $rep->bottomMargin) {
            $rep->Header();
        }
        $rep->AddImage($filename, $x, $rep->row - $h, $w, $h);
    }
    $rep->End();
}
<?php

include "include/header_admin.php";
include "include/admin_menu.php";
?>
<div id="content6"> 
<table>
  <tr>
    <td>Name&nbsp;&nbsp;</td>
	<td><?php 
echo ucwords(get_customer_name($_GET['id']));
?>
</td>
   </tr>
  <tr>
    <td>Email&nbsp;&nbsp;</td>
    <td><?php 
echo ucwords(get_customer_email($_GET['id']));
?>
</td>
  </tr>
 
  <tr>
    <td>Mobile no.&nbsp;&nbsp;</td>
    <td><?php 
echo ucwords(get_customer_mobile($_GET['id']));
?>
</td>
   
  </tr>
  <tr>