public function run() { $model = new Filter(); $model->city = $this->city; $model->date_n = $this->date_n; $model->time_n = $this->time_n; $model->language = $this->language; $model->guide = $this->guide; /*CITY*/ $citys = SegCities::model()->findAll(); /*TIME*/ $times = SegStarttimes::model()->findAll(); /*LANGUAGE*/ $languages = Languages::model()->findAll(); /*GUIDE*/ $criteria = new CDbCriteria(); $criteria->condition = 'cities_id=:cities_id'; $criteria->params = array(':cities_id' => $this->city); //$criteria->join = 'LEFT JOIN `users` ON (`users`.`id` = `t`.`users_id`)'; $guides_link = SegGuidesCities::model()->findAll($criteria); $guides = array(); $i = 0; foreach ($guides_link as $item) { $criteria_1 = new CDbCriteria(); $criteria_1->condition = 'id=:id'; $criteria_1->params = array(':id' => $item->users_id); $guides_contact = User::model()->find($criteria_1); // print_r($guides_contact); $criteria_2 = new CDbCriteria(); $criteria_2->condition = 'idcontacts=:idcontacts'; $criteria_2->params = array(':idcontacts' => $guides_contact->id_contact); $guides[$i] = SegContacts::model()->find($criteria_2); $i++; } $this->render('dopMenuFilter', array('citys' => $citys, 'times' => $times, 'languages' => $languages, 'guides' => $guides, 'model' => $model)); }
public function loadContact($id) { $model=SegContacts::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; }
public function actionBook($id) { if (!Yii::app()->user->hasState("book_data")) { // $backdata= get_object_vars(json_decode(Yii::app()->user->getState("city_data"))); $this->redirect(array("index")); } $bookdata = get_object_vars(json_decode(Yii::app()->user->getState("book_data"))); $model = $this->loadModel($bookdata['sid']); $tour = $this->loadTR($model->city_id, $bookdata['tid']); $contact = new SegContacts(); $ticket_count = 0; if (isset($_POST['SegScheduledTours'])) { $model->tourroute_id = $tour->idseg_tourroutes; if (isset($_POST['SegScheduledTours']['language_id'])) { $model->language_id = $_POST['SegScheduledTours']['language_id']; } if (isset($_POST['SegScheduledTours']['current_subscribers'])) { $ticket_count = (int) $_POST['SegScheduledTours']['current_subscribers']; if (is_null($model->current_subscribers)) { $model->current_subscribers = 0; } $model->current_subscribers += $ticket_count; $model->TNmax_sched = $tour->TNmax; } if (isset($_POST['SegContacts'])) { $contact->attributes = $_POST['SegContacts']; if ($contact->validate()) { $contact->save(); Yii::app()->user->setState('book_data', null); //save booking $id_user = $contact->idcontacts; //save guidestourinvoice $guidestourinvoices = new SegGuidestourinvoices(); $guidestourinvoices->creationDate = $model->date; $guidestourinvoices->cityid = $model->city_id; $guidestourinvoices->sched_tourid = $model->tourroute_id; $guidestourinvoices->guideNr = $model->guide1_id; $guidestourinvoices->status = 0; $guidestourinvoices->contacts_id = $id_user; $guidestourinvoices->id_sched = $model->idseg_scheduled_tours; $guidestourinvoices->save(); $model->save(); //save guidestourinvoicecustomers $id_invoice = $guidestourinvoices->idseg_guidesTourInvoices; for ($j = 0; $j < $ticket_count; $j++) { $guidestourinvoicescustomers = new SegGuidestourinvoicescustomers(); $guidestourinvoicescustomers->customersName = $contact->firstname . ' ' . $contact->surname; // $guidestourinvoicescustomers->price = $tour->base_price; $guidestourinvoicescustomers->price = 0; $guidestourinvoicescustomers->cityid = $model->city_id; $guidestourinvoicescustomers->tourInvoiceid = $id_invoice; //$guidestourinvoicescustomers->CustomeInvoicNumber = ; $b = $tour->city['seg_cityname'][0]; $year = date('y', time()); $max = Yii::app()->db->createCommand("SELECT max(CustomerInvoiceNumber) from seg_guidestourinvoicescustomers where cityid=" . $tour->cityid)->queryScalar(); $max_i = $max + 1; $guidestourinvoicescustomers->KA_string = 'KA' . $b . $year . '/' . $max_i; $guidestourinvoicescustomers->CustomerInvoiceNumber = $max_i; $guidestourinvoicescustomers->isPaid = 0; // $guidestourinvoicescustomers->origin_booking = $id_book; $guidestourinvoicescustomers->save(); } $date_ex = date('d/m/Y', $model->date_now); $x1 = strtotime($model->starttime) - strtotime("00:00:00"); $x2 = $tour->standard_duration * 60; $x3 = $x1 + $x2; $x4 = $x3 + strtotime("00:00:00"); $x5 = date('H:i:s', $x4); $tourend = $x5; $guidename = $model->user_ob->contact_ob->firstname; $guidemnr = $model->user_ob->contact_ob->phone; $message = "Thank you for booking your city tour with Cherry Tours " . $model->city_ob->seg_cityname; $message .= "\n"; $message .= "\nWe have just reserved the following tour date for you:"; $message .= "\n" . $date_ex; $message .= "\nTour start: " . $model->starttime . " (Please show up at the assigned meeting point about 10 minutes before tour start.)"; $message .= "\n"; $message .= "\nEnd of tour: " . $tourend; $message .= "\nTour route: " . $model->tourroute_ob->name; $message .= "\nTour language: " . $model->language_ob->englishname; $message .= "\nTour guide: " . $guidename; $message .= "\nGuide phone: " . $guidemnr . "(for last-minute requests regarding weather or meeting point)"; $message .= "\nFurthermore we recommend:"; $message .= "\n- comfortable shoes, no high heels"; $message .= "\n- adequate clothing (below 15 degrees centigrade, we especially recommend wearing warm clothes and gloves)"; $message .= "\n- sunglasses, if necessary sun protection etc."; $message .= "\n"; $message .= "\nPayment:"; $message .= "\n- On site"; $message .= "\n"; $message .= "\nWe accept the following methods of payment:"; $message .= "\n- Cash in EUR"; $message .= "\n- EC"; $message .= "\n- Credit cards (Visa, Master Card, American Express, JCB Cards, Union Pay)"; $message .= "\n- Vouchers purchased at Cherry Tours"; $message .= "\n"; $message .= "\nWeather:"; $message .= "\nIf the weather forecast shows a high chance of rain at the tour date, we will contact you near-term via email, SMS or phone and inform you if the tour has to be cancelled."; $message .= "\nIf it rains despite a positive weather forecast, the tour guide will decide on-site if the tour can take place. Generally, the tour is arranged along a route where you can always take cover in case of a short rain shower."; $message .= "\n"; $message .= "\n"; $name_forms = $model->city_ob->seg_cityname; $to = $contact->email; if ($this->sendMail($to, $name_forms, $message)) { $stuttgart_link = Yii::app()->createUrl('thankyou'); // header( 'Location: '.$stuttgart_link.'?id=1' ); } // } $this->render('result', array('post' => $_POST, 'contacts' => $contact->attributes, 'model' => $model->attributes)); return; } } } $this->render('book', array('post' => $_POST, 'model' => $model, 'contact' => $contact, 'tour' => $tour)); }
public function actionBook($id) { $sid = ''; if (Yii::app()->user->hasState("book_data") || $_POST['sid']) { if (Yii::app()->user->getState("book_data")) { $bookdata = get_object_vars(json_decode(Yii::app()->user->getState("book_data"))); $sid = $bookdata['sid']; $tid = $bookdata['tid']; } //var_dump($sid); //var_dump($_POST); exit; if (isset($_POST['sid'])) { $sid = $_POST['sid'] * 1; } if (isset($_POST['tid'])) { $tid = $_POST['tid'] * 1; } // $model = $this->loadModel($sid); $tour = $this->loadTR($model->city_id, $tid); } $contact = new SegContacts(); $ticket_count = 0; if (isset($_POST['SegScheduledTours'])) { $model->tourroute_id = $tour->idseg_tourroutes; if (isset($_POST['SegScheduledTours']['language_id'])) { $model->language_id = $_POST['SegScheduledTours']['language_id']; } if (isset($_POST['SegScheduledTours']['current_subscribers'])) { $ticket_count = (int) $_POST['SegScheduledTours']['current_subscribers']; if (is_null($model->current_subscribers)) { $model->current_subscribers = 0; } $model->current_subscribers += $ticket_count; $model->TNmax_sched = $tour->TNmax; } if (isset($_POST['SegContacts'])) { $contact->attributes = $_POST['SegContacts']; if ($contact->validate()) { $contact->save(); Yii::app()->user->setState('book_data', null); //save booking $id_user = $contact->idcontacts; //save guidestourinvoice $guidestourinvoices = new SegGuidestourinvoices(); $guidestourinvoices->creationDate = $model->date; $guidestourinvoices->cityid = $model->city_id; $guidestourinvoices->sched_tourid = $model->tourroute_id; $guidestourinvoices->guideNr = $model->guide1_id; $guidestourinvoices->status = 0; $guidestourinvoices->contacts_id = $id_user; $guidestourinvoices->id_sched = $model->idseg_scheduled_tours; $guidestourinvoices->save(); $model->save(); //save guidestourinvoicecustomers $id_invoice = $guidestourinvoices->idseg_guidesTourInvoices; for ($j = 0; $j < $ticket_count; $j++) { $guidestourinvoicescustomers = new SegGuidestourinvoicescustomers(); $guidestourinvoicescustomers->customersName = $contact->firstname . ' ' . $contact->surname; //$guidestourinvoicescustomers->price = $tour->base_price; $guidestourinvoicescustomers->price = 0; $guidestourinvoicescustomers->cityid = $model->city_id; $guidestourinvoicescustomers->tourInvoiceid = $id_invoice; //$guidestourinvoicescustomers->CustomeInvoicNumber = ; $b = $tour->city['seg_cityname'][0]; $year = date('y', time()); $max = Yii::app()->db->createCommand("SELECT max(CustomerInvoiceNumber) from seg_guidestourinvoicescustomers where cityid=" . $tour->cityid)->queryScalar(); $max_i = $max + 1; $guidestourinvoicescustomers->KA_string = 'KA' . $b . $year . '/' . $max_i; $guidestourinvoicescustomers->CustomerInvoiceNumber = $max_i; $guidestourinvoicescustomers->isPaid = 0; //$guidestourinvoicescustomers->origin_booking = $id_book; $guidestourinvoicescustomers->save(); } $to = $contact->email; //////////text email $otpr = $stopt = 0; ///// $starttime = str_replace('00:00', '00', $model->starttime); $tourdate = $this->dateEn($model->date); if (!empty($model->duration)) { $stopt = $model->duration; } else { $stopt = $tour->standard_duration; } $stoptime = date("H:i", strtotime($model->date . ' ' . $model->starttime) + $stopt * 60) . ' Uhr'; $tour_name = $model->city_ob->seg_cityname . ' ' . $tour->name; ////lang $text_lang = $model->language_ob->germanname; if (is_null($model->language_id)) { $lang = SegLanguagesGuides::model()->with('languages')->findAll('users_id=' . $model->guide1_id); $zp = $text_lang = ''; foreach ($lang as $val) { $text_lang .= $zp . $val->languages->germanname; $zp = ', '; } } ////point $meetingpoint = $tour->meetingpoint_description; if (Yii::app()->language == 'en') { $meetingpoint = $tour->meetingpoint_description_en; } //settings template mail $mailtext = array('city_name' => $model->city_ob->seg_cityname, 'city_en' => $model->city_ob->webadress_en, 'tour_date' => $tourdate, 'tour_starttime' => $starttime, 'tour_stoptime' => $stoptime, 'tour_guest' => $ticket_count, 'tour_name' => $tour_name, 'tour_lang' => $text_lang, 'tour_guide_name' => $model->user_ob->guidename, 'tour_guide_tel' => $model->user_ob->contact_ob->phone, 'contact_name' => $_POST['SegContacts']['firstname'] . ' ' . $_POST['SegContacts']['surname'], 'contact_street' => $_POST['SegContacts']['additional_address'] . '<br>' . $_POST['SegContacts']['street'], 'contact_city' => $_POST['SegContacts']['city'], 'contact_land' => $_POST['SegContacts']['country'], 'contact_tel' => $_POST['SegContacts']['phone'], 'contact_email' => $_POST['SegContacts']['email'], 'meetingpoint' => $meetingpoint); //template mail $msg = $this->renderPartial('../thankyousend/tour_mail', $mailtext, TRUE); if ($this->sendMail($to, 'Cherrytours: ' . $tour_name, $msg)) { // send mail admin //$email_admin = $model->city_ob->mailInfo; $email_admin = '*****@*****.**'; $msg = $this->renderPartial('../thankyousend/tour_mail_admin', $mailtext, TRUE); $this->sendMail($email_admin, 'Cherrytours: New client ' . $tour_name, $msg); /// $this->render('thankyou', array('model' => $model, 'tour' => $tour, 'post' => $_POST, 'sid' => $sid, 'tid' => $tid, 'guest' => $ticket_count)); } else { $this->render('../thankyousend/mail_success', array('text_link' => 'Anwendung beibehalten. Ich kann nicht einen Brief schicken.', 'city_en' => $model->city_ob->webadress_en)); } //unset($_POST); } else { echo 'goto_book'; $this->render('book', array('post' => $_POST, 'model' => $model, 'contact' => $contact, 'tour' => $tour, 'sid' => $sid, 'tid' => $tid)); } } } else { $this->render('book', array('post' => $_POST, 'model' => $model, 'contact' => $contact, 'tour' => $tour, 'sid' => $sid, 'tid' => $tid)); } }
public function loadGuide() { $gdata = SegGuidesdata::model()->findByPk(Yii::app()->user->gid); $gcontact= SegContacts::model()->findByPk(Yii::app()->user->cid); $city= SegGuidesCities::model()->with('cities')->find("users_id=:user",array(':user'=>Yii::app()->user->id)); $tel=""; if(!($city==null)) $tel=$city->cities->localPhone; // if(!($city==null)) $tel=$city; if(($gdata===null)||($gcontact===null)) throw new CHttpException(404,'The requested user data is missing.'); return array('data'=>$gdata,'contact'=>$gcontact,'tel'=>$tel); }