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_remittances() { global $path_to_root, $systypes_array; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $email = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; if (!$from || !$to) { return; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $fno = explode("-", $from); $tno = explode("-", $to); $from = min($fno[0], $tno[0]); $to = max($fno[0], $tno[0]); $cols = array(4, 85, 150, 225, 275, 360, 450, 515); // $headers in doctext.inc $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); if ($email == 0) { $rep = new FrontReport(_('REMITTANCE'), "RemittanceBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { if ($fno[0] == $tno[0]) { $types = array($fno[1]); } else { $types = array(ST_BANKPAYMENT, ST_SUPPAYMENT, ST_SUPPCREDIT); } foreach ($types as $j) { $myrow = get_remittance($j, $i); if (!$myrow) { continue; } $res = get_bank_trans($j, $i); $baccount = db_fetch($res); $params['bankaccount'] = $baccount['bank_act']; if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); $rep->title = _('REMITTANCE'); $rep->filename = "Remittance" . $i . ".pdf"; } $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); $contacts = get_supplier_contacts($myrow['supplier_id'], 'invoice'); $rep->SetCommonData($myrow, null, $myrow, $baccount, ST_SUPPAYMENT, $contacts); $rep->NewPage(); $result = get_allocations_for_remittance($myrow['supplier_id'], $myrow['type'], $myrow['trans_no']); $doctype = ST_SUPPAYMENT; $total_allocated = 0; $rep->TextCol(0, 4, _("As advance / full / part / payment towards:"), -2); $rep->NewLine(2); while ($myrow2 = db_fetch($result)) { $rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2); $rep->TextCol(1, 2, $myrow2['supp_reference'], -2); $rep->TextCol(2, 3, sql2date($myrow2['tran_date']), -2); $rep->TextCol(3, 4, sql2date($myrow2['due_date']), -2); $rep->AmountCol(4, 5, $myrow2['Total'], $dec, -2); $rep->AmountCol(5, 6, $myrow2['Total'] - $myrow2['alloc'], $dec, -2); $rep->AmountCol(6, 7, $myrow2['amt'], $dec, -2); $total_allocated += $myrow2['amt']; $rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } $memo = get_comments_string($j, $i); if ($memo != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $memo, -2); } $rep->row = $rep->bottomMargin + 16 * $rep->lineHeight; $rep->TextCol(3, 6, _("Total Allocated"), -2); $rep->AmountCol(6, 7, $total_allocated, $dec, -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Left to Allocate"), -2); $myrow['Total'] *= -1; $myrow['ov_discount'] *= -1; $rep->AmountCol(6, 7, $myrow['Total'] + $myrow['ov_discount'] - $total_allocated, $dec, -2); if (floatcmp($myrow['ov_discount'], 0)) { $rep->NewLine(); $rep->TextCol(3, 6, _("Discount"), -2); $rep->AmountCol(6, 7, -$myrow['ov_discount'], $dec, -2); } $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(3, 6, _("TOTAL REMITTANCE"), -2); $rep->AmountCol(6, 7, $myrow['Total'], $dec, -2); $words = price_in_words($myrow['Total'], ST_SUPPAYMENT); if ($words != "") { $rep->NewLine(2); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->Font(); if ($email == 1) { $myrow['DebtorName'] = $myrow['supp_name']; $rep->End($email); } } } if ($email == 0) { $rep->End(); } }
$cheque->row = $row_address; $cheque->lineHeight = 12; $cheque->TextWrapLines($col0, $width_col0, $from_trans['supp_name'] . "\n" . $from_trans['address']); $dotadd = 40; $cheque->lineHeight = 16; for ($i = 0; $i < 2; $i++) { // First Stub $cheque->row = $i == 0 ? $row_first_stub : $row_second_stub; $cheque->TextWrap($col0, $cheque->row, $width_col0, $from_trans['supp_name']); $cheque->TextWrap($col1, $cheque->row, $width_col1, sql2date($from_trans['tran_date'])); if ($checkinput != "") { $cheque->TextWrap($col3, $cheque->row, 93, $checkinput); } $cheque->NewLine(); // Get allocations (shows supplier references on invoices and its amount) (Two columns). $result = get_allocations_for_remittance($from_trans['supplier_id'], $from_trans['type'], $from_trans['trans_no']); $totalallocated = 0; $totallines = 0; while ($alloc_row = db_fetch($result)) { $theamout = number_format2($alloc_row['amt'], $dec); $cheque->TextWrap($col0, $cheque->row, 100, $alloc_row['supp_reference'] . " " . str_repeat('.', $dotadd)); $tcol = $col6; $cheque->TextWrap($tcol, $cheque->row, 50, number_format2($alloc_row['amt'], $dec), "right"); if ($show_currencies) { $cheque->TextWrap($tcol += 55, $cheque->row, 50, $from_trans['curr_code']); } if ($alloc_row['Total'] != $alloc_row['amt']) { $cheque->TextWrap($tcol += 55, $cheque->row, $width_normal, _(" (Left to allocate ") . number_format2($alloc_row['Total'] - $alloc_row['amt'], $dec) . ")"); } $totalallocated += $alloc_row['amt']; $totallines++;