function check_item_data() { global $SysPrefs, $allow_negative_prices; $is_inventory_item = is_inventory_item(get_post('stock_id')); if (!get_post('stock_id_text', true)) { display_error(_("Item description cannot be empty.")); set_focus('stock_id_edit'); return false; } elseif (!check_num('qty', 0) || !check_num('Disc', 0, 100)) { display_error(_("The item could not be updated because you are attempting to set the quantity ordered to less than 0, or the discount percent to more than 100.")); set_focus('qty'); return false; } elseif (!check_num('price', 0) && (!$allow_negative_prices || $is_inventory_item)) { display_error(_("Price for inventory item must be entered and can not be less than 0")); set_focus('price'); return false; } elseif (isset($_POST['LineNo']) && isset($_SESSION['Items']->line_items[$_POST['LineNo']]) && !check_num('qty', $_SESSION['Items']->line_items[$_POST['LineNo']]->qty_done)) { set_focus('qty'); display_error(_("You attempting to make the quantity ordered a quantity less than has already been delivered. The quantity delivered cannot be modified retrospectively.")); return false; } $cost_home = get_standard_cost(get_post('stock_id')); // Added 2011-03-27 Joe Hunt $cost = $cost_home / get_exchange_rate_from_home_currency($_SESSION['Items']->customer_currency, $_SESSION['Items']->document_date); if (input_num('price') < $cost) { $dec = user_price_dec(); $curr = $_SESSION['Items']->customer_currency; $price = number_format2(input_num('price'), $dec); if ($cost_home == $cost) { $std_cost = number_format2($cost_home, $dec); } else { $price = $curr . " " . $price; $std_cost = $curr . " " . number_format2($cost, $dec); } display_warning(sprintf(_("Price %s is below Standard Cost %s"), $price, $std_cost)); } return true; }
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(); }
function print_salesman_list() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; $summary = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; if ($summary == 0) { $sum = tr("No"); } else { $sum = tr("Yes"); } $dec = user_qty_dec(); $cols = array(0, 60, 150, 220, 325, 385, 450, 515); $headers = array(tr('Invoice'), tr('Customer'), tr('Branch'), tr('Customer Ref'), tr('Inv Date'), tr('Total'), tr('Provision')); $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right'); $headers2 = array(tr('Salesman'), " ", tr('Phone'), tr('Email'), tr('Provision'), tr('Break Pt.'), tr('Provision') . " 2"); $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Summary Only'), 'from' => $sum, 'to' => '')); $cols2 = $cols; $aligns2 = $aligns; $rep = new FrontReport(tr('Salesman Listing'), "SalesmanListing.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); $rep->Header(); $salesman = 0; $subtotal = $total = $subprov = $provtotal = 0; $result = GetSalesmanTrans($from, $to); while ($myrow = db_fetch($result)) { if ($rep->row < $rep->bottomMargin + 2 * $rep->lineHeight) { $salesman = 0; $rep->Header(); } $rep->NewLine(0, 2, false, $salesman); if ($salesman != $myrow['salesman_code']) { if ($salesman != 0) { $rep->Line($rep->row - 8); $rep->NewLine(2); $rep->TextCol(0, 3, tr('Total')); $rep->TextCol(5, 6, number_format2($subtotal, $dec)); $rep->TextCol(6, 7, number_format2($subprov, $dec)); $rep->Line($rep->row - 4); $rep->NewLine(2); //$rep->Line($rep->row); } $rep->TextCol(0, 2, $myrow['salesman_code'] . " " . $myrow['salesman_name']); $rep->TextCol(2, 3, $myrow['salesman_phone']); $rep->TextCol(3, 4, $myrow['salesman_email']); $rep->TextCol(4, 5, number_format2($myrow['provision'], user_percent_dec()) . " %"); $rep->TextCol(5, 6, number_format2($myrow['break_pt'], $dec)); $rep->TextCol(6, 7, number_format2($myrow['provision2'], user_percent_dec()) . " %"); $rep->NewLine(2); $salesman = $myrow['salesman_code']; $total += $subtotal; $provtotal += $subprov; $subtotal = 0; $subprov = 0; } $date = sql2date($myrow['tran_date']); $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date); $amt = $myrow['InvoiceTotal'] * $rate; if ($subprov > $myrow['break_pt'] && $myrow['provision2'] != 0) { $prov = $myrow['provision2'] * $amt / 100; } else { $prov = $myrow['provision'] * $amt / 100; } if (!$summary) { $rep->TextCol(0, 1, $myrow['trans_no']); $rep->TextCol(1, 2, $myrow['DebtorName']); $rep->TextCol(2, 3, $myrow['br_name']); $rep->TextCol(3, 4, $myrow['contact_name']); $rep->TextCol(4, 5, $date); $rep->TextCol(5, 6, number_format2($amt, $dec)); $rep->TextCol(6, 7, number_format2($prov, $dec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 2 * $rep->lineHeight) { $salesman = 0; $rep->Header(); } } $subtotal += $amt; $subprov += $prov; } if ($salesman != 0) { $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 3, tr('Total')); $rep->TextCol(5, 6, number_format2($subtotal, $dec)); $rep->TextCol(6, 7, number_format2($subprov, $dec)); $rep->Line($rep->row - 4); $rep->NewLine(2); //$rep->Line($rep->row); $total += $subtotal; $provtotal += $subprov; } $rep->fontSize += 2; $rep->TextCol(0, 3, tr('Grand Total')); $rep->fontSize -= 2; $rep->TextCol(5, 6, number_format2($total, $dec)); $rep->TextCol(6, 7, number_format2($provtotal, $dec)); $rep->Line($rep->row - 4); $rep->End(); }
function print_inventory_purchase() { global $path_to_root; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $category = $_POST['PARAM_2']; $location = $_POST['PARAM_3']; $fromsupp = $_POST['PARAM_4']; $item = $_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'; $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 ($fromsupp == '') { $froms = _('All'); } else { $froms = get_supplier_name($fromsupp); } if ($item == '') { $itm = _('All'); } else { $itm = $item; } $cols = array(0, 60, 180, 225, 275, 400, 420, 465, 520); $headers = array(_('Category'), _('Description'), _('Date'), _('#'), _('Supplier'), _('Qty'), _('Unit Price'), _('Total')); if ($fromsupp != '') { $headers[4] = ''; } $aligns = array('left', 'left', 'left', 'left', 'left', 'left', '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' => _('Supplier'), 'from' => $froms, 'to' => ''), 5 => array('text' => _('Item'), 'from' => $itm, 'to' => '')); $rep = new FrontReport(_('Inventory Purchasing Report'), "InventoryPurchasingReport", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $res = getTransactions($category, $location, $fromsupp, $item, $from, $to); $total = $total_supp = $grandtotal = 0.0; $total_qty = 0.0; $catt = $stock_description = $stock_id = $supplier_name = ''; while ($trans = db_fetch($res)) { if ($stock_description != $trans['description']) { if ($stock_description != '') { if ($supplier_name != '') { $rep->NewLine(2, 3); $rep->TextCol(0, 1, _('Total')); $rep->TextCol(1, 4, $stock_description); $rep->TextCol(4, 5, $supplier_name); $rep->AmountCol(5, 7, $total_qty, get_qty_dec($stock_id)); $rep->AmountCol(7, 8, $total_supp, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $total_supp = $total_qty = 0.0; $supplier_name = $trans['supplier_name']; } } $stock_id = $trans['stock_id']; $stock_description = $trans['description']; } if ($supplier_name != $trans['supplier_name']) { if ($supplier_name != '') { $rep->NewLine(2, 3); $rep->TextCol(0, 1, _('Total')); $rep->TextCol(1, 4, $stock_description); $rep->TextCol(4, 5, $supplier_name); $rep->AmountCol(5, 7, $total_qty, get_qty_dec($stock_id)); $rep->AmountCol(7, 8, $total_supp, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $total_supp = $total_qty = 0.0; } $supplier_name = $trans['supplier_name']; } if ($catt != $trans['cat_description']) { if ($catt != '') { $rep->NewLine(2, 3); $rep->TextCol(0, 1, _('Total')); $rep->TextCol(1, 7, $catt); $rep->AmountCol(7, 8, $total, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $rep->NewLine(); $total = 0.0; } $rep->TextCol(0, 1, $trans['category_id']); $rep->TextCol(1, 6, $trans['cat_description']); $catt = $trans['cat_description']; $rep->NewLine(); } $curr = get_supplier_currency($trans['supplier_id']); $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['tran_date'])); $trans['price'] *= $rate; $rep->NewLine(); $trans['supp_reference'] = get_supp_inv_reference($trans['supplier_id'], $trans['stock_id'], $trans['tran_date']); $rep->fontSize -= 2; $rep->TextCol(0, 1, $trans['stock_id']); if ($fromsupp == ALL_TEXT) { $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1); $rep->TextCol(2, 3, sql2date($trans['tran_date'])); $rep->TextCol(3, 4, $trans['supp_reference']); $rep->TextCol(4, 5, $trans['supplier_name']); } else { $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1); $rep->TextCol(2, 3, sql2date($trans['tran_date'])); $rep->TextCol(3, 4, $trans['supp_reference']); } $rep->AmountCol(5, 6, $trans['qty'], get_qty_dec($trans['stock_id'])); $rep->AmountCol(6, 7, $trans['price'], $dec); $amt = $trans['qty'] * $trans['price']; $rep->AmountCol(7, 8, $amt, $dec); $rep->fontSize += 2; $total += $amt; $total_supp += $amt; $grandtotal += $amt; $total_qty += $trans['qty']; } if ($stock_description != '') { if ($supplier_name != '') { $rep->NewLine(2, 3); $rep->TextCol(0, 1, _('Total')); $rep->TextCol(1, 4, $stock_description); $rep->TextCol(4, 5, $supplier_name); $rep->AmountCol(5, 7, $total_qty, get_qty_dec($stock_id)); $rep->AmountCol(7, 8, $total_supp, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $rep->NewLine(); $total_supp = $total_qty = 0.0; $supplier_name = $trans['supplier_name']; } } if ($supplier_name != '') { $rep->NewLine(2, 3); $rep->TextCol(0, 1, _('Total')); $rep->TextCol(1, 4, $stock_description); $rep->TextCol(4, 5, $supplier_name); $rep->AmountCol(5, 7, $total_qty, get_qty_dec($stock_id)); $rep->AmountCol(7, 8, $total_supp, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $rep->NewLine(); } $rep->NewLine(2, 3); $rep->TextCol(0, 1, _('Total')); $rep->TextCol(1, 7, $catt); $rep->AmountCol(7, 8, $total, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $rep->NewLine(2, 1); $rep->TextCol(0, 7, _('Grand Total')); $rep->AmountCol(7, 8, $grandtotal, $dec); $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
function print_aged_supplier_analysis() { global $path_to_root, $systypes_array; $to = $_POST['PARAM_0']; $fromsupp = $_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 ($fromsupp == ALL_TEXT) { $from = _('All'); } else { $from = get_supplier_name($fromsupp); } $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(_('Supplier'), '', '', _('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' => _('Supplier'), '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 Supplier Analysis'), "AgedSupplierAnalysis", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $total = array(); $total[0] = $total[1] = $total[2] = $total[3] = $total[4] = 0.0; $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; $nowdue = "1-" . $PastDueDays1 . " " . _('Days'); $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . _('Days'); $pastdue2 = _('Over') . " " . $PastDueDays2 . " " . _('Days'); $sql = "SELECT supplier_id, supp_name AS name, curr_code FROM " . TB_PREF . "suppliers"; if ($fromsupp != ALL_TEXT) { $sql .= " WHERE supplier_id=" . db_escape($fromsupp); } $sql .= " ORDER BY supp_name"; $result = db_query($sql, "The suppliers 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; } $supprec = get_supplier_details($myrow['supplier_id'], $to, $show_all); if (!$supprec) { continue; } $supprec['Balance'] *= $rate; $supprec['Due'] *= $rate; $supprec['Overdue1'] *= $rate; $supprec['Overdue2'] *= $rate; $str = array($supprec["Balance"] - $supprec["Due"], $supprec["Due"] - $supprec["Overdue1"], $supprec["Overdue1"] - $supprec["Overdue2"], $supprec["Overdue2"], $supprec["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] += $supprec["Balance"] - $supprec["Due"]; $total[1] += $supprec["Due"] - $supprec["Overdue1"]; $total[2] += $supprec["Overdue1"] - $supprec["Overdue2"]; $total[3] += $supprec["Overdue2"]; $total[4] += $supprec["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['supplier_id'], $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->TextCol(2, 3, sql2date($trans['tran_date']), -2); 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); $rep->NewLine(); 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->End(); }
function print_grn_valuation() { global $path_to_root; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $comments = $_POST['PARAM_2']; $orientation = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; 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(); $cols = array(0, 75, 225, 260, 295, 330, 370, 410, 455, 515); $headers = array(_('Stock ID'), _('Description'), _('PO No'), _('GRN') . "#", _('Inv') . "#", _('Qty'), _('Inv Price'), _('PO Price'), _('Total')); $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to)); $rep = new FrontReport(_('GRN Valuation Report'), "GRNValuationReport", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $res = getTransactions($from, $to); $total = $qtotal = $grandtotal = 0.0; $stock_id = ''; while ($trans = db_fetch($res)) { if ($stock_id != $trans['item_code']) { if ($stock_id != '') { $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); $rep->AmountCol(5, 6, $qtotal, $qdec); $rep->AmountCol(8, 9, $total, $dec); $rep->NewLine(); $total = $qtotal = 0; } $stock_id = $trans['item_code']; } $curr = get_supplier_currency($trans['supplier_id']); $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['delivery_date'])); $trans['std_cost_unit'] *= $rate; $rep->NewLine(); $rep->TextCol(0, 1, $trans['item_code']); $rep->TextCol(1, 2, $trans['description']); $rep->TextCol(2, 3, $trans['order_no']); $qdec = get_qty_dec($trans['item_code']); $rep->TextCol(3, 4, $trans['batch_no']); if ($trans['quantity_inv']) { $suppinv = getSuppInvDetails($trans['grn_item_id']); while ($inv = db_fetch($suppinv)) { $inv['inv_price'] *= $rate; $rep->TextCol(4, 5, $inv['inv_no']); $rep->AmountCol(5, 6, $inv['inv_qty'], $qdec); $rep->AmountCol(6, 7, $inv['inv_price'], $dec); $rep->AmountCol(7, 8, $trans['std_cost_unit'], $dec); $amt = round2($inv['inv_qty'] * $inv['inv_price'], $dec); $rep->AmountCol(8, 9, $amt, $dec); $rep->NewLine(); $total += $amt; $qtotal += $inv['inv_qty']; $grandtotal += $amt; } } if ($trans['qty_recd'] - $trans['quantity_inv'] != 0) { $rep->TextCol(4, 5, "--"); $rep->AmountCol(5, 6, $trans['qty_recd'] - $trans['quantity_inv'], $qdec); $rep->AmountCol(7, 8, $trans['unit_price'], $dec); $amt = round2(($trans['qty_recd'] - $trans['quantity_inv']) * $trans['unit_price'], $dec); $rep->AmountCol(8, 9, $amt, $dec); $total += $amt; $qtotal += $trans['qty_recd'] - $trans['quantity_inv']; $grandtotal += $amt; } else { $rep->NewLine(-1); } } if ($stock_id != '') { $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); $rep->AmountCol(5, 6, $qtotal, $qdec); $rep->AmountCol(8, 9, $total, $dec); $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 7, _('Grand Total')); $rep->AmountCol(8, 9, $grandtotal, $dec); } $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
function print_aged_supplier_analysis() { global $comp_path, $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $to = $_REQUEST['PARAM_0']; $fromsupp = $_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 ($fromsupp == reserved_words::get_all_numeric()) { $from = tr('All'); } else { $from = get_supplier_name($fromsupp); } $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('Supplier'), '', '', 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('Supplier'), '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 Supplier Analysis'), "AgedSupplierAnalysis.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $total = array(); $total[0] = $total[1] = $total[2] = $total[3] = $total[4] = 0.0; $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'); $sql = "SELECT supplier_id, supp_name AS name, curr_code FROM suppliers "; if ($fromsupp != reserved_words::get_all_numeric()) { $sql .= "WHERE supplier_id={$fromsupp} "; } $sql .= "ORDER BY supp_name"; $result = db_query($sql, "The suppliers 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; $supprec = get_supplier_details($myrow['supplier_id'], $to); foreach ($supprec as $i => $value) { $supprec[$i] *= $rate; } $total[0] += $supprec["Balance"] - $supprec["Due"]; $total[1] += $supprec["Due"] - $supprec["Overdue1"]; $total[2] += $supprec["Overdue1"] - $supprec["Overdue2"]; $total[3] += $supprec["Overdue2"]; $total[4] += $supprec["Balance"]; $str = array(number_format2($supprec["Balance"] - $supprec["Due"], $dec), number_format2($supprec["Due"] - $supprec["Overdue1"], $dec), number_format2($supprec["Overdue1"] - $supprec["Overdue2"], $dec), number_format2($supprec["Overdue2"], $dec), number_format2($supprec["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['supplier_id'], $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); 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() . "/pdf_files/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(); }
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(); }
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(); }
function print_payment_report() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $to = $_REQUEST['PARAM_0']; $fromsupp = $_REQUEST['PARAM_1']; $currency = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; if ($fromsupp == reserved_words::get_all_numeric()) { $from = tr('All'); } else { $from = get_supplier_name($fromsupp); } $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('Due Date'), '', '', '', tr('Total'), tr('Balance')); $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('Supplier'), 'from' => $from, 'to' => ''), 3 => array('text' => tr('Currency'), 'from' => $currency, 'to' => '')); $rep = new FrontReport(tr('Payment Report'), "PaymentReport.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $total = array(); $grandtotal = array(0, 0); $sql = "SELECT supplier_id, supp_name AS name, curr_code, payment_terms.terms FROM suppliers, payment_terms\n\t\tWHERE "; if ($fromsupp != reserved_words::get_all_numeric()) { $sql .= "supplier_id={$fromsupp} AND "; } $sql .= "suppliers.payment_terms = payment_terms.terms_indicator\n\t\tORDER BY supp_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, 6, $myrow['name'] . " - " . $myrow['terms']); if ($convert) { $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to); $rep->TextCol(6, 7, $myrow['curr_code']); } else { $rate = 1.0; } $rep->fontSize -= 2; $rep->NewLine(1, 2); $res = getTransactions($myrow['supplier_id'], $to); if (db_num_rows($res) == 0) { continue; } $rep->Line($rep->row + 4); $total[0] = $total[1] = 0.0; while ($trans = db_fetch($res)) { $rep->NewLine(1, 2); $rep->TextCol(0, 1, $trans['type_name']); $rep->TextCol(1, 2, $trans['supp_reference']); $rep->TextCol(2, 3, sql2date($trans['due_date'])); $item[0] = Abs($trans['TranTotal']) * $rate; $rep->TextCol(6, 7, number_format2($item[0], $dec)); $item[1] = $trans['Balance'] * $rate; $rep->TextCol(7, 8, number_format2($item[1], $dec)); for ($i = 0; $i < 2; $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 < 2; $i++) { $rep->TextCol($i + 6, $i + 7, number_format2($total[$i], $dec)); $total[$i] = 0.0; } $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 < 2; $i++) { $rep->TextCol($i + 6, $i + 7, number_format2($grandtotal[$i], $dec)); } $rep->Line($rep->row - 4); $rep->End(); }