当前位置: 首页>>代码示例>>PHP>>正文


PHP Booking::CalculatePrice方法代码示例

本文整理汇总了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));
     }
 }
开发者ID:alifst11,项目名称:symfonybooking,代码行数:33,代码来源:actions.class.php

示例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);
     }
 }
开发者ID:alifst11,项目名称:symfonybooking,代码行数:44,代码来源:actions.class.php

示例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;
     }
 }
开发者ID:alifst11,项目名称:symfonybooking,代码行数:22,代码来源:Booking.class.php


注:本文中的Booking::CalculatePrice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。