Пример #1
0
	protected function getRoomTypeName()
	{
		$tempArr = array();
		$rooms = Housetype::model()->findAll(array(
				'select'=>'id,name',
		));
	
		foreach($rooms as $room){
			$tempArr[$room->id] = $room->name;
		}
	
		return $tempArr;
	}
Пример #2
0
	public function actionIndex()
	{
		/* //检查是否进行了前一步(即是否有选择路线)
		$sessionid = Yii::app()->session['sid'];//Yii::app()->session->sessionID;
		$tempModel = $this->checkSessionId($sessionid);
		if(!$tempModel){
			$this->render('404',array('msg'=>'您还没选择参团路线,快去选择吧!'));
			exit;
		} */
		
		//////////////////////////////////////
		
		//以后还要做一个参数过滤的函数,过滤该参数
		$code = $this->checkKParm();
		
		$orderModel = $this->getOrderByRandCode($code);
		//如果没有该订单,说明没有通过一步步预定,非法操作
		if(!$orderModel){
			$this->redirect('/tuan');
			exit;
		}
		
		$tid = $orderModel->tid;
		$cal_id = $orderModel->cal_id;

		$aduit = $orderModel->aduit;//成人数
		$child = $orderModel->child;//儿童数
		
		$model = $this->getOneTravelByPk($tid);
		if($model === null){
			$this->render('404',array('msg'=>'抱歉,没有该团或该团刚被管理员删除!'));
			exit;
		}
		
		//计算成人和儿童分别的总价格
		$model->aduit_price = ($orderModel->aduit_price) * $aduit;
		$model->childen_price = ($orderModel->chilend_price	) * $child;
		
		//查找该产品对于该出发日期的信息
		$cals = Travelcalendar::model()->find(array(
				'select'=>'id,trackcode,date',
				'condition'=>"tid=$tid and id = $cal_id",
				));
		
		if($cals === null){
			$this->render('404',array('msg'=>'抱歉,暂时没有该出团日期'));
			exit;
		}
		
		//分配房型
		$housetype = Housetype::model()->findAll(array(
				'select'=>'id,name,aduit,child,aduit_price,chilend_price',
				'condition'=>"tid=$tid",
				));
		
		/*SEO信息*/
		$this->seo_title = '填写订单-'.$model->seo_title;
		$this->seo_keyword = $model->seo_keyword;
		$this->seo_description = $model->seo_description;
		
		//获取第一张缩略图由于显示
		$fistThumb = TravelImg::model()->find(array('select'=>'path','condition'=>"tid=$tid"));
		
		$this->render('index',array(
				'model'=>$model,
				'aduit'=>$aduit,
				'child'=>$child,
				'id'=>$tid,
				'cals'=>$cals,
				'housetype'=>$housetype,
				'fistThumb'=>$fistThumb,
				'code'=>$code,
				'aduitprice'=>$orderModel->aduit_price,
				'childprice'=>$orderModel->chilend_price,
				));
	}
Пример #3
0
	private function loadModel($id)
	{
		$model = Housetype::model()->findByPk($id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}
Пример #4
0
	public function actionRoom($id)
	{
		$id = intval($id);
		$model = $this->loadModel($id);
		
		if(isset($_GET['rid'])){
			$rid = intval($_GET['rid']);
			$romModel = OrderRoom::model()->findByPk($rid);
		}else
			$romModel = new OrderRoom;
		
		
		//房型列表
		$romtypeaduitprice = array();
		$romtypechildprice = array();
		$roomtypeArr = array();
		$roomType = Housetype::model()->findAll(array('condition'=>"tid=$model->tid"));
		foreach($roomType as $roomty){
			$key = $roomty->id;
			$roomtypeArr[$key]=$roomty->name;
			$romtypeaduitprice[$key]=$roomty->aduit_price;
			$romtypechildprice[$key]=$roomty->chilend_price;
		}
		
		//接收参数并添加或修改房间信息
		if(isset($_POST['OrderRoom'])){
			$aduit = intval($_POST['OrderRoom']['aduit']);//成人数
			$child = intval($_POST['OrderRoom']['child']);//儿童数
			if($aduit==0 && $child==0){
				Yii::app()->user->setFlash('error','成人数和儿童或必须至少一个不为零!');
			}else{
				$rkey = intval($_POST['OrderRoom']['type']);
				$romModel->oid = $id;
				$romModel->aduit = $aduit;
				$romModel->child = $child;
				$romModel->type = $roomtypeArr[$rkey];
				$romModel->price = ($romtypeaduitprice[$rkey]*$aduit) + ($romtypechildprice[$rkey]*$child);
				if($romModel->save(false)){
					Yii::app()->user->setFlash('success','成功!');
				}else{
					Yii::app()->user->setFlash('error','失败!');
				}
			}
		}
		
		//房间列表
		$rooms = $model->Rooms;
		
		$this->render('room',array(
				'model'=>$model,
				'rooms'=>$rooms,
				'romModel'=>$romModel,
				'roomtypeArr'=>$roomtypeArr,
				'roomType'=>$roomType,
				));
	}