本文整理汇总了PHP中Booking::setCustomer方法的典型用法代码示例。如果您正苦于以下问题:PHP Booking::setCustomer方法的具体用法?PHP Booking::setCustomer怎么用?PHP Booking::setCustomer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Booking
的用法示例。
在下文中一共展示了Booking::setCustomer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showCreateBookingPage
private function showCreateBookingPage()
{
if (WebRequest::wasPosted()) {
try {
// get variables
$bcust = WebRequest::postInt("bcust");
$badults = WebRequest::postInt("badults");
$bchildren = WebRequest::postInt("bchildren");
$bstart = WebRequest::post("bstart");
$bend = WebRequest::post("bend");
$bpromo = WebRequest::postInt("bpromo");
$broom = WebRequest::postInt("broom");
// data validation
if ($badults == 0) {
throw new CreateBookingException("no-adults");
}
if ($bstart == null) {
throw new CreateBookingException("no-start-date");
}
if ($bend == null) {
throw new CreateBookingException("no-end-date");
}
if ($bcust == 0) {
throw new CreateBookingException("no-customer-for-booking");
}
$booking = new Booking();
// set values
$booking->setCustomer($bcust);
$booking->setAdults($badults);
$booking->setChildren($bchildren);
$booking->setStartDate($bstart);
$booking->setEndDate($bend);
$booking->setPromocode($bpromo);
$booking->setRoom($broom);
$booking->save();
global $cScriptPath;
$this->mHeaders[] = "Location: {$cScriptPath}/Bookings";
} catch (CreateBookingException $ex) {
$this->mBasePage = "mgmt/bookingCreate.tpl";
$this->error($ex->getMessage());
}
} else {
$this->mBasePage = "mgmt/bookingCreate.tpl";
}
}
示例2: runPage
protected function runPage()
{
if (WebRequest::wasPosted()) {
if (!WebRequest::postInt("calroom")) {
$this->showCal();
return;
}
$startdate = new DateTime(WebRequest::post("qbCheckin"));
$enddate = new DateTime(WebRequest::post("qbCheckout"));
$room = Room::getById(WebRequest::postInt("calroom"));
for ($date = $startdate; $date < $enddate; $date->modify("+1 day")) {
if (!$room->isAvailable($date)) {
$this->error("room-not-available");
$this->showCal();
return;
}
}
// search for customer
if (!($customer = Customer::getByEmail(WebRequest::post("qbEmail")))) {
$customer = new Customer();
$suTitle = WebRequest::post("qbTitle");
$suFirstname = WebRequest::post("qbFirstname");
$suLastname = WebRequest::post("qbLastname");
$suAddress = WebRequest::post("qbAddress");
$suCity = WebRequest::post("qbCity");
$suPostcode = WebRequest::post("qbPostcode");
$suCountry = WebRequest::post("qbCountry");
$suEmail = WebRequest::post("qbEmail");
$customer->setPassword($suEmail);
// set values
$customer->setTitle($suTitle);
$customer->setFirstname($suFirstname);
$customer->setSurname($suLastname);
$address = new Address();
$address->setLine1($suAddress);
$address->setCity($suCity);
$address->setPostCode($suPostcode);
$address->setCountry($suCountry);
$address->save();
$customer->setAddress($address);
$customer->setEmail($suEmail);
// save it
$customer->save();
$customer->sendMailConfirm();
// save it again
$customer->save();
}
$booking = new Booking();
$booking->setStartDate(WebRequest::post("qbCheckin"));
$booking->setEndDate(WebRequest::post("qbCheckout"));
$booking->setAdults(WebRequest::post("qbAdults"));
$booking->setChildren(WebRequest::post("qbChildren"));
$booking->setPromocode(WebRequest::post("qbPromoCode"));
$booking->setRoom($room->getId());
$booking->setCustomer($customer->getId());
$booking->save();
$msg = Message::getMessage("booking-confirmation");
$msg = str_replace("\$1", $booking->getStartDate(), $msg);
$msg = str_replace("\$2", $booking->getEndDate(), $msg);
$msg = str_replace("\$3", $booking->getAdults(), $msg);
$msg = str_replace("\$4", $booking->getChildren(), $msg);
$msg = str_replace("\$5", $booking->getRoom()->getName(), $msg);
Mail::send($customer->getEmail(), Message::getMessage("booking-confimation-subject"), $msg);
$this->mSmarty->assign("content", $msg);
return;
}
throw new YouShouldntBeDoingThatException();
}