function get_transactions() { $data_after = date2sql($_POST['TransAfterDate']); $date_to = date2sql($_POST['TransToDate']); $sql = "SELECT debtor_trans.*,\n\t\tdebtors_master.name AS CustName, debtors_master.curr_code AS CustCurrCode,\n \t(debtor_trans.ov_amount + debtor_trans.ov_gst + " . "debtor_trans.ov_freight + debtor_trans.ov_freight_tax + debtor_trans.ov_discount)\n\t\tAS TotalAmount,\n\t\tdebtor_trans.alloc AS Allocated,\n\t\t((debtor_trans.type = 10)\n\t\tAND debtor_trans.due_date < '" . date2sql(Today()) . "') AS OverDue\n \tFROM debtor_trans, debtors_master\n \tWHERE debtors_master.debtor_no = debtor_trans.debtor_no\n\t\t\tAND (debtor_trans.ov_amount + debtor_trans.ov_gst + " . "debtor_trans.ov_freight + debtor_trans.ov_freight_tax + debtor_trans.ov_discount != 0)\n \t\tAND debtor_trans.tran_date >= '{$data_after}'\n \t\tAND debtor_trans.tran_date <= '{$date_to}'"; if ($_POST['customer_id'] != reserved_words::get_all()) { $sql .= " AND debtor_trans.debtor_no = '" . $_POST['customer_id'] . "'"; } if (isset($_POST['filterType']) && $_POST['filterType'] != reserved_words::get_all()) { if ($_POST['filterType'] == '1' || $_POST['filterType'] == '2') { $sql .= " AND debtor_trans.type = 10 "; } elseif ($_POST['filterType'] == '3') { $sql .= " AND debtor_trans.type = " . systypes::cust_payment(); } elseif ($_POST['filterType'] == '4') { $sql .= " AND debtor_trans.type = 11 "; } if ($_POST['filterType'] == '2') { $today = date2sql(Today()); $sql .= " AND debtor_trans.due_date < '{$today}'\n\t\t\t\tAND (round(abs(debtor_trans.ov_amount + " . "debtor_trans.ov_gst + debtor_trans.ov_freight + " . "debtor_trans.ov_freight_tax + debtor_trans.ov_discount) - debtor_trans.alloc,6) > 0) "; } } else { $sql .= " AND debtor_trans.type != 13 "; } if (!check_value('showSettled')) { $sql .= " AND (round(abs(debtor_trans.ov_amount + debtor_trans.ov_gst + " . "debtor_trans.ov_freight + debtor_trans.ov_freight_tax + " . "debtor_trans.ov_discount) - debtor_trans.alloc,6) != 0) "; } $sql .= " ORDER BY debtor_trans.tran_date"; return db_query($sql, "No transactions were returned"); }
function get_transactions() { $date_after = date2sql($_POST['TransAfterDate']); $date_to = date2sql($_POST['TransToDate']); $sql = "SELECT debtor_trans.*,debtors_master.name AS CustName," . "debtors_master.curr_code AS CustCurrCode," . "(debtor_trans.ov_amount + debtor_trans.ov_gst + " . "debtor_trans.ov_freight + debtor_trans.ov_freight_tax + " . "debtor_trans.ov_discount) AS " . "TotalAmount, debtor_trans.alloc AS Allocated, " . "((debtor_trans.type = 10) " . "AND debtor_trans.due_date < '" . date2sql(Today()) . "') AS OverDue " . "FROM debtor_trans, debtors_master " . "WHERE debtors_master.debtor_no = debtor_trans.debtor_no " . "AND debtor_trans.tran_date >= '{$date_after}' " . "AND debtor_trans.tran_date <= '{$date_to}'"; if ($_POST['customer_id'] != reserved_words::get_all()) { $sql .= " AND debtor_trans.debtor_no = '" . $_POST['customer_id'] . "'"; } if ($_POST['filterType'] != reserved_words::get_all()) { if ($_POST['filterType'] == '1') { $sql .= " AND (debtor_trans.type = 10 OR debtor_trans.type = 1) "; } elseif ($_POST['filterType'] == '2') { $sql .= " AND (debtor_trans.type = 10) "; } elseif ($_POST['filterType'] == '3') { $sql .= " AND (debtor_trans.type = " . systypes::cust_payment() . " OR debtor_trans.type = 2) "; } elseif ($_POST['filterType'] == '4') { $sql .= " AND debtor_trans.type = 11 "; } elseif ($_POST['filterType'] == '5') { $sql .= " AND debtor_trans.type = 13 "; } if ($_POST['filterType'] == '2') { $today = date2sql(Today()); $sql .= " AND debtor_trans.due_date < '{$today}' " . "AND (debtor_trans.ov_amount + debtor_trans.ov_gst + " . "debtor_trans.ov_freight_tax + debtor_trans.ov_freight + " . "debtor_trans.ov_discount - debtor_trans.alloc > 0) "; } } $sql .= " ORDER BY debtor_trans.tran_date DESC,debtor_trans.type," . "debtor_trans.trans_no "; return db_query($sql, "No transactions were returned"); }
function get_transactions() { global $db; $date_after = date2sql($_POST['TransAfterDate']); $date_to = date2sql($_POST['TransToDate']); // Sherifoz 22.06.03 Also get the description $sql = "SELECT supp_trans.type, supp_trans.trans_no,\n \tsupp_trans.tran_date, supp_trans.reference, supp_trans.supp_reference,\n \t(supp_trans.ov_amount + supp_trans.ov_gst + supp_trans.ov_discount) AS TotalAmount, supp_trans.alloc AS Allocated,\n\t\t((supp_trans.type = 20 OR supp_trans.type = 21) AND supp_trans.due_date < '" . date2sql(Today()) . "') AS OverDue,\n \t(ABS(supp_trans.ov_amount + supp_trans.ov_gst + supp_trans.ov_discount - supp_trans.alloc) <= 0.005) AS Settled,\n\t\tsuppliers.curr_code, suppliers.supp_name, supp_trans.due_date\n \tFROM supp_trans, suppliers\n \tWHERE suppliers.supplier_id = supp_trans.supplier_id\n \tAND supp_trans.tran_date >= '{$date_after}'\n \tAND supp_trans.tran_date <= '{$date_to}'"; if ($_POST['supplier_id'] != reserved_words::get_all()) { $sql .= " AND supp_trans.supplier_id = '" . $_POST['supplier_id'] . "'"; } if (isset($_POST['filterType']) && $_POST['filterType'] != reserved_words::get_all()) { if ($_POST['filterType'] == '1') { $sql .= " AND (supp_trans.type = 20 OR supp_trans.type = 2)"; } elseif ($_POST['filterType'] == '2') { $sql .= " AND supp_trans.type = 20 "; } elseif ($_POST['filterType'] == '3') { $sql .= " AND (supp_trans.type = 22 OR supp_trans.type = 1) "; } elseif ($_POST['filterType'] == '4' || $_POST['filterType'] == '5') { $sql .= " AND supp_trans.type = 21 "; } if ($_POST['filterType'] == '2' || $_POST['filterType'] == '5') { $today = date2sql(Today()); $sql .= " AND supp_trans.due_date < '{$today}' "; } } $sql .= " ORDER BY supp_trans.tran_date"; return db_query($sql, "No supplier transactions were returned"); }
function print_inventory_planning() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $category = $_REQUEST['PARAM_0']; $location = $_REQUEST['PARAM_1']; $comments = $_REQUEST['PARAM_2']; $dec = user_qty_dec(); if ($category == reserved_words::get_all_numeric()) { $category = 0; } if ($category == 0) { $cat = tr('All'); } else { $cat = get_category_name($category); } if ($location == reserved_words::get_all()) { $location = 'all'; } if ($location == 'all') { $loc = tr('All'); } else { $loc = $location; } $cols = array(0, 50, 150, 180, 210, 240, 270, 300, 330, 390, 435, 480, 525); $per0 = strftime('%b', mktime(0, 0, 0, date('m'), date('d'), date('Y'))); $per1 = strftime('%b', mktime(0, 0, 0, date('m') - 1, date('d'), date('Y'))); $per2 = strftime('%b', mktime(0, 0, 0, date('m') - 2, date('d'), date('Y'))); $per3 = strftime('%b', mktime(0, 0, 0, date('m') - 3, date('d'), date('Y'))); $per4 = strftime('%b', mktime(0, 0, 0, date('m') - 4, date('d'), date('Y'))); $headers = array(tr('Category'), '', $per4, $per3, $per2, $per1, $per0, '3*M', tr('QOH'), tr('Cust Ord'), tr('Supp Ord'), tr('Sugg Ord')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => tr('Location'), 'from' => $loc, 'to' => '')); $rep = new FrontReport(tr('Inventory Planning Report'), "InventoryPlanning.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $res = getTransactions($category, $location); $catt = ''; while ($trans = db_fetch($res)) { if ($catt != $trans['cat_description']) { if ($catt != '') { $rep->Line($rep->row - 2); $rep->NewLine(2, 3); } $rep->TextCol(0, 1, $trans['category_id']); $rep->TextCol(1, 2, $trans['cat_description']); $catt = $trans['cat_description']; $rep->NewLine(); } $custqty = getCustQty($trans['stock_id'], $trans['loc_code']); $custqty += getCustAsmQty($trans['stock_id'], $trans['loc_code']); $suppqty = getSuppQty($trans['stock_id'], $trans['loc_code']); $period = getPeriods($trans['stock_id'], $trans['loc_code']); $rep->NewLine(); $rep->TextCol(0, 1, $trans['stock_id']); $rep->TextCol(1, 2, $trans['description']); $rep->TextCol(2, 3, number_format2($period['prd0'], $dec)); $rep->TextCol(3, 4, number_format2($period['prd1'], $dec)); $rep->TextCol(4, 5, number_format2($period['prd2'], $dec)); $rep->TextCol(5, 6, number_format2($period['prd3'], $dec)); $rep->TextCol(6, 7, number_format2($period['prd4'], $dec)); $MaxMthSales = Max($period['prd0'], $period['prd1'], $period['prd2'], $period['prd3']); $IdealStockHolding = $MaxMthSales * 3; $rep->TextCol(7, 8, number_format2($IdealStockHolding, $dec)); $rep->TextCol(8, 9, number_format2($trans['qty_on_hand'], $dec)); $rep->TextCol(9, 10, number_format2($custqty, $dec)); $rep->TextCol(10, 11, number_format2($suppqty, $dec)); $SuggestedTopUpOrder = $IdealStockHolding - $trans['qty_on_hand'] + $custqty - $suppqty; if ($SuggestedTopUpOrder < 0.0) { $SuggestedTopUpOrder = 0.0; } $rep->TextCol(11, 12, number_format2($SuggestedTopUpOrder, $dec)); } $rep->Line($rep->row - 4); $rep->End(); }
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(); }
function display_allocatable_transactions() { global $table_style, $path_to_root; start_form(); /* show all outstanding receipts and credits to be allocated */ /*Clear any previous allocation records */ if (isset($_SESSION['alloc'])) { unset($_SESSION['alloc']->allocs); unset($_SESSION['alloc']); } if (!isset($_POST['supplier_id'])) { $_POST['supplier_id'] = get_global_supplier(); } echo "<center>" . tr("Select a Supplier: ") . " "; supplier_list('supplier_id', $_POST['supplier_id'], true, true); echo "<br>"; check(tr("Show Settled Items:"), 'ShowSettled', null, true); echo "</center><br><br>"; set_global_supplier($_POST['supplier_id']); if (isset($_POST['supplier_id']) && $_POST['supplier_id'] == reserved_words::get_all()) { unset($_POST['supplier_id']); } $settled = false; if (check_value('ShowSettled')) { $settled = true; } $supplier_id = null; if (isset($_POST['supplier_id'])) { $supplier_id = $_POST['supplier_id']; } $trans_items = get_allocatable_from_supp_transactions($supplier_id, $settled); start_table($table_style); if (!isset($_POST['supplier_id'])) { $th = array(tr("Transaction Type"), tr("#"), tr("Reference"), tr("Date"), tr("Supplier"), tr("Currency"), tr("Total"), tr("Left To Allocate")); } else { $th = array(tr("Transaction Type"), tr("#"), tr("Reference"), tr("Date"), tr("Total"), tr("Left To Allocate")); } table_header($th); $k = 0; //row colour counter $has_settled_items = false; while ($myrow = db_fetch($trans_items)) { if ($myrow["settled"] == 1) { start_row("class='settledbg'"); $has_settled_items = true; } else { alt_table_row_color($k); } label_cell(systypes::name($myrow["type"])); label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"])); label_cell($myrow["reference"]); label_cell(sql2date($myrow["tran_date"])); if (!isset($_POST['supplier_id'])) { label_cell($myrow["supp_name"]); label_cell($myrow["curr_code"]); } amount_cell(-$myrow["Total"]); amount_cell(-$myrow["Total"] - $myrow["alloc"]); label_cell("<a href='{$path_to_root}/purchasing/allocations/supplier_allocate.php?trans_no=" . $myrow["trans_no"] . "&trans_type=" . $myrow["type"] . "'>" . tr("Allocate") . "</a>"); end_row(); } end_table(); if ($has_settled_items) { display_note(tr("Marked items are settled."), 0, 1, "class='settledfg'"); } if (db_num_rows($trans_items) == 0) { display_note(tr("There are no allocations to be done."), 1, 2); } end_form(); }
function print_inventory_valuation_report() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $category = $_REQUEST['PARAM_0']; $location = $_REQUEST['PARAM_1']; $detail = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; $dec = user_price_dec(); if ($category == reserved_words::get_all_numeric()) { $category = 0; } if ($category == 0) { $cat = tr('All'); } else { $cat = get_category_name($category); } if ($location == reserved_words::get_all()) { $location = 'all'; } if ($location == 'all') { $loc = tr('All'); } else { $loc = $location; } $cols = array(0, 100, 250, 350, 450, 515); $headers = array(tr('Category'), '', tr('Quantity'), tr('Unit Cost'), tr('Value')); $aligns = array('left', 'left', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => tr('Location'), 'from' => $loc, 'to' => '')); $rep = new FrontReport(tr('Inventory Valuation Report'), "InventoryValReport.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $res = getTransactions($category, $location); $total = $grandtotal = 0.0; $catt = ''; while ($trans = db_fetch($res)) { if ($catt != $trans['cat_description']) { if ($catt != '') { if ($detail) { $rep->NewLine(2, 3); $rep->TextCol(0, 4, tr('Total')); } $rep->Textcol(4, 5, number_format2($total, $dec)); if ($detail) { $rep->Line($rep->row - 2); $rep->NewLine(); } $rep->NewLine(); $total = 0.0; } $rep->TextCol(0, 1, $trans['category_id']); $rep->TextCol(1, 2, $trans['cat_description']); $catt = $trans['cat_description']; if ($detail) { $rep->NewLine(); } } if ($detail) { $rep->NewLine(); $rep->fontsize -= 2; $rep->TextCol(0, 1, $trans['stock_id']); $rep->TextCol(1, 2, $trans['description']); $rep->TextCol(2, 3, number_format2($trans['QtyOnHand'], user_qty_dec())); $rep->TextCol(3, 4, number_format2($trans['UnitCost'], $dec)); $rep->TextCol(4, 5, number_format2($trans['ItemTotal'], $dec)); $rep->fontsize += 2; } $total += $trans['ItemTotal']; $grandtotal += $trans['ItemTotal']; } if ($detail) { $rep->NewLine(2, 3); $rep->TextCol(0, 4, tr('Total')); } $rep->Textcol(4, 5, number_format2($total, $dec)); if ($detail) { $rep->Line($rep->row - 2); $rep->NewLine(); } $rep->NewLine(2, 1); $rep->TextCol(0, 4, tr('Grand Total')); $rep->TextCol(4, 5, number_format2($grandtotal, $dec)); $rep->Line($rep->row - 4); $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(); }
if (isset($_POST['StockLocation']) && $_POST['StockLocation'] == reserved_words::get_all()) { $th = array(tr("#"), tr("Reference"), tr("Supplier"), tr("Location"), tr("Supplier's Reference"), tr("Order Date"), tr("Currency"), tr("Order Total"), ""); } else { $th = array(tr("#"), tr("Reference"), tr("Supplier"), tr("Supplier's Reference"), tr("Order Date"), tr("Currency"), tr("Order Total"), ""); } table_header($th); $j = 1; $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); $date = sql2date($myrow["ord_date"]); label_cell(get_trans_view_str(systypes::po(), $myrow["order_no"])); label_cell($myrow["reference"]); label_cell($myrow["supp_name"]); if (isset($_POST['StockLocation']) && $_POST['StockLocation'] == reserved_words::get_all()) { label_cell($myrow["location_name"]); } label_cell($myrow["requisition_no"]); label_cell($date); label_cell($myrow["curr_code"]); amount_cell($myrow["OrderValue"]); label_cell(print_document_link($myrow['order_no'], tr("Print"))); end_row(); $j++; if ($j == 12) { $j = 1; table_header($th); } } end_table(2);
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(); }
function print_stock_check() { global $comp_path, $path_to_root, $pic_height, $pic_width; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $category = $_REQUEST['PARAM_0']; $location = $_REQUEST['PARAM_1']; $pictures = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; $dec = user_qty_dec(); if ($category == reserved_words::get_all_numeric()) { $category = 0; } if ($category == 0) { $cat = tr('All'); } else { $cat = get_category_name($category); } if ($location == reserved_words::get_all()) { $location = 'all'; } if ($location == 'all') { $loc = tr('All'); } else { $loc = $location; } $cols = array(0, 100, 305, 375, 445, 515); $headers = array(tr('Category'), tr('Description'), tr('Quantity'), tr('Demand'), tr('Difference')); $aligns = array('left', 'left', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => tr('Location'), 'from' => $loc, 'to' => '')); if ($pictures) { $user_comp = user_company(); } else { $user_comp = ""; } $rep = new FrontReport(tr('Stock Check Sheets'), "StockCheckSheet.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $res = getTransactions($category, $location); $catt = ''; while ($trans = db_fetch($res)) { if ($catt != $trans['cat_description']) { if ($catt != '') { $rep->Line($rep->row - 2); $rep->NewLine(2, 3); } $rep->TextCol(0, 1, $trans['category_id']); $rep->TextCol(1, 2, $trans['cat_description']); $catt = $trans['cat_description']; $rep->NewLine(); } $demandqty = getDemandQty($trans['stock_id'], $trans['loc_code']); $demandqty += getDemandAsmQty($trans['stock_id'], $trans['loc_code']); $rep->NewLine(); $rep->TextCol(0, 1, $trans['stock_id']); $rep->TextCol(1, 2, $trans['description']); $rep->TextCol(2, 3, number_format2($trans['QtyOnHand'], $dec)); $rep->TextCol(3, 4, number_format2($demandqty, $dec)); $rep->TextCol(4, 5, number_format2($trans['QtyOnHand'] - $demandqty, $dec)); if ($pictures) { $image = $comp_path . '/' . $user_comp . '/images/' . $trans['stock_id'] . '.jpg'; if (file_exists($image)) { $rep->NewLine(); if ($rep->row - $height < $rep->bottomMargin) { $rep->Header(); } $rep->AddImage($image, $rep->cols[1], $rep->row - $pic_height, $pic_width, $pic_height); $rep->row -= $pic_height; $rep->NewLine(); } } } $rep->Line($rep->row - 4); $rep->End(); }