Beispiel #1
0
	public function actionCustom()
	{
		//判断是否有旅游产品ID参数过来
		if(!isset($_GET['id'])){
			$this->render('404',array('msg'=>'哈哈..您还没有选择旅游线路哦!'));
			exit;
		}
		//接收参数
		$tid = intval($_GET['id']);//旅游信息表自增ID
		
		//分配旅游信息
		$travel = $this->loadModel($tid);
		
		//访问人数增加1
		$travel->views = $travel->views+1;
		$travel->save(false);
		
		//分配产品图片
		$picture = TravelImg::model()->findAll(array(
				'select'=>'path',
				'condition'=>"tid=$tid",
				'order'=>'createtime desc',
				'limit'=>5,
		));
		
		//分配当日行程
		$today = Travalday::model()->findAll(array(
				'condition'=>"tid=$tid",
				'order'=>'daynumber asc',
		));
		
		//分配各项提示
		$tips = TravelTips::model()->find(array(
				'condition'=>"tid=$tid",
		));
		
		//分配该产品所有今天之后的出团信息
		$now = time();
		$tuans = Travelcalendar::model()->findAll(array(
				'select'=>'id,tid,trackcode,aduit_price,date,number,enabled',
				'condition'=>"tid=$tid and date>=$now",
				'order'=>'date asc',
		));
		
		//该页面当前的出团日期
		$Calcount = 0;//这个团号下的已经支付的剩余人数
		$sales = null;//特卖信息
		$saleflag = false;//判断是否来自特卖,或者是否为合法特卖
		
		if(isset($_GET['gd'])){
			$cal_id = intval($_GET['gd']);
			$tuanfirstcal = Travelcalendar::model()->find(array(
					'select'=>'id,trackcode,date,number',
					'condition'=>"id=$cal_id and tid=$tid",
			));
			if($tuanfirstcal==null){
				$this->render('404',array('msg'=>'哈哈..该旅游路线这天不出团哦,请选择其它日期吧!'));
				exit;
			}
			$tempCount = $this->getSurplusCount($cal_id);
			$Calcount = ($travel->number)-$tempCount;
			//判断是否为特卖页面而来
			if(isset($_GET['f']) && ($_GET['f']=='sale' || $_GET['f']=='disc')){
				$sales = $this->isSale($cal_id);
				if($sales){
					$saleflag = true;
				}
			}
		}else{
			$tuanfirstcal = Travelcalendar::model()->find(array(
					'select'=>'id,trackcode,date,number',
					'condition'=>"tid=$tid and date>=$now",
			));
			if($tuanfirstcal!=null){
				$tempCount = $this->getSurplusCount($tuanfirstcal->id);
				$Calcount = ($travel->number)-$tempCount;
			}
		}
		
		/*SEO信息*/
		$this->seo_title = $travel->seo_title;
		$this->seo_keyword = $travel->seo_keyword;
		$this->seo_description = $travel->seo_description;
		
		/* //将Travel表ID和Calendar表ID暂时存在session中
		 Yii::app()->session['tid'] = $tid;
		Yii::app()->session['tname'] = $travel->title;
		Yii::app()->session['tday'] = $travel->daynumber;
		Yii::app()->session['cid'] = $tuanfirstcal==null?0:$tuanfirstcal->id; */
		
		//输出四件猜你喜欢产品
		$cai = Youlike::model()->findAll(array(
				'select'=>'othertid',
				'condition'=>"tid=$travel->id",
				'limit'=>4,
		));
		
		//查询评论
		$reviews = Travelreviews::model()->findAll(array('select'=>'mid,departure,content,praise','condition'=>"tid=$tid"));
		
		$this->render('custom',array(
				'picture'=>$picture,
				'today'=>$today,
				'travel'=>$travel,
				'tips'=>$tips,
				'tuans'=>$tuans,
				'tuanfirstcal'=>$tuanfirstcal,
				'Calcount'=>$Calcount,
				'cai'=>$cai,
				'sales'=>$sales,
				'saleflag'=>$saleflag,
				'now'=>$now,
				'reviews'=>$reviews,
		));
	}
Beispiel #2
0
	public function mysearch()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.
	
		$criteria=new CDbCriteria;
	
		if(isset($_POST['Travel']['title']) && !empty($_POST['Travel']['title'])){
			$criteria->compare('title',$_POST['Travel']['title'],true);
		}
	
		if(isset($_POST['Travel']['trackcode']) && !empty($_POST['Travel']['trackcode'])){
			$criteria->compare('trackcode',$_POST['Travel']['trackcode'],false);
		}
	
		if(isset($_POST['type'])){
			switch ($_POST['type']){
				case 1:
					if(isset($_POST['Travel']['start']) && !empty($_POST['Travel']['start'])){
						$start = strtotime($_POST['Travel']['start']);
						$criteria->addCondition("createtime>=$start");
					}
					if(isset($_POST['Travel']['stop']) && !empty($_POST['Travel']['stop'])){
						$stop = strtotime($_POST['Travel']['stop']);
						$criteria->addCondition("createtime<=$stop");
					}
					break;
				case 2:
					if(isset($_POST['Travel']['start']) && !empty($_POST['Travel']['start'])){
						$start = strtotime($_POST['Travel']['start']);
						$criteria->addCondition("updatetime>=$start");
					}
					if(isset($_POST['Travel']['stop']) && !empty($_POST['Travel']['stop'])){
						$stop = strtotime($_POST['Travel']['stop']);
						$criteria->addCondition("updatetime<=$stop");
					}
					break;
				default :
					break;
			}
		}
	
		if(isset($_POST['ptype']) && $_POST['ptype']!=0){
			$type = $_POST['ptype'];
			$criteria->addCondition("type=$type");
		}
		
		if(isset($_GET['id'])){
			$tid = intval($_GET['id']);
			$mydata = Youlike::model()->findAll(array('select'=>'othertid','condition'=>"tid=$tid"));
			foreach($mydata as $data){
				$criteria->addCondition("id<>$data->othertid");
			}
			$criteria->addCondition("id<>$tid");
		}
		$criteria->order='updatetime desc';
	
		return new CActiveDataProvider($this, array(
				'criteria'=>$criteria,
		));
	}
	public function actionAddlikeall($id)
	{
		if(isset($_POST['selectdel'])){
			foreach($_POST['selectdel'] as $tid){
				$model = new Youlike;
				$model->tid = $id;
				$model->othertid = $tid;
				$model->createtime = time();
				$model->save(false);
			}
			Yii::app()->user->setFlash('success','添加成功!');
		}
		$this->redirect(array('youlike', 'id' => $id));
	}