<?php
namespace app\agent\controller;

use app\agent\BaseController;
use app\common\model\Broker as BrokerModel;
use app\common\model\ComjobsReport as ComjobsReportModel;

class Comjobs extends BaseController
{
	
	public function report()
    {
        $agentid = $this->access_agent['id'];
        $brokerlist = BrokerModel::where('agentid', '=', $agentid)->order(['id'=>'desc'])->select();
        return view('comjobs/report',[
            'brokerlist'	=> $brokerlist
        ]);
    }

    public function listReport()
    {
        $agentid = $this->access_agent['id'];
        $map = [
            ['agentid','=',$agentid]
        ];
        $limit = input('limit', 20);
        $page = input('page', 1);
        $list = ComjobsReportModel::with(['comjobs','broker'])->where($map)->order('id','desc')->limit($limit)->page($page)->append(['status_text'])->select();
        $count = ComjobsReportModel::where($map)->count();
        if ($count==0){
            exit(json_encode(array(
                'code' 	=> 1,
                'msg'	=> "未查询到数据"
            )));
        }
        exit(json_encode(array(
            'code' 	=> 0,
            'msg'	=> "",
            'count' => $count,
            'data'  => $list
        )));
    }

    public function comjobsform()
    {

    }
}
