protected function additionList($tid) { $info = TravelAdditional::model()->findAll(array( 'select'=>'id,name,price', 'condition'=>"tid=$tid", )); $arr = array(); foreach($info as $value){ $id = $value['id']; $arr[$id] = array('name'=>$value['name'],'price'=>$value['price']); } return $arr; }
private function tickerPriceList() { $ticker = TravelAdditional::model()->findAll(array( 'select'=>'id,price', )); $arr = array(); foreach($ticker as $tick){ $id = $tick['id']; $arr[$id] = $tick['price']; } return $arr; }
public function actionDeladdition() { $id = $_GET['id']; $aid = $_GET['aid']; $addiModel = TravelAdditional::model()->findByPk($aid); if($addiModel->delete()){ Yii::app()->user->setFlash('success', "删除附加项目成功!"); }else{ Yii::app()->user->setFlash('error', "删除附加项目失败!"); } $this->redirect(array('addition', 'id' => $id)); }
public function actionAdds($id) { $model = $this->loadModel($id); //附加项目列表 $tid = $model->tid; $addsArr = array(); $addPrce = array(); $addsModel = TravelAdditional::model()->findAll(array('condition'=>"tid=$tid")); foreach($addsModel as $ad){ $key = $ad->id; $addsArr[$key] = $ad->name; $addPrce[$key] = $ad->price; } if(isset($_GET['aid'])){ $aid = intval($_GET['aid']); $aModel = OrderAdditional::model()->findByPk($aid); }else{ $aModel = new OrderAdditional; } //接收参数并保存到数据库 if(isset($_POST['OrderAdditional'])){ $num = intval($_POST['OrderAdditional']['num']); if($num==0){ Yii::app()->user->setFlash('error','参加项目人数必须大于0!'); }else{ $akey = intval($_POST['OrderAdditional']['name']); $aModel->oid = $id; $aModel->name = $addsArr[$akey]; $aModel->num = $num; $aModel->price = $addPrce[$akey]; $aModel->createtime = time(); if($aModel->save(false)){ Yii::app()->user->setFlash('success','成功!'); }else{ Yii::app()->user->setFlash('error','失败!'); } } } $adds = $model->Adds; $this->render('adds',array( 'model'=>$model, 'aModel'=>$aModel, 'adds'=>$adds, 'addsArr'=>$addsArr, )); }
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; } //检查是否有上一步的选择房间 $token = 'order'.$orderModel->id; $roomArr = $this->checkOrderRoomStep($token); //start : 判断是否附加项全部隐藏了,如果全部隐藏则自动跳到下一步 //判断是否隐藏 $struct = Structure::model()->findAll(array('select'=>'enabled','condition'=>'id=6 or id=7 or id=8','order'=>'id asc')); if(empty($struct)){ $this->redirect($this->createUrl('/submit',array('k'=>$code))); exit; } //end $tid = $orderModel->tid;//产品ID //获取参数 $aduit = $orderModel->aduit;//参团成人人数 $child = $orderModel->child;//参团儿童人数 //分配门票附加项 $tickets = TravelAdditional::model()->findAll(array( 'select'=>'id,name,price', 'condition'=>"tid=$tid", )); //如果没有门票项目,则在视图中隐藏门票信息,这里设一个标志符 $flag = empty($tickets)?false:true; //获取价格 $Travelprice = $this->getTravelInfo($tid); $Travelprice->aduit_price = ($orderModel->aduit_price)*$aduit; $Travelprice->childen_price = ($orderModel->chilend_price)*$child; //房间价格 $housePriceTotal = $this->getRoomsPrice($token,$aduit,$child); //计算这部总价格 $nowTotalPrice = ($Travelprice->aduit_price) + ($Travelprice->childen_price) + $housePriceTotal; //获取保险项目 $insurance = Insurance::model()->findAll(array( 'select'=>'id,name,price,description', 'condition'=>"tid=$tid", )); $this->render('index',array( 'tickets'=>$tickets, 'flag'=>$flag, 'aduit'=>$aduit, 'child'=>$child, 'roomArr'=>$roomArr, 'Travelprice'=>$Travelprice, 'insurance'=>$insurance, 'housePriceTotal'=>$housePriceTotal, 'nowTotalPrice'=>$nowTotalPrice, 'token'=>$token, 'code'=>$code, 'struct'=>$struct, 'daynumber'=>$orderModel->daynumber, )); }