operation_log.class.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. }
  44. /*
  45. * operation_search search
  46. */
  47. private function _operation_search() {
  48. $cp = common::check_input($_POST ['cp']); //current_page
  49. $ps = common::check_input($_POST ['ps']); //ps
  50. if (empty($ps))
  51. $ps = 10;
  52. $sqlWhere = ' where 1=1';
  53. $user_name = common::check_input($_POST ['user_name']);
  54. $user_type = common::check_input($_POST ['user_type']);
  55. $page = common::check_input($_POST ['page']);
  56. $operation = common::check_input($_POST ['operation']);
  57. if (!empty($user_name)){
  58. $sqlWhere .= " and user_name ilike '%" . $user_name . "%'";
  59. }
  60. if (!empty($user_type)){
  61. $sqlWhere .= " and lower(user_type) = '".strtolower($user_type)."'";
  62. }
  63. if (!empty($page)){
  64. $sqlWhere .= " and lower(page) = '".strtolower($page)."'";
  65. }
  66. if (!empty($operation)){
  67. $sqlWhere .= " and lower(operation) = '".strtolower($operation)."'";
  68. }
  69. if (isset($_POST['operation_date_start']) && !empty($_POST['operation_date_start']))
  70. $sqlWhere .= " and operation_time >= '" . common::usDate2sqlDate($_POST['operation_date_start']) . " 00:00:00'";
  71. if (isset($_POST['operation_date_end']) && !empty($_POST['operation_date_end']))
  72. $sqlWhere .= " and operation_time <= '" . common::usDate2sqlDate($_POST['operation_date_end']) . " 23:59:59'";
  73. $rc = $_POST ['rc'];
  74. if ($rc == - 1) {
  75. $sql = "SELECT count(1) from public.customer_service_operation_log" . $sqlWhere;
  76. $rc = common::excuteOneSql($sql);
  77. }
  78. $tp = ceil($rc / $ps);
  79. $order_by = " id";
  80. if ($rc > 0) {
  81. $sql = "SELECT * from public.customer_service_operation_log " . $sqlWhere .
  82. " order by $order_by limit " . $ps . " offset " . ($cp - 1) * $ps;
  83. $rs = common::excuteListSql($sql);
  84. //处理operation_detail 可以放在保存的时候做(待定)
  85. foreach($rs as $key => $val){
  86. $json = $val['operation_detail'];
  87. if(!empty($json)){
  88. $_text = '';
  89. $data = json_decode($json,true);
  90. foreach ($data as $jk => $jv) {
  91. $_text .= $jk.":".$jv."; ";
  92. }
  93. $rs[$key]["operation_detail"] = $_text;
  94. }
  95. }
  96. $arrTmp = array('searchData' => $rs,
  97. 'rc' => $rc,
  98. 'ps' => $ps,
  99. 'cp' => $cp,
  100. 'tp' => $tp);
  101. } else {
  102. $arrTmp = array('searchData' => array());
  103. }
  104. common::echo_json_encode(200,$arrTmp);
  105. exit();
  106. }
  107. }
  108. ?>