鼠笼管理系统
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.

307 lines
11 KiB

7 months ago
<?php
class Admin_IndexController extends Ctrl_Admin{
public function indexAction(){
//权限判断跳转
/*$tMsg = '';
switch($_SESSION['admin']['roles']){
case 5:$tMsg = '/admin_purchases/';break;
case 8:$tMsg = '/admin_overseer/';break;
case 10:$tMsg = '/admin_wages/';break;
default:$tMsg = '/admin_senior/';break;
}*/
}
public function indexcountAction(){
//权限判断跳转
/*$tMsg = '';
switch($_SESSION['admin']['roles']){
case 5:$tMsg = '/admin_purchases/';break;
case 8:$tMsg = '/admin_overseer/';break;
case 10:$tMsg = '/admin_wages/';break;
default:$tMsg = '/admin_senior/';break;
}*/
}
public function deleteAction(){
$p = $_REQUEST;
$table = $p['tablename'];
$id = $p['id'];
$CMD = new CompanyModel;
$sql = "update `{$table}` set status=2 where id={$id}";
if(!$CMD->exec($sql)){
Tool_Fnc::ajaxMsg('操作失败');
}
Tool_Fnc::ajaxMsg('操作成功',1);
}
/*
* 公司简介
* TIME
*
*
* */
public function companyAction(){
}
public function companysaveAction(){
$p = $_REQUEST;
$img = empty($p['img'])?Tool_Fnc::ajaxMsg('请上传图片'):$p['img'];
$content = empty($p['content'])?Tool_Fnc::ajaxMsg('请填写公司介绍'):$p['content'];
$CMD = new CompanyModel;
if(!empty($id)){
$Data['id'] = $id;
}
$Data['img'] = $img;
$Data['content'] = $content;
$Data['created'] = date('Y-m-d h:i:s',time());
$Data['status'] = 1;
if(!$CMD->save($Data)){
Tool_Fnc::ajaxMsg('操作失败');
}
Tool_Fnc::ajaxMsg('操作成功',1);
}
public function companylistAction(){
$p = $_REQUEST;
$page = $p['page'];
$limit = $p['limit'];
$offset = ($page-1)*$limit;
$CMD = new CompanyModel;
$sql = "select * from company where status=1";
$count = $CMD->query($sql);
$sql = "select * from company where status=1 order by id desc limit {$offset},{$limit} ";
$data = $CMD->query($sql);
foreach ($data as $key => &$val){
$val['content'] = strip_tags($val['content']);
}
$return['code'] = 0;
$return['count'] = count($count);
$return['data'] = $data;
$return['msg'] = "成功";
echo json_encode($return);die;
}
/*
* 中心分部
* TIME
*
*
* */
public function childrencompanyAction(){
}
public function companychildrensaveAction(){
$p = $_REQUEST;
$img = empty($p['img'])?Tool_Fnc::ajaxMsg('请上传图片'):$p['img'];
$content = empty($p['content'])?Tool_Fnc::ajaxMsg('请填写公司介绍'):$p['content'];
$address = empty($p['address'])?Tool_Fnc::ajaxMsg('请填写公司介绍'):$p['address'];
$phone = empty($p['phone'])?Tool_Fnc::ajaxMsg('请填写公司介绍'):$p['phone'];
$title = empty($p['title'])?Tool_Fnc::ajaxMsg('请填写公司介绍'):$p['title'];
$CMD = new CompanychildrenModel;
if(!empty($id)){
$Data['id'] = $id;
}
$Data['logo'] = $img;
$Data['title'] = $title;
$Data['address'] = $address;
$Data['phone'] = $phone;
$Data['content'] = $content;
$Data['created'] = date('Y-m-d h:i:s',time());
$Data['status'] = 1;
if(!$CMD->save($Data)){
Tool_Fnc::ajaxMsg('操作失败');
}
Tool_Fnc::ajaxMsg('操作成功',1);
}
public function companychildrenlistAction(){
$p = $_REQUEST;
$page = $p['page'];
$limit = $p['limit'];
$offset = ($page-1)*$limit;
$CMD = new CompanychildrenModel;
$sql = "select * from company_children";
$count = $CMD->query($sql);
$sql = "select * from company_children order by id desc limit {$offset},{$limit} ";
$data = $CMD->query($sql);
foreach ($data as $key => &$val){
$val['content'] = strip_tags($val['content']);
}
$return['code'] = 0;
$return['count'] = count($count);
$return['data'] = $data;
$return['msg'] = "成功";
echo json_encode($return);die;
}
/*
* 证书查询
* TIME
*
*
* */
public function ceilAction(){
}
public function ceilsaveAction(){
$p = $_REQUEST;
$img = empty($p['img'])?Tool_Fnc::ajaxMsg('请上传图片'):$p['img'];
$content = empty($p['content'])?Tool_Fnc::ajaxMsg('请填写公司介绍'):$p['content'];
$url = empty($p['url'])?Tool_Fnc::ajaxMsg('请输入证书查询地址'):$p['url'];
$level = empty($p['level'])?Tool_Fnc::ajaxMsg('请输入证书等级'):$p['level'];
$title = empty($p['title'])?Tool_Fnc::ajaxMsg('请输入证书介绍'):$p['title'];
$CMD = new CeilModel;
if(!empty($id)){
$Data['id'] = $id;
}
$Data['img'] = $img;
$Data['url'] = $url;
$Data['title'] = $title;
$Data['level'] = $level;
$Data['content'] = $content;
$Data['created'] = date('Y-m-d h:i:s',time());
$Data['status'] = 1;
if(!$CMD->save($Data)){
Tool_Fnc::ajaxMsg('操作失败');
}
Tool_Fnc::ajaxMsg('操作成功',1);
}
public function ceillistAction(){
$p = $_REQUEST;
$page = $p['page'];
$limit = $p['limit'];
$offset = ($page-1)*$limit;
$CMD = new CeilModel;
$sql = "select * from ceil";
$count = $CMD->query($sql);
$sql = "select * from ceil where status=1 order by id desc limit {$offset},{$limit} ";
$data = $CMD->query($sql);
foreach ($data as $key => &$val){
$val['content'] = strip_tags($val['content']);
}
$return['code'] = 0;
$return['count'] = count($count);
$return['data'] = $data;
$return['msg'] = "成功";
echo json_encode($return);die;
}
/*
* 文件下载
* TIME
*
*
* */
public function filedownAction(){
$CMO = new ClasssModel;
$class = $CMO->query('select * from class where type=2 and status=1');
$this->assign('class',$class);
}
public function filedownlistAction(){
$p = $_REQUEST;
$page = $p['page'];
$limit = $p['limit'];
$offset = ($page-1)*$limit;
$CMD = new TeacherModel;
$sql = "select class.title classname,filedown.* from filedown left join class on filedown.class=class.id where filedown.status=1";
$count = $CMD->query($sql);
$sql = "select class.title classname,filedown.* from filedown left join class on filedown.class=class.id where filedown.status=1 order by filedown.id desc limit {$offset},{$limit} ";
$data = $CMD->query($sql);
foreach ($data as $key => &$val){
$val['content'] = strip_tags($val['content']);
}
$return['code'] = 0;
$return['count'] = count($count);
$return['data'] = $data;
$return['msg'] = "成功";
echo json_encode($return);die;
}
public function filedownsaveAction(){
$p = $_REQUEST;
$img = empty($p['img'])?Tool_Fnc::ajaxMsg('请上传图片'):$p['img'];
$content = empty($p['content'])?Tool_Fnc::ajaxMsg('请填写文件介绍'):$p['content'];
$class = empty($p['class'])?Tool_Fnc::ajaxMsg('请选择资料类别'):$p['class'];
$title = empty($p['title'])?Tool_Fnc::ajaxMsg('请填写资料标题'):$p['title'];
$CMD = new FiledownModel;
if(!empty($id)){
$Data['id'] = $id;
}
$Data['logo'] = $img;
$Data['title'] = $title;
$Data['content'] = $content;
$Data['class'] = $class;
$Data['created'] = date('Y-m-d h:i:s',time());
$Data['status'] = 1;
if(!$CMD->save($Data)){
Tool_Fnc::ajaxMsg('操作失败');
}
Tool_Fnc::ajaxMsg('操作成功',1);
}
public function serviceAction(){
$CMO = new ClasssModel;
$class = $CMO->query('select * from class where type=3 and status=1');
$this->assign('class',$class);
}
public function servicelistAction(){
$p = $_REQUEST;
$page = $p['page'];
$limit = $p['limit'];
$offset = ($page-1)*$limit;
$CMD = new TeacherModel;
$sql = "select class.title classname,service.* from service left join class on service.class=class.id where service.status=1";
$count = $CMD->query($sql);
$sql = "select class.title classname,service.* from service left join class on service.class=class.id where service.status=1 order by service.id desc limit {$offset},{$limit} ";
$data = $CMD->query($sql);
foreach ($data as $key => &$val){
$val['content'] = strip_tags($val['content']);
}
$return['code'] = 0;
$return['count'] = count($count);
$return['data'] = $data;
$return['msg'] = "成功";
echo json_encode($return);die;
}
public function servicesaveAction(){
$p = $_REQUEST;
$img = empty($p['img'])?Tool_Fnc::ajaxMsg('请上传图片'):$p['img'];
$content = empty($p['content'])?Tool_Fnc::ajaxMsg('请填写售后介绍'):$p['content'];
$class = empty($p['class'])?Tool_Fnc::ajaxMsg('请选择售后类别'):$p['class'];
$title = empty($p['title'])?Tool_Fnc::ajaxMsg('请填写售后标题'):$p['title'];
$CMD = new ServiceModel;
if(!empty($id)){
$Data['id'] = $id;
}
$Data['img'] = $img;
$Data['title'] = $title;
$Data['content'] = $content;
$Data['class'] = $class;
$Data['created'] = date('Y-m-d h:i:s',time());
$Data['status'] = 1;
if(!$CMD->save($Data)){
Tool_Fnc::ajaxMsg('操作失败');
}
Tool_Fnc::ajaxMsg('操作成功',1);
}
public function uploadAction(){
$file = $_FILES['file'];
$type = $_REQUEST['type'];
$tImgurl = 'uploads/img/'.date('Y-m').'/';
$tDir = APPLICATION_PATH . '/public/' . $tImgurl;
$tUpload = new Tool_Upload($file , $tDir);
$tSavename = $tUpload->getSaveName();
$tExt = $tUpload->extension;
$tFile = $tSavename . '.' . $tExt;
$tRes = $tUpload->upload($tSavename);
if($type==1){
$return['errno'] = 0;
if($tRes != 1){
$return['errno'] = 1;
$return['message'] = $tRes;
}else{
$return['data']['url'] = Yaf_Registry::get('config')->web->url->img.$tImgurl.$tFile;
$return['data']['alt'] = '';
$return['data']['href'] = '';
}
echo json_encode($return);die;
}
if ($tRes != 1) {
Tool_Fnc::ajaxMsg($tRes);
}else{
Tool_Fnc::ajaxMsg('上传成功',$tRes,$tImgurl.$tFile);
}
}
}