function pager(&$pager) { global $use_popup_windows, $use_date_picker, $path_to_root; $pager->select_records(); div_start("_{$pager->name}_span"); $headers = array(); foreach ($pager->columns as $num_col => $col) { // record status control column is displayed only when control checkbox is on if (isset($col['head']) && ($col['type'] != 'inactive' || get_post('show_inactive'))) { if (!isset($col['ord'])) { $headers[] = $col['head']; } else { $icon = $col['ord'] == 'desc' ? 'sort_desc.gif' : ($col['ord'] == 'asc' ? 'sort_asc.gif' : 'sort_none.gif'); $headers[] = navi_button($pager->name . '_sort_' . $num_col, $col['head'], true, $icon); } } } /* show a table of records returned by the sql */ start_table(TABLESTYLE, "width={$pager->width}"); table_header($headers); if ($pager->header_fun) { // if set header handler start_row("class='{$pager->header_class}'"); $fun = $pager->header_fun; if (method_exists($pager, $fun)) { $h = $pager->{$fun}($pager); } elseif (function_exists($fun)) { $h = $fun($pager); } foreach ($h as $c) { // draw header columns $pars = isset($c[1]) ? $c[1] : ''; label_cell($c[0], $pars); } end_row(); } $cc = 0; // row colour counter foreach ($pager->data as $line_no => $row) { $marker = $pager->marker; if ($marker && $marker($row)) { start_row("class='{$pager->marker_class}'"); } else { alt_table_row_color($cc); } foreach ($pager->columns as $k => $col) { $coltype = $col['type']; $cell = isset($col['name']) ? $row[$col['name']] : ''; if (isset($col['fun'])) { // use data input function if defined $fun = $col['fun']; if (method_exists($pager, $fun)) { $cell = $pager->{$fun}($row, $cell); } elseif (function_exists($fun)) { $cell = $fun($row, $cell); } else { $cell = ''; } } switch ($coltype) { // format column case 'time': label_cell($cell, "width=40"); break; case 'date': label_cell(sql2date($cell), "align='center' nowrap"); break; case 'dstamp': // time stamp displayed as date label_cell(sql2date(substr($cell, 0, 10)), "align='center' nowrap"); break; case 'tstamp': // time stamp - FIX user format label_cell(sql2date(substr($cell, 0, 10)) . ' ' . substr($cell, 10), "align='center'"); break; case 'percent': percent_cell($cell); break; case 'amount': if ($cell == '') { label_cell(''); } else { amount_cell($cell, false); } break; case 'qty': if ($cell == '') { label_cell(''); } else { qty_cell($cell, false, isset($col['dec']) ? $col['dec'] : null); } break; case 'email': email_cell($cell, isset($col['align']) ? "align='" . $col['align'] . "'" : null); break; case 'rate': label_cell(number_format2($cell, user_exrate_dec()), "align=center"); break; case 'inactive': if (get_post('show_inactive')) { $pager->inactive_control_cell($row); } break; default: // case 'text': if (isset($col['align'])) { label_cell($cell, "align='" . $col['align'] . "'"); } else { label_cell($cell); } case 'skip': // column not displayed } } end_row(); } // end of while loop if ($pager->footer_fun) { // if set footer handler start_row("class='{$pager->footer_class}'"); $fun = $pager->footer_fun; if (method_exists($pager, $fun)) { $h = $pager->{$fun}($pager); } elseif (function_exists($fun)) { $h = $fun($pager); } foreach ($h as $c) { // draw footer columns $pars = isset($c[1]) ? $c[1] : ''; label_cell($c[0], $pars); } end_row(); } start_row("class='navibar'"); $colspan = count($pager->columns); $inact = @$pager->inactive_ctrl == true ? ' ' . checkbox(null, 'show_inactive', null, true) . _("Show also Inactive") : ''; end_row(); end_table(); $but_pref = $pager->name . '_page_'; // if (@$pager->inactive_ctrl) // submit('Update', _('Update'), true, '', null); // inactive update $context = array('first' => $this->pager_button($but_pref . 'first', _('«'), $pager->first_page), 'previous' => $this->pager_button($but_pref . 'prev', _('‹'), $pager->prev_page), 'next' => $this->pager_button($but_pref . 'next', _('›'), $pager->next_page), 'last' => $this->pager_button($but_pref . 'last', _('»'), $pager->last_page)); $from = ($pager->curr_page - 1) * $pager->page_len + 1; $to = $from + $pager->page_len - 1; if ($to > $pager->rec_count) { $to = $pager->rec_count; } $all = $pager->rec_count; // echo sprintf(_('Records %d-%d of %d'), $from, $to, $all); // echo $inact; // echo "</td>"; echo ThemeBootstrap::get()->renderBlock('controls.twig.html', 'pager', $context); /* if ($pager->rec_count) { echo "<td colspan=$colspan class='navibar' style='border:none;padding:3px;'>"; echo "<div style='float:right;'>"; $but_pref = $pager->name . '_page_'; start_table(); start_row(); if (@$pager->inactive_ctrl) submit('Update', _('Update'), true, '', null); // inactive update echo navi_button_cell($but_pref . 'first', _('First'), $pager->first_page, 'right'); echo navi_button_cell($but_pref . 'prev', _('Prev'), $pager->prev_page, 'right'); echo navi_button_cell($but_pref . 'next', _('Next'), $pager->next_page, 'right'); echo navi_button_cell($but_pref . 'last', _('Last'), $pager->last_page, 'right'); end_row(); end_table(); echo "</div>"; $from = ($pager->curr_page - 1) * $pager->page_len + 1; $to = $from + $pager->page_len - 1; if ($to > $pager->rec_count) $to = $pager->rec_count; $all = $pager->rec_count; echo sprintf(_('Records %d-%d of %d'), $from, $to, $all); echo $inact; echo "</td>"; } else { label_cell(_('No records') . $inact, "colspan=$colspan class='navibar'"); } */ if (isset($pager->marker_txt)) { display_note($pager->marker_txt, 0, 1, "class='{$pager->notice_class}'"); } div_end(); return true; }
function display_credit_items() { start_form(); hidden('cart_id'); start_table(TABLESTYLE2, "width=80%", 5); echo "<tr><td>"; // outer table start_table(TABLESTYLE, "width=100%"); start_row(); label_cells(_("Customer"), $_SESSION['Items']->customer_name, "class='tableheader2'"); label_cells(_("Branch"), get_branch_name($_SESSION['Items']->Branch), "class='tableheader2'"); label_cells(_("Currency"), $_SESSION['Items']->customer_currency, "class='tableheader2'"); end_row(); start_row(); // if (!isset($_POST['ref'])) // $_POST['ref'] = $Refs->get_next(11); if ($_SESSION['Items']->trans_no == 0) { ref_cells(_("Reference"), 'ref', '', null, "class='tableheader2'"); } else { label_cells(_("Reference"), $_SESSION['Items']->reference, "class='tableheader2'"); } label_cells(_("Crediting Invoice"), get_customer_trans_view_str(ST_SALESINVOICE, array_keys($_SESSION['Items']->src_docs)), "class='tableheader2'"); if (!isset($_POST['ShipperID'])) { $_POST['ShipperID'] = $_SESSION['Items']->ship_via; } label_cell(_("Shipping Company"), "class='tableheader2'"); shippers_list_cells(null, 'ShipperID', $_POST['ShipperID']); // if (!isset($_POST['sales_type_id'])) // $_POST['sales_type_id'] = $_SESSION['Items']->sales_type; // label_cell(_("Sales Type"), "class='tableheader2'"); // sales_types_list_cells(null, 'sales_type_id', $_POST['sales_type_id']); end_row(); end_table(); echo "</td><td>"; // outer table start_table(TABLESTYLE, "width=100%"); if ($_SESSION['Items']->custom_num != '') { text_row(_("Credit Memo No."), 'custom_num', $_SESSION['Items']->custom_num, null, "class='tableheader2'"); } else { text_row(_("Credit Memo No."), 'custom_num', '', null, "class='tableheader2'"); } //moodlearning label_row(_("Invoice Date"), $_SESSION['Items']->src_date, "class='tableheader2'"); date_row(_("Credit Note Date"), 'CreditDate', '', $_SESSION['Items']->trans_no == 0, 0, 0, 0, "class='tableheader2'"); end_table(); echo "</td></tr>"; end_table(1); // outer table div_start('credit_items'); start_table(TABLESTYLE, "width=80%"); $th = array(_("Item Code"), _("Item Description"), _("Invoiced Quantity"), _("Units"), _("Credited"), _("Credit Quantity"), _("Price"), _("Discount %"), _("Total")); //Karen edited Credited table_header($th); $k = 0; //row colour counter foreach ($_SESSION['Items']->line_items as $line_no => $ln_itm) { if ($ln_itm->quantity == $ln_itm->qty_done) { continue; // this line was fully credited/removed } alt_table_row_color($k); // view_stock_status_cell($ln_itm->stock_id); alternative view label_cell($ln_itm->stock_id); text_cells(null, 'Line' . $line_no . 'Desc', $ln_itm->item_description, 30, 50); $dec = get_qty_dec($ln_itm->stock_id); qty_cell($ln_itm->quantity, false, $dec); label_cell($ln_itm->units); label_cell($ln_itm->qty_done); //Karen edited amount_cells(null, 'Line' . $line_no, number_format2($ln_itm->qty_dispatched, $dec), null, null, $dec); $line_total = $ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent); amount_cell($ln_itm->price); percent_cell($ln_itm->discount_percent * 100); amount_cell($line_total); end_row(); } if (!check_num('ChargeFreightCost')) { $_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost); } $colspan = 8; //Karen edited 7 start_row(); label_cell(_("Credit Shipping Cost"), "colspan={$colspan} align=right"); small_amount_cells(null, "ChargeFreightCost", price_format(get_post('ChargeFreightCost', 0))); end_row(); /*moodlearning*/ start_row(); label_cell(_("Bulk Discount"), "colspan={$colspan} align=right"); small_amount_cells(null, "bulk_dis", $_SESSION['Items']->bulk_discount); end_row(); /* */ $inv_items_total = $_SESSION['Items']->get_items_total_dispatch(); $discount = input_num('bulk_dis') / 100; $display_sub_total = price_format($inv_items_total + input_num($_POST['ChargeFreightCost'])); label_row(_("Sub-total"), $display_sub_total, "colspan={$colspan} align=right", "align=right"); $taxes = $_SESSION['Items']->get_taxes(input_num($_POST['ChargeFreightCost'])); $tax_total = display_edit_tax_items($taxes, $colspan, $_SESSION['Items']->tax_included); /*moodlearning*/ $total = $inv_items_total + input_num('ChargeFreightCost') + $tax_total; $tot = price_format($total - $total * $discount); /* */ $display_total = price_format($inv_items_total + input_num('ChargeFreightCost') + $tax_total); label_row(_("Credit Note Total"), $tot, "colspan={$colspan} align=right", "align=right"); //moodlearning edit $tot end_table(); div_end(); }
function display_credit_items() { global $table_style, $table_style2; start_form(false, true); start_table("{$table_style2} width=80%", 5); echo "<tr><td>"; // outer table start_table("{$table_style} width=100%"); start_row(); label_cells(tr("Customer"), $_SESSION['Items']->customer_name, "class='tableheader2'"); label_cells(tr("Branch"), get_branch_name($_SESSION['Items']->Branch), "class='tableheader2'"); label_cells(tr("Currency"), $_SESSION['Items']->customer_currency, "class='tableheader2'"); end_row(); start_row(); // if (!isset($_POST['ref'])) // $_POST['ref'] = references::get_next(11); if ($_SESSION['Items']->trans_no == 0) { ref_cells(tr("Reference"), 'ref', $_SESSION['Items']->reference, "class='tableheader2'"); } else { label_cells(tr("Reference"), $_SESSION['Items']->reference, "class='tableheader2'"); } // label_cells(tr("Crediting Invoice"), get_customer_trans_view_str(10, $_SESSION['InvoiceToCredit']), "class='tableheader2'"); label_cells(tr("Crediting Invoice"), get_customer_trans_view_str(10, array_keys($_SESSION['Items']->src_docs)), "class='tableheader2'"); if (!isset($_POST['ShipperID'])) { $_POST['ShipperID'] = $_SESSION['Items']->ship_via; } label_cell(tr("Shipping Company"), "class='tableheader2'"); shippers_list_cells(null, 'ShipperID', $_POST['ShipperID']); // if (!isset($_POST['sales_type_id'])) // $_POST['sales_type_id'] = $_SESSION['Items']->sales_type; // label_cell(tr("Sales Type"), "class='tableheader2'"); // sales_types_list_cells(null, 'sales_type_id', $_POST['sales_type_id']); end_row(); end_table(); echo "</td><td>"; // outer table start_table("{$table_style} width=100%"); label_row(tr("Invoice Date"), $_SESSION['Items']->src_date, "class='tableheader2'"); date_row(tr("Credit Note Date"), 'CreditDate', null, 0, 0, 0, "class='tableheader2'"); end_table(); echo "</td></tr>"; end_table(1); // outer table start_table("{$table_style} width=80%"); $th = array(tr("Item Code"), tr("Item Description"), tr("Invoiced Quantity"), tr("Units"), tr("Credit Quantity"), tr("Price"), tr("Discount %"), tr("Total")); table_header($th); $k = 0; //row colour counter foreach ($_SESSION['Items']->line_items as $line_no => $ln_itm) { if ($ln_itm->quantity == $ln_itm->qty_done) { continue; // this line was fully credited } alt_table_row_color($k); // view_stock_status_cell($ln_itm->stock_id); alternative view label_cell($ln_itm->stock_id); text_cells(null, 'Line' . $line_no . 'Desc', $ln_itm->item_description, 30, 50); qty_cell($ln_itm->quantity); label_cell($ln_itm->units); amount_cells(null, 'Line' . $line_no, qty_format($ln_itm->qty_dispatched)); $line_total = $ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent); amount_cell($ln_itm->price); percent_cell($ln_itm->discount_percent * 100); amount_cell($line_total); end_row(); } if (!check_num('ChargeFreightCost')) { $_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost); } start_row(); label_cell(tr("Credit Shipping Cost"), "colspan=7 align=right"); amount_cells(null, "ChargeFreightCost", $_POST['ChargeFreightCost'], 6, 6); end_row(); $inv_items_total = $_SESSION['Items']->get_items_total_dispatch(); $display_sub_total = price_format($inv_items_total + input_num($_POST['ChargeFreightCost'])); label_row(tr("Sub-total"), $display_sub_total, "colspan=7 align=right", "align=right"); $taxes = $_SESSION['Items']->get_taxes(input_num($_POST['ChargeFreightCost'])); $tax_total = display_edit_tax_items($taxes, 7, $_SESSION['Items']->tax_included); $display_total = price_format($inv_items_total + input_num('ChargeFreightCost') + $tax_total); label_row(tr("Credit Note Total"), $display_total, "colspan=7 align=right", "align=right"); end_table(); }