예제 #1
0
 public function contactRepos($sendername, $email, $message)
 {
     $contact = new Contact();
     $contact->s_name = $sendername;
     $contact->s_email = $email;
     $contact->s_message = $message;
     $contact->save();
 }
예제 #2
0
 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');
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id        	
  * @return Response
  */
 public function destroy($id)
 {
     // Start transaction!
     \DB::beginTransaction();
     try {
         $Contact = Contact::find($id);
         if ($Contact) {
             $this->withdraw($Contact);
             // Commit
             \DB::commit();
             return Response::json(['result' => 'OK']);
         }
     } catch (\ValidationException $e) {
         // Rollback and then redirect
         DB::rollback();
         App::abort(404);
     }
     // Rollback
     DB::rollback();
 }
예제 #4
0
파일: list.php 프로젝트: Dionnit/Touristic
    }
    return $date;
}], ['attribute' => 'CountryID', 'label' => 'Страна', 'content' => function ($data) {
    $country = null;
    $result = Tours::findOne($data->orderCalc['TourID']);
    //print_r($result);
    if (is_object($result) && $result) {
        $country = $result->country['Name'];
    }
    return $country;
}], ['attribute' => 'ContactID', 'label' => 'Туристы', 'content' => function ($data) {
    $mainContact = $data->contact;
    $list = "<ul>";
    $list .= "<li>" . $mainContact['Name'] . " " . $mainContact['SurName'] . "</li>";
    foreach ($data->participants as $value) {
        $contact = Contact::findOne($value['ContactID']);
        $list .= "<li>" . $contact->Name . " " . $contact->SurName . "</li>";
    }
    $list .= "</ul>";
    return $list;
}], ['attribute' => 'CurrencyID', 'label' => 'Валюта', 'content' => function ($data) {
    $currency = '';
    $result = Currency::findOne($data->orderCalc['CurrencyID']);
    if (is_object($result)) {
        $currency = $result->Currency;
    }
    return $currency;
}], ['attribute' => 'Price', 'label' => 'Стоимость', 'content' => function ($data) {
    return $data->orderCalc['Price'];
}], ['attribute' => 'Charges', 'label' => 'Комиссия', 'content' => function ($data) {
    return $data->Charges;
예제 #5
0
 public function getContact()
 {
     return $this->hasOne(Contact::className(), ['ID' => 'ContactID']);
 }