likang 2 gadi atpakaļ
vecāks
revīzija
07966b375b
1 mainītis faili ar 11 papildinājumiem un 5 dzēšanām
  1. 11 5
      catch/tag_history/controller/TagHistory.php

+ 11 - 5
catch/tag_history/controller/TagHistory.php

@@ -435,6 +435,7 @@ class TagHistory extends CatchController
     {
         $lable = $request->get('lable');
         $mac = $request->get('mac');
+        $where=[];
         $limit = 10;
         $page = 1;
         if ($request->get('page')) {
@@ -443,11 +444,16 @@ class TagHistory extends CatchController
         if ($request->get('limit')) {
             $limit = $request->get('limit');
         }
-        $where = [
-            ['lable', '=', $lable],
-            ['mac', '=', $mac]
-        ];
-        $list = $this->tagHistoryModel->where($where)->order('addTime desc')->page($page)->limit($limit)->select();
+        $times=  $request->get("filter_time");
+        if(!empty($request->get("filter_time"))){
+            $where[]= ["time",">=",strtotime($times[0])];
+            $where[]= ["time","<=",strtotime($times[1])];
+        }
+      
+        $where[] =  ['lable', '=', $lable];
+        $where[]  = ['mac', '=', $mac];
+        
+        $list = $this->tagHistoryModel->where($where)->order('id desc')->page($page)->limit($limit)->select();
         foreach ($list as $key => $value) {
             $list[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
             $list[$key]['addTime'] = date('Y-m-d H:i:s', $value['addTime']);