...
|
...
|
@@ -9,6 +9,7 @@ |
|
|
namespace app\admin\controller;
|
|
|
|
|
|
|
|
|
use app\admin\model\Excel;
|
|
|
use cmf\controller\AdminBaseController;
|
|
|
use think\Validate;
|
|
|
use think\Db;
|
...
|
...
|
@@ -17,11 +18,12 @@ use think\Image; |
|
|
|
|
|
class VolunteerController extends AdminBaseController
|
|
|
{
|
|
|
public function index(){
|
|
|
$where=[];
|
|
|
public function index()
|
|
|
{
|
|
|
$where = [];
|
|
|
$param = $this->request->param();
|
|
|
$startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
|
|
|
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
|
|
|
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
|
|
|
if (!empty($startTime) && !empty($endTime)) {
|
|
|
$where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
} else {
|
...
|
...
|
@@ -44,15 +46,15 @@ class VolunteerController extends AdminBaseController |
|
|
if (!empty($keyword)) {
|
|
|
$where['name|province|city|county|email|move_phone|fixed_phone|card_number|school|postcode|nation|politics|sex|urgency_phone|qq'] = ['like', "%$keyword%"];
|
|
|
}
|
|
|
$data=Db::name('volunteer')
|
|
|
->where('delete_time',0)
|
|
|
$data = Db::name('volunteer')
|
|
|
->where('delete_time', 0)
|
|
|
->where($where)
|
|
|
->order('create_time desc')
|
|
|
->paginate(10);
|
|
|
$data->appends($param);
|
|
|
$this->assign([
|
|
|
'data'=>$data,
|
|
|
'page'=>$data->render(),
|
|
|
'data' => $data,
|
|
|
'page' => $data->render(),
|
|
|
]);
|
|
|
$this->assign('start_time', isset($param['start_time']) ? $param['start_time'] : '');
|
|
|
$this->assign('end_time', isset($param['end_time']) ? $param['end_time'] : '');
|
...
|
...
|
@@ -61,33 +63,37 @@ class VolunteerController extends AdminBaseController |
|
|
$this->assign('type', isset($param['type']) ? $param['type'] : '');
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
//编辑
|
|
|
public function edit(){
|
|
|
$id=$this->request->param('id', 0, 'intval');
|
|
|
if($this->request->isPost()){
|
|
|
$param=$this->request->param();
|
|
|
public function edit()
|
|
|
{
|
|
|
$id = $this->request->param('id', 0, 'intval');
|
|
|
if ($this->request->isPost()) {
|
|
|
$param = $this->request->param();
|
|
|
/*更新级别*/
|
|
|
$level_map['min']=['<=',$param['work_time']];
|
|
|
$level_map['max']=['>',$param['work_time']];
|
|
|
$level=db('level')->where($level_map)->value('level');
|
|
|
$param['level']=$level;
|
|
|
$level_map['min'] = ['<=', $param['work_time']];
|
|
|
$level_map['max'] = ['>', $param['work_time']];
|
|
|
$level = db('level')->where($level_map)->value('level');
|
|
|
$param['level'] = $level;
|
|
|
Db::name('volunteer')
|
|
|
->where('id',$id)
|
|
|
->where('id', $id)
|
|
|
->update($param);
|
|
|
|
|
|
$this->success('更新成功!');
|
|
|
}else{
|
|
|
$data=Db::name('volunteer')
|
|
|
->where('id',$id)
|
|
|
} else {
|
|
|
$data = Db::name('volunteer')
|
|
|
->where('id', $id)
|
|
|
->find();
|
|
|
$this->assign([
|
|
|
'data'=>$data,
|
|
|
'data' => $data,
|
|
|
]);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//删除
|
|
|
public function delete(){
|
|
|
public function delete()
|
|
|
{
|
|
|
$param = $this->request->param();
|
|
|
|
|
|
if (isset($param['id'])) {
|
...
|
...
|
@@ -95,9 +101,9 @@ class VolunteerController extends AdminBaseController |
|
|
$resultPortal = Db::name('volunteer')
|
|
|
->where(['id' => $id])
|
|
|
->delete();
|
|
|
if($resultPortal){
|
|
|
if ($resultPortal) {
|
|
|
$this->success("删除成功!", '');
|
|
|
}else{
|
|
|
} else {
|
|
|
$this->error("删除失败!", '');
|
|
|
}
|
|
|
|
...
|
...
|
@@ -110,29 +116,32 @@ class VolunteerController extends AdminBaseController |
|
|
->delete();
|
|
|
if ($result) {
|
|
|
$this->success("删除成功!", '');
|
|
|
}else{
|
|
|
} else {
|
|
|
$this->error("删除失败!", '');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//发布
|
|
|
public function publish(){
|
|
|
$param=$this->request->param();
|
|
|
public function publish()
|
|
|
{
|
|
|
$param = $this->request->param();
|
|
|
$ids = $this->request->param('ids/a');
|
|
|
if(!empty($ids)&&!empty($param['yes'])){
|
|
|
Db::name('volunteer')->where(['id'=>['in',$ids]])->update(array('status'=>2));
|
|
|
$this->success('操作成功!','');
|
|
|
}else{
|
|
|
Db::name('volunteer')->where(['id'=>['in',$ids]])->update(array('status'=>3));
|
|
|
$this->success('操作成功!','');
|
|
|
if (!empty($ids) && !empty($param['yes'])) {
|
|
|
Db::name('volunteer')->where(['id' => ['in', $ids]])->update(array('status' => 2));
|
|
|
$this->success('操作成功!', '');
|
|
|
} else {
|
|
|
Db::name('volunteer')->where(['id' => ['in', $ids]])->update(array('status' => 3));
|
|
|
$this->success('操作成功!', '');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public function daochu(){
|
|
|
$where=[];
|
|
|
public function excels()
|
|
|
{
|
|
|
$where = [];
|
|
|
$param = $this->request->param();
|
|
|
$startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
|
|
|
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
|
|
|
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
|
|
|
if (!empty($startTime) && !empty($endTime)) {
|
|
|
$where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
} else {
|
...
|
...
|
@@ -155,12 +164,53 @@ class VolunteerController extends AdminBaseController |
|
|
if (!empty($keyword)) {
|
|
|
$where['name|province|city|county|email|move_phone|fixed_phone|card_number|school|postcode|nation|politics|sex|urgency_phone|qq'] = ['like', "%$keyword%"];
|
|
|
}
|
|
|
$data=Db::name('volunteer')
|
|
|
->where('delete_time',0)
|
|
|
|
|
|
$data = Db::name('volunteer')
|
|
|
->where('delete_time', 0)
|
|
|
->where($where)
|
|
|
->order('create_time desc')
|
|
|
->select();
|
|
|
dump($data);
|
|
|
->order('create_time asc')
|
|
|
->select()->toArray();
|
|
|
|
|
|
foreach ($data as $k => $v) {
|
|
|
switch ($v['sex']) {
|
|
|
case 1:
|
|
|
$data[$k]['sex'] = '男';
|
|
|
break;
|
|
|
case 2:
|
|
|
$data[$k]['sex'] = '女';
|
|
|
break;
|
|
|
default:
|
|
|
$data[$k]['sex'] = '保密';
|
|
|
}
|
|
|
$data[$k]['card_number'] = '`' . $v['card_number'];
|
|
|
}
|
|
|
$title = [
|
|
|
['ID', 15, 'id', 1],
|
|
|
['姓名', 15, 'name', 1],
|
|
|
['性别', 15, 'sex', 1],
|
|
|
['生日', 15, 'birthday', 1],
|
|
|
['民族', 15, 'nation', 1],
|
|
|
['政治面貌', 15, 'politics', 1],
|
|
|
['学历', 15, 'education', 1],
|
|
|
['工作单位', 15, 'unit', 1],
|
|
|
['职务', 15, 'duty', 1],
|
|
|
['通讯地址', 15, 'addr', 1],
|
|
|
['邮编', 15, 'postcode', 1],
|
|
|
['毕业院校', 15, 'school', 1],
|
|
|
['身份证号', 25, 'card_number', 1],
|
|
|
['固定电话', 15, 'fixed_phone', 1],
|
|
|
['移动电话', 15, 'move_phone', 1],
|
|
|
['邮箱', 15, 'email', 1],
|
|
|
['紧急联系人电话', 15, 'urgency_phone', 1],
|
|
|
['qq号', 15, 'qq', 1],
|
|
|
['省', 15, 'province', 1],
|
|
|
['市', 15, 'city', 1],
|
|
|
['区县', 15, 'county', 1],
|
|
|
['详细地址', 15, 'address', 1],
|
|
|
];
|
|
|
|
|
|
$Excel = new Excel();
|
|
|
$letter = $Excel->excelAcross(count($title));
|
|
|
$Excel->excel($letter, $title, $data, '志愿者列表');
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|