예제 #1
0
 /**
  * 编辑考勤分类
  */
 public function modifyAction()
 {
     $categoryId = $this->_request->getQuery('categoryid');
     if ($categoryId) {
         /* @var $daoCategory Dao_App_Attend_Category */
         $daoCategory = Tudu_Dao_Manager::getDao('Dao_App_Attend_Category', Tudu_Dao_Manager::DB_APP);
         $condition = array('categoryid' => $categoryId, 'orgid' => $this->_user->orgId);
         $category = $daoCategory->getCategory($condition);
         if (null === $category) {
             /**
              * @see Oray_Function
              */
             require_once 'Oray/Function.php';
             Oray_Function::alert($this->lang['category_not_exists'], '/app/attend/category/index');
         }
         $category = $category->toArray();
         foreach ($category['flowsteps'] as $key => &$step) {
             if (isset($step['sections'])) {
                 $step['users'] = $this->_formatStepSection($step['sections']);
             }
             if (isset($step['branches'])) {
                 foreach ($step['branches'] as &$branch) {
                     if (isset($branch['sections'])) {
                         $branch['users'] = $this->_formatStepSection($branch['sections']);
                     }
                 }
             }
         }
         $this->view->category = $category;
         $this->view->action = self::ACTION_UPDATE;
     } else {
         $this->view->action = self::ACTION_CREATE;
     }
 }
예제 #2
0
 /**
  * 登录验证
  */
 public function preDispatch()
 {
     $action = strtolower($this->_request->getActionName());
     if (!$this->_user->isAdminLogined()) {
         if (in_array($action, array('save'))) {
             return $this->json(false, '登陆超时,请重新登陆');
         } else {
             $this->destroySession();
             $this->referer($this->_request->getBasePath() . '/login/');
         }
     }
     if (!$this->_user->isOwner()) {
         if (in_array($action, array('save'))) {
             return $this->json(false, '非超级管理员帐户不能进行该操作');
         } else {
             Oray_Function::alert('非超级管理员帐户不能进行该操作');
         }
     }
 }
예제 #3
0
 /**
  * 验证APP
  */
 public function checkApp()
 {
     /* @var $daoApp Dao_App_App_App */
     $daoApp = Tudu_Dao_Manager::getDao('Dao_App_App_App', Tudu_Dao_Manager::DB_APP);
     $app = $daoApp->getApp(array('orgid' => $this->_user->orgId, 'appid' => $this->_appId));
     if ($app === null) {
         Oray_Function::alert($this->lang['warn_app_not_exists']);
     }
     if ($app->status == 0) {
         Oray_Function::alert($this->lang['warn_app_initialization']);
     }
     if ($app->status == 2) {
         Oray_Function::alert($this->lang['warn_app_status_stop']);
     }
     if ($app->activeTime === null || $app->activeTime > time()) {
         Oray_Function::alert($this->lang['warn_app_active_time']);
     }
     $this->_settings = $app->settings;
 }
예제 #4
0
파일: Admin.php 프로젝트: bjtenao/tudu-web
 /**
  * 显示设置页面
  */
 public function indexAction()
 {
     $daoAppUser = Tudu_Dao_Manager::getDao('Dao_App_App_User', Tudu_Dao_Manager::DB_APP);
     $daoApp = Tudu_Dao_Manager::getDao('Dao_App_App_App', Tudu_Dao_Manager::DB_APP);
     $app = $daoApp->getApp(array('orgid' => $this->_user->orgId, 'appid' => $this->_appId));
     // 没安装或过期
     if (null === $app || $app->expireDate && $app->expireDate < time()) {
         return Oray_Function::alert('您还没有安装该应用或已过期');
     }
     $users = $daoAppUser->getAppUsers(array('orgid' => $this->_user->orgId, 'appid' => $this->_appId))->toArray();
     $roles = array();
     foreach ($users as $user) {
         $roles[$user['role']][] = $user['itemid'];
     }
     $app = $app->toArray();
     $settings = $app['settings'];
     if (empty($settings) || !isset($settings['checkoutremind'])) {
         $app['settings']['checkoutremind'] = 1;
     }
     $this->view->roles = $roles;
     $this->view->app = $app;
 }
예제 #5
0
 /**
  * 回复编辑页面
  */
 public function postAction()
 {
     $postId = $this->_request->getQuery('pid');
     $post = array();
     $access = array('upload' => true, 'progress' => $this->_user['role'] == Dao_Td_Tudu_Tudu::ROLE_ACCEPTER);
     $content = $this->_request->getPost('content');
     if (!empty($content)) {
         $post['content'] = $content;
     }
     if ($postId) {
         /* @var $daoPost Dao_Td_Tudu_Post */
         $daoPost = $this->getDao('Dao_Td_Tudu_Post');
         $post = $daoPost->getPost(array('tuduid' => $this->_tudu->tuduId, 'postid' => $postId));
         if ($post === null) {
             return Oray_Function::alert($this->lang['post_not_exists']);
         }
         // 不是回复者时,读取版主的权限
         if ($post->uniqueId !== $this->_user->uniqueId) {
             Oray_Function::alert($this->lang['perm_deny_update_post']);
         }
         if ($post->attachNum > 0) {
             /* @var $daoFile Dao_Td_Attachment_File */
             $daoFile = $this->getDao('Dao_Td_Attachment_File');
             $attachments = $daoFile->getFiles(array('tuduid' => $post->tuduId, 'postid' => $post->postId));
             $post->attachments = $attachments->toArray();
         }
         $access['progress'] = $post->isLog && in_array($this->_user->email, $tudu->accepter) && $tudu->selfTuduStatus < Dao_Td_Tudu_Tudu::STATUS_DONE;
         $post = $post->toArray();
     }
     $cookies = $this->_request->getCookie();
     $this->view->registModifier('tudu_format_content', array($this, 'formatContent'));
     $upload = $this->_options['upload'];
     $upload['cgi']['upload'] .= '?authtype=foreign&' . session_name() . '=' . $this->_sessionId . '&email=' . $this->_user['email'];
     $this->view->upload = $upload;
     $this->view->cookies = serialize($cookies);
     $this->view->post = $post;
     $this->view->tudu = $this->_tudu->toArray();
     $this->view->access = $access;
     $this->render('modify_post');
 }
예제 #6
0
 /**
  * 编辑回复
  */
 public function postAction()
 {
     $access = array('upload' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPLOAD_ATTACH), 'modify' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPDATE_POST));
     $tuduId = $this->_request->getQuery('tid');
     $postId = $this->_request->getQuery('pid');
     $post = array();
     $params = $this->_request->getPost();
     /*if (!empty($content)) {
           $post['content'] = $content;
       }*/
     if (!$tuduId) {
         return $this->_redirect($_SERVER['HTTP_REFERER']);
     }
     /* @var $daoTudu Dao_Td_Tudu_Tudu */
     $daoTudu = $this->getDao('Dao_Td_Tudu_Tudu');
     $tudu = $daoTudu->getTuduById($this->_user->uniqueId, $tuduId);
     /* @var $daoPost Dao_Td_Tudu_Post */
     $daoPost = $this->getDao('Dao_Td_Tudu_Post');
     /* @var $daoFile Dao_Td_Attachment_File */
     $daoFile = $this->getDao('Dao_Td_Attachment_File');
     if (null === $tudu || !$tudu->uniqueId) {
         return $this->_redirect($_SERVER['HTTP_REFERER']);
     }
     if ($postId) {
         // 编辑权限检查
         if (!$access['modify']) {
             Oray_Function::alert($this->lang['perm_deny_update_post']);
         }
         $post = $daoPost->getPost(array('tuduid' => $tuduId, 'postid' => $postId));
         if (!$post) {
             $this->_redirect('/tudu/?search=inbox');
         }
         // 不是回复者时,读取版主的权限
         if ($post->uniqueId !== $this->_user->uniqueId) {
             $boards = $this->getBoards(false);
             $board = $boards[$post->boardId];
             $isModerators = array_key_exists($this->_user->userId, $board['moderators']);
             if (!$isModerators) {
                 Oray_Function::alert($this->lang['perm_deny_update_post']);
             }
         }
         if ($post->attachNum > 0) {
             $attachments = $daoFile->getFiles(array('tuduid' => $post->tuduId, 'postid' => $post->postId));
             $post->attachments = $attachments->toArray();
         }
         $access['progress'] = $post->isLog && in_array($this->_user->userName, $tudu->accepter) && $tudu->selfTuduStatus < Dao_Td_Tudu_Tudu::STATUS_DONE;
         $post = $post->toArray();
     } else {
         if (count($tudu->accepter) > 1) {
             $access['progress'] = in_array($this->_user->userName, $tudu->accepter) && $tudu->selfAcceptTime && $tudu->selfTuduStatus < Dao_Td_Tudu_Tudu::STATUS_DONE;
         } else {
             $access['progress'] = in_array($this->_user->userName, $tudu->accepter) && $tudu->selfAcceptTime && $tudu->status < Dao_Td_Tudu_Tudu::STATUS_DONE;
         }
         $fromPostId = isset($params['fpid']) ? $params['fpid'] : null;
         $fromPost = null;
         if ($fromPostId) {
             $fromPost = $daoPost->getPost(array('tuduid' => $tuduId, 'uniqueid' => $this->_user->uniqueId, 'postid' => $fromPostId));
             if ($fromPost) {
                 $post = $fromPost->toArray();
             }
         }
         $post = array_merge($post, $params);
         if (isset($post['percent'])) {
             $post['percent'] = (int) $post['percent'];
         }
         if (isset($params['attach']) && is_array($params['attach'])) {
             $attachments = $daoFile->getFiles(array('fileid' => $params['attach'], 'uniqueid' => $this->_user->uniqueId), array('isattachment' => null));
             $post['attachments'] = array_unique($attachments->toArray());
             $post['attachnum'] = count($post['attachments']);
         }
         if (isset($params['savetime'])) {
             $post['savetime'] = (int) $params['savetime'];
         }
         if (isset($params['elapsedtime'])) {
             $post['elapsedtime'] = (int) $params['elapsedtime'] * 3600;
         }
     }
     $boards = $this->getBoards(false);
     if (isset($boards[$tudu->boardId])) {
         $this->view->board = $boards[$tudu->boardId];
     }
     $cookies = $this->_request->getCookie();
     $this->view->registModifier('tudu_format_content', array($this, 'formatContent'));
     $upload = $this->options['upload'];
     $upload['cgi']['upload'] .= '?' . session_name() . '=' . $this->_sessionId . '&email=' . $this->_user->address;
     $this->view->upload = $upload;
     $this->view->cookies = serialize($cookies);
     $this->view->post = $post;
     $this->view->tudu = $tudu->toArray();
     $this->view->access = $access;
     $this->view->back = $this->_request->getQuery('back');
     $this->view->newwin = (bool) $this->_request->getQuery('newwin');
     $this->render('modify_post');
 }
예제 #7
0
 /**
  *
  * 编辑
  */
 public function modifyAction()
 {
     $boardId = $this->_request->getQuery('bid');
     $board = array();
     $action = 'create';
     $daoBoard = $this->getDao('Dao_Td_Board_Board');
     $daoTemplate = $this->getDao('Dao_Td_Tudu_Template');
     if ($boardId) {
         $board = $daoBoard->getBoard(array('orgid' => $this->_user->orgId, 'boardid' => $boardId));
         $templates = $daoTemplate->getTemplatesByBoardId($this->_user->orgId, $boardId, null, 'ordernum ASC');
         if (null === $board) {
             return Oray_Function::alert($this->lang['board_not_exists']);
         }
         $board = $board->toArray();
         $action = 'update';
         $daoClass = $this->getDao('Dao_Td_Tudu_Class');
         $classes = $daoClass->getClassesByBoardId($this->_user->orgId, $board['boardid'], 'ordernum ASC');
         if ($templates) {
             $this->view->templates = $templates->toArray();
         }
         $this->view->classes = $classes->toArray();
     } else {
         if (!$this->_user->getAccess()->assertEquals(Tudu_Access::PERM_CREATE_BOARD, true)) {
             Oray_Function::alert($this->lang['perm_deny_create'], '/board/');
         }
     }
     $zones = $daoBoard->getBoards(array('orgid' => $this->_user->orgId, 'type' => 'zone'));
     // 权限
     $access = array('discuss' => $this->_user->getAccess()->assertEquals(Tudu_Access::PERM_CREATE_DISCUSS, true), 'notice' => $this->_user->getAccess()->assertEquals(Tudu_Access::PERM_CREATE_NOTICE, true), 'task' => $this->_user->getAccess()->assertEquals(Tudu_Access::PERM_CREATE_TUDU, true), 'meeting' => $this->_user->getAccess()->assertEquals(Tudu_Access::PERM_CREATE_MEETING, true), 'board' => $this->_user->getAccess()->assertEquals(Tudu_Access::PERM_CREATE_BOARD, true), 'upload' => $this->_user->getAccess()->assertEquals(Tudu_Access::PERM_UPLOAD_ATTACH, true), 'meeting' => $this->_user->getAccess()->assertEquals(Tudu_Access::PERM_CREATE_MEETING, true));
     //$uploadOpt = $this->bootstrap->getOption('upload');
     $this->view->board = $board;
     $this->view->zones = $zones->toArray();
     $this->view->action = $action;
     $this->view->newwin = (bool) $this->_request->getQuery('newwin');
     $this->view->access = $access;
 }
예제 #8
0
파일: Apply.php 프로젝트: bjtenao/tudu-web
 /**
  * 显示图度内容
  */
 public function viewAction()
 {
     $tuduId = $this->_request->getQuery('tid');
     $newwin = (bool) $this->_request->getQuery('newwin');
     if (null === $tuduId) {
     }
     $daoTudu = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Tudu', Tudu_Dao_Manager::DB_TS);
     $daoApply = Tudu_Dao_Manager::getDao('Dao_App_Attend_Apply', Tudu_Dao_Manager::DB_APP);
     $tudu = $daoTudu->getTuduById($this->_user->uniqueId, $tuduId);
     if (null === $tudu) {
         return Oray_Function('');
     }
     if ($newwin) {
         $daoOrg = Tudu_Dao_Manager::getDao('Dao_Md_Org_Org', Tudu_Dao_Manager::DB_MD);
         $org = $daoOrg->getOrg(array('orgid' => $this->_user->orgId));
         $this->view->org = $org->toArray();
     }
     $apply = $daoApply->getApply(array('tuduid' => $tuduId));
     if (null === $apply) {
         Oray_Function::alert('考勤申请不存在或已被删除');
     }
     $isSender = $this->_user->uniqueId == $apply->senderId;
     $isTarget = $this->_user->uniqueId == $apply->uniqueId;
     $access = array('view' => $tudu->uniqueId == $this->_user->uniqueId && !empty($tudu->labels), 'reply' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_CREATE_POST), 'modify' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPDATE_TUDU) && $isSender, 'delete' => false, 'upload' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPLOAD_ATTACH), 'cancel' => ($isSender || $isTarget) && !$tudu->isDone, 'confirm' => $isSender && !$tudu->isDone, 'undone' => $isSender && $tudu->isDone, 'ignore' => true, 'target' => $isTarget, 'sender' => $isSender, 'agree' => false, 'disagree' => false);
     if ($tudu->isDone) {
         $access['reply'] = false;
         $access['modify'] = false;
     }
     // 回复内容
     $page = (int) $this->_request->getQuery('page');
     $pageSize = max(20, (int) $this->_user->option['replysize']);
     $uniqueId = $this->_request->getQuery('unid');
     $back = $this->_request->getQuery('back');
     $recordCount = $tudu->replyNum + 1;
     $labels = $this->_this->getLabels();
     $isInvert = (bool) $this->_request->getQuery('invert', isset($this->_user->option['postsort']) && $this->_user->option['postsort'] == 1);
     $query = array('tid' => $tudu->tuduId, 'back' => $back, 'invert' => $isInvert ? 1 : 0);
     $condition = array('tuduid' => $tudu->tuduId);
     // 已关联用户,设置已读状态
     if ($tudu->uniqueId == $this->_user->uniqueId) {
         if (!$tudu->isRead) {
             $daoTudu->markRead($tuduId, $this->_user->uniqueId);
         }
         // 增加到关联用户,解决版块中的已读未读状态问题(!!会导致重新发送的不会投递到用户图度箱)
     } else {
         $daoTudu->addUser($tuduId, $this->_user->uniqueId, array('isread' => true));
     }
     // 增加浏览次数
     $daoTudu->hit($tudu->tuduId);
     /* @var $daoPost Dao_Td_Tudu_Post */
     $daoPost = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Post', Tudu_Dao_Manager::DB_TS);
     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' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_UPDATE_POST), 'delete' => $this->_user->getAccess()->isAllowed(Tudu_Access::PERM_DELETE_POST));
     foreach ($posts as $key => $post) {
         // 读取回复的附件信息
         if ($post['attachnum'] > 0) {
             $files = Tudu_Dao_Manager::getDao('Dao_Td_Attachment_File', Tudu_Dao_Manager::DB_TS)->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']];
         }
     }
     if ($tudu->stepId && strpos($tudu->stepId, '^') !== 0) {
         /* @var $daoStep Dao_Td_Tudu_Step */
         $daoStep = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Step', Tudu_Dao_Manager::DB_TS);
         $step = $daoStep->getCurrentStep($tuduId, $tudu->stepId, $this->_user->uniqueId);
         if (null !== $step && $step['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE) {
             $this->view->isreview = true;
         }
         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['divide'] = false;
             $access['accept'] = false;
             $access['reject'] = false;
             $access['progress'] = false;
             $access['review'] = false;
         }
     }
     // 获取联系人的IM在线信息
     $config = $this->_this->bootstrap->getOption('im');
     $im = new Oray_Im_Client($config['host'], $config['port']);
     $imStatus = $im->getUserStatus(array_keys($status));
     foreach ($imStatus as $email => $_status) {
         if (isset($status[$email])) {
             $status[$email] = $_status;
         }
     }
     //$daoStep = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Step', Tudu_Dao_Manager::DB_TS);
     $daoFlow = Tudu_Dao_Manager::getDao('Dao_Td_Tudu_Flow', Tudu_Dao_Manager::DB_TS);
     $flow = $daoFlow->getFlow(array('tuduid' => $tudu->tuduId));
     if ($flow) {
         $steps = $flow->steps;
         foreach ($steps as $sid => $step) {
             if ($sid == $flow->currentStepId) {
                 $section = $step['section'][$step['currentSection']];
                 if (count($section) > 1) {
                     $this->view->samereview = true;
                 }
                 foreach ($section as $u) {
                     if ($u['uniqueid'] == $this->_user->uniqueId && $u['status'] == 1) {
                         $access['agree'] = $access['disagree'] = true;
                     }
                 }
             }
         }
         $this->view->steps = $steps;
     }
     /*
             $users   = $daoStep->getTuduStepUsers($tudu->tuduId);
             $accepters = $daoTudu->getAccepters($tuduId);
     
             $isDisagreed = false;
             $steps = array();
             $isExceed = false;
             $processIndex = null;
             $sameReview = false;
             $currentUser = array();
             $currentIndex = null;
             foreach ($users as &$user) {
                 $info = explode(' ', $user['userinfo']);
                 $user['email']    = $info[0];
                 $user['truename'] = $info[1];
     
                 if ($user['type'] == Dao_Td_Tudu_Step::TYPE_EXECUTE && $user['stepid'] == $tudu->stepId && !empty($accepters)) {
                     foreach ($accepters as $accepter) {
                         if ($accepter['uniqueid'] == $user['uniqueid']) {
                             $user['percent'] = $accepter['percent'];
                         }
                     }
                 }
     
                 $processIndex = $user['processindex'];
     
                 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']]['stepstatus'] = $user['stepstatus'];
                 $steps[$user['ordernum']]['future']     = !empty($user['future']);
     
                 if ($user['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE && $user['status'] > 2) {
                     $isDisagreed = true;
                 }
     
                 if ($tudu->flowId && $user['stepid'] == $tudu->stepId) {
                     if (null === $currentIndex && $user['status'] < 2) {
                         $currentIndex = $user['processindex'];
                     }
                     if ($currentIndex == $user['processindex']) {
                         $currentUser[] = $user['userinfo'];
                     }
     
                     if ($user['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE) {
                         $steptype = 1;
                     } else {
                         $steptype = 0;
                     }
                     $this->view->steptype = $steptype;
                 }
             }
             // 判断是否同时审批
             $index = null;
             foreach ($users as $item) {
     
                 if ($item['type'] == Dao_Td_Tudu_Step::TYPE_EXAMINE && $item['stepid'] == $tudu->stepId) {
                     if ($index == $item['processindex']) {
                         $sameReview = true;
                     }
                     $index = $item['processindex'];
                 }
             }
     
             if ($sameReview) {
                 foreach ($users as $item) {
                     if ($tudu->flowId && $item['stepid'] == $tudu->stepId) {
                         $currentUser[] = $item['userinfo'];
                     }
                 }
             }
     
             ksort($steps);
     
             if (!empty($currentUser)) {
                 $tudu->to = Dao_Td_Tudu_Tudu::formatAddress(implode("\n", array_unique($currentUser)));
             }
     
             if ($isDisagreed && count($steps)) {
                 if ($tudu->flowId) {
                     $access['accept'] = false;
                     if (strpos($tudu->stepId, '^') === 0) {
                         $access['reject'] = false;
                     }
                 } else {
                     $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->userName])) {
                             $access['accept'] = false;
                             $access['reject'] = false;
                         }
                     }
     
                     reset($steps);
                 }
             }
     
             if ($sameReview) {
                 $this->view->samereview = $sameReview;
             }
     
             if (count($steps) > 0) {
                 $this->view->steps = $steps;
             }*/
     if ($access['upload']) {
         $upload = $this->_this->options['upload'];
         $upload['cgi']['upload'] .= '?' . session_name() . '=' . Zend_Session::getId() . '&email=' . $this->_user->address;
         $this->view->upload = $upload;
     }
     $this->view->registModifier('tudu_format_content', array($this, 'formatContent'));
     $this->view->registModifier('tudu_get_attachment_url', array($this, 'getAttachmentUrl'));
     $this->view->registFunction('format_label', array($this, 'formatLabels'));
     $this->view->access = $access;
     $this->view->tudu = $tudu->toArray();
     $this->view->apply = $apply->toArray();
     $this->view->posts = $posts;
     $this->view->pageinfo = array('currpage' => $page, 'pagecount' => $pageCount, 'pagesize' => $pageSize, 'recordcount' => $recordCount, 'query' => $query, 'url' => '/tudu/view');
     $this->view->cookies = serialize($this->_request->getCookie());
     $this->view->query = $query;
     $this->view->labels = $labels;
     $this->view->newwin = $newwin;
     $this->view->imstatus = $imStatus;
     $this->view->isinvert = $isInvert;
 }
예제 #9
0
 /**
  * 下载附件
  */
 public function indexAction()
 {
     $this->_helper->viewRenderer->setNeverRender();
     $act = $this->_request->getParam('act', $this->_request->getQuery('action'));
     $fileId = $this->_request->getQuery('fid', $this->_request->getQuery('aid'));
     $mod = $this->_request->getParam('mod', self::UPLOAD_ATTACHMENT);
     if ($mod == self::UPLOAD_ATTACHMENT) {
         /* @var $file Dao_Td_Attachment_Record_File */
         $file = $this->getDao('Dao_Td_Attachment_File')->getFile(array('fileid' => $fileId));
         if (null === $file || !$file->tuduId && $file->uniqueId != $this->_user->uniqueId) {
             Oray_Function::alert($this->lang['file_not_exists']);
             return false;
         }
         if ($file->tuduId) {
             $tudu = $this->getDao('Dao_Td_Tudu_Tudu')->getTuduById($this->_user->uniqueId, $file->tuduId);
             $boards = $this->getBoards(false);
             $board = $boards[$tudu->boardId];
             $isModerators = array_key_exists($this->_user->userId, $board['moderators']);
             $inGroups = (bool) sizeof(array_uintersect($this->_user->groups, $board['groups'], "strcasecmp"));
             $isSuperModerator = !empty($board['parentid']) && array_key_exists($this->_user->userId, $boards[$board['parentid']]['moderators']);
             // 禁止访问
             if (null === $tudu || !$tudu->uniqueId && !$isModerators && !$isSuperModerator && !$inGroups) {
                 Oray_Function::alert($this->lang['file_deny_access']);
                 return false;
             }
         }
     } elseif ($mod == self::UPLOAD_NETDISK) {
         /* @var $daoFile Dao_Td_Netdisk_File */
         $daoFile = $this->getDao('Dao_Td_Netdisk_File');
         $ownerId = $this->_request->getQuery('ownerid');
         $file = $daoFile->getFile(array('uniqueid' => $ownerId, 'fileid' => $fileId));
         if (null === $file) {
             Oray_Function::alert($this->lang['file_not_exists']);
             return false;
         }
         /* @var $daoShare Dao_Td_Netdisk_Share */
         $daoShare = $this->getDao('Dao_Td_Netdisk_Share');
         $share = $daoShare->getShare(array('objectid' => $fileId, 'targetid' => $this->_user->userName, 'ownerid' => $ownerId));
         if (null === $file) {
             Oray_Function::alert($this->lang['file_not_exists']);
             return false;
         }
     } else {
         Oray_Function::alert($this->lang['file_not_exists']);
         return false;
     }
     $option = $this->bootstrap->getOption('upload');
     $path = $option['path'] . '/' . $file->path . '/' . $file->fileId;
     if (!file_exists($path)) {
         return Oray_Function::alert($this->lang['file_not_exists']);
     }
     $this->_response->setHeader('Content-Type', $file->type . ', charset=utf-8');
     $this->_response->setHeader('Content-Length', $file->size);
     $type = $act == 'view' ? 'inline' : 'attachment';
     // FF Only
     if (false !== strpos(strtolower($this->_request->getServer('HTTP_USER_AGENT')), 'firefox')) {
         $this->_response->setHeader('Content-Disposition', $type . ';filename*=UTF-8\'\'' . urlencode($file->fileName));
         // Other
     } else {
         $this->_response->setHeader('Content-Disposition', $type . ';filename=' . urlencode($file->fileName));
     }
     $this->_response->sendHeaders();
     $fp = fopen($path, 'rb');
     while (!feof($fp)) {
         echo fread($fp, 4096);
         @flush();
         @ob_flush();
     }
     fclose($fp);
     // 取消输出 - 主要避免再次输出文件头,两种方式,第一种比较直接
     $this->getFrontController()->returnResponse(true);
     //$this->_response->clearAllHeaders();
 }
예제 #10
0
파일: Review.php 프로젝트: bjtenao/tudu-web
 /**
  * 修改应用范围页面
  */
 public function applyAction()
 {
     $flowId = $this->_request->getQuery('flowid');
     /* @var $daoFlow Dao_App_Attend_Flow */
     $daoFlow = Tudu_Dao_Manager::getDao('Dao_App_Attend_Flow', Tudu_Dao_Manager::DB_APP);
     $condition = array('flowid' => $flowId, 'orgid' => $this->_user->orgId);
     $flow = $daoFlow->getFlow($condition);
     if (null === $flow) {
         Oray_Function::alert($this->lang['flow_not_exists'], '/app/attend/review/index');
     }
     /* @var $daoCategory Dao_App_Attend_Category */
     $daoCategory = Tudu_Dao_Manager::getDao('Dao_App_Attend_Category', Tudu_Dao_Manager::DB_APP);
     $categories = $daoCategory->getCategories(array('orgid' => $this->_user->orgId), null, 'status DESC, issystem DESC, createtime DESC');
     $this->view->categories = $categories->toArray();
     $this->view->flow = $flow->toArray();
 }
예제 #11
0
 /**
  * 保存图度工作流
  */
 public function saveAction()
 {
     $flowId = $this->_request->getPost('flowid');
     $post = $this->_request->getPost();
     if (empty($post['bid'])) {
         return $this->json(false, $this->lang['params_invalid_boardid']);
     }
     if (empty($post['subject'])) {
         return $this->json(false, $this->lang['params_invalid_flow_subject']);
     }
     $members = (array) $this->_request->getPost('member');
     $count = count($members);
     if ($count <= 0) {
         return $this->json(false, $this->lang['params_invalid_flow_steps']);
     }
     /* @var $daoFlow Dao_Td_Flow_Flow */
     $daoFlow = $this->getDao('Dao_Td_Flow_Flow');
     /* @var $daoAttachment Dao_Td_Flow_Attachment */
     $daoAttachment = $this->getDao('Dao_Td_Flow_Attachment');
     $params = array('boardid' => $post['bid'], 'classid' => !empty($post['classid']) ? $post['classid'] : null, 'orgid' => $this->_user->orgId, 'uniqueid' => $this->_user->uniqueId, 'subject' => trim($post['subject']), 'cc' => !empty($post['cc']) ? $post['cc'] : null, 'description' => !empty($post['description']) ? trim($post['description']) : null, 'elapsedtime' => !empty($post['elapsedtime']) ? $post['elapsedtime'] : null);
     if (!empty($post['avaliable'])) {
         $params['avaliable'] = $post['avaliable'];
     } else {
         $params['avaliable'] = $this->_user->userName;
     }
     if (!empty($post['content'])) {
         $params['content'] = $post['content'];
     }
     // 处理附件
     $attachment = array();
     if (!empty($post['attach']) && is_array($post['attach'])) {
         foreach ($post['attach'] as $item) {
             $attachment[] = array('fileid' => $item, 'isattach' => true);
         }
         unset($post['attachment']);
     }
     // 处理图片文件
     if (!empty($post['file']) && is_array($post['file'])) {
         foreach ($post['file'] as $item) {
             $attachment[] = array('fileid' => $item, 'isattach' => false);
         }
         unset($post['file']);
     }
     // 处理网盘文件
     if (!empty($post['nd-attach']) && is_array($post['nd-attach'])) {
         /* @var $daoNdFile Dao_Td_Netdisk_File */
         $daoNdFile = $this->getDao('Dao_Td_Netdisk_File');
         /* @var $daoFile Dao_Td_Attachment_File */
         $daoFile = $this->getDao('Dao_Td_Attachment_File');
         foreach ($post['nd-attach'] as $ndFileId) {
             $attach = $daoAttachment->getAttachment(array('fileid' => $ndFileId));
             if (null !== $attach) {
                 $attachment[] = array('fileid' => $ndFileId, 'isattach' => true);
                 continue;
             }
             $file = $daoNdFile->getFile(array('uniqueid' => $this->_user->uniqueId, 'fileid' => $ndFileId));
             if ($file) {
                 $fid = $daoFile->createFile(array('uniqueid' => $this->_user->uniqueId, 'fileid' => $ndFileId, 'orgid' => $this->_user->orgId, 'filename' => $file->fileName, 'path' => $file->path, 'type' => $file->type, 'size' => $file->size, 'createtime' => time()));
                 if ($fid) {
                     $attachment[] = array('fileid' => $ndFileId, 'isattach' => true);
                 }
             }
         }
     }
     // 创建
     if (!$flowId) {
         $params['flowid'] = Dao_Td_Flow_Flow::getFlowId();
         $params['createtime'] = time();
         $params['steps'] = $this->formatSteps($post);
         $ret = $daoFlow->createFlow($params);
         $flowId = $ret;
         // 添加附件关联
         if (!empty($attachment)) {
             foreach ($attachment as $attach) {
                 $daoAttachment->addAttachment($flowId, $attach['fileid'], (bool) $attach['isattach']);
             }
         }
         $avalible = explode("\n", $params['avaliable']);
         $updateGroups = true;
         // 更新
     } else {
         $updateAttach = false;
         $flow = $daoFlow->getFlowById($flowId);
         // 修改的工作流不存在或已被删除
         if (null === $flow) {
             Oray_Function::alert($this->lang['flow_not_exists']);
         }
         // 检查是否已有图度使用了本工作流
         $isValid = $daoFlow->isValidFlow($flowId);
         if ($isValid) {
             // 比较步骤流程
             $isNew = $this->compareSteps($this->formatSteps($post), $flow->steps);
             // 流程发生变化创建新的工作流
             if ($isNew) {
                 // 更新is_valid字段
                 $daoFlow->updateFlow($flowId, array('isvalid' => 0));
                 $params['flowid'] = Dao_Td_Flow_Flow::getFlowId();
                 $params['steps'] = $this->formatSteps($post, $flowId);
                 // 创建新的工作流
                 $ret = $daoFlow->createFlow($params);
                 $flowId = $ret;
                 // 附件处理
                 if ($daoAttachment->existsAttach($flow->flowId)) {
                     $attachments = $daoAttachment->getAttachments(array('flowid' => $flow->flowId));
                     foreach ($attachments as $attach) {
                         $daoAttachment->addAttachment($flowId, $attach->fileId, $attach->isAttach);
                     }
                 }
                 // 流程没有变化
             } else {
                 $params['steps'] = $this->formatSteps($post);
                 $ret = $daoFlow->updateFlow($flowId, $params);
                 $updateAttach = true;
             }
             // 流程没有使用过,直接保存
         } else {
             $params['steps'] = $this->formatSteps($post);
             $ret = $daoFlow->updateFlow($flowId, $params);
             $updateAttach = true;
         }
         if ($updateAttach) {
             // 更新时清除附件关联
             $daoAttachment->deleteAttachment($flowId);
             if (!empty($attachment)) {
                 foreach ($attachment as $attach) {
                     $daoAttachment->addAttachment($flowId, $attach['fileid'], (bool) $attach['isattach']);
                 }
             }
         }
         // 比较可用人群,若有更新则与板块的参与人比较,缺少则添加到板块参与人
         $avalible = explode("\n", $params['avaliable']);
         $diff = array_diff($avalible, $flow->avaliable);
         $updateGroups = !empty($diff) ? true : false;
     }
     if (!$ret) {
         return $this->json(false, $post['action'] == 'update' ? $this->lang['update_flow_failed'] : $this->lang['create_flow_failed']);
     }
     // 是否需要更新板块参与人
     if ($updateGroups) {
         /* @var $daoBoard Dao_Td_Board_Board */
         $daoBoard = $this->getDao('Dao_Td_Board_Board');
         $boardId = $params['boardid'];
         $boards = $this->getBoards(false);
         $board = $boards[$boardId];
         $diff = array_diff($avalible, $board['groups']);
         if (!empty($diff)) {
             $groups = array_merge($avalible, $board['groups']);
             $groups = array_unique($groups);
             $daoBoard->updateBoard($this->_user->orgId, $boardId, array('groups' => implode("\n", $groups)));
         }
     }
     return $this->json(true, $post['action'] == 'update' ? $this->lang['update_flow_success'] : $this->lang['create_flow_success'], array('flowid' => $flowId));
 }
예제 #12
0
 /**
  * 保存工作日调整
  */
 public function saveadjustAction()
 {
     // 权限验证
     $role = $this->getRoles();
     if (empty($role['admin'])) {
         Oray_Function::alert('您没有创建或修改工作日调整的权限', '/app/attend/schedule/index');
     }
     $adjustId = $this->_request->getPost('adjustid');
     $post = $this->_request->getPost();
     $users = $this->_request->getPost('user');
     if (!is_array($users) || empty($users)) {
         return $this->json(false, $this->lang['param_user_null']);
     }
     $startTime = strtotime($post['starttime']);
     $endTime = strtotime($post['endtime']);
     $params = array('subject' => $post['subject'], 'starttime' => $startTime, 'endtime' => $endTime, 'type' => $post['type']);
     $adjustDate = array('starttime' => $startTime, 'endtime' => $endTime);
     /* @var $daoAdjust Dao_App_Attend_Schedule_Adjust */
     $daoAdjust = Tudu_Dao_Manager::getDao('Dao_App_Attend_Schedule_Adjust', Tudu_Dao_Manager::DB_APP);
     if ($adjustId) {
         $adjust = $daoAdjust->getAdjust(array('adjustid' => $adjustId));
         // 不存在
         if (null === $adjust || $adjust->orgId != $this->_user->orgId) {
             return $this->json(false, $this->lang['adjust_not_exists']);
         }
         $daoAdjust->updateAdjust($adjustId, $params);
         $daoAdjust->removeUser($adjustId);
     } else {
         $params['orgid'] = $this->_user->orgId;
         $params['adjustid'] = Dao_App_Attend_Schedule_Adjust::getAdjustId();
         $params['createtime'] = time();
         $adjustId = $daoAdjust->createAdjust($params);
     }
     // 添加用户
     $addressBook = Tudu_AddressBook::getInstance();
     foreach ($users as $item) {
         // 帐号
         if (false !== strpos($item, '@')) {
             $members = array($addressBook->searchUser($this->_user->orgId, $item));
             // 群组
         } else {
             $members = $addressBook->getGroupUsers($this->_user->orgId, $item);
         }
         foreach ($members as $user) {
             // 添加用户关联
             $daoAdjust->addUser(array('orgid' => $this->_user->orgId, 'adjustid' => $adjustId, 'uniqueid' => $user['uniqueid'], 'createtime' => time()));
             $this->updateAdjustAttend($user['uniqueid'], $post['type'], $adjustDate);
         }
     }
     return $this->json(true, $this->lang['save_adjust_success']);
 }
예제 #13
0
 /**
  * 编辑权限组的用户权限
  * 页面显示
  */
 public function modifyAccessAction()
 {
     /* @var @daoRole Dao_Md_User_Role */
     $daoRole = $this->getDao('Dao_Md_User_Role');
     $roleId = $this->_request->getQuery('roleid');
     if (!$roleId) {
         Oray_Function::alert($this->lang['invalid_params_roleid']);
     }
     if (!$daoRole->existsRole($this->_orgId, $roleId)) {
         Oray_Function::alert($this->lang['role_not_exists']);
     }
     $role = $daoRole->getRole(array('orgid' => $this->_orgId, 'roleid' => $roleId));
     $accesses = $daoRole->getAccesses($this->_orgId, $roleId);
     if (!count($accesses)) {
         $accesses = $daoRole->getAccesses($this->_orgId, '^user');
     }
     $this->view->role = $role->toArray();
     $this->view->accesses = $accesses;
 }
예제 #14
0
 /**
  * 发送成功页面
  */
 public function sentAction()
 {
     $authId = $this->_request->getQuery('authid');
     if (empty($authId)) {
         return Oray_Function::alert('验证信息错误,发送验证邮件失败');
     }
     /* @var $daoEmailAuth Dao_Reg_Email */
     $daoEmailAuth = Tudu_Dao_Manager::getDao('Dao_Reg_Email', Tudu_Dao_Manager::DB_SITE);
     $auth = $daoEmailAuth->getEmailAuth(array('emailauthid' => $authId));
     if (null === $auth || $auth->orgId != $this->_user->orgId || $auth->userId !== $this->_user->userId || $auth->status !== 0 || $auth->expireTime < time()) {
         return Oray_Function::alert('验证信息错误,发送验证邮件失败');
     }
     list(, $suffix) = explode('@', $auth->email);
     if (isset($this->_emailLoginUrl[$suffix])) {
         $this->view->loginurl = $this->_emailLoginUrl[$suffix];
     }
     $this->view->auth = $auth->toArray();
 }
예제 #15
0
 /**
  * 批量修改账号信息 - 页面显示
  */
 public function batchAction()
 {
     $userId = $this->_request->getQuery('userid');
     $back = $this->_request->getQuery('back');
     if (!$userId) {
         return $this->json(false, $this->lang['invalid_params_userid']);
     }
     $userIds = explode(',', $userId);
     if (count($userIds) <= 0) {
         Oray_Function::alert('没有选择需要编辑的用户');
     }
     /* @var $daoUser Dao_Md_User_User*/
     $daoUser = $this->getDao('Dao_Md_User_User');
     $users = $daoUser->getUsers(array('orgid' => $this->_orgId))->toArray();
     $modifies = array();
     foreach ($users as $item) {
         if (in_array($item['userid'], $userIds)) {
             $modifies[] = $item;
         }
     }
     // 群组
     /* @var $daoGroup Dao_Md_User_Group */
     $daoGroup = $this->getDao('Dao_Md_User_Group');
     $groups = $daoGroup->getGroups(array('orgid' => $this->_orgId), null, array('ordernum' => 'DESC'))->toArray();
     // 权限组
     /* @var $daoRole Dao_Md_User_Role */
     $daoRole = $this->getDao('Dao_Md_User_Role');
     $roles = $daoRole->getRoles(array('orgid' => $this->_orgId), null, array('issystem' => 'DESC'))->toArray();
     /* @var $daoOrg Dao_Md_Department_Department */
     $daoDepartment = $this->getDao('Dao_Md_Department_Department');
     $depts = $daoDepartment->getDepartments(array('orgid' => $this->_orgId))->toArray();
     /* @var @daoOrg Dao_Md_Org_Org */
     $daoOrg = $this->getDao('Dao_Md_Org_Org');
     $org = $daoOrg->getOrg(array('orgid' => $this->_orgId));
     $this->view->users = $users;
     $this->view->userids = $userIds;
     $this->view->depts = $depts;
     $this->view->roles = $roles;
     $this->view->groups = $groups;
     $this->view->modifies = $modifies;
     $this->view->back = $back;
     $this->view->org = $org->toArray();
 }
예제 #16
0
파일: Count.php 프로젝트: bjtenao/tudu-web
 /**
  * 导出数据
  */
 public function exportAction()
 {
     $this->_this->setNeverRender();
     $type = $this->_request->getQuery('type');
     $url = $this->_request->getQuery('url');
     $year = $this->_request->getQuery('year');
     $month = $this->_request->getQuery('month');
     //$page  = max(1, (int) $this->_request->getQuery('page'));
     //$pageSize = 25;
     if (!in_array($type, array('month', 'date'))) {
         Oray_Function::alert($this->lang['error_type_of_operate'], $url);
     }
     /* @var $daoMonth Dao_App_Attend_Month */
     $daoMonth = Tudu_Dao_Manager::getDao('Dao_App_Attend_Month', Tudu_Dao_Manager::DB_APP);
     /* @var $daoTotal Dao_App_Attend_Total */
     $daoTotal = Tudu_Dao_Manager::getDao('Dao_App_Attend_Total', Tudu_Dao_Manager::DB_APP);
     /* @var $daoCategory Dao_App_Attend_Category */
     $daoCategory = Tudu_Dao_Manager::getDao('Dao_App_Attend_Category', Tudu_Dao_Manager::DB_APP);
     /* @var $daoDate Dao_App_Attend_Date */
     $daoDate = Tudu_Dao_Manager::getDao('Dao_App_Attend_Date', Tudu_Dao_Manager::DB_APP);
     /* @var $daoDate Dao_App_Attend_Checkin */
     $daCheckin = Tudu_Dao_Manager::getDao('Dao_App_Attend_Checkin', Tudu_Dao_Manager::DB_APP);
     $data = array();
     switch ($type) {
         case 'month':
             $keywords = $this->_request->getQuery('keywords');
             $deptId = $this->_request->getQuery('deptid');
             $filename = $year . $month . '.csv';
             // 读取分类
             $categories = $daoCategory->getCategories(array('orgid' => $this->_user->orgId), array('status' => 1), 'issystem DESC, createtime DESC');
             // 导出数据的列名
             $columns = array(Oray_Function::utf8ToGbk($this->lang['name']), Oray_Function::utf8ToGbk($this->lang['dept']), Oray_Function::utf8ToGbk($this->lang['category_late'] . '(' . $this->lang['times'] . ')'), Oray_Function::utf8ToGbk($this->lang['category_leave'] . '(' . $this->lang['times'] . ')'), Oray_Function::utf8ToGbk($this->lang['category_unwork'] . '(' . $this->lang['times'] . ')'));
             // 导出数据分类的列名
             foreach ($categories as $category) {
                 if ($category->categoryId == '^checkin') {
                     $columns[] = Oray_Function::utf8ToGbk($category->categoryName . '(' . $this->lang['times'] . ')');
                 } else {
                     $columns[] = Oray_Function::utf8ToGbk($category->categoryName . '(' . $this->lang['hour'] . ')');
                 }
             }
             $data[] = implode(',', $columns);
             $userCondition = array('orgid' => $this->_user->orgId, 'userid' => $this->_user->userId);
             $roles = $this->getRoles();
             $condition = array('orgid' => $this->_user->orgId, 'date' => $year . $month);
             if (!empty($roles) && !empty($roles['sum'])) {
                 if (!empty($keywords)) {
                     $userCondition['keyword'] = $keywords;
                 }
                 if (!empty($deptId)) {
                     $daoDept = Tudu_Dao_Manager::getDao('Dao_Md_Department_Department', Tudu_Dao_Manager::DB_MD);
                     $deptIds = $daoDept->getChildDeptid($this->_user->orgId, $deptId);
                     $userCondition['deptid'] = array_merge((array) $deptId, $deptIds);
                 } else {
                     if (empty($roles['admin']) && !empty($roles['sum'])) {
                         $depts = array();
                         if (!empty($roles['moderator'])) {
                             $depts = $this->getModerateDepts(true, true);
                         } else {
                             $depts = $this->getRoleDepts(true, true);
                         }
                         if (!empty($depts)) {
                             $userCondition['deptid'] = $depts;
                         }
                     }
                 }
                 /* @var $daoCast Dao_Md_User_Cast */
                 $daoCast = Tudu_Dao_Manager::getDao('Dao_Md_User_Cast', Tudu_Dao_Manager::DB_MD);
                 $users = $daoCast->getCastUsers($userCondition, null, 'deptid DESC');
                 $users = $users->toArray();
                 $uniqueIds = array();
                 foreach ($users as $user) {
                     $uniqueIds[] = $user['uniqueid'];
                     $condition['uniqueid'] = $uniqueIds;
                 }
             } else {
                 $users = array();
                 $condition['uniqueid'] = $this->_user->uniqueId;
                 /* @var $daoUser Dao_Md_User_User*/
                 $daoUser = Tudu_Dao_Manager::getDao('Dao_Md_User_User', Tudu_Dao_Manager::DB_MD);
                 $user = $daoUser->getUserCard($userCondition);
                 $users[] = $user;
             }
             $datas = array();
             $records = $daoMonth->getAttendMonthList($condition)->toArray('uniqueid');
             $totals = $daoTotal->getAttendTotals($condition);
             foreach ($users as $user) {
                 foreach ($totals as $total) {
                     $id = strtr($total->categoryId, array('^' => ''));
                     if (!isset($datas[$user['uniqueid']][$id])) {
                         $datas[$user['uniqueid']][$id] = 0;
                     }
                     if ($total->uniqueId == $user['uniqueid']) {
                         $datas[$user['uniqueid']][$id] = $total->total;
                     }
                 }
                 foreach ($categories as $category) {
                     $id = strtr($category->categoryId, array('^' => ''));
                     if (!isset($datas[$user['uniqueid']][$id])) {
                         $datas[$user['uniqueid']][$id] = 0;
                     }
                 }
                 foreach ($records as $uniqueId => $record) {
                     foreach ($record as $key => $value) {
                         if (!isset($datas[$user['uniqueid']][$key])) {
                             $datas[$user['uniqueid']][$key] = 0;
                         }
                         if ($uniqueId == $user['uniqueid']) {
                             $datas[$user['uniqueid']][$key] = $value;
                         }
                     }
                 }
                 $datas[$user['uniqueid']]['uniqueid'] = $user['uniqueid'];
                 $datas[$user['uniqueid']]['truename'] = $user['truename'];
                 $datas[$user['uniqueid']]['deptname'] = $user['deptname'];
             }
             $data[] = $this->arrayToString($datas, $type, $categories);
             break;
         case 'date':
             $unId = $this->_request->getQuery('unid');
             $categoryId = $this->_request->getQuery('categoryid');
             // 读取用户信息/* @var $daoUser Dao_Md_User_User */
             $daoUser = Tudu_Dao_Manager::getDao('Dao_Md_User_User', Tudu_Dao_Manager::DB_MD);
             $userInfo = $daoUser->getUserCard(array('uniqueid' => $unId));
             // 导出的文件名称
             $filename = $userInfo['truename'] . '(' . $year . $month . ').csv';
             $date = array('start' => mktime(0, 0, 0, (int) $month, 1, (int) $year), 'end' => mktime(0, 0, 0, (int) $month + 1, 1, (int) $year));
             $condition = array('uniqueid' => $unId, 'date' => $date);
             if (!empty($categoryId)) {
                 if ($categoryId != '^late' && $categoryId != '^leave' && $categoryId != '^unwork' && $categoryId != '^uncheckin' && $categoryId != '^uncheckout') {
                     $condition['categoryid'] = $categoryId;
                 }
                 if ($categoryId == '^late') {
                     $condition['islate'] = true;
                 }
                 if ($categoryId == '^leave') {
                     $condition['isleave'] = true;
                 }
                 if ($categoryId == '^unwork') {
                     $condition['iswork'] = true;
                 }
                 if ($categoryId == '^uncheckin') {
                     $condition['uncheckin'] = true;
                 }
                 if ($categoryId == '^uncheckout') {
                     $condition['uncheckout'] = true;
                 }
             }
             $records = $daoDate->getAttendDatePage($condition, 'date ASC')->toArray();
             $checkins = $daCheckin->getCheckins(array('uniqueid' => $unId, 'date' => $date))->toArray();
             $today = strtotime(date('Y-m-d'));
             foreach ($records as &$record) {
                 $isCheckin = false;
                 $isCheckout = false;
                 $isToday = $record['date'] == $today ? true : false;
                 $record['truename'] = $userInfo['truename'];
                 $record['deptname'] = $userInfo['deptname'];
                 foreach ($checkins as &$checkin) {
                     if ($record['date'] == $checkin['date']) {
                         // 上班签到
                         if ($checkin['type'] == 0) {
                             $isCheckin = true;
                             $record['checkintime'] = $checkin['createtime'];
                             $record['checkinip'] = $checkin['ip'];
                             $record['checkinaddress'] = !empty($checkin['address']) ? $checkin['address'] : $this->lang['unknow'];
                             // 下班签退
                         } elseif ($checkin['type'] == 1) {
                             $isCheckout = true;
                             $record['checkouttime'] = $checkin['createtime'];
                             $record['checkoutip'] = $checkin['ip'];
                             $record['checkoutaddress'] = !empty($checkin['address']) ? $checkin['address'] : $this->lang['unknow'];
                         }
                         unset($checkin);
                     }
                 }
                 if ($isToday && (!$isCheckout || !$isCheckin)) {
                     $record['iswork'] = 0;
                 }
             }
             // 导出数据的列名
             $columns = array(Oray_Function::utf8ToGbk($this->lang['name']), Oray_Function::utf8ToGbk($this->lang['dept']), Oray_Function::utf8ToGbk($this->lang['date']), Oray_Function::utf8ToGbk($this->lang['checkin']), Oray_Function::utf8ToGbk($this->lang['checkout']), Oray_Function::utf8ToGbk($this->lang['work_time']), Oray_Function::utf8ToGbk($this->lang['category_late']), Oray_Function::utf8ToGbk($this->lang['category_leave']), Oray_Function::utf8ToGbk($this->lang['category_unwork']));
             $data[] = implode(',', $columns);
             $data[] = $this->arrayToString($records, $type);
             break;
     }
     header("Content-type:text/csv");
     header("Content-Disposition:attachment;filename=" . $filename);
     header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
     header('Expires:0');
     header('Pragma:public');
     echo implode("\n", $data);
 }