<?php
namespace app\web\controller;

use think\facade\Session;
use app\web\BaseController;
use app\common\model\Worker as WorkerModel;
use app\common\model\Comjobs as ComjobsModel;

class Worker extends BaseController
{
	

	public function detail()
	{
		$workerid = input('workerid/d', 0); 
		$worker = WorkerModel::where('status','in','4,5')->where('id','=',$workerid)->append(['wtype_text'])->findOrEmpty();
		$comjobslist = ComjobsModel::with(['worker','comjobsCate'])->where(['status'=>3,'workerid'=>$workerid])->where('createtime','<=',time())->order(['updatetime'=>'desc','createtime'=>'desc','id'=>'desc'])->limit(5)->select();
		return view('worker/detail', [
			
			'worker'		=> $worker,
			'comjobslist'	=> $comjobslist
		]);
	}
	
	
	public function worker()
	{
		$wtypelist = array(['value'=>0,'title'=>'不限'], ['value'=>1,'title'=>'普通企业'], ['value'=>2,'title'=>'派遣企业'] );
		$page = input('page/d',1);
		$map = array();
		$map[] = ['status','in','4,5'];
		$keywords = input('keywords/s', "");
		if (!empty($keywords)){
			$map[] =['title', 'like', '%'.$keywords.'%'];
		}
		$wtype = input('wtype/d', 0);
		if (!empty($wtype)){
			$map[] = ['wtype', '=', $wtype];
		}
		$list = WorkerModel::where($map)->order(['priority'=>'desc','id'=>'desc',])->append(['wtype_text'])->page($page)->paginate(['list_rows'=>10,'query' => request()->param()]);
		$pageview = $list->render();
		return view('worker/worker', [
			'wtypelist'		=> $wtypelist,
			'keywords'	=> $keywords,
			'wtype'		=> $wtype,
			'list'		=> $list,
			'pageview'	=> $pageview
		]);
	}	
	
}