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"); }
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_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(); }
} hidden('selected_id', $selected_id); } text_row_ex(tr("Description:"), 'name', 40); yesno_list_row(tr("Tax Shipping:"), 'tax_shipping', null, "", "", true); end_table(); display_note(tr("Select the taxes that are included in this group."), 1); start_table($table_style2); $th = array(tr("Tax"), tr("Default Rate (%)"), tr("Rate (%)")); table_header($th); for ($i = 0; $i < 5; $i++) { start_row(); if (!isset($_POST['tax_type_id' . $i])) { $_POST['tax_type_id' . $i] = 0; } tax_types_list_cells(null, 'tax_type_id' . $i, $_POST['tax_type_id' . $i], true, tr("None"), true); if ($_POST['tax_type_id' . $i] != 0 && $_POST['tax_type_id' . $i] != reserved_words::get_all_numeric()) { $default_rate = get_tax_type_default_rate($_POST['tax_type_id' . $i]); label_cell(percent_format($default_rate), "nowrap align=right"); if (!isset($_POST['rate' . $i]) || $_POST['rate' . $i] == "") { $_POST['rate' . $i] = percent_format($default_rate); } small_amount_cells(null, 'rate' . $i, $_POST['rate' . $i], null, null, user_percent_dec()); } end_row(); } end_table(1); submit_add_or_update_center(!isset($selected_id)); end_form(); //------------------------------------------------------------------------------------ end_page();
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(); }
function print_price_listing() { global $comp_path, $path_to_root, $pic_height, $pic_width; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $category = $_REQUEST['PARAM_0']; $salestype = $_REQUEST['PARAM_1']; $pictures = $_REQUEST['PARAM_2']; $showGP = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; $dec = user_price_dec(); if ($category == reserved_words::get_all_numeric()) { $category = 0; } if ($salestype == reserved_words::get_all_numeric()) { $salestype = 0; } if ($category == 0) { $cat = tr('All'); } else { $cat = get_category_name($category); } if ($salestype == 0) { $stype = tr('All'); } else { $stype = get_sales_type_name($salestype); } if ($showGP == 0) { $GP = tr('No'); } else { $GP = tr('Yes'); } $cols = array(0, 100, 385, 450, 515); $headers = array(tr('Category/Items'), tr('Description'), tr('Price'), tr('GP %')); $aligns = array('left', 'left', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => tr('Sales Type'), 'from' => $stype, 'to' => ''), 3 => array('text' => tr('Show GP %'), 'from' => $GP, 'to' => '')); if ($pictures) { $user_comp = user_company(); } else { $user_comp = ""; } $rep = new FrontReport(tr('Price Listing'), "PriceListing.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $result = fetch_prices($category, $salestype); $currcode = ''; $catgor = ''; while ($myrow = db_fetch($result)) { if ($currcode != $myrow['curr_abrev']) { $rep->NewLine(2); $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['curr_abrev'] . " " . tr('Prices')); $currcode = $myrow['curr_abrev']; $rep->fontSize -= 2; $rep->NewLine(); } if ($catgor != $myrow['description']) { $rep->Line($rep->row - $rep->lineHeight); $rep->NewLine(2); $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['category_id'] . " - " . $myrow['description']); $catgor = $myrow['description']; $rep->fontSize -= 2; $rep->NewLine(); } $rep->NewLine(); $rep->TextCol(0, 1, $myrow['stock_id']); $rep->TextCol(1, 2, $myrow['name']); $rep->TextCol(2, 3, number_format2($myrow['price'], $dec)); if ($showGP) { if ($myrow['price'] != 0.0) { $disp = ($myrow['price'] - $myrow['Standardcost']) * 100 / $myrow['price']; } else { $disp = 0.0; } $rep->TextCol(3, 4, number_format2($disp, user_percent_dec()) . " %"); } if ($pictures) { $image = $comp_path . '/' . $user_comp . "/images/" . $myrow['stock_id'] . ".jpg"; if (file_exists($image)) { $rep->NewLine(); if ($rep->row - $pic_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(); } } else { $rep->NewLine(0, 1); } } $rep->Line($rep->row - 4); $rep->End(); }
if (isset($_GET['delete'])) { if (can_delete($selected_id)) { delete_account_type($selected_id); meta_forward($_SERVER['PHP_SELF']); } } //----------------------------------------------------------------------------------- $result = get_account_types(); start_table($table_style); $th = array(tr("Name"), tr("Subgroup Of"), tr("Class Type"), "", ""); table_header($th); $k = 0; while ($myrow = db_fetch($result)) { alt_table_row_color($k); $bs_text = get_account_class_name($myrow["class_id"]); if ($myrow["parent"] == reserved_words::get_any_numeric()) { $parent_text = ""; } else { $parent_text = get_account_type_name($myrow["parent"]); } label_cell($myrow["name"]); label_cell($parent_text); label_cell($bs_text); edit_link_cell("selected_id=" . $myrow["id"]); delete_link_cell("selected_id=" . $myrow["id"] . "&delete=1"); end_row(); } end_table(); //----------------------------------------------------------------------------------- hyperlink_no_params($_SERVER['PHP_SELF'], tr("New Account Group")); start_form();
function display_item_form() { global $table_style2; start_table($table_style2, 5, 7); echo "<tr><td valign=top>"; // outer table echo "<table>"; if (!isset($_POST['customer_id'])) { $_POST['customer_id'] = get_global_customer(false); } if (!isset($_POST['DateBanked'])) { $_POST['DateBanked'] = Today(); if (!is_date_in_fiscalyear($_POST['DateBanked'])) { $_POST['DateBanked'] = end_fiscalyear(); } } customer_list_row(tr("From Customer:"), 'customer_id', null, false, true); if (db_customer_has_branches($_POST['customer_id'])) { customer_branches_list_row(tr("Branch:"), $_POST['customer_id'], 'BranchID', null, false, true, true); } else { hidden('BranchID', reserved_words::get_any_numeric()); } read_customer_data(); set_global_customer($_POST['customer_id']); if (isset($_POST['HoldAccount']) && $_POST['HoldAccount'] != 0) { echo "</table></table>"; display_note(tr("This customer account is on hold."), 0, 0, "class='redfb'"); } else { $display_discount_percent = percent_format($_POST['pymt_discount'] * 100) . "%"; amount_row(tr("Amount:"), 'amount'); amount_row(tr("Amount of Discount:"), 'discount'); label_row(tr("Customer prompt payment discount :"), $display_discount_percent); date_row(tr("Date of Deposit:"), 'DateBanked'); echo "</table>"; echo "</td><td valign=top class='tableseparator'>"; // outer table echo "<table>"; bank_accounts_list_row(tr("Into Bank Account:"), 'bank_account', null, true); $cust_currency = get_customer_currency($_POST['customer_id']); $bank_currency = get_bank_account_currency($_POST['bank_account']); if ($cust_currency != $bank_currency) { exchange_rate_display($cust_currency, $bank_currency, $_POST['DateBanked']); } bank_trans_types_list_row(tr("Type:"), 'ReceiptType', null); text_row(tr("Reference:"), 'ref', null, 20, 40); textarea_row(tr("Memo:"), 'memo_', null, 22, 4); echo "</table>"; echo "</td></tr>"; end_table(); // outer table if ($cust_currency != $bank_currency) { display_note(tr("Amount and discount are in customer's currency.")); } echo "<br>"; submit_center('AddPaymentItem', tr("Add Payment")); } echo "<br>"; }
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_statements() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $customer = $_REQUEST['PARAM_0']; $currency = $_REQUEST['PARAM_1']; $bankaccount = $_REQUEST['PARAM_2']; $email = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; $dec = user_price_dec(); $cols = array(4, 100, 130, 190, 250, 320, 385, 450, 515); //$headers in doctext.inc $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array('comments' => $comments, 'bankaccount' => $bankaccount); $baccount = get_bank_account($params['bankaccount']); $cur = get_company_pref('curr_default'); $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; if ($email == 0) { $rep = new FrontReport(tr('STATEMENT'), "StatementBulk.pdf", user_pagesize()); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); } $sql = "SELECT debtor_no, name AS DebtorName, address, tax_id, email, curr_code, curdate() AS tran_date, payment_terms FROM debtors_master"; if ($customer != reserved_words::get_all_numeric()) { $sql .= " WHERE debtor_no = {$customer}"; } else { $sql .= " ORDER by name"; } $result = db_query($sql, "The customers could not be retrieved"); while ($myrow = db_fetch($result)) { $date = date('Y-m-d'); $myrow['order_'] = ""; $TransResult = getTransactions($myrow['debtor_no'], $date); if (db_num_rows($TransResult) == 0) { continue; } if ($email == 1) { $rep = new FrontReport("", "", user_pagesize()); $rep->currency = $cur; $rep->Font(); $rep->title = tr('STATEMENT'); $rep->filename = "Statement" . $myrow['debtor_no'] . ".pdf"; $rep->Info($params, $cols, null, $aligns); } $rep->Header2($myrow, null, null, $baccount, 12); $rep->NewLine(); $linetype = true; $doctype = 12; if ($rep->currency != $myrow['curr_code']) { include $path_to_root . "reporting/includes/doctext2.inc"; } else { include $path_to_root . "reporting/includes/doctext.inc"; } $rep->fontSize += 2; $rep->TextCol(0, 8, $doc_Outstanding); $rep->fontSize -= 2; $rep->NewLine(2); while ($myrow2 = db_fetch($TransResult)) { $DisplayTotal = number_format2(Abs($myrow2["TotalAmount"]), $dec); $DisplayAlloc = number_format2($myrow2["Allocated"], $dec); if ($myrow2['type'] == 10) { $DisplayNet = number_format2($myrow2["TotalAmount"] - $myrow2["Allocated"], $dec); } else { $DisplayNet = number_format2($myrow2["TotalAmount"] + $myrow2["Allocated"], $dec); } $rep->TextCol(0, 1, $myrow2['type_name'], -2); $rep->TextCol(1, 2, $myrow2['reference'], -2); $rep->TextCol(2, 3, sql2date($myrow2['tran_date']), -2); if ($myrow2['type'] == 10) { $rep->TextCol(3, 4, sql2date($myrow2['due_date']), -2); } if ($myrow2['TotalAmount'] > 0.0) { $rep->TextCol(4, 5, $DisplayTotal, -2); } else { $rep->TextCol(5, 6, $DisplayTotal, -2); } $rep->TextCol(6, 7, $DisplayAlloc, -2); $rep->TextCol(7, 8, $DisplayNet, -2); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 10 * $rep->lineHeight) { $rep->Header2($myrow, null, null, $baccount); } } $nowdue = "1-" . $PastDueDays1 . " " . $doc_Days; $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . $doc_Days; $pastdue2 = $doc_Over . " " . $PastDueDays2 . " " . $doc_Days; $CustomerRecord = get_customer_details($myrow['debtor_no']); $str = array($doc_Current, $nowdue, $pastdue1, $pastdue2, $doc_Total_Balance); $str2 = array(number_format2($CustomerRecord["Balance"] - $CustomerRecord["Due"], $dec), number_format2($CustomerRecord["Due"] - $CustomerRecord["Overdue1"], $dec), number_format2($CustomerRecord["Overdue1"] - $CustomerRecord["Overdue2"], $dec), number_format2($CustomerRecord["Overdue2"], $dec), number_format2($CustomerRecord["Balance"], $dec)); $col = array($rep->cols[0], $rep->cols[0] + 110, $rep->cols[0] + 210, $rep->cols[0] + 310, $rep->cols[0] + 410, $rep->cols[0] + 510); $rep->row = $rep->bottomMargin + 8 * $rep->lineHeight; for ($i = 0; $i < 5; $i++) { $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str[$i], 'right'); } $rep->NewLine(); for ($i = 0; $i < 5; $i++) { $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str2[$i], 'right'); } if ($email == 1) { $rep->End($email, $doc_Statement . " " . $doc_as_of . " " . sql2date($date), $myrow, 12); } } if ($email == 0) { $rep->End(); } }
function print_customer_details_listing() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $from = $_REQUEST['PARAM_0']; $area = $_REQUEST['PARAM_1']; $folk = $_REQUEST['PARAM_2']; $more = $_REQUEST['PARAM_3']; $less = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; $dec = 0; if ($area == reserved_words::get_all_numeric()) { $area = 0; } if ($folk == reserved_words::get_all_numeric()) { $folk = 0; } if ($area == 0) { $sarea = tr('All Areas'); } else { $sarea = get_area_name($area); } if ($folk == 0) { $salesfolk = tr('All Sales Folk'); } else { $salesfolk = get_salesman_name($folk); } if ($more != '') { $morestr = tr('Greater than ') . number_format2($more, $dec); } else { $morestr = ''; } if ($less != '') { $lessstr = tr('Less than ') . number_format2($less, $dec); } else { $lessstr = ''; } $more = (double) $more; $less = (double) $less; $cols = array(0, 150, 300, 400, 550); $headers = array(tr('Customer Postal Address'), tr('Price/Turnover'), tr('Branch Contact Information'), tr('Branch Delivery Address')); $aligns = array('left', 'left', 'left', 'left'); $params = array(0 => $comments, 1 => array('text' => tr('Activity Since'), 'from' => $from, 'to' => ''), 2 => array('text' => tr('Sales Areas'), 'from' => $sarea, 'to' => ''), 3 => array('text' => tr('Sales Folk'), 'from' => $salesfolk, 'to' => ''), 4 => array('text' => tr('Activity'), 'from' => $morestr, 'to' => $lessstr)); $rep = new FrontReport(tr('Customer Details Listing'), "CustomerDetailsListing.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $result = get_customer_details_for_report($area, $folk); $carea = ''; $sman = ''; while ($myrow = db_fetch($result)) { $printcustomer = true; if ($more != '' || $less != '') { $turnover = getTransactions($myrow['debtor_no'], $myrow['branch_code'], $from); if ($more != 0.0 && $turnover <= (double) $more) { $printcustomer = false; } if ($less != 0.0 && $turnover >= (double) $less) { $printcustomer = false; } } if ($printcustomer) { if ($carea != $myrow['description']) { $rep->fontSize += 2; $rep->NewLine(2, 7); $rep->Font('bold'); $rep->TextCol(0, 3, tr('Customers in') . " " . $myrow['description']); $carea = $myrow['description']; $rep->fontSize -= 2; $rep->Font(); $rep->NewLine(); } if ($sman != $myrow['salesman_name']) { $rep->fontSize += 2; $rep->NewLine(1, 7); $rep->Font('bold'); $rep->TextCol(0, 3, $myrow['salesman_name']); $sman = $myrow['salesman_name']; $rep->fontSize -= 2; $rep->Font(); $rep->NewLine(); } $rep->NewLine(); $rep->TextCol(0, 1, $myrow['name']); $adr = Explode("\n", $myrow['address']); $count1 = count($adr); for ($i = 0; $i < $count1; $i++) { $rep->TextCol(0, 1, $adr[$i], 0, ($i + 1) * $rep->lineHeight); } $count1++; $rep->TextCol(1, 2, tr('Price List') . ": " . $myrow['sales_type']); if ($more != 0.0 || $less != 0.0) { $rep->TextCol(1, 2, tr('Turnover') . ": " . number_format2($turnover, $dec), 0, $rep->lineHeight); } $rep->TextCol(2, 3, $myrow['br_name']); $rep->TextCol(2, 3, $myrow['contact_name'], 0, $rep->lineHeight); $rep->TextCol(2, 3, tr('Ph') . ": " . $myrow['phone'], 0, 2 * $rep->lineHeight); $rep->TextCol(2, 3, tr('Fax') . ": " . $myrow['fax'], 0, 3 * $rep->lineHeight); $adr = Explode("\n", $myrow['br_address']); $count2 = count($adr); for ($i = 0; $i < $count2; $i++) { $rep->TextCol(3, 4, $adr[$i], 0, ($i + 1) * $rep->lineHeight); } $rep->TextCol(3, 4, $myrow['email'], 0, ($count2 + 1) * $rep->lineHeight); $count2++; $count1 = Max($count1, $count2); $count1 = Max($count1, 4); $rep->NewLine($count1); $rep->Line($rep->row + 8); $rep->NewLine(0, 3); } } $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(); }
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_outstanding_GRN() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $fromsupp = $_REQUEST['PARAM_0']; $comments = $_REQUEST['PARAM_1']; if ($fromsupp == reserved_words::get_all_numeric()) { $from = tr('All'); } else { $from = get_supplier_name($fromsupp); } $dec = user_price_dec(); $cols = array(0, 40, 80, 190, 250, 320, 385, 450, 515); $headers = array(tr('GRN'), tr('Order'), tr('Item') . '/' . tr('Description'), tr('Qty Recd'), tr('qty Inv'), tr('Balance'), tr('Std Cost'), tr('Value')); $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Supplier'), 'from' => $from, 'to' => '')); $rep = new FrontReport(tr('Outstanding GRNs Report'), "OutstandingGRN.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $Tot_Val = 0; $Supplier = ''; $SuppTot_Val = 0; $res = getTransactions($fromsupp); while ($GRNs = db_fetch($res)) { if ($Supplier != $GRNs['supplier_id']) { if ($Supplier != '') { $rep->NewLine(2); $rep->TextCol(0, 7, tr('Total')); $rep->TextCol(7, 8, number_format2($SuppTot_Val, $dec)); $rep->Line($rep->row - 2); $rep->NewLine(3); $SuppTot_Val = 0; } $rep->TextCol(0, 6, $GRNs['supp_name']); $Supplier = $GRNs['supplier_id']; } $rep->NewLine(); $rep->TextCol(0, 1, $GRNs['id']); $rep->TextCol(1, 2, $GRNs['order_no']); $rep->TextCol(2, 3, $GRNs['item_code'] . '-' . $GRNs['description']); $rep->TextCol(3, 4, number_format2($GRNs['qty_recd'], $dec)); $rep->TextCol(4, 5, number_format2($GRNs['quantity_inv'], $dec)); $QtyOstg = $GRNs['qty_recd'] - $GRNs['quantity_inv']; $Value = ($GRNs['qty_recd'] - $GRNs['quantity_inv']) * $GRNs['std_cost_unit']; $rep->TextCol(5, 6, number_format2($QtyOstg, $dec)); $rep->TextCol(6, 7, number_format2($GRNs['std_cost_unit'], $dec)); $rep->TextCol(7, 8, number_format2($Value, $dec)); $Tot_Val += $Value; $SuppTot_Val += $Value; $rep->NewLine(0, 1); } if ($Supplier != '') { $rep->NewLine(); $rep->TextCol(0, 7, tr('Total')); $rep->TextCol(7, 8, number_format2($SuppTot_Val, $dec)); $rep->Line($rep->row - 2); $rep->NewLine(3); $SuppTot_Val = 0; } $rep->NewLine(2); $rep->TextCol(0, 7, tr('Grand Total')); $rep->TextCol(7, 8, number_format2($Tot_Val, $dec)); $rep->Line($rep->row - 2); $rep->End(); }