if (isset($_POST['submit']))
{
switch ($_POST['userroles'])
{
case 0:
//all
//make the content to be paginated
$items = $db->dbSelectBySql("SELECT id,first_name,last_name,role,confirmed,email,registration_date FROM users ORDER BY registration_date DESC");
break;
case 1:
//admins
//make the content to be paginated
$items = $db->dbSelectBySql("SELECT id,first_name,last_name,role,confirmed,email,registration_date FROM users WHERE role = 1 ORDER BY registration_date DESC");
break;
case 2:
//regulars
//make the content to be paginated
$items = $db->dbSelectBySql("SELECT id,first_name,last_name,role,confirmed,email,registration_date FROM users WHERE role = 2 ORDER BY registration_date DESC");
break;
case 3:
//team
//make the content to be paginated
$items = $db->dbSelectBySql("SELECT id,first_name,last_name,role,confirmed,email,registration_date FROM users WHERE role = 3 ORDER BY registration_date DESC");
break;
case 4:
//sellers
//make the content to be paginated
$items = $db->dbSelectBySql("SELECT id,first_name,last_name,role,confirmed,email,registration_date FROM users WHERE role = 4 ORDER BY registration_date DESC");
break;
}
//pagination
//setting the offset
$offset = $this->params[1];
if (!$offset)
{
$totaloffset = 0;
}else{
$totaloffset = $offset * PERPAGE;
}
//connect the contents and the paginator
$slicedArray = array_slice($items,$totaloffset,PERPAGE);
$this->_view->items = $slicedArray;
$pagename = APP_URL . '/admin/users/index/';
$totalcount = count($items);
$numpages = ceil($totalcount/PERPAGE);
$this->_view->numpages = $numpages;
//create the paginator
$nav = new Shtigliz_PageNavigator($pagename,$totalcount,PERPAGE,$totaloffset,10);
$nav->setFirstParamName(OFFSET);
$this->_view->nav = $nav;
}
|