|
|
|
@ -305,6 +305,12 @@ class PromoteCompanyController extends ThinkController
|
|
|
|
|
$this->assign('data', $data);
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function marketingDirectorShow($ids=[], $isShow=0)
|
|
|
|
|
{
|
|
|
|
|
$upt = M('promote_company','tab_')->where(['id'=>['in', $ids]])->save(['marketing_director_show'=>$isShow]);
|
|
|
|
|
return $upt ? $this->success('更新成功'): $this->error('更新失败');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//编辑
|
|
|
|
@ -577,7 +583,7 @@ WHERE old_change_promote_id in ({$promoteData})";
|
|
|
|
|
}
|
|
|
|
|
$list = M('service_agreement', 'tab_')
|
|
|
|
|
->field("tab_service_agreement.*, group_concat(distinct(tab_promote_company.company_name)) as company_name")
|
|
|
|
|
->join('tab_promote_company on tab_promote_company.service_agreement_show = tab_service_agreement.id', 'LEFT')->where($map)->page($p, $row)->order("status desc")->select();
|
|
|
|
|
->join('tab_promote_company on tab_promote_company.service_agreement_show = tab_service_agreement.id', 'LEFT')->where($map)->group('tab_service_agreement.id asc')->page($p, $row)->order("status desc")->select();
|
|
|
|
|
$count = M('service_agreement', 'tab_')->where($map)->count();
|
|
|
|
|
$page = set_pagination($count, $row);
|
|
|
|
|
if ($page) {
|
|
|
|
@ -590,6 +596,20 @@ WHERE old_change_promote_id in ({$promoteData})";
|
|
|
|
|
public function serviceAgreementSave($id=0, $delete=0)
|
|
|
|
|
{
|
|
|
|
|
if (IS_POST) {
|
|
|
|
|
if (!empty(I('ids'))) {
|
|
|
|
|
$ids = is_array(I('ids')) ? I('ids') : [I('ids')];
|
|
|
|
|
if ($delete) {
|
|
|
|
|
// 获取默认合同id
|
|
|
|
|
$defaultService = M('service_agreement', 'tab_')->where(['status'=>2])->find();
|
|
|
|
|
if(in_array($defaultService['id'], $ids)) {
|
|
|
|
|
return $this->error('无法删除默认模板');
|
|
|
|
|
}
|
|
|
|
|
$useingService = M('promote_company', 'tab_')->where(['service_agreement_show'=>['in', $ids]])->find();
|
|
|
|
|
if (!empty($useingService)) return $this->error('有正在使用该服务合同的公司,无法删除');
|
|
|
|
|
$result = M('service_agreement', 'tab_')->where(['id'=>['in', $ids]])->delete();
|
|
|
|
|
return $result ? $this->success('删除完成') : $this->error('删除失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (empty($_POST['name']) || empty($_POST['content'])) {
|
|
|
|
|
return $this->error('请填写完整内容');
|
|
|
|
|
}
|
|
|
|
@ -604,13 +624,7 @@ WHERE old_change_promote_id in ({$promoteData})";
|
|
|
|
|
return $result ? $this->success('生成协议完成') : $this->error('生成协议失败');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ($id) {
|
|
|
|
|
if ($delete) {
|
|
|
|
|
$useingService = M('promote_company', 'tab_')->where(['service_agreement_show'=>$id])->find();
|
|
|
|
|
if (!empty($useingService)) return $this->error('有正在使用该服务协议的公司,无法删除');
|
|
|
|
|
$result = M('service_agreement', 'tab_')->where(['id'=>$id])->delete();
|
|
|
|
|
return $result ? $this->success('删除完成') : $this->error('删除失败');
|
|
|
|
|
}
|
|
|
|
|
if (!empty($id)) {
|
|
|
|
|
$info = M('service_agreement', 'tab_')->where(['id'=>$id])->find();
|
|
|
|
|
if (empty($info)) return $this->error('未找到协议');
|
|
|
|
|
$this->assign('info', $info);
|
|
|
|
|