...
|
...
|
@@ -91,6 +91,15 @@ class AdminCommonController extends AdminBaseController |
|
|
return $p_ids;
|
|
|
}
|
|
|
|
|
|
//查询项目
|
|
|
public function getProjectName1($project_id){
|
|
|
$res = Db::name('project')
|
|
|
->where('id',$project_id)
|
|
|
->field('id,name project_name,is_inspect')
|
|
|
->find();
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
//获取项目id
|
|
|
public function getProjectId($id){
|
|
|
$res = Db::name('user')
|
...
|
...
|
@@ -442,7 +451,7 @@ class AdminCommonController extends AdminBaseController |
|
|
$arr['b_company']['company_name'] = !empty($b_company['company_name'])?$b_company['company_name']:'';
|
|
|
$arr['b_company']['logo'] = !empty($b_company['logo'])?$host.$b_company['logo']:'';
|
|
|
//报表标题
|
|
|
$arr['title'] = $project['name'].$report_name.'报表';
|
|
|
$arr['title'] = $report_name.'报表';
|
|
|
}
|
|
|
return $arr;
|
|
|
}
|
...
|
...
|
@@ -735,9 +744,9 @@ class AdminCommonController extends AdminBaseController |
|
|
$arr = [];
|
|
|
//甲乙方logo,名称,报表名称
|
|
|
if($table == 'check'){
|
|
|
$company = $this->getCompanyName($res['project_id'],'月检');
|
|
|
$company = $this->getCompanyName($res['project_id'],$res['title'].'月检');
|
|
|
}else{
|
|
|
$company = $this->getCompanyName($res['project_id'],'年检');
|
|
|
$company = $this->getCompanyName($res['project_id'],$res['title'].'年检');
|
|
|
}
|
|
|
if($company){
|
|
|
$arr['a_company'] = $company['a_company'];
|
...
|
...
|
@@ -747,6 +756,9 @@ class AdminCommonController extends AdminBaseController |
|
|
|
|
|
//月检时间
|
|
|
if($table == 'check'){
|
|
|
|
|
|
$arr['title'] = $res['project_name'] . '月检' . date('Y-m-d', $res['ins_m_time']).'报表';
|
|
|
|
|
|
//月检时间
|
|
|
$arr['ins_m_time'] = date('Y/m/d',$res['ins_m_time']);
|
|
|
//月检点
|
...
|
...
|
@@ -939,9 +951,9 @@ class AdminCommonController extends AdminBaseController |
|
|
$arr = [];
|
|
|
//甲乙方logo,名称,报表名称
|
|
|
if($table == 'train'){
|
|
|
$company = $this->getCompanyName($res['project_id'],'培训');
|
|
|
$company = $this->getCompanyName($res['project_id'],$res['title'].'培训');
|
|
|
}else{
|
|
|
$company = $this->getCompanyName($res['project_id'],'演习');
|
|
|
$company = $this->getCompanyName($res['project_id'],$res['title'].'演习');
|
|
|
}
|
|
|
if($company){
|
|
|
$arr['a_company'] = $company['a_company'];
|
...
|
...
|
@@ -1061,15 +1073,15 @@ class AdminCommonController extends AdminBaseController |
|
|
//甲乙方logo,名称,报表名称
|
|
|
if($table == 'repair'){
|
|
|
if($party == 0){
|
|
|
$company = $this->getCompanyName($res['project_id'],'(甲方)报修');
|
|
|
$company = $this->getCompanyName($res['project_id'],$res['title'].'(甲方)报修');
|
|
|
}else{
|
|
|
$company = $this->getCompanyName($res['project_id'],'(乙方)报修');
|
|
|
$company = $this->getCompanyName($res['project_id'],$res['title'].'(乙方)报修');
|
|
|
}
|
|
|
}else{
|
|
|
if($party == 0){
|
|
|
$company = $this->getCompanyName($res['project_id'],'(甲方)改造');
|
|
|
$company = $this->getCompanyName($res['project_id'],$res['title'].'(甲方)改造');
|
|
|
}else{
|
|
|
$company = $this->getCompanyName($res['project_id'],'(乙方)改造');
|
|
|
$company = $this->getCompanyName($res['project_id'],$res['title'].'(乙方)改造');
|
|
|
}
|
|
|
}
|
|
|
if($company){
|
...
|
...
|
@@ -1414,4 +1426,151 @@ class AdminCommonController extends AdminBaseController |
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
//独立年检获取乙方公司id
|
|
|
public function getCompanyB(){
|
|
|
$admin_id = cmf_get_current_admin_id();
|
|
|
if($admin_id == 1){
|
|
|
$company_id_b = '';
|
|
|
}else{
|
|
|
//获取乙方公司id
|
|
|
$company_id_b = $this->getProjectId($admin_id);
|
|
|
}
|
|
|
return $company_id_b;
|
|
|
}
|
|
|
|
|
|
//根据乙方公司查询乙方员工
|
|
|
public function getStaffB($company_id){
|
|
|
$company = Db::name('company')
|
|
|
->where('id',$company_id)
|
|
|
->where('pid',0)
|
|
|
->field('id,u_s_id')
|
|
|
->find();
|
|
|
$u_s_id_s = [];
|
|
|
if($company){
|
|
|
$u_s_id_s = explode(',',trim($company['u_s_id'],','));
|
|
|
}
|
|
|
return $u_s_id_s;
|
|
|
}
|
|
|
|
|
|
//独立年检巡检点
|
|
|
public function getTestPoint($where){
|
|
|
//查询项目的月检点
|
|
|
$res_test = Db::name('spot')
|
|
|
->where($where)
|
|
|
->field('id,spot_name')
|
|
|
->select()
|
|
|
->toArray();
|
|
|
if($res_test){
|
|
|
$testIns = $this->getInsTest($where,'status,spot_id,images,uid');
|
|
|
foreach ($res_test as &$value){
|
|
|
$value['status'] = 2;
|
|
|
foreach ($testIns as $ins_value){
|
|
|
if($value['id'] == $ins_value['spot_id']){
|
|
|
$value['status'] = $ins_value['status'];
|
|
|
$user = $this->getUserById(['id'=>$ins_value['uid']]);
|
|
|
if($user){
|
|
|
$value['user_login'] = $user['user_login'];
|
|
|
}else{
|
|
|
$value['user_login'] = '';
|
|
|
}
|
|
|
$images = $this->absolutionUrl($ins_value['images']);
|
|
|
$images = $this->getDayImages($images);
|
|
|
if($images){
|
|
|
$value['images'] = $images;
|
|
|
}else{
|
|
|
$value['images'] = [];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(!isset($value['user_login'])){
|
|
|
$value['user_login'] = '';
|
|
|
}
|
|
|
if(!isset($value['images'])){
|
|
|
$value['images'] = [];
|
|
|
}
|
|
|
}
|
|
|
$result = $res_test;
|
|
|
}else{
|
|
|
$result = [];
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
//获取独立年检的巡检信息
|
|
|
public function getInsTest($where,$field){
|
|
|
$res = Db::name('years')
|
|
|
->where($where)
|
|
|
->field($field)
|
|
|
->select()
|
|
|
->toArray();
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
//查看独立年检数据是否有
|
|
|
public function exportTestList($param,$field){
|
|
|
$res = Db::name('test')
|
|
|
->alias('t')
|
|
|
->join('user u','t.uid = u.id','LEFT')
|
|
|
->where(function (Query $query) use ($param){
|
|
|
$common = new AdminCommonController();
|
|
|
//获取乙方公司id
|
|
|
$company_id_b = $common->getCompanyB();
|
|
|
if(!empty($company_id_b)){
|
|
|
$u_s_id_s = $common->getStaffB($company_id_b);
|
|
|
$query->whereIn('uid',$u_s_id_s);
|
|
|
}
|
|
|
//查询登录乙方账号的所有项目
|
|
|
$startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
|
|
|
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
|
|
|
if (!empty($startTime)) {
|
|
|
$query->where('t.test_time', '>=', $startTime);
|
|
|
}
|
|
|
if (!empty($endTime)) {
|
|
|
$query->where('t.test_time', '<=', $endTime);
|
|
|
}
|
|
|
|
|
|
})
|
|
|
->field($field)
|
|
|
->select()->toArray();
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
//独立年检详情
|
|
|
public function testExportData($res){
|
|
|
$arr = [];
|
|
|
//查找乙方发起人所在乙方公司
|
|
|
$uid = ','.$res['uid'].',';
|
|
|
$host = new InspectModel();
|
|
|
$host = $host::host.'/';
|
|
|
$b_company = $this->getCompany(['u_s_id'=>['like','%'.$uid.'%']],'id,company_name,logo');
|
|
|
$arr['b_company']['company_name'] = !empty($b_company['company_name'])?$b_company['company_name']:'';
|
|
|
$arr['b_company']['logo'] = !empty($b_company['logo'])?$host.$b_company['logo']:'';
|
|
|
//报表标题
|
|
|
$arr['title'] = $res['title'].'独立年检报表';
|
|
|
|
|
|
//独立年检时间
|
|
|
$arr['test_time'] = date('Y/m/d',$res['test_time']);
|
|
|
$arr['time'] = date('Y-m-d',$res['test_time']).'('.$res['id'].')';
|
|
|
|
|
|
//独立年检点
|
|
|
$arr['test_point'] = $this->getTestPoint(['test_id'=>$res['id']]);
|
|
|
|
|
|
//地点
|
|
|
$arr['address'] = $res['address'];
|
|
|
//单号
|
|
|
$arr['number'] = $res['number'];
|
|
|
//备注
|
|
|
$arr['remark'] = $res['remark'];
|
|
|
|
|
|
//独立年检(乙方发起人)
|
|
|
$user = $this->getUserById(['id'=>$res['uid']]);
|
|
|
if($user){
|
|
|
$arr['user_login'] = $user['user_login'];
|
|
|
}else{
|
|
|
$arr['user_login'] = '';
|
|
|
}
|
|
|
|
|
|
return $arr;
|
|
|
}
|
|
|
} |
...
|
...
|
|