コード例 #1
0
ファイル: Equip.php プロジェクト: null-1/fangtaitong
 /**
  * verify
  * 
  * @param array $record
  * @return bool
  */
 public function verify($record)
 {
     if (empty($record) || !is_array($record)) {
         return false;
     }
     if (isset($record['re_hid'])) {
         if (!Zyon_Util::isUnsignedInt($record['re_hid']) || empty($record['re_hid']) || strlen($record['re_hid']) > 10) {
             return false;
         }
     }
     if (isset($record['re_rid'])) {
         if (!Zyon_Util::isUnsignedInt($record['re_rid']) || empty($record['re_rid']) || strlen($record['re_rid']) > 10) {
             return false;
         }
     }
     if (isset($record['re_type'])) {
         if (!Zyon_Util::isInt($record['re_type']) || !in_array($record['re_type'], static::$_types, true) || strlen($record['re_type']) > 3) {
             return false;
         }
     }
     if (isset($record['re_qnty'])) {
         if (!Zyon_Util::isUnsignedInt($record['re_qnty']) || strlen($record['re_qnty']) > 5) {
             return false;
         }
     }
     if (isset($record['re_name'])) {
         if (!is_string($record['re_name']) || trim($record['re_name']) == '' || mb_strlen($record['re_name']) > 30) {
             return false;
         }
     }
     return true;
 }
コード例 #2
0
ファイル: Journal.php プロジェクト: null-1/fangtaitong
 /**
  * verify
  * 
  * @param array $record
  * @return bool
  */
 public function verify($record)
 {
     if (empty($record) || !is_array($record)) {
         return false;
     }
     if (isset($record['bj_hid'])) {
         if (!Zyon_Util::isUnsignedInt($record['bj_hid']) || empty($record['bj_hid']) || strlen($record['bj_hid']) > 10) {
             return false;
         }
     }
     if (isset($record['bj_bid'])) {
         if (!Zyon_Util::isUnsignedInt($record['bj_bid']) || empty($record['bj_bid']) || strlen($record['bj_bid']) > 10) {
             return false;
         }
     }
     if (isset($record['bj_uid'])) {
         if (!Zyon_Util::isUnsignedInt($record['bj_uid']) || empty($record['bj_uid']) || strlen($record['bj_uid']) > 10) {
             return false;
         }
     }
     if (isset($record['bj_sum'])) {
         if (!Zyon_Util::isInt($record['bj_sum']) || strlen($record['bj_sum']) > 10) {
             return false;
         }
     }
     if (isset($record['bj_time'])) {
         if (!Zyon_Util::isUnsignedInt($record['bj_time']) || strlen($record['bj_time']) > 11) {
             return false;
         }
     }
     if (isset($record['bj_user'])) {
         if (!is_string($record['bj_user']) || mb_strlen($record['bj_user']) > 20) {
             return false;
         }
     }
     if (isset($record['bj_memo'])) {
         if (!is_string($record['bj_memo']) || mb_strlen($record['bj_memo']) > 200) {
             return false;
         }
     }
     if (isset($record['bj_pid'])) {
         if (!Zyon_Util::isUnsignedInt($record['bj_pid']) || strlen($record['bj_pid']) > 10) {
             return false;
         }
     }
     if (isset($record['bj_pynm'])) {
         if (!is_string($record['bj_pynm']) || mb_strlen($record['bj_pynm']) > 30) {
             return false;
         }
     }
     return true;
 }
コード例 #3
0
 /**
  * 时间轴
  */
 public function indexAction()
 {
     $rosta = array('time' => time(), 'line' => array(), 'room' => array(), 'data' => array());
     $date = $this->input('date');
     $lgth = $this->input('lgth');
     $skip = $this->input('skip');
     $rids = $this->input('rids');
     $time = strtotime(Zyon_Util::isDate($date) ? $date : ($date = date('Y-m-d', $rosta['time'] - 86400)));
     if (!Zyon_Util::isInt($lgth)) {
         $lgth = 8;
     }
     $lgth = (int) $lgth;
     if (abs($lgth) > 30 || abs($lgth) < 2) {
         $this->flash(0, '入住时间和离店时间间隔最少 2天,最长 30天');
     }
     $lgth = $lgth > 0 ? $lgth - 1 : $lgth + 1;
     // 订单查询默认条件
     $where = array('o_hid = ' . $this->model('order')->quote($this->_master['u_hid']), 'o_status <> ' . $this->model('order')->quote(ORDER_STATUS_YQX));
     // 指定房间编号集合
     if ($rids) {
         $rids = explode(',', $rids);
         if (empty($rids)) {
             $rooms = array();
         } else {
             $rooms = Zyon_Array::keyto($this->model('room')->getRoomAryByIds($rids, $this->_master['u_hid']), 'r_id');
         }
     } else {
         $rooms = Zyon_Array::keyto($this->model('room')->getRoomAryByHid($this->_master['u_hid']), 'r_id');
     }
     if (!empty($rooms)) {
         foreach ($rooms as $key => &$room) {
             if ($room['r_attr'] & ROOM_ATTR_YCFT) {
                 unset($rooms[$key]);
             }
         }
         unset($room);
         if (!empty($rooms)) {
             // 增加查询房间限定
             $where[] = sprintf('o_rid IN (%s)', implode(',', array_keys($rooms)));
         }
     }
     // 取得上(下)一个有订单时间临界点
     if (!empty($rooms) && $skip) {
         if ($lgth < 0) {
             $orders = $this->model('order')->fetch(array('where' => array_merge($where, array('o_etime < ' . $this->model('order')->quote($time))), 'order' => 'o_etime DESC', 'field' => 'o_edatm', 'limit' => 1));
             if ($orders) {
                 $time = (int) $orders[0]['o_edatm'];
             }
         } else {
             $orders = $this->model('order')->fetch(array('where' => array_merge($where, array('o_btime > ' . $this->model('order')->quote($time))), 'order' => 'o_btime ASC', 'field' => 'o_bdatm', 'limit' => 1));
             if ($orders) {
                 $time = (int) $orders[0]['o_bdatm'];
             }
         }
     }
     // 令 {$time} 为左值
     if ($lgth < 0) {
         $time = $time + $lgth * 86400;
         $lgth = abs($lgth);
     }
     $btime = $time;
     $etime = $btime + $lgth * 86400 + 86399;
     $rosta['line'][] = $btime;
     $rosta['line'][] = $etime;
     if (!empty($rooms)) {
         $obnum = $this->model('order')->calNumAryByRidAryAndSta(array_keys($rooms), ORDER_STATUS_YD, $rosta['time'] - 86400 * 3);
         foreach ($rooms as &$room) {
             $rosta['data'][$room['r_id']] = array();
             $rosta['room'][$room['r_id']] = array('rid' => $room['r_id'], 'sta' => $room['r_status'], 'rnm' => $this->view->escape($room['r_name']), 'ext' => array('rtp' => $this->view->escape($room['r_type']), 'rlo' => $this->view->escape($room['r_layout']), 'rze' => $this->view->escape($room['r_zone']), 'rvw' => $this->model('room')->getViewListByCode($room['r_view'])), 'ovt' => (int) $room['r_otime'], 'lvt' => (int) $room['r_btime'], 'rvt' => (int) $room['r_etime'], 'obn' => (int) (isset($obnum[$room['r_id']]) ? $obnum[$room['r_id']] : 0));
         }
         unset($room);
         $orders = Zyon_Array::keyto($this->model('order')->fetchAry(array_merge($where, array('o_btime < ' . $this->model('order')->quote($etime), 'o_etime > ' . $this->model('order')->quote($btime))), 'o_id DESC'), 'o_id');
         if (!empty($orders)) {
             $others = array();
             $owhere = array();
             foreach ($orders as &$order) {
                 $rosta['data'][$order['o_rid']][$order['o_id']] = array('key' => $order['o_mtime'], 'oid' => $order['o_id'], 'bid' => $order['o_bid'], 'ats' => (int) $order['o_attr'], 'sta' => (int) $order['o_status'], 'lvt' => $order['o_btime'], 'rvt' => $order['o_etime'], 'act' => $this->model('order')->getUsableActions($order, $this->_hostel, false), 'gst' => array('bkg' => array(array('gnm' => $this->view->escape($order['o_gbker_name']), 'tel' => $this->view->escape($order['o_gbker_phone']))), 'lvg' => array(array('gnm' => $this->view->escape($order['o_glver_name']), 'tel' => $this->view->escape($order['o_glver_phone'])))));
                 if ($order['o_memo'] == '') {
                     $rosta['data'][$order['o_rid']][$order['o_id']]['tip'] = '';
                 }
                 // 检测订单与房态的冲突
                 if ($order['o_btime'] <= $rooms[$order['o_rid']]['r_etime'] && $order['o_edatm'] > $rooms[$order['o_rid']]['r_btime']) {
                     unset($rosta['data'][$order['o_rid']][$order['o_id']]['act'][ORDER_ACTION_BLDD]);
                     unset($rosta['data'][$order['o_rid']][$order['o_id']]['act'][ORDER_ACTION_BLRZ]);
                 }
                 // 拆分占位和不占位订单
                 if ($order['o_status'] == ORDER_STATUS_YD) {
                     $owhere = empty($owhere) ? array(min($order['o_btime'], $btime), max($order['o_etime'], $etime)) : array(min($order['o_btime'], $owhere[0]), max($order['o_etime'], $owhere[1]));
                 } else {
                     $others[$order['o_id']] = $order;
                     unset($orders[$order['o_id']]);
                 }
             }
             unset($order);
             // 获取扩展时间段的订单
             if (!empty($owhere) && ($owhere[0] < $btime || $owhere[1] > $etime)) {
                 $others += Zyon_Array::keyto($this->model('order')->fetch(array('where' => array_merge($where, array(sprintf('o_id NOT IN (%s)', implode(',', array_merge(array_keys($orders), array_keys($others)))), 'o_status <> ' . $this->model('order')->quote(ORDER_STATUS_YD), 'o_btime < ' . $this->model('order')->quote($owhere[1]), 'o_etime > ' . $this->model('order')->quote($owhere[0]))), 'field' => array('o_id', 'o_rid', 'o_btime', 'o_etime'))), 'o_id');
             }
             // 检测不占位的订单冲突
             foreach ($orders as &$order) {
                 foreach ($others as &$other) {
                     if ($other['o_rid'] === $order['o_rid'] && $other['o_btime'] < $order['o_etime'] && $other['o_etime'] > $order['o_btime']) {
                         unset($rosta['data'][$order['o_rid']][$order['o_id']]['act'][ORDER_ACTION_BLDD]);
                         unset($rosta['data'][$order['o_rid']][$order['o_id']]['act'][ORDER_ACTION_BLRZ]);
                         break;
                     }
                 }
                 unset($other);
             }
             unset($order, $orders, $others);
         }
     }
     if ($this->input('ct') === 'json') {
         $this->flash(1, array('context' => $rosta));
     }
     $this->view->hotel = $this->_hostel;
     $this->view->rosta = $rosta;
 }
コード例 #4
0
 /**
  * 旅店房态
  */
 public function indexAction()
 {
     $this->checkHotelStat($hotel = $this->loadUsableHotel($this->input('hid')));
     if ((!$this->_master || $this->_master['u_hid'] !== $hotel['h_id']) && !(SYSTEM_GROUPS_GSER & (int) $hotel['h_rosta_visible'])) {
         $this->flash(0, '旅店尚未开放该功能');
     }
     $rosta = array('time' => time(), 'line' => array(), 'room' => array(), 'data' => array());
     $date = $this->input('date');
     $lgth = $this->input('lgth');
     $time = strtotime(Zyon_Util::isDate($date) ? $date : ($date = date('Y-m-d', $rosta['time'])));
     if (!Zyon_Util::isInt($lgth)) {
         $lgth = 8;
     }
     $lgth = (int) $lgth;
     if (abs($lgth) > 30 || abs($lgth) < 2) {
         $this->flash(0, '入住时间和离店时间间隔最少 2天,最长 30天');
     }
     $lgth = $lgth > 0 ? $lgth - 1 : $lgth + 1;
     // 令 {$time} 为左值
     if ($lgth < 0) {
         $time = $time + $lgth * 86400;
         $lgth = abs($lgth);
     }
     $btime = $time;
     $etime = $btime + $lgth * 86400 + 86399;
     $rosta['line'][] = $btime;
     $rosta['line'][] = $etime;
     if ($btime > $rosta['time'] - 86400) {
         // 订单查询默认条件
         $where = array('o_hid = ' . $this->model('order')->quote($hotel['h_id']), 'o_status <> ' . $this->model('order')->quote(ORDER_STATUS_YQX));
         $rooms = Zyon_Array::keyto($this->model('room')->getRoomAryByHid($hotel['h_id']), 'r_id');
         if (!empty($rooms)) {
             foreach ($rooms as $key => &$room) {
                 if ($room['r_attr'] & ROOM_ATTR_YCFT) {
                     unset($rooms[$key]);
                     continue;
                 }
                 $rosta['data'][$room['r_id']] = array();
                 $rosta['rent'][$room['r_id']] = array();
                 $rosta['room'][$room['r_id']] = array('rid' => $room['r_id'], 'rnm' => $this->view->escape($room['r_name']), 'ext' => array('rtp' => $this->view->escape($room['r_type']), 'rlo' => $this->view->escape($room['r_layout']), 'rze' => $this->view->escape($room['r_zone']), 'rvw' => $this->model('room')->getViewListByCode($room['r_view'])));
                 if ($btime < $room['r_otime']) {
                     $_r_btime = $btime;
                     $_r_otime = min($etime, $room['r_otime']);
                     while ($_r_btime < $_r_otime) {
                         $rosta['data'][$room['r_id']][($_r_btime - $btime) / 86400] = ROSTA_BL;
                         $_r_btime += 86400;
                     }
                 }
                 if ($room['r_btime']) {
                     $_r_btime = max($btime, $room['r_btime']);
                     $_r_etime = min($etime, $room['r_etime']);
                     while ($_r_btime < $_r_etime) {
                         $rosta['data'][$room['r_id']][($_r_btime - $btime) / 86400] = ROSTA_BL;
                         $_r_btime += 86400;
                     }
                 }
             }
             unset($room);
         }
         if (!empty($rooms)) {
             // 增加查询房间限定
             $where[] = sprintf('o_rid IN (%s)', implode(',', array_keys($rooms)));
             $orders = Zyon_Array::keyto($this->model('order')->getOrderAryByIds($this->model('order')->fetchIds(array_merge($where, array('o_bdatm < ' . $this->model('order')->quote($etime), 'o_edatm > ' . $this->model('order')->quote($btime))))), 'o_id');
             if (!empty($orders)) {
                 foreach ($orders as &$order) {
                     switch ($order['o_status']) {
                         case ORDER_STATUS_YD:
                             $sta = ROSTA_YD;
                             break;
                         default:
                             $sta = ROSTA_BL;
                             break;
                     }
                     $_o_btime = max($btime, $order['o_bdatm']);
                     $_o_etime = min($etime, $order['o_edatm']);
                     while ($_o_btime < $_o_etime) {
                         $key = ($_o_btime - $btime) / 86400;
                         if (!isset($rosta['data'][$order['o_rid']][$key]) || $rosta['data'][$order['o_rid']][$key] !== ROSTA_BL) {
                             $rosta['data'][$order['o_rid']][$key] = $sta;
                         }
                         $_o_btime += 86400;
                     }
                 }
                 unset($order);
             }
             $prices = $this->model('room.price')->getPriceDotAryByHid($hotel['h_id'], $btime, $etime);
             if (!empty($prices)) {
                 foreach ($prices as $rid => &$lst) {
                     if (isset($rooms[$rid])) {
                         foreach ($lst as $dtm => $val) {
                             $val = (int) $val;
                             if (($end = end($rosta['rent'][$rid])) !== false && $end === $val) {
                                 unset($rosta['rent'][$rid][$key = key($rosta['rent'][$rid])]);
                                 $key = explode(',', $key);
                                 $key[1] = ($dtm - $btime) / 86400;
                                 $rosta['rent'][$rid][implode(',', $key)] = $val;
                             } else {
                                 $rosta['rent'][$rid][($dtm - $btime) / 86400] = $val;
                             }
                         }
                     }
                 }
                 unset($lst);
             }
             // 合并相同状态的单元格,键 P 改为 L,R
             foreach ($rosta['data'] as $key => &$val) {
                 $lst = array();
                 ksort($val, SORT_NUMERIC);
                 $idx = -1;
                 foreach ($val as $k => $v) {
                     if ($k && isset($val[$k - 1]) && $val[$k - 1] === $v) {
                         $lst[$idx][2] = $k;
                     } else {
                         ++$idx;
                         $lst[] = array($v, $k);
                     }
                 }
                 $rosta['data'][$key] = array();
                 foreach ($lst as $k => $v) {
                     $rosta['data'][$key][isset($v[2]) ? $v[1] . ',' . $v[2] : $v[1]] = $v[0];
                 }
             }
         }
     }
     if ($this->input('ct') === 'json') {
         $this->flash(1, array('context' => $rosta));
     }
     $this->view->hotel = $hotel;
     $this->view->rosta = $rosta;
 }
コード例 #5
0
ファイル: Bill.php プロジェクト: null-1/fangtaitong
 /**
  * verify
  * 
  * @param array $record
  * @return bool
  */
 public function verify($record)
 {
     if (empty($record) || !is_array($record)) {
         return false;
     }
     if (isset($record['b_hid'])) {
         if (!Zyon_Util::isUnsignedInt($record['b_hid']) || empty($record['b_hid']) || strlen($record['b_hid']) > 10) {
             return false;
         }
     }
     if (isset($record['b_sid'])) {
         if (!Zyon_Util::isUnsignedInt($record['b_sid']) || empty($record['b_sid']) || strlen($record['b_sid']) > 10) {
             return false;
         }
     }
     if (isset($record['b_attr']) && !$record['b_attr'] instanceof Zend_Db_Expr) {
         if (!Zyon_Util::isInt($record['b_attr']) || strlen((string) $record['b_attr']) > 10) {
             return false;
         }
     }
     if (isset($record['b_name']) && !$record['b_name'] instanceof Zend_Db_Expr) {
         if (!is_string($record['b_name']) || mb_strlen($record['b_name']) > 100) {
             return false;
         }
     }
     if (isset($record['b_cost']) && !$record['b_cost'] instanceof Zend_Db_Expr) {
         if (!Zyon_Util::isInt($record['b_cost']) || strlen((string) $record['b_cost']) > 10) {
             return false;
         }
     }
     if (isset($record['b_paid']) && !$record['b_paid'] instanceof Zend_Db_Expr) {
         if (!Zyon_Util::isInt($record['b_paid']) || strlen((string) $record['b_paid']) > 10) {
             return false;
         }
     }
     if (isset($record['b_memo'])) {
         if (!is_string($record['b_memo'])) {
             return false;
         }
     }
     if (isset($record['b_ltime'])) {
         if (!Zyon_Util::isUnsignedInt($record['b_ltime']) || strlen($record['b_ltime']) > 10) {
             return false;
         }
     }
     if (isset($record['b_status'])) {
         if (!Zyon_Util::isUnsignedInt($record['b_status']) || strlen($record['b_status']) > 3) {
             return false;
         }
     }
     return true;
 }