<?php
namespace app\mainapp\controller;

use app\mainapp\BaseController;
use think\facade\Session;

use app\common\model\User as UserModel;
use app\common\model\UserPaystub as UserPaystubModel;

class Paystub extends BaseController
{
		
	// 获得用户信息
	public function listPaystub()
	{
		$ppage = input('ppage/d', 1);
		$psize = input('psize/d', 20);
		$idcard = input('idcard/s');
		$plist = UserPaystubModel::where('idcard', '=', $idcard)->order(['id'=>'desc'])->page($ppage)->limit($psize)->select();
		page_result(0, "", array(
			'plist' => $plist,
			'pstatus' => $psize > count($plist) ? 'noMore' : 'more'
			));
	}
	
	public function getPaystub()
	{
		$paystubid = input('paystubid/d', 0);
		$idcard = input('idcard/s');
		$paystub = UserPaystubModel::where('idcard', '=', $idcard)->where('id', '=', $paystubid)->findOrEmpty();
		if ($paystub->isEmpty()){
			page_result(1, "工资条信息不存在");
		}
		page_result(0, "", array(
			'paystub'			=> $paystub
			));
	}

}
	