コード例 #1
0
ファイル: AgentController.php プロジェクト: Dionnit/Touristic
 public function actionCreate($type = null, $id = null)
 {
     $request = Yii::$app->request;
     //Проверяем наличие параметров
     if ((!$type || !$id) && $request->isGet) {
         return $this->goBack();
     }
     if ($request->isPost) {
         $post = $request->post();
         //print_r($post);die;
         $mainContact = '';
         foreach ($post['tourist'] as $key => $value) {
             //print_r($value);die;
             // Записываем туристов в контакты
             $model = new Contact(['Name' => $value['name'], 'SurName' => $value['surName'], 'CreatedOn' => date('Y-m-d H:i:s.z', time())]);
             $model->save();
             $lastContactId = Yii::$app->db2->createCommand("SELECT ID FROM {{%Contact}} ORDER BY CreatedOn DESC")->queryOne();
             $lastContactId = $lastContactId['ID'];
             if ($key == '0') {
                 $mainContact = $lastContactId;
             }
             // Записываем паспортные данные
             $model = new ContactPassport(['Name' => $value['name'], 'SurName' => $value['surName'], 'CreatedOn' => date('Y-m-d H:i:s.z', time()), 'Series' => $value['series'], 'Number' => $value['number'], 'Granted' => $value['granted'], 'ContactID' => $lastContactId, 'CreatedOn' => date('Y-m-d H:i:s.z', time())]);
             $model->save();
         }
         // Создаем заявку
         $model = new Orders(['ContactID' => $mainContact, 'CreatedOn' => date('Y-m-d H:i:s.z', time()), 'Status' => '99a1047e-1078-4d26-b5b2-b4abffff4160', 'CustomerAccountID' => Yii::$app->user->identity->companyId]);
         $model->save();
         $lastOrderId = Yii::$app->db2->createCommand("SELECT ID FROM {{%Orders}} ORDER BY CreatedOn DESC")->queryOne();
         $lastOrderId = $lastOrderId['ID'];
         // Привязываем тур или отель
         if ($post['type'] == 'hotel') {
             /* Привязвваем отель */
             $hotelPriceId = HotelPartner::findOne(['HotelID' => $post['id']]);
             if ($hotelPriceId) {
                 $hotelPriceId = $hotelPriceId->hotelPrice['ID'];
             }
             $model = new OrderCalc(['OrderID' => $lastOrderId, 'HotelPriceID' => $hotelPriceId]);
             $model->save();
         } else {
             /* Привязвваем тур */
             $model = new TourPriceMain(['ID' => $post['id']]);
             $model->save();
             $model = new OrderCalc(['TourID' => $post['id'], 'OrderID' => strtolower($lastOrderId)]);
             $model->save();
         }
         return $this->redirect(Url::to(['agent/list']));
     } else {
         return $this->render('create');
     }
 }
コード例 #2
0
ファイル: OrdersSearch.php プロジェクト: Dionnit/Touristic
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Orders::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     //$query->joinWith(['orderCalcDetails']);
     $query->joinWith(['orderCalcDetails' => function ($query) {
         $query->from(['ocd' => 'tbl_OrderCalcDetail']);
     }]);
     // enable sorting for the related column
     $dataProvider->sort->attributes['orderCalcDetails.DateStart'] = ['asc' => ['ocd.DateStart' => SORT_ASC], 'desc' => ['ocd.DateStart' => SORT_DESC]];
     $dataProvider->sort->attributes['orderCalcDetails.DateEnd'] = ['asc' => ['ocd.DateEnd' => SORT_ASC], 'desc' => ['ocd.DateEnd' => SORT_DESC]];
     $query->andFilterWhere(['CreatedOn' => $this->CreatedOn, 'ModifiedOn' => $this->ModifiedOn, 'DiscountPercent' => $this->DiscountPercent, 'OrderDate' => $this->OrderDate, 'Sum' => $this->Sum, 'VisitDate' => $this->VisitDate, 'DaysCount' => $this->DaysCount, 'NightsCount' => $this->NightsCount, 'CustomerAccountID' => Yii::$app->user->identity->companyId, 'IsFake' => $this->IsFake, 'Charges' => $this->Charges]);
     $query->andFilterWhere(['like', 'ID', $this->ID])->andFilterWhere(['like', 'CreatedByID', $this->CreatedByID])->andFilterWhere(['like', 'ModifiedByID', $this->ModifiedByID])->andFilterWhere(['like', 'Name', $this->Name])->andFilterWhere(['like', 'CompanyID', $this->CompanyID])->andFilterWhere(['like', 'ContactID', $this->ContactID])->andFilterWhere(['like', 'CurrencyID', $this->CurrencyID])->andFilterWhere(['like', 'ResponsibleID', $this->ResponsibleID])->andFilterWhere(['like', 'Status', $this->Status])->andFilterWhere(['like', 'Description', $this->Description])->andFilterWhere(['like', 'TripType', $this->TripType])->andFilterWhere(['like', 'TripNumber', $this->TripNumber])->andFilterWhere(['like', 'ContactAccountID', $this->ContactAccountID])->andFilterWhere(['like', 'CustomerContactID', $this->CustomerContactID])->andFilterWhere(['like', 'ContactDescription', $this->ContactDescription])->andFilterWhere(['like', 'OrderContactTelephone', $this->OrderContactTelephone])->andFilterWhere(['LIKE', 'ocd.DateStart', $this->getAttribute('orderCalcDetails.DateStart')])->andFilterWhere(['LIKE', 'ocd.DateEnd', $this->getAttribute('orderCalcDetails.DateEnd')])->andFilterWhere(['like', 'CurrentVariantID', $this->CurrentVariantID]);
     return $dataProvider;
 }
コード例 #3
0
 /**
  * Finds the Orders model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Orders the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Orders::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #4
0
ファイル: view.php プロジェクト: Dionnit/Touristic
<?php

/* @var $this yii\web\View */
use app\models\orders\Orders;
?>
<div class="row">
	<div class="col-md-3">
		<h3 class="num-order <?php 
echo Orders::statusTextColor($data->Status);
?>
"><?php 
echo $data->Name;
?>
</h3>
	</div>
	<div class="col-md-4">
		<h4>Статус: <small> <em> <?php 
echo $data->orderStatus->Name;
?>
</em></small></h4>
	</div>
	<div class="col-md-5">
		<table class="table table-bordered">
			<thead>
				<tr>
					<th>Стоимость</th>
					<th>Комиссия</th>
					<th>К оплате</th>
				</tr>
			</thead>
			<tbody>