78 lines
2.7 KiB
PHP
78 lines
2.7 KiB
PHP
<?php
|
|
namespace Admin\Controller;
|
|
use Think\Controller;
|
|
class FeedbackController extends AdminController{
|
|
public function __construct(){
|
|
parent::__construct();
|
|
$this->table=D("Feedback");
|
|
$this->cat=M("feedback_cat")->where("status=1")->order("sort asc")->select();
|
|
}
|
|
//
|
|
public function index(){
|
|
$catid=I("get.catid",0,"intval");
|
|
if($catid){
|
|
$where["catid"]=$catid;
|
|
}
|
|
//查询与分页
|
|
$listRows=C("display.admin_shownum");//每页显示多少条
|
|
$total=$this->table->where($where)->having($having)->count();
|
|
$page = new \Think\Page($total, $listRows);
|
|
$data=$this->table->relation(true)->where($where)->order('addtime desc')->limit($page->firstRow,$page->listRows)->select();
|
|
$this->assign("listpage", $page->show());
|
|
$this->assign('data', $data);
|
|
$this->display($type);
|
|
}
|
|
//信息展示
|
|
public function show(){
|
|
$this->pagetitle="详情";
|
|
$id=I("get.id",0,"intval");
|
|
$this->r=$this->table->relation(true)->find($id);
|
|
if(!$this->r){
|
|
$this->error("信息不存在");
|
|
}
|
|
//设置为已读
|
|
$seetdata["id"]=$id;
|
|
$seetdata["is_read"]=1;
|
|
$this->table->save($seetdata);
|
|
//
|
|
$formtemp=$this->r["feedback_cat"]["formtemp"];
|
|
$formtemp=explode("\r\n",$formtemp);
|
|
foreach($formtemp as $key=>$v){
|
|
$val=explode("<!--field-->",$v);
|
|
//判断是否为录入字段
|
|
if(!strstr($this->r["feedback_cat"]["is_enter"],",".$val[1].",")){
|
|
continue;
|
|
}
|
|
$newdata[$key]["name"]=$val[0];
|
|
$newdata[$key]["field"]=$val[1];
|
|
$newdata[$key]["value"]=$this->r[$val[1]];
|
|
//判断字段类型,如果是复选框和日期类型的要做置换
|
|
$formtype=M("feedback_field")->where(array("field"=>$val[1]))->getField("formtype");
|
|
if($formtype=="date"){
|
|
$newdata[$key]["value"]=$newdata[$key]["value"]?date("Y-m-d H:i:s",$newdata[$key]["value"]):"";
|
|
}
|
|
//
|
|
}
|
|
$this->newdata=$newdata;
|
|
$this->display($type);
|
|
}
|
|
//
|
|
public function delete(){
|
|
$ids=I("ids");
|
|
|
|
if(!$ids){
|
|
$this->error= '请选择信息!';
|
|
return false;
|
|
}
|
|
if(is_array($ids)){
|
|
foreach($ids as $id){
|
|
$this->table->delete($id);
|
|
}
|
|
}else{
|
|
$this->table->delete($ids);
|
|
}
|
|
D("UserLog")->add("delete",$this->table->getTableName(),$ids);
|
|
$this->success("删除成功");
|
|
}
|
|
}
|