function print_list_of_journal_entries() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; $systype = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; $dec = user_price_dec(); $cols = array(0, 100, 240, 300, 400, 460, 520, 580); $headers = array(tr('Type/Account'), tr('Account Name'), tr('Date/Dim.'), tr('Person/Item/Memo'), tr('Debit'), tr('Credit')); $aligns = array('left', 'left', 'left', 'left', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Type'), 'from' => systypes::name($systype), 'to' => '')); $rep = new FrontReport(tr('List of Journal Entries'), "JournalEntries.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); if ($systype == -1) { $systype = null; } $trans = get_gl_transactions($from, $to, -1, null, 0, $systype); $typeno = 0; while ($myrow = db_fetch($trans)) { if ($typeno != $myrow['type_no']) { if ($typeno != 0) { $rep->Line($rep->row + 4); $rep->NewLine(); } $typeno = $myrow['type_no']; $TransName = systypes::name($myrow['type']); $rep->TextCol(0, 2, $TransName . " # " . $myrow['type_no']); $rep->TextCol(2, 3, sql2date($myrow['tran_date'])); $coms = payment_person_types::person_name($myrow["person_type_id"], $myrow["person_id"]); $memo = get_comments_string($myrow['type'], $myrow['type_no']); if ($memo != '') { $coms .= $coms != "" ? "/" : "" . $memo; } $rep->TextCol(3, 6, $coms); $rep->NewLine(2); } $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) { $rep->TextCol(4, 5, number_format2(abs($myrow['amount']), $dec)); } else { $rep->TextCol(5, 6, number_format2(abs($myrow['amount']), $dec)); } $rep->NewLine(1, 2); } $rep->Line($rep->row + 4); $rep->End(); }
function print_Chart_of_Accounts() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $showbalance = $_REQUEST['PARAM_0']; $comments = $_REQUEST['PARAM_1']; $dec = 0; $cols = array(0, 50, 300, 425, 500); $headers = array(tr('Account'), tr('Account Name'), tr('Account Code'), tr('Balance')); $aligns = array('left', 'left', 'left', 'right'); $params = array(0 => $comments); $rep = new FrontReport(tr('Chart of Accounts'), "ChartOfAccounts.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $classname = ''; $group = ''; $accounts = get_gl_accounts_all(); while ($account = db_fetch($accounts)) { if ($showbalance == 1) { $begin = begin_fiscalyear(); if (is_account_balancesheet($account["account_code"])) { $begin = ""; } $balance = get_gl_trans_from_to($begin, ToDay(), $account["account_code"], 0); } if ($account['AccountTypeName'] != $group) { if ($classname != '') { $rep->row -= 4; } if ($account['AccountClassName'] != $classname) { $rep->Font('bold'); $rep->TextCol(0, 4, $account['AccountClassName']); $rep->Font(); $rep->row -= $rep->lineHeight + 4; } $group = $account['AccountTypeName']; $rep->TextCol(0, 4, $account['AccountTypeName']); //$rep->Line($rep->row - 4); $rep->row -= $rep->lineHeight + 4; } $classname = $account['AccountClassName']; $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); $rep->TextCol(2, 3, $account['account_code2']); if ($showbalance == 1) { $rep->TextCol(3, 4, number_format2($balance, $dec)); } $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } $rep->Line($rep->row); $rep->End(); }
function render($id, $title) { global $path_to_root; include_once $path_to_root . "/reporting/includes/class.graphic.inc"; $begin = begin_fiscalyear(); $today = Today(); $begin1 = date2sql($begin); $today1 = date2sql($today); $sql = "SELECT SUM(amount) AS total, c.class_name, c.ctype FROM\n " . TB_PREF . "gl_trans," . TB_PREF . "chart_master AS a, " . TB_PREF . "chart_types AS t,\n " . TB_PREF . "chart_class AS c WHERE\n account = a.account_code AND a.account_type = t.id AND t.class_id = c.cid\n AND IF(c.ctype > 3, tran_date >= '{$begin1}', tran_date >= '0000-00-00')\n AND tran_date <= '{$today1}' "; if ($this->data_filter != '') { $sql .= ' AND ' . $this->data_filter; } $sql .= " GROUP BY c.cid ORDER BY c.cid"; $result = db_query($sql, "Transactions could not be calculated"); $calculated = _("Calculated Return"); if ($this->graph_type == 'Table') { start_table(TABLESTYLE2, "width=98%"); $total = 0; while ($myrow = db_fetch($result)) { if ($myrow['ctype'] > 3) { $total += $myrow['total']; $myrow['total'] = -$myrow['total']; } label_row($myrow['class_name'], number_format2($myrow['total'], user_price_dec()), "class='label' style='font-weight:bold;'", "style='font-weight:bold;' align=right"); } label_row(" ", ""); label_row($calculated, number_format2(-$total, user_price_dec()), "class='label' style='font-weight:bold;'", "style='font-weight:bold;' align=right"); end_table(1); } else { $pg = new graph(); $i = 0; $total = 0; while ($myrow = db_fetch($result)) { if ($myrow['ctype'] > 3) { $total += $myrow['total']; $myrow['total'] = -$myrow['total']; $pg->x[$i] = $myrow['class_name']; $pg->y[$i] = abs($myrow['total']); $i++; } } $pg->x[$i] = $calculated; $pg->y[$i] = -$total; $pg->title = $title; $pg->axis_x = _("Class"); $pg->axis_y = _("Amount"); $pg->graphic_1 = $today; $pg->type = 5; $pg->skin = 1; $pg->built_in = false; $filename = company_path() . "/pdf_files/" . uniqid("") . ".png"; $pg->display($filename, true); echo "<img src='{$filename}' border='0' alt='{$title}' style='max-width:100%'>"; } }
function display_po_receive_items() { div_start('grn_items'); start_table(TABLESTYLE, "colspan=7 width='90%'"); $th = array(_("Item Code"), _("Description"), _("Ordered"), _("Units"), _("Received"), _("Outstanding"), _("This Delivery"), _("Price"), _("Total")); table_header($th); /*show the line items on the order with the quantity being received for modification */ $total = 0; $k = 0; //row colour counter if (count($_SESSION['PO']->line_items) > 0) { foreach ($_SESSION['PO']->line_items as $ln_itm) { alt_table_row_color($k); $qty_outstanding = $ln_itm->quantity - $ln_itm->qty_received; if (!isset($_POST['Update']) && !isset($_POST['ProcessGoodsReceived']) && $ln_itm->receive_qty == 0) { //If no quantites yet input default the balance to be received $ln_itm->receive_qty = $qty_outstanding; } $line_total = $ln_itm->receive_qty * $ln_itm->price; $total += $line_total; label_cell($ln_itm->stock_id); if ($qty_outstanding > 0) { text_cells(null, $ln_itm->stock_id . "Desc", $ln_itm->item_description, 30, 50); } else { label_cell($ln_itm->item_description); } $dec = get_qty_dec($ln_itm->stock_id); qty_cell($ln_itm->quantity, false, $dec); label_cell($ln_itm->units); qty_cell($ln_itm->qty_received, false, $dec); qty_cell($qty_outstanding, false, $dec); if ($qty_outstanding > 0) { qty_cells(null, $ln_itm->line_no, number_format2($ln_itm->receive_qty, $dec), "align=right", null, $dec); } else { label_cell(number_format2($ln_itm->receive_qty, $dec), "align=right"); } amount_decimal_cell($ln_itm->price); amount_cell($line_total); end_row(); } } $colspan = count($th) - 1; $display_sub_total = price_format($total); label_row(_("Sub-total"), $display_sub_total, "colspan={$colspan} align=right", "align=right"); $taxes = $_SESSION['PO']->get_taxes(input_num('freight_cost'), true); $tax_total = display_edit_tax_items($taxes, $colspan, $_SESSION['PO']->tax_included); $display_total = price_format($total + input_num('freight_cost') + $tax_total); start_row(); label_cells(_("Amount Total"), $display_total, "colspan={$colspan} align='right'", "align='right'"); end_row(); end_table(); div_end(); }
function display_po_receive_items() { global $table_style; start_table("colspan=7 {$table_style} width=90%"); $th = array(tr("Item Code"), tr("Description"), tr("Ordered"), tr("Units"), tr("Received"), tr("Outstanding"), tr("This Delivery"), tr("Price"), tr("Total")); table_header($th); /*show the line items on the order with the quantity being received for modification */ $total = 0; $k = 0; //row colour counter if (count($_SESSION['PO']->line_items) > 0) { foreach ($_SESSION['PO']->line_items as $ln_itm) { alt_table_row_color($k); $qty_outstanding = $ln_itm->quantity - $ln_itm->qty_received; if ($ln_itm->receive_qty == 0) { //If no quantites yet input default the balance to be received $ln_itm->receive_qty = $qty_outstanding; } $line_total = $ln_itm->receive_qty * $ln_itm->price; $total += $line_total; label_cell($ln_itm->stock_id); if ($qty_outstanding > 0) { text_cells(null, $ln_itm->stock_id . "Desc", $ln_itm->item_description, 30, 50); } else { label_cell($ln_itm->item_description); } qty_cell($ln_itm->quantity); label_cell($ln_itm->units); qty_cell($ln_itm->qty_received); qty_cell($qty_outstanding); if ($qty_outstanding > 0) { qty_cells(null, $ln_itm->line_no, qty_format($ln_itm->receive_qty), "align=right"); } else { qty_cells(null, $ln_itm->line_no, qty_format($ln_itm->receive_qty), "align=right", "disabled"); } amount_cell($ln_itm->price); amount_cell($line_total); end_row(); } } $display_total = number_format2($total, user_price_dec()); label_row(tr("Total value of items received"), $display_total, "colspan=8 align=right", "nowrap align=right"); end_table(); }
function display_rates($curr_code) { global $table_style; $result = get_exchange_rates($curr_code); br(2); start_table($table_style); $th = array(tr("Date to Use From"), tr("Exchange Rate"), "", ""); table_header($th); $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell(sql2date($myrow["date_"])); label_cell(number_format2($myrow["rate_buy"], user_exrate_dec()), "nowrap align=right"); edit_link_cell("selected_id=" . $myrow["id"]); delete_link_cell("selected_id=" . $myrow["id"] . "&delete=1"); end_row(); } //END WHILE LIST LOOP end_table(); }
function print_bill_of_material() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $frompart = $_REQUEST['PARAM_0']; $topart = $_REQUEST['PARAM_1']; $comments = $_REQUEST['PARAM_2']; $dec = user_qty_dec(); $cols = array(0, 50, 305, 375, 445, 515); $headers = array(tr('Component'), tr('Description'), tr('Loc'), tr('Wrk Ctr'), tr('Quantity')); $aligns = array('left', 'left', 'left', 'left', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Component'), 'from' => $frompart, 'to' => $topart)); $rep = new FrontReport(tr('Bill of Material Listing'), "BillOfMaterial.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $res = getTransactions($frompart, $topart); $parent = ''; while ($trans = db_fetch($res)) { if ($parent != $trans['parent']) { if ($parent != '') { $rep->Line($rep->row - 2); $rep->NewLine(2, 3); } $rep->TextCol(0, 1, $trans['parent']); $desc = get_item($trans['parent']); $rep->TextCol(1, 2, $desc['description']); $parent = $trans['parent']; $rep->NewLine(); } $rep->NewLine(); $rep->TextCol(0, 1, $trans['component']); $rep->TextCol(1, 2, $trans['CompDescription']); $rep->TextCol(2, 3, $trans['loc_code']); $rep->TextCol(3, 4, $trans['workcentre_added']); $rep->TextCol(4, 5, number_format2($trans['quantity'], $dec)); } $rep->Line($rep->row - 4); $rep->End(); }
function render($id, $title) { $sql = 'SELECT * FROM (SELECT max(trans_date) `Week End`, ' . 'concat(cast(case when weekofyear(trans_date) = 1 and month(trans_date)=12 then year(trans_date) + 1 else year(trans_date) end as char),cast(weekofyear(trans_date) as char)) `Week No`, ' . 'sum(case when weekday(trans_date)=0 then gross_output else 0 end) Monday, ' . 'sum(case when weekday(trans_date)=1 then gross_output else 0 end) Tuesday, ' . 'sum(case when weekday(trans_date)=2 then gross_output else 0 end) Wednesday, ' . 'sum(case when weekday(trans_date)=3 then gross_output else 0 end) Thursday, ' . 'sum(case when weekday(trans_date)=4 then gross_output else 0 end) Friday, ' . 'sum(case when weekday(trans_date)=5 then gross_output else 0 end) Saturday, ' . 'sum(case when weekday(trans_date)=6 then gross_output else 0 end) Sunday ' . 'FROM (SELECT bt.trans_date trans_date, ' . 'sum((ttd.net_amount+ttd.amount)*ex_rate) gross_output, ' . 'sum(ttd.net_amount*ex_rate) net_output, ' . 'sum(ttd.amount*ex_rate) payable ' . 'FROM ' . TB_PREF . 'bank_trans bt ' . 'INNER JOIN ' . TB_PREF . 'cust_allocations ca ' . 'ON bt.type = ca.trans_type_from ' . 'AND bt.trans_no = ca.trans_no_from ' . 'INNER JOIN ' . TB_PREF . 'debtor_trans dt ' . 'ON dt.type = ca.trans_type_from ' . 'AND dt.trans_no = ca.trans_no_from ' . 'INNER JOIN ' . TB_PREF . 'debtors_master dm ' . 'ON dt.debtor_no = dm.debtor_no ' . 'INNER JOIN ' . TB_PREF . 'trans_tax_details ttd ' . 'ON ttd.trans_type = ca.trans_type_to ' . 'AND ttd.trans_no = ca.trans_no_to ' . 'INNER JOIN ' . TB_PREF . 'tax_types tt ' . 'ON tt.id = ttd.tax_type_id '; if ($this->data_filter != '') { $sql .= ' WHERE ' . $this->data_filter; } $sql .= ' GROUP BY bt.trans_date ' . ') days ' . 'GROUP BY concat(cast(case when weekofyear(trans_date) = 1 and month(trans_date)=12 then year(trans_date) + 1 else year(trans_date) end as char),cast(weekofyear(trans_date) as char)) ' . 'ORDER BY max(trans_date) desc '; if (isset($this->top)) { $sql .= ' limit ' . $this->top; } $sql .= ") weeks ORDER BY `Week End`"; $result = db_query($sql) or die(_('Error getting daily sales data')); $rows = array(); //flag is not needed $flag = true; $table = array(); $table['cols'] = array(array('label' => 'Week End', 'type' => 'string'), array('label' => 'Monday', 'type' => 'number'), array('label' => 'Tuesday', 'type' => 'number'), array('label' => 'Wednesday', 'type' => 'number'), array('label' => 'Thursday', 'type' => 'number'), array('label' => 'Friday', 'type' => 'number'), array('label' => 'Saturday', 'type' => 'number'), array('label' => 'Sunday', 'type' => 'number')); $rows = array(); while ($r = db_fetch_assoc($result)) { $temp = array(); // the following line will used to slice the Pie chart $temp[] = array('v' => (string) $r['Week End'], 'f' => sql2date($r['Week End'])); $temp[] = array('v' => (double) $r['Monday'], 'f' => number_format2($r['Monday'], user_price_dec())); $temp[] = array('v' => (double) $r['Tuesday'], 'f' => number_format2($r['Tuesday'], user_price_dec())); $temp[] = array('v' => (double) $r['Wednesday'], 'f' => number_format2($r['Wednesday'], user_price_dec())); $temp[] = array('v' => (double) $r['Thursday'], 'f' => number_format2($r['Thursday'], user_price_dec())); $temp[] = array('v' => (double) $r['Friday'], 'f' => number_format2($r['Friday'], user_price_dec())); $temp[] = array('v' => (double) $r['Saturday'], 'f' => number_format2($r['Saturday'], user_price_dec())); $temp[] = array('v' => (double) $r['Sunday'], 'f' => number_format2($r['Sunday'], user_price_dec())); $rows[] = array('c' => $temp); } $table['rows'] = $rows; $jsonTable = json_encode($table); $js = "google.load('visualization', '1', {'packages':['corechart','table']});\ngoogle.setOnLoadCallback(drawChart" . $id . ");\nfunction drawChart" . $id . "() {\n var data = new google.visualization.DataTable(" . $jsonTable . ");\n var options = {"; if ($this->graph_type != 'Table') { $js .= "height: 300, "; } $js .= "title: '" . $title . "'\n };\n var chart" . $id . " = new google.visualization." . $this->graph_type . "(document.getElementById('widget_div_" . $id . "'));\n chart" . $id . ".draw(data, options);\n}"; add_js_source($js); }
function render($id, $title) { $sql = ''; if (isset($this->orderby)) { $sql .= 'SELECT `Week End`, `Week no`, `Gross Sales`, `Net Sales`, `Tax` ' . 'FROM ('; } $sql .= 'SELECT max(bt.trans_date) `Week End`, ' . 'weekofyear(bt.trans_date) `Week no`, ' . 'sum((ttd.net_amount+ttd.amount)*ex_rate) `Gross Sales`, ' . 'sum(ttd.net_amount*ex_rate) `Net Sales`, ' . 'sum(ttd.amount*ex_rate) `Tax` ' . 'FROM ' . TB_PREF . 'bank_trans bt ' . 'INNER JOIN ' . TB_PREF . 'cust_allocations ca ' . 'ON bt.type = ca.trans_type_from ' . 'AND bt.trans_no = ca.trans_no_from ' . 'INNER JOIN ' . TB_PREF . 'debtor_trans dt ' . 'ON dt.type = ca.trans_type_from ' . 'AND dt.trans_no = ca.trans_no_from ' . 'INNER JOIN ' . TB_PREF . 'debtors_master dm ' . 'ON dt.debtor_no = dm.debtor_no ' . 'INNER JOIN ' . TB_PREF . 'trans_tax_details ttd ' . 'ON ttd.trans_type = ca.trans_type_to ' . 'AND ttd.trans_no = ca.trans_no_to ' . 'INNER JOIN ' . TB_PREF . 'tax_types tt ' . 'ON tt.id = ttd.tax_type_id '; if ($this->data_filter != '') { $sql .= ' WHERE ' . $this->data_filter; } $sql .= ' GROUP BY weekofyear(bt.trans_date) '; if (isset($this->orderby)) { $sql .= ') items order by `' . $this->orderby . '` ' . $this->orderby_seq; } if (isset($this->top)) { $sql .= ' limit ' . $this->top; } $result = db_query($sql) or die(_('Error getting weekly sales data')); $rows = array(); //flag is not needed $flag = true; $table = array(); $table['cols'] = array(array('label' => 'Week End', 'type' => 'string'), array('label' => 'Gross Sales', 'type' => 'number')); $rows = array(); while ($r = db_fetch_assoc($result)) { $temp = array(); // the following line will used to slice the Pie chart $temp[] = array('v' => (string) $r['Week End'], 'f' => sql2date($r['Week End'])); $temp[] = array('v' => (double) $r['Gross Sales'], 'f' => number_format2($r['Gross Sales'], user_price_dec())); $rows[] = array('c' => $temp); } $table['rows'] = $rows; $jsonTable = json_encode($table); $js = "google.load('visualization', '1', {'packages':['corechart','table']});\ngoogle.setOnLoadCallback(drawChart" . $id . ");\nfunction drawChart" . $id . "() {\n var data = new google.visualization.DataTable(" . $jsonTable . ");\n var options = {"; if ($this->graph_type != 'Table') { $js .= "height: 300, "; } $js .= "title: '" . $title . "'\n };\n var chart" . $id . " = new google.visualization." . $this->graph_type . "(document.getElementById('widget_div_" . $id . "'));\n chart" . $id . ".draw(data, options);\n}"; add_js_source($js); }
function print_dimension_summary() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $fromdim = $_REQUEST['PARAM_0']; $todim = $_REQUEST['PARAM_1']; $showbal = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; $cols = array(0, 50, 210, 250, 320, 395, 465, 515); $headers = array(tr('Reference'), tr('Name'), tr('Type'), tr('Date'), tr('Due Date'), tr('Closed'), tr('YTD')); $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Dimension'), 'from' => $fromdim, 'to' => $todim)); $rep = new FrontReport(tr('Dimension Summary'), "DimensionSummary.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $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->TextCol(3, 4, $trans['date_']); $rep->TextCol(4, 5, $trans['due_date']); if ($trans['closed']) { $str = tr('Yes'); } else { $str = tr('No'); } $rep->TextCol(5, 6, $str); if ($showbal) { $balance = getYTD($trans['id']); $rep->TextCol(6, 7, number_format2($balance, 0)); } $rep->NewLine(1, 2); } $rep->Line($rep->row); $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); $urrow = get_customer_trans($transId['trans_no_from'], ST_CUSTPAYMENT); $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 += $DisplayPrice * ($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']); $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_SALESINVOICE; $rep->fontSize += 4; $rep->TextCol(3, 6, _("Total: "), -2); $rep->TextCol(6, 7, $DisplaySubTot + $TotalDiscount, -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(); } // if($urrow['ov_discount']>0) // { // $rep->TextCol(3, 6, _("Cash Discount") . ": ", -2); // $rep->TextCol(6, 7, '('.$urrow['ov_discount'].')', -2); // $rep->NewLine(); // } $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot - $urrow['ov_discount'], -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Paid"), -2); $rep->TextCol(6, 7, $transId['amt'], -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Due"), -2); $rep->TextCol(6, 7, $DisplaySubTot - $urrow['ov_discount'] - $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->Font('bold'); $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'], 0); // $words =$myrow['Total']; if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->fontSize -= 4; $rep->Font(); if ($email == 1) { $rep->End($email); } } if ($email == 0) { $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']; $customer = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; 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, 40, 60, 100, 200, 250, 300, 320, 400, 450, 500); // $headers in doctext.inc $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); //$params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); $company_data = get_company_prefs(); 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); if ($customer && $myrow['debtor_no'] != $customer) { continue; } $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(0); $rep->currency = $cur; $rep->Font(); $rep->Info(null, $cols, null, $aligns); //$contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], true); //$baccount['payment_service'] = $pay_service; $salesman = get_imc_code($branch['branch_code']); $pay_term = get_payment_terms($myrow['payment_terms']); $branch_data = get_branch_accounts($myrow['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']); $invoice_no = get_custom_no($myrow['trans_no'], $myrow['type']); $contact = getContactPerson($myrow['salesman'], $myrow['debtor_no'], $branch['branch_code']); $rep->NewPage(); $result = get_customer_trans_details(ST_SALESINVOICE, $i); $SubTotal = 0; $rep->NewLine(8); $rep->TextCol(2, 7, _("CHARGE INVOICE # " . $invoice_no)); $rep->TextCol(8, 9, $myrow['TranDate']); $rep->NewLine(); $rep->TextCol(2, 7, $branch['br_name']); if ($dt != 0) { //$display_bulk_discount = (($sub_total - $myrow['Total']) / $sub_total) * 100; $tot = $myrow['Total'] + $dt; $dscnt = ($tot - $myrow['Total']) / $tot * 100; //$dscnt = ($dt / $myrow['Total']) * 100; $significant = strlen(substr(strrchr($dscnt, "."), 1)); if ($significant > 2) { $rep->TextCol(7, 9, floor($dscnt) . "%"); } else { $rep->TextCol(7, 9, $dscnt . "%"); } } $rep->NewLine(); $rep->TextCol(2, 7, $branch['branch_ref']); $rep->TextCol(8, 9, $salesman); $rep->NewLine(); $rep->TextCol(2, 6, $contact); if ($pay_term['terms'] == 'Cash Only') { $rep->TextCol(8, 9, $pay_term['terms']); } else { $rep->TextCol(7, 10, $pay_term['terms']); } $rep->NewLine(); $oldrow = $rep->row; $newrow = $rep->row; $rep->TextColLines(2, 6, $branch['br_address'], -2); $rep->row = $oldrow; $rep->NewLine(5); $rep->Font('bold'); //$rep->Line($rep->row + 10); //$rep->TextCol(2,5, _("Item Description")); //$rep->TextCol(5,6, _("Quantity")); //$rep->TextCol(7,8, _("Unit Price")); //$rep->TextCol(9,10, _("Total Amount")); //$rep->Line($rep->row - 4); $rep->NewLine(2); $rep->Font(); 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()); $Net2 = round2($sign * ($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); $dNet = number_format2($Net2, $dec); /*if ($myrow2["discount_percent"]==0) $DisplayDiscount =""; else $DisplayDiscount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%";*/ //if ($myrow["ov_discount"]==0) // $DisplayDiscount =""; //else //$DisplayDiscount = number_format2($myrow["ov_discount"]/$myrow["ov_amount"] * 100,user_percent_dec()) . "%"; //$rep->TextCol(0, 3, $myrow2['stock_id'], -2); $oldrow = $rep->row; $rep->TextColLines(0, 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(5, 6, $DisplayQty . " " . $myrow2['units']); //$rep->TextCol(5, 6, $myrow2['units'], -2); $rep->TextCol(7, 8, $DisplayPrice, -2); //$rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(8, 10, $dNet, -2); } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } $memo = get_comments_string(ST_SALESINVOICE, $i); if ($memo != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $memo, -2); } $DisplayNet = number_format2($SubTotal, $dec); $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($sign * $myrow["ov_freight"], $dec); $DisplayTots = number_format2($myrow['Total'], $dec); $DisplayDiscount = number_format2($SubTotal - $myrow['Total'], $dec); $rep->row = $rep->bottomMargin + 30 * $rep->lineHeight; $doctype = ST_SALESINVOICE; $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(9, 10, $DisplayNet, -2); $rep->NewLine(); //$rep->TextCol(8, 9, _("Less discount: ")); $rep->TextCol(9, 10, $DisplayDiscount, -2); $rep->NewLine(); //$rep->TextCol(8, 9, _("Net Amount : "), -2); $rep->TextCol(9, 10, $DisplayTots, -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 ($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->Font('bold'); //$rep->TextCol(3, 6, _("TOTAL INVOICE"), - 2); //$rep->TextCol(6, 7, $DisplayTotal, -2); //$words = price_in_words($myrow['Total'], ST_SALESINVOICE); //if ($words != "") //{ // $rep->NewLine(1); // $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); //} //$rep->Font(); if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
label_cell($date_); if (!isset($_POST['amount' . $i])) { $_POST['amount' . $i] = '0'; } amount_cells(null, 'amount' . $i, null, 15, null, 0); if ($showdims) { $d = get_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']); label_cell(number_format2($d, 0), "nowrap align=right"); $btotal += $d; } $lamount = get_gl_trans_from_to(add_years($date_, -1), add_years(end_month($date_), -1), $_POST['account'], $_POST['dim1'], $_POST['dim2']); $total += input_num('amount' . $i); $ltotal += $lamount; label_cell(number_format2($lamount, 0), "nowrap align=right"); $date_ = add_months($date_, 1); end_row(); } start_row(); label_cell("<b>" . tr("Total") . "</b>"); label_cell("<b>" . number_format2($total, 0) . "</b>", 'align=right'); if ($showdims) { label_cell("<b>" . number_format2($btotal, 0) . "</b>", "nowrap align=right"); } label_cell("<b>" . number_format2($ltotal, 0) . "</b>", "nowrap align=right"); end_row(); end_table(1); submit_center_first('add', tr("Save")); submit_center_last('delete', tr("Delete")); } end_form(); end_page();
function dec_amount($row, $amount) { return number_format2($amount, $row['decimals']); }
edit_button_cell("Edit" . $myrow['requisition_detail_id'], _("Edit")); delete_button_cell("Delete" . $myrow['requisition_detail_id'], _("Delete")); end_row(); } end_table(1); //----------------------------------------------------------------------------------- start_table(TABLESTYLE2); if ($selected_id != -1) { if ($Mode == 'Edit') { //editing an existing status code $myrow = get_requisition_detail($selected_id); $_POST['item_code'] = $myrow["item_code"]; $_POST['purpose'] = $myrow["purpose"]; $_POST['order_quantity'] = $myrow["order_quantity"]; $_POST['estimate_price'] = $myrow["estimate_price"]; } hidden('selected_id', $selected_id); } sales_local_items_list_row(_("Item :"), 'item_code', null, false, false); text_row(_("Purpose :"), 'purpose', null, 50, 50); $res = get_item_edit_info(get_post('item_code')); $dec = $res["decimals"] == '' ? 0 : $res["decimals"]; $units = $res["units"] == '' ? _('kits') : $res["units"]; qty_row(_("Requisition Quantity:"), 'order_quantity', number_format2(1, $dec), '', $units, $dec); amount_row(_("Estimate Price :"), 'estimate_price', null, null, null, 2); hidden('requisitionid'); end_table(1); submit_add_or_update_center($selected_id == -1, '', 'both'); end_form(); //------------------------------------------------------------------------------------ end_page();
function print_sales_orders() { global $path_to_root, $print_as_quote, $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']; $print_as_quote = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; if (!$from || !$to) { return; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $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) { if ($print_as_quote == 0) { $rep = new FrontReport(_("SALES ORDER"), "SalesOrderBulk", user_pagesize(), 9, $orientation); } else { $rep = new FrontReport(_("QUOTE"), "QuoteBulk", user_pagesize(), 9, $orientation); } } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { $myrow = get_sales_order_header($i, ST_SALESORDER); $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; $branch = get_branch($myrow["branch_code"]); if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); if ($print_as_quote == 1) { $rep->title = _('QUOTE'); $rep->filename = "Quote" . $i . ".pdf"; } else { $rep->title = _("SALES ORDER"); $rep->filename = "SalesOrder" . $i . ".pdf"; } } else { $rep->title = $print_as_quote == 1 ? _("QUOTE") : _("SALES ORDER"); } $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); $contacts = get_branch_contacts($branch['branch_code'], 'order', $branch['debtor_no'], true); $rep->SetCommonData($myrow, $branch, $myrow, $baccount, ST_SALESORDER, $contacts); $rep->NewPage(); $result = get_sales_order_details($i, ST_SALESORDER); $SubTotal = 0; $items = $prices = array(); while ($myrow2 = db_fetch($result)) { $Net = round2((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"], user_price_dec()); $prices[] = $Net; $items[] = $myrow2['stk_code']; $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], $dec); $DisplayQty = number_format2($myrow2["quantity"], get_qty_dec($myrow2['stk_code'])); $DisplayNet = number_format2($Net, $dec); if ($myrow2["discount_percent"] == 0) { $DisplayDiscount = ""; } else { $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, user_percent_dec()) . "%"; } $rep->TextCol(0, 1, $myrow2['stk_code'], -2); $oldrow = $rep->row; $rep->TextColLines(1, 2, $myrow2['description'], -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(4, 5, $DisplayPrice, -2); $rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(6, 7, $DisplayNet, -2); } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } if ($myrow['comments'] != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $myrow['comments'], -2); } $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($myrow["freight_cost"], $dec); $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_SALESORDER; $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Shipping"), -2); $rep->TextCol(6, 7, $DisplayFreight, -2); $rep->NewLine(); $DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec); if ($myrow['tax_included'] == 0) { $rep->TextCol(3, 6, _("TOTAL ORDER EX VAT"), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $rep->NewLine(); } $tax_items = get_tax_for_items($items, $prices, $myrow["freight_cost"], $myrow['tax_group_id'], $myrow['tax_included'], null); $first = true; foreach ($tax_items as $tax_item) { if ($tax_item['Value'] == 0) { continue; } $DisplayTax = number_format2($tax_item['Value'], $dec); $tax_type_name = $tax_item['tax_type_name']; if ($myrow['tax_included']) { 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 { $SubTotal += $tax_item['Value']; $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec); $rep->Font('bold'); $rep->TextCol(3, 6, _("TOTAL ORDER VAT INCL."), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $words = price_in_words($myrow["freight_cost"] + $SubTotal, ST_SALESORDER); if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->Font(); if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
if ($show_currencies) { label_cells(_("Payment Currency"), $receipt['bank_curr_code'], "class='tableheader2'"); } label_cells(_("Amount"), number_format2(-$receipt['bank_amount'], user_price_dec()), "class='tableheader2'"); if ($receipt['ov_discount'] != 0) { label_cells(_("Discount"), number_format2(-$receipt['ov_discount'] * $receipt['rate'], user_price_dec()), "class='tableheader2'"); } else { label_cells(_("Payment Type"), $bank_transfer_types[$receipt['BankTransType']], "class='tableheader2'"); } end_row(); start_row(); if ($show_currencies) { label_cells(_("Supplier's Currency"), $receipt['curr_code'], "class='tableheader2'"); } if ($show_both_amounts) { label_cells(_("Amount"), number_format2(-$receipt['Total'], user_price_dec()), "class='tableheader2'"); } label_cells(_("Reference"), $receipt['ref'], "class='tableheader2'"); end_row(); if ($receipt['ov_discount'] != 0) { start_row(); label_cells(_("Payment Type"), $bank_transfer_types[$receipt['BankTransType']], "class='tableheader2'"); end_row(); } comments_display_row(ST_SUPPAYMENT, $trans_no); end_table(1); $voided = is_voided_display(ST_SUPPAYMENT, $trans_no, _("This payment has been voided.")); // now display the allocations for this payment if (!$voided) { display_allocations_from(PT_SUPPLIER, $receipt['supplier_id'], ST_SUPPAYMENT, $trans_no, -$receipt['Total']); }
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(); }
$_POST['loc_code'] = $myrow["loc_code"]; $_POST['component'] = $myrow["component"]; // by Tom Moulton $_POST['workcentre_added'] = $myrow["workcentre_added"]; $_POST['quantity'] = number_format2($myrow["quantity"], get_qty_dec($myrow["component"])); label_row(_("Component:"), $myrow["component"] . " - " . $myrow["description"]); } hidden('selected_id', $selected_id); } else { start_row(); label_cell(_("Component:"), "class='label'"); echo "<td>"; echo stock_component_items_list('component', $selected_parent, null, false, true); if (get_post('_component_update')) { $Ajax->activate('quantity'); } echo "</td>"; end_row(); } hidden('stock_id', $selected_parent); locations_list_row(_("Location to Draw From:"), 'loc_code', null); workcenter_list_row(_("Work Centre Added:"), 'workcentre_added', null); $dec = get_qty_dec(get_post('component')); $_POST['quantity'] = number_format2(input_num('quantity', 1), $dec); qty_row(_("Quantity:"), 'quantity', null, null, null, $dec); end_table(1); submit_add_or_update_center($selected_id == -1, '', 'both'); end_form(); } // ---------------------------------------------------------------------------------- end_page();
function print_deliveries() { global $path_to_root, $packing_slip, $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']; $email = $_POST['PARAM_2']; $packing_slip = $_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, 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) { if ($packing_slip == 0) { $rep = new FrontReport(_('DELIVERY'), "DeliveryNoteBulk", user_pagesize(), 9, $orientation); } else { $rep = new FrontReport(_('PACKING SLIP'), "PackingSlipBulk", user_pagesize(), 9, $orientation); } } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { if (!exists_customer_trans(ST_CUSTDELIVERY, $i)) { continue; } $myrow = get_customer_trans($i, ST_CUSTDELIVERY); $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); if ($packing_slip == 0) { $rep->title = _('DELIVERY NOTE'); $rep->filename = "Delivery" . $myrow['reference'] . ".pdf"; } else { $rep->title = _('PACKING SLIP'); $rep->filename = "Packing_slip" . $myrow['reference'] . ".pdf"; } } $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); $contacts = get_branch_contacts($branch['branch_code'], 'delivery', $branch['debtor_no'], true); $rep->SetCommonData($myrow, $branch, $sales_order, '', ST_CUSTDELIVERY, $contacts); $rep->NewPage(); $result = get_customer_trans_details(ST_CUSTDELIVERY, $i); $SubTotal = 0; while ($myrow2 = db_fetch($result)) { if ($myrow2["quantity"] == 0) { continue; } $Net = round2((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"], user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], $dec); $DisplayQty = number_format2($myrow2["quantity"], get_qty_dec($myrow2['stock_id'])); $DisplayNet = number_format2($Net, $dec); if ($myrow2["discount_percent"] == 0) { $DisplayDiscount = ""; } else { $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, user_percent_dec()) . "%"; } $rep->TextCol(0, 1, $myrow2['stock_id'], -2); $oldrow = $rep->row; $rep->TextColLines(1, 2, $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); if ($packing_slip == 0) { $rep->TextCol(4, 5, $DisplayPrice, -2); $rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(6, 7, $DisplayNet, -2); } } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } $memo = get_comments_string(ST_CUSTDELIVERY, $i); if ($memo != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $memo, -2); } $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($myrow["ov_freight"], $dec); $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_CUSTDELIVERY; if ($packing_slip == 0) { $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Shipping"), -2); $rep->TextCol(6, 7, $DisplayFreight, -2); $rep->NewLine(); $tax_items = get_trans_tax_details(ST_CUSTDELIVERY, $i); $first = true; while ($tax_item = db_fetch($tax_items)) { if ($tax_item['amount'] == 0) { continue; } $DisplayTax = number_format2($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 ($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($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($myrow["ov_freight"] + $myrow["ov_freight_tax"] + $myrow["ov_gst"] + $myrow["ov_amount"], $dec); $rep->Font('bold'); $rep->TextCol(3, 6, _("TOTAL DELIVERY INCL. VAT"), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $words = price_in_words($myrow['Total'], ST_CUSTDELIVERY); if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->Font(); } if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
function check_data() { if (!get_post('stock_id_text', true)) { display_error(_("Item description cannot be empty.")); set_focus('stock_id_edit'); return false; } $dec = get_qty_dec($_POST['stock_id']); $min = 1 / pow(10, $dec); if (!check_num('qty', $min)) { $min = number_format2($min, $dec); display_error(_("The quantity of the order item must be numeric and not less than ") . $min); set_focus('qty'); return false; } if (!check_num('price', 0)) { display_error(_("The price entered must be numeric and not less than zero.")); set_focus('price'); return false; } if ($_SESSION['PO']->trans_type == ST_PURCHORDER && !is_date($_POST['req_del_date'])) { display_error(_("The date entered is in an invalid format.")); set_focus('req_del_date'); return false; } return true; }
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 = 0; // $pay_service = $_POST['PARAM_4']; // $comments = $_POST['PARAM_5']; // $customer = $_POST['PARAM_6']; $orientation = 'L'; // // 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); // if($customer && $myrow['debtor_no'] != $customer) { // continue; // } //$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); $result = get_referral_details(); $SubTotal = 0; while ($myrow2 = db_fetch($result)) { if ($myrow2["quantity"] == 0) { continue; } $rep->TextCol(0, 1, $myrow2['Date'], -2); $oldrow = $rep->row; $rep->TextColLines(1, 2, $myrow2['Invoice'], -2); $newrow = $rep->row; $rep->row = $oldrow; $rep->TextCol(2, 3, $myrow2['Name'], -2); $rep->TextCol(3, 4, $myrow2['Bill'], -2); $rep->TextCol(4, 5, $myrow2['10%'], -2); $rep->TextCol(5, 6, $myrow2['10% Dis'], -2); $rep->TextCol(6, 7, $myrow2['15%'], -2); $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_SALESINVOICE; $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Shipping"), -2); $rep->TextCol(6, 7, $DisplayFreight, -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 ($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->Font('bold'); $rep->TextCol(3, 6, _("TOTAL INVOICE"), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $words = price_in_words($myrow['Total'], ST_SALESINVOICE); if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->Font(); if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
function print_inventory_planning() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $category = $_REQUEST['PARAM_0']; $location = $_REQUEST['PARAM_1']; $comments = $_REQUEST['PARAM_2']; $dec = user_qty_dec(); if ($category == reserved_words::get_all_numeric()) { $category = 0; } if ($category == 0) { $cat = tr('All'); } else { $cat = get_category_name($category); } if ($location == reserved_words::get_all()) { $location = 'all'; } if ($location == 'all') { $loc = tr('All'); } else { $loc = $location; } $cols = array(0, 50, 150, 180, 210, 240, 270, 300, 330, 390, 435, 480, 525); $per0 = strftime('%b', mktime(0, 0, 0, date('m'), date('d'), date('Y'))); $per1 = strftime('%b', mktime(0, 0, 0, date('m') - 1, date('d'), date('Y'))); $per2 = strftime('%b', mktime(0, 0, 0, date('m') - 2, date('d'), date('Y'))); $per3 = strftime('%b', mktime(0, 0, 0, date('m') - 3, date('d'), date('Y'))); $per4 = strftime('%b', mktime(0, 0, 0, date('m') - 4, date('d'), date('Y'))); $headers = array(tr('Category'), '', $per4, $per3, $per2, $per1, $per0, '3*M', tr('QOH'), tr('Cust Ord'), tr('Supp Ord'), tr('Sugg Ord')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => tr('Location'), 'from' => $loc, 'to' => '')); $rep = new FrontReport(tr('Inventory Planning Report'), "InventoryPlanning.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $res = getTransactions($category, $location); $catt = ''; while ($trans = db_fetch($res)) { if ($catt != $trans['cat_description']) { if ($catt != '') { $rep->Line($rep->row - 2); $rep->NewLine(2, 3); } $rep->TextCol(0, 1, $trans['category_id']); $rep->TextCol(1, 2, $trans['cat_description']); $catt = $trans['cat_description']; $rep->NewLine(); } $custqty = getCustQty($trans['stock_id'], $trans['loc_code']); $custqty += getCustAsmQty($trans['stock_id'], $trans['loc_code']); $suppqty = getSuppQty($trans['stock_id'], $trans['loc_code']); $period = getPeriods($trans['stock_id'], $trans['loc_code']); $rep->NewLine(); $rep->TextCol(0, 1, $trans['stock_id']); $rep->TextCol(1, 2, $trans['description']); $rep->TextCol(2, 3, number_format2($period['prd0'], $dec)); $rep->TextCol(3, 4, number_format2($period['prd1'], $dec)); $rep->TextCol(4, 5, number_format2($period['prd2'], $dec)); $rep->TextCol(5, 6, number_format2($period['prd3'], $dec)); $rep->TextCol(6, 7, number_format2($period['prd4'], $dec)); $MaxMthSales = Max($period['prd0'], $period['prd1'], $period['prd2'], $period['prd3']); $IdealStockHolding = $MaxMthSales * 3; $rep->TextCol(7, 8, number_format2($IdealStockHolding, $dec)); $rep->TextCol(8, 9, number_format2($trans['qty_on_hand'], $dec)); $rep->TextCol(9, 10, number_format2($custqty, $dec)); $rep->TextCol(10, 11, number_format2($suppqty, $dec)); $SuggestedTopUpOrder = $IdealStockHolding - $trans['qty_on_hand'] + $custqty - $suppqty; if ($SuggestedTopUpOrder < 0.0) { $SuggestedTopUpOrder = 0.0; } $rep->TextCol(11, 12, number_format2($SuggestedTopUpOrder, $dec)); } $rep->Line($rep->row - 4); $rep->End(); }
while ($myrow = db_fetch($vresult)) { alt_table_row_color($k); label_cell($myrow["valuation_year"]); amount_cell($myrow["asset_value"]); amount_cell($myrow["value_change"]); delete_button_cell("Delete" . $myrow['asset_valuation_id'], _("Delete")); end_row(); } end_table(1); start_table(TABLESTYLE2); if ($selected_id != -1) { if ($Mode == 'Edit') { //editing an existing status code $myrow = get_asset_valuation($selected_id); $_POST['valuationyear'] = $myrow["valuation_year"]; $_POST['assetvalue'] = number_format2($myrow["asset_value"], 2); } hidden('selected_id', $selected_id); } text_row(_("Year of Valuation :"), 'valuationyear', null, 50, 50); amount_row(_("Asset Value :"), 'assetvalue', null, null, null, 2); echo "<input type='hidden' id='assetid' name='assetid' value='" . $_POST['assetid'] . "'/>"; end_table(1); submit_add_or_update_center($selected_id == -1, '', 'both'); end_form(); // --------------------------------------------------------------------------------------------- echo "<hr/>\n"; $aresult = get_all_amortisation($_POST['assetid']); start_form(); start_table(TABLESTYLE, "width=50%"); $th = array(_("Year"), _("Asset Value"), _("Depreciation"));
} display_heading($systypes_array[ST_BANKTRANSFER] . " #{$trans_no}"); echo "<br>"; start_table(TABLESTYLE, "width=80%"); start_row(); label_cells(_("From Bank Account"), $from_trans['bank_account_name'], "class='tableheader2'"); if ($show_currencies) { label_cells(_("Currency"), $from_trans['bank_curr_code'], "class='tableheader2'"); } label_cells(_("Amount"), number_format2(-$from_trans['amount'], user_price_dec()), "class='tableheader2'", "align=right"); if ($show_currencies) { end_row(); start_row(); } label_cells(_("To Bank Account"), $to_trans['bank_account_name'], "class='tableheader2'"); if ($show_currencies) { label_cells(_("Currency"), $to_trans['bank_curr_code'], "class='tableheader2'"); } if ($show_both_amounts) { label_cells(_("Amount"), number_format2($to_trans['amount'], user_price_dec()), "class='tableheader2'", "align=right"); } end_row(); start_row(); label_cells(_("Date"), sql2date($from_trans['trans_date']), "class='tableheader2'"); label_cells(_("Transfer Type"), $bank_transfer_types[$from_trans['account_type']], "class='tableheader2'"); label_cells(_("Reference"), $from_trans['ref'], "class='tableheader2'"); end_row(); comments_display_row(ST_BANKTRANSFER, $trans_no); end_table(1); is_voided_display(ST_BANKTRANSFER, $trans_no, _("This transfer has been voided.")); end_page(true, false, false, ST_BANKTRANSFER, $trans_no);
function print_po() { global $path_to_root, $show_po_item_codes; 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(); $cols = array(4, 60, 225, 300, 340, 385, 450, 515); // $headers in doctext.inc $aligns = array('left', 'left', 'left', 'right', 'left', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); if ($email == 0) { $rep = new FrontReport(_('PURCHASE ORDER'), "PurchaseOrderBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { $myrow = get_po($i); $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); $rep->title = _('PURCHASE ORDER'); $rep->filename = "PurchaseOrder" . $i . ".pdf"; } $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); $contacts = get_supplier_contacts($myrow['supplier_id'], 'order'); $rep->SetCommonData($myrow, null, $myrow, $baccount, ST_PURCHORDER, $contacts); $rep->NewPage(); $result = get_po_details($i); $SubTotal = 0; $items = $prices = array(); while ($myrow2 = db_fetch($result)) { $data = get_purchase_data($myrow['supplier_id'], $myrow2['item_code']); if ($data !== false) { if ($data['supplier_description'] != "") { $myrow2['description'] = $data['supplier_description']; } if ($data['suppliers_uom'] != "") { $myrow2['units'] = $data['suppliers_uom']; } if ($data['conversion_factor'] != 1) { $myrow2['unit_price'] = round2($myrow2['unit_price'] * $data['conversion_factor'], user_price_dec()); $myrow2['quantity_ordered'] = round2($myrow2['quantity_ordered'] / $data['conversion_factor'], user_qty_dec()); } } $Net = round2($myrow2["unit_price"] * $myrow2["quantity_ordered"], user_price_dec()); $prices[] = $Net; $items[] = $myrow2['item_code']; $SubTotal += $Net; $dec2 = 0; $DisplayPrice = price_decimal_format($myrow2["unit_price"], $dec2); $DisplayQty = number_format2($myrow2["quantity_ordered"], get_qty_dec($myrow2['item_code'])); $DisplayNet = number_format2($Net, $dec); if ($show_po_item_codes) { $rep->TextCol(0, 1, $myrow2['item_code'], -2); $rep->TextCol(1, 2, $myrow2['description'], -2); } else { $rep->TextCol(0, 2, $myrow2['description'], -2); } $rep->TextCol(2, 3, sql2date($myrow2['delivery_date']), -2); $rep->TextCol(3, 4, $DisplayQty, -2); $rep->TextCol(4, 5, $myrow2['units'], -2); $rep->TextCol(5, 6, $DisplayPrice, -2); $rep->TextCol(6, 7, $DisplayNet, -2); $rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } if ($myrow['comments'] != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $myrow['comments'], -2); } $DisplaySubTot = number_format2($SubTotal, $dec); $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_PURCHORDER; $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); $tax_items = get_tax_for_items($items, $prices, 0, $myrow['tax_group_id'], $myrow['tax_included'], null); $first = true; foreach ($tax_items as $tax_item) { if ($tax_item['Value'] == 0) { continue; } $DisplayTax = number_format2($tax_item['Value'], $dec); $tax_type_name = $tax_item['tax_type_name']; if ($myrow['tax_included']) { 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 { $SubTotal += $tax_item['Value']; $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($SubTotal, $dec); $rep->Font('bold'); $rep->TextCol(3, 6, _("TOTAL PO"), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $words = price_in_words($SubTotal, ST_PURCHORDER); if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->Font(); if ($email == 1) { $myrow['DebtorName'] = $myrow['supp_name']; if ($myrow['reference'] == "") { $myrow['reference'] = $myrow['order_no']; } $rep->End($email); } } if ($email == 0) { $rep->End(); } }
read_supp_invoice($trans_no, ST_SUPPCREDIT, $supp_trans); display_heading("<font color=red>" . _("SUPPLIER CREDIT NOTE") . " # " . $trans_no . "</font>"); echo "<br>"; start_table(TABLESTYLE, "width=95%"); start_row(); label_cells(_("Supplier"), $supp_trans->supplier_name, "class='tableheader2'"); label_cells(_("Reference"), $supp_trans->reference, "class='tableheader2'"); label_cells(_("Supplier's Reference"), $supp_trans->supp_reference, "class='tableheader2'"); end_row(); start_row(); label_cells(_("Invoice Date"), $supp_trans->tran_date, "class='tableheader2'"); label_cells(_("Due Date"), $supp_trans->due_date, "class='tableheader2'"); label_cells(_("Currency"), get_supplier_currency($supp_trans->supplier_id), "class='tableheader2'"); end_row(); comments_display_row(ST_SUPPCREDIT, $trans_no); end_table(1); $total_gl = display_gl_items($supp_trans, 3); $total_grn = display_grn_items($supp_trans, 2); $display_sub_tot = number_format2($total_gl + $total_grn, user_price_dec()); start_table(TABLESTYLE, "width=95%"); label_row(_("Sub Total"), $display_sub_tot, "align=right", "nowrap align=right width=17%"); $tax_items = get_trans_tax_details(ST_SUPPCREDIT, $trans_no); display_supp_trans_tax_details($tax_items, 1); $display_total = number_format2(-($supp_trans->ov_amount + $supp_trans->ov_gst), user_price_dec()); label_row("<font color=red>" . _("TOTAL CREDIT NOTE") . "</font", "<font color=red>{$display_total}</font>", "colspan=1 align=right", "nowrap align=right"); end_table(1); $voided = is_voided_display(ST_SUPPCREDIT, $trans_no, _("This credit note has been voided.")); if (!$voided) { display_allocations_from(PT_SUPPLIER, $supp_trans->supplier_id, ST_SUPPCREDIT, $trans_no, -($supp_trans->ov_amount + $supp_trans->ov_gst)); } end_page(true, false, false, ST_SUPPCREDIT, $trans_no);
function check_item_data() { global $SysPrefs, $allow_negative_prices; $is_inventory_item = is_inventory_item(get_post('stock_id')); if (!get_post('stock_id_text', true)) { display_error(_("Item description cannot be empty.")); set_focus('stock_id_edit'); return false; } elseif (!check_num('qty', 0) || !check_num('Disc', 0, 100)) { display_error(_("The item could not be updated because you are attempting to set the quantity ordered to less than 0, or the discount percent to more than 100.")); set_focus('qty'); return false; } elseif (!check_num('price', 0) && (!$allow_negative_prices || $is_inventory_item)) { display_error(_("Price for inventory item must be entered and can not be less than 0")); set_focus('price'); return false; } elseif (isset($_POST['LineNo']) && isset($_SESSION['Items']->line_items[$_POST['LineNo']]) && !check_num('qty', $_SESSION['Items']->line_items[$_POST['LineNo']]->qty_done)) { set_focus('qty'); display_error(_("You attempting to make the quantity ordered a quantity less than has already been delivered. The quantity delivered cannot be modified retrospectively.")); return false; } $cost_home = get_standard_cost(get_post('stock_id')); // Added 2011-03-27 Joe Hunt $cost = $cost_home / get_exchange_rate_from_home_currency($_SESSION['Items']->customer_currency, $_SESSION['Items']->document_date); if (input_num('price') < $cost) { $dec = user_price_dec(); $curr = $_SESSION['Items']->customer_currency; $price = number_format2(input_num('price'), $dec); if ($cost_home == $cost) { $std_cost = number_format2($cost_home, $dec); } else { $price = $curr . " " . $price; $std_cost = $curr . " " . number_format2($cost, $dec); } display_warning(sprintf(_("Price %s is below Standard Cost %s"), $price, $std_cost)); } return true; }
$th = array(_("Account Code"), _("Account Description"), _("Dimension"), _("Amount"), _("Memo")); } else { $th = array(_("Account Code"), _("Account Description"), _("Amount"), _("Memo")); } } table_header($th); $k = 0; //row colour counter $total_amount = 0; while ($item = db_fetch($items)) { if ($item["account"] != $to_trans["account_code"]) { alt_table_row_color($k); label_cell($item["account"]); label_cell($item["account_name"]); if ($dim >= 1) { label_cell(get_dimension_string($item['dimension_id'], true)); } if ($dim > 1) { label_cell(get_dimension_string($item['dimension2_id'], true)); } amount_cell(-$item["amount"]); label_cell($item["memo_"]); end_row(); $total_amount += $item["amount"]; } } label_row(_("Total"), number_format2(-$total_amount, user_price_dec()), "colspan=" . (2 + $dim) . " align=right", "align=right"); end_table(1); display_allocations_from($to_trans['person_type_id'], $to_trans['person_id'], 2, $trans_no, $to_trans['settled_amount']); } end_page(true, false, false, ST_BANKDEPOSIT, $trans_no);
alt_table_row_color($k); } label_cell($stock_item->stock_id); label_cell($stock_item->item_description); $dec = get_qty_dec($stock_item->stock_id); qty_cell($stock_item->quantity, false, $dec); label_cell($stock_item->units); amount_decimal_cell($stock_item->price); label_cell($stock_item->req_del_date); amount_cell($line_total); qty_cell($stock_item->qty_received, false, $dec); qty_cell($stock_item->qty_inv, false, $dec); end_row(); $total += $line_total; } $display_sub_tot = number_format2($total, user_price_dec()); label_row(_("Sub Total"), $display_sub_tot, "align=right colspan=6", "nowrap align=right", 2); $taxes = $purchase_order->get_taxes(); $tax_total = display_edit_tax_items($taxes, 6, $purchase_order->tax_included, 2); $display_total = price_format($total + $tax_total); start_row(); label_cells(_("Amount Total"), $display_total, "colspan=6 align='right'", "align='right'"); label_cell('', "colspan=2"); end_row(); end_table(); if ($overdue_items) { display_note(_("Marked items are overdue."), 0, 0, "class='overduefg'"); } //---------------------------------------------------------------------------------------------------- $k = 0; $grns_result = get_po_grns($_GET['trans_no']);