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, )); }
public function actionModify($id) { $model = $this->loadModel($id); $tips = TravelTips::model()->find(array( 'condition'=>"tid=$id", )); //查询旅游产品类型 $typeModel = Traveltype::model()->findAll(array( 'select'=>'id,name', )); //查询出发地 $departure = Departure::model()->findAll(array( 'select'=>'id,name', )); //查询目的地 $dests = Destination::model()->findAll(array( 'select'=>'id,name', )); //附加项目模型 $addModel = new TravelAdditional; if(isset($_POST['Travel'])) { $model->attributes = $_POST['Travel']; $model->to_addr = implode(';', $_POST['Travel']['to_addr']); $model->updatetime = time(); if($model->save(false)){ Yii::app()->user->setFlash('success', "产品保存成功"); //echo $_POST['Travel']['to_addr']; } } $this->render('edit',array( 'model'=>$model, 'tips'=>$tips, 'typeModel'=>$typeModel, 'departure'=>$departure, 'dests'=>$dests, 'addModel'=>$addModel, )); }