saimod todo asignee table, display - missing modification option

This commit is contained in:
Ulf Gebhardt 2015-06-02 21:27:38 +02:00
parent 1ba6cbd6cd
commit 450a39855b
8 changed files with 58 additions and 24 deletions

View File

@ -0,0 +1,8 @@
CREATE TABLE `system_todo_asign` (
`todo` INT(10) NOT NULL,
`user` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`todo`, `user`)
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB
;

View File

@ -0,0 +1,10 @@
<?php
namespace SYSTEM\DBD;
class system_todo_asign {
const NAME_PG = 'system.todo_asign';
const NAME_MYS = 'system_todo_asign';
const FIELD_TODO = 'todo';
const FIELD_USER = 'user';
}

View File

@ -0,0 +1,27 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_TODO_LIST extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'TODO',
//mys
'SELECT * FROM('.
' SELECT todo.'.\SYSTEM\DBD\system_todo::FIELD_ID.' as todo_id,'.
' todo.'.\SYSTEM\DBD\system_todo::FIELD_TYPE.', todo.'.\SYSTEM\DBD\system_todo::FIELD_CLASS.', todo.'.\SYSTEM\DBD\system_todo::FIELD_TIME.', todo.'.\SYSTEM\DBD\system_todo::FIELD_COUNT.', todo.'.\SYSTEM\DBD\system_todo::FIELD_MESSAGE.', todo.'.\SYSTEM\DBD\system_todo::FIELD_REQUEST_URI.', todo.'.\SYSTEM\DBD\system_todo::FIELD_FILE.', todo.'.\SYSTEM\DBD\system_todo::FIELD_LINE.', todo.'.\SYSTEM\DBD\system_todo::FIELD_SERVER_NAME.', todo.'.\SYSTEM\DBD\system_todo::FIELD_SERVER_PORT.', todo.'.\SYSTEM\DBD\system_todo::FIELD_QUERYTIME.', todo.'.\SYSTEM\DBD\system_todo::FIELD_IP.','.
' creator.'.\SYSTEM\DBD\system_user::FIELD_ID.' as creator_id,'.
' creator.'.\SYSTEM\DBD\system_user::FIELD_USERNAME.','.
' asignee.'.\SYSTEM\DBD\system_user::FIELD_USERNAME.' as asignee,'.
' asignee.'.\SYSTEM\DBD\system_user::FIELD_ID.' as asignee_id'.
' FROM '.\SYSTEM\DBD\system_todo::NAME_MYS.' as todo'.
' LEFT JOIN '.\SYSTEM\DBD\system_todo_asign::NAME_MYS.' as asign ON todo.'.\SYSTEM\DBD\system_todo::FIELD_ID.'=asign.'.\SYSTEM\DBD\system_todo_asign::FIELD_TODO.
' LEFT JOIN '.\SYSTEM\DBD\system_user::NAME_MYS.' as creator ON todo.'.\SYSTEM\DBD\system_todo::FIELD_USER.'=creator.'.\SYSTEM\DBD\system_user::FIELD_ID.
' LEFT JOIN '.\SYSTEM\DBD\system_user::NAME_MYS.' as asignee ON asign.'.\SYSTEM\DBD\system_todo_asign::FIELD_USER.'=asignee.'.\SYSTEM\DBD\system_user::FIELD_ID.
' WHERE todo.'.\SYSTEM\DBD\system_todo::FIELD_STATE.' = ?'.
' ORDER BY case when asign.'.\SYSTEM\DBD\system_todo_asign::FIELD_USER.' = ? then 1 else 2 end'.
' LIMIT 100'.
') as a'.
' GROUP BY a.todo_id'.
' ORDER BY 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

@ -1,17 +0,0 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_TODO_TODO_LIST extends \SYSTEM\DB\QQ {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'SELECT * FROM '.\SYSTEM\DBD\system_todo::NAME_PG.
' LEFT JOIN '.\SYSTEM\DBD\system_user::NAME_PG.' ON '.\SYSTEM\DBD\system_todo::NAME_PG.'."'.\SYSTEM\DBD\system_todo::FIELD_USER.'"='.\SYSTEM\DBD\system_user::NAME_PG.'."'.\SYSTEM\DBD\system_user::FIELD_ID.'"'.
' WHERE '.\SYSTEM\DBD\system_todo::FIELD_STATE.'='.\SYSTEM\DBD\system_todo::FIELD_STATE_OPEN.
' ORDER BY '.\SYSTEM\DBD\system_todo::FIELD_TYPE.' DESC, '.\SYSTEM\DBD\system_todo::FIELD_COUNT.' DESC, '.\SYSTEM\DBD\system_todo::FIELD_TIME.' DESC LIMIT 100;',
//mys
'SELECT * FROM '.\SYSTEM\DBD\system_todo::NAME_MYS.
' LEFT JOIN '.\SYSTEM\DBD\system_user::NAME_MYS.' ON '.\SYSTEM\DBD\system_todo::FIELD_USER.'='.\SYSTEM\DBD\system_user::NAME_MYS.'.'.\SYSTEM\DBD\system_user::FIELD_ID.
' WHERE '.\SYSTEM\DBD\system_todo::FIELD_STATE.'='.\SYSTEM\DBD\system_todo::FIELD_STATE_OPEN.
' ORDER BY '.\SYSTEM\DBD\system_todo::FIELD_TYPE.' DESC, '.\SYSTEM\DBD\system_todo::FIELD_COUNT.' DESC, '.\SYSTEM\DBD\system_todo::FIELD_TIME.' DESC LIMIT 100;'
);}}

View File

@ -39,10 +39,11 @@ class saimod_sys_todo extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_action_todolist(){
$result = $result_user = '';
$res = \SYSTEM\DBD\SYS_SAIMOD_TODO_TODO_LIST::QQ();
$userid = \SYSTEM\SECURITY\Security::getUser()->id;
$res = \SYSTEM\DBD\SYS_SAIMOD_TODO_LIST::QQ(array(\SYSTEM\DBD\system_todo::FIELD_STATE_OPEN,$userid));
$count = \SYSTEM\DBD\SYS_SAIMOD_TODO_TODO_COUNT::Q1()['count'];
while($row = $res->next()){
$row['class_row'] = self::trclass($row['type'],$row['class']);
$row['class_row'] = self::trclass($row['type'],$row['class'],$row['asignee_id'],$userid);
$row['time_elapsed'] = \SYSTEM\time::time_ago_string(strtotime($row['time']));
//$row['report_type'] = self::reporttype($row['type']);
$row['state_string'] = self::state($row['count']);
@ -129,9 +130,12 @@ class saimod_sys_todo extends \SYSTEM\SAI\SaiModule {
return '<input type="submit" class="btn-danger" value="reopen">';}
return '<input type="submit" class="btn-danger" value="close">';}
private static function trclass($type,$class){
private static function trclass($type,$class,$asignee,$userid){
if($type == \SYSTEM\DBD\system_todo::FIELD_TYPE_USER){
return 'success';}
if($asignee == $userid){ return 'danger';}
if($asignee){ return 'warning';}
return 'success';
}
switch($class){
case 'SYSTEM\LOG\INFO': case 'INFO': case 'SYSTEM\LOG\COUNTER':
return 'success';

View File

@ -5,7 +5,8 @@
<tr>
<th>${time_ago}</th>
<th>${table_message}</th>
<th>${table_user}</th>
<th>${table_author}</th>
<th>${table_asignee}</th>
</tr>
${todo_user_list_elements}
</table>

View File

@ -1,4 +1,4 @@
<tr class="sai_todo_element ${class_row}" onClick="system.load('todo(todo${openclose});todo.${ID}');">
<tr class="sai_todo_element ${class_row}" onClick="system.load('todo(todo${openclose});todo.${todo_id}');">
<td>${time_elapsed}</td>
<td>${class}</td>
<td style="word-break: break-all;">${message}</td>

View File

@ -1,5 +1,6 @@
<tr class="sai_todo_element ${class_row}" onClick="system.load('todo(todo${openclose});todo.${ID}');">
<tr class="sai_todo_element ${class_row}" onClick="system.load('todo(todo${openclose});todo.${todo_id}');">
<td>${time_elapsed}</td>
<td style="word-break: break-all;">${message}</td>
<td>${username}</td>
<td>${asignee}</td>
</tr>