88 lines
2.9 KiB
PHP
88 lines
2.9 KiB
PHP
<?php
|
|
namespace Admin\Controller;
|
|
use Think\Controller;
|
|
class FeedbackCatController extends AdminController{
|
|
public function __construct(){
|
|
parent::__construct();
|
|
$this->table=D("FeedbackCat");
|
|
$this->memberGroup=M("member_group")->select();
|
|
//展示该数据表下所有的字段
|
|
$this->table_field=M("feedback_field")->order("sort asc,field_id asc")->select();
|
|
}
|
|
//
|
|
public function index(){
|
|
$data=$this->table->order("sort asc,catid asc")->select();
|
|
$this->assign('data', $data);
|
|
$this->display($type);
|
|
}
|
|
//
|
|
public function add(){
|
|
if(IS_POST){
|
|
if (!$this->table->create()){//验证
|
|
$this->error($this->table->getError());
|
|
}
|
|
$result=$this->table->data_save();
|
|
if($_POST[catid]){
|
|
D("UserLog")->add("update",$this->table->getTableName(),$result[catid]);
|
|
}else{
|
|
D("UserLog")->add("add",$this->table->getTableName(),$result[catid]);
|
|
}
|
|
|
|
$this->success($catid);
|
|
}else{
|
|
$this->display();
|
|
}
|
|
}
|
|
public function editor(){
|
|
$catid=I("get.catid",0,"int");
|
|
$r=$this->table->find($catid);
|
|
//将formtemp中的字段名称更新到字段列表中
|
|
$field_name_arr=array();
|
|
$field_arr=array();
|
|
$formtype_arr=explode("\r\n",$r["formtemp"]);
|
|
foreach($formtype_arr as $v){
|
|
$f=explode("<!--field-->",$v);
|
|
$field_arr[]=$f[1];
|
|
$field_name_arr[$f[1]]=$f[0];
|
|
}
|
|
$new_table_field=array();
|
|
$table_field=$this->table_field;
|
|
foreach($table_field as $v){
|
|
//更新字段名
|
|
if(in_array($v["field"], $field_arr)){
|
|
$v["name"]=$field_name_arr[$v["field"]];
|
|
}
|
|
//判断该字段分别在每个勾选项里是否有勾选
|
|
$v["is_enter_checked"]=strstr($r[is_enter],",".$v["field"].",")?1:0;
|
|
$v["must_enter_checked"]=strstr($r[must_enter],",".$v["field"].",")?1:0;
|
|
//
|
|
$new_table_field[]=$v;
|
|
}
|
|
$this->table_field=$new_table_field;
|
|
//
|
|
$this->assign("r",$r);
|
|
$this->display();
|
|
}
|
|
//
|
|
public function delete(){
|
|
$catid=I("catid",0,'intval');
|
|
$result=$this->table->data_delete($catid);
|
|
if(!$result){
|
|
$this->error($this->table->getError());
|
|
}
|
|
D("UserLog")->add("delete",$this->table->getTableName(),$catid);
|
|
$this->success("删除成功");
|
|
}
|
|
//字段排序
|
|
public function sort(){
|
|
$ids=I("ids");
|
|
$sort=I("sort");
|
|
foreach($ids as $key=>$id){
|
|
$data['catid']=(int)$id;
|
|
$data['sort']=(int)$sort[$key];
|
|
$this->table->save($data);
|
|
}
|
|
$this->success("排序更改成功");
|
|
}
|
|
}
|