Ejemplo n.º 1
0
 public function userAction()
 {
     if ($this->request->isPost()) {
         $this->view->disable();
         $post = json_decode(file_get_contents("php://input"), true);
         $where = '1=1';
         empty($post['username']) || ($where .= " and name like '%" . htmlspecialchars(trim($post['username'])) . "%'");
         empty($post['depart']) || ($where .= " and depart=" . intval($post['depart']));
         $limit = array('number' => $this->config->pageNum, 'offset' => (intval($post['p']) - 1) * $this->config->pageNum);
         $arr = array($where, 'limit' => $limit, 'order' => 'id desc');
         $user = Admin::find($arr);
         $total = Admin::count($where);
         $info = array('total' => ceil($total / $this->config->pageNum), 'info' => $user->toArray());
         echo json_encode($info);
     }
     $this->view->departs = Depart::find()->toArray();
 }