Exemple #1
0
 /**
  * Delete IDs from given table if they are older than X mn
  *
  *@access private
  *@param string $table Table to clean
  *@param string $fieldname field from table containing timestamp
  *@param int $mins delete IDs older than $mins minutes
  *@return int 1 if success, 0 if error
  */
 function cleanId($table, $fieldname, $mins)
 {
     global $dbauth, $l;
     $this->error = "";
     $date = dateToTimestamp(nowDate());
     $date -= $mins * 60;
     $date = timestampToDate($date);
     $query = "DELETE FROM " . $table . " WHERE\n    " . $fieldname . " < " . $date;
     $res = $dbauth->query($query);
     if ($dbauth->error()) {
         $this->error = $l['str_trouble_with_db'];
         return 0;
     }
     return 1;
 }
 /**
  * 添加学生 第 1 步提交处理.
  * 
  * @access public
  * @return void
  * @author Liuping <*****@*****.**>
  */
 public function addStep1Action()
 {
     // 当前操作, 参见第 1 步中说明.
     $operFlag = intval(I('post.oper', 1));
     $data = I('post.');
     $this->autoFieldMap($data, $this->baseInfoMaps);
     // 转换字段名
     $lastStuId = $data['id'];
     if (empty($lastStuId)) {
         $data['create_time'] = time();
     }
     // 上级中介 uid
     $data['fuid'] = $this->getParentAgentUId();
     $partid = $data['partid'];
     // 部门id, 没有选择部门时计算
     if (empty($partid)) {
         $partid = $this->getDeptId();
     } else {
         $partid = intval($partid);
     }
     $data['partid'] = $partid;
     // 先验证规则.
     $model = new MemberStuModel();
     // 2015-9-1 liuping 增加, 处理表中增加 is_mod 字段作为该学生6项基本信息是否可以修改判断
     $res = TRUE;
     // 验证状态, 默认验证通过
     if (!empty($lastStuId)) {
         $stuInfo = $model->fetchStuInfo($lastStuId);
         if (empty($stuInfo)) {
             $this->error('Parameters error');
         }
         $res = AgentAuth::checkStu(intval($lastStuId), [AgentAuth::WRITE]);
         if (9 !== $res['status']) {
             $this->error('No permission');
         }
         // 是否可以修改, 可以修改就要执行验证规则
         $is_mod = isset($stuInfo['is_mod']) ? intval($stuInfo['is_mod']) : 0;
         if (0 === $is_mod) {
             // 可以修改, 执行验证
             $res = $model->validate($model->baseInfoRules)->create($data);
         } else {
             $res = TRUE;
         }
     } else {
         // 新增时执行的验证
         $res = $model->validate($model->baseInfoRules)->create($data);
     }
     if (!$res) {
         // 验证失败
         $this->error($model->getError());
     }
     // 验证成功规则能过, 验证是否有添加学生的权限
     // 校验一级中介是否有权限添加学生
     if (!AgentAuth::checkTopAgentOfStu($data['uid'])) {
         $this->error('No permission');
     }
     // 验证是否有该学生资料.
     $res1 = $this->checkBaseInfo($data);
     if ($res1) {
         $this->error('This student has been added previously!');
     }
     // 字段规则验证成功且不重名.
     if ($res && !$res1) {
         $data['birth'] = dateToTimestamp($data['birth']);
         $res = $model->procBaseInfo($data);
         if (!$res) {
             // 添加或修改失败
             $this->error('Action failed');
         }
         // 新增时, 获取到最近一次 id
         if (empty($lastStuId)) {
             $lastStuId = $model->getLastInsID();
         }
         // 写入系统日志
         $_mark = session('username') . '在' . date('Y-m-d H:i:s') . ', 编辑了一个学生, 学生姓名: ' . $stuInfo['first_name'] . $stuInfo['family_name'];
         if (2 === $operFlag) {
             // 写入编辑日志
             system_log($_mark, $model->getTableName(), $lastStuId, 'e', $data, $stuInfo, 1);
         }
     }
     $stepUrl = U('addStep2');
     $stuId = $lastStuId;
     $uid = $data['uid'];
     $this->myRedirect('addTrans', $stepUrl, $stuId, $uid, '', $operFlag);
 }
 /**
  * ajax 按申请信息搜索学生.
  *
  * @access public
  * @return void
  * @author Liuping <*****@*****.**>
  */
 public function ajaxApplySearch()
 {
     $post = I('post.');
     // 默认条件值
     $_status_default = ['a_status' => [], 'o_status' => [], 'c_status' => [], 'invalid' => []];
     $_other_default = ['firstAppStartDate' => '', 'firstAppEndDate' => '', 'lastAppStartDate' => '', 'lastAppEndDate' => '', 'school' => '', 'refNo' => '', 'appYear' => ''];
     $_allowSortFields = ['appNum', 'offerNum', 'firstAppDate', 'lastAppDate'];
     // 允许排序的字段
     $_sort_default = ['field' => 'lastAppDate', 'sortby' => 'DESC'];
     // 默认用这个字段排序
     // status 条件
     $statusCond = isset($post['status']) ? $post['status'] : [];
     $statusCond = is_array($statusCond) ? $statusCond : [];
     $statusCond = array_merge($_status_default, $statusCond);
     // 合并 status 条件
     // other 条件
     $otherCond = isset($post['other']) ? $post['other'] : [];
     $otherCond = is_array($otherCond) ? $otherCond : [];
     $otherCond = array_merge($_other_default, $otherCond);
     // 判断几个日期是否有值并转换成时间戳
     $_firstStartDate = $otherCond['firstAppStartDate'];
     $_firstEndDate = $otherCond['firstAppEndDate'];
     $_lastStartDate = $otherCond['lastAppStartDate'];
     $_lastEndDate = $otherCond['lastAppEndDate'];
     if (!empty($_firstStartDate)) {
         $_firstStartDate = dateToTimestamp($_firstStartDate, '/');
         $_firstStartDate = $_firstStartDate === FALSE ? '' : $_firstStartDate;
     } else {
         $_firstStartDate = '';
     }
     if (!empty($_firstEndDate)) {
         $_firstEndDate = dateToEndTimestamp($_firstEndDate, '/');
         $_firstEndDate = $_firstEndDate === FALSE ? '' : $_firstEndDate;
     } else {
         $_firstEndDate = '';
     }
     if (!empty($_lastStartDate)) {
         $_lastStartDate = dateToTimestamp($_lastStartDate, '/');
         $_lastStartDate = $_lastStartDate === FALSE ? '' : $_lastStartDate;
     } else {
         $_lastStartDate = '';
     }
     if (!empty($_lastEndDate)) {
         $_lastEndDate = dateToEndTimestamp($_lastStartDate, '/');
         $_lastEndDate = $_lastEndDate === FALSE ? '' : $_lastEndDate;
     } else {
         $_lastEndDate = '';
     }
     $otherCond['firstAppStartDate'] = $_firstStartDate;
     $otherCond['firstAppEndDate'] = $_firstEndDate;
     $otherCond['lastAppStartDate'] = $_lastStartDate;
     $otherCond['lastAppEndDate'] = $_lastEndDate;
     // 申请年份
     $appYear = isset($otherCond['appYear']) ? $otherCond['appYear'] : date('Y', time());
     $appYear = is_numeric($appYear) ? intval($appYear) : intval(date('Y', time()));
     // 排序
     $sortCond = isset($post['sort']) ? $post['sort'] : [];
     $sortCond = is_array($sortCond) ? $sortCond : [];
     $sortCond = array_merge($_sort_default, $sortCond);
     // 最终条件
     $post = ['sort' => $sortCond, 'other' => $otherCond, 'status' => $statusCond];
     $service = new StudentApplySearchService();
     $result = $service->applySearch($post, TRUE, 20);
     $this->assign('arrSort', $sortCond);
     $this->assign('lists', $result['lists']);
     $this->assign('pageList', $result['pageList']);
     $this->assign('totalList', $result['totalList']);
     $this->display();
 }
 /**
  * @购物车下单,批量处理第一步
  * @Author: 段涛
  * @FunctionName: actionShopCarOne
  */
 public function actionShopCarOne()
 {
     if (IS_POST) {
         $universityID = I('post.universityID');
         $majorID = I('post.majorID');
         $year = I('post.year');
         $month = I('post.month');
         $majorType = I('post.majorType');
         $statusModel = M('apply_status');
         $uid = session('uid');
         $this->checkStudentID();
         //检测户学生ID;
         //            $anoList=unserialize(session ('appNumber'));//获取批量申请编号集
         //            if($anoList){//如果有申请单号及判断点击过返回退到第一步
         //                M('apply_status')->where(array('a_no'=>array('in',$anoList['ano'])))->delete();
         //
         //                $num=M( 'apply_student' )->where(array('s_id'=>cookie('s_id'),'app_year'=>$year[0]))->getField('num');
         //                $currentNum=count($anoList['ano']);
         //                if($num-$currentNum<0){
         //                    $currentNum=$num;
         //                }
         //                M( 'apply_student' )->where(array('s_id'=>cookie('s_id'),'app_year'=>$year[0]))->setDec('num',$currentNum);
         //            }
         //            session('appNumber',null);
         //用户基础信息
         $user['inf'] = I('post.inf');
         $user['inf']['partid'] = '-1';
         //DIY判断
         $user['inf']['uid'] = session('uid');
         $user['inf']['date_of_birth'] = dateToTimestamp($user['inf']['date_of_birth']);
         $user['inf']['s_id'] = cookie('s_id');
         //学生ID
         $user['inf']['create_time'] = time();
         $user['inf']['fuid'] = 0;
         //判断是否用户使用锁定表内容
         $member_stu = M('member_stu')->field('family_name,first_name,sex,birth,country,nationality,is_mod')->where(array('uid' => session('uid')))->find();
         if ($member_stu['is_mod'] == 1) {
             $user['inf']['family_name'] = $member_stu['family_name'];
             $user['inf']['given_name'] = $member_stu['first_name'];
             $user['inf']['gender'] = $member_stu['sex'];
             $user['inf']['date_of_birth'] = $member_stu['birth'];
             $user['inf']['country_of_birth'] = $member_stu['country'];
             $user['inf']['nationality'] = $member_stu['nationality'];
         }
         //用户其他信息信息数据
         $user['other'] = I('post.other');
         $user['other']['create_time'] = time();
         $user['other']['partid'] = '-1';
         //DIY判断
         $user['other']['uid'] = session('uid');
         $user['other']['s_id'] = cookie('s_id');
         //学生ID
         if ($user['other']['ever_to_britain'] != 'yes') {
             $user['other']['visa_type'] = '';
             $user['other']['date_of_expriy'] = '';
             $user['other']['date_of_first_entry'] = '';
         }
         if ($user['other']['whoes_payfor'] != "Other") {
             $user['other']['whoes_payfor_name'] = '';
             $user['other']['payfor_relation'] = '';
         }
         if ($user['other']['is_difficulty'] != "yes") {
             $user['other']['specify_difficulty'] = '';
             $user['other']['difficulty_desc'] = '';
         }
         //数据库
         $member = M('member');
         //用户基本数据库
         $member->startTrans();
         $member_other = M('member_other');
         //用户其他数据库
         $member_other->startTrans();
         $apply_status = M('apply_status');
         //申请状态表
         $apply_status->startTrans();
         $result2 = $this->checkDB(session('uid'), $user['inf'], 'member');
         //更新用户基本资料
         $result3 = $this->checkDB(session('uid'), $user['other'], 'member_other');
         //更新用户基本其他资料
         $result1 = $this->upDataStudentIDInf($user['inf']);
         //更新学生基本6大信息表
         $isSaveOk = true;
         //初始一个成功值
         $anoList = unserialize(session('appNumber'));
         //获取批量申请编号集
         //            if($anoList){//如果有申请单号及判断点击过返回退到第一步
         //                M('apply_status')->where(array('a_no'=>array('in',$anoList['ano'])))->delete();
         //
         //                $num=M( 'apply_student' )->where(array('s_id'=>cookie('s_id'),'app_year'=>$year[0]))->getField('num');
         //                $currentNum=count($anoList['ano']);
         //                if($num-$currentNum<0){
         //                    $currentNum=$num;
         //                }
         //                M( 'apply_student' )->where(array('s_id'=>cookie('s_id'),'app_year'=>$year[0]))->setDec('num',$currentNum);
         //            }
         //            session('appNumber',null);
         $i = 0;
         $appNumber['ano'] = array();
         foreach ($universityID as $k => $rs) {
             //循环写入数据库
             if ($isSaveOk !== false) {
                 //专业信息
                 $user['inf']['usid'] = $rs;
                 $user['inf']['mjid'] = $majorID[$k];
                 $user['inf']['type'] = $majorType[$k];
                 $user['inf']['month'] = $month[$k];
                 //保存到数据库
                 $a_no = '';
                 if ($anoList) {
                     //如果有申请单号及判断点击过返回退到第一步
                     $a_no = $anoList['ano'][$i];
                     $appNumber['ano'][] = $user['inf']['a_no'] = $user['other']['a_no'] = $a_no;
                 } else {
                     $a_no = date('YmdHis') . rand(1, 9999);
                     $appNumber['ano'][] = $user['inf']['a_no'] = $user['other']['a_no'] = $a_no;
                     $result8 = $this->updataAppTimes(cookie('s_id'), $year[$k]);
                     //更新申请次数
                 }
                 $result4 = $member->add($user['inf']);
                 $result5 = $member_other->add($user['other']);
                 $result6 = $this->updataMember_stu($user['inf'], $a_no, $year[$k]);
                 //更新申请状态记录表
                 $result7 = $this->appStepLog($a_no, 1);
                 //更新申请步凑
                 if ($result4 !== false && $result5 !== false && $result6 !== false && $result7 !== false && $result8 !== false) {
                     $isSaveOk = true;
                 } else {
                     $isSaveOk = false;
                 }
                 $i++;
             }
         }
         if ($anoList && $i != count($anoList['ano'])) {
             //点击返回并提交申请后申请数量是否减少
             M('apply_status')->where(array('a_no' => array('not in', $appNumber['ano']), 'id' => array('in', session('STATUS_')), 'uid' => $uid, 'fuid' => 0))->delete();
             $sql = M('apply_status')->getLastSql();
             $currentNum = count($anoList['ano']) - $i;
             M('apply_student')->where(array('s_id' => cookie('s_id'), 'app_year' => $year[0]))->setDec('num', $currentNum);
         }
         if ($isSaveOk !== false && $result2 !== false && $result3 !== false && $result1 !== false) {
             $member->commit();
             $member_other->commit();
             $appNumber['step'] = 1;
             if ($appNumber) {
                 session('appNumber', serialize($appNumber));
             }
             $this->redirect('/Apply/shopCarStep2', 0);
             //跳转到第二步
         } else {
             $member->rollback();
             $member_other->rollback();
             $this->error('SAVE DATE FALSE');
         }
     }
 }
Exemple #5
0
 /**
  * 排序处理用于修改学生所属区域的教育背景信息.
  * 学位排名一样, 按毕业日期排序.
  * 
  * @access private
  * @param array $eduBackInfo 二维数组.
  * @return string 国家名称
  * @author Liuping <*****@*****.**> 
  */
 public function sortEduForModArea_bak($eduBackInfo)
 {
     // 学位排名, 数字越小排名越高
     //'Diploma', 'HND', 'Bachelor', 'Master', 'Other'
     $arrQua = [1 => 'Master', 2 => 'Bachelor', 3 => 'HND', 4 => 'Diploma', 5 => 'Other'];
     $newEduBackInfo = [];
     foreach ($eduBackInfo as $row) {
         $_qua = $row['qualification'];
         if (FALSE !== stripos($_qua, 'other')) {
             $_qua = 'Other';
         }
         // 该学位的排名
         $_index = array_search($_qua, $arrQua, TRUE);
         if (FALSE !== $_index) {
             $_gradtime = dateToTimestamp($row['graduation_date'], '/');
             $_new_row = ['country' => $row['institution_country'], 'qua' => $_index, 'gradetime' => $_gradtime];
             $newEduBackInfo[] = $_new_row;
         }
     }
     unset($eduBackInfo);
     // 排序, 先按
     multi_array_sort($newEduBackInfo, 'qua', SORT_ASC, 'gradetime', SORT_DESC);
     $newEduBackInfo = array_values($newEduBackInfo);
     $result = isset($newEduBackInfo[0]) ? $newEduBackInfo[0]['country'] : '';
     return $result;
 }
Exemple #6
0
function datetimeToTimestamp($datetime)
{
    if ($datetime == "") {
        return 0;
    }
    $parts = explode(" ", $datetime);
    return dateToTimestamp($parts[0], $parts[1]);
}
 /**
  *ajax保存用户基本资料
  *Editor : 段涛
  *Function name : savePersonalInfo
  */
 public function savePersonalInfo()
 {
     //会员基本信息
     if (IS_AJAX) {
         $data = I('post.');
         $data['date_of_birth'] = dateToTimestamp($data['date_of_birth']);
         $find = M('member')->where(array('a_no' => $data['a_no']))->find();
         $result['status'] = false;
         //初始状态
         if ($find) {
             $success = M('member')->where(array('id' => $find['id']))->save($data);
             //更新资料
             if ($success !== false) {
                 $result['status'] = true;
                 system_log(session('adminUser') . "在" . date('Y-m-d H:i:s') . "修改学生个人申请信息申请资料,申请编号" . $data['a_no'], 'app_member', 'a_no', 'e', $data, $find, 0);
             }
         } else {
             $result['error'] = "Can't find user information";
         }
         $this->ajaxReturn($result, 'json');
     }
 }
$cssFiles = array('reset', 'grid_r12', 'fonts', 'template');
// Handle any specific requests regarding css loaded
if (isset($_GET['home']) && $_GET['home']) {
    $cssFiles[] = 'home';
}
// check last modified times
foreach ($cssFiles as $file) {
    if (is_file($tmp = './' . $file . '.css')) {
        $modTimes[$file] = filemtime($tmp);
    }
}
// Get last modified time of file
//$modTimes['shared'] = getlastmod();
// exit out of script if cached on client
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
    $cliModTime = dateToTimestamp($_SERVER['HTTP_IF_MODIFIED_SINCE']);
    if (max($modTimes) <= $cliModTime) {
        header('HTTP/1.x 304 Not Modified');
        exit;
    }
}
/**
 * send last modified date of file to client so it will have date for server
 * on next request.
 * Technically we could just send the current time (as PEAR does) rather
 * than the actual modify time of the file since either way would get the
 * correct behavior, but since we already have the actual modified time of
 * the file, we'll just use that.
 */
$srvModDate = timestampToDate(max($modTimes));
header("Last-Modified: {$srvModDate}");
 /**
  *ajax保存用户基本资料
  *Editor : 段涛
  *Function name : savePersonalInfo
  */
 public function savePersonalInfo()
 {
     //会员基本信息
     if (IS_AJAX) {
         $data = I('post.');
         if ($data['date_of_birth'] != "") {
             $data['date_of_birth'] = dateToTimestamp($data['date_of_birth']);
         }
         $find = M('member')->where(array('uid' => session('uid'), 'a_no' => ''))->getField('id');
         $result['status'] = false;
         //初始状态
         if ($find) {
             $success = M('member')->where(array('uid' => session('uid'), 'a_no' => ''))->save($data);
             //更新资料
             //更新member_stu表中的用户资料
             $memberInf['family_name'] = $data['family_name'];
             $memberInf['first_name'] = $data['given_name'];
             $memberInf['sex'] = $data['gender'];
             $memberInf['birth'] = $data['date_of_birth'];
             $memberInf['country'] = $data['country_of_birth'];
             $memberInf['nationality'] = $data['nationality'];
             M('member_stu')->where(array('is_mod' => 0, 'uid' => session('uid')))->save($memberInf);
             if ($success !== false) {
                 $result['status'] = true;
             }
         } else {
             $data['uid'] = session('uid');
             $data['partid'] = -1;
             $data['a_no'] = '';
             $data['create_time'] = time();
             $success = M('member')->add($data);
             //添加资料
             if ($success !== false) {
                 $result['status'] = true;
             }
         }
         $this->ajaxReturn($result, 'json');
     }
 }