本文整理汇总了PHP中Booking::CalculatePrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Booking::CalculatePrice方法的具体用法?PHP Booking::CalculatePrice怎么用?PHP Booking::CalculatePrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Booking
的用法示例。
在下文中一共展示了Booking::CalculatePrice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeNewBooking
public function executeNewBooking(sfWebRequest $request)
{
$app_id = $request->getParameter('apid');
$date_from = $request->getParameter('start_date');
$days = $request->getParameter('days');
$pax = $request->getParameter('pax');
$date_to = date("Y-m-d", strtotime($date_from) + 86400 * $days);
$app = Doctrine_Core::getTable('Apartment')->find($app_id);
$form = new BookingForm();
$form->PublicBookingForm($app);
$booking = new Booking();
$booking->date_from = $date_from;
$booking->date_to = $date_to;
if ($this->getUser()->isAuthenticated()) {
if ($booking->StartBooking($app, $pax)) {
/* @TODO: 1. Save request. Set comfirmed -> FALSE
2. Get reservation ID ?? */
$this->apartment = $app;
$this->booking = $booking;
$this->price = Booking::CalculatePrice($app, $date_from, $date_to);
$this->pax = $pax;
$this->form = new BookingForm();
$this->form->PublicPaymentForm($app->id, $booking->date_from, $booking->date_to, $pax);
} else {
/* Not avalible, return form and error */
$callback_url = 'http://localhost/symfonybooking/web/frontend_dev.php/en/apartment/' . $app->getId();
return $this->renderPartial('booking/booking_form', array('form' => $form, 'sign_in' => false, 'callback' => $callback_url, 'error' => 'Something is wrong, please check once more ...'));
}
} else {
/* User in not singed in */
return $this->renderPartial('booking/booking_form', array('form' => $form, 'sign_in' => true, 'callback' => $callback_url));
}
}
示例2: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()));
$params = $request->getParameter($this->form->getName());
if ($form->isValid()) {
// $notice = $form->getObject()->isNew() ? 'Booking was created successfully.' : 'Booking was updated successfully.';
try {
/* Start booking */
$apartment = Doctrine_Core::getTable('Apartment')->find($params['apartment_id']);
$booking = $form->getObject();
$from = $params['date_from']['year'] . '-' . $params['date_from']['month'] . '-' . $params['date_from']['day'];
$to = $params['date_to']['year'] . '-' . $params['date_to']['month'] . '-' . $params['date_to']['day'];
$booking->date_from = $from;
$booking->date_to = $to;
if ($booking->StartBooking($apartment, $params['pax'])) {
$booking->Apartment = $apartment;
$booking->client_id = $params['client_id'];
$booking->pax = $params['pax'];
$booking->valid = $params['valid'];
$booking->canceled = $params['canceled'];
$booking->price = Booking::CalculatePrice($apartment, $from, $to);
$booking->save();
// return sfView::SUCCESS;
$this->redirect(array('sf_route' => 'booking_edit', 'sf_subject' => $booking));
$this->getUser()->setFlash('error', ' Booking successfully created. ', false);
} else {
$this->getUser()->setFlash('error', 'Apartment is unavalible for this dates !', false);
return sfView::SUCCESS;
}
} catch (Doctrine_Validator_Exception $e) {
$errorStack = $form->getObject()->getErrorStack();
$message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
foreach ($errorStack as $field => $errors) {
$message .= "{$field} (" . implode(", ", $errors) . "), ";
}
$message = trim($message, ', ');
$this->getUser()->setFlash('error', $message);
return sfView::SUCCESS;
}
$this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $booking)));
} else {
$this->getUser()->setFlash('error', 'There are some errors ...', false);
}
}
示例3: CheckBookingPossibility
public function CheckBookingPossibility(Apartment $app, $pax)
{
/* Avalibility check. Expecting TRUE or FALSE */
$avalibility = $app->CheckBookingsInPeriod($this->date_from, $this->date_to);
/* Are dates valid for individual apartment ? */
$dates = true;
/* Minimum or maximum pax for individual apartment or ... ? */
$pax_valid = false;
if ($pax >= 1 && $pax <= $app->getMaxPax()) {
$pax_valid = true;
}
/* Are there periods for dates... Can we get real price ? */
$price = false;
if (Booking::CalculatePrice($app, $this->date_from, $this->date_to) > 0) {
$price = true;
}
if ($dates === true && $avalibility === false && $pax_valid === true && $price === true) {
return $this;
} else {
return false;
}
}