function print_statements() { global $path_to_root, $systypes_array; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $customer = $_POST['PARAM_0']; $currency = $_POST['PARAM_1']; $show_also_allocated = $_POST['PARAM_2']; $email = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $orientation = $orientation ? 'L' : 'P'; $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); $cur = get_company_pref('curr_default'); $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; if ($email == 0) { $rep = new FrontReport(_('STATEMENT'), "StatementBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } $sql = "SELECT debtor_no, name AS DebtorName, address, tax_id, curr_code, curdate() AS tran_date FROM " . TB_PREF . "debtors_master"; if ($customer != ALL_TEXT) { $sql .= " WHERE debtor_no = " . db_escape($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, $show_also_allocated); $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; if (db_num_rows($TransResult) == 0) { continue; } if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); $rep->title = _('STATEMENT'); $rep->filename = "Statement" . $myrow['debtor_no'] . ".pdf"; $rep->Info($params, $cols, null, $aligns); } $contacts = get_customer_contacts($myrow['debtor_no'], 'invoice'); $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); //= get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no']); $rep->SetCommonData($myrow, null, null, $baccount, ST_STATEMENT, $contacts); $rep->NewPage(); $rep->NewLine(); $doctype = ST_STATEMENT; $rep->fontSize += 2; $rep->TextCol(0, 8, _("Outstanding Transactions")); $rep->fontSize -= 2; $rep->NewLine(2); while ($myrow2 = db_fetch($TransResult)) { $DisplayTotal = number_format2(Abs($myrow2["TotalAmount"]), $dec); $DisplayAlloc = number_format2($myrow2["Allocated"], $dec); $DisplayNet = number_format2($myrow2["TotalAmount"] - $myrow2["Allocated"], $dec); $rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2); $rep->TextCol(1, 2, $myrow2['reference'], -2); $rep->TextCol(2, 3, sql2date($myrow2['tran_date']), -2); if ($myrow2['type'] == ST_SALESINVOICE) { $rep->TextCol(3, 4, sql2date($myrow2['due_date']), -2); } if ($myrow2['type'] == ST_SALESINVOICE || $myrow2['type'] == ST_BANKPAYMENT) { $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->NewPage(); } } $nowdue = "1-" . $PastDueDays1 . " " . _("Days"); $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . _("Days"); $pastdue2 = _("Over") . " " . $PastDueDays2 . " " . _("Days"); $CustomerRecord = get_customer_details($myrow['debtor_no'], null, $show_also_allocated); $str = array(_("Current"), $nowdue, $pastdue1, $pastdue2, _("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 + (10 * $rep->lineHeight - 6); 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, _("Statement") . " " . _("as of") . " " . sql2date($date)); } } if ($email == 0) { $rep->End(); } }
table_header($th); start_row(); label_cell($customer_record["curr_code"]); label_cell($customer_record["terms"]); amount_cell($customer_record["Balance"] - $customer_record["Due"]); amount_cell($customer_record["Due"] - $customer_record["Overdue1"]); amount_cell($customer_record["Overdue1"] - $customer_record["Overdue2"]); amount_cell($customer_record["Overdue2"]); amount_cell($customer_record["Balance"]); end_row(); end_table(); } //------------------------------------------------------------------------------------------------ div_start('totals_tbl'); if ($_POST['customer_id'] != "" && $_POST['customer_id'] != ALL_TEXT) { $customer_record = get_customer_details($_POST['customer_id'], $_POST['TransToDate']); display_customer_summary($customer_record); echo "<br>"; } div_end(); if (get_post('RefreshInquiry')) { $Ajax->activate('totals_tbl'); } //------------------------------------------------------------------------------------------------ function systype_name($dummy, $type) { global $systypes_array; return $systypes_array[$type]; } function order_view($row) {
function print_sales_summary_report() { global $path_to_root; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $tax_id = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; if ($tax_id == 0) { $tid = _('No'); } else { $tid = _('Yes'); } 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(_('Sales Summary Report'), "SalesSummaryReport", user_pagesize(), 9, $orientation); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Tax Id Only'), 'from' => $tid, 'to' => '')); $cols = array(0, 130, 180, 270, 350, 400, 500); $headers = array(_('Customer'), _('Total ex. Tax'), _('Tax'), _('Total'), _('Balance'), _('Due')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right'); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $totalnet = 0.0; $totaltax = 0.0; $transactions = getTaxTransactions($from, $to, $tax_id); $rep->TextCol(0, 4, _('Balances in Home Currency')); $rep->NewLine(2); $custno = 0; $tax = $total = 0; $custname = $tax_id = ""; while ($trans = db_fetch($transactions)) { $customer_record = get_customer_details($custno); $customer_crm = getPhone($custno); if ($custno != $trans['debtor_no']) { if ($custno != 0) { $rep->TextCol(0, 1, $custname); //$rep->TextCol(1, 2, $tax_id); $rep->TextCol(1, 2, $custno, $dec); $rep->TextCol(2, 3, $trans['debtor_no'], $dec); $rep->TextCol(3, 4, $customer_crm['phone'], $dec); $rep->AmountCol(4, 5, $tax + $total, $dec); $rep->AmountCol(5, 6, $customer_record["Balance"], $dec); $totalnet += $total; $totaltax += $tax; $total = $tax = 0; $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->NewPage(); } } $custno = $trans['debtor_no']; $custname = $trans['cust_name']; $tax_id = $trans['tax_id']; } $taxes = getTaxes($trans['type'], $trans['trans_no']); if ($taxes != null) { if ($taxes['included_in_price']) { $trans['total'] -= $taxes['tax']; } $tax += $taxes['tax']; } $total += $trans['total']; } if ($custno != 0) { $customer_record = get_customer_details($custno); $rep->TextCol(0, 1, $custname); //$rep->TextCol(1, 2, $tax_id); $rep->AmountCol(1, 2, $total, $dec); $rep->AmountCol(2, 3, $tax, $dec); $rep->AmountCol(3, 4, $tax + $total, $dec); $rep->AmountCol(4, 5, $customer_record["Balance"], $dec); $rep->AmountCol(5, 6, $customer_record["Due"], $dec); $totalnet += $total; $totaltax += $tax; $rep->NewLine(); } $rep->Font('bold'); $rep->NewLine(); $rep->Line($rep->row + $rep->lineHeight); $rep->TextCol(0, 1, _("Total")); $rep->AmountCol(1, 2, $totalnet, $dec); $rep->AmountCol(2, 3, $totaltax, $dec); $rep->AmountCol(3, 4, $totaltax + $totalnet, $dec); $rep->Line($rep->row - 5); $rep->Font(); $rep->End(); }
} 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"); } //------------------------------------------------------------------------------------------------ if ($_POST['customer_id'] != "" && $_POST['customer_id'] != reserved_words::get_all()) { $customer_record = get_customer_details($_POST['customer_id']); display_customer_summary($customer_record); echo "<br>"; } //------------------------------------------------------------------------------------------------ $result = get_transactions(); if (db_num_rows($result) == 0) { display_note(tr("The selected customer has no transactions for the given dates."), 0, 2); end_page(); exit; } //------------------------------------------------------------------------------------------------ print_hidden_script(10); start_table("{$table_style} width='80%'"); $th = array(tr("Type"), tr("#"), tr("Order"), tr("Reference"), tr("Date"), tr("Due Date"), tr("Customer"), tr("Branch"), tr("Currency"), tr("Debit"), tr("Credit"), "", "", "", ""); if ($_POST['customer_id'] != reserved_words::get_all()) {
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_invoices() { global $path_to_root, $alternative_tax_include_on_docs, $suppress_tax_rates, $no_zero_lines_amount; 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']; $pay_service = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $TotalDiscount = 0; 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, 60, 225, 300, 325, 385, 450, 515); // $headers in doctext.inc $aligns = array('left', 'left', 'right', 'left', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); if ($email == 0) { $rep = new FrontReport(_('INVOICE'), "InvoiceBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { if (!exists_customer_trans(ST_SALESINVOICE, $i)) { continue; } $sign = 1; $myrow = get_customer_trans($i, ST_SALESINVOICE); $transId = get_payment_id($i); if ($transId != NULL) { $urrow = get_customer_trans($transId['trans_no_from'], ST_CUSTPAYMENT); } else { $urrow['ov_discount'] = 0; } $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; $branch = get_branch($myrow["branch_code"]); $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER); if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); $rep->title = _('INVOICE'); $rep->filename = "Invoice" . $myrow['reference'] . ".pdf"; } $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); $contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], true); $baccount['payment_service'] = $pay_service; $rep->SetCommonData($myrow, $branch, $sales_order, $baccount, ST_SALESINVOICE, $contacts); $rep->NewPage(); $result = get_customer_trans_details(ST_SALESINVOICE, $i); // print_r($result); $SubTotal = 0; while ($myrow2 = db_fetch($result)) { if ($myrow2["quantity"] == 0) { continue; } $Net = round2($sign * ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], $dec); $DisplayQty = number_format2($sign * $myrow2["quantity"], get_qty_dec($myrow2['stock_id'])); $DisplayNet = number_format2($Net, $dec); if ($myrow2["discount_percent"] == 0) { $DisplayDiscount = 0; } else { $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, user_percent_dec()) . "%"; } $rep->fontSize += 5; $rep->TextCol(0, 1, $myrow2['stock_id'], -2); $oldrow = $rep->row; $rep->TextColLines(1, 5, $myrow2['StockDescription'], -2); $newrow = $rep->row; $rep->row = $oldrow; if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) { //$rep->TextCol(2, 3, $DisplayQty, -2); //$rep->TextCol(3, 4, $myrow2['units'], -2); $rep->TextCol(5, 6, $DisplayPrice, -2); //$rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(6, 7, $DisplayNet, -2); $TotalDiscount += $myrow2["unit_price"] * ($DisplayDiscount / 100); } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } $rep->fontSize -= 5; } // $memo = get_comments_string(ST_SALESINVOICE, $i); // if ($memo != "") // { // $rep->NewLine(); // $rep->TextColLines(1, 5, $memo, -2); // } $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($sign * $myrow["ov_freight"], $dec); $customer_record = get_customer_details($myrow['reference']); $total = $SubTotal + $TotalDiscount; $subtot = $SubTotal - $urrow['ov_discount']; $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_SALESINVOICE; $rep->fontSize += 4; $rep->Font('bold'); $rep->Line(); $rep->TextCol(3, 6, _("Total: "), -2); $rep->TextCol(6, 7, $total, -2); //$rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); if ($TotalDiscount > 0 || $urrow['ov_discount'] > 0) { $rep->TextCol(3, 6, _("Discount(s)"), -2); $rep->TextCol(6, 7, '- ' . ($TotalDiscount + $urrow['ov_discount']) . '', -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $subtot, -2); $rep->NewLine(); } // if($urrow['ov_discount']>0) // { // $rep->TextCol(3, 6, _("Cash Discount") . ": ", -2); // $rep->TextCol(6, 7, '('.$urrow['ov_discount'].')', -2); // $rep->NewLine(); // } if ($transId['amt'] != NULL) { $rep->TextCol(3, 6, _("Paid"), -2); $rep->TextCol(6, 7, $transId['amt'], -2); $rep->NewLine(); } $subtot - $transId['amt'] == 0 ? '' : $rep->TextCol(3, 6, _("Due"), -2); $rep->TextCol(6, 7, $subtot - $transId['amt'] == 0 ? 'Full Paid' : $subtot - $transId['amt'], -2); $rep->NewLine(); $tax_items = get_trans_tax_details(ST_SALESINVOICE, $i); $first = true; while ($tax_item = db_fetch($tax_items)) { if ($tax_item['amount'] == 0) { continue; } $DisplayTax = number_format2($sign * $tax_item['amount'], $dec); if (isset($suppress_tax_rates) && $suppress_tax_rates == 1) { $tax_type_name = $tax_item['tax_type_name']; } else { $tax_type_name = $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) "; } // if($TotalDiscount>0){ // $rep->TextCol(3, 7, _("Total Discount") . ": " . $TotalDiscount.'+'.$urrow['ov_discount'], -2); // $rep->NewLine(); // } if ($tax_item['included_in_price']) { if (isset($alternative_tax_include_on_docs) && $alternative_tax_include_on_docs == 1) { if ($first) { $rep->TextCol(3, 6, _("Total Tax Excluded"), -2); $rep->TextCol(6, 7, number_format2($sign * $tax_item['net_amount'], $dec), -2); $rep->NewLine(); } $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); $first = false; } //else // $rep->TextCol(3, 7, _("Included") . " " . $tax_type_name . _("Amount") . ": " . $DisplayTax, -2); } else { $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($sign * ($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"] + $myrow["ov_freight_tax"]), $dec); $rep->TextCol(3, 6, _("TOTAL INVOICE"), -2); $rep->TextCol(6, 7, $DisplayTotal - $urrow['ov_discount'], -2); //$words = price_in_words($myrow['Total'], ST_SALESINVOICE); $words = price_in_words($transId['amt'], ST_CUSTPAYMENT); // $words =$myrow['Total']; $rep->Font(); if ($words != "") { $rep->NewLine(3); //$rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); $rep->TextCol(1, 7, "Taka " . $words . " Recieved. Thank You.", -2); } $memo = get_comments_string(ST_SALESINVOICE, $i); if ($memo != "") { $rep->NewLine(); $rep->Font('bold'); $rep->TextColLines(1, 5, 'Remarks: ' . $memo, -2); $rep->Font(); } if ($email == 1) { $rep->End($email); } $rep->fontSize -= 4; $rep->Font(); $rep->NewLine(1); $mytime = date('m/d/Y h:i:s a', time()); $rep->TextColLines(4, 7, 'Printed by ' . $_SESSION["wa_current_user"]->name . ' at ' . $mytime, -2); } if ($email == 0) { $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_aged_customer_analysis() { global $comp_path, $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']; $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 ($fromcust == reserved_words::get_all_numeric()) { $from = tr('All'); } else { $from = get_customer_name($fromcust); } $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('Customer'), '', '', 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('Customer'), '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 Customer Analysis'), "AgedCustomerAnalysis.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $total = array(0, 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) { $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; $custrec = get_customer_details($myrow['debtor_no'], $to); foreach ($custrec as $i => $value) { $custrec[$i] *= $rate; } $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"]; $str = array(number_format2($custrec["Balance"] - $custrec["Due"], $dec), number_format2($custrec["Due"] - $custrec["Overdue1"], $dec), number_format2($custrec["Overdue1"] - $custrec["Overdue2"], $dec), number_format2($custrec["Overdue2"], $dec), number_format2($custrec["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['debtor_no'], $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); if ($trans['type'] == 11 || $trans['type'] == 12 || $trans['type'] == 2) { $trans['Balance'] *= -1; $trans['Due'] *= -1; $trans['Overdue1'] *= -1; $trans['Overdue2'] *= -1; } 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() . "/images/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(); }
<?php include_once 'header.php'; include_once '_database/database.php'; include_once 'functions/functions.php'; ?> <?php if (isset($_SESSION['userID'])) { $userID = $_SESSION['userID']; } if (isset($_GET['user'])) { $userID = $_GET['user']; } $result = get_user_details($userID); $user = mysqli_fetch_assoc($result); $result2 = get_customer_details($userID); $sp = mysqli_fetch_assoc($result2); ?> <div id="fullscreen"> <div id="fullscreen-inner"> <div id="fullscreen-inner-left" class="fullscreen-inner-button"><span class="icon-caret-left"></span></div> <div id="fullscreen-inner-right" class="fullscreen-inner-button"><span class="icon-caret-right"></span></div> <div id="fullscreen-inner-close" class="fullscreen-inner-button"><span class="icon-close"></span></div> <div id="fullscreen-image"></div> </div> </div> <div id="apDivContainer">