function print_dimension_summary() { global $path_to_root; $fromdim = $_POST['PARAM_0']; $todim = $_POST['PARAM_1']; $showbal = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; 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'; $cols = array(0, 50, 210, 250, 320, 395, 465, 515); $headers = array(_('Reference'), _('Name'), _('Type'), _('Date'), _('Due Date'), _('Closed'), _('YTD')); $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Dimension'), 'from' => get_dimension_string($fromdim), 'to' => get_dimension_string($todim))); $rep = new FrontReport(_('Dimension Summary'), "DimensionSummary", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $res = getTransactions($fromdim, $todim); while ($trans = db_fetch($res)) { $rep->TextCol(0, 1, $trans['reference']); $rep->TextCol(1, 2, $trans['name']); $rep->TextCol(2, 3, $trans['type_']); $rep->DateCol(3, 4, $trans['date_'], true); $rep->DateCol(4, 5, $trans['due_date'], true); if ($trans['closed']) { $str = _('Yes'); } else { $str = _('No'); } $rep->TextCol(5, 6, $str); if ($showbal) { $balance = getYTD($trans['id']); $rep->AmountCol(6, 7, $balance, 0); } $rep->NewLine(1, 2); } $rep->Line($rep->row); $rep->End(); }
function print_GL_transactions() { global $path_to_root, $systypes_array; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $fromacc = $_POST['PARAM_2']; $toacc = $_POST['PARAM_3']; if ($dim == 2) { $dimension = $_POST['PARAM_4']; $dimension2 = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; $destination = $_POST['PARAM_8']; } else { if ($dim == 1) { $dimension = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $destination = $_POST['PARAM_7']; } else { $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; } } 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'; $rep = new FrontReport(_('GL Account Transactions'), "GLAccountTransactions", user_pagesize(), 9, $orientation); $dec = 2; //$cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570); $cols = array(0, 65, 105, 125, 175, 230, 290, 345, 405, 465, 525); //------------0--1---2---3----4----5----6----7----8----9----10------- //-----------------------dim1-dim2----------------------------------- //-----------------------dim1---------------------------------------- //------------------------------------------------------------------- $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension') . " 1", _('Dimension') . " 2", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); } elseif ($dim == 1) { $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension'), "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); } else { $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), "", "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); } if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => _('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 4 => array('text' => _('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc)); } } if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $accounts = get_gl_accounts($fromacc, $toacc); while ($account = db_fetch($accounts)) { if (is_account_balancesheet($account["account_code"])) { $begin = ""; } else { $begin = get_fiscalyear_begin_for_date($from); if (date1_greater_date2($begin, $from)) { $begin = $from; } $begin = add_days($begin, -1); } $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2); $trans = get_gl_transactions($from, $to, -1, $account['account_code'], $dimension, $dimension2); $rows = db_num_rows($trans); if ($prev_balance == 0.0 && $rows == 0) { continue; } $rep->Font('bold'); $rep->TextCol(0, 4, $account['account_code'] . " " . $account['account_name'], -2); $rep->TextCol(4, 6, _('Opening Balance')); if ($prev_balance > 0.0) { $rep->AmountCol(7, 8, abs($prev_balance), $dec); } else { $rep->AmountCol(8, 9, abs($prev_balance), $dec); } $rep->Font(); $total = $prev_balance; $rep->NewLine(2); if ($rows > 0) { while ($myrow = db_fetch($trans)) { $total += $myrow['amount']; $type_name = $systypes_array[$myrow["type"]]; if ($type_name == "Customer Payment") { $rep->TextCol(0, 1, "CRB", -2); } if ($type_name == "Cash Disbursement/Check Voucher") { $rep->TextCol(0, 1, "CDB", -2); } if ($type_name == "Journal Entry") { $rep->TextCol(0, 1, "JB", -2); } if ($type_name == "Customer Credit Note") { $type_name = "Credit Memo"; } if ($type_name == "Sales Invoice") { $type_name = "Invoice"; } else { if ($type_name != "Customer Payment" && $type_name != "Cash Disbursement/Check Voucher" && $type_name != "Journal Entry") { $rep->TextCol(0, 1, $type_name, -2); } } $reference = get_reference($myrow["type"], $myrow["type_no"]); $rep->TextCol(1, 2, $reference); $rep->TextCol(2, 3, $myrow['type_no'], -2); $rep->DateCol(3, 4, $myrow["tran_date"], true); if ($dim >= 1) { $rep->TextCol(4, 5, get_dimension_string($myrow['dimension_id'])); } if ($dim > 1) { $rep->TextCol(5, 6, get_dimension_string($myrow['dimension2_id'])); } $txt = payment_person_name($myrow["person_type_id"], $myrow["person_id"], false); $memo = $myrow['memo_']; if ($txt != "") { if ($memo != "") { $txt = $txt . "/" . $memo; } } else { $txt = $memo; } $rep->TextCol(6, 7, $txt, -2); if ($myrow['amount'] > 0.0) { $rep->AmountCol(7, 8, abs($myrow['amount']), $dec); } else { $rep->AmountCol(8, 9, abs($myrow['amount']), $dec); } $rep->TextCol(9, 10, number_format2($total, $dec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->NewPage(); } } $rep->NewLine(); } $rep->Font('bold'); $rep->TextCol(4, 6, _("Ending Balance")); if ($total > 0.0) { $rep->AmountCol(7, 8, abs($total), $dec); } else { $rep->AmountCol(8, 9, abs($total), $dec); } $rep->Font(); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); } $rep->End(); }
function print_salesman_list() { global $path_to_root; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $summary = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; 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 ($summary == 0) { $sum = _("No"); } else { $sum = _("Yes"); } $dec = user_price_dec(); $cols = array(0, 60, 150, 220, 325, 385, 450, 515); $headers = array(_('Invoice'), _('Customer'), _('Branch'), _('Customer Ref'), _('Inv Date'), _('Total'), _('Provision')); $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right'); $headers2 = array(_('Salesman'), " ", _('Phone'), _('Email'), _('Provision'), _('Break Pt.'), _('Provision') . " 2"); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Summary Only'), 'from' => $sum, 'to' => '')); $aligns2 = $aligns; $rep = new FrontReport(_('Salesman Listing'), "SalesmanListing", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $cols2 = $cols; $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); $rep->NewPage(); $salesman = 0; $subtotal = $total = $subprov = $provtotal = 0; $result = GetSalesmanTrans($from, $to); while ($myrow = db_fetch($result)) { $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, _('Total')); $rep->AmountCol(5, 6, $subtotal, $dec); $rep->AmountCol(6, 7, $subprov, $dec); $rep->Line($rep->row - 4); $rep->NewLine(2); } $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->AmountCol(5, 6, $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; } $rate = $myrow['rate']; $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->DateCol(4, 5, $myrow['tran_date'], true); $rep->AmountCol(5, 6, $amt, $dec); $rep->AmountCol(6, 7, $prov, $dec); $rep->NewLine(); } $subtotal += $amt; $subprov += $prov; } if ($salesman != 0) { $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); $rep->AmountCol(5, 6, $subtotal, $dec); $rep->AmountCol(6, 7, $subprov, $dec); $rep->Line($rep->row - 4); $rep->NewLine(2); $total += $subtotal; $provtotal += $subprov; } $rep->fontSize += 2; $rep->TextCol(0, 3, _('Grand Total')); $rep->fontSize -= 2; $rep->AmountCol(5, 6, $total, $dec); $rep->AmountCol(6, 7, $provtotal, $dec); $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
function print_order_status_list() { global $path_to_root; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $category = $_POST['PARAM_2']; $location = $_POST['PARAM_3']; $backorder = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $destination = $_POST['PARAM_7']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; if ($category == ALL_NUMERIC) { $category = 0; } if ($location == ALL_TEXT) { $location = null; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } if ($location == null) { $loc = _('All'); } else { $loc = get_location_name($location); } if ($backorder == 0) { $back = _('All Orders'); } else { $back = _('Back Orders Only'); } $cols = array(0, 60, 150, 260, 325, 385, 450, 515); $headers2 = array(_('Order'), _('Customer'), _('Branch'), _('Customer Ref'), _('Ord Date'), _('Del Date'), _('Loc')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right'); $headers = array(_('Code'), _('Description'), _('Ordered'), _('Delivered'), _('Outstanding'), ''); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => ''), 4 => array('text' => _('Selection'), 'from' => $back, 'to' => '')); $aligns2 = $aligns; $rep = new FrontReport(_('Order Status Listing'), "OrderStatusListing", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $cols2 = $cols; $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); $rep->NewPage(); $orderno = 0; $result = GetSalesOrders($from, $to, $category, $location, $backorder); while ($myrow = db_fetch($result)) { $rep->NewLine(0, 2, false, $orderno); if ($orderno != $myrow['order_no']) { if ($orderno != 0) { $rep->Line($rep->row); $rep->NewLine(); } $rep->TextCol(0, 1, $myrow['order_no']); $rep->TextCol(1, 2, get_customer_name($myrow['debtor_no'])); $rep->TextCol(2, 3, get_branch_name($myrow['branch_code'])); $rep->TextCol(3, 4, $myrow['customer_ref']); $rep->DateCol(4, 5, $myrow['ord_date'], true); $rep->DateCol(5, 6, $myrow['delivery_date'], true); $rep->TextCol(6, 7, $myrow['from_stk_loc']); $rep->NewLine(2); $orderno = $myrow['order_no']; } $rep->TextCol(0, 1, $myrow['stk_code']); $rep->TextCol(1, 2, $myrow['description']); $dec = get_qty_dec($myrow['stk_code']); $rep->AmountCol(2, 3, $myrow['quantity'], $dec); $rep->AmountCol(3, 4, $myrow['qty_sent'], $dec); $rep->AmountCol(4, 5, $myrow['quantity'] - $myrow['qty_sent'], $dec); if ($myrow['quantity'] - $myrow['qty_sent'] > 0) { $rep->Font('italic'); $rep->TextCol(5, 6, _('Outstanding')); $rep->Font(); } $rep->NewLine(); } $rep->Line($rep->row); $rep->End(); }
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_check() { global $path_to_root, $systypes_array, $print_invoice_no; // Get the payment $from = $_POST['PARAM_0']; $destination = $_POST['PARAM_1']; $trans_no = explode("-", $from); $dec = user_price_dec(); if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $from_trans = get_remittance($trans_no[1], $trans_no[0]); // Get check information $total_amt = $from_trans['Total']; $date = sql2date($from_trans['tran_date']); $memo = get_comments_string($trans_no[1], $trans_no[0]); // Begin the report $rep = new FrontReport(_('Printable Check'), "PrintableCheck", user_pagesize()); $rep->SetHeaderType(null); $rep->NewPage(); // Set the font $rep->Font('', 'courier'); $rep->fontSize = 12; ////////////////// // Check portion $rep->NewLine(1, 0, 76); $rep->cols = array(63, 340, 470, 565); $rep->aligns = array('left', 'left', 'right', 'right'); // Pay to $rep->TextCol(0, 1, $from_trans['supp_name']); // Date $rep->DateCol(1, 2, $rep->DatePrettyPrint($date, 0, 0)); // Amount (numeric) $rep->TextCol(2, 3, '***' . number_format2(-$total_amt, $dec)); // Amount (words) $rep->NewLine(1, 0, 23); $rep->TextCol(0, 2, $from_trans['curr_code'] . ": " . price_in_words(-$total_amt, ST_CHEQUE)); // Memo $rep->NewLine(1, 0, 78); $rep->TextCol(0, 1, $memo); $rep->company = get_company_prefs(); ///////////////////// // Item details x 2 for ($section = 1; $section <= 2; $section++) { $rep->fontSize = 12; // Move down to the correct section $rep->row = $section == 1 ? 505 : 255; $rep->cols = array(20, 340, 470, 588); $rep->aligns = array('left', 'left', 'right', 'right'); // Pay to $rep->Font('b'); $rep->TextCol(0, 1, $from_trans['supp_name']); $rep->Font(); // Date $rep->DateCol(1, 2, $rep->DatePrettyPrint($date, 0, 0)); // Amount (numeric) $rep->TextCol(2, 3, number_format2(-$total_amt, 2)); // Add Trans # + Reference $rep->NewLine(); if ($print_invoice_no == 0) { $tno = $from_trans['reference']; } else { $tno = $from_trans['trans_no']; } $rep->TextCol(0, 3, sprintf(_("Payment # %s - from Customer: %s - %s"), $tno, $from_trans['supp_account_no'], $rep->company['coy_name'])); // Add memo $rep->NewLine(); $rep->TextCol(0, 3, _("Memo: ") . $memo); // TODO: Do we want to set a limit on # of item details? (Max is probably 6-7) // Get item details $result = get_allocations_for_remittance($from_trans['supplier_id'], $from_trans['type'], $from_trans['trans_no']); // Fill in details $rep->NewLine(2); $rep->fontSize = 10; // Use different columns now for the additional info $rep->cols = array(20, 160, 235, 290, 370, 480, 588); $rep->aligns = array('left', 'left', 'left', 'right', 'right', 'right'); // Add headers $rep->Font('b'); $rep->TextCol(0, 1, _("Type/Id")); $rep->TextCol(1, 2, _("Trans Date")); $rep->TextCol(2, 3, _("Due Date")); $rep->TextCol(3, 4, _("Total Amount")); $rep->TextCol(4, 5, _("Left to Allocate")); $rep->TextCol(5, 6, _("This Allocation")); $rep->NewLine(); $rep->Font(); $total_allocated = 0; while ($item = db_fetch($result)) { $rep->TextCol(0, 1, $systypes_array[$item['type']] . " " . $item['supp_reference']); $rep->TextCol(1, 2, sql2date($item['tran_date'])); $rep->TextCol(2, 3, sql2date($item['due_date'])); $rep->AmountCol(3, 4, $item['Total'], $dec); $rep->AmountCol(4, 5, $item['Total'] - $item['alloc'], $dec); $rep->AmountCol(5, 6, $item['amt'], $dec); $total_allocated += $item['amt']; $rep->NewLine(1, 0, $rep->lineHeight + 3); // Space it out } $rep->NewLine(); $rep->TextCol(4, 5, _("Total Allocated")); $rep->AmountCol(5, 6, $total_allocated, $dec); $rep->NewLine(); $rep->TextCol(4, 5, _("Left to Allocate")); $rep->AmountCol(5, 6, -$from_trans['Total'] - $total_allocated, $dec); } // end of section $rep->End(); }
function print_aged_customer_analysis() { global $path_to_root, $systypes_array; $to = $_POST['PARAM_0']; $fromcust = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $show_all = $_POST['PARAM_3']; $summaryOnly = $_POST['PARAM_4']; $no_zeros = $_POST['PARAM_5']; $graphics = $_POST['PARAM_6']; $comments = $_POST['PARAM_7']; $orientation = $_POST['PARAM_8']; $destination = $_POST['PARAM_9']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; if ($graphics) { include_once $path_to_root . "/reporting/includes/class.graphic.inc"; $pg = new graph(); } if ($fromcust == ALL_TEXT) { $from = _('All'); } else { $from = get_customer_name($fromcust); } $dec = user_price_dec(); if ($summaryOnly == 1) { $summary = _('Summary Only'); } else { $summary = _('Detailed Report'); } if ($currency == ALL_TEXT) { $convert = true; $currency = _('Balances in Home Currency'); } else { $convert = false; } if ($no_zeros) { $nozeros = _('Yes'); } else { $nozeros = _('No'); } if ($show_all) { $show = _('Yes'); } else { $show = _('No'); } $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; $nowdue = "1-" . $PastDueDays1 . " " . _('Days'); $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . _('Days'); $pastdue2 = _('Over') . " " . $PastDueDays2 . " " . _('Days'); $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515); $headers = array(_('Customer'), '', '', _('Current'), $nowdue, $pastdue1, $pastdue2, _('Total Balance')); $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => _('Customer'), 'from' => $from, 'to' => ''), 3 => array('text' => _('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => _('Type'), 'from' => $summary, 'to' => ''), 5 => array('text' => _('Show Also Allocated'), 'from' => $show, 'to' => ''), 6 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => '')); if ($convert) { $headers[2] = _('Currency'); } $rep = new FrontReport(_('Aged Customer Analysis'), "AgedCustomerAnalysis", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $total = array(0, 0, 0, 0, 0); $sql = "SELECT debtor_no, name, curr_code FROM " . TB_PREF . "debtors_master"; if ($fromcust != ALL_TEXT) { $sql .= " WHERE debtor_no=" . db_escape($fromcust); } $sql .= " ORDER BY name"; $result = db_query($sql, "The customers could not be retrieved"); while ($myrow = db_fetch($result)) { if (!$convert && $currency != $myrow['curr_code']) { continue; } if ($convert) { $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to); } else { $rate = 1.0; } $custrec = get_customer_details($myrow['debtor_no'], $to, $show_all); if (!$custrec) { continue; } $custrec['Balance'] *= $rate; $custrec['Due'] *= $rate; $custrec['Overdue1'] *= $rate; $custrec['Overdue2'] *= $rate; $str = array($custrec["Balance"] - $custrec["Due"], $custrec["Due"] - $custrec["Overdue1"], $custrec["Overdue1"] - $custrec["Overdue2"], $custrec["Overdue2"], $custrec["Balance"]); if ($no_zeros && floatcmp(array_sum($str), 0) == 0) { continue; } $rep->fontSize += 2; $rep->TextCol(0, 2, $myrow['name']); if ($convert) { $rep->TextCol(2, 3, $myrow['curr_code']); } $rep->fontSize -= 2; $total[0] += $custrec["Balance"] - $custrec["Due"]; $total[1] += $custrec["Due"] - $custrec["Overdue1"]; $total[2] += $custrec["Overdue1"] - $custrec["Overdue2"]; $total[3] += $custrec["Overdue2"]; $total[4] += $custrec["Balance"]; for ($i = 0; $i < count($str); $i++) { $rep->AmountCol($i + 3, $i + 4, $str[$i], $dec); } $rep->NewLine(1, 2); if (!$summaryOnly) { $res = get_invoices($myrow['debtor_no'], $to, $show_all); if (db_num_rows($res) == 0) { continue; } $rep->Line($rep->row + 4); while ($trans = db_fetch($res)) { $rep->NewLine(1, 2); $rep->TextCol(0, 1, $systypes_array[$trans['type']], -2); $rep->TextCol(1, 2, $trans['reference'], -2); $rep->DateCol(2, 3, $trans['tran_date'], true, -2); if ($trans['type'] == ST_CUSTCREDIT || $trans['type'] == ST_CUSTPAYMENT || $trans['type'] == ST_BANKDEPOSIT) { $trans['Balance'] *= -1; $trans['Due'] *= -1; $trans['Overdue1'] *= -1; $trans['Overdue2'] *= -1; } foreach ($trans as $i => $value) { $trans[$i] *= $rate; } $str = array($trans["Balance"] - $trans["Due"], $trans["Due"] - $trans["Overdue1"], $trans["Overdue1"] - $trans["Overdue2"], $trans["Overdue2"], $trans["Balance"]); for ($i = 0; $i < count($str); $i++) { $rep->AmountCol($i + 3, $i + 4, $str[$i], $dec); } } $rep->Line($rep->row - 8); $rep->NewLine(2); } } if ($summaryOnly) { $rep->Line($rep->row + 4); $rep->NewLine(); } $rep->fontSize += 2; $rep->TextCol(0, 3, _('Grand Total')); $rep->fontSize -= 2; for ($i = 0; $i < count($total); $i++) { $rep->AmountCol($i + 3, $i + 4, $total[$i], $dec); if ($graphics && $i < count($total) - 1) { $pg->y[$i] = abs($total[$i]); } } $rep->Line($rep->row - 8); if ($graphics) { global $decseps, $graph_skin; $pg->x = array(_('Current'), $nowdue, $pastdue1, $pastdue2); $pg->title = $rep->title; $pg->axis_x = _("Days"); $pg->axis_y = _("Amount"); $pg->graphic_1 = $to; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = company_path() . "/pdf_files/" . uniqid("") . ".png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->NewPage(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $rep->NewLine(); $rep->End(); }
function print_tax_report() { global $path_to_root, $trans_dir, $Hooks, $systypes_array; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $summaryOnly = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; 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(); $rep = new FrontReport(_('Tax Report'), "TaxReport", user_pagesize(), 9, $orientation); if ($summaryOnly == 1) { $summary = _('Summary Only'); } else { $summary = _('Detailed Report'); } $res = getTaxTypes(); $taxes = array(); while ($tax = db_fetch($res)) { $taxes[$tax['id']] = array('in' => 0, 'out' => 0, 'taxin' => 0, 'taxout' => 0); } $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Type'), 'from' => $summary, 'to' => '')); $cols = array(0, 80, 130, 180, 270, 350, 400, 430, 480, 485, 520); $headers = array(_('Trans Type'), _('Ref'), _('Date'), _('Name'), _('Branch Name'), _('Net'), _('Rate'), _('Tax'), '', _('Name')); $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right', 'left'); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); if (!$summaryOnly) { $rep->NewPage(); } $totalnet = 0.0; $totaltax = 0.0; $transactions = getTaxTransactions($from, $to); while ($trans = db_fetch($transactions)) { if (in_array($trans['trans_type'], array(ST_CUSTCREDIT, ST_SUPPINVOICE, ST_JOURNAL))) { $trans['net_amount'] *= -1; $trans['amount'] *= -1; } if (!$summaryOnly) { $rep->TextCol(0, 1, $systypes_array[$trans['trans_type']]); if ($trans['memo'] == '') { $trans['memo'] = get_reference($trans['trans_type'], $trans['trans_no']); } $rep->TextCol(1, 2, $trans['memo']); $rep->DateCol(2, 3, $trans['tran_date'], true); $rep->TextCol(3, 4, $trans['name']); $rep->TextCol(4, 5, $trans['br_name']); $rep->AmountCol(5, 6, $trans['net_amount'], $dec); $rep->AmountCol(6, 7, $trans['rate'], $dec); $rep->AmountCol(7, 8, $trans['amount'], $dec); $rep->TextCol(9, 10, $trans['taxname']); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->NewPage(); } } if ($trans['trans_type'] == ST_JOURNAL && $trans['amount'] < 0) { $taxes[$trans['tax_type_id']]['taxin'] += $trans['amount']; $taxes[$trans['tax_type_id']]['in'] += $trans['net_amount']; } elseif ($trans['trans_type'] == ST_JOURNAL && $trans['amount'] >= 0) { $taxes[$trans['tax_type_id']]['taxout'] += $trans['amount']; $taxes[$trans['tax_type_id']]['out'] += $trans['net_amount']; } elseif (in_array($trans['trans_type'], array(ST_BANKDEPOSIT, ST_SALESINVOICE, ST_CUSTCREDIT))) { $taxes[$trans['tax_type_id']]['taxout'] += $trans['amount']; $taxes[$trans['tax_type_id']]['out'] += $trans['net_amount']; } else { $taxes[$trans['tax_type_id']]['taxin'] += $trans['amount']; $taxes[$trans['tax_type_id']]['in'] += $trans['net_amount']; } $totalnet += $trans['net_amount']; $totaltax += $trans['amount']; } // Summary $cols2 = array(0, 100, 180, 260, 340, 420, 500); if ($orientation == 'L') { recalculate_cols($cols2); } $headers2 = array(_('Tax Rate'), _('Outputs'), _('Output Tax'), _('Inputs'), _('Input Tax'), _('Net Tax')); $aligns2 = array('left', 'right', 'right', 'right', 'right', 'right', 'right'); $rep->Info($params, $cols2, $headers2, $aligns2); //for ($i = 0; $i < count($cols2); $i++) // $rep->cols[$i] = $rep->leftMargin + $cols2[$i]; $rep->headers = $headers2; $rep->aligns = $aligns2; $rep->NewPage(); $taxtotal = 0; foreach ($taxes as $id => $sum) { $tx = getTaxInfo($id); $rep->TextCol(0, 1, $tx['name'] . " " . number_format2($tx['rate'], $dec) . "%"); $rep->AmountCol(1, 2, $sum['out'], $dec); $rep->AmountCol(2, 3, $sum['taxout'], $dec); $rep->AmountCol(3, 4, $sum['in'], $dec); $rep->AmountCol(4, 5, $sum['taxin'], $dec); $rep->AmountCol(5, 6, $sum['taxout'] + $sum['taxin'], $dec); $taxtotal += $sum['taxout'] + $sum['taxin']; $rep->NewLine(); } $rep->Font('bold'); $rep->NewLine(); $rep->Line($rep->row + $rep->lineHeight); $rep->TextCol(3, 5, _("Total payable or refund")); $rep->AmountCol(5, 6, $taxtotal, $dec); $rep->Line($rep->row - 5); $rep->Font(); $rep->NewLine(); hook_tax_report_done(); $rep->End(); }
function print_bank_transactions() { global $path_to_root, $systypes_array; $acc = $_POST['PARAM_0']; $from = $_POST['PARAM_1']; $to = $_POST['PARAM_2']; $comments = $_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"; } $rep = new FrontReport(_('Bank Statement'), "BankStatement", user_pagesize(), 9, "L"); $dec = user_price_dec(); $cols = array(0, 90, 110, 170, 225, 450, 500, 550, 600, 660, 700); $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'center', 'left'); $headers = array(_('Type'), _('#'), _('Reference'), _('Date'), _('Person/Item'), _('Debit'), _('Credit'), _('Balance'), _('Reco Date'), _('Narration')); $account = get_bank_account($acc); $act = $account['bank_account_name'] . " - " . $account['bank_curr_code'] . " - " . $account['bank_account_number']; $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Bank Account'), 'from' => $act, 'to' => '')); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $prev_balance = get_bank_balance_to($from, $account["id"]); $trans = get_bank_transactions($from, $to, $account['id']); $rows = db_num_rows($trans); if ($prev_balance != 0.0 || $rows != 0) { $rep->Font('bold'); $rep->TextCol(0, 3, $act); $rep->TextCol(3, 5, _('Opening Balance')); if ($prev_balance > 0.0) { $rep->AmountCol(5, 6, abs($prev_balance), $dec); } else { $rep->AmountCol(6, 7, abs($prev_balance), $dec); } $rep->Font(); $total = $prev_balance; $rep->NewLine(2); if ($rows > 0) { // Keep a running total as we loop through // the transactions. $total_debit = $total_credit = 0; while ($myrow = db_fetch($trans)) { $total += $myrow['amount']; $rep->TextCol(0, 1, $systypes_array[$myrow["type"]]); $rep->TextCol(1, 2, $myrow['trans_no']); $rep->TextCol(2, 3, $myrow['ref']); $rep->DateCol(3, 4, $myrow["trans_date"], true); $rep->TextCol(4, 5, payment_person_name($myrow["person_type_id"], $myrow["person_id"], false)); if ($myrow['amount'] > 0.0) { $rep->AmountCol(5, 6, abs($myrow['amount']), $dec); $total_debit += abs($myrow['amount']); } else { $rep->AmountCol(6, 7, abs($myrow['amount']), $dec); $total_credit += abs($myrow['amount']); } $rep->AmountCol(7, 8, $total, $dec); if ($myrow["reconciled"] && $myrow["reconciled"] != '0000-00-00') { $rep->DateCol(8, 9, $myrow["reconciled"], true); } $rep->TextCol(9, 10, $myrow['memo_']); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->NewPage(); } } $rep->NewLine(); } // Print totals for the debit and credit columns. $rep->TextCol(3, 5, _("Total Debit / Credit")); $rep->AmountCol(5, 6, $total_debit, $dec); $rep->AmountCol(6, 7, $total_credit, $dec); $rep->NewLine(2); $rep->Font('bold'); $rep->TextCol(3, 5, _("Ending Balance")); if ($total > 0.0) { $rep->AmountCol(5, 6, abs($total), $dec); } else { $rep->AmountCol(6, 7, abs($total), $dec); } $rep->Font(); $rep->NewLine(2); // Print the difference between starting and ending balances. $net_change = $total - $prev_balance; $rep->TextCol(3, 5, _("Net Change")); if ($total > 0.0) { $rep->AmountCol(5, 6, $net_change, $dec, 0, 0, 0, 0, null, 1, True); } else { $rep->AmountCol(6, 7, $net_change, $dec, 0, 0, 0, 0, null, 1, True); } $rep->Font(); $rep->NewLine(2); // Calculate Bank Balance as per reco $date = date2sql($to); $sql = "SELECT SUM(IF(reconciled<='{$date}' AND reconciled !='0000-00-00', amount, 0)) as reconciled,\n\t\t\t\t SUM(amount) as books_total\n\t\t\tFROM " . TB_PREF . "bank_trans trans\n\t\t\tWHERE bank_act=" . db_escape($account['id']) . "\n\t\t\tAND trans_date <= '{$date}'"; // ." AND trans.reconciled IS NOT NULL"; //display_notification($sql); $t_result = db_query($sql, "Cannot retrieve reconciliation data"); if ($t_row = db_fetch($t_result)) { $books_total = $t_row['books_total']; $reconciled = $t_row['reconciled']; } $difference = $books_total - $reconciled; // Bank Balance (by Reco) $rep->Font('bold'); $rep->TextCol(3, 5, _("Bank Balance")); if ($reconciled > 0.0) { $rep->AmountCol(5, 6, abs($reconciled), $dec); } else { $rep->AmountCol(6, 7, abs($reconciled), $dec); } $rep->Font(); $rep->NewLine(2); // Reco Difference $rep->Font('bold'); $rep->TextCol(3, 5, _("Difference")); if ($difference > 0.0) { $rep->AmountCol(5, 6, abs($difference), $dec); } else { $rep->AmountCol(6, 7, abs($difference), $dec); } $rep->Font(); $rep->NewLine(2); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); } $rep->End(); }
function print_bank_transactions() { global $path_to_root, $systypes_array; $acc = $_POST['PARAM_0']; $from = $_POST['PARAM_1']; $to = $_POST['PARAM_2']; $zero = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; 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'; $rep = new FrontReport(_('Bank Statement'), "BankStatement", user_pagesize(), 9, $orientation); $dec = user_price_dec(); $cols = array(0, 90, 110, 170, 225, 350, 400, 460, 520); $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right'); $headers = array(_('Type'), _('#'), _('Reference'), _('Date'), _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); $account = get_bank_account($acc); $act = $account['bank_account_name'] . " - " . $account['bank_curr_code'] . " - " . $account['bank_account_number']; $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Bank Account'), 'from' => $act, 'to' => '')); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $prev_balance = get_bank_balance_to($from, $account["id"]); $trans = get_bank_transactions($from, $to, $account['id']); $rows = db_num_rows($trans); if ($prev_balance != 0.0 || $rows != 0) { $rep->Font('bold'); $rep->TextCol(0, 3, $act); $rep->TextCol(3, 5, _('Opening Balance')); if ($prev_balance > 0.0) { $rep->AmountCol(5, 6, abs($prev_balance), $dec); } else { $rep->AmountCol(6, 7, abs($prev_balance), $dec); } $rep->Font(); $total = $prev_balance; $rep->NewLine(2); $total_debit = $total_credit = 0; if ($rows > 0) { // Keep a running total as we loop through // the transactions. while ($myrow = db_fetch($trans)) { if ($zero == 0 && $myrow['amount'] == 0.0) { continue; } $total += $myrow['amount']; $rep->TextCol(0, 1, $systypes_array[$myrow["type"]]); $rep->TextCol(1, 2, $myrow['trans_no']); $rep->TextCol(2, 3, $myrow['ref']); $rep->DateCol(3, 4, $myrow["trans_date"], true); $rep->TextCol(4, 5, payment_person_name($myrow["person_type_id"], $myrow["person_id"], false)); if ($myrow['amount'] > 0.0) { $rep->AmountCol(5, 6, abs($myrow['amount']), $dec); $total_debit += abs($myrow['amount']); } else { $rep->AmountCol(6, 7, abs($myrow['amount']), $dec); $total_credit += abs($myrow['amount']); } $rep->AmountCol(7, 8, $total, $dec); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->NewPage(); } } $rep->NewLine(); } // Print totals for the debit and credit columns. $rep->TextCol(3, 5, _("Total Debit / Credit")); $rep->AmountCol(5, 6, $total_debit, $dec); $rep->AmountCol(6, 7, $total_credit, $dec); $rep->NewLine(2); $rep->Font('bold'); $rep->TextCol(3, 5, _("Ending Balance")); if ($total > 0.0) { $rep->AmountCol(5, 6, abs($total), $dec); } else { $rep->AmountCol(6, 7, abs($total), $dec); } $rep->Font(); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); // Print the difference between starting and ending balances. $net_change = $total - $prev_balance; $rep->TextCol(3, 5, _("Net Change")); if ($total > 0.0) { $rep->AmountCol(5, 6, $net_change, $dec, 0, 0, 0, 0, null, 1, True); } else { $rep->AmountCol(6, 7, $net_change, $dec, 0, 0, 0, 0, null, 1, True); } } $rep->End(); }
function print_list_of_journal_entries() { global $path_to_root, $systypes_array; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $systype = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; 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, 100, 240, 300, 400, 460, 520, 580); $headers = array(_('Type/Account'), _('Reference') . '/' . _('Account Name'), _('Date/Dim.'), _('Person/Item/Memo'), _('Debit'), _('Credit')); $aligns = array('left', 'left', 'left', 'left', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Type'), 'from' => $systype == -1 ? _('All') : $systypes_array[$systype], 'to' => '')); $rep = new FrontReport(_('List of Journal Entries'), "JournalEntries", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); if ($systype == -1) { $systype = null; } $trans = get_gl_transactions($from, $to, -1, null, 0, 0, $systype); $typeno = $type = 0; $debit = $credit = 0.0; $totdeb = $totcre = 0.0; while ($myrow = db_fetch($trans)) { if ($type != $myrow['type'] || $typeno != $myrow['type_no']) { if ($typeno != 0) { $rep->Line($rep->row += 6); $rep->NewLine(); $rep->AmountCol(4, 5, $debit, $dec); $rep->AmountCol(5, 6, abs($credit), $dec); $totdeb += $debit; $totcre += $credit; $debit = $credit = 0.0; $rep->Line($rep->row -= 4); $rep->NewLine(); } $typeno = $myrow['type_no']; $type = $myrow['type']; $TransName = $systypes_array[$myrow['type']]; $rep->TextCol(0, 1, $TransName . " # " . $myrow['type_no']); $rep->TextCol(1, 2, get_reference($myrow['type'], $myrow['type_no'])); $rep->DateCol(2, 3, $myrow['tran_date'], true); $coms = payment_person_name($myrow["person_type_id"], $myrow["person_id"]); $memo = get_comments_string($myrow['type'], $myrow['type_no']); if ($memo != '') { if ($coms == "") { $coms = $memo; } else { $coms .= " / " . $memo; } } $rep->TextColLines(3, 6, $coms); $rep->NewLine(); } $rep->TextCol(0, 1, $myrow['account']); $rep->TextCol(1, 2, $myrow['account_name']); $dim_str = get_dimension_string($myrow['dimension_id']); $dim_str2 = get_dimension_string($myrow['dimension2_id']); if ($dim_str2 != "") { $dim_str .= "/" . $dim_str2; } $rep->TextCol(2, 3, $dim_str); $rep->TextCol(3, 4, $myrow['memo_']); if ($myrow['amount'] > 0.0) { $debit += $myrow['amount']; $rep->AmountCol(4, 5, abs($myrow['amount']), $dec); } else { $credit += $myrow['amount']; $rep->AmountCol(5, 6, abs($myrow['amount']), $dec); } $rep->NewLine(1, 2); } if ($typeno != 0) { $rep->Line($rep->row += 6); $rep->NewLine(); $rep->AmountCol(4, 5, $debit, $dec); $rep->AmountCol(5, 6, abs($credit), $dec); $totdeb += $debit; $totcre += $credit; $rep->Line($rep->row -= 4); $rep->NewLine(); $rep->TextCol(0, 4, _("Total")); $rep->AmountCol(4, 5, $totdeb, $dec); $rep->AmountCol(5, 6, abs($totcre), $dec); $rep->Line($rep->row -= 4); } $rep->End(); }
function print_subsidiary_ledger() { global $path_to_root, $systypes_array; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $fromacc = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report2.inc"; } $orientation = $orientation ? 'L' : 'P'; $rep = new FrontReport(_('Subsidiary Ledger Report'), "SubsidiaryLedger", user_pagesize(), 9, $orientation); $dec = user_price_dec(); //$headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension')." 1", _('Dimension')." 2", // _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); //$cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570); $cols = array(0, 65, 105, 125, 175, 230, 290, 345, 405, 465, 525); //------------0--1---2---3----4----5----6----7----8----9----10------- //-----------------------dim1-dim2----------------------------------- //-----------------------dim1---------------------------------------- //------------------------------------------------------------------- $aligns = array('left', 'left', 'left', 'center', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $headers = array(_('Account Name'), '', '', '', '', '', _('Debit'), _('Credit'), '', _('Balance')); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $fromacc)); if ($orientation == 'L') { recalculate_cols($cols); } $rep->SetHeaderType('Header_custom'); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $accounts = get_gl_accounts($fromacc, $fromacc); while ($account = db_fetch($accounts)) { if (is_account_balancesheet($account["account_code"])) { $begin = ""; } else { $begin = get_fiscalyear_begin_for_date($from); if (date1_greater_date2($begin, $from)) { $begin = $from; } $begin = add_days($begin, -1); } $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2); $trans = get_gl_transactions($from, $to, -1, $account['account_code'], $dimension, $dimension2); $rows = db_num_rows($trans); if ($prev_balance == 0.0 && $rows == 0) { continue; } $rep->Font('bold'); $rep->TextCol(0, 4, $account['account_code'] . " " . $account['account_name'], -2); $rep->TextCol(4, 6, _('Opening Balance')); if ($prev_balance > 0.0) { $rep->AmountCol(7, 8, abs($prev_balance), $dec); } else { $rep->AmountCol(8, 9, abs($prev_balance), $dec); } $rep->Font(); $total = $prev_balance; $rep->NewLine(2); if ($rows > 0) { $previous = ''; while ($myrow = db_fetch($trans)) { $total += $myrow['amount']; $txt = payment_person_name($myrow["person_type_id"], $myrow["person_id"], false); $current = $txt; $memo = $myrow['memo_']; if ($txt != "") { if ($previous == $current) { $txt = ''; } else { $rep->NewLine(1); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 0); $rep->TextCol(3, 8, $txt, -2); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); $rep->NewLine(1); } $previous = $current; } $rep->TextCol(0, 3, $systypes_array[$myrow["type"]], -2); $rep->DateCol(4, 6, $myrow["tran_date"], true); if ($myrow['amount'] > 0.0) { $rep->AmountCol(6, 7, abs($myrow['amount']), $dec); } else { $rep->AmountCol(7, 8, abs($myrow['amount']), $dec); } $rep->TextCol(8, 10, number_format2($total, $dec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->NewPage(); } } $rep->NewLine(); } $rep->Font('bold'); $rep->TextCol(4, 6, _("Ending Balance")); if ($total > 0.0) { $rep->AmountCol(7, 8, abs($total), $dec); } else { $rep->AmountCol(8, 9, abs($total), $dec); } $rep->Font(); } $rep->End(); }
function print_payment_report() { global $path_to_root, $systypes_array; $to = $_POST['PARAM_0']; $fromsupp = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $no_zeros = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; 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 ($fromsupp == ALL_TEXT) { $from = _('All'); } else { $from = get_supplier_name($fromsupp); } $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'), _('#'), _('Due Date'), '', '', '', _('Total'), _('Balance')); $aligns = array('left', 'left', 'left', 'left', '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' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => '')); $rep = new FrontReport(_('Payment Report'), "PaymentReport", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $total = array(); $grandtotal = array(0, 0); $sql = "SELECT supplier_id, supp_name AS name, curr_code, " . TB_PREF . "payment_terms.terms FROM " . TB_PREF . "suppliers, " . TB_PREF . "payment_terms\n\t\tWHERE "; if ($fromsupp != ALL_TEXT) { $sql .= "supplier_id=" . db_escape($fromsupp) . " AND "; } $sql .= "" . TB_PREF . "suppliers.payment_terms = " . TB_PREF . "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; } $res = getTransactions($myrow['supplier_id'], $to); if ($no_zeros && db_num_rows($res) == 0) { continue; } $rep->fontSize += 2; $rep->TextCol(0, 6, $myrow['name'] . " - " . $myrow['terms']); if ($convert) { $rep->TextCol(6, 7, $myrow['curr_code']); } $rep->fontSize -= 2; $rep->NewLine(1, 2); if (db_num_rows($res) == 0) { continue; } $rep->Line($rep->row + 4); $total[0] = $total[1] = 0.0; while ($trans = db_fetch($res)) { if ($no_zeros && $trans['TranTotal'] == 0 && $trans['Balance'] == 0) { continue; } if ($convert) { $rate = $trans['rate']; } else { $rate = 1.0; } $rep->NewLine(1, 2); $rep->TextCol(0, 1, $systypes_array[$trans['type']]); $rep->TextCol(1, 2, $trans['supp_reference']); if ($trans['type'] == ST_SUPPINVOICE) { $rep->DateCol(2, 3, $trans['due_date'], true); } else { $rep->DateCol(2, 3, $trans['tran_date'], true); } if ($trans['type'] != ST_SUPPINVOICE) { $trans['TranTotal'] = -$trans['TranTotal']; $trans['Balance'] = -$trans['Balance']; } $item[0] = $trans['TranTotal'] * $rate; $rep->AmountCol(6, 7, $item[0], $dec); $item[1] = $trans['Balance'] * $rate; $rep->AmountCol(7, 8, $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, _('Total')); for ($i = 0; $i < 2; $i++) { $rep->AmountCol($i + 6, $i + 7, $total[$i], $dec); $total[$i] = 0.0; } $rep->Line($rep->row - 4); $rep->NewLine(2); } $rep->fontSize += 2; $rep->TextCol(0, 3, _('Grand Total')); $rep->fontSize -= 2; for ($i = 0; $i < 2; $i++) { $rep->AmountCol($i + 6, $i + 7, $grandtotal[$i], $dec); } $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }