You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.9 KiB

7 years ago
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. class Main extends WB_Controller {
  4. public function index()
  5. {
  6. // 메타태그 설정
  7. $this->site->meta_title = "관리자 대시보드";
  8. // 최근 방문자수 구해오기
  9. $this->data['count_list']
  10. = $this->db
  11. ->where('std_date >=', date('Y-m-d', strtotime("-1 month")) . ' 00:00:00' )
  12. ->where('std_date <=', date('Y-m-d') . ' 23:59:59' )
  13. ->order_by('std_date ASC')
  14. ->get('statics_date')
  15. ->result_array();
  16. $this->data['month_count'] = array(
  17. "sumT" => 0,
  18. "sumM" => 0
  19. );
  20. $this->data['today_count'] = array(
  21. "sumT" => 0,
  22. "sumM" => 0
  23. );
  24. $this->data['month_data'] = array();
  25. $this->data['month_mobile'] = array();
  26. $this->data['month_label'] = array();
  27. foreach($this->data['count_list'] as $row)
  28. {
  29. if( $row['std_date'] == date('Y-m-d') )
  30. {
  31. $this->data['today_count']['sumT'] += $row['std_count'];
  32. $this->data['today_count']['sumM'] += $row['std_mobile'];
  33. }
  34. $this->data['month_count']['sumT'] += $row['std_count'];
  35. $this->data['month_count']['sumM'] += $row['std_mobile'];
  36. $this->data['month_data'][] = $row['std_count'] - $row['std_mobile'];
  37. $this->data['month_mobile'][] = $row['std_mobile'];
  38. $this->data['month_label'][] = $row['std_date'];
  39. }
  40. $this->data['month_data'] = json_encode($this->data['month_data'], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
  41. $this->data['month_mobile'] = json_encode($this->data['month_mobile'], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
  42. $this->data['month_label'] = json_encode($this->data['month_label'], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
  43. // 총 회원수 구해오기
  44. $member_list = $this->db->select('mem_status, COUNT(*) AS cnt')->where_in('mem_status', array('Y',"H",'D'))->group_by('mem_status')->get('member')->result_array();
  45. $this->data['total_member'] = 0;
  46. $this->data['total_member_h'] = 0;
  47. $this->data['total_member_d'] = 0;
  48. foreach($member_list as $row)
  49. {
  50. if ($row['mem_status'] == 'D') $this->data['total_member_d'] = $row['cnt'];
  51. else if ($row['mem_status'] == 'H') $this->data['total_member_h'] = $row['cnt'];
  52. if($row['mem_status'] != 'N') {
  53. $this->data['total_member'] += $row['cnt'];
  54. }
  55. }
  56. $this->data['total_count']
  57. = $this->db
  58. ->select('SUM(std_count) AS sumT, SUM(std_mobile) AS sumM')
  59. ->get('statics_date')
  60. ->row_array();
  61. // 레이아웃 & 뷰파일 설정
  62. $this->theme = "admin";
  63. $this->view = "main/index";
  64. }
  65. }