From 44a34bc89fc5746cb016481fa1e18af3f8190dce Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 13 Feb 2020 22:19:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A8=E5=B9=BF=E5=85=AC?= =?UTF-8?q?=E5=8F=B8=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PromoteCompanyController.class.php | 49 +++++++++++++++---- .../Admin/View/PromoteCompany/lists.html | 2 +- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index 50ceddccc..55b05428a 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -249,8 +249,19 @@ class PromoteCompanyController extends ThinkController if (empty($data)) { $this->error('数据异常', U('lists')); } - $data['contact_begin']=date("Y-m-d",$data['contact_begin']); - $data['contact_end']=date("Y-m-d",$data['contact_end']); + if($data['contact_begin'] >0){ + $data['contact_begin']=date("Y-m-d",$data['contact_begin']); + }else{ + $data['contact_begin']=''; + } + if($data['contact_end'] >0){ + $data['contact_end']=date("Y-m-d",$data['contact_end']); + }else{ + $data['contact_end']=''; + } + if($data['resources'] == ''){ + $data['resources'] ="[]"; + } $this->assign('data', $data); $this->display(); } @@ -293,8 +304,19 @@ class PromoteCompanyController extends ThinkController if (empty($data)) { $this->error('数据异常', U('lists')); } - $data['contact_begin']=date("Y-m-d",$data['contact_begin']); - $data['contact_end']=date("Y-m-d",$data['contact_end']); + if($data['contact_begin'] >0){ + $data['contact_begin']=date("Y-m-d",$data['contact_begin']); + }else{ + $data['contact_begin']=''; + } + if($data['contact_end'] >0){ + $data['contact_end']=date("Y-m-d",$data['contact_end']); + }else{ + $data['contact_end']=''; + } + if($data['resources'] == ''){ + $data['resources'] ="[]"; + } $this->assign('data', $data); $this->display(); @@ -304,20 +326,29 @@ class PromoteCompanyController extends ThinkController //删除 public function del() { - if (!empty($_POST['ids'])) { - if (!is_array($_POST['ids'])) { + $model = M($this->modelName, 'tab_'); + if (!empty($_POST['id'])) { + if (!is_array($_POST['id'])) { $this->error('参数异常'); } - $id = implode(',', $_POST['ids']); + $id = $_POST['id']; } else { $id = intval(I('get.id', 0)); if ($id == 0) { $this->error('参数异常'); } } - - $res = M($this->modelName, 'tab_')->delete($id); + //删除所有资源 + $data = $model->field('resources')->find($id)['resources']; + $data = json_encode($data,true); + if(is_array($data) && count($data) >0){ + foreach($data as $k=>$v){ + unlink("./".$v['file_path']); + } + } + $res = $model->delete($id); + //删除对应的推广员 if ($res === false) { $this->error('删除失败'); } diff --git a/Application/Admin/View/PromoteCompany/lists.html b/Application/Admin/View/PromoteCompany/lists.html index f23a8c409..34766efc3 100644 --- a/Application/Admin/View/PromoteCompany/lists.html +++ b/Application/Admin/View/PromoteCompany/lists.html @@ -115,7 +115,7 @@ 查看 编辑 - 删除 + 删除 {$data.company_name} {$data.platform_name}