<?php

// 获取社会实践活动列表
require_once ("../user_include.inc");

ErrorLogger::doOutput("Compass...ajax_get_socialEvent_event_list.php....Start.", 0);

//获取参数
$unionId = ParamUtil::getRequestString("unionId");

//翻页
$page = ParamUtil::getRequestNumber("page", 0);//翻页

$result = array();

//参数检查
if(empty($unionId)) {
	$result["message"] = "参数错误！";
	responseNG($result);
}

//判断用户是否存在
$param = array();
$param['unionid'] = $unionId;
$param['delete_flg'] = false;
$userList = UserMst::getList($param,'id','desc', 0, 1);
if(empty($userList)) {
	$result["message"] = "用户不存在！";
	responseNG($result);
}

//每页显示条数
$rowCount = 10;
$offset = $page * $rowCount;

$userMst = $userList[0];

//社会实践[todo 以后从别的平台调取数据]
$socialEventEventList = array();
$param = array();
$param['delete_flg'] = false;
$tmpList = SocialEventDat::getList($param,'id','desc', $offset, $rowCount);
$socialEventEvenCount = SocialEventDat::getListCount($param);
$pageCount = ceil($socialEventEvenCount/$rowCount);

//数据加工
if(!empty($tmpList)) {
	foreach($tmpList as $tmp) {
		$tmp->school_title = "#家校平台学校名#";
		$tmp->class_title = "#家校平台班级名#";
		$tmp->publish_time = substr($tmp->publish_time,0,10);
		$socialEventEventList[]= $tmp;
	}
}

//组装返回数据
$result["pageCount"] = $rowCount;
$result["page"] = $page;
$result["socialEventEvenCount"] = $socialEventEvenCount;
$result["socialEventEventList"] = $socialEventEventList;

ErrorLogger::doOutput("Compass...ajax_get_socialEvent_event_list.php....End.", 0);

//返回结果
responseOK($result);

function responseNG($result) {
	$result = array("status"=>"NG", "result"=>$result);
	print json_encode($result);
	exit;
}
function responseOK($result) {
	$result = array("status"=>"OK", "result"=>$result);
	print json_encode($result);
	exit;
}
?>