新增推广公司删除

master
chenzhi 5 years ago
parent 4e28b39999
commit 44a34bc89f

@ -249,8 +249,19 @@ class PromoteCompanyController extends ThinkController
if (empty($data)) { if (empty($data)) {
$this->error('数据异常', U('lists')); $this->error('数据异常', U('lists'));
} }
if($data['contact_begin'] >0){
$data['contact_begin']=date("Y-m-d",$data['contact_begin']); $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']); $data['contact_end']=date("Y-m-d",$data['contact_end']);
}else{
$data['contact_end']='';
}
if($data['resources'] == ''){
$data['resources'] ="[]";
}
$this->assign('data', $data); $this->assign('data', $data);
$this->display(); $this->display();
} }
@ -293,8 +304,19 @@ class PromoteCompanyController extends ThinkController
if (empty($data)) { if (empty($data)) {
$this->error('数据异常', U('lists')); $this->error('数据异常', U('lists'));
} }
if($data['contact_begin'] >0){
$data['contact_begin']=date("Y-m-d",$data['contact_begin']); $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']); $data['contact_end']=date("Y-m-d",$data['contact_end']);
}else{
$data['contact_end']='';
}
if($data['resources'] == ''){
$data['resources'] ="[]";
}
$this->assign('data', $data); $this->assign('data', $data);
$this->display(); $this->display();
@ -304,20 +326,29 @@ class PromoteCompanyController extends ThinkController
//删除 //删除
public function del() public function del()
{ {
if (!empty($_POST['ids'])) { $model = M($this->modelName, 'tab_');
if (!is_array($_POST['ids'])) { if (!empty($_POST['id'])) {
if (!is_array($_POST['id'])) {
$this->error('参数异常'); $this->error('参数异常');
} }
$id = implode(',', $_POST['ids']); $id = $_POST['id'];
} else { } else {
$id = intval(I('get.id', 0)); $id = intval(I('get.id', 0));
if ($id == 0) { if ($id == 0) {
$this->error('参数异常'); $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) { if ($res === false) {
$this->error('删除失败'); $this->error('删除失败');
} }

@ -115,7 +115,7 @@
<td rowspan="{$data.row}"> <td rowspan="{$data.row}">
<a href="{:U('view',array('id'=>$data['id']))}">查看</a> <a href="{:U('view',array('id'=>$data['id']))}">查看</a>
<a href="{:U('edit',array('id'=>$data['id']))}">编辑</a> <a href="{:U('edit',array('id'=>$data['id']))}">编辑</a>
<a href="{:U('del',array('id'=>$data['id']))}" class="confirm ajax-get">删除</a> <a href="{:U('del',array('id'=>$data['id']))}" style="color: red;" class="confirm ajax-get">删除</a>
</td> </td>
<td rowspan="{$data.row}">{$data.company_name}</td> <td rowspan="{$data.row}">{$data.company_name}</td>
<td rowspan="{$data.row}">{$data.platform_name}</td> <td rowspan="{$data.row}">{$data.platform_name}</td>

Loading…
Cancel
Save