|
|
|
@ -55,8 +55,45 @@ class CompanyRelationController extends AdminController
|
|
|
|
|
|
|
|
|
|
public function addRelation()
|
|
|
|
|
{
|
|
|
|
|
$this->assign('companyType',$this->CompanyType);
|
|
|
|
|
$this->display();
|
|
|
|
|
if ($_POST) {
|
|
|
|
|
$params = I('post.');
|
|
|
|
|
if ($params['first_company_type'] == $params['second_company_type']) {
|
|
|
|
|
$this->error('合作甲乙双方不能是同类型公司');
|
|
|
|
|
}
|
|
|
|
|
if ($params['first_company_type']!=0 && $params['second_company_type']!=0) {
|
|
|
|
|
$this->error('合作甲乙双方必须有个是己方公司');
|
|
|
|
|
}
|
|
|
|
|
$params['remark'] = $params['remark'] ?? '';
|
|
|
|
|
$params['status'] = 0;
|
|
|
|
|
$params['verify_log']=json_encode(["create_user"=>$this->admininfo["username"],"create_time"=>date("Y-m-d H:i:s")]);
|
|
|
|
|
//判断已有未审核
|
|
|
|
|
$where = "
|
|
|
|
|
(
|
|
|
|
|
(first_company_type ='{$params['first_company_type']}' and first_company_id = '{$params['first_company_id']}')
|
|
|
|
|
OR
|
|
|
|
|
(first_company_type ='{$params['second_company_type']}' and first_company_id = '{$params['second_company_id']}')
|
|
|
|
|
)
|
|
|
|
|
AND
|
|
|
|
|
(
|
|
|
|
|
(second_company_type ='{$params['first_company_type']}' and second_company_id = '{$params['first_company_id']}')
|
|
|
|
|
OR
|
|
|
|
|
(second_company_type ='{$params['second_company_type']}' and second_company_id = '{$params['second_company_id']}')
|
|
|
|
|
)
|
|
|
|
|
AND
|
|
|
|
|
status < 2
|
|
|
|
|
";
|
|
|
|
|
$hasdb = $this->DBlogModel->field("count(id) count")->where($where)->find()['count'];
|
|
|
|
|
if($hasdb > 0){
|
|
|
|
|
$this->error('当前甲乙双方已有审批单,请直接搜索后修改');
|
|
|
|
|
}
|
|
|
|
|
$id = $this->DBlogModel->add($params);
|
|
|
|
|
addOperationLog(['op_type'=>0,'key'=>$id,'op_name'=>'新增','url'=>U('lists')]);
|
|
|
|
|
$this->ajaxReturn(["msg"=>"添加成功","code"=>1,"url"=>U("lists")]);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$this->assign('companyType',$this->CompanyType);
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public function editRelation()
|
|
|
|
|
{
|
|
|
|
|