Ejemplo n.º 1
0
 public function run()
 {
     $this->controller->pageTitle = 'Book a Workspace';
     $now = date('Y-m-d', time());
     $date = Yii::app()->request->getParam('date');
     $date = $date == '' ? $now : $date;
     $proxy = new CHub();
     $result = $proxy->getHubList();
     if (Yii::app()->request->isAjaxRequest) {
         $id = Yii::app()->request->getParam('id');
         $hub = Yii::app()->request->getParam('hub');
         $date = Yii::app()->request->getParam('date');
         if ($id) {
             $date = date('Ymd', strtotime($date));
             $record = Reservations::model()->findAll('startTime =' . date('Ymd', strtotime($date)) . '100000' . ' and userId=' . Yii::app()->user->id . ' and type=1 and status=1');
             $orderid = Order::model()->findAllByAttributes(array('status' => 1, 'userId' => Yii::app()->user->id, 'type' => 1));
             if ($orderid) {
                 foreach ($orderid as $list) {
                     $order = OrderProduct::model()->find('endDate>=' . $date . ' and orderId=' . $list['id'] . ' and startDate<=' . $date);
                     if ($order) {
                         break;
                     }
                 }
                 if ($order) {
                     echo CJSON::encode(array('code' => 200, 'data' => array('num' => $order['totalTimes'] - $order['usedTimes'], 'count' => count($record))));
                 } else {
                     echo CJSON::encode(array('code' => 200, 'data' => array('num' => 0)));
                 }
             } else {
                 $code = CodeUsed::model()->findAll('userId=' . Yii::app()->user->id);
                 if ($code) {
                     foreach ($code as $list) {
                         $value = Code::model()->find('endDate>=' . $date . ' and id=' . $list['codeId'] . ' and startDate<=' . $date);
                         if ($value) {
                             break;
                         }
                     }
                     if ($value) {
                         echo CJSON::encode(array('code' => 200, 'data' => array('num' => 1, 'count' => count($record))));
                     } else {
                         echo CJSON::encode(array('code' => 200, 'data' => array('num' => 0)));
                     }
                 } else {
                     echo CJSON::encode(array('code' => 200, 'data' => array('num' => 0)));
                 }
             }
         } else {
             $proxy = new CReservation();
             $result = $proxy->getNumber($date);
             if ($result['code'] == 200) {
                 $data = array('code' => 200, 'data' => $result);
                 echo CJSON::encode($data);
             }
         }
     } else {
         $this->controller->render('workspacelist', array('data' => $result['data'], 'date' => $date));
     }
 }
Ejemplo n.º 2
0
 public function run()
 {
     $this->controller->pageTitle = "My Reservations";
     $reservation = new CReservation();
     // Yii::app()->user->id = 1187;
     $upcoming = $reservation->getupcomingRes(Yii::app()->user->id);
     $previous = $reservation->getpreRes(Yii::app()->user->id);
     // print_r($upcoming);die;
     if ($upcoming['code'] == 200 && $previous['code'] == 200) {
         $this->controller->render('myreservations', array('upcominglist' => $upcoming['data'], 'previouslist' => $previous['data']));
     } else {
         throw new Exception("Error Processing Request", 1);
     }
 }
Ejemplo n.º 3
0
 public function run()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $date = Yii::app()->request->getParam('date');
         $hubId = Yii::app()->request->getParam('hubId');
         $userId = Yii::app()->user->id;
         $data = array('startTime' => $date . ' 10:00:00', 'hubId' => $hubId, 'userId' => $userId, 'type' => 1);
         $proxy = new CReservation();
         $num = $proxy->getNumber($date, $hubId);
         if ($num['count'] < 50) {
             $result = $proxy->createReservation($data);
             echo CJSON::encode(array('code' => 200, 'message' => 'success'));
         } else {
             echo CJSON::encode(array('code' => 300, 'message' => 'no num'));
         }
     }
 }
Ejemplo n.º 4
0
 public function run()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $id = Yii::app()->request->getParam('id');
         Yii::log($id, CLogger::LEVEL_ERROR, 'info');
         $reservation = new CReservation();
         $result = $reservation->cancel($id);
         if ($result['code'] == 200) {
             echo CJSON::encode(array('code' => 200, 'mes' => 'success'));
         } else {
             echo CJSON::encode(array('code' => 500, 'mes' => 'cancel fail'));
         }
         // echo CJSON::encode(array(
         // 		'code'=>200,
         // 	));
     }
 }
 public function run()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $userId = Yii::app()->user->id;
         $id = Yii::app()->request->getParam('id');
         $hubId = Yii::app()->request->getParam('hubId');
         $starts = Yii::app()->request->getParam('starts');
         $hour = Yii::app()->request->getParam('hour');
         $date = Yii::app()->request->getParam('date');
         $startTime = $date . ' ' . $starts . ':00';
         $endTime = strtotime($startTime);
         $endTime = date('Y-m-d H:i:s', $endTime + $hour * 60 * 60);
         $data = array('startTime' => $startTime, 'endTime' => $endTime, 'userId' => $userId, 'hubId' => $hubId, 'conferenceroomId' => $id, 'type' => 2);
         $proxy = new CReservation();
         $result = $proxy->createReservation($data);
         if ($result['code'] == 200) {
             echo CJSON::encode($result);
         } else {
             throw new CHttpException($result['code'], $result['message']);
         }
     }
 }