예제 #1
0
파일: Cycle.php 프로젝트: bjtenao/tudu-web
 /**
  * 格式化周期任务参数
  *
  * @param array  $params
  * @param string $suffix
  * @return array
  */
 public function formatParams($params, $suffix = '')
 {
     $cycle = array();
     if (!empty($params['cycleid' . $suffix])) {
         $cycle['cycleid'] = $params['cycleid' . $suffix];
     } else {
         $cycle['cycleid'] = Dao_Td_Tudu_Cycle::getCycleId();
     }
     $cycle['mode'] = $params['mode' . $suffix];
     $cycle['endtype'] = $params['endtype' . $suffix];
     $cycle['displaydate'] = $params['displaydate' . $suffix];
     // 重复范围
     if ($cycle['endtype'] == Dao_Td_Tudu_Cycle::END_TYPE_COUNT) {
         $cycle['endcount'] = (int) $params['endcount' . $suffix];
     } elseif ($cycle['endtype'] == Dao_Td_Tudu_Cycle::END_TYPE_DATE) {
         $cycle['enddate'] = @strtotime($params['enddate' . $suffix]);
     } else {
         $cycle['endtype'] = Dao_Td_Tudu_Cycle::END_TYPE_NONE;
     }
     if ($cycle['displaydate'] == 1 && empty($params['starttime' . $suffix])) {
         $params['starttime'] = time();
     }
     $cycle['type'] = (int) $params['type' . '-' . $cycle['mode'] . $suffix];
     $prefix = $cycle['mode' . $suffix] . '-' . $cycle['type' . $suffix] . '-';
     $cycle['day'] = isset($params[$prefix . 'day' . $suffix]) ? (int) $params[$prefix . 'day' . $suffix] : 0;
     $cycle['week'] = isset($params[$prefix . 'week' . $suffix]) ? (int) $params[$prefix . 'week' . $suffix] : 0;
     $cycle['month'] = isset($params[$prefix . 'month' . $suffix]) ? (int) $params[$prefix . 'month' . $suffix] : 0;
     $cycle['iskeepattach'] = !empty($params['iskeepattach' . $suffix]) ? 1 : 0;
     if (isset($params[$prefix . 'weeks'])) {
         $cycle['weeks'] = implode(',', $params[$prefix . 'weeks' . $suffix]);
     }
     if (isset($params[$prefix . 'at'])) {
         $cycle['at'] = (int) $params[$prefix . 'at' . $suffix];
     }
     if (isset($params[$prefix . 'what'])) {
         $cycle['what'] = $params[$prefix . 'what' . $suffix];
     }
     if (!empty($params['starttime' . $suffix]) && !empty($params['endtime' . $suffix])) {
         $cycle['period'] = Oray_Function::dateDiff('d', strtotime($params['starttime' . $suffix]), strtotime($params['endtime' . $suffix]));
     }
     return $cycle;
 }
예제 #2
0
 /**
  * 查看图度内容
  *
  */
 public function viewAction()
 {
     $tudu = $this->_tudu;
     $votes = array();
     $isForward = (bool) $this->_request->getQuery('forward');
     $isAccepter = $this->_tudu->role == Dao_Td_Tudu_Tudu::ROLE_ACCEPTER;
     $isCC = !$isAccepter;
     /* @var $daoTudu Dao_Td_Tudu_Tudu */
     $daoTudu = $this->getDao('Dao_Td_Tudu_Tudu');
     $access = array('view' => true, 'forward' => $isAccepter, 'reply' => $isCC || $isAccepter, 'accept' => $isAccepter && !$tudu->selfAcceptTime && $this->_tudu->selfTuduStatus < 2, 'reject' => $isAccepter && $this->_tudu->selfTuduStatus < 2, 'progress' => $isAccepter && $tudu->selfAcceptTime, 'upload' => true, 'claim' => false, 'agree' => false, 'disagree' => false);
     $upload = $this->_options['upload'];
     $upload['cgi']['upload'] .= '?authtype=foreign&' . session_name() . '=' . $this->_sessionId . '&email=' . $this->_session->auth['address'];
     //var_dump(serialize($_SESSION));
     $this->view->registModifier('tudu_format_content', array($this, 'formatContent'));
     $this->view->registModifier('tudu_get_attachment_url', array($this, 'getAttachmentUrl'));
     $this->view->upload = $upload;
     // 草稿,显示编辑界面
     if ($isForward) {
         $access = array('upload' => true);
         $attachments = array();
         if ($tudu->cycleId) {
             $daoCycle = $this->getDao('Dao_Td_Tudu_Cycle');
             $cycle = $daoCycle->getCycle(array('cycleid' => $tudu->cycleId));
             $this->view->cycle = $cycle->toArray();
         }
         $type = $tudu->type;
         $tudu = $tudu->toArray();
         if ($isForward) {
             $tudu['to'] = array();
             $tudu['cc'] = array();
             $this->view->action = 'forward';
         }
         $daoClass = $this->getDao('Dao_Td_Tudu_Class');
         $classes = $daoClass->getClassesByBoardId($this->_tudu->orgId, $tudu['boardid'], array('ordernum' => 'ASC'));
         // 处理快捷板块
         $attentions = array('children' => array());
         $boards = array();
         if ($isForward) {
             $daoBoard = $this->getDao('Dao_Td_Board_Board');
             $board = $daoBoard->getBoard(array('orgid' => $this->_tudu->orgId, 'boardid' => $tudu['boardid']));
             $boards[] = $board->toArray();
         }
         $users = $this->_deliver->getTuduUsers($this->_tudu->tuduId);
         $this->view->classes = $classes->toArray();
         $this->view->users = $users;
         $this->view->boards = $boards;
         $this->view->tudu = $tudu;
         $this->view->access = $access;
         $this->view->isforward = $isForward;
         $this->render('modify_' . $type);
         return;
     }
     // 会议信息
     if ($tudu->type == 'meeting') {
         $daoMeeting = $this->getDao('Dao_Td_Tudu_Meeting');
         $meeting = $daoMeeting->getMeeting(array('tuduid' => $tudu->tuduId));
         if (null !== $meeting) {
             $this->view->meeting = $meeting->toArray();
         }
     }
     // 读取投票
     if ($tudu->special == Dao_Td_Tudu_Tudu::SPECIAL_VOTE) {
         /**
          * @var Dao_Td_Tudu_Vote
          */
         $daoVote = $this->getDao('Dao_Td_Tudu_Vote');
         $votes = $daoVote->getVotesByTuduId($tudu->tuduId);
         $votes = $votes->toArray();
         $votes = $daoVote->formatVotes($votes);
         foreach ($votes as $voteId => &$vote) {
             // 统计参与人
             $vote['countvoter'] = $daoVote->countVoter($tudu->tuduId, $voteId);
             $isVoted = $daoVote->hasVote($tudu->tuduId, $voteId, $this->_user['uniqueid']);
             $expired = !empty($vote['expiretime']) && time() > $vote['expiretime'] + 86400;
             $vote['expired'] = $expired;
             $vote['isvoted'] = $isVoted;
             $vote['enabled'] = !$isVoted && !$expired;
         }
     }
     // 读取周期任务信息
     /* @var $daoCycle Dao_Td_Tudu_Cycle */
     $daoCycle = $this->getDao('Dao_Td_Tudu_Cycle');
     if ($cycle = $daoCycle->getCycle(array('cycleid' => $tudu->cycleId))) {
         $this->view->cycleremind = $this->_formatCycleInfo($cycle->toArray(), $tudu);
     }
     // 处理任务相关逻辑
     if ($tudu->type == 'task') {
         // 任务类权限的特殊过滤
         // 已确认完成时,禁止操作的权限
         if ($tudu->isDone) {
             $access['reply'] = false;
         }
         // 已完成(完成、取消、拒绝)时,禁止操作的权限
         if ($isAccepter && $tudu->selfTuduStatus >= Dao_Td_Tudu_Tudu::STATUS_DONE) {
             $access['accept'] = false;
             $access['reject'] = false;
             $access['forward'] = false;
             if (count($tudu->accepter) > 1 && $tudu->selfTuduStatus >= Dao_Td_Tudu_Tudu::STATUS_DONE) {
                 $access['progress'] = false;
             }
         }
         if ($tudu->stepId && strpos($tudu->stepId, '^') !== 0) {
             /* @var $daoStep Dao_Td_Tudu_Step */
             $daoStep = $this->getDao('Dao_Td_Tudu_Step');
             $step = $daoStep->getCurrentStep($tudu->tuduId, $tudu->stepId, $this->_user['uniqueid']);
             if (null !== $step && $step['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE) {
                 if ($step['uniqueid'] == $this->_user['uniqueid'] && $step['status'] == 1 && !$tudu->isDone) {
                     $access['agree'] = true;
                     $access['disagree'] = true;
                 }
                 $access['forward'] = false;
                 $access['accept'] = false;
                 $access['reject'] = false;
                 $access['progress'] = false;
             }
         }
         if ($tudu->status >= Dao_Td_Tudu_Tudu::STATUS_DONE) {
             $access['progress'] = false;
             $access['accept'] = false;
             $access['reject'] = false;
             $access['forward'] = false;
         }
         if ($isAccepter && $tudu->acceptMode && !$tudu->acceptTime) {
             $access['claim'] = true;
             $access['forward'] = false;
             $access['accept'] = false;
             $access['reject'] = false;
             $access['progress'] = false;
             $access['agree'] = false;
             $access['disagree'] = false;
         }
         $remind = '';
         $to = array();
         foreach ($tudu->to as $u) {
             $to[] = $u[0];
         }
         $to = implode($this->lang['comma'], $to);
         if ($tudu->lastForwarder) {
             $remind .= sprintf($this->lang['forward_info'], $tudu->from[0], date('Y-m-d H:i:s', $tudu->lastForwardTime), $tudu->lastForwarder, $to);
         } elseif ($tudu->acceptMode && !$tudu->acceptTime) {
             $remind .= sprintf($this->lang['claim_info'], $tudu->from[0], $to);
         } elseif ($tudu->acceptMode && $tudu->acceptTime) {
             $remind .= sprintf($this->lang['claim_accepter_info'], $tudu->from[0], $to);
         } else {
             $remind .= sprintf($this->lang['send_info'], $tudu->from[0], $to);
         }
         if ($tudu->accepter) {
             if ($isAccepter) {
                 // 已过期
                 if ($tudu->isExpired) {
                     $remind .= sprintf($this->lang['remind_expried'], Oray_Function::dateDiff('d', $tudu->endTime, time()));
                     // 未接受
                 } elseif (!$tudu->acceptMode && !$tudu->selfAcceptTime && $tudu->selfTuduStatus <= Dao_Td_Tudu_Tudu::STATUS_DOING) {
                     if ($tudu->endTime) {
                         $remind .= sprintf($this->lang['remind_time_left'], Oray_Function::dateDiff('d', time(), $tudu->endTime) + 1) . sprintf($this->lang['remind_unaccepted'], $tudu->from[0]);
                     } else {
                         $remind .= sprintf($this->lang['remind_unaccepted'], $tudu->from[0]);
                     }
                 }
             }
             $this->view->remind = $remind;
         }
         // 会议
     } elseif ($tudu->type == 'meeting') {
         $access['forward'] = false;
         $access['progress'] = false;
         if ($tudu->isDone) {
             $access['reply'] = false;
             $access['modify'] = false;
         }
         // 显示发起人提醒信息
         if ($isAccepter && $meeting) {
             $startTime = $meeting->isAllday ? date('Y-m-d', $tudu->startTime) : date('Y-m-d H:i', $tudu->startTime);
             $remind = sprintf($this->lang['remind_meeting_left'], $tudu->from[0], $startTime);
             // 未接受
             if (!$tudu->selfAcceptTime) {
                 $remind .= $this->lang['remind_meeting_accept'];
             }
             $this->view->remind = $remind;
         }
     } else {
         $access['accept'] = false;
         $access['reject'] = false;
         $access['forward'] = false;
         $access['progress'] = false;
         $access['review'] = false;
         $access['reply'] &= !$tudu->isDone;
     }
     // 增加浏览次数
     $daoTudu->hit($tudu->tuduId);
     // 读取回复列表
     $uniqueId = $this->_request->getQuery('unid');
     $back = $this->_request->getQuery('back');
     $recordCount = $tudu->replyNum + 1;
     $pageSize = 20;
     $isInvert = $this->_request->getQuery('invert', 0);
     $page = max(1, (int) $this->_request->getQuery('page', 1));
     $query = array('tid' => $tudu->tuduId, 'back' => $back, 'invert' => $isInvert);
     $condition = array('tuduid' => $tudu->tuduId);
     /* @var $daoPost Dao_Td_Tudu_Post */
     $daoPost = $this->getDao('Dao_Td_Tudu_Post');
     if ($uniqueId) {
         $condition['uniqueid'] = $uniqueId;
         $query['unid'] = $uniqueId;
         $recordCount = $daoPost->getPostCount($tudu->tuduId, $uniqueId);
     }
     $pageCount = intval(($recordCount - 1) / $pageSize) + 1;
     $isLast = false;
     if ($page == 'last') {
         $page = $pageCount;
         $isLast = true;
     } else {
         $page = min($pageCount, max(1, (int) $page));
     }
     $postSort = $isInvert ? 'createtime DESC' : 'createtime ASC';
     // 获取回复内容
     $posts = $daoPost->getPostPage($condition, $postSort, $page, $pageSize)->toArray();
     // 回复者的在线状态
     $status = array();
     // 回复的相关权限
     $postAccess = array('modify' => false, 'delete' => false);
     foreach ($posts as $key => $post) {
         // 公告过滤不可见的回复
         if ($tudu->type == 'notice' && !$post['isfirst'] && !in_array('^v', $tudu->labels) && !in_array('^e', $tudu->labels)) {
             unset($posts[$key]);
             continue;
         }
         // 读取回复的附件信息
         if ($post['attachnum'] > 0) {
             $files = $this->getDao('Dao_Td_Attachment_File')->getFiles(array('tuduid' => $tudu->tuduId, 'postid' => $post['postid']));
             $posts[$key]['attachment'] = $files->toArray();
         }
         // 权限
         if (!$post['isfirst'] && !$tudu->isDone) {
             $posts[$key]['access'] = array('modify' => $postAccess['modify'] && $post['uniqueid'] == $this->_user->uniqueId, 'delete' => $postAccess['delete'] && $post['uniqueid'] == $this->_user->uniqueId);
         }
         if ($post['header']) {
             $posts[$key]['header'] = $this->formatPostHeader($post['header']);
         }
         if ($post['email']) {
             if (!array_key_exists($post['email'], $status)) {
                 $status[$post['email']] = false;
             }
             $posts[$key]['imstatus'] =& $status[$post['email']];
         }
     }
     $isDisagreed = false;
     if ($tudu->type == 'task' && $tudu->stepNum > 0) {
         $daoStep = $this->getDao('Dao_Td_Tudu_Step');
         $users = $daoStep->getTuduStepUsers($tudu->tuduId);
         $steps = array();
         $isExceed = false;
         foreach ($users as &$user) {
             $info = explode(' ', $user['userinfo']);
             $user['email'] = $info[0];
             $user['truename'] = $info[1];
             if (!$isExceed && $user['stepid'] == $tudu->stepId) {
                 $isExceed = true;
             }
             if ($isExceed && ($user['stepid'] != $tudu->stepId || $user['type'] == 1 && $user['status'] < 1)) {
                 $user['future'] = true;
             }
             $steps[$user['ordernum']]['users'][] = $user;
             $steps[$user['ordernum']]['stepid'] = $user['stepid'];
             $steps[$user['ordernum']]['type'] = $user['type'];
             $steps[$user['ordernum']]['future'] = !empty($user['future']);
             if ($user['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE && $user['status'] > 2) {
                 $access['progress'] = false;
                 $access['divide'] = false;
                 $isDisagreed = true;
             }
         }
         ksort($steps);
         if (!$isDisagreed && count($steps)) {
             $lastStep = end($steps);
             if ($lastStep['type'] == 0) {
                 $arrTo = array();
                 foreach ($lastStep['users'] as $u) {
                     $arrTo[$u['email']] = array($u['truename'], null, null, $u['email']);
                 }
                 $tudu->to = $arrTo;
                 if (!isset($arrTo[$this->_user['email']])) {
                     $access['accept'] = false;
                     $access['reject'] = false;
                 }
             }
             reset($steps);
         }
         if (count($steps) > 1) {
             $this->view->steps = $steps;
         }
     }
     $this->view->tudu = $tudu->toArray();
     $this->view->posts = $posts;
     $this->view->pageinfo = array('currpage' => $page, 'pagecount' => $pageCount, 'pagesize' => $pageSize, 'recordcount' => $recordCount, 'query' => $query, 'url' => '/tudu/view');
     $this->view->last = $isLast;
     //$this->view->cookies= serialize($cookies);
     $this->view->votes = $votes;
     $this->view->query = $query;
     $this->view->access = $access;
     $this->view->isinvert = $isInvert;
     return $this->render('view_' . $tudu->type);
 }
예제 #3
0
 /**
  * Construct
  *
  * @param array $record
  */
 public function __construct(array $record)
 {
     $this->orgId = $record['orgid'];
     $this->boardId = $record['boardid'];
     $this->tuduId = $record['tuduid'];
     $this->classId = $record['classid'];
     $this->className = $record['classname'];
     $this->type = $record['type'];
     $this->subject = $record['subject'];
     $this->from = Dao_Td_Tudu_Tudu::formatAddress($record['from'], true);
     $this->to = Dao_Td_Tudu_Tudu::formatAddress($record['to']);
     $this->cc = Dao_Td_Tudu_Tudu::formatAddress($record['cc']);
     $this->priority = $this->_toInt($record['priority']);
     $this->privacy = $this->_toInt($record['privacy']);
     $this->attachNum = $this->_toInt($record['attachnum']);
     $this->lastPostTime = $this->_toTimestamp($record['lastposttime']);
     $this->lastPoster = $record['lastposter'];
     $this->posterInfo = $record['posterinfo'];
     $this->viewNum = $record['viewnum'];
     $this->replyNum = $this->_toInt($record['replynum']);
     $this->logNum = $this->_toInt($record['lognum']);
     $this->startTime = $this->_toTimestamp($record['starttime']);
     $this->endTime = $this->_toTimestamp($record['endtime']);
     $this->acceptTime = $this->_toTimestamp($record['accepttime']);
     $this->createTime = $this->_toTimestamp($record['createtime']);
     $this->percent = $this->_toInt($record['percent']);
     $this->status = $this->_toInt($record['status']);
     $this->special = $this->_toInt($record['special']);
     $this->uniqueId = $record['uniqueid'];
     $this->isRead = $this->_toBoolean($record['isread']);
     $this->isForward = $this->_toBoolean($record['isforward']);
     $this->isDone = $this->_toBoolean($record['isdone']);
     $this->labels = $this->_toArray($record['labels']);
     $this->nodeType = isset($record['nodetype']) ? $record['nodetype'] : null;
     $this->parentId = isset($record['parentid']) ? $record['parentid'] : null;
     $this->isTuduGroup = in_array($this->nodeType, array(Dao_Td_Tudu_Group::TYPE_NODE, Dao_Td_Tudu_Group::TYPE_ROOT));
     $this->selfPercent = isset($record['selfpercent']) ? $this->_toInt($record['selfpercent']) : null;
     $this->role = !empty($record['role']) ? $record['role'] : null;
     $this->selfTuduStatus = isset($record['selftudustatus']) ? $this->_toInt($record['selftudustatus']) : null;
     $this->selfAcceptTime = isset($record['selfaccepttime']) ? $this->_toTimestamp($record['selfaccepttime']) : null;
     $this->isExpired = $this->endTime && $this->status <= Dao_Td_Tudu_Tudu::STATUS_DOING && Oray_Function::dateDiff('d', $this->endTime, time()) > 0;
     if (isset($this->from[3])) {
         $this->sender = $this->from[3];
     }
     $this->accepter = !empty($this->to) ? array_keys($this->to) : array();
     if (isset($record['forwardinfo']) || isset($record['lastforward'])) {
         $forwardInfo = count($this->accepter) > 1 ? $record['forwardinfo'] : $record['lastforward'];
         $array = explode("\n", $forwardInfo);
         if (count($array) == 2) {
             $this->lastForwarder = $array[0];
             $this->lastForwardTime = $this->_toInt($array[1]);
         }
     }
     parent::__construct();
 }
예제 #4
0
 /**
  *
  * @param array  $params
  * @param string $suffix
  */
 private function _getCycleParams(array $params, $suffix = '')
 {
     $keys = array('cycleid' => array('type' => 'string'), 'mode' => array('type' => 'string'), 'endtype' => array('type' => 'int'), 'displaydate' => array('type' => 'boolean'), 'starttime' => array('type' => 'date'), 'keepattach' => array('type' => 'boolean'), 'type' => array('type' => 'int', 'key' => 'type-%mode'), 'day' => array('type' => 'int', 'key' => '%mode-%type-day'), 'week' => array('type' => 'int', 'key' => '%mode-%type-week'), 'month' => array('type' => 'int', 'key' => '%mode-%type-month'));
     $ret = array('mode' => 'day', 'type' => 1);
     foreach ($keys as $col => $item) {
         $key = isset($item['key']) ? str_replace(array('%mode', '%type'), array($ret['mode'], $ret['type']), $item['key']) : $col . $suffix;
         $val = isset($params[$key]) ? $params[$key] : null;
         switch ($item['type']) {
             case 'int':
                 $ret[$col] = (int) $val;
                 break;
             case 'date':
                 $ret[$col] = is_numeric($val) ? (int) $val : strtotime($val);
                 break;
             case 'boolean':
                 $ret[$col] = (bool) $val;
                 break;
             case 'string':
             default:
                 $ret[$col] = trim($val);
                 break;
         }
     }
     if (Dao_Td_Tudu_Cycle::END_TYPE_COUNT == $params['endtype']) {
         $ret['endcount'] = !empty($params['endcount' . $suffix]) ? $params['endcount' . $suffix] : 1;
     }
     if (Dao_Td_Tudu_Cycle::END_TYPE_DATE == $params['endtype']) {
         $ret['enddate'] = !empty($params['enddate' . $suffix]) ? $params['enddate' . $suffix] : strtotime(date('Y-m-d'));
     }
     if (empty($ret['cycleid'])) {
         $ret['cycleid'] = Dao_Td_Tudu_Cycle::getCycleId();
     }
     $prefix = $ret['mode'] . '-' . $ret['type'] . '-';
     if (isset($params[$prefix . 'weeks'])) {
         $ret['weeks'] = implode(',', $params[$prefix . 'weeks' . $suffix]);
     }
     if (isset($params[$prefix . 'at'])) {
         $ret['at'] = (int) $params[$prefix . 'at' . $suffix];
     }
     if (isset($params[$prefix . 'what'])) {
         $ret['what'] = $params[$prefix . 'what' . $suffix];
     }
     if (!empty($params['starttime' . $suffix]) && !empty($params['endtime' . $suffix])) {
         $ret['period'] = Oray_Function::dateDiff('d', strtotime($params['starttime' . $suffix]), strtotime($params['endtime' . $suffix]));
     }
     return $ret;
 }
예제 #5
0
파일: Attend.php 프로젝트: bjtenao/tudu-web
 /**
  * 获取签到提醒,json返回
  */
 public function getcheckintipsAction()
 {
     $tips = array('checkin' => array('isshow' => false, 'starttime' => '^off', 'outtime' => '^off'), 'checkout' => array('isshow' => false, 'starttime' => '^off', 'outtime' => '^off'));
     // 是否需要签退提醒
     $checkoutRemind = empty($this->_settings) ? true : false;
     if (!empty($this->_settings) && $this->_settings['checkoutremind']) {
         $checkoutRemind = true;
     }
     $plan = $this->getPlan();
     if (!empty($plan) && $plan['scheduleid'] != '^off' && $plan['scheduleid'] != '^exemption') {
         $checkins = $this->getCheckins('type');
         $date = date('Y-m-d', time());
         if ($plan['checkintime'] && !isset($checkins[0])) {
             $checkinTime = strtotime($date . ' ' . $plan['checkintime']);
             $min = Oray_Function::dateDiff('min', time(), $checkinTime);
             $tips['checkin']['starttime'] = $checkinTime - 3600;
             $tips['checkin']['outtime'] = $checkinTime + 3600;
             // 下班前后1小时才有提醒
             if ($min <= 60 && $min >= -60) {
                 $tips['checkin']['isshow'] = true;
                 $tips['checkin']['starttime'] = '^off';
             }
         }
         if ($checkoutRemind && $plan['checkouttime'] && !isset($checkins[1])) {
             $checkoutTime = strtotime($date . ' ' . $plan['checkouttime']);
             // 灵活提示
             if (isset($checkins[0]) && $plan['checkintime']) {
                 $checkin = $checkins[0];
                 if ($checkin['status'] == Dao_App_Attend_Checkin::STATUS_NORMAL) {
                     $planCheckinTime = strtotime($date . ' ' . $plan['checkintime']);
                     if ($checkin['createtime'] > $planCheckinTime) {
                         $planCheckoutTime = strtotime($date . ' ' . $plan['checkouttime']);
                         $planWorkTime = $planCheckoutTime - $planCheckinTime;
                         $checkoutTime = $checkin['createtime'] + $planWorkTime;
                     }
                 }
             }
             $min = Oray_Function::dateDiff('min', time(), $checkoutTime);
             $tips['checkout']['starttime'] = $checkoutTime;
             $tips['checkout']['outtime'] = $checkoutTime + 1800;
             // 下班前后半小时才有提醒
             if ($min <= 0 && $min >= -30) {
                 $tips['checkout']['isshow'] = true;
                 $tips['checkout']['starttime'] = '^off';
             }
         }
     }
     return $this->_this->json(true, null, array('tips' => $tips, 'currtime' => time()));
 }
예제 #6
0
파일: Tudu.php 프로젝트: bjtenao/tudu-web
 /**
  * Construct
  *
  * @param array $record
  */
 public function __construct(array $record)
 {
     $this->orgId = $record['orgid'];
     $this->boardId = $record['boardid'];
     $this->tuduId = $record['tuduid'];
     $this->postId = $record['postid'];
     $this->cycleId = $record['cycleid'];
     $this->stepId = isset($record['stepid']) ? $record['stepid'] : null;
     $this->appId = isset($record['appid']) ? $record['appid'] : null;
     $this->flowId = isset($record['flowid']) ? $record['flowid'] : null;
     $this->classId = $record['classid'];
     $this->prevTuduId = !empty($record['prevtuduid']) ? $record['prevtuduid'] : null;
     $this->className = $record['classname'];
     $this->type = $record['type'];
     $this->subject = $record['subject'];
     $this->from = Dao_Td_Tudu_Tudu::formatAddress($record['from'], true);
     $this->to = Dao_Td_Tudu_Tudu::formatAddress($record['to']);
     $this->cc = Dao_Td_Tudu_Tudu::formatAddress($record['cc']);
     $this->bcc = isset($record['bcc']) ? Dao_Td_Tudu_Tudu::formatAddress($record['bcc']) : null;
     $this->content = $record['content'];
     $this->priority = $this->_toInt($record['priority']);
     $this->privacy = $this->_toInt($record['privacy']);
     $this->needConfirm = isset($record['needconfirm']) ? $this->_toInt($record['needconfirm']) : null;
     $this->password = $record['password'];
     $this->isAuth = isset($record['isauth']) ? $this->_toBoolean($record['isauth']) : null;
     $this->authCode = isset($record['authcode']) ? $record['authcode'] : null;
     $this->attachNum = $this->_toInt($record['attachnum']);
     $this->lastPostTime = $this->_toTimestamp($record['lastposttime']);
     $this->lastPoster = $record['lastposter'];
     $this->posterInfo = $record['posterinfo'];
     $this->viewNum = $record['viewnum'];
     $this->cycleNum = isset($record['cyclenum']) ? $this->_toInt($record['cyclenum']) : null;
     $this->replyNum = $this->_toInt($record['replynum']);
     $this->logNum = $this->_toInt($record['lognum']);
     $this->stepNum = isset($record['stepnum']) ? $this->_toInt($record['stepnum']) : null;
     $this->startTime = $this->_toTimestamp($record['starttime']);
     $this->endTime = $this->_toTimestamp($record['endtime']);
     $this->completeTime = isset($record['completetime']) ? $this->_toTimestamp($record['completetime']) : null;
     $this->totalTime = $this->_toInt($record['totaltime']);
     $this->elapsedTime = $this->_toInt($record['elapsedtime']);
     $this->acceptTime = $this->_toTimestamp($record['accepttime']);
     $this->createTime = $this->_toTimestamp($record['createtime']);
     $this->percent = $this->_toInt($record['percent']);
     $this->score = $this->_toInt($record['score']);
     $this->status = $this->_toInt($record['status']);
     $this->special = $this->_toInt($record['special']);
     $this->uniqueId = $record['uniqueid'];
     $this->isRead = $this->_toBoolean($record['isread']);
     $this->isDraft = $this->_toBoolean($record['isdraft']);
     $this->isForward = $this->_toBoolean($record['isforward']);
     $this->isTop = $this->_toBoolean($record['istop']);
     $this->isDone = $this->_toBoolean($record['isdone']);
     $this->mark = isset($record['mark']) ? $this->_toInt($record['mark']) : null;
     $this->isSend = isset($record['issend']) ? $this->_toBoolean($record['issend']) : null;
     $this->notifyAll = isset($record['notifyall']) ? $this->_toBoolean($record['notifyall']) : null;
     $this->acceptMode = isset($record['accepmode']) ? $this->_toBoolean($record['accepmode']) : null;
     $this->labels = $this->_toArray($record['labels']);
     $this->nodeType = isset($record['nodetype']) ? $record['nodetype'] : null;
     $this->parentId = isset($record['parentid']) ? $record['parentid'] : null;
     $this->rootId = isset($record['rootid']) ? $record['rootid'] : null;
     $this->isTuduGroup = in_array($this->nodeType, array(Dao_Td_Tudu_Group::TYPE_NODE, Dao_Td_Tudu_Group::TYPE_ROOT));
     $this->selfPercent = isset($record['selfpercent']) ? $this->_toInt($record['selfpercent']) : null;
     $this->role = !empty($record['role']) ? $record['role'] : null;
     $this->selfTuduStatus = isset($record['selftudustatus']) ? $this->_toInt($record['selftudustatus']) : null;
     $this->selfAcceptTime = isset($record['selfaccepttime']) ? $this->_toTimestamp($record['selfaccepttime']) : null;
     $this->selfStepStatus = isset($record['selfstepstatus']) ? $this->_toInt($record['selfstepstatus']) : null;
     $this->displayDate = isset($record['displaydate']) ? $this->_toInt($record['displaydate']) : null;
     $this->stepType = isset($record['steptype']) ? $this->_toInt($record['steptype']) : null;
     $this->isExpired = $this->endTime && $this->status <= Dao_Td_Tudu_Tudu::STATUS_DOING && Oray_Function::dateDiff('d', $this->endTime, time()) > 0;
     if (isset($this->from[3])) {
         $this->sender = $this->from[3];
     }
     $this->accepter = !empty($this->to) ? array_keys($this->to) : array();
     if (isset($record['forwardinfo']) || isset($record['lastforward'])) {
         $forwardInfo = count($this->accepter) > 1 ? $record['forwardinfo'] : $record['lastforward'];
         $array = explode("\n", $forwardInfo);
         if (count($array) == 2) {
             $this->lastForwarder = $array[0];
             $this->lastForwardTime = $this->_toInt($array[1]);
         }
     }
     parent::__construct();
 }