saimod todo pagination

This commit is contained in:
Ulf Gebhardt 2015-06-10 18:30:11 +02:00
parent 277fd88105
commit 073e9c2538
12 changed files with 33 additions and 24 deletions

View File

@ -27,6 +27,7 @@ class ResultMysqliPrepare extends \SYSTEM\DB\Result{
\mysqli_free_result($this->meta);
call_user_func_array(array($this->res, 'bind_result'), $this->binds); //you need 2 append the parameters - thats the right way to do that.
$this->res->store_result();
}
public function __destruct() {

View File

@ -49,8 +49,8 @@ INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`,
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (116, 42, 'editor', 'text', 115, 0, 1, '#tab_editor', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_text&action=editor&id=${id}&lang=${lang}', 'init_saimod_sys_text_editor', '\\SYSTEM\\SAI\\saimod_sys_text');
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (120, 42, 'todo', 'todo', -1, 0, 0, '#content', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo', 'init_saimod_sys_todo', '\\SYSTEM\\SAI\\saimod_sys_todo');
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (121, 42, 'todolist', 'todo', 120, 0, 0, '#tab_todo', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=todolist&filter=${filter}&search=${search}', 'init_saimod_sys_todo_todo', '\\SYSTEM\\SAI\\saimod_sys_todo');
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (122, 42, 'doto', 'todo', 120, 0, 1, '#tab_todo', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=dotolist&filter=${filter}&search=${search}', 'init_saimod_sys_todo_doto', '\\SYSTEM\\SAI\\saimod_sys_todo');
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (121, 42, 'todolist', 'todo', 120, 0, 0, '#tab_todo', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=todolist&filter=${filter}&search=${search}&page=${page}', 'init_saimod_sys_todo_todo', '\\SYSTEM\\SAI\\saimod_sys_todo');
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (122, 42, 'doto', 'todo', 120, 0, 1, '#tab_todo', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=dotolist&filter=${filter}&search=${search}&page=${page}', 'init_saimod_sys_todo_doto', '\\SYSTEM\\SAI\\saimod_sys_todo');
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (123, 42, 'stats', 'todo', 120, 0, 1, '#tab_todo', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=stats', 'init_saimod_sys_todo_stats', '\\SYSTEM\\SAI\\saimod_sys_todo');
INSERT INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (124, 42, 'todoopen', 'todo', 120, 0, 1, '#tab_todo', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=todo&todo=${todo}', 'init_saimod_sys_todo_todoopen', '\\SYSTEM\\SAI\\saimod_sys_todo');

View File

@ -146,8 +146,10 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1016, 42, 2, 1000, 'priority_down', 'todo', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1020, 42, 3, 1000, 'todolist', 'filter', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1021, 42, 3, 1000, 'todolist', 'search', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1022, 42, 3, 1000, 'todolist', 'page', 'UINT0');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1025, 42, 3, 1000, 'dotolist', 'filter', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1026, 42, 3, 1000, 'dotolist', 'search', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1027, 42, 3, 1000, 'dotolist', 'page', 'UINT0');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1100, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_docu', 'action', NULL);

View File

@ -22,7 +22,7 @@ function init_saimod_sys_todo() {
function register_search(){
$('#btn_search').click(function(){
system.load($(this).attr('state')+$('#input_search').val(),true);
system.load($(this).attr('state')+$('#input_search').val()+$(this).attr('state2'),true);
});
}

View File

@ -21,7 +21,6 @@ class SYS_SAIMOD_TODO_LIST extends \SYSTEM\DB\QP {
' WHERE todo.'.\SYSTEM\DBD\system_todo::FIELD_STATE.' = ?'.
' AND (todo.'.\SYSTEM\DBD\system_todo::FIELD_MESSAGE.' LIKE ? OR creator.'.\SYSTEM\DBD\system_user::FIELD_USERNAME.' LIKE ? OR assignee.'.\SYSTEM\DBD\system_user::FIELD_USERNAME.' LIKE ?)'.
' ORDER BY case when assign.'.\SYSTEM\DBD\system_todo_assign::FIELD_USER.' = ? then 1 else 2 end'.
' LIMIT 100'.
') as a'.
' GROUP BY a.todo_id'.
' ORDER BY a.'.\SYSTEM\DBD\system_todo::FIELD_PRIORITY.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_TYPE.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_COUNT.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_TIME.' DESC'

View File

@ -21,7 +21,6 @@ class SYS_SAIMOD_TODO_LIST_FREE extends \SYSTEM\DB\QP {
' WHERE todo.'.\SYSTEM\DBD\system_todo::FIELD_STATE.' = ?'.
' AND assign.'.\SYSTEM\DBD\system_todo_assign::FIELD_USER.' IS NULL'.
' AND (todo.'.\SYSTEM\DBD\system_todo::FIELD_MESSAGE.' LIKE ? OR creator.'.\SYSTEM\DBD\system_user::FIELD_USERNAME.' LIKE ? OR assignee.'.\SYSTEM\DBD\system_user::FIELD_USERNAME.' LIKE ?)'.
' LIMIT 100'.
') as a'.
' GROUP BY a.todo_id'.
' ORDER BY a.'.\SYSTEM\DBD\system_todo::FIELD_PRIORITY.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_TYPE.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_COUNT.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_TIME.' DESC'

View File

@ -21,7 +21,6 @@ class SYS_SAIMOD_TODO_LIST_MINE extends \SYSTEM\DB\QP {
' WHERE todo.'.\SYSTEM\DBD\system_todo::FIELD_STATE.' = ?'.
' AND assign.'.\SYSTEM\DBD\system_todo_assign::FIELD_USER.' = ?'.
' AND (todo.'.\SYSTEM\DBD\system_todo::FIELD_MESSAGE.' LIKE ? OR creator.'.\SYSTEM\DBD\system_user::FIELD_USERNAME.' LIKE ? OR assignee.'.\SYSTEM\DBD\system_user::FIELD_USERNAME.' LIKE ?)'.
' LIMIT 100'.
') as a'.
' GROUP BY a.todo_id'.
' ORDER BY a.'.\SYSTEM\DBD\system_todo::FIELD_PRIORITY.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_TYPE.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_COUNT.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_TIME.' DESC'

View File

@ -21,7 +21,6 @@ class SYS_SAIMOD_TODO_LIST_OTHERS extends \SYSTEM\DB\QP {
' WHERE todo.'.\SYSTEM\DBD\system_todo::FIELD_STATE.' = ?'.
' AND NOT assign.'.\SYSTEM\DBD\system_todo_assign::FIELD_USER.' = ?'.
' AND (todo.'.\SYSTEM\DBD\system_todo::FIELD_MESSAGE.' LIKE ? OR creator.'.\SYSTEM\DBD\system_user::FIELD_USERNAME.' LIKE ? OR assignee.'.\SYSTEM\DBD\system_user::FIELD_USERNAME.' LIKE ?)'.
' LIMIT 100'.
') as a'.
' GROUP BY a.todo_id'.
' ORDER BY a.'.\SYSTEM\DBD\system_todo::FIELD_PRIORITY.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_TYPE.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_COUNT.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_TIME.' DESC'

View File

@ -22,7 +22,6 @@ class SYS_SAIMOD_TODO_LIST_TYPE extends \SYSTEM\DB\QP {
' AND todo.'.\SYSTEM\DBD\system_todo::FIELD_TYPE.' = ?'.
' AND (todo.'.\SYSTEM\DBD\system_todo::FIELD_MESSAGE.' LIKE ? OR creator.'.\SYSTEM\DBD\system_user::FIELD_USERNAME.' LIKE ? OR assignee.'.\SYSTEM\DBD\system_user::FIELD_USERNAME.' LIKE ?)'.
' ORDER BY case when assign.'.\SYSTEM\DBD\system_todo_assign::FIELD_USER.' = ? then 1 else 2 end'.
' LIMIT 100'.
') as a'.
' GROUP BY a.todo_id'.
' ORDER BY a.'.\SYSTEM\DBD\system_todo::FIELD_PRIORITY.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_TYPE.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_COUNT.' DESC, a.'.\SYSTEM\DBD\system_todo::FIELD_TIME.' DESC'

View File

@ -49,17 +49,18 @@ class saimod_sys_todo extends \SYSTEM\SAI\SaiModule {
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_todo/tpl/saimod_sys_todo_new.tpl'), $vars);
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_action_todolist($filter='all',$search=''){
return self::generate_list(\SYSTEM\DBD\system_todo::FIELD_STATE_OPEN,$filter,$search);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_action_todolist($filter='all',$search='%',$page=0){
return self::generate_list(\SYSTEM\DBD\system_todo::FIELD_STATE_OPEN,$filter,$search,$page);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_action_dotolist($filter='all',$search=''){
return self::generate_list(\SYSTEM\DBD\system_todo::FIELD_STATE_CLOSED,$filter,$search);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_action_dotolist($filter='all',$search='%',$page=0){
return self::generate_list(\SYSTEM\DBD\system_todo::FIELD_STATE_CLOSED,$filter,$search,$page);}
private static function generate_list($state,$filter,$search){
private static function generate_list($state,$filter,$search,$page){
$vars = array();
$vars['filter'] = $filter;
$vars['search'] = $search;
$search = '%'.$search.'%';
$vars['page'] = $page;
$search = $search;
$vars['todo_list_elements'] = $vars['filter_mine'] =
$vars['filter_free'] = $vars['filter_others'] = $vars['filter_gen'] =
$vars['filter_user'] = $vars['filter_report'] = '';
@ -102,7 +103,8 @@ class saimod_sys_todo extends \SYSTEM\SAI\SaiModule {
break;
}
$count_filtered = 0;
while($row = $res->next()){
$res->seek(100*$page);
while(($row = $res->next()) && ($count_filtered < 100)){
$row['class_row'] = self::trclass($row['type'],$row['class'],$row['assignee_id'],$userid);
$row['time_elapsed'] = \SYSTEM\time::time_ago_string(strtotime($row['time']));
$row['state_string'] = self::state($row['count']);
@ -114,6 +116,11 @@ class saimod_sys_todo extends \SYSTEM\SAI\SaiModule {
$vars['todo_list_elements'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_todo/tpl/todo_user_list_element.tpl'), $row);
$count_filtered++;
}
$vars['pagination'] = '';
for($i=0;$i < ceil($count/100);$i++){
$data = array('page' => $i,'search' => $search, 'filter' => $filter, 'active' => ($i == $page) ? 'active' : '');
$vars['pagination'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_todo/tpl/todo_list_pagination.tpl'), $data);
}
$vars['count'] = $count_filtered.'/'.$count;
$vars['state'] = $state == \SYSTEM\DBD\system_todo::FIELD_STATE_OPEN ? 'todo' : 'todo(doto)';
$vars = array_merge($vars, \SYSTEM\PAGE\text::tag(\SYSTEM\DBD\system_text::TAG_SAI_TODO));

View File

@ -1,17 +1,17 @@
<div id="table-wrapper">
<ul class="nav nav-pills" id="error_filter">
<li class="${filter_all}"><a href="#!${state};filter.all;search.${search}">${basic_all}</a></li>
<li class="${filter_mine}"><a href="#!${state};filter.mine;search.${search}">${basic_mine}</a></li>
<li class="${filter_free}"><a href="#!${state};filter.free;search.${search}">${basic_free}</a></li>
<li class="${filter_others}"><a href="#!${state};filter.others;search.${search}">${basic_others}</a></li>
<li class="${filter_gen}"><a href="#!${state};filter.gen;search.${search}">${basic_generated}</a></li>
<li class="${filter_user}"><a href="#!${state};filter.user;search.${search}">${basic_user}</a></li>
<li class="${filter_report}"><a href="#!${state};filter.report;search.${search}">${basic_report}</a></li>
<button class="btn-sm btn btn-success" state="${state};filter.${filter};search." id="btn_search" type="submit" style="float: right; margin-left: 10px;"><span class="glyphicon glyphicon-search" aria-hidden="true"></span> ${basic_search}</button>
<li class="${filter_all}"><a href="#!${state};filter.all;search.${search};page.${page}">${basic_all}</a></li>
<li class="${filter_mine}"><a href="#!${state};filter.mine;search.${search};page.${page}">${basic_mine}</a></li>
<li class="${filter_free}"><a href="#!${state};filter.free;search.${search};page.${page}">${basic_free}</a></li>
<li class="${filter_others}"><a href="#!${state};filter.others;search.${search};page.${page}">${basic_others}</a></li>
<li class="${filter_gen}"><a href="#!${state};filter.gen;search.${search};page.${page}">${basic_generated}</a></li>
<li class="${filter_user}"><a href="#!${state};filter.user;search.${search};page.${page}">${basic_user}</a></li>
<li class="${filter_report}"><a href="#!${state};filter.report;search.${search};page.${page}">${basic_report}</a></li>
<button class="btn-sm btn btn-success" state="${state};filter.${filter};search." state2=";page.${page}" id="btn_search" type="submit" style="float: right; margin-left: 10px;"><span class="glyphicon glyphicon-search" aria-hidden="true"></span> ${basic_search}</button>
<input class="input-medium search-query action-control" id="input_search" type="text" placeholder="${basic_placeholder_search}" size="20" style="float: right;" value="${search}"/>
</ul>
Rows: ${count}
<h5>User ToDo's</h5>
<h5>ToDo's</h5>
<table class="table table-hover table-condensed">
<tr>
<th>${time_ago}</th>
@ -21,4 +21,7 @@
</tr>
${todo_list_elements}
</table>
<ul class="pagination">
${pagination}
</ul>
</div>

View File

@ -0,0 +1 @@
<li><a class="${active}" href="#!${state};filter.all;search.${search};page.${page}">${page}</a></li>