operation_log.class.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. if (!defined('IN_ONLINE')) {
  3. exit('Access Denied');
  4. }
  5. /**
  6. * Description of operation_log
  7. *
  8. * @author Administrator
  9. */
  10. class operation_log{
  11. private static $_operation_log;
  12. function __construct() {
  13. }
  14. public static function getInstance() {
  15. global $memory_limit;
  16. $memory_limit = ini_get("memory_limit");
  17. ini_set("memory_limit", '2048M');
  18. if (!self::$_operation_log) {
  19. $c = __CLASS__;
  20. self::$_operation_log = new $c;
  21. }
  22. return self::$_operation_log;
  23. }
  24. public function operation_log() {
  25. $operate = utils::_get('operate');
  26. $operate = strtolower($operate);
  27. /*
  28. * index page
  29. */
  30. if (empty($operate)) {
  31. $column = column::getInstance()->getDisplayColumn('Operation_Search');
  32. $OperationTableColumns = column::getInstance()->tableColumns('Operation_Search',$column);
  33. $data['OperationTableColumns'] = $OperationTableColumns;
  34. common::echo_json_encode(200,$data);
  35. exit();
  36. }
  37. /*
  38. * operation_search search
  39. */
  40. if ($operate == "search") {
  41. $this->_operation_search();
  42. }
  43. if ($operate == "excel") {
  44. $sql = common::deCode($_POST ['tmp_search'], 'D');
  45. $sql = substr($sql, 0, strripos($sql, " limit"));
  46. if(!empty($sql)){
  47. $rss = common::excuteListSql($sql);
  48. }
  49. foreach($rss as $key =>$val){
  50. $rss[$key]['Operation Time'] = $rss[$key]['_operation_time'];
  51. }
  52. common::echo_json_encode(200,array("msg"=>"success","Data" => $rss));
  53. exit;
  54. }
  55. }
  56. /*
  57. * operation_search search
  58. */
  59. private function _operation_search() {
  60. $cp = common::check_input($_POST ['cp']); //current_page
  61. $ps = common::check_input($_POST ['ps']); //ps
  62. if (empty($ps))
  63. $ps = 10;
  64. $sqlWhere = ' where 1=1';
  65. $user_name = common::check_input($_POST ['user_name']);
  66. $user_type = common::check_input($_POST ['user_type']);
  67. $page = common::check_input($_POST ['page']);
  68. $operation = common::check_input($_POST ['operation']);
  69. if (!empty($user_name)){
  70. $sqlWhere .= " and user_name ilike '%" . $user_name . "%'";
  71. }
  72. if (!empty($user_type)){
  73. $sqlWhere .= " and lower(user_type) = '".strtolower($user_type)."'";
  74. }
  75. if (!empty($page)){
  76. $sqlWhere .= " and lower(page) = '".strtolower($page)."'";
  77. }
  78. if (!empty($operation)){
  79. $sqlWhere .= " and lower(operation) = '".strtolower($operation)."'";
  80. }
  81. if (isset($_POST['operation_date_start']) && !empty($_POST['operation_date_start']))
  82. $sqlWhere .= " and operation_time >= '" . common::usDate2sqlDate($_POST['operation_date_start']) . " 00:00:00'";
  83. if (isset($_POST['operation_date_end']) && !empty($_POST['operation_date_end']))
  84. $sqlWhere .= " and operation_time <= '" . common::usDate2sqlDate($_POST['operation_date_end']) . " 23:59:59'";
  85. // $allLogColumns = array();
  86. // $allLogColumns[] = array("title" =>"User Type","field" =>"user_type","formatter" =>"normal","type" =>"normal");
  87. // $allLogColumns[] = array("title" =>"User Name","field" =>"user_name","formatter" =>"normal","type" =>"normal");
  88. // $allLogColumns[] = array("title" =>"Page","field" =>"page","formatter" =>"normal","type" =>"normal");
  89. // $allLogColumns[] = array("title" =>"Operation","field" =>"operation","formatter" =>"normal","type" =>"normal");
  90. // $allLogColumns[] = array("title" =>"Operation Details","field" =>"operation_detail","formatter" =>"normal","type" =>"normal");
  91. // $allLogColumns[] = array("title" =>"Operation Time","field" =>"operation_time","formatter" =>"normal","type" =>"normal");
  92. $rc = $_POST ['rc'];
  93. if ($rc == - 1) {
  94. $sql = "SELECT count(1) from public.customer_service_operation_log" . $sqlWhere;
  95. error_log($sql);
  96. $rc = common::excuteOneSql($sql);
  97. }
  98. $tp = ceil($rc / $ps);
  99. $order_by = " id desc";
  100. if ($rc > 0) {
  101. $sql = "SELECT ".column::getInstance()->getSearchSqlForDisplay('Operation_Search').", to_char(operation_time, 'YYYY/MM/DD HH24:MI:SS') as _operation_time from public.customer_service_operation_log " . $sqlWhere .
  102. " order by $order_by limit " . $ps . " offset " . ($cp - 1) * $ps;
  103. $rs = common::excuteListSql($sql);
  104. //处理operation_detail 可以放在保存的时候做(待定)
  105. foreach($rs as $key => $val){
  106. $json = $val['operation_detail'];
  107. if(!empty($json)){
  108. $_text = '';
  109. $data = json_decode($json,true);
  110. foreach ($data as $jk => $jv) {
  111. $_text .= $jk.":".$jv."; ";
  112. }
  113. $rs[$key]["operation_detail"] = $_text;
  114. }
  115. }
  116. $arrTmp = array('searchData' => $rs,
  117. 'tmp_search' => common::deCode($sql, 'E'),
  118. 'rc' => $rc,
  119. 'ps' => $ps,
  120. 'cp' => $cp,
  121. 'tp' => $tp);
  122. } else {
  123. $arrTmp = array('searchData' => array(),
  124. 'tmp_search' => common::deCode($sql, 'E'),
  125. 'rc' => $rc,
  126. 'ps' => $ps,
  127. 'cp' => $cp,
  128. 'tp' => $tp);
  129. }
  130. common::echo_json_encode(200,$arrTmp);
  131. exit();
  132. }
  133. }
  134. ?>