From 54491390805ded4ca366f355f746c2ee84ae4cbf Mon Sep 17 00:00:00 2001 From: rylon Date: Tue, 30 Dec 2014 12:21:14 +0100 Subject: [PATCH] todo stats extendable --- sai/modules/saimod_sys_todo/autoload.inc | 7 ++- .../saimod_sys_todo/saimod_sys_todo.php | 52 +++++++++++-------- .../saimod_sys_todo/stats/todo_stats_gen.php | 10 ++++ .../saimod_sys_todo/stats/todo_stats_user.php | 10 ++++ sai/modules/saimod_sys_todo/todo_stats.php | 7 +++ .../saimod_sys_todo/todo_stats_data.php | 14 +++++ .../saimod_sys_todo/tpl/todo_stats.tpl | 39 +++----------- .../saimod_sys_todo/tpl/todo_stats_entry.tpl | 6 +++ 8 files changed, 88 insertions(+), 57 deletions(-) create mode 100644 sai/modules/saimod_sys_todo/stats/todo_stats_gen.php create mode 100644 sai/modules/saimod_sys_todo/stats/todo_stats_user.php create mode 100644 sai/modules/saimod_sys_todo/todo_stats.php create mode 100644 sai/modules/saimod_sys_todo/todo_stats_data.php create mode 100644 sai/modules/saimod_sys_todo/tpl/todo_stats_entry.tpl diff --git a/sai/modules/saimod_sys_todo/autoload.inc b/sai/modules/saimod_sys_todo/autoload.inc index a3861ae..033c876 100644 --- a/sai/modules/saimod_sys_todo/autoload.inc +++ b/sai/modules/saimod_sys_todo/autoload.inc @@ -1,5 +1,8 @@ perc;} + $result['project'] = round($result['project'] / (count($result['data'])),2); + return $result; } public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_action_stats(){ - return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_todo/tpl/todo_stats.tpl'), self::statistics());} + $vars = array(); + $stats = self::statistics(); + $vars['project'] = $stats['project']; + $vars['entries'] = ''; + foreach($stats['data'] as $stat){ + $vars['entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_todo/tpl/todo_stats_entry.tpl'), $stat); + } + return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_todo/tpl/todo_stats.tpl'), $vars);} private static function time_elapsed_string($ptime) { diff --git a/sai/modules/saimod_sys_todo/stats/todo_stats_gen.php b/sai/modules/saimod_sys_todo/stats/todo_stats_gen.php new file mode 100644 index 0000000..51e5111 --- /dev/null +++ b/sai/modules/saimod_sys_todo/stats/todo_stats_gen.php @@ -0,0 +1,10 @@ +name = $name; + $this->part = $part; + $this->whole = $whole; + $this->perc = round($this->part / $this->whole * 100,2); + } +} diff --git a/sai/modules/saimod_sys_todo/tpl/todo_stats.tpl b/sai/modules/saimod_sys_todo/tpl/todo_stats.tpl index f54c98d..082d1f1 100644 --- a/sai/modules/saimod_sys_todo/tpl/todo_stats.tpl +++ b/sai/modules/saimod_sys_todo/tpl/todo_stats.tpl @@ -1,42 +1,15 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + ${entries} - + +
ValueName Count%
ToDo_All${todo_count}${todo_perc}%
ToDo_Gen${todo_gen_count}${todo_gen_perc}%
ToDo_User${todo_user_count}${todo_user_perc}%
DoTo_All${doto_count}${doto_perc}%
DoTo_Gen${doto_gen_count}${doto_gen_perc}%
DoTo_User${doto_user_count}${doto_user_perc}%AllDone
Project ${project_perc}%${project}%
\ No newline at end of file diff --git a/sai/modules/saimod_sys_todo/tpl/todo_stats_entry.tpl b/sai/modules/saimod_sys_todo/tpl/todo_stats_entry.tpl new file mode 100644 index 0000000..aa258bc --- /dev/null +++ b/sai/modules/saimod_sys_todo/tpl/todo_stats_entry.tpl @@ -0,0 +1,6 @@ + + ${name} + ${part} + ${whole} + ${perc}% + \ No newline at end of file