<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends CommonController {
    public function index(){
		$number=session('card');
		$workers=D('hworker');
		$where['per_card']=array('in',$number);
		$result=$workers->where($where)->limit(3)->select();
		$this->assign('result',$result);
		$info=$workers->where($where)->find();
		$this->assign('info',$info);
		//var_dump($info);die;
        $this->display();
    }
	
	public function lst(){
		$workers=D('hworker');
		//$card=$per_card;
        $card=session('card');
		$where['per_card']=array('in',$card);
		//$result=$workers->where($where)->select();
        //$this->assign('result',$result);
		//$number=$result['per_card'];
		//var_dump($number);die;
		$count=$workers->where($where)->count(); // 查询满足要求的总记录数
	    $this->assign('count',$count);
		$Page=new  \Think\Page($count,3); // 实例化分页类 传入总记录数和每页显示的记录数(25)
		//$Page->setConfig('header','共%TOTAL_ROW%条');
	    //$Page->setConfig('first','首页');
	   // $Page->setConfig('last','尾页');
	    $Page->setConfig('prev','上一页');
	    $Page->setConfig('next','下一页');
		//$Page->setConfig('end','尾页');
		$show=$Page->show();  // 分页显示输出
		  // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$list=$workers->where($where)->order('per_card')->limit($Page->firstRow.','.$Page->listRows)->select();
		 // var_dump($list);die;
		$this->assign('list',$list);// 赋值数据集
		$this->assign('page',$show);//赋值分页输出
		$result=$workers->where($where)->find();
        $this->assign('result',$result);
		$this->display();
		}
	//工资查询列表页面getlist方法
	public function getlist($p,$card){
		 $perpage=3;
		 $offset=($p-1)*$perpage;
		 $sql="SELECT * FROM  pay_hworker WHERE per_card=$card LIMIT $offset,$perpage";
		 $workers=D('hworker');
		 $data=$workers->query($sql);
		 echo json_encode($data);
		}
		
		
		

}
