X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fdb_pager_view.inc;h=96609dc3afe1afefb983e613bf33020a5fbe8908;hb=7561718ee5113232ce917f63085d272884b0929c;hp=e9990815f5d22e78d464a551d186dda6827c45f1;hpb=69cb44aa7570e2ce26f540014cd682bc21c2ad1c;p=fa-stable.git diff --git a/includes/ui/db_pager_view.inc b/includes/ui/db_pager_view.inc index e9990815..96609dc3 100644 --- a/includes/ui/db_pager_view.inc +++ b/includes/ui/db_pager_view.inc @@ -1,13 +1,24 @@ . +***********************************************************************/ //-------------------------------------------------------------------------------------------------- -function pager_link($link_text, $url) +function pager_link($link_text, $url, $icon=false) { global $path_to_root; - $link = access_string($link_text); + if (user_graphic_links() && $icon) + $link_text = set_icon($icon, $link_text); $href = $path_to_root . $url; - return "" . $link[0] . ""; + return "" . $link_text . ""; } function navi_button($name, $value, $enabled=true, $icon = false) { @@ -22,21 +33,24 @@ function navi_button($name, $value, $enabled=true, $icon = false) { function navi_button_cell($name, $value, $enabled=true, $align='left') { label_cell(navi_button($name, $value, $enabled), "align='$align'"); } + + //----------------------------------------------------------------------------- // // Sql paged table view. Call this function inside form. // function display_db_pager(&$pager) { - global $table_style, $use_popup_windows, $use_date_picker, $path_to_root; + global $path_to_root; $pager->select_records(); div_start("_{$pager->name}_span"); $headers = array(); -//display_error(print_r($pager->columns,true)); + foreach($pager->columns as $num_col=>$col) { - if (isset($col['head'])) { - if (!isset($col['ord'])) + // 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' : @@ -47,9 +61,25 @@ function display_db_pager(&$pager) { } } /* show a table of records returned by the sql */ - start_table("$table_style width=95%"); + 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) { @@ -71,23 +101,36 @@ function display_db_pager(&$pager) { } else $cell = ''; } - switch($coltype) { // format column + case 'time': + label_cell($cell, "width=40"); break; case 'date': - label_cell(sql2date($cell), "align='center'"); break; + label_cell(sql2date($cell), "align='center' nowrap"); break; case 'dstamp': // time stamp displayed as date - label_cell(sql2date(substr($cell, 0, 10)), "align='center'"); break; + 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': - amount_cell($cell, false); break; + if ($cell=='') + label_cell(''); + else + amount_cell($cell, false); break; case 'qty': - qty_cell($cell); break; + 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': - rate_cell($cell); break; + 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'])) @@ -100,32 +143,56 @@ function display_db_pager(&$pager) { end_row(); } //end of while loop - end_table(); - start_table("$table_style align='center' class='navibar' width=95%"); - start_row(); + + 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") : ''; if($pager->rec_count) { - $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; - label_cell(sprintf( _('Records %d-%d of %d'), $from, $to, $all), - "style='border:none'"); - echo "