Exemple #1
0
 /**
  * Get record page 前台登录日志列表
  * 
  * @param array $condition
  * @param mixed $sort
  * @param int $page
  * @param int $pageSize
  * @return Oray_Dao_Recordset
  */
 public function getLoginLogPage(array $condition = null, $sort = null, $page = null, $pageSize = null)
 {
     $table = 'td_login_log';
     $columns = 'login_log_id AS loginlogid, org_id AS orgid, unique_id AS uniqueid, address, ' . 'truename, ip, local, isp, `from`, client_info AS clientinfo, create_time AS createtime';
     $primary = 'create_time';
     $recordClass = "Dao_Td_Log_Record_Login";
     $where = array();
     $order = array();
     if (!empty($condition['orgid'])) {
         $where[] = 'org_id = ' . $this->_db->quote($condition['orgid']);
     }
     if (!empty($condition['uniqueid'])) {
         $where[] = 'unique_id = ' . $this->_db->quote($condition['uniqueid']);
     }
     if (!empty($condition['address'])) {
         $where[] = 'address = ' . $this->_db->quote($condition['address']);
     }
     if (!empty($condition['truename'])) {
         $where[] = 'truename = ' . $this->_db->quote($condition['truename']);
     }
     if (!empty($condition['starttime']) && !empty($condition['endtime'])) {
         $where[] = 'create_time >= UNIX_TIMESTAMP(' . $this->_db->quote($condition['starttime']) . ') AND create_time <= UNIX_TIMESTAMP(' . $this->_db->quote($condition['endtime']) . ')';
     }
     if (!empty($condition['starttime']) && empty($condition['endtime'])) {
         $where[] = 'create_time >= UNIX_TIMESTAMP(' . $this->_db->quote($condition['starttime']) . ')';
     }
     if (empty($condition['starttime']) && !empty($condition['endtime'])) {
         $where[] = 'create_time <= UNIX_TIMESTAMP(' . $this->_db->quote($condition['endtime']) . ')';
     }
     if (!empty($condition['keywords'])) {
         $keyword = $this->_db->quote('%' . $condition['keywords'] . '%');
         $where[] = "address LIKE {$keyword} OR truename LIKE {$keyword} OR ip LIKE {$keyword}";
     }
     // WHERE
     $where = implode(' AND ', $where);
     // 格式化排序参数
     $sort = $this->_formatSort($sort);
     foreach ($sort as $key => $val) {
         switch ($key) {
             case 'createtime':
                 $key = 'create_time';
                 break;
             default:
                 continue 2;
                 break;
         }
         $order[] = $key . ' ' . $val;
     }
     // ORDER
     $order = implode(', ', $order);
     // 使用默认的分页大小
     if (null === $pageSize) {
         $pageSize = self::$_defaultPageSize;
     }
     /**
      * @see Oray_Db_Paginator
      */
     require_once 'Oray/Db/Paginator.php';
     // 初始化分页器
     $paginator = new Oray_Db_Paginator(array(Oray_Db_Paginator::ADAPTER => $this->_db, Oray_Db_Paginator::RECORD_CLASS => $recordClass, Oray_Db_Paginator::PAGE_SIZE => $pageSize, Oray_Db_Paginator::TABLE => $table, Oray_Db_Paginator::PRIMARY => $primary, Oray_Db_Paginator::COLUMNS => $columns, Oray_Db_Paginator::WHERE => $where, Oray_Db_Paginator::ORDER => $order));
     // 返回查询结果
     return $paginator->query($page);
 }
Exemple #2
0
 /**
  * 分页读取联系人列表
  *
  * @param $condition
  * @param $sort
  * @param $page
  * @param $pageSize
  * @return Oray_Dao_Recordset
  */
 public function getContactPage(array $condition, $sort = null, $page = null, $pageSize = null)
 {
     $table = 'td_contact AS c';
     $columns = 'c.contact_id AS contactid, c.unique_id AS uniqueid, true_name AS truename, pinyin, email, mobile, ' . 'affinity, last_contact_time AS lastcontacttime, groups, from_user AS fromuser';
     $where = array();
     $order = array();
     $limit = '';
     $primary = 'c.contact_id';
     $recordClass = 'Dao_Td_Contact_Record_Contact';
     if (!empty($condition['contactid'])) {
         $where[] = 'c.contact_id = ' . $this->_db->quote($condition['contactid']);
     }
     if (!empty($condition['uniqueid'])) {
         $where[] = 'c.unique_id = ' . $this->_db->quote($condition['uniqueid']);
     }
     if (!empty($condition['keywrod'])) {
         $keyword = $this->_db->quote("%{$condition['keyword']}%");
         $where[] = "(true_name LIKE {$keyword} OR pinyin LIKE {$keyword} OR email LIKE {$keyword})";
     }
     if (!empty($condition['nearly']) && is_int($condition['nearly'])) {
         $where[] = 'c.last_contact_time >= ' . strtotime('-' . $condition['nearly'] . ' days');
     }
     if (array_key_exists('isshow', $condition)) {
         if (null !== $condition['isshow']) {
             $where[] = 'is_show = ' . $condition['isshow'] ? 1 : 0;
         }
     } else {
         $where[] = 'is_show = 1';
     }
     if (array_key_exists('groupid', $condition)) {
         if (!empty($condition['groupid'])) {
             $table .= ' LEFT JOIN td_contact_group_member AS gm ON c.contact_id = gm.contact_id AND c.unique_id = gm.unique_id';
             $where[] = 'gm.group_id = ' . $this->_db->quote($condition['groupid']);
         } else {
             $where[] = 'c.groups = \'\'';
         }
     }
     // WHERE
     $where = implode(' AND ', $where);
     // 格式化排序参数
     $sort = $this->_formatSort($sort);
     foreach ($sort as $key => $val) {
         switch ($key) {
             case 'lastcontacttime':
                 $key = 'last_contact_time';
                 break;
             case 'affinity':
             default:
                 continue 2;
                 break;
         }
         $order[] = $key . ' ' . $val;
     }
     $order = implode(', ', $order);
     // 使用默认的分页大小
     if (null === $pageSize) {
         $pageSize = self::$_defaultPageSize;
     }
     /**
      * @see Oray_Db_Paginator
      */
     require_once 'Oray/Db/Paginator.php';
     $paginator = new Oray_Db_Paginator(array(Oray_Db_Paginator::ADAPTER => $this->_db, Oray_Db_Paginator::TABLE => $table, Oray_Db_Paginator::COLUMNS => $columns, Oray_Db_Paginator::ORDER => $order, Oray_Db_Paginator::PRIMARY => $primary, Oray_Db_Paginator::WHERE => $where, Oray_Db_Paginator::PAGE_SIZE => $pageSize, Oray_Db_Paginator::RECORD_CLASS => $recordClass));
     return $paginator->query($page);
 }
Exemple #3
0
 /**
  * Get record page
  *
  * @param array $condition
  * @param mixed $sort
  * @param int $page
  * @param int $pageSize
  * @return Oray_Dao_Recordset
  */
 public function getAdminLogPage(array $condition = null, $sort = null, $page = null, $pageSize = null)
 {
     $table = 'md_op_log';
     $columns = 'org_id AS orgid, user_id AS userid, module, action, sub_action AS subaction, ' . 'target, ip, local, create_time AS createtime, detail';
     $primary = 'create_time';
     $recordClass = "Dao_Md_Log_Record_Oplog";
     $where = array();
     $order = array();
     if (!empty($condition['userid'])) {
         $where[] = 'user_id = ' . $this->_db->quote($condition['userid']);
     }
     if (!empty($condition['orgid'])) {
         $where[] = 'org_id = ' . $this->_db->quote($condition['orgid']);
     }
     if (!empty($condition['module'])) {
         $where[] = 'module = ' . $this->_db->quote($condition['module']);
     }
     /*if (!empty($condition['starttime']) && !empty($condition['endtime'])) {
                 $where[] = 'create_time >= UNIX_TIMESTAMP(' . $this->_db->quote($condition['starttime']) . ') AND create_time <= UNIX_TIMESTAMP(' . $this->_db->quote($condition['endtime']) . ')';
             }
     
             if (!empty($condition['starttime']) && empty($condition['endtime'])) {
                 $where[] = 'create_time >= UNIX_TIMESTAMP(' . $this->_db->quote($condition['starttime']) . ')';
             }
     
             if (empty($condition['starttime']) && !empty($condition['endtime'])) {
                 $where[] = 'create_time <= UNIX_TIMESTAMP(' . $this->_db->quote($condition['endtime']) . ')';
             }*/
     if (isset($condition['createtime'])) {
         if (is_int($condition['createtime'])) {
             $where[] = 'create_time = ' . $condition['createtime'];
         } elseif (is_array($condition['createtime'])) {
             $arr = $condition['createtime'];
             if (isset($arr[0]) && is_int($arr[0])) {
                 $where[] = 'create_time >= ' . $arr[0];
             }
             if (isset($arr[1]) && is_int($arr[1])) {
                 $where[] = 'create_time <=' . $arr[1];
             }
         }
     }
     if (!empty($condition['keywords']) && Oray_Function::isByte($condition['keywords'])) {
         $keyword = $this->_db->quote('%' . $condition['keywords'] . '%');
         $where[] = "(user_id LIKE {$keyword} OR ip LIKE {$keyword})";
     }
     // WHERE
     $where = implode(' AND ', $where);
     // 格式化排序参数
     $sort = $this->_formatSort($sort);
     foreach ($sort as $key => $val) {
         switch ($key) {
             case 'createtime':
                 $key = 'create_time';
                 break;
             default:
                 continue 2;
                 break;
         }
         $order[] = $key . ' ' . $val;
     }
     // ORDER
     $order = implode(', ', $order);
     // 使用默认的分页大小
     if (null === $pageSize) {
         $pageSize = self::$_defaultPageSize;
     }
     /**
      * @see Oray_Db_Paginator
      */
     require_once 'Oray/Db/Paginator.php';
     // 初始化分页器
     $paginator = new Oray_Db_Paginator(array(Oray_Db_Paginator::ADAPTER => $this->_db, Oray_Db_Paginator::RECORD_CLASS => $recordClass, Oray_Db_Paginator::PAGE_SIZE => $pageSize, Oray_Db_Paginator::TABLE => $table, Oray_Db_Paginator::PRIMARY => $primary, Oray_Db_Paginator::COLUMNS => $columns, Oray_Db_Paginator::WHERE => $where, Oray_Db_Paginator::ORDER => $order));
     // 返回查询结果
     return $paginator->query($page);
 }
Exemple #4
0
 /**
  * 获取排班调整记录分页列表
  *
  * @param $condition
  * @param $sort
  * @param $pageSize
  * @param $page
  * @return Oray_Dao_Recordset
  */
 public function getAdjustPage(array $condition, $sort = null, $pageSize = null, $page = null)
 {
     $table = 'attend_schedule_adjust';
     $columns = 'org_id AS orgid, adjust_id AS adjustid, subject, start_time AS starttime, end_time AS endtime, type, ' . 'create_time AS createtime';
     $where = array();
     $bind = array();
     $order = '';
     $primary = 'adjust_id';
     $recordClass = 'Dao_App_Attend_Schedule_Record_Adjust';
     if (!empty($condition['orgid'])) {
         $where[] = 'org_id = :orgid';
         $bind['orgid'] = $condition['orgid'];
     }
     if (empty($where)) {
         return new Oray_Dao_Recordset();
     }
     $where = implode(' AND ', $where);
     $sort = $this->_formatSort($sort);
     foreach ($sort as $key => $val) {
         switch ($key) {
             case 'createtime':
                 $key = 'create_time';
                 break;
             default:
                 continue 2;
         }
         $order[] = $key . ' ' . $val;
     }
     $order = implode(', ', $order);
     // 使用默认的分页大小
     if (null === $pageSize) {
         $pageSize = self::$_defaultPageSize;
     }
     /**
      * @see Oray_Db_Paginator
      */
     require_once 'Oray/Db/Paginator.php';
     try {
         // 初始化分页器
         $paginator = new Oray_Db_Paginator(array(Oray_Db_Paginator::ADAPTER => $this->_db, Oray_Db_Paginator::RECORD_CLASS => $recordClass, Oray_Db_Paginator::PAGE_SIZE => $pageSize, Oray_Db_Paginator::TABLE => $table, Oray_Db_Paginator::PRIMARY => $primary, Oray_Db_Paginator::COLUMNS => $columns, Oray_Db_Paginator::WHERE => $where, Oray_Db_Paginator::ORDER => $order));
         // 返回查询结果
         return $paginator->query($page);
     } catch (Zend_Db_Exception $e) {
         $this->_catchException($e, __MEHOTD__);
         return new Oray_Dao_Recordset();
     }
 }
Exemple #5
0
 /**
  * 获取版块的图度列表
  *
  * SELECT
  * t.org_id AS orgid, t.board_id AS boardid, t.tudu_id AS tuduid, t.cycle_id AS cycleid,
  * t.type, t.subject, t.from, t.to, t.cc, t.priority, t.privacy,
  * t.last_post_time AS lastposttime, t.last_poster AS lastposter,
  * t.view_num AS viewnum, t.reply_num AS replynum, t.log_num AS lognum, t.percent, t.score, t.status,
  * t.special, t.start_time AS starttime, t.end_time AS endtime,
  * t.total_time AS totaltime, t.elapsed_time AS elapsedtime,
  * t.create_time AS createtime, t.accept_time AS accepttime,
  * p.post_id AS postid, '' AS content, '' AS posterinfo, p.attach_num AS attachnum,
  * tu.unique_id AS uniqueid, TRIM(LEADING ',' FROM tu.labels) labels,
  * tu.is_read AS isread, tu.is_forward AS isforward, is_draft AS isdraft, is_done AS isdone,
  * g.type AS nodetype, g.parent_tudu_id AS parentid
  *
  * FROM td_tudu t
  * LEFT JOIN td_tudu_group g ON g.tudu_id = p.tudu_id
  * LEFT JOIN td_post p ON p.tudu_id = t.tudu_id AND p.is_first = 1
  * LEFT JOIN td_tudu_user tu ON tu.tudu_id = t.tudu_id AND tu.unique_id = ?
  *
  * WHERE t.is_draft = 0
  * AND t.org_id = ?
  * AND t.board_id = ?
  *
  * @param array $condition
  * @param mixed $sort
  * @param int $page
  * @param int $pageSize
  * @return Oray_Dao_Recordset
  */
 public function getBoardTuduPage(array $condition = null, $sort = null, $page = null, $pageSize = null)
 {
     $uniqueId = isset($condition['uniqueid']) ? $this->_db->quote($condition['uniqueid']) : "''";
     $table = "td_tudu t " . "LEFT JOIN td_post p ON p.tudu_id = t.tudu_id AND p.is_first = 1 " . "LEFT JOIN td_tudu_group g ON g.tudu_id = p.tudu_id " . "LEFT JOIN td_class c ON t.class_id = c.class_id AND t.org_id = c.org_id AND t.board_id = c.board_id " . 'LEFT JOIN td_tudu_cycle tc ON tc.cycle_id = t.cycle_id ' . "LEFT JOIN td_tudu_user tu ON tu.tudu_id = t.tudu_id AND tu.unique_id = " . $uniqueId;
     $columns = "t.org_id AS orgid, t.board_id AS boardid, t.tudu_id AS tuduid, t.cycle_id AS cycleid, " . "t.type, t.subject, t.from, t.to, t.cc, t.priority, t.privacy, t.password, " . "t.last_post_time AS lastposttime, t.last_poster AS lastposter, t.flow_id AS flowid, " . "t.view_num AS viewnum, t.reply_num AS replynum, t.log_num AS lognum, t.percent, t.score, t.status, " . "t.special, t.start_time AS starttime, t.end_time AS endtime, t.need_confirm AS needconfirm, " . "t.total_time AS totaltime, t.elapsed_time AS elapsedtime, t.accep_mode AS accepmode, " . "t.create_time AS createtime, t.accept_time AS accepttime, " . "p.post_id AS postid, '' AS content, '' AS posterinfo, p.attach_num AS attachnum, " . "tu.unique_id AS uniqueid, TRIM(LEADING ',' FROM tu.labels) labels, tu.mark, " . "tu.is_read AS isread, tu.is_forward AS isforward, is_draft AS isdraft, is_done AS isdone, t.is_top AS istop, " . "t.class_id AS classid, c.class_name AS classname, tc.display_date AS displaydate, " . "g.type AS nodetype, g.parent_tudu_id AS parentid";
     $primary = "t.tudu_id";
     $recordClass = "Dao_Td_Tudu_Record_Tudu";
     $where = array();
     $order = array();
     if (isset($condition['orgid'])) {
         $where[] = 't.org_id = ' . $this->_db->quote($condition['orgid']);
     }
     if (isset($condition['boardid'])) {
         if (is_array($condition['boardid'])) {
             $where[] = 't.board_id IN(' . implode(',', array_map(array($this->_db, 'quote'), $condition['boardid'])) . ')';
         } else {
             $where[] = 't.board_id = ' . $this->_db->quote($condition['boardid']);
         }
     }
     // 关键字
     if (!empty($condition['keyword'])) {
         $keyword = $this->_db->quote('%' . $condition['keyword'] . '%');
         $where[] = 't.subject LIKE ' . $keyword;
     }
     // 发送人
     if (!empty($condition['from'])) {
         $from = $this->_db->quote('%' . $condition['from'] . '%');
         $where[] = 't.from LIKE ' . $from;
     }
     // 接收人
     if (!empty($condition['to'])) {
         $to = $this->_db->quote('%' . $condition['to'] . '%');
         $where[] = 't.to LIKE ' . $to;
     }
     // 主题分类
     if (isset($condition['classid'])) {
         $where[] = 'c.class_id = ' . $this->_db->quote($condition['classid']);
     }
     // 类型
     if (!empty($condition['type'])) {
         if (is_array($condition['type'])) {
             $where[] = 't.type IN ( ' . implode(',', array_map(array($this->_db, 'quote'), $condition['type'])) . ')';
         } else {
             $where[] = 't.type = ' . $this->_db->quote($condition['type']);
         }
     }
     if (isset($condition['priority']) && is_int($condition['priority'])) {
         $where[] = 't.priority = ' . $condition['priority'];
     }
     if (isset($condition['status']) && is_int($condition['status'])) {
         $where[] = 't.status = ' . $condition['status'];
     }
     // 创建时间
     if (isset($condition['createtime'])) {
         if (is_array($condition['createtime'])) {
             $array = array();
             if (isset($condition['createtime']['start']) && is_int($condition['createtime']['start'])) {
                 $array[] = 't.create_time >= ' . $condition['createtime']['start'];
             }
             if (isset($condition['createtime']['end']) && is_int($condition['createtime']['end'])) {
                 $array[] = 't.create_time <= ' . $condition['createtime']['end'];
             }
             if ($array) {
                 $where[] = '(' . implode(' AND ', $array) . ')';
             }
         } elseif (is_int($condition['createtime'])) {
             $where[] = 't.create_time >= ' . $condition['createtime'];
         }
     }
     // 创建时间
     if (isset($condition['endtime'])) {
         if (is_array($condition['endtime'])) {
             $array = array();
             if (isset($condition['endtime']['start']) && is_int($condition['endtime']['start'])) {
                 $array[] = 't.end_time >= ' . $condition['endtime'];
             }
             if (isset($condition['endtime']['end']) && is_int($condition['endtime']['end'])) {
                 $array[] = 't.end_time <= ' . $condition['endtime'];
             }
             if ($array) {
                 $where[] = '(' . implode(' AND ', $array) . ')';
             }
         } elseif (is_int($condition['endtime'])) {
             $where[] = 't.end_time >= ' . $condition['endtime'];
         }
     }
     // 过期
     if (isset($condition['expiredate']) && is_int($condition['expiredate'])) {
         $where[] = '(t.is_done <> 1 OR t.create_time >= ' . $condition['expiredate'] . ')';
     }
     // 过滤草稿
     $where[] = 't.is_draft = 0';
     if (isset($condition['privacy'])) {
         $where[] = '(t.privacy = 0 OR tu.unique_id = ' . $uniqueId . ')';
     }
     if (isset($condition['self'])) {
         $where[] = 'tu.unique_id = ' . $uniqueId;
     }
     // WHERE
     $where = implode(' AND ', $where);
     // 格式化排序参数
     $sort = $this->_formatSort($sort);
     foreach ($sort as $key => $val) {
         switch ($key) {
             case 'lastposttime':
                 $key = 'last_post_time';
                 break;
             case 'subject':
                 $key = 'subject';
                 break;
             case 'endtime':
                 $key = 'end_time';
                 break;
             case 'istop':
                 $key = 'is_top';
                 break;
             default:
                 continue 2;
                 break;
         }
         $order[] = $key . ' ' . $val;
     }
     // ORDER
     $order = implode(', ', $order);
     // 使用默认的分页大小
     if (null === $pageSize) {
         $pageSize = self::$_defaultPageSize;
     }
     /**
      * @see Oray_Db_Paginator
      */
     require_once 'Oray/Db/Paginator.php';
     // 初始化分页器
     $paginator = new Oray_Db_Paginator(array(Oray_Db_Paginator::ADAPTER => $this->_db, Oray_Db_Paginator::RECORD_CLASS => $recordClass, Oray_Db_Paginator::PAGE_SIZE => $pageSize, Oray_Db_Paginator::TABLE => $table, Oray_Db_Paginator::PRIMARY => $primary, Oray_Db_Paginator::COLUMNS => $columns, Oray_Db_Paginator::WHERE => $where, Oray_Db_Paginator::ORDER => $order));
     // 返回查询结果
     return $paginator->query($page);
 }
Exemple #6
0
 /**
  *
  * @param array $condition
  * @param mixd  $sort
  * @param int   $page
  * @param int   $pageSize
  * @return Oray_Dao_Recordset
  */
 public function getRealNamePage(array $condition, $sort = null, $page = null, $pageSize = null)
 {
     $table = 'md_org_realname r ' . 'LEFT JOIN md_organization o ON r.org_id = o.org_id ' . 'LEFT JOIN md_org_info oi ON r.org_id = oi.org_id ';
     $columns = 'r.realname_id AS realnameid, r.org_id AS orgid, r.status, r.create_time AS createtime, ' . 'r.update_time AS updatetime, o.org_name AS orgname, oi.entire_name AS entirename';
     $recordClass = 'Dao_Md_Org_Record_Real';
     $primary = 'r.realname_id';
     $where = array();
     $order = array();
     $limit = '';
     if (!empty($condition['orgid'])) {
         $where[] = 'r.org_id = ' . $this->_db->quote($condition['orgid']);
     }
     if (!empty($condition['orgname'])) {
         $where[] = 'o.org_name LIKE ' . $this->_db->quote('%' . $condition['orgname'] . '%');
     }
     if (!empty($condition['entirename'])) {
         $where[] = 'oi.entire_name LIKE ' . $this->_db->quote('%' . $condition['entirename'] . '%');
     }
     if (!empty($condition['domainname'])) {
         $where[] = 'd.domain_name = ' . $this->_db->quote($condition['domainname']);
     }
     if (isset($condition['status']) && is_int($condition['status'])) {
         $where[] = 'r.status = ' . $this->_db->quote($condition['status']);
     }
     if (isset($condition['createtime']) && is_array($condition['createtime'])) {
         $c = array();
         if (isset($condition['createtime']['start'])) {
             $c[] = 'r.create_time >= ' . $condition['createtime']['start'];
         }
         if (isset($condition['createtime']['end'])) {
             $c[] = 'r.create_time <= ' . $condition['createtime']['end'];
         }
         if ($c) {
             $where[] = '(' . implode(' AND ', $c) . ')';
         }
     }
     if (isset($condition['updatetime']) && is_array($condition['updatetime'])) {
         $u = array();
         if (isset($condition['updatetime']['start'])) {
             $u[] = 'r.update_time >= ' . $condition['updatetime']['start'];
         }
         if (isset($condition['updatetime']['end'])) {
             $u[] = 'r.update_time <= ' . $condition['updatetime']['end'];
         }
         if ($u) {
             $where[] = '(' . implode(' AND ', $u) . ')';
         }
     }
     if (!empty($where)) {
         $where = implode(' AND ', $where);
     } else {
         $where = '';
     }
     // 排序
     $sort = $this->_formatSort($sort);
     foreach ($sort as $key => $val) {
         switch ($key) {
             case 'createtime':
                 $key = 'r.create_time';
                 break;
             case 'updatetime':
                 $key = 'r.update_time';
                 break;
             case 'status':
                 $key = 'r.status';
                 break;
             default:
                 continue 2;
                 break;
         }
         $order[] = $key . ' ' . $val;
     }
     // ORDER
     $order = implode(', ', $order);
     // 使用默认的分页大小
     if (null === $pageSize) {
         $pageSize = self::$_defaultPageSize;
     }
     /**
      * @see Oray_Db_Paginator
      */
     require_once 'Oray/Db/Paginator.php';
     // 初始化分页器
     $paginator = new Oray_Db_Paginator(array(Oray_Db_Paginator::ADAPTER => $this->_db, Oray_Db_Paginator::RECORD_CLASS => $recordClass, Oray_Db_Paginator::PAGE_SIZE => $pageSize, Oray_Db_Paginator::TABLE => $table, Oray_Db_Paginator::PRIMARY => $primary, Oray_Db_Paginator::COLUMNS => $columns, Oray_Db_Paginator::WHERE => $where, Oray_Db_Paginator::ORDER => $order));
     // 返回查询结果
     return $paginator->query($page);
 }
Exemple #7
0
 /**
  * Set the default page size
  *
  * @param int $size
  */
 public static function setDefaultPageSize($size)
 {
     self::$_defaultPageSize = (int) $size;
 }
Exemple #8
0
 /**
  * 获取配置用户分页
  *
  * @param array $condition
  * @param mixed $sort
  * @param int   $page
  * @param int   $pageSize
  * @return Oray_Dao_Recordset
  */
 public function getCastUserPage($condition, $sort, $page = null, $pageSize = null)
 {
     if (empty($condition['orgid']) || empty($condition['castid'])) {
         return new Oray_Dao_Recordset();
     }
     $table = 'v_cast_user AS V ' . 'LEFT JOIN md_user_info AS UI ON V.user_id = UI.user_id AND V.org_id = UI.org_id ' . 'LEFT JOIN md_department AS D ON V.dept_id = D.dept_id ';
     $columns = 'V.org_id AS orgid, V.unique_id AS uniqueid, V.true_name AS truename, V.user_id AS userid, V.dept_id AS deptid, ' . 'V.domain_name AS domainname, UI.tel, UI.mobile, UI.position, D.dept_name AS deptname';
     $where = array();
     $order = array();
     $primary = 'V.user_id';
     $recordClass = 'Dao_Md_Cast_Record_UserPage';
     $where[] = 'V.org_id = ' . $this->_db->quote($condition['orgid']);
     $where[] = 'V.cast_id = ' . $this->_db->quote($condition['castid']);
     if (!empty($condition['userid'])) {
         $where[] = 'V.user_id = ' . $this->_db->quote($condition['userid']);
     }
     if (!empty($condition['domain'])) {
         $where[] = 'V.domain_name = ' . $this->_db->quote($condition['domain']);
     }
     if (!empty($condition['domainid'])) {
         $where[] = 'U.domain_id = ' . $this->_db->quote($condition['domainid']);
     }
     if (!empty($condition['deptid'])) {
         if (is_array($condition['deptid'])) {
             $condition['deptid'] = array_map(array($this->_db, 'quote'), $condition['deptid']);
             $where[] = 'V.dept_id IN (' . implode(',', $condition['deptid']) . ')';
         } else {
             $where[] = 'V.dept_id = ' . $this->_db->quote($condition['deptid']);
         }
     }
     if (!empty($condition['keyword'])) {
         $keyword = $this->_db->quote('%' . $condition['keyword'] . '%');
         $where[] = "(V.true_name LIKE {$keyword} OR V.pinyin LIKE {$keyword} OR V.user_id LIKE {$keyword})";
     }
     if (!$where) {
         return new Oray_Dao_Recordset();
     }
     // WHERE
     $where = implode(' AND ', $where);
     // 排序
     $sort = $this->_formatSort($sort);
     foreach ($sort as $key => $val) {
         switch ($key) {
             default:
                 continue 2;
                 break;
         }
         $order[] = $key . ' ' . $val;
     }
     // ORDER
     $order = implode(', ', $order);
     // 使用默认的分页大小
     if (null === $pageSize) {
         $pageSize = self::$_defaultPageSize;
     }
     /**
      * @see Oray_Db_Paginator
      */
     require_once 'Oray/Db/Paginator.php';
     $paginator = new Oray_Db_Paginator(array(Oray_Db_Paginator::ADAPTER => $this->_db, Oray_Db_Paginator::TABLE => $table, Oray_Db_Paginator::COLUMNS => $columns, Oray_Db_Paginator::ORDER => $order, Oray_Db_Paginator::PRIMARY => $primary, Oray_Db_Paginator::WHERE => $where, Oray_Db_Paginator::PAGE_SIZE => $pageSize, Oray_Db_Paginator::RECORD_CLASS => $recordClass));
     return $paginator->query($page);
 }
Exemple #9
0
 /**
  *
  * @param $condition
  * @param $filter
  * @param $sort
  * @param $maxCount
  */
 public function getCastUserPage(array $condition, $sort = null, $page = null, $pageSize = null)
 {
     if (empty($condition['orgid']) || empty($condition['userid'])) {
         return new Oray_Dao_Recordset();
     }
     $orgId = $this->_db->quote($condition['orgid']);
     $userId = $this->_db->quote($condition['userid']);
     $table = 'md_user AS U ' . "LEFT JOIN md_cast_disable_user AS CU ON CU.org_id = U.org_id AND CU.user_id = U.user_id AND CU.owner_id = {$userId} " . 'LEFT JOIN md_user_info AS UI ON U.org_id = UI.org_id AND U.user_id = UI.user_id ' . 'LEFT JOIN md_department DE ON U.org_id = DE.org_id AND U.dept_id = DE.dept_id';
     $columns = 'U.org_id AS orgid, UI.true_name AS truename, U.user_id AS userid, mobile, ' . 'U.dept_id AS deptid, DE.dept_name AS deptname, UI.pinyin, U.unique_id AS uniqueid, ' . 'UI.position, UI.tel';
     $where = array();
     $order = array();
     $recordClass = 'Dao_Md_User_Record_Users';
     $primary = 'U.org_id';
     //$where[] = 'CU.org_id =' . $orgId;
     //$where[] = 'CU.owner_id =' . $userId;
     $where[] = 'U.org_id =' . $orgId;
     $where[] = 'CU.user_id IS NULL';
     $where[] = 'U.status <> 0 AND U.is_show = 1';
     if (!empty($condition['keyword'])) {
         $keyword = $this->_db->quote('%' . $condition['keyword'] . '%');
         $like[] = "UI.true_name LIKE {$keyword}";
         if (Oray_Function::isByte($keyword)) {
             $like[] = "UI.pinyin LIKE {$keyword}";
             $like[] = "U.user_id LIKE {$keyword}";
         }
         $where[] = '(' . implode(' OR ', $like) . ')';
     }
     if (!empty($condition['pinyin'])) {
         $keyword = $this->_db->quote($condition['pinyin'] . '%');
         $where[] = "(U.true_name LIKE {$keyword} OR UI.pinyin LIKE {$keyword})";
     }
     if (!empty($condition['deptid']) && is_array($condition['deptid'])) {
         foreach ($condition['deptid'] as $deptId) {
             $dept[] = 'U.dept_id = ' . $this->_db->quote($deptId);
         }
         $where[] = '(' . implode(' OR ', $dept) . ')';
     }
     // WHERE
     $where = implode(' AND ', $where);
     // 排序
     $sort = $this->_formatSort($sort);
     foreach ($sort as $key => $val) {
         switch ($key) {
             case 'ordernum':
                 $key = 'U.order_num';
                 break;
             case 'userid':
                 $key = 'U.user_id';
                 break;
             case 'deptid':
                 $key = 'U.dept_id';
                 break;
             default:
                 continue 2;
                 break;
         }
         $order[] = $key . ' ' . $val;
     }
     // ORDER
     $order = implode(', ', $order);
     // 使用默认的分页大小
     if (null === $pageSize) {
         $pageSize = self::$_defaultPageSize;
     }
     /**
      * @see Oray_Db_Paginator
      */
     require_once 'Oray/Db/Paginator.php';
     $paginator = new Oray_Db_Paginator(array(Oray_Db_Paginator::ADAPTER => $this->_db, Oray_Db_Paginator::TABLE => $table, Oray_Db_Paginator::COLUMNS => $columns, Oray_Db_Paginator::ORDER => $order, Oray_Db_Paginator::PRIMARY => $primary, Oray_Db_Paginator::WHERE => $where, Oray_Db_Paginator::PAGE_SIZE => $pageSize, Oray_Db_Paginator::RECORD_CLASS => $recordClass));
     return $paginator->query($page);
 }
Exemple #10
0
 /**
  * Get record page
  * 
  * @param array $condition
  * @param mixed $sort
  * @param int $page
  * @param int $pageSize
  * @return Oray_Dao_Recordset
  */
 public function getRecordPage(array $condition = null, $sort = null, $page = null, $pageSize = null)
 {
     $table = "";
     $columns = "";
     $primary = "";
     $recordClass = "Oray_Dao_Record";
     $where = array();
     $order = array();
     // $condition...
     // WHERE
     $where = implode(' AND ', $where);
     // 格式化排序参数
     $sort = $this->_formatSort($sort);
     foreach ($sort as $key => $val) {
         switch ($key) {
             default:
                 continue 2;
                 break;
         }
         $order[] = $key . ' ' . $val;
     }
     // ORDER
     $order = implode(', ', $order);
     // 使用默认的分页大小
     if (null === $pageSize) {
         $pageSize = self::$_defaultPageSize;
     }
     /**
      * @see Oray_Db_Paginator
      */
     require_once 'Oray/Db/Paginator.php';
     // 初始化分页器
     $paginator = new Oray_Db_Paginator(array(Oray_Db_Paginator::ADAPTER => $this->_db, Oray_Db_Paginator::RECORD_CLASS => $recordClass, Oray_Db_Paginator::PAGE_SIZE => $pageSize, Oray_Db_Paginator::TABLE => $table, Oray_Db_Paginator::PRIMARY => $primary, Oray_Db_Paginator::COLUMNS => $columns, Oray_Db_Paginator::WHERE => $where, Oray_Db_Paginator::ORDER => $order));
     // 返回查询结果
     return $paginator->query($page);
 }
Exemple #11
0
 /**
  * 获取审批分页列表
  *
  * @param $condition
  * @param $sort
  * @param $page
  * @param $pageSize
  */
 public function getApplyPage(array $condition, $sort = null, $page = null, $pageSize = null)
 {
     $table = 'attend_apply AS A LEFT JOIN attend_category AS C ON A.org_id = C.org_id AND A.category_id = C.category_id ';
     $columns = 'A.apply_id AS applyid, A.org_id AS orgid, A.tudu_id AS tuduid, A.category_id AS categoryid, A.unique_id AS uniqueid, A.period, ' . 'A.sender_id AS senderid, A.user_info AS userinfo, A.start_time AS starttime, A.end_time AS endtime, A.status, ' . 'A.is_allday AS isallday, A.create_time AS createtime, C.category_name as categoryname';
     $where = array();
     $bind = array();
     $primary = 'A.apply_id';
     $recordClass = 'Dao_App_Attend_Record_Apply';
     if (!empty($condition['uniqueid'])) {
         if (is_array($condition['uniqueid'])) {
             foreach ($condition['uniqueid'] as $item) {
                 $uniqueIds[] = $this->_db->quote($item);
             }
             $where[] = 'A.unique_id IN (' . implode(',', $uniqueIds) . ')';
         } else {
             $where[] = 'A.unique_id = ' . $this->_db->quote($condition['uniqueid']);
         }
     }
     if (!empty($condition['senderid'])) {
         $where[] = 'A.sender_id = ' . $this->_db->quote($condition['senderid']);
     }
     if (!empty($condition['categoryid'])) {
         $where[] = 'A.category_id = ' . $this->_db->quote($condition['categoryid']);
     }
     if (!empty($condition['starttime'])) {
         $where[] = 'A.start_time >= ' . $this->_db->quote($condition['starttime']);
     }
     if (!empty($condition['endtime'])) {
         $where[] = 'A.end_time <= ' . $this->_db->quote($condition['endtime']);
     }
     if (!empty($condition['startdate']) && !empty($condition['enddate'])) {
         $start = (int) $condition['startdate'];
         $end = (int) $condition['enddate'];
         $where[] = "(A.start_time >= {$start} AND A.end_time <= {$end} " . "OR (A.end_time IS NULL AND A.start_time >= {$start} AND A.start_time <= {$end}) " . "OR (A.start_time IS NULL AND A.end_time <= {$end} AND A.end_time >= {$start}))";
     }
     if (isset($condition['status'])) {
         $where[] = 'A.status = ' . $this->_db->quote($condition['status']);
     }
     if (!empty($condition['orgid'])) {
         $where[] = 'A.org_id = ' . $this->_db->quote($condition['orgid']);
     }
     if (!empty($condition['reviewerid'])) {
         $reviewerId = $this->_db->quote($condition['reviewerid']);
         $table .= 'LEFT JOIN attend_apply_reviewer AS R ON A.apply_id = R.apply_id AND R.unique_id = ' . $reviewerId;
         $columns .= ', R.review_status AS reviewstatus';
         $cond = 'R.unique_id = ' . $reviewerId;
         if (!empty($condition['associateid'])) {
             $condition['associateid'] = array_map(array($this->_db, 'quote'), $condition['associateid']);
             $cond .= ' OR A.unique_id IN (' . implode(',', $condition['associateid']) . ')';
         }
         $where[] = '(' . $cond . ')';
     }
     $where[] = 'A.status >= 0';
     if (empty($where)) {
         return new Oray_Dao_Recordset();
     }
     $where = implode(' AND ', $where);
     $sort = $this->_formatSort($sort);
     foreach ($sort as $key => $val) {
         switch ($key) {
             case 'createtime':
                 $key = 'A.create_time';
                 break;
             default:
                 continue 2;
         }
         $order[] = $key . ' ' . $val;
     }
     $order = implode(', ', $order);
     // 使用默认的分页大小
     if (null === $pageSize) {
         $pageSize = self::$_defaultPageSize;
     }
     /**
      * @see Oray_Db_Paginator
      */
     require_once 'Oray/Db/Paginator.php';
     // 初始化分页器
     $paginator = new Oray_Db_Paginator(array(Oray_Db_Paginator::ADAPTER => $this->_db, Oray_Db_Paginator::RECORD_CLASS => $recordClass, Oray_Db_Paginator::PAGE_SIZE => $pageSize, Oray_Db_Paginator::TABLE => $table, Oray_Db_Paginator::PRIMARY => $primary, Oray_Db_Paginator::COLUMNS => $columns, Oray_Db_Paginator::WHERE => $where, Oray_Db_Paginator::ORDER => $order));
     // 返回查询结果
     return $paginator->query($page);
 }