Esempio n. 1
0
start_form();
start_table(TABLESTYLE);
$th = array(_("User login"), _("Full Name"), _("Phone"), _("E-mail"), _("Last Visit"), _("Access Level"), "", "");
inactive_control_column($th);
table_header($th);
$k = 0;
//row colour counter
while ($myrow = db_fetch($result)) {
    alt_table_row_color($k);
    $last_visit_date = sql2date($myrow["last_visit_date"]);
    /*The security_headings array is defined in config.php */
    $not_me = strcasecmp($myrow["user_id"], $_SESSION["wa_current_user"]->username);
    label_cell($myrow["user_id"]);
    label_cell($myrow["real_name"]);
    label_cell($myrow["phone"]);
    email_cell($myrow["email"]);
    label_cell($last_visit_date, "nowrap");
    label_cell($myrow["role"]);
    if ($not_me) {
        inactive_control_cell($myrow["id"], $myrow["inactive"], 'users', 'id');
    } elseif (check_value('show_inactive')) {
        label_cell('');
    }
    edit_button_cell("Edit" . $myrow["id"], _("Edit"));
    if ($not_me) {
        delete_button_cell("Delete" . $myrow["id"], _("Delete"));
    } else {
        label_cell('');
    }
    end_row();
}
 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;
 }
Esempio n. 3
0
    $_POST['show_inactive'] = $sav;
}
//------------------------------------------------------------------------------------------------
$result = get_salesmen(check_value('show_inactive'));
start_form();
start_table(TABLESTYLE, "width='60%'");
$th = array(_("Name"), _("Phone"), _("Fax"), _("Email"), _("Provision"), _("Break Pt."), _("Provision") . " 2", "", "");
inactive_control_column($th);
table_header($th);
$k = 0;
while ($myrow = db_fetch($result)) {
    alt_table_row_color($k);
    label_cell($myrow["salesman_name"]);
    label_cell($myrow["salesman_phone"]);
    label_cell($myrow["salesman_fax"]);
    email_cell($myrow["salesman_email"]);
    label_cell(percent_format($myrow["provision"]) . " %", "nowrap align=right");
    amount_cell($myrow["break_pt"]);
    label_cell(percent_format($myrow["provision2"]) . " %", "nowrap align=right");
    inactive_control_cell($myrow["salesman_code"], $myrow["inactive"], 'salesman', 'salesman_code');
    edit_button_cell("Edit" . $myrow["salesman_code"], _("Edit"));
    delete_button_cell("Delete" . $myrow["salesman_code"], _("Delete"));
    end_row();
}
//END WHILE LIST LOOP
inactive_control_row($th);
end_table();
echo '<br>';
//------------------------------------------------------------------------------------------------
$_POST['salesman_email'] = "";
if ($selected_id != -1) {