硕顺crm后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

99 lines
2.6 KiB

<?php
namespace app\admin\controller\qingdong\general;
use app\common\controller\Backend;
use addons\qingdong\model\Field;
use think\Db;
use think\Exception;
/**
* 通知模板
*/
class NoticeTemplate extends Backend {
protected $relationSearch = true;
/**
* @var \addons\qingdong\model\NoticeTemplate
*/
protected $model = null;
public function _initialize() {
parent::_initialize();
$this->model =new \addons\qingdong\model\NoticeTemplate;
}
/**
* 查看
*/
public function index() {
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
$list = $this->model->where([])->paginate();
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
/**
* 修改通知模板
*/
public function edit($id = null) {
if ($this->request->isPost()) {
$data = input('row/a');
if (empty($id) || empty($data)) {
$this->error('参数错误');
}
Db::startTrans();
try {
$this->model->save(['data' => json_encode($data,JSON_UNESCAPED_UNICODE)], ['id' => $id]);
Db::commit();
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
$this->success('设置成功');
}
$row=$this->model->get($id);
if(empty($row)){
$this->error('数据不存在');
}
$this->view->assign('variable',$this->model->getVariable($row['type']));
$this->view->assign('row',$row);
return $this->view->fetch();
}
/**
* 修改通知模板
*/
public function edit_enterprise($id = null) {
if ($this->request->isPost()) {
$data = input('row/a');
if (empty($id) || empty($data)) {
$this->error('参数错误');
}
Db::startTrans();
try {
$this->model->save(['enterprise_data' => json_encode($data,JSON_UNESCAPED_UNICODE)], ['id' => $id]);
Db::commit();
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
$this->success('设置成功');
}
$row=$this->model->get($id);
if(empty($row)){
$this->error('数据不存在');
}
$this->view->assign('variable',$this->model->getVariable($row['type']));
$this->view->assign('row',$row);
return $this->view->fetch();
}
}