作者 杨育虎

online push

正在显示 37 个修改的文件 包含 1424 行增加177 行删除
... ... @@ -76,12 +76,15 @@ class IndexController extends RestBaseController
$volunteer = $volunteerModel->selectData($volunteer_page,$volunteer_pageNum,array('status'=>2));
//活动
$activityModel = new ActivityModel();
$activity = $activityModel->selectData(0,2);
$activity = $activityModel->selectDataByTime(0,2);
foreach ($activity as $k=>$v){
$activity[$k]['start_time']=date('Y-m-d',$v['start_time']);
}
// $beginAtOnce = $activityModel->beginAtOnce($activity_page,$activity_pageNum);
//新闻
$activityNewsModel = new ActivityNewsModel();
$news = $activityNewsModel->selectData($activity_page,$activity_pageNum);
$news = $activityModel->selectDataByTime($activity_page,$activity_pageNum,1);
//幻灯片
$slideItemModel = new SlideItemModel();
... ... @@ -225,7 +228,10 @@ class IndexController extends RestBaseController
* @return button_title:按钮标题
* @return join:参加用户@
* @join photo:照片 name:名称 level:星级 duty:岗位
* @return button_status:按钮状态7.用户被拒绝重新申请客户6.用户是志愿者,但是未报名参加活动5.已结束(活动过期)4.已提交工作汇报(用户是志愿者,已报名活动,已通过审核,已签到)3.提交工作汇报(用户是志愿者,已报名活动,选择线下或线上+线下,已通过审核,按钮变为签到但不可点击,活动有效时间内,变为可点击状态)2.待审核(用户是志愿者,已报名活动,但是未通过审核)1.报名 (用户是志愿者,但是未报名参加活动)
* @return button_status:按钮状态8.报名通过活动未结束,不能填写报告7.用户被拒绝重新申请客户6.用户是志愿者,但是未报名参加活动5.已结束(活动过期)4.已提交工作汇报(用户是志愿者,已报名活动,已通过审核,已签到)3.提交工作汇报(用户是志愿者,已报名活动,选择线下或线上+线下,已通过审核,按钮变为签到但不可点击,活动有效时间内,变为可点击状态)2.待审核(用户是志愿者,已报名活动,但是未通过审核)1.报名 (用户是志愿者,但是未报名参加活动)
* @return activity_stage:0.未开始1.进行中2.已结束
* @return status:0.未审核1.已通过2.已拒绝3.已提交工作汇报
* @return is_join:0.未参加1.已参加
*/
public function activity_info(){
$id = $this->request->param('id');
... ... @@ -236,8 +242,6 @@ class IndexController extends RestBaseController
/*获取状态*/
$userModel = new UserModel();
$user = $userModel->findData(array('id'=>$userId));
/*是否为志愿者*/
$Volunteer=new VolunteerModel();
$volunteerMap['user_id']=$userId;
... ... @@ -260,6 +264,17 @@ class IndexController extends RestBaseController
$is_end=0;
}
if ($is_end==0){
if ($activity['start_time']>time()){
$activity['activity_stage']=0;
}else{
$activity['activity_stage']=1;
}
}else{
$activity['activity_stage']=2;
}
if($user['type'] == 2){
$activity['admin']=1;
}else{
... ... @@ -291,21 +306,21 @@ class IndexController extends RestBaseController
}elseif($join['status']==0){
$is_book=1;
$is_pass=0;
}
$check=0;
if ($is_volunteer==1 && $check==0 && $is_join==1 && $is_pass==1 && $is_book==0){
$status=3;
$title='工作汇报';
/*添加状态 活动没有开始时不能提交报告*/
if ($is_volunteer==1 && $check==0 && $is_pass==1 && $is_end==0){
$status=8;
$title='暂不能提交工作汇报';
$check=1;
}
if ($is_volunteer==0 && $check==0) {
$status=6;
if ($is_volunteer==1 && $check==0 && $is_join==1 && $is_pass==1 && $is_book==0){
$status=3;
$title='工作汇报';
$check=1;
$title='成为志愿者';
}
if ($is_end==1 && $check==0){
... ... @@ -314,6 +329,13 @@ class IndexController extends RestBaseController
$check=1;
}
if ($is_volunteer==0 && $check==0) {
$status=6;
$check=1;
$title='成为志愿者';
}
if ($is_volunteer==1 && $check==0 && $is_pass==1 && $is_book==1){
$status=4;
$title='已签到';
... ... @@ -343,13 +365,51 @@ class IndexController extends RestBaseController
}
$activity['button_title']=$title;
$activity['button_status']=$status;
/*活动参与状态*/
$activity['is_join']=$is_join;
$people=$Join->getJoinData($id);
$map1=[];
$sub_map['j.activity_id']=$id;
$sub_map['j.status']=['in','1,3'];
$sub_map['j.delete_time']=0;
$subQuery = db('join')->alias('j')
->field('max(j.id)')
->join('volunteer v','v.user_id=j.user_id')
->where($sub_map)
->group('j.user_id')
->select()
->toArray();
if (!empty($subQuery)){
foreach ($subQuery as $k=>$v){
$new_map[]=$v["max(j.id)"];
}
$map1['j.id']=['in',implode(',',$new_map)];
}
$map1['j.activity_id']=$id;
$map1['j.status']=['in','1,3'];
$map1['j.delete_time']=0;
$people=db('join')->alias('j')
->group('j.user_id')
->field('v.name,v.photo,v.level,j.work_content')
->join('volunteer v','v.user_id=j.user_id')
->where($map1)
->order('j.id','asc')
->select()
->toArray();
$join1=[];
$work_content=db('work')->column('name');
// dump($people);
foreach ($people as $k=>$v){
$join1[$k]['photo']=$v['photo'];
$join1[$k]['name']=$v['name'];
$join1[$k]['level']=$v['level'];
$join1[$k]['duty']=$v['duty'];
$join1[$k]['duty']=$work_content[$v['work_content']-1]??'';
}
$activity['join']=$join1;
$this->success('获取成功!',$activity);
... ... @@ -429,6 +489,8 @@ class IndexController extends RestBaseController
$is_pass=1;
}
$check=0;
if ($is_volunteer==0 && $check==0) {
$status=6;
$check=1;
... ... @@ -497,6 +559,7 @@ class IndexController extends RestBaseController
$Join=new JoinModel();
$where['user_id']=$userId;
$where['activity_id']=$activity_id;
$where['status']=1;
$where['delete_time']=0;
$join=$Join->findData($where);
if (empty($join)){
... ... @@ -533,6 +596,7 @@ class IndexController extends RestBaseController
*
* @param name:id type:int require:1 other: desc:活动id
* @param name:form_id type:int require:1 other: desc:表单id
* @param name:card_number type:int require:1 other: desc:身份证号
* @param name:type type:int require:1 other: desc:活动类型1:线上2:线下3:线上+线下
* @param name:start_time type:int require:1 other: desc:开始时间
* @param name:end_time type:int require:1 other: desc:结束时间
... ... @@ -549,6 +613,7 @@ class IndexController extends RestBaseController
$end_time=strtotime(input('end_time'));
$activity_id=input('id');
$form_id=input('form_id');
$card_number=input('card_number');
$this->saveFormId($userId,$form_id);
/*三期增加字段*/
... ... @@ -569,11 +634,14 @@ class IndexController extends RestBaseController
$map['user_id']=$userId;
$map['activity_id']=$activity_id;
$map['delete_time']=0;
$map['status']=0;
$join=$Join->findData($map);
if ($join){
// $this->error('已经报名参加过该活动!');
$this->error('已经报名参加过该活动!');
}
$data['user_id']=$userId;
$data['card_number']=$card_number;
$data['activity_id']=$activity_id;
$data['type']=$type;
$data['start_time']=$start_time;
... ... @@ -644,12 +712,13 @@ class IndexController extends RestBaseController
$data['select_time']=$select_time;
$data['apply_stay']=$apply_stay;
$data['apply_food']=$apply_food;
$data['card_number']=input('card_number');
$data['status']=0;//需要重新进行审核
$Join=new JoinModel();
$result=$Join->where($map)->Update($data);
/*echo $Join->getLastSql();
dump($result);
exit();*/
if ($result>0){
$this->success('修改成功,请等待审核!');
}
... ... @@ -671,12 +740,14 @@ class IndexController extends RestBaseController
* @return birthday:生日
* @return sex:性别
* @return tel:手机号
* @return card_number:身份证号
* @return work_type:工作类型
* @return work_content:工作内容
* @return select_time:选择日期
* @return apply_stay:申请入住
* @return apply_food:申请用餐
*
*
*/
public function getApplyInfo(){
$userId=$this->getUserId();
... ... @@ -707,12 +778,13 @@ class IndexController extends RestBaseController
}
$info=db('join')->field('sgin_time,id,type,user_id,activity_id,select_time,apply_stay,apply_food,work_content')->where($map)->find();
$user=db('volunteer')->field('sex,name,birthday,move_phone')->where('user_id',$userId)->find();
$user=db('volunteer')->field('card_number,sex,name,birthday,move_phone')->where('user_id',$userId)->find();
if (!empty($user)){
$return['name']=$user['name'];
$return['birthday']=$user['birthday'];
$return['sex']=$user['sex']==1?'男':'女';
$return['tel']=$user['move_phone'];
$return['card_number']=$user['card_number'];
}
if (!empty($info)){
$return['work_content']=db('work')->where('id',$info['work_content'])->value('name');
... ... @@ -797,15 +869,18 @@ class IndexController extends RestBaseController
$userId=$user_id;
}
$map['user_id']=input('user_id');
if (empty($map['user_id'])){
$map['user_id']=$userId;
}
$map['activity_id']=$activity_id;
$map['status']=['in','1,3'];
$map['delete_time']=0;
$result=db('join')->where($map)->find();
// echo db('join')->getLastSql();
$result=db('join')->where($map)->order('id','desc')->find();
if (empty($result)){
$this->error('没有相关信息');
}
$return['work_content']=db('work')->where('id',$result['work_content'])->value('name');
$return['work_report']=$result['work_report'];
/* $return['date']=date('Y-m-d',$result['add_time']);
$return['time']=date('H:i:s',$result['add_time']);*/
$return['time']=json_decode($result['select_time'],true);
... ... @@ -848,14 +923,21 @@ class IndexController extends RestBaseController
* @header name:XX-Token require:1 default: desc:token
*
* @param name:city_id type:int require:1 other: desc:城市id
* @param name:end type:int require:1 other: desc:0,未结束1,已结束
* @return activity:活动@
* @activity id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区
*/
public function cityGetActivity(){
$city_id=input('city_id');
$end=input('end');
if (empty($end)||$end==0){
$type='>=';
}else{
$type='<';
}
$Activity=new ActivityModel();
$activity=$Activity->selectCityData($city_id);
$activity=$Activity->selectCityData($city_id,$type);
$this->success('',$activity);
}
... ... @@ -893,14 +975,21 @@ class IndexController extends RestBaseController
* @header name:XX-Token require:1 default: desc:token
*
* @param name:type n_id type:int require:1 other: desc:类型id
* @param name:end type:int require:1 other: desc:0,未结束1,已结束
* @return activity:活动@
* @activity id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区
*/
public function typeGetActivity(){
$type_id=input('type');
$end=input('end');
if (empty($end)||$end==0){
$type='>=';
}else{
$type='<';
}
$Activity=new ActivityModel();
$activity=$Activity->selectTypeData($type_id);
$activity=$Activity->selectTypeData($type_id,$type);
$this->success('',$activity);
}
... ... @@ -966,8 +1055,6 @@ class IndexController extends RestBaseController
$last->mergeImage('../static/images/bottom.png','png',595,536,425,0);
$last->mergeImage('../upload/qrcode/1-'.$id.'.png','png',595,536,477,160);
$last->save('../upload/qrcode/4-'.$id.'.png');
dump($circle);
dump($Image->get());*/
... ... @@ -1002,4 +1089,7 @@ class IndexController extends RestBaseController
$app = Factory::officialAccount($config);
}
}
\ No newline at end of file
... ...
... ... @@ -16,6 +16,7 @@ use api\index\model\VolunteerModel;
use api\index\model\UserModel;
use cmf\controller\RestBaseController;
use EasyWeChat\Foundation\Application;
use think\Db;
use think\Validate;
/**
... ... @@ -55,21 +56,25 @@ class MemberCenterController extends RestBaseController
//判断当前用户是否提交过
$volunteerModel = new VolunteerModel();
$result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0));
// dump($result->toArray());
$userModel = new UserModel();
$user = $userModel->findData(array('id'=>$user_id));
if(empty($result)){
$is_submit = 0;
}else {
$user['avatar']=$result['photo'];
$user['user_nickname']=$result['name'];
$is_submit = 1;
}
if (empty($result['level'])){
$result['level']=0;
}
if (empty($result['work_time'])){
$result['work_time']=0;
}
$user['level']=$result['level'];
$user['work_time']=$result['work_time'];
$user['is_submit'] = $is_submit;
... ... @@ -275,7 +280,7 @@ class MemberCenterController extends RestBaseController
'user_id' => $user_id,
];
$form_id=input('form_id');
if (empty($form_id)){
if (!empty($form_id)){
$this->saveFormId($user_id,$form_id);
}
$volunteerModel = new VolunteerModel();
... ... @@ -447,11 +452,12 @@ class MemberCenterController extends RestBaseController
*
* @header name:XX-Token require:1 default: desc:token
*
* @param name:add_time type:int require:0 other: desc:添加时间
* @param name:user_id type:int require:0 other: desc:用户id
* @param name:join_id type:int require:0 other: desc:参加id
*
*/
public function addTime(){
$user_id = $this->getUserId();
//判断这个用户是不是管理员
$userModel = new UserModel();
... ... @@ -459,17 +465,43 @@ class MemberCenterController extends RestBaseController
if($user['type'] != 2){
$this->success(['code'=>40001,'msg'=>'查无此人!']);
}
$map['user_id']=input('user_id');
$map['id']=input('join_id');
$time=input('add_time');
// $data['add_time']=['exp','work_time'+$time];
$user_id1=input('user_id');
if (empty($user_id1)){
$join=\db('join')->where($map)->find();
if (empty($join)){
$this->error('参数错误');
}
$joinUpdate['work_time']=$time;
\db('join')->where($map)->update($joinUpdate);
if ($time>$join['work_time']){
$add_time=$time-$join['work_time'];
$volunteerUpdate['work_time']=$add_time;
\db('volunteer')->where('user_id',$join['user_id'])->setInc('work_time',$add_time);
}else{
$add_time=$join['work_time']-$time;
\db('volunteer')->where('user_id',$join['user_id'])->setDec('work_time',$add_time);
}
}else{
\db('volunteer')->where('user_id',$user_id1)->setInc('work_time',$time);
}
$result=1;
/* // $data['add_time']=['exp','work_time'+$time];
$result=db('volunteer')->where($map)->setInc('work_time',$time);
// echo db('volunteer')->getLastSql();
// echo db('volunteer')->getLastSql();*/
if ($result>0){
$this->success('修改成功!');
}else{
$this->error('此人不是审核通过的志愿者!');
}
}
/**
* @title 管理员查看活动申请详情
* @description 管理员审核
... ... @@ -491,15 +523,16 @@ class MemberCenterController extends RestBaseController
if($user['type'] != 2){
$this->success(['code'=>40001,'msg'=>'查无此人!']);
}
/*获取*/
if (!empty($return['time'])){
$return['time']= array_reverse($return['time']);
}
$info=db('join')->field('sgin_time,id,type,user_id,activity_id,select_time,apply_stay,apply_food,work_content')->where($map)->find();
$user=db('volunteer')->field('sex,name,birthday,move_phone')->where('user_id',$info['user_id'])->find();
$info=db('join')->field('card_number,sgin_time,id,type,user_id,activity_id,select_time,apply_stay,apply_food,work_content')->where($map)->find();
$user=db('volunteer')->field('card_number,sex,name,birthday,move_phone')->where('user_id',$info['user_id'])->find();
if (!empty($user)){
$return['name']=$user['name'];
$return['birthday']=$user['birthday'];
... ... @@ -514,6 +547,7 @@ class MemberCenterController extends RestBaseController
$return['apply_food']=json_decode($info['apply_food'],true);
$return['id']=$info['id'];
$return['work_type']=$info['type'];
$return['card_number']=$user['card_number'];
$return['is_complete']=$info['sgin_time']==0?'0':'1';
/* switch ($info['type']){
case 1:
... ... @@ -556,6 +590,7 @@ class MemberCenterController extends RestBaseController
if(empty($id)){
$this->error('缺少参数id');
}
$data['refund_reason']=input('refund_reason')??'';
$status = $this->request->param('status');
if(empty($status)){
$this->error('缺少参数status');
... ... @@ -576,21 +611,24 @@ class MemberCenterController extends RestBaseController
if ($data['status']==2){
$keyword='审核通过';
}else{
$keyword='审核未通过';
$keyword="审核未通过 原因:$data[refund_reason]";
}
$data['refund_reason']=input('refund_reason')??'';
$result = $volunteerModel->updateData(array('id'=>$id),$data);
if(empty($result)){
$this->success(['code'=>40002,'msg'=>'当前申请可能已被其他管理员审核,请刷新页面!']);
}
$userMap['user_id']=$id;
$openid=db('third_party_user')->where($userMap)->value('openid');
$volunteer=db('volunteer')->where('id',$id)->find();
$formMap['user_id']=$id;
$userMap['user_id']=$volunteer['user_id'];
$openid=db('third_party_user')->where($userMap)->value('openid');
$formMap['user_id']=$volunteer['user_id'];
$formMap['use_time']=0;
$formMap['expire_time']=['>',time()];
$form_id=\db('form_id')->where($formMap)->find();
$now=time();
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>$now]);
if (!empty($form_id)){
$data['keyword1']= $volunteer['name'];
$data['keyword2']='志愿者审核';
$data['keyword3']=$keyword;
... ... @@ -604,6 +642,7 @@ class MemberCenterController extends RestBaseController
'emphasis_keyword' =>$data['keyword3']='状态',
];
$this->wxappNotice($message);
}
$this->success(['code'=>20000,'msg'=>'更新成功!']);
}
... ... @@ -640,14 +679,57 @@ class MemberCenterController extends RestBaseController
$map['activity_id']=$id;
$map['j.delete_time']=0;
$info=db('join')->alias('j')
/* $info=db('join')->alias('j')
->group('j.user_id')
->field('v.*,j.*,j.id as join_id,j.status as status')
->join('volunteer v','v.user_id=j.user_id')
->where($map)
->order('j.id','asc')
->select()
->toArray();*/
/* $subQuery = db('join')->alias('j')
->field('j.user_id,v.name,v.photo,j.id as join_id,j.status as status,j.delete_time,j.activity_id,j.work_content')
->join('volunteer v','v.user_id=j.user_id')
->where($map)
->order('j.id','desc')
->buildSql();
dump($subQuery);
$info= Db::table($subQuery.'a')
->group('a.user_id')
->select()
->toArray();*/
$new_map=[];
$subQuery = db('join')->alias('j')
->field('max(j.id)')
->join('volunteer v','v.user_id=j.user_id')
->where($map)
->group('j.user_id')
->select()
->toArray();
if (!empty($subQuery)){
foreach ($subQuery as $k=>$v){
$new_map[]=$v["max(j.id)"];
}
}
$map1['j.id']=['in',implode(',',$new_map)];
$info=db('join')->alias('j')
->group('j.user_id')
->field('v.*,j.*,j.id as join_id,j.status as status')
->join('volunteer v','v.user_id=j.user_id')
->where($map1)
->order('j.id','asc')
->select()
->toArray();
/*$info=db('join_view')
->group('user_id')
->where($map)
->select()
->toArray();*/
// echo db('join')->getLastSql();
$return=[];
$i0=0;
... ... @@ -767,6 +849,8 @@ class MemberCenterController extends RestBaseController
$formMap['use_time']=0;
$formMap['expire_time']=['>',time()];
$form_id=\db('form_id')->where($formMap)->find();
$now=time();
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>$now]);
if ($data['status']==1){
if (!empty($form_id)){
... ... @@ -790,7 +874,7 @@ class MemberCenterController extends RestBaseController
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]);
$data['keyword1']= $volunteer['name'];
$data['keyword2']='活动审核';
$data['keyword3']='未通过';
$data['keyword3']='未通过 原因:'.$refund_reason;
$data['keyword4']=$activity['activity_name'];
$message = [
'touser' => $openid,
... ... @@ -811,7 +895,6 @@ class MemberCenterController extends RestBaseController
}
}
protected function wxappNotice($message){
$appId = 'wx7a3bf4e0796c070a';
$secret = '755478f064e09a8301345e0c427c6cf3';
... ... @@ -825,7 +908,7 @@ class MemberCenterController extends RestBaseController
try{
$result= $notice->send($message);
}catch(Exception $e){
$e->getMessage();
// $e->getMessage();
}
return $result;
}
... ... @@ -904,4 +987,5 @@ class MemberCenterController extends RestBaseController
}
\ No newline at end of file
... ...
... ... @@ -56,13 +56,37 @@ class ActivityModel extends Model
->toArray();
return $data;
}
public function selectCityData($city_id){
public function selectDataByTime($page,$pageNum,$type=0){
$order = "create_time desc";
$where['a.delete_time'] = ['eq',0];
if ($type==0){
$where['a.end_time']=['>',time()];
}else{
$where['a.end_time']=['<',time()];
}
$where['is_up'] = ['eq',1];
$data = $this->alias('a')
->field('a.*,p.province_name,act.type_name')
->join('activity_type act','act.id=a.activity_type','LEFT')
->join('position_province p','p.id=a.position_id','LEFT')
->where($where)
->limit(($page * $pageNum),$pageNum)
->order($order)
->select()
->toArray();
return $data;
}
public function selectCityData($city_id,$type=">="){
$order = "create_time desc";
$where['a.delete_time'] = ['eq',0];
$where['a.is_up']=1;
$where['a.end_time']=[$type,time()];
if (!empty($city_id)){
$where['a.position_id'] = $city_id;
}
$data = $this->alias('a')
->field('a.*,p.province_name,act.type_name')
->join('activity_type act','act.id=a.activity_type','LEFT')
... ... @@ -71,12 +95,17 @@ class ActivityModel extends Model
->order($order)
->select()
->toArray();
// echo $this->getLastSql();
return $data;
}
public function selectTypeData($type_id){
public function selectTypeData($type_id,$type="<="){
$order = "create_time desc";
$where['a.delete_time'] = ['eq',0];
$where['a.is_up']=1;
$where['a.end_time']=[$type,time()];
if (!empty($type_id)){
$where['a.activity_type'] = $type_id;
}
... ...
... ... @@ -55,15 +55,19 @@ class JoinModel extends Model
*/
public function getUserJoin($userId){
$where['j.user_id']=$userId;
$where['j.status']=['>',1];
$where['j.status']=['in','1,3'];
$where['j.delete_time']=0;
$info=$this->alias('j')
->field('a.*,at.type_name,pp.*,a.id as id')
->join('cmf_activity a','a.id=j.activity_id')
->join('cmf_activity_type at','a.activity_type=at.id')
->join('cmf_position_province pp','a.position_id=pp.id')
->join('cmf_activity_type at','a.activity_type=at.id','LEFT')
->join('cmf_position_province pp','a.position_id=pp.id','LEFT')
->where($where)
->order('a.start_time','desc')
->group('a.id')
->select()
->toArray();
// echo $this->getLastSql();
return $info;
}
}
\ No newline at end of file
... ...
... ... @@ -189,13 +189,51 @@ class PublicController extends RestBaseController
$openid = $this->request->param('openid');
$third_party_user = Db::name('third_party_user')->where(array('openid'=>$openid))->find();
if(empty($third_party_user)){
$this->success('查无此人!',['code'=>20000,'msg'=>'查无此人!']);
/*没有相关用户 添加用户到数据库 分配token*/
$ip = $this->request->ip(0, true);
$currentTime=time();
Db::startTrans();
$appId = config('app_id');
$userId = Db::name("user")->insertGetId([
'create_time' => $currentTime,
'user_status' => 1,
'user_type' => 2,
'sex' => 0,
'user_nickname' => '用户',
'avatar' => '',
'last_login_ip' => $ip,
'last_login_time' => $currentTime
]);
$row=Db::name("third_party_user")->insert([
'openid' => $openid,
'user_id' => $userId,
'third_party' => 'wxapp',
'app_id' => $appId,
'last_login_ip' => $ip,
'union_id' => '',
'last_login_time' => $currentTime,
'create_time' => $currentTime,
'login_times' => 1,
'status' => 1
]);
if($userId && $row){
Db::commit();
$token = cmf_generate_user_token($userId, 'wxapp');
$this->success("登录成功!", ['token' => $token]);
}else{
Db::rollback();
$this->error(['code'=>'40004','msg'=>'登录失败']);
}
// $this->success('查无此人!',['code'=>20000,'msg'=>'查无此人!']);
}
$data = Db::name('user_token')->where(array('user_id'=>$third_party_user['user_id']))->find();
if($data['expire_time']<time()){
$this->success('token过期了',['code'=>20000,'msg'=>'token过期了']);
$token = cmf_generate_user_token($third_party_user['user_id'], 'wxapp');
$this->success('ok',['code'=>20000,'msg'=>'ok','token'=>$token]);
}else{
$this->success('ok',['code'=>20000,'msg'=>'ok','data'=>$data['token']]);
$this->success('ok',['code'=>20000,'msg'=>'ok','token'=>$data['token']]);
}
}
... ...
... ... @@ -9,6 +9,7 @@
namespace app\admin\controller;
use app\admin\model\Excel;
use cmf\controller\AdminBaseController;
use think\Request;
use think\Validate;
... ... @@ -24,34 +25,48 @@ class ActivityController extends AdminBaseController
$startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
if (!empty($startTime) && !empty($endTime)) {
$where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
$where['a.create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
} else {
if (!empty($startTime)) {
$where['create_time'] = ['>= time', $startTime];
$where['a.create_time'] = ['>= time', $startTime];
}
if (!empty($endTime)) {
$where['create_time'] = ['<= time', $endTime];
$where['a.create_time'] = ['<= time', $endTime];
}
}
$keyword = empty($param['keyword']) ? '' : $param['keyword'];
if (!empty($keyword)) {
$where['activity_name|abstract'] = ['like', "%$keyword%"];
$where['a.activity_name|a.abstract'] = ['like', "%$keyword%"];
}
$data=Db::name('activity')
->where('delete_time',0)
->alias('a')
->field('a.*,at.type_name,pc.province_name as city_name')
->join('activity_type at','a.activity_type=at.id','LEFT')
->join('position_province pc','a.position_id=pc.id','LEFT')
->where('a.delete_time',0)
->where($where)
->order('create_time desc')
->order('a.create_time desc')
->paginate(10);
$data->appends($param);
$list=$data->items();
foreach ($list as $k=>$v){
$join_map['status']=['in','1,3'];
$join_map['activity_id']=$v['id'];
$join_map['delete_time']=0;
$list[$k]['count']=\db('join')->where($join_map)->count('*');
}
$this->assign([
'data'=>$data,
'data'=>$list,
'page'=>$data->render(),
]);
//dump($list);
$this->assign('start_time', isset($param['start_time']) ? $param['start_time'] : '');
$this->assign('end_time', isset($param['end_time']) ? $param['end_time'] : '');
$this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
return $this->fetch();
}
public function news(){
$where=[];
$param = $this->request->param();
... ... @@ -121,7 +136,7 @@ class ActivityController extends AdminBaseController
$data=Db::name('activity')
->where('id',$id)
->find();
$activity_type=\db('activity_type')->select()->toArray();
$activity_type=\db('activity_type')->where('delete_time','0')->select()->toArray();
foreach ($activity_type as $k=>$v){
$activity[$v['id']]['type_name']=$v['type_name'];
$activity[$v['id']]['id']=$v['id'];
... ... @@ -225,7 +240,7 @@ class ActivityController extends AdminBaseController
->insert($param);
$this->success('添加成功!');
}else{
$activity_type=\db('activity_type')->select()->toArray();
$activity_type=\db('activity_type')->where('delete_time','0')->select()->toArray();
foreach ($activity_type as $k=>$v){
$activity[$v['id']]['type_name']=$v['type_name'];
$activity[$v['id']]['id']=$v['id'];
... ... @@ -333,7 +348,6 @@ class ActivityController extends AdminBaseController
}else{
$this->error("删除失败!", '');
}
}
if (isset($param['ids'])) {
... ... @@ -442,9 +456,9 @@ class ActivityController extends AdminBaseController
public function join(){
$map['j.activity_id']=input('id');
$map['j.delete_time']=0;
//$map['j.delete_time']=0;
$join=\db('join')
->field('j.*,v.name,v.photo')
->field('j.*,v.name,v.photo,v.card_number')
->alias('j')
->join('volunteer v','v.user_id=j.user_id')
->where($map)
... ... @@ -458,8 +472,8 @@ class ActivityController extends AdminBaseController
$join[$k]['sgin_time']=date('Y-m-d H:i:s',$v['sgin_time']);
}
$join[$k]['work_content']=\db('work')->where('id',$v['work_content'])->value('name');
$join[$k]['select_time']=json_decode($v['select_time'],true);
$join[$k]['apply_stay']=json_decode($v['apply_stay'],true);
$join[$k]['select_time'] =json_decode($v['select_time'],true);
$join[$k]['apply_stay'] =json_decode($v['apply_stay'],true);
$join[$k]['apply_food']=json_decode($v['apply_food'],true);
}
$this->assign('data',$join);
... ... @@ -512,19 +526,18 @@ class ActivityController extends AdminBaseController
}
protected function wxappNotice($message){
$appId = 'wx7a3bf4e0796c070a';
$secret = '755478f064e09a8301345e0c427c6cf3';
$config = [
'app_id' => $appId,
'secret' => $secret,
];
try{
$wechat=new Application($config);
$notice=$wechat->mini_program->notice;
try{
$result= $notice->send($message);
}catch(Exception $e){
$e->getMessage();
//$e->getMessage();
}
return $result;
}
... ... @@ -540,6 +553,7 @@ class ActivityController extends AdminBaseController
$this->error('参数错误!');
}
$update['status']='2';
$update['refund_reason']=input('refund_reason');
$result=\db('join')->where($map)->update($update);
if ($result>0){
... ... @@ -556,7 +570,7 @@ class ActivityController extends AdminBaseController
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]);
$data['keyword1']= $volunteer['name'];
$data['keyword2']='活动审核';
$data['keyword3']='未通过';
$data['keyword3']='未通过 原因:'.$update['refund_reason'];
$data['keyword4']=$activity['activity_name'];
$message = [
'touser' => $openid,
... ... @@ -568,8 +582,6 @@ class ActivityController extends AdminBaseController
];
$this->wxappNotice($message);
}
$this->success('操作成功!');
}else{
$this->error('操作失败!');
... ... @@ -594,28 +606,25 @@ class ActivityController extends AdminBaseController
public function joinTimePost(){
$map['id']=input('id');
$data['work_time']=input('work_time');
$result=\db('join')->where($map)->update($data);
/*更新用户使用时间*/
$time=input('work_time');
$join=\db('join')->where($map)->find();
$user_id=$join['user_id'];
$all_map['user_id']=$user_id;
$all_result=\db('join')->where($all_map)->sum('work_time');
\db('volunteer')->where('user_id',$user_id)->setInc('work_time',$data['work_time']);
$all_result=\db('volunteer')->where('user_id',$user_id)->value('work_time');
$level_map['min']=['<=',$all_result];
$level_map['max']=['>',$all_result];
$level=db('level')->where($level_map)->value('level');
//dump($all_result);
//var_dump($level);
\db('volunteer')->where('user_id',$user_id)->update(['level'=>$level]);
$joinUpdate['work_time']=$time;
\db('join')->where($map)->update($joinUpdate);
if ($time>$join['work_time']){
$add_time=$time-$join['work_time'];
$volunteerUpdate['work_time']=$add_time;
\db('volunteer')->where('user_id',$join['user_id'])->setInc('work_time',$add_time);
}else{
$add_time=$join['work_time']-$time;
\db('volunteer')->where('user_id',$join['user_id'])->setDec('work_time',$add_time);
}
$result=1;
if ($result>0){
$this->success('编辑成功!');
$this->success('修改成功!');
}else{
$this->error('时长没有变化!');
$this->error('此人不是审核通过的志愿者!');
}
}
public function userWork(){
... ... @@ -631,13 +640,172 @@ class ActivityController extends AdminBaseController
}
}
$this->assign('info',$info);
$this->assign('pic',$pic);
return $this->fetch();
}
public function refund(){
$id=input('id');
$this->assign('id',$id);
return $this->fetch();
}
public function excel(){
$map['j.activity_id']=input('id');
$activity=\db('activity')->where('id',$map['j.activity_id'])->find();
$map['j.status']=['in','1,3'];
$map['j.delete_time']=0;
$join=\db('join')
->field('j.*,v.name,v.photo,v.sex,v.card_number,v.move_phone,v.birthday')
->alias('j')
->join('volunteer v','v.user_id=j.user_id')
->where($map)
->select()
->toArray();
$work=\db('work')->select()->toArray();
/* dump($join);
exit();*/
//dump(get_image_path('https://volunteer.cnpu.org/upload/20190112/9bd2840928f0acee61ce6c906cda32c3.jpg'));
foreach ($join as $k=>$v){
/*dump($k);*/
$join[$k]['card_number']='`'.$v['card_number'];
if (!empty($v['add_time'])){
$join[$k]['add_time']=date('Y-m-d H:i:s',$v['add_time']);
}
if (!empty($v['sgin_time'])){
$join[$k]['sgin_time']=date('Y-m-d H:i:s',$v['sgin_time']);
}
$join[$k]['work_content']=\db('work')->where('id',$v['work_content'])->value('name');
$join[$k]['photo']=get_image_path($v['photo']);
if (!empty($v['select_time'])){
$select[$k]=json_decode($v['select_time'],true);
foreach ($select[$k] as $k1=>$v1){
$date[$k]['time'][$k1]=$v1['date'].' '.$v1['time'];
}
$join[$k]['select']=implode(',',$date[$k]['time']);
}else{
$join[$k]['apply_stay']='';
}
if (!empty($v['apply_stay'])){
$select[$k]=json_decode($v['apply_stay'],true);
foreach ($select[$k] as $k1=>$v1){
$date[$k]['time'][$k1]=$v1['date'];
}
$join[$k]['stay']=implode(',',$date[$k]['time']);
}else{
$join[$k]['apply_stay']='';
}
if (!empty($v['apply_food'])){
$select[$k]=json_decode($v['apply_food'],true);
foreach ($select[$k] as $k1=>$v1){
$date[$k]['time'][$k1]=$v1['date'].' '.$v1['time'];
}
$join[$k]['food']=implode(',',$date[$k]['time']);
}else{
$join[$k]['apply_food']='';
}
switch ($v['status']){
case 0:
$join[$k]['status']='未审核';
break;
case 1:
$join[$k]['status']='已通过';
break;
case 2:
$join[$k]['status']='未通过';
break;
case 3:
$join[$k]['status']='已提交工作汇报';
break;
}
switch ($v['type']){
case 1:
$join[$k]['type']='线上';
break;
case 2:
$join[$k]['type']='线下';
break;
case 3:
$join[$k]['type']='线上及线下';
break;
}
switch ($v['sex']){
case 1:
$join[$k]['sex']='男';
break;
case 2:
$join[$k]['sex']='女';
break;
}
$join[$k]['work_content']=$work[$v['work_content']-1]['name'];
}
$title = [
['ID', 15, 'id', 1],
['姓名', 15, 'name', 1],
['性别', 15, 'sex', 1],
['出生日期', 15, 'birthday', 1],
['电话', 15, 'move_phone', 1],
['身份证号', 25, 'card_number', 1],
['参与方式', 15, 'type', 1],
['审核状态', 15, 'status', 1],
['工作内容', 15, 'work_content', 1],
['选择时间', 30, 'select', 1],
['申请入住', 30, 'stay', 1],
['申请用餐', 30, 'food', 1],
['工作报告', 50, 'work_report', 1],
['拒绝原因', 20, 'refund_reason', 1],
];
$Excel = new Excel();
$letter = $Excel->excelAcross(count($title));
$Excel->excel($letter, $title, $join, "$activity[activity_name]参与人员");
}
public function addtime(){
$id=input('id');
$user_id=input('user_id');
$this->assign('id',$id);
$this->assign('user_id',$user_id);
return $this->fetch();
}
public function addtimepost(){
$id=input('id');
$time=input('time');
$user_id=input('user_id');
$map['activity_id']=$id;
// $map['status']=['in','1,3'];
// $map['delete_time']=0;
// $join=\db('join')->where($map)->select();
// foreach ($join as $k=>$v){
// /*是否已经设置过时间*/
// if (empty($v['work_time'])){
// /*添加用户时间和活动时间*/
// \db('join')->where('id',$v['id'])->update(['work_time'=>$time]);
// \db('volunteer')->where('user_id',$v['user_id'])->setInc('work_time',$time);
// $flag=1;
// }
// }
$users=explode(',',$user_id);
foreach($users as $k=>$v){
\db('join')->where('id',$v)->update(['work_time'=>$time]);
$info= db('join')->where('id',$v)->find();
\db('volunteer')->where('user_id',$info['user_id'])->setInc('work_time',$time);
$flag=1;
}
$this->success('设置工作时长成功!');
/* if (isset($flag)){
$this->success('设置工作时长成功!');
}else{
$this->error('全部已经确定了工作时长');
}*/
}
}
\ No newline at end of file
... ...
... ... @@ -9,6 +9,7 @@
namespace app\admin\controller;
use app\admin\model\Excel;
use cmf\controller\AdminBaseController;
use think\Validate;
use think\Db;
... ... @@ -17,8 +18,9 @@ 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']);
... ... @@ -44,50 +46,132 @@ 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)
$addr = empty($param['addr']) ? '' : $param['addr'];
if (!empty($addr)) {
$where['addr'] = ['like', "%$addr%"];
}
$list = Db::name('volunteer')
->where('delete_time', 0)
->where($where)
->order('create_time desc')
->paginate(10);
$data->appends($param);
$list->appends($param);
$data=$list->items();
$year=date('Y');
foreach ($data as $k=>$v){
$data[$k]['age']=$year-date('Y',strtotime($v['birthday']));
$data[$k]['level']=get_level($v['work_time']);
}
$this->assign([
'data'=>$data,
'page'=>$data->render(),
'data' => $data,
'page' => $list ->render(),
]);
$this->assign('start_time', isset($param['start_time']) ? $param['start_time'] : '');
$this->assign('end_time', isset($param['end_time']) ? $param['end_time'] : '');
$this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
$this->assign('addr', isset($param['addr']) ? $param['addr'] : '');
$this->assign('category', isset($param['category']) ? $param['category'] : '');
$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');
$volunteer_org=\db('volunteer')->where('id',$id)->find();
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;
Db::name('volunteer')
->where('id',$id)
$level_map['min'] = ['<=', $param['work_time']];
$level_map['max'] = ['>', $param['work_time']];
$level = db('level')->where($level_map)->value('level');
$param['level'] = $level;
$result= Db::name('volunteer')
->where('id', $id)
->update($param);
/*发送模板消息进行通知*/
if ($result>0 && $volunteer_org['status']!=$param['status']){
$volunteer=\db('volunteer')->where('id',$id)->find();
$userMap['user_id']=$volunteer['user_id'];
$openid=db('third_party_user')->where($userMap)->value('openid');
$formMap['user_id']=$volunteer['user_id'];
$formMap['use_time']=0;
$formMap['expire_time']=['>',time()];
$form_id=\db('form_id')->where($formMap)->find();
if (!empty($form_id)&& $param['status']!=1){
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]);
$data['keyword1']= $volunteer['name'];
$data['keyword2']='志愿者审核';
if ($param['status']==2){
$data['keyword3']='通过';
}
if ($param['status']==3){
$data['keyword3']='未通过 原因:'.$param['refund_reason'];
}
$data['keyword4']='申请成为志愿者';
$message = [
'touser' => $openid,
'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw',
'page' => 'pages/index/index',
'form_id' => $form_id['value'],
'data' => $data,
'emphasis_keyword' =>$data['keyword3']='状态',
];
$this->wxappNotice($message);
}
}
$this->success('操作成功!');
$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();
}
}
/**
* 模板消息发送
* @param $message
* @return \EasyWeChat\Support\Collection
* @throws \EasyWeChat\Core\Exceptions\InvalidArgumentException
*/
protected function wxappNotice($message){
$appId = 'wx7a3bf4e0796c070a';
$secret = '755478f064e09a8301345e0c427c6cf3';
$config = [
'app_id' => $appId,
'secret' => $secret,
];
$wechat=new Application($config);
$notice=$wechat->mini_program->notice;
$result= $notice->send($message);
return $result;
try{
$wechat=new Application($config);
$notice=$wechat->mini_program->notice;
$result= $notice->send($message);
}catch(Exception $e){
$e->getMessage();
}
return $result;
}
//删除
public function delete(){
public function delete()
{
$param = $this->request->param();
if (isset($param['id'])) {
... ... @@ -95,9 +179,9 @@ class VolunteerController extends AdminBaseController
$resultPortal = Db::name('volunteer')
->where(['id' => $id])
->delete();
if($resultPortal){
if ($resultPortal) {
$this->success("删除成功!", '');
}else{
} else {
$this->error("删除失败!", '');
}
... ... @@ -110,26 +194,29 @@ 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']);
... ... @@ -155,12 +242,110 @@ 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 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, 'volunteers');
}
public function sendnotice(){
return $this->fetch();
}
public function sendsms(){
$data = Db::name('volunteer')
->where('delete_time', 0)
->order('create_time desc')
->select();
dump($data);
$this->assign([
'list' => $data,
]);
return $this->fetch();
}
public function smsPost(){
$user=input('to_user_id');
$content=input('description');
if (empty($user)||$user==0){
$this->error('请选择用户!');
}
if (empty($content)){
$this->error('内容不能为空!');
}
$users=explode(',',$user);
$result=send_duanxinbao($content,$users);
if ($result==0){
$this->success('发送成功!');
}else{
$this->error('发送失败!');
}
}
public function pass(){
$id=input('id');
$update['status']='2';
$result=\db('volunteer')->where('id',$id)->update($update);
if ($result>0){
$this->success('编辑成功!');
}else{
$this->error('编辑失败');
}
}
public function unpass(){
$id=input('id');
$update['status']='3';
$result=\db('volunteer')->where('id',$id)->update($update);
if ($result>0){
$this->success('编辑成功!');
}else{
$this->error('编辑失败');
}
}
}
\ No newline at end of file
... ...
<?php
/**
* Created by PhpStorm.
* User: wz
* Date: 2019/3/30
* Time: 14:14
*/
namespace app\admin\model;
class Excel
{
/**
* 循环excel单元格横坐标 最大702列
*/
public function excelAcross($num){
$arr=['A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
$re=[];
$counts=['0'=>0,'1'=>0];
if ($num<=702){
for ($i=0;$i<$num;$i++){
if ($counts[0]==0){
$re[]=$arr[$counts[1]];
}else{
$nums=$counts[0]-1;
$re[]=$arr[$nums].$arr[$counts[1]];
}
if ($counts[1]>=25){
$counts[1]=0;
$counts[0]++;
}else{
$counts[1]++;
}
}
return $re;
}else{
return false;
}
}
//例子
public function cs(){
$title=[['列名','列宽','字段名','1:普通文本 2:图片(必须为本地路径)','图片宽度 非图片可不填']];
$letter=$this->excelAcross(count($title));
$list=[['id'=>1,'mobile'=>2],['id'=>2,'mobile'=>2]];
}
//excel
/**
* @param $letter
* @param $title
* @param $list 数据
* @param $name
* @throws \PHPExcel_Exception
* @throws \PHPExcel_Reader_Exception
* @throws \PHPExcel_Writer_Exception
*/
public function excel($letter,$title,$list,$name){
// 导出Exl
import("Org.Util.PHPExcel");
import("Org.Util.PHPExcel.Worksheet.Drawing");
import("Org.Util.PHPExcel.Writer.Excel2007");
$objPHPExcel = new \PHPExcel();
$objWriter = new \PHPExcel_Writer_Excel2007($objPHPExcel);
$objActSheet = $objPHPExcel->getActiveSheet();
foreach ($letter as $k=>$v){
// 水平居中(位置很重要,建议在最初始位置)
$objPHPExcel->setActiveSheetIndex(0)->getStyle($v)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//设置首行
$objActSheet->setCellValue($v.'1', $title[$k][0]);
// 设置个表格宽度
$objPHPExcel->getActiveSheet()->getColumnDimension($v)->setWidth($title[$k][1]);
// 垂直居中
$objPHPExcel->getActiveSheet()->getStyle($v)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
}
foreach($list as $k=>$v){
$k +=2;
foreach ($letter as $key=>$val){
if ($title[$key][3]==1){
$objActSheet->setCellValue($val.$k, empty($v[$title[$key][2]])?'':$v[$title[$key][2]]);
}else{
$objPHPExcel->getActiveSheet()->getDefaultRowDimension($k)->setRowHeight(200);
// 图片生成
$objDrawing[$k] = new \PHPExcel_Worksheet_Drawing();
$objDrawing[$k]->setPath('./'.$v[$title[$key][2]]);
// 设置宽度高度
//$objDrawing[$k]->setHeight(80);//照片高度
$objDrawing[$k]->setWidth($title[$key][4]); //照片宽度
/*设置图片要插入的单元格*/
$objDrawing[$k]->setCoordinates($val.$k);
// 图片偏移距离
$objDrawing[$k]->setOffsetX(10);
$objDrawing[$k]->setOffsetY(10);
$objDrawing[$k]->setWorksheet($objPHPExcel->getActiveSheet());
}
}
}
$fileName = $name;
$ua = $_SERVER['HTTP_USER_AGENT'];
$ua = strtolower($ua);
if(preg_match('/msie/', $ua) || preg_match('/edge/', $ua)) { //判断是否为IE或Edge浏览器
$fileName = str_replace('+', '%20', urlencode($fileName)); //使用urlencode对文件名进行重新编码
}
$date = date("Y-m-d",time());
$fileName .= "_{$date}.xlsx";
$fileName = iconv("utf-8", "gb2312", $fileName);
//重命名表
// $objPHPExcel->getActiveSheet()->setTitle('test');
//设置活动单指数到第一个表,所以Excel打开这是第一个表
$objPHPExcel->setActiveSheetIndex(0);
header('Content-Type: application/vnd.ms-excel');
header("Content-Disposition: attachment;filename=\"$fileName\"");
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output'); //文件通过浏览器下载
exit();
// END
}
}
\ No newline at end of file
... ...
... ... @@ -23,3 +23,4 @@ return [
"authcode" => 'alOaS0bMPmbDxRzL1c',
//#COOKIE_PREFIX#
];
... ...
<?php return array (
);
\ No newline at end of file
... ...
... ... @@ -10,7 +10,7 @@
// [ 入口文件 ]
// 调试模式开关
define("APP_DEBUG", true);
define("APP_DEBUG", false);
// 定义CMF根目录,可更改此目录
define('CMF_ROOT', __DIR__ . '/../');
... ...
<include file="public@header" />
</head>
<body>
<div class="wrap">
<ul class="nav nav-tabs">
</ul>
<form id="refund_form" method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('addtimePost')}">
<div class="form-group ">
<label for="input-name" class="col-sm-2 control-label"><span class="form-required">*</span>工时时长(h)</label>
<div class="col-md-10 col-sm-10">
<input class="form-control" type="number" required name="time" id="refund_reason" value="" placeholder="请输入工作时长">
</div>
</div>
<input type="hidden" name="id" value="{$id}">
<input type="hidden" name="user_id" value="{$user_id}">
<div style="display: none" class="form-group">
<label for="input-name" class="col-sm-2 control-label"><span class="form-required"></span></label>
<div class="col-md-6 col-sm-10">
<button id="sub" type="submit" class="btn btn-primary js-ajax-submit">保存</button>
</div>
</div>
</form>
<script type="application/javascript">
function load(){
/*检查*/
$('#sub').click();
}
</script>
</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -35,11 +35,13 @@
</th>
<th width="20">ID</th>
<th width="50">标题</th>
<th width="20">缩略图</th>
<th width="20">摘要</th>
<th width="30">创建时间</th>
<th width="30">更新时间</th>
<th width="30">发布时间</th>
<th width="100">活动类型</th>
<th width="20">封面图</th>
<th width="30">开始时间</th>
<th width="30">活动地点</th>
<th width="20">报名人数</th>
<!-- <th width="30">结束时间</th>
<th width="30">发布时间</th>-->
<th width="30">状态</th>
<th width="100">操作</th>
</tr>
... ... @@ -53,18 +55,18 @@
</td>
<td>{$vo.id}</td>
<td>{$vo.activity_name}</td>
<td>{$vo.type_name}</td>
<td>
<notempty name="$vo.thumbnail">
<a href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo.thumbnail)}');">
<i class="fa fa-photo fa-fw"></i>
<img height="80px" src="{:cmf_get_image_preview_url($vo.thumbnail)}">
</a>
</notempty>
</td>
<td>{$vo.abstract}</td>
<!--<td>{:cmf_replace_content_file_url(htmlspecialchars_decode($vo.content))}</td>-->
<td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
<td>{:date('Y-m-d H:i:s',$vo['update_time'])}</td>
<td>{:date('Y-m-d',$vo['time'])}</td>
<td>{:date('Y-m-d H:i:s',$vo['start_time'])}</td>
<td>{$vo.city_name}</td>
<td><a href="{:url('activity/join',array('id'=>$vo['id']))}">{$vo.count}</a></td>
<td>
<notempty name="vo.is_up">
<a data-toggle="tooltip" title="已发布"><i class="fa fa-check"></i></a>
... ... @@ -72,6 +74,11 @@
<a data-toggle="tooltip" title="未发布"><i class="fa fa-close"></i></a>
</notempty>
</td>
<!--<td>{:cmf_replace_content_file_url(htmlspecialchars_decode($vo.content))}</td>-->
<!--<td>{:date('Y-m-d H:i:s',$vo['end_time'])}</td>-->
<!--<td>{:date('Y-m-d',$vo['time'])}</td>-->
<td>
<a href='{:url("activity/edit",array("id"=>$vo["id"]))}'>{:lang('EDIT')}</a>|
<a class="js-ajax-delete" href="{:url('activity/delete',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>
... ...
... ... @@ -7,6 +7,15 @@
<li><a href="{:url('activity/add')}">添加活动</a></li>
</ul>
<form class="well form-inline margin-top-20" method="post" action="{:url('excel')}">
<!-- 关键字:
<input type="text" class="form-control" name="keyword" style="width: 150px;" value="" placeholder="请输入关键字">-->
<input type="hidden" name="id" value="{:input('id')}">
<input type="submit" class="btn btn-primary" value="导出">
<!-- <a class="btn btn-danger" href="/admin/activity/index.html">清空</a>-->
</form>
<button class="btn btn-primary" onclick="addtime({:input('id')})">批量添加工时</button>
<form class="js-ajax-form" action="" method="post">
<table class="table table-hover table-bordered">
... ... @@ -23,6 +32,7 @@
<th width="20">状态</th>
<th width="30">参加类型</th>
<th width="30">工作内容</th>
<th width="30">身份证号</th>
<th width="30">选择时间</th>
<th width="30">申请住宿</th>
<th width="30">申请饮食</th>
... ... @@ -49,12 +59,17 @@
</notempty>
</td>
<td>
<if condition="$vo.delete_time eq 0">
<switch name="$vo.status">
<case value="0">未审核</case>
<case value="1">已通过</case>
<case value="2">未通过</case>
<case value="3">已签到</case>
</switch>
<else />
<span style="color:darkred">已退出</span>
</if>
</td>
<td>
<switch name="$vo.type">
... ... @@ -67,6 +82,9 @@
<td>
{$vo['work_content']}
</td>
<td>
{$vo['card_number']}
</td>
<!-- <td><if condition="$vo['start_time'] neq 0">{:date('Y-m-d',$vo['start_time'])}</if></td>-->
<!--<td><if condition="$vo['end_time'] neq 0">{:date('Y-m-d',$vo['end_time'])}</if></td>-->
<td>
... ... @@ -80,7 +98,7 @@
<td>
<notempty name="vo['apply_stay']">
<volist name="vo['apply_stay']" id="v1">
{$v1.date} {$v1.idcard}<br />
{$v1.date} <br />
</volist>
</notempty>
</td>
... ... @@ -95,27 +113,34 @@
<td>{$vo['sgin_time']}</td>
<td>{$vo['work_time']}</td>
<td>
<if condition="$vo['delete_time'] eq 0">
<if condition="$vo['status'] eq 0">
<a href="{:url('activity/joinPass',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="确定审核通过吗?">通过</a>|
<a onclick="dorefund({$vo['id']})">拒绝</a>
<span onclick="dorefund({$vo['id']})">拒绝</span>
<!--
<a href="{:url('activity/joinUnPass',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="确定拒绝通过吗?">拒绝</a>|
-->
</if>
<if condition="$vo['status'] eq 2">
<span style="color:darkred">已拒绝无法操作</span>
<span style="color:darkred">拒绝理由:{$vo['refund_reason']}</span>
</if>
<if condition="$vo['status'] eq 1 or $vo['status'] eq 3 ">
<font style="color: blue" onclick="doSelectCategory({$vo['id']})" href="{:url('activity/joinTime',array('id'=>$vo['id']))}">参加活动时间</font>
<font style="" onclick="userWork({$vo['id']})" href="{:url('activity/userWork',array('id'=>$vo['id']))}">查看工作汇报</font>
</if>
<else />
<span style="color:darkred">已退出</span>
</if>
</td>
</tr>
</foreach>
</tbody>
</table>
</form>
</div>
<script src="__STATIC__/js/admin.js"></script>
... ... @@ -125,19 +150,19 @@
console.log(res)
openIframeLayer("{:url('activity/joinTime')}?id=" + selectedCategoriesId, '请完善信息', {
area: ['1000px', '700px'],
// btn: ['确定', '取消'],
btn: ['确定', '取消'],
yes: function (index, layero) {
//do something
var iframeWin = window[layero.find('iframe')[0]['name']];
var selectedCategories = iframeWin.confirm();
if (selectedCategories.selectedCategoriesId.length == 0) {
layer.msg('请选择分类');
return;
}
$('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
$('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
console.log(index)
console.log(layero)
var iframeWin= window[layero.find('iframe')];
var body = layer.getChildFrame('body', index);
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:
iframeWin.load();
//console.log(layer.getFrameIndex(index));
layer.close(index); //如果设定了yes回调,需进行手工关闭
console.log('reload');
location.reload()
}
});
}
... ... @@ -145,6 +170,9 @@
function userWork(res) {
var selectedCategoriesId = res
console.log(res)
openIframeLayer("{:url('activity/userWork')}?id=" + selectedCategoriesId, '请完善信息', {
area: ['1000px', '700px'],
// btn: ['确定', '取消'],
... ... @@ -164,6 +192,66 @@
});
}
function dorefund(res) {
var selectedCategoriesId = res
console.log(res)
openIframeLayer("{:url('activity/refund')}?id=" + selectedCategoriesId, '拒绝信息', {
area: ['700px', '300px'],
btn: ['确定','取消'],
yes: function (index, layero) {
//do something
console.log(index)
console.log(layero)
var iframeWin= window[layero.find('iframe')];
// console.log('222222222222');
/* console.log($('#refund_form').html());
$('#refund_form').submit();*/
var body = layer.getChildFrame('body', index);
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:
iframeWin.load();
//console.log(layer.getFrameIndex(index));
layer.close(index); //如果设定了yes回调,需进行手工关闭
console.log('reload');
location.reload()
}
});
}
function addtime(res) {
var selectedCategoriesId = res
console.log(res)
var img_url =[];
$("input[name='ids[]']:checked").each(function(){
img_url.push($(this).val());
})
console.log(img_url)
var user_id=img_url.join(',');
console.log(user_id);
openIframeLayer("{:url('activity/addtime')}?id=" + selectedCategoriesId +"&user_id="+user_id, '输入工时', {
area: ['700px', '300px'],
btn: ['确定','取消'],
yes: function (index, layero) {
//do something
console.log(index)
console.log(layero)
var iframeWin= window[layero.find('iframe')];
var body = layer.getChildFrame('body', index);
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:
iframeWin.load();
//console.log(layer.getFrameIndex(index));
layer.close(index); //如果设定了yes回调,需进行手工关闭
console.log('reload');
location.reload()
}
});
}
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -12,13 +12,21 @@
<input type="hidden" class="form-control" id="input-name" name="id" value="{$_GET['id']}">
</div>
</div>
<div class="form-group">
<div style="display: none" class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
<button id="sub" type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
</div>
</div>
</form>
</div>
<script type="application/javascript">
function load(){
/*检查*/
$('#sub').click();
}
</script>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
... ...
<include file="public@header" />
</head>
<body>
<div class="wrap">
<ul class="nav nav-tabs">
</ul>
<form id="refund_form" method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('joinUnPass')}">
<div class="form-group ">
<label for="input-name" class="col-sm-2 control-label"><span class="form-required">*</span>拒绝理由</label>
<div class="col-md-10 col-sm-10">
<input class="form-control" type="text" required name="refund_reason" id="refund_reason" value="" placeholder="请输入拒绝理由">
</div>
</div>
<input type="hidden" name="id" value="{$id}">
<div style="display: none" class="form-group">
<label for="input-name" class="col-sm-2 control-label"><span class="form-required"></span></label>
<div class="col-md-6 col-sm-10">
<button id="sub" type="submit" class="btn btn-primary js-ajax-submit">保存</button>
</div>
</div>
</form>
<script type="application/javascript">/**/
function load(){
/*检查*/
$('#sub').click();
}
</script>
</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -19,7 +19,9 @@
<div class="col-md-6 col-sm-10">
<notempty name="pic">
<volist name="pic" id="vo">
<a href="javascript:parent.imagePreviewDialog('{$vo}');">
<img style="width:150px;" src="{$vo}"/>
</a>
</volist>
</notempty>
</div>
... ...
... ... @@ -79,6 +79,18 @@
</div>
</div>
<div class="form-group">
<label for="input-site_icp" class="col-sm-2 control-label">短信账号</label>
<div class="col-md-6 col-sm-10">
<input type="text" class="form-control" id="input-site_icp" name="options[duanxinbao]" value="{$duanxinbao|default=''}">
</div>
</div>
<div class="form-group">
<label for="input-site_icp" class="col-sm-2 control-label">短信密码</label>
<div class="col-md-6 col-sm-10">
<input type="text" class="form-control" id="input-site_icp" name="options[duanxinbaomima]" value="">
</div>
</div>
<div class="form-group">
<label for="input-site_admin_email" class="col-sm-2 control-label">{:lang('WEBMASTER_EMAIL')}</label>
<div class="col-md-6 col-sm-10">
<input type="text" class="form-control" id="input-site_admin_email" name="options[site_admin_email]" value="{$site_admin_email|default=''}">
... ...
... ... @@ -281,17 +281,39 @@
<tr>
<td>
<div class="checkbox">
<label><input type="radio" name="status" value="1" <eq name="$data.status" value="1">checked</eq> >未审核</label>
<label><input type="radio" name="status" value="2" <eq name="$data.status" value="2">checked</eq> >通过审核</label>
<label><input type="radio" name="status" value="3" <eq name="$data.status" value="3">checked</eq> >未通过审核</label>
<label><input type="radio" onclick="unrefund()" name="status" value="1" <eq name="$data.status" value="1">checked</eq> >未审核</label>
<label><input type="radio" onclick="unrefund()" name="status" value="2" <eq name="$data.status" value="2">checked</eq> >通过审核</label>
<label><input type="radio" onclick="refund()" name="status" value="3" <eq name="$data.status" value="3">checked</eq> >未通过审核</label>
</div>
</td>
</tr>
<tr class="refund_div" <if condition="$data.status neq 3">style="display: none"</if>>
<th><b>审核不通过原因</b></th>
</tr>
<tr class="refund_div" <if condition="$data.status neq 3">style="display: none"</if>>
<td>
<input class="form-control" type="text" name="refund_reason" value="{$data.refund_reason}">
</td>
</tr>
</table>
</div>
</div>
</form>
</div>
<script type="application/javascript">
function refund() {
$('.refund_div').show()
}
function unrefund() {
$('.refund_div').hide()
}
</script>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
//编辑器路径定义
... ...
... ... @@ -4,7 +4,7 @@
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="{:url('volunteer/index')}">志愿者列表</a></li>
<!--<li><a href="{:url('volunteer/add')}">添加志愿者</a></li>-->
<li><a href="{:url('volunteer/sendNotice')}">发送短信通知</a></li>
</ul>
<form id="forms" class="well form-inline margin-top-20" method="post" action="{:url('volunteer/index')}">
分类:
... ... @@ -21,6 +21,8 @@
<option value='2' <if condition="$type eq 2">selected</if>>社会志愿者</option>
<option value='3' <if condition="$type eq 3">selected</if>>办事处志愿者</option>
</select> &nbsp;&nbsp;
地区:
<input type="text" class="form-control" name="addr" style="width: 150px;" value="{$addr|default=''}" placeholder="请输入地区">&nbsp;&nbsp;
关键字:
<input type="text" class="form-control" name="keyword" style="width: 150px;" value="{$keyword|default=''}" placeholder="请输入关键字">&nbsp;&nbsp;
时间:
... ... @@ -38,7 +40,7 @@
var search="{:url('volunteer/index')}";
var excel="{:url('excels')}";
document.getElementById('search').onclick=function () {
document.getElementById('forms').action=search;
document.getElementById('forms').action=index;
}
document.getElementById('excel').onclick=function () {
document.getElementById('forms').action=excel;
... ... @@ -59,6 +61,7 @@
data-action="{:url('volunteer/delete')}" data-subcheck="true" data-msg="你确定删除吗?">
{:lang('DELETE')}
</button>
</div>
<thead>
<tr>
... ... @@ -69,16 +72,13 @@
</th>
<th>ID</th>
<th>姓名</th>
<th>头像</th>
<th>性别</th>
<th>出生日期</th>
<th>民族</th>
<th>政治面貌</th>
<th>学历</th>
<th>工作单位</th>
<th>更多信息请查看详情</th>
<th>提交时间</th>
<th>更新时间</th>
<th>状态</th>
<th>年龄</th>
<th>地区</th>
<th>总工时</th>
<th>星级</th>
<th>审核状态</th>
<th>操作</th>
</tr>
</thead>
... ... @@ -92,6 +92,11 @@
<td>{$vo.id}</td>
<td>{$vo.name}</td>
<td>
<a href="javascript:parent.imagePreviewDialog('{$vo.photo}');">
<img height="80px" src="{$vo.photo}">
</a>
</td>
<td>
<if condition="$vo.sex eq 0">
未知
<elseif condition="$vo.sex eq 1"/>
... ... @@ -100,14 +105,12 @@
</if>
</td>
<td>{$vo.birthday}</td>
<td>{$vo.nation}</td>
<td>{$vo.politics}</td>
<td>{$vo.education}</td>
<td>{$vo.unit}</td>
<td>……</td>
<td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
<td>{:date('Y-m-d H:i:s',$vo['update_time'])}</td>
<td>
{$vo.age}
</td>
<td>{$vo.province}</td>
<td>{$vo.work_time}</td>
<td>{$vo.level}</td>
<td>
<if condition="$vo.status eq 1">
未审核
... ... @@ -119,7 +122,21 @@
</td>
<td>
<a href='{:url("volunteer/edit",array("id"=>$vo["id"]))}'>查看详情</a>|
<a class="js-ajax-delete" href="{:url('volunteer/delete',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>
<!--<a class="js-ajax-delete" href="{:url('volunteer/delete',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>-->
<a class="js-ajax-delete" href="{:url('volunteer/pass',array('id'=>$vo['id']))}">通过</a>|
<a class="js-ajax-delete" href="{:url('volunteer/unpass',array('id'=>$vo['id']))}">拒绝</a>
<if condition="getUserType($vo['user_id'])== 1">
<a href="{:url('user/adminIndex/is_admin',array('id'=>$vo['user_id']))}"
class="js-ajax-dialog-btn"
data-msg="确定进行测操作?">设为管理员</a>
<else />
<a href="{:url('user/adminIndex/not_is_admin',array('id'=>$vo['user_id']))}"
class="js-ajax-dialog-btn"
data-msg="确定进行测操作?">取消管理员</a>
</if>
</td>
</tr>
</foreach>
... ... @@ -128,6 +145,39 @@
<div class="pagination">{$page}</div>
</form>
</div>
<script type="application/javascript">
var index="{:url('index')}";
var search="{:url('Search')}";
$('#search').onclick()=function () {
console.log('222');
$('#forms').action=search;
}
function sendSms(res) {
var selectedCategoriesId = res
console.log(res)
openIframeLayer("{:url('volunteer/sendSms')}?id=" + selectedCategoriesId, '选择编号', {
area: ['1000px', '900px'],
btn: ['确定','取消'],
yes: function (index, layero) {
//do something
console.log(index)
console.log(layero)
var iframeWin= window[layero.find('iframe')];
var body = layer.getChildFrame('body', index);
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:
iframeWin.load();
//console.log(layer.getFrameIndex(index));
layer.close(index); //如果设定了yes回调,需进行手工关闭
console.log('reload');
location.reload()
}
});
e.stopPropagation()
}
</script>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
... ...
<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:url('index')}">志愿者列表</a></li>
<li class="active"><a href="">添加消息</a></li>
</ul>
<form action="{:url('smsPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
<div class="row">
<div class="col-md-9">
<table class="table table-bordered">
<tr id="checkUserTr">
<th>选择用户<span class="form-required">*</span></th>
<td>
<input class="form-control" type="text" required
placeholder="请选择用户" onclick="doSelectUsers();" id="js-users-name-input"
readonly/>
<input class="form-control" type="hidden" name="to_user_id" value="0"
id="js-users-id-input"/>
</td>
</tr>
<tr>
<th>消息内容</th>
<td>
<textarea class="form-control" name="description" id="description"
style="height: 100px;"
placeholder="请输入消息内容"></textarea>
</td>
</tr>
</table>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary js-ajax-submit">发送消息</button>
<a class="btn btn-default" href="{:url('Message/index')}">{:lang('BACK')}</a>
</div>
</div>
</form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
//编辑器路径定义
var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
$(function () {
var to_user_type=$("input[name=to_user_type]").val();
if(to_user_type==0){
$('#checkUserTr').hide();
}else{
$('#checkUserTr').show();
}
editorcontent = new baidu.editor.ui.Editor();
editorcontent.render('content');
try {
editorcontent.sync();
} catch (err) {
}
$('.btn-cancel-thumbnail').click(function () {
$('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail').val('');
});
});
function checkedUserType(type) {
if(type===0){
$('#checkUserTr').hide();
}else{
$('#checkUserTr').show();
}
}
function doSelectUsers() {
var selectedUsersId = $('#js-users-id-input').val();
openIframeLayer("{:url('volunteer/sendSms')}?ids=" + selectedUsersId, '请选择用户', {
area: ['1200px', '800px'],
btn: ['确定', '取消'],
yes: function (index, layero) {
//do something
var iframeWin = window[layero.find('iframe')[0]['name']];
var selectedUsers = iframeWin.confirm();
if (selectedUsers.selectedUsersId.length == 0) {
layer.msg('请选择用户');
return;
}
$('#js-users-id-input').val(selectedUsers.selectedUsersId.join(','));
$('#js-users-name-input').val(selectedUsers.selectedUsersName.join(' '));
//console.log(layer.getFrameIndex(index));
layer.close(index); //如果设定了yes回调,需进行手工关闭
}
});
}
</script>
</body>
</html>
\ No newline at end of file
... ...
<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap" style="min-width: inherit">
<form class="well form-inline margin-top-20" method="post" action="">
用户ID:
<input class="form-control" type="text" name="uid" style="width: 200px;" value=""
placeholder="用户id">
<input type="submit" class="btn btn-primary" value="搜索"/>
<a class="btn btn-danger" href="">清空</a>
</form>
<form method="post" class="js-ajax-form" action="">
<table class="table table-hover table-bordered table-list">
<thead>
<tr>
<th width="16">
<label>
<input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
</label>
</th>
<th width="50">ID</th>
<th>名称</th>
<th>手机号</th>
</tr>
</thead>
<tbody id="tb">
<foreach name="list" item="vo">
<tr id="check-tr">
<td >
<input type="checkbox" id="in{$vo.id}" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
value="{$vo.move_phone}" data-name="{$vo.name}" >
</td>
<td>{$vo.id}</td>
<td>{$vo.name}</td>
<td>{$vo.move_phone}</td>
</tr>
</foreach>
</tbody>
</table>
</form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
// $('.js-check').click(function(e) {
// var sel_id='in'+e.currentTarget.defaultValue;
//
// $( ".js-check" ).each( function(res) {
// console.log(res)
// $(".js-check").eq(res).prop("checked",false)
// $('#'+sel_id).prop("checked",true)
// } );
// }
//
// )
$('.data-item-tr').click(function (e) {
console.log(e);
var $this = $(this);
if ($(e.target).is('input')) {
return;
}
var $input = $this.find('input');
if ($input.is(':checked')) {
$input.prop('checked', false);
} else {
$input.prop('checked', true);
}
});
function confirm() {
var selectedUsersId = [];
var selectedUsersName = [];
var selectedUsers = [];
$('.js-check:checked').each(function () {
var $this = $(this);
selectedUsersId.push($this.val());
selectedUsersName.push($this.data('name'));
selectedUsers.push({
id: $this.val(),
name: $this.data('name')
});
});
return {
selectedUsers: selectedUsers,
selectedUsersId: selectedUsersId,
selectedUsersName: selectedUsersName
};
}
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -1784,6 +1784,35 @@ function send_sms($data){
$return = $sendAPI->sendSMS('GET');
return $return;
}
function send_duanxinbao($content,$phone){
$site_info=cmf_get_option('site_info');
$userName=$site_info['duanxinbao'];
$Password=md5($site_info['duanxinbaomima']);
$content='【白求恩志愿者】'.$content.'退订回N';
/*$phone='17080088824';
$content='志愿者小程序';*/
if (is_array($phone)){
$phone=implode(',',$phone);
}
$url="http://api.smsbao.com/sms?u=".$userName.'&p='.$Password.'&m='.$phone.'&c='.$content;
$return=cmf_curl_get($url);
return $return;
}
/**
* 获取用户类型
* @param $user_id
* @return mixed
*/
function getUserType($user_id){
$type=\db('user')->where('id',$user_id)->value('type');
return $type;
}
/**
* 生成签名
* @param array $param 要加密的数组
... ... @@ -1853,3 +1882,27 @@ function wxappNotice($message){
return $result;
}
/**
* 获取路径
* @param $url
*/
function get_image_path($url){
$domain='/upload';
$return=strstr($url,$domain);
return $return;
}
/**
* 获取级别
*/
function get_level($time){
$map['min']=['<=',$time];
$map['max']=['>=',$time];
$level=\db('level')->where($map)->value('level');
if (empty($level)){
return 0;
}
return $level;
}
\ No newline at end of file
... ...