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_purchases_cost() { global $path_to_root; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $destination = $_POST['PARAM_2']; $orientation = $_POST['PARAM_3']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $dec = user_price_dec(); if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } $cols = array(0, 20, 55, 85, 125, 200, 230, 260, 290, 325, 350, 375, 425, 475); //14 headers + 1 lagi dapat for cols //todo: format date paid to 2 digits representation only i.e. 12/12/12 $headers = array(_('CV#'), _('Date Paid'), _('OR #'), _('Supplier'), _('Title of Book'), _('Quantity'), _('Unit Cost'), _('Amount'), _('With Tax'), _('Net'), _('PO #'), _('Stock Supplied'), _('Stock Amount'), _('Total Amount')); //todo: Date Paid, OR(official receipt number) Amount, w/tax, net, Stock supplied, stock amount and total amount // Possible tables to read on: grn_batch and grn_items $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => '')); $rep = new FrontReport(_('Summary of Purchases at Cost Report'), "SummaryPurchasesCostReport", user_pagesize(), 8, 'L'); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $res = getTransactions($from, $to); $total = $grandtotal = 0.0; $total1 = $grandtotal1 = 0.0; $total2 = $grandtotal2 = 0.0; $catt = ''; while ($trans = db_fetch($res)) { $rep->NewLine(); $rep->fontSize -= 2; $rep->TextCol(3, 4, $trans['supp_name']); $rep->TextCol(4, 5, $trans['description']); $rep->AmountCol(5, 6, $trans['quantity_ordered']); $rep->AmountCol(6, 7, $trans['unit_price']); $rep->AmountCol(10, 11, $trans['order_no']); } $rep->NewLine(2, 3); $rep->TextCol(0, 4, _('Total')); $rep->AmountCol(4, 5, $total, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $rep->NewLine(2, 1); $rep->TextCol(0, 4, _('Grand Total')); $rep->AmountCol(4, 5, $grandtotal, $dec); $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
function print_royalty_sales() { $item_id = $_POST['PARAM_0']; global $path_to_root, $systypes_array; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $result = fetchRoyalty($item_id); $name = ""; while ($book = db_fetch($result)) { $name = $book[1]; } $params = array(0 => $comments, 1 => array('text' => _('Item'), 'from' => $name)); $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(0, 150, 250, 350, 450); $headers = array(_('Name'), _('ID #'), _('Date'), _('Quantity'), _('Status')); $aligns = array('left', 'left', 'left', 'left', 'left'); $usr = get_user($user); $user_id = $usr['user_id']; $rep = new FrontReport(_('Royalty Sales'), "RoyaltySales", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->SetHeaderType('Header'); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $rep->TextCol(0, 1, $item_id); $rep->TextCol(2, 4, fetchTitle($item_id)); $rep->NewLine(); $rep->NewLine(); $result = fetchRoyalty($item_id); while ($myrow = db_fetch($result)) { $rep->TextCol(0, 1, $myrow[0]); $rep->TextCol(1, 2, ' ' . $myrow[1]); $rep->TextCol(2, 3, $myrow[2]); $rep->TextCol(3, 4, $myrow[3]); $rep->TextCol(4, 5, 'Closed'); $rep->NewLine(); } $result1 = fetchCreditMemo($item_id); while ($myrow1 = db_fetch($result1)) { if ($myrow1[3] > 0) { $rep->TextCol(0, 1, $myrow1[0]); $rep->TextCol(1, 2, ' ' . $myrow1[1]); $rep->TextCol(2, 3, $myrow1[2]); $rep->TextCol(3, 4, '- ' . $myrow1[3]); $rep->TextCol(4, 5, 'Closed'); $rep->NewLine(); } } $rep->Line($rep->row + 4); $rep->End(); }
function print_summary() { global $path_to_root; $imc = $_POST['PARAM_0']; $comments = $_POST['PARAM_1']; $orientation = $_POST['PARAM_2']; $destination = $_POST['PARAM_3']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(0, 10, 100, 150, 200, 250, 300, 350, 400, 450, 520); //$headers = array(_('IMC')); $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left'); //$params = array( 0 => $comments, 1 => array( 'text' => _('Period'), 'from' => $from)); $aligns2 = $aligns; $summary = 1; $rep = new FrontReport(_('Client List'), "ClientList", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $cols2 = $cols; $rep->Font(); $rep->Info(null, $cols, null, $aligns); $rep->NewPage(); $salesman = 0; $result = getList($imc); while ($myrow = db_fetch($result)) { $previous == ''; $salesman = get_salesman_name($myrow['salesman']); $current = $salesman; if ($salesman != "") { if ($previous == $current) { $salesman = ''; $rep->TextCol(1, 10, $myrow['br_name']); $rep->NewLine(); } else { $rep->Font('bold'); $rep->NewLine(2); $rep->Line($rep->row + 10); $rep->TextCol(0, 2, $salesman); $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->Font(); $rep->TextCol(1, 10, $myrow['br_name']); $rep->NewLine(); } $previous = $current; } } $rep->NewLine(); $rep->End(); }
function print_audit_trail() { global $path_to_root, $systypes_array; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $systype = $_POST['PARAM_2']; $user = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(0, 60, 120, 180, 240, 340, 400, 460, 520); $headers = array(_('Date'), _('Time'), _('User'), _('Trans Date'), _('Type'), _('#'), _('Action'), _('Amount')); $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'right'); $usr = get_user($user); $user_id = $usr['user_id']; $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Type'), 'from' => $systype != -1 ? $systypes_array[$systype] : _('All'), 'to' => ''), 3 => array('text' => _('User'), 'from' => $user != -1 ? $user_id : _('All'), 'to' => '')); $rep = new FrontReport(_('Audit Trail'), "AuditTrail", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $trans = getTransactions($from, $to, $systype, $user); while ($myrow = db_fetch($trans)) { $rep->TextCol(0, 1, sql2date(date("Y-m-d", $myrow['unix_stamp']))); if (user_date_format() == 0) { $rep->TextCol(1, 2, date("h:i:s a", $myrow['unix_stamp'])); } else { $rep->TextCol(1, 2, date("H:i:s", $myrow['unix_stamp'])); } $rep->TextCol(2, 3, $myrow['user_id']); $rep->TextCol(3, 4, sql2date($myrow['gl_date'])); $rep->TextCol(4, 5, $systypes_array[$myrow['type']]); $rep->TextCol(5, 6, $myrow['trans_no']); if ($myrow['gl_seq'] == null) { $action = _('Changed'); } else { $action = _('Closed'); } $rep->TextCol(6, 7, $action); if ($myrow['amount'] != null) { $rep->AmountCol(7, 8, $myrow['amount'], $dec); } $rep->NewLine(1, 2); } $rep->Line($rep->row + 4); $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() { 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 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 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); }
} 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 inventory_movements() { global $path_to_root; $from_date = $_POST['PARAM_0']; $to_date = $_POST['PARAM_1']; $category = $_POST['PARAM_2']; $location = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } if ($location == '') { $loc = _('All'); } else { $loc = get_location_name($location); } $cols = array(0, 60, 130, 160, 185, 215, 250, 275, 305, 340, 365, 395, 430, 455, 485, 520); $headers = array(_('Category'), _('Description'), _('UOM'), '', '', _('OpeningStock'), '', '', _('StockIn'), '', '', _('Delivery'), '', '', _('ClosingStock')); $headers2 = array("", "", "", _("QTY"), _("Rate"), _("Value"), _("QTY"), _("Rate"), _("Value"), _("QTY"), _("Rate"), _("Value"), _("QTY"), _("Rate"), _("Value")); $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from_date, 'to' => $to_date), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => '')); $rep = new FrontReport(_('Costed Inventory Movements'), "CostedInventoryMovements", user_pagesize(), 8, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers2, $aligns, $cols, $headers, $aligns); $rep->NewPage(); $totval_open = $totval_in = $totval_out = $totval_close = 0; $result = fetch_items($category); $dec = user_price_dec(); $catgor = ''; while ($myrow = db_fetch($result)) { if ($catgor != $myrow['description']) { $rep->NewLine(2); $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['category_id'] . " - " . $myrow['description']); $catgor = $myrow['description']; $rep->fontSize -= 2; $rep->NewLine(); } $rep->NewLine(); $rep->TextCol(0, 1, $myrow['stock_id']); $rep->TextCol(1, 2, $myrow['name']); $rep->TextCol(2, 3, $myrow['units']); $qoh_start = get_qoh_on_date($myrow['stock_id'], $location, add_days($from_date, -1)); $qoh_end = get_qoh_on_date($myrow['stock_id'], $location, $to_date); $inward = trans_qty($myrow['stock_id'], $location, $from_date, $to_date); $outward = trans_qty($myrow['stock_id'], $location, $from_date, $to_date, false); $openCost = avg_unit_cost($myrow['stock_id'], $location, $from_date); $unitCost = avg_unit_cost($myrow['stock_id'], $location, add_days($to_date, 1)); $rep->AmountCol(3, 4, $qoh_start, get_qty_dec($myrow['stock_id'])); $rep->AmountCol(4, 5, $openCost, $dec); $openCost *= $qoh_start; $totval_open += $openCost; $rep->AmountCol(5, 6, $openCost); if ($inward > 0) { $rep->AmountCol(6, 7, $inward, get_qty_dec($myrow['stock_id'])); $unitCost_in = trans_qty_unit_cost($myrow['stock_id'], $location, $from_date, $to_date); $rep->AmountCol(7, 8, $unitCost_in, $dec); $unitCost_in *= $inward; $totval_in += $unitCost_in; $rep->AmountCol(8, 9, $unitCost_in); } if ($outward > 0) { $rep->AmountCol(9, 10, $outward, get_qty_dec($myrow['stock_id'])); $unitCost_out = trans_qty_unit_cost($myrow['stock_id'], $location, $from_date, $to_date, false); $rep->AmountCol(10, 11, $unitCost_out, $dec); $unitCost_out *= $outward; $totval_out += $unitCost_out; $rep->AmountCol(11, 12, $unitCost_out); } $rep->AmountCol(12, 13, $qoh_end, get_qty_dec($myrow['stock_id'])); $rep->AmountCol(13, 14, $unitCost, $dec); $unitCost *= $qoh_end; $totval_close += $unitCost; $rep->AmountCol(14, 15, $unitCost); $rep->NewLine(0, 1); } $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 1, _("Total")); $rep->AmountCol(5, 6, $totval_open); $rep->AmountCol(8, 9, $totval_in); $rep->AmountCol(11, 12, $totval_out); $rep->AmountCol(14, 15, $totval_close); $rep->Line($rep->row - 4); $rep->End(); }
function print_inventory_sales() { global $path_to_root; $from = $_POST['PARAM_0']; $destination = $_POST['PARAM_1']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $dec = user_price_dec(); if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } $cols = array(0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200); $headers = array(_('Date'), _('Client Name'), _('IMC'), _('Charge'), _('Sales'), _('Date'), _('CM#'), _('Returns'), _(''), _('Discount'), _('Balance'), _('Date'), _('PR/OR#'), _('Date'), _('OR #'), _('Amount'), _('Partial'), _('Balance'), _('Date'), _(''), _('Commission'), _('w/tax'), _('Net Commission')); $header2 = array(_(''), '', '', _('Invoice'), _('Amount'), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), '', _(''), _('')); $aligns = array('left', 'center', 'center', 'center', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => '')); $rep = new FrontReport(_('Series Report'), "SeriesReport", user_pagesize(), 8, 'L'); $rep->Font(); $rep->Info($params, $cols, $header2, $aligns, $cols, $headers, $aligns); $rep->NewPage(); $total = $grandtotal = 0.0; $total1 = $grandtotal1 = 0.0; $total2 = $grandtotal2 = 0.0; $catt = ''; $res = getTransactions($imc, $from); while ($myrow = db_fetch($res)) { $company_data = get_company_prefs(); $branch = get_branch($myrow["branch_code"]); $branch_data = get_branch_accounts($myrow['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']); $salesman = get_imc_code($myrow['branch_code']); $res2 = get_return_details($myrow['order_']); $returns = 0; $rtn_dt = 0; $credit_num = ""; $cm_date = ""; $num = db_num_rows($res2); $var = array(); while ($myrow2 = db_fetch($res2)) { $returns += $myrow2['ov_amount']; if ($num > 1) { $credit_num .= $myrow2['customized_no'] . "/"; $cm_date = $myrow2['tran_date'] . "/"; } else { $credit_num .= $myrow2['customized_no']; $cm_date = $myrow2['tran_date']; } $var = array($myrow2['trans_no']); //$res2 = get_return_discount($branch_data['sales_discount_account'], $myrow2['type'], $myrow2['trans_no']); // while ($myrow3 = db_fetch($res2)){ // $rtn_dt += abs($myrow3['amount']); // } } foreach ($var as $vars) { $res2 = get_return_discount($branch_data['sales_discount_account'], ST_CUSTCREDIT, $vars); while ($myrow3 = db_fetch($res2)) { $rtn_dt += abs($myrow3['amount']); } } $total_returns = $returns + $rtn_dt; $return_discount = $rtn_dt / $total_returns * 100; //$discount = $myrow['discount']; $invoicetot = $myrow['ov_amount'] + $dt; $invoice_discount = $dt / $invoicetot * 100; $sales_discount = ($invoicetot - $total_returns) * ($invoice_discount / 100); $net_sales = $invoicetot - $total_returns - $sales_discount; $gross_commission = ($invoicetot - $total_returns) * ($myrow['commission'] / 100); $tot_invoice = $invoicetot - $invoicetot * ($invoice_discount / 100); $sample = $invoicetot - $total_returns; $rep->TextCol(0, 1, $myrow['tranDate']); $rep->TextCol(1, 2, $myrow['br_name']); $rep->TextCol(2, 3, $salesman); $rep->TextCol(3, 4, $myrow['customized_no']); if ($myrow['IsVoid'] == '') { $rep->AmountCol(4, 5, $invoicetot, 2); $rep->TextCol(5, 6, $cm_date); $rep->TextCol(6, 7, $credit_num); if ($total_returns != 0) { $rep->AmountCol(7, 8, $total_returns, 2); } if ($invoice_discount < 0) { $rep->TextCol(8, 9, "CLIENT SALES/SALES DISCOUNT NOT DEFINED."); } else { $rep->TextCol(8, 9, $invoice_discount . "%"); } if ($sales_discount < 0) { $rep->TextCol(9, 10, "ERROR."); } else { if ($sales_discount != 0) { $rep->AmountCol(9, 10, $sales_discount, 2); } } if ($net_sales != 0) { $rep->AmountCol(10, 11, $net_sales, 2); } $partial_payment = 0; $or = get_pr_details($myrow['type'], $myrow['trans_no']); $ref = ''; $num2 = db_num_rows($or); $date_alloc = ''; while ($pr = db_fetch($or)) { $partial_payment += $pr['amt']; $date_alloc = $pr['prDate'] . " "; $pr_number = $pr['customized_no'] . " "; if ($num2 > 1) { $ref .= $pr['reference'] . "/"; } else { $ref = $pr['reference']; } } $net_remittance = $net_sales - $partial_payment; $rep->TextCol(11, 12, $date_alloc); $rep->TextCol(12, 13, $ref); $rep->TextCol(13, 14, $date_alloc); $rep->TextCol(14, 15, _("")); if ($partial_payment == $tot_invoice) { $rep->AmountCol(15, 16, $partial_payment, 2); } if ($partial_payment != 0) { if ($partial_payment < $tot_invoice) { $bal = $tot_invoice - $partial_payment; $rep->AmountCol(16, 17, $partial_payment, 2); $rep->AmountCol(17, 18, $bal, 2); } } //$rep->AmountCol(15,16, $partial_payment, 2); //$rep->AmountCol(17,18, $net_remittance, 2); $myrow4 = db_fetch(get_commission_details($myrow['type'], $myrow['trans_no'])); $comm = ($invoicetot - $total_returns) * ($myrow4['commission'] / 100); $rep->TextCol(18, 19, $myrow4['tranDate']); if ($myrow4['commission'] != 0) { $rep->TextCol(19, 20, $myrow4['commission'] . "%"); } if ($comm != 0) { $rep->AmountCol(20, 21, $comm, 2); } if ($myrow4['with_tax'] != 0) { $rep->AmountCol(21, 22, $myrow4['with_tax'], 2); } if ($myrow4['net_commission'] != 0) { $rep->AmountCol(22, 23, $myrow4['net_commission'], 2); } $net_invoice += $invoicetot; $net_discount += $sales_discount; $net_returns += $total_returns; $sale_amount += $net_sales; $net_partial += $partial_payment; $net_rem += $net_remittance; $net_bal += $bal; $net_balance = $net_rem + $net_bal; $net_comm += $comm; $net_tax += $myrow4['with_tax']; $net_net_comm += $myrow4['net_commission']; } else { $rep->TextCol(4, 5, "Voided"); } $rep->NewLine(); } $rep->Font('bold'); $rep->NewLine(); $rep->TextCol(1, 2, "TOTAL"); $rep->AmountCol(4, 5, $net_invoice, 2); $rep->AmountCol(7, 8, $net_returns, 2); $rep->AmountCol(9, 10, $net_discount, 2); $rep->AmountCol(10, 11, $sale_amount, 2); $rep->AmountCol(16, 17, $net_partial, 2); //$rep->AmountCol(17,18, $net_balance, 2); $rep->AmountCol(20, 21, $net_comm, 2); $rep->AmountCol(21, 22, $net_tax, 2); $rep->AmountCol(22, 23, $net_net_comm, 2); $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); $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_subsidiary_ledger() { global $path_to_root, $systypes_array; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $cat = $_POST['PARAM_2']; $account = $_POST['PARAM_3']; $account2 = $_POST['PARAM_4']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report2.inc"; } $orientation = $orientation ? 'L' : 'P'; $rep = new FrontReport(_('Subsidiary Ledger Report'), "SubsidiaryLedger", user_pagesize(), 9, L); $dec = user_price_dec(); //$headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension')." 1", _('Dimension')." 2", // _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); //$cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570); $cols = array(0, 50, 140, 200, 210, 400, 450, 550, 600, 650); //------------0--1---2-----3----4----5----6----7----8----9----10------- //-----------------------dim1-dim2----------------------------------- //-----------------------dim1---------------------------------------- //------------------------------------------------------------------- $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right', 'right'); //$headers = array(_('ID'), '', '', '', '', '', '', _('Debit'), _('Credit'), _('Balance')); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $fromacc)); if ($orientation == 'L') { recalculate_cols($cols); } $rep->SetHeaderType('header3'); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); if ($cat == 3) { $person = get_salesman_name($account); } if ($cat == 1) { $person = get_supplier_name($account); } /*$rep->TextCol(0,2, $cat); $rep->NewLine();*/ $rep->Font('bold'); $rep->TextCol(0, 2, "Name:" . $person); $rep->NewLine(); $rep->TextCol(0, 1, "ID:"); $rep->TextCol(1, 2, "Src:"); $rep->TextCol(2, 3, "Date:"); $rep->TextCol(4, 5, "Memo:"); $rep->TextCol(5, 6, "Account:"); $rep->TextCol(6, 7, "Debit:"); $rep->TextCol(8, 9, "Credit:"); $rep->Font(); $rep->NewLine(2); $result = getTransaction($from, $to, $cat, $account, $account2); $type = ''; while ($myrow = db_fetch($result)) { if ($myrow['Voided'] == '' && $myrow['amount'] > 0) { $comments = get_comments_string($myrow['type'], $myrow['type_no']); $custom = get_custom_no($myrow['type_no'], $myrow['type']); if ($myrow['type'] == ST_DISBURSEMENT) { $type = "CD"; } if ($myrow['type'] == ST_PURCHASEORDER) { $type = "P.O."; } if ($myrow['type'] == ST_SUPPAYMENT) { $type = "CD"; } //else // $type = $systypes_array[$myrow["type"]]; $rep->TextCol(0, 1, "#" . $custom); $rep->TextCol(1, 2, $type); $rep->TextCol(2, 3, $myrow['tranDate']); $rep->TextCol(4, 5, $comments); $rep->TextCol(5, 6, $myrow['account']); $dr += $myrow['amount']; $rep->AmountCol(6, 7, $myrow['amount'], 2); $rep->NewLine(); } else { if ($myrow['Voided'] == '' && $myrow['amount'] < 0) { $cr += $myrow['amount']; //$rep->AmountCol(8,9, $myrow['amount'], 2); } } } $rep->NewLine(2); $rep->Font('bold'); $rep->AmountCol(6, 7, $dr, 2); $rep->NewLine(2); $rep->TextCol(1, 2, "Net Activity: "); $rep->AmountCol(2, 4, $cr, 2); $rep->End(); }
$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);
function print_purchases_cost() { global $path_to_root; $from = $_POST['PARAM_0']; $destination = $_POST['PARAM_1']; $orientation = $_POST['PARAM_2']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $dec = user_price_dec(); if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } $cols = array(0, 50, 100, 150, 200, 250, 300, 350); $headers = array(_('Invoice'), _('Client Name'), _('IMC'), _('Charge'), _('Sales'), _('Date of')); //$header2 = array(_('Date'), '', '', _('Invoice'), _('Amount'), _('Credit Memo'), _('Memo No.'), _(' Return'), _('%'), _('%'), _('Sales'), _('Provisional Receipt'), _('Receipt No.'), _('Payment'), _('Remittance'), _('Commission'), _('Percentage'), '', _('W/holding Tax'), _('Commission')); $aligns = array('left', 'left', 'left', 'left'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => '')); $rep = new FrontReport(_('Summary of Purchases at Cost Report'), "SummaryPurchasesCostReport", user_pagesize(), 8, 'L'); $rep->Font(); $rep->Info($params, $cols, $header2, $aligns); $rep->NewPage(); $res = getTransactions($category, $from, $to); $total = $grandtotal = 0.0; $total1 = $grandtotal1 = 0.0; $total2 = $grandtotal2 = 0.0; $catt = ''; while ($trans = db_fetch($res)) { if ($catt != $trans['cat_description']) { if ($catt != '') { $rep->NewLine(2, 3); $rep->TextCol(0, 4, _('Total')); $rep->AmountCol(4, 5, $total, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $rep->NewLine(); $total = $total1 = $total2 = 0.0; } $rep->TextCol(0, 1, $trans['category_id']); $rep->TextCol(1, 7, $trans['cat_description']); $catt = $trans['cat_description']; $rep->NewLine(); } $rep->NewLine(); $rep->fontSize -= 2; $rep->TextCol(0, 1, $trans['stock_id']); $rep->TextCol(1, 2, $trans['description']); $rep->AmountCol(2, 3, $trans['quantity'], get_qty_dec($trans['stock_id'])); $rep->AmountCol(3, 4, $trans['unit_price'], $dec); $rep->AmountCol(4, 5, $trans['quantity'] * $trans['unit_price'], $dec); if ($trans['unit_price'] == 0) { $rep->TextCol(6, 7, _('Gift')); } $rep->fontSize += 2; $total += $trans['quantity'] * $trans['unit_price']; $grandtotal += $trans['quantity'] * $trans['unit_price']; } $rep->NewLine(2, 3); $rep->TextCol(0, 4, _('Total')); $rep->AmountCol(4, 5, $total, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $rep->NewLine(2, 1); $rep->TextCol(0, 4, _('Grand Total')); $rep->AmountCol(4, 5, $grandtotal, $dec); $rep->Line($rep->row - 4); $rep->NewLine(); $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_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(); } }
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(); } }
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']);
function print_inventory_sales() { global $path_to_root; $from = $_POST['PARAM_0']; $destination = $_POST['PARAM_1']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $dec = user_price_dec(); if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } $cols = array(0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200); $headers = array(_('Date'), _('Client Name'), _('IMC'), _('Charge'), _('Sales'), _('Date'), _('CM#'), _('Returns'), _(''), _('Discount'), _('Balance'), _('Date'), _('PR/OR#'), _('Date'), _('OR #'), _('Partial'), _('Net'), _('Balance'), _('Date'), _(''), _('Commission'), _('w/tax'), _('Net Commission')); $header2 = array(_(''), '', '', _('Invoice'), _('Amount'), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), '', _(''), _('')); $aligns = array('left', 'center', 'center', 'center', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => '')); $rep = new FrontReport(_('Series Report'), "Series Report", user_pagesize(), 8, 'L'); $rep->Font(); $rep->Info($params, $cols, $header2, $aligns, $cols, $headers, $aligns); $rep->NewPage(); $total = $grandtotal = 0.0; $total1 = $grandtotal1 = 0.0; $total2 = $grandtotal2 = 0.0; $catt = ''; $res = getTransactions($imc, $from); while ($myrow = db_fetch($res)) { $company_data = get_company_prefs(); $branch = get_branch($myrow["branch_code"]); $branch_data = get_branch_accounts($myrow['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']); $salesman = get_imc_code($myrow['branch_code']); $res2 = get_return_details($myrow['order_']); $returns = 0; $rtn_dt = 0; while ($myrow2 = db_fetch($res2)) { $returns += $myrow2['ov_amount']; $credit_num = $myrow2['customized_no']; $cm_date = $myrow2['tran_date']; $res2 = get_return_discount($branch_data['sales_discount_account'], $myrow2['type'], $myrow2['trans_no']); while ($myrow3 = db_fetch($res2)) { $rtn_dt += abs($myrow3['amount']); } } $total_returns = $returns + $rtn_dt; $return_discount = $rtn_dt / $total_returns * 100; $discount = $myrow['discount']; $invoicetot = $myrow['ov_amount'] + $dt; $sales_discount = ($invoicetot - $total_returns) * ($return_discount / 100); $net_sales = $invoicetot - $total_returns - $sales_discount; $gross_commission = ($invoicetot - $total_returns) * ($myrow['commission'] / 100); $rep->TextCol(0, 1, $myrow['tran_date']); $rep->TextCol(1, 2, $myrow['br_name']); $rep->TextCol(2, 3, $salesman); $rep->TextCol(3, 4, $myrow['customized_no']); $rep->AmountCol(4, 5, $invoicetot, 2); $rep->TextCol(5, 6, $cm_date); $rep->TextCol(6, 7, $credit_num); $rep->AmountCol(7, 8, $total_returns, 2); $rep->TextCol(8, 9, $return_discount . "%"); $rep->AmountCol(9, 10, $sales_discount, 2); $rep->AmountCol(10, 11, $net_sales, 2); $rep->TextCol(18, 19, $myrow['date']); $rep->TextCol(19, 20, $myrow['commission'] . "%"); $rep->AmountCol(20, 21, $gross_commission, 2); $rep->AmountCol(21, 22, $myrow['with_tax'], 2); $rep->AmountCol(22, 23, $myrow['net_commission'], 2); $or = get_pr_details($myrow['type'], $myrow['trans_no']); while ($pr = db_fetch($or)) { $net_remittance = $net_sales - $pr['amt']; $rep->TextCol(11, 12, $pr['date_alloc']); $rep->TextCol(12, 13, $pr['customized_no']); $rep->TextCol(13, 14, _("DATE")); $rep->TextCol(14, 15, _("OR#")); $rep->TextCol(15, 16, ""); $rep->AmountCol(17, 18, '', 2); } $rep->NewLine(); // } $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']; $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(); } }
function handle_commit_order() { $cart =& $_SESSION['PO']; if (can_commit()) { copy_to_cart(); if ($cart->trans_type != ST_PURCHORDER) { // for direct grn/invoice set same dates for lines as for whole document foreach ($cart->line_items as $line_no => $line) { $cart->line_items[$line_no]->req_del_date = $cart->orig_order_date; } } if ($cart->order_no == 0) { // new po/grn/invoice /*its a new order to be inserted */ $ref = $cart->reference; if ($cart->trans_type != ST_PURCHORDER) { $cart->reference = 'auto'; begin_transaction(); // all db changes as single transaction for direct document } $order_no = add_po($cart); new_doc_date($cart->orig_order_date); $cart->order_no = $order_no; if ($cart->trans_type == ST_PURCHORDER) { unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$order_no}"); } //Direct GRN if ($cart->trans_type == ST_SUPPRECEIVE) { $cart->reference = $ref; } if ($cart->trans_type != ST_SUPPINVOICE) { $cart->Comments = $cart->reference; } //grn does not hold supp_ref foreach ($cart->line_items as $key => $line) { $cart->line_items[$key]->receive_qty = $line->quantity; } $grn_no = add_grn($cart); if ($cart->trans_type == ST_SUPPRECEIVE) { commit_transaction(); // save PO+GRN unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedGRN={$grn_no}"); } // Direct Purchase Invoice $inv = new supp_trans(ST_SUPPINVOICE); $inv->Comments = $cart->Comments; $inv->supplier_id = $cart->supplier_id; $inv->tran_date = $cart->orig_order_date; $inv->due_date = $cart->due_date; $inv->reference = $ref; $inv->supp_reference = $cart->supp_ref; $inv->tax_included = $cart->tax_included; $supp = get_supplier($cart->supplier_id); $inv->tax_group_id = $supp['tax_group_id']; $inv->ov_amount = $inv->ov_gst = $inv->ov_discount = 0; $total = 0; foreach ($cart->line_items as $key => $line) { $inv->add_grn_to_trans($line->grn_item_id, $line->po_detail_rec, $line->stock_id, $line->item_description, $line->receive_qty, 0, $line->receive_qty, $line->price, $line->price, true, get_standard_cost($line->stock_id), ''); $inv->ov_amount += round2($line->receive_qty * $line->price, user_price_dec()); } $inv->tax_overrides = $cart->tax_overrides; if (!$inv->tax_included) { $taxes = $inv->get_taxes($inv->tax_group_id, 0, false); foreach ($taxes as $taxitem) { $total += isset($taxitem['Override']) ? $taxitem['Override'] : $taxitem['Value']; } } $inv->ex_rate = $cart->ex_rate; $inv_no = add_supp_invoice($inv); commit_transaction(); // save PO+GRN+PI // FIXME payment for cash terms. (Needs cash account selection) unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedPI={$inv_no}"); } else { // order modification $order_no = update_po($cart); unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$order_no}&Updated=1"); } } }
function display_grn_items_for_selection() { global $table_style; $result = get_grn_items(0, $_SESSION['supp_trans']->supplier_id, true); if (db_num_rows($result) == 0) { display_note(tr("There are no outstanding items received from this supplier that have not been invoiced by them."), 0, 1); end_page(); exit; } /*Set up a table to show the outstanding GRN items for selection */ start_form(false, true); display_heading2(tr("Items Received Yet to be Invoiced")); start_table("{$table_style} colspan=7 width=95%"); $th = array(tr("Delivery"), tr("Sequence #"), tr("P.O."), tr("Item"), tr("Description"), tr("Received On"), tr("Quantity Received"), tr("Quantity Invoiced"), tr("Uninvoiced Quantity"), tr("Order Price"), tr("Total")); table_header($th); $i = $k = 0; while ($myrow = db_fetch($result)) { $grn_already_on_invoice = False; foreach ($_SESSION['supp_trans']->grn_items as $entered_grn) { if ($entered_grn->id == $myrow["id"]) { $grn_already_on_invoice = True; } } if ($grn_already_on_invoice == False) { alt_table_row_color($k); label_cell(get_trans_view_str(25, $myrow["grn_batch_id"])); //text_cells(null, 'grn_item_id', $myrow["id"]); submit_cells('grn_item_id', $myrow["id"]); label_cell(get_trans_view_str(systypes::po(), $myrow["purch_order_no"])); label_cell($myrow["item_code"]); label_cell($myrow["description"]); label_cell(sql2date($myrow["delivery_date"])); qty_cell($myrow["qty_recd"]); qty_cell($myrow["quantity_inv"]); qty_cell($myrow["qty_recd"] - $myrow["quantity_inv"]); amount_cell($myrow["unit_price"]); amount_cell(round($myrow["unit_price"] * ($myrow["qty_recd"] - $myrow["quantity_inv"]), user_price_dec())); end_row(); $i++; if ($i > 15) { $i = 0; table_header($th); } } } end_table(); }
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);
end_table(); echo "</td></tr>"; end_table(); } echo "<center>"; if ($_SESSION['View']->so_type == 1) { display_note(_("This Sales Order is used as a Template."), 0, 0, "class='currentfg'"); } display_heading2(_("Line Details")); start_table(TABLESTYLE, "colspan=9 width=95%"); $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Price"), _("Discount"), _("Total"), _("Quantity Delivered")); table_header($th); $k = 0; //row colour counter foreach ($_SESSION['View']->line_items as $stock_item) { $line_total = round2($stock_item->quantity * $stock_item->price * (1 - $stock_item->discount_percent), user_price_dec()); 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_cell($stock_item->price); amount_cell($stock_item->discount_percent * 100); amount_cell($line_total); qty_cell($stock_item->qty_done, false, $dec); end_row(); } label_row(_("Shipping"), price_format($_SESSION['View']->freight_cost), "align=right colspan=6", "nowrap align=right", 1); $sub_tot = $_SESSION['View']->get_items_total() + $_SESSION['View']->freight_cost; $display_sub_tot = price_format($sub_tot);
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 print_salesman_list() { global $path_to_root; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $summary = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; if ($summary == 0) { $sum = _("No"); } else { $sum = _("Yes"); } $dec = user_price_dec(); $cols = array(0, 60, 150, 220, 325, 385, 450, 515); $headers = array(_('Invoice'), _('Customer'), _('Branch'), _('Customer Ref'), _('Inv Date'), _('Total'), _('Provision')); $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right'); $headers2 = array(_('Salesman'), " ", _('Phone'), _('Email'), _('Provision'), _('Break Pt.'), _('Provision') . " 2"); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Summary Only'), 'from' => $sum, 'to' => '')); $aligns2 = $aligns; $rep = new FrontReport(_('Salesman Listing'), "SalesmanListing", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $cols2 = $cols; $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); $rep->NewPage(); $salesman = 0; $subtotal = $total = $subprov = $provtotal = 0; $result = GetSalesmanTrans($from, $to); while ($myrow = db_fetch($result)) { $rep->NewLine(0, 2, false, $salesman); if ($salesman != $myrow['salesman_code']) { if ($salesman != 0) { $rep->Line($rep->row - 8); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); $rep->AmountCol(5, 6, $subtotal, $dec); $rep->AmountCol(6, 7, $subprov, $dec); $rep->Line($rep->row - 4); $rep->NewLine(2); } $rep->TextCol(0, 2, $myrow['salesman_code'] . " " . $myrow['salesman_name']); $rep->TextCol(2, 3, $myrow['salesman_phone']); $rep->TextCol(3, 4, $myrow['salesman_email']); $rep->TextCol(4, 5, number_format2($myrow['provision'], user_percent_dec()) . " %"); $rep->AmountCol(5, 6, $myrow['break_pt'], $dec); $rep->TextCol(6, 7, number_format2($myrow['provision2'], user_percent_dec()) . " %"); $rep->NewLine(2); $salesman = $myrow['salesman_code']; $total += $subtotal; $provtotal += $subprov; $subtotal = 0; $subprov = 0; } $rate = $myrow['rate']; $amt = $myrow['InvoiceTotal'] * $rate; if ($subprov > $myrow['break_pt'] && $myrow['provision2'] != 0) { $prov = $myrow['provision2'] * $amt / 100; } else { $prov = $myrow['provision'] * $amt / 100; } if (!$summary) { $rep->TextCol(0, 1, $myrow['trans_no']); $rep->TextCol(1, 2, $myrow['DebtorName']); $rep->TextCol(2, 3, $myrow['br_name']); $rep->TextCol(3, 4, $myrow['contact_name']); $rep->DateCol(4, 5, $myrow['tran_date'], true); $rep->AmountCol(5, 6, $amt, $dec); $rep->AmountCol(6, 7, $prov, $dec); $rep->NewLine(); } $subtotal += $amt; $subprov += $prov; } if ($salesman != 0) { $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); $rep->AmountCol(5, 6, $subtotal, $dec); $rep->AmountCol(6, 7, $subprov, $dec); $rep->Line($rep->row - 4); $rep->NewLine(2); $total += $subtotal; $provtotal += $subprov; } $rep->fontSize += 2; $rep->TextCol(0, 3, _('Grand Total')); $rep->fontSize -= 2; $rep->AmountCol(5, 6, $total, $dec); $rep->AmountCol(6, 7, $provtotal, $dec); $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
function 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; }
function print_annual_balance_breakdown_detail() { global $path_to_root, $date_system; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; if ($dim == 2) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $dimension2 = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { if ($dim == 1) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { $date = $_POST['PARAM_0']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $title = _("Annual Balance Breakdown - Detailed"); $output_filename = "AnnualBalanceBreakDownDetail"; $fontsize = 7; $page_size = user_pagesize(); $page_orientation = 'L'; $margins = array('top' => 30, 'bottom' => 34, 'left' => 16, 'right' => 10); $excelColWidthFactor = 5; $rep = new FrontReport($title, $output_filename, $page_size, $fontsize, $page_orientation, $margins, $excelColWidthFactor); $enddate = end_month($date); $dec = user_price_dec(); // Lay out the columns for this report //$cols2 = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- $cols2 = array(0 => 0, 70); $endline = $rep->endLine - 20; $wi = ($endline - $cols2[1]) / 12; // 12 amount columns for ($i = 2; $i < 15; $i++) { $cols2[$i] = $cols2[$i - 1] + $wi; } $cols = $cols2; //---------------------------------------------------------------------------------------- $aligns2 = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers2 = array(); //$cols = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- //---------------------------------------------------------------------------------------- $aligns = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers = array(); $date = begin_month($date); $date = add_months($date, -11); list($da, $mo, $yr) = explode_date_to_dmy($date); if ($date_system == 1) { list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da); } elseif ($date_system == 2) { list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da); } $headers2[0] = 'Account'; $headers[0] = ''; for ($i = 0; $i < 12; $i++) { $header_row[$i] = $rep->DatePrettyPrint($date, 0, 1); // Wrap at space between month & year $wrap_point = strpos($header_row[$i], ' '); if ($wrap_point) { $headers2[] = substr($header_row[$i], 0, $wrap_point); $headers[] = substr($header_row[$i], $wrap_point + 1); } else { $headers2[] = ''; $headers[] = $header_row[$i]; } $date = add_months($date, 1); } /* $header_row[] = "Fiscal Year Begin"; $header_row[] = "Fiscal YTD"; for ($i = 12; $i < 14; $i++) { $wrapped_header_text = $rep->TextWrapCalc($header_row[$i], $cols[$i+2] - $cols[$i+1], true); $headers2[] = trim($wrapped_header_text[0]); $headers[] = trim($wrapped_header_text[1]); } */ if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => '', 'from' => '', 'to' => ''), 4 => array('text' => _("Dimension 1"), 'from' => get_dimension_string($dimension), 'to' => ''), 5 => array('text' => _("Dimension 2"), 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate))); } } // Company logo setting $companylogoenable = true; // Footer Settings $footerenable = true; $footertext = _('For Management Purposes Only'); $rep->Font(); $rep->SetFillColor(240, 240, 240); $rep->scaleLogoWidth = true; $rep->lineHeight = 8; $rep->SetCellPadding(4); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2, $companylogoenable, $footerenable, $footertext); $rep->SetHeaderType('Header3'); $rep->NewPage(); $rep->SetDrawColor(0, 0, 0); $rep->SetLineWidth(0.1); $sales = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $classresult = get_account_classes(false, 1); while ($class = db_fetch($classresult)) { $ctotal = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $convert = get_class_type_convert($class["ctype"]); //Print Class Name $rep->NewLine(); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $oldFontSize = $rep->fontSize; $rep->fontSize = 12; $rep->Font('b'); $rep->TextCol(0, 5, $class["class_name"]); $rep->Font(); $rep->fontSize = $oldFontSize; $rep->SetCellPadding($oldcMargin); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { $classtotal = display_type($accounttype["id"], $accounttype["name"], $yr, $mo, $convert, $dec, $rep, $dimension, $dimension2); for ($i = 1; $i <= 12; $i++) { $ctotal[$i] += $classtotal[$i]; } } //Print Class Summary $rep->row += 5; $rep->Line($rep->row - 3); $rep->NewLine(); $rep->Font('b'); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $fill = 0; $rep->TextCol(0, 1, _('Total') . " " . $class["class_name"], 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $ctotal[$i] * $convert, $dec, 0, 4, 0, $fill, NULL, 1, true); $sales[$i] += $ctotal[$i]; } $rep->Font(); $rep->NewLine(2); } $rep->Font('bold'); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->TextCol(0, 1, _('Net Assets (Liabilities)'), 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $sales[$i] * -1, $dec, 0, 4, 0, $fill, NULL, 1, true); } $rep->Font(); $rep->NewLine(); $rep->Line($rep->row); $rep->NewLine(2); $calc = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $total = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $classresult = get_account_classes(false, 0); while ($class = db_fetch($classresult)) { $convert = get_class_type_convert($class["ctype"]); //Print Class Name $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->Font('b'); $rep->TextCol(0, 1, _("Total ") . $class["class_name"], 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); $typeresult = get_account_types(false, $class['cid']); while ($accounttype = db_fetch($typeresult)) { $result = get_gl_accounts(null, null, $accounttype['id']); while ($account = db_fetch($result)) { $bal = getPeriods($yr, $mo, $account["account_code"], $dimension, $dimension2); $balance = array(1 => $bal['per01'], $bal['per02'], $bal['per03'], $bal['per04'], $bal['per05'], $bal['per06'], $bal['per07'], $bal['per08'], $bal['per09'], $bal['per10'], $bal['per11'], $bal['per12']); for ($i = 1; $i <= 12; $i++) { $total[$i] += $balance[$i]; } } } for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $total[$i] * $convert, $dec, 0, 4, 0, $fill, NULL, 1, true); $calc[$i] += $total[$i]; $total[$i] = 0; } $rep->NewLine(2); } $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->TextCol(0, 1, _('Total Profit/Loss'), 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, -$calc[$i], $dec, 0, 4, 0, $fill, NULL, 1, true); // no convert } $rep->Font(); $rep->End(); }