function generate_page(&$tpl) { global $month, $year, $sql, $cfg; $start_index = 0; $rows_per_page = $cfg['DOMAIN_ROWS_PER_PAGE']; if (isset($_GET['psi']) && is_numeric($_GET['psi'])) { $start_index = $_GET['psi']; } else { if (isset($_POST['psi']) && is_numeric($_GET['psi'])) { $start_index = $_POST['psi']; } } $tpl->assign(array('POST_PREV_PSI' => $start_index)); // count query $count_query = <<<SQL_QUERY select count(admin_id) as cnt from admin where admin_type = 'reseller' SQL_QUERY; $query = <<<SQL_QUERY select admin_id, admin_name from admin where admin_type = 'reseller' order by admin_id desc limit {$start_index}, {$rows_per_page} SQL_QUERY; $rs = exec_query($sql, $count_query, array()); $records_count = $rs->fields['cnt']; $rs = exec_query($sql, $query, array()); if ($rs->RowCount() == 0) { /* $tpl -> assign( array( 'TRAFFIC_TABLE' => '', 'MESSAGE' => tr('Not found reseller(s) in your system!') ) ); */ $tpl->assign(array('TRAFFIC_TABLE' => '', 'SCROLL_PREV' => '', 'SCROLL_NEXT' => '')); set_page_message(tr('Not found reseller(s) in your system!')); return; } else { $prev_si = $start_index - $rows_per_page; if ($start_index == 0) { $tpl->assign('SCROLL_PREV', ''); } else { $tpl->assign(array('SCROLL_PREV_GRAY' => '', 'PREV_PSI' => $prev_si)); } $next_si = $start_index + $rows_per_page; if ($next_si + 1 > $records_count) { $tpl->assign('SCROLL_NEXT', ''); } else { $tpl->assign(array('SCROLL_NEXT_GRAY' => '', 'NEXT_PSI' => $next_si)); } $tpl->assign(array('PAGE_MESSAGE' => '')); gen_select_lists($tpl, @$month, @$year); $row = 1; while (!$rs->EOF) { generate_reseller_entry($tpl, $rs->fields['admin_id'], $rs->fields['admin_name'], $row++); $rs->MoveNext(); } } $tpl->parse('TRAFFIC_TABLE', 'traffic_table'); }
/** * @param EasySCP_TemplateEngine $tpl */ function generate_page($tpl) { global $month, $year; $cfg = EasySCP_Registry::get('Config'); $sql = EasySCP_Registry::get('Db'); $start_index = 0; $rows_per_page = $cfg->DOMAIN_ROWS_PER_PAGE; if (isset($_GET['psi']) && is_numeric($_GET['psi'])) { $start_index = $_GET['psi']; } else { if (isset($_POST['psi']) && is_numeric($_GET['psi'])) { $start_index = $_POST['psi']; } } $tpl->assign(array('POST_PREV_PSI' => $start_index)); // count query $count_query = "\n\t\tSELECT\n\t\t\tCOUNT(`admin_id`) AS cnt\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_type` = 'reseller'\n\t"; $query = "\n\t\tSELECT\n\t\t\t`admin_id`, `admin_name`\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_type` = 'reseller'\n\t\tORDER BY\n\t\t\t`admin_name` DESC\n\t\tLIMIT\n\t\t\t{$start_index}, {$rows_per_page};\n\t"; $rs = exec_query($sql, $count_query); $records_count = $rs->fields['cnt']; $rs = exec_query($sql, $query); if ($rs->rowCount() == 0) { set_page_message(tr('There are no resellers in your system!'), 'info'); return; } else { $prev_si = $start_index - $rows_per_page; if ($start_index == 0) { $tpl->assign('SCROLL_PREV', ''); } else { $tpl->assign(array('SCROLL_PREV_GRAY' => '', 'PREV_PSI' => $prev_si)); } $next_si = $start_index + $rows_per_page; if ($next_si + 1 > $records_count) { $tpl->assign('SCROLL_NEXT', ''); } else { $tpl->assign(array('SCROLL_NEXT_GRAY' => '', 'NEXT_PSI' => $next_si)); } gen_select_lists($tpl, @$month, @$year); $row = 1; while (!$rs->EOF) { generate_reseller_entry($tpl, $rs->fields['admin_id'], $rs->fields['admin_name'], $row++); $rs->moveNext(); } } }