コード例 #1
0
 protected function _assign(Dwoo_Data $data)
 {
     $details = $this->_eventData->getAllDetails();
     $reservationID = $this->_eventData->getReservationID();
     $reservationModel = new RM_Reservations();
     $reservation = $reservationModel->find($reservationID)->current();
     $arrayDetails = array();
     foreach ($details as $detail) {
         $arrayDetails[] = array('unit' => $detail->getUnit()->toArray(), 'period' => (array) $detail->getPeriod(), 'periodtime' => (array) $detail->getPeriod(true), 'persons' => $detail->getPersons(), 'total' => $detail->getTotal());
     }
     // total paid and total due
     $billing = new RM_Billing();
     $priceCharges = $billing->getPrice($reservationID);
     $billingArray['tax'] = $priceCharges->tax;
     $billingArray['paid'] = $billing->getPaymentsTotal($reservation);
     $billingArray['due'] = $priceCharges->total;
     $billingArray['confirmed'] = $reservation->confirmed ? $translate->_('MessageYes') : $translate->_('MessageNo');
     $data->assign('details', $arrayDetails);
     $data->assign('reservation_id', $this->_eventData->getReservationID());
     return $data;
 }
コード例 #2
0
 protected function _assign(Dwoo_Data $data)
 {
     $translate = RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN);
     $locationsDAO = new RM_Locations();
     $reservationID = $this->_eventData->getReservationID();
     $reservationModel = new RM_Reservations();
     $reservation = $reservationModel->find($reservationID)->current();
     // reservation details
     $details = $this->_eventData->getAllDetails();
     $arrayDetails = array();
     foreach ($details as $detail) {
         $unit = $detail->getUnit()->toArray();
         $period = $detail->getPeriod()->toArray();
         $periodWithTime = $detail->getPeriod()->toArray(true);
         $location = $locationsDAO->fetchByUnit($unit['id'])->toArray();
         $extrasForTemplate = array();
         $extras = $detail->getExtras();
         foreach ($extras as $extra) {
             $extrasForTemplate[] = $extra->toArray();
         }
         $arrayDetails[] = array('unit' => $unit, 'locationInfo' => isset($location[0]) ? $location[0] : '', 'period' => $period, 'periodtime' => $periodWithTime, 'persons' => $detail->getPersons()->getAll(), 'total' => $detail->getTotal(), 'extras' => $extrasForTemplate);
     }
     // total paid and total due
     $billing = new RM_Billing();
     $priceCharges = $billing->getPrice($reservationID);
     $billingArray['tax'] = $priceCharges->tax;
     $billingArray['paid'] = $billing->getPaymentsTotal($reservation);
     $billingArray['due'] = $priceCharges->total;
     $billingArray['confirmed'] = $reservation->confirmed ? $translate->_('MessageYes') : $translate->_('MessageNo');
     // return the data to the template
     $data->assign('extras', $extrasForTemplate);
     $data->assign('details', $arrayDetails);
     $data->assign('user', $this->_eventData->getUser()->toArray());
     $data->assign('reservation_id', $reservationID);
     $data->assign('billing', $billingArray);
     return $data;
 }
コード例 #3
0
 /**
  * this function returns the saved reservation price
  *
  * @return array/json
  */
 public function getsavedpricesJsonAction()
 {
     $reservationID = $this->_getParam('reservation_id');
     if ($reservationID == null) {
         return array('data' => array('success' => false, 'error' => RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_ERRORS)->_('Admin.Reservation.Edit', 'ReservationIDMissed')));
     }
     $billingModel = new RM_Billing();
     $getSavedPrice = $billingModel->getPrice($reservationID);
     return array('data' => $getSavedPrice, 'encoded' => false);
 }
コード例 #4
0
ファイル: Reservations.php プロジェクト: laiello/resmania
 /**
  * Method that parsed invoice template and returns string
  *
  * All variable that parsed into invoice.pthml template
  * $reservation:
  * $reservation.id
  * $reservation.user_id
  * $reservation.confirmed (Yes, No - translated)
  * $reservation.is_read (Yes, No - translated)
  * $reservation.creation_datetime (In MySQL format: Y-m-d H:m:s)
  * $reservation.modified_datetime (In MySQL format: Y-m-d H:m:s)
  * $reservation.notes
  * $reservation.tax
  * $reservation.paid
  * $reservation.due
  *
  * $customer:
  * $customer.id
  * $customer.title (Translated)
  * $customer.first_name
  * $customer.last_name
  * $customer.address1
  * $customer.address2
  * $customer.state
  * $customer.city
  * $customer.postcode
  * $customer.country
  * $customer.telephone
  * $customer.mobile
  * $customer.email
  * $customer.username
  *
  * $details each detail is an $element:
  * $element.reservation_id
  * $element.unit_id
  * $element.start_datetime (In MySQL format: Y-m-d H:m:s)
  * $element.end_datetime (In MySQL format: Y-m-d H:m:s)
  * $element.total_price
  * $element.unit.id
  * $element.unit.rating (number)
  * $element.unit.published (Yes, No - translated)
  * $element.unit.color (hex color)
  * $element.unit.(all language db field names that are belong to unit type, for example: name, summary, description)
  *
  * $text: all text constants in section 'Admin.Invoice' in languages file, for example $text.BookingReference
  *
  * @param RM_Reservation_Row $reservation
  * @return <type>
  */
 public static function getInvoice(RM_Reservation_Row $reservation)
 {
     $translate = RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_MAIN);
     $data = new Dwoo_Data();
     $data->assign('invoice', array('date' => date('d/m/Y')));
     $config = new RM_Config();
     $data->assign('currencysymbol', $config->getCurrencySymbol());
     //TODO: resmania - we need to add discounts and coupons here
     $reservationArray = $reservation->toArray();
     $billing = new RM_Billing();
     $priceCharges = $billing->getPrice($reservation->id);
     $reservationArray['tax'] = $priceCharges->tax;
     $reservationArray['paid'] = $billing->getPaymentsTotal($reservation);
     $reservationArray['due'] = abs($priceCharges->total - $billing->getPaymentsTotal($reservation));
     $reservationArray['total'] = $priceCharges->total;
     $reservationArray['confirmed'] = $reservation->confirmed ? $translate->_('MessageYes') : $translate->_('MessageNo');
     $reservationArray['is_read'] = $reservation->is_read ? $translate->_('MessageYes') : $translate->_('MessageNo');
     $data->assign('reservation', $reservationArray);
     $text = $translate->getSectionMessages('Common.Invoice');
     $data->assign('text', $text);
     $userModel = new RM_Users();
     $user = $userModel->getByReservation($reservation);
     if ($user == null) {
         $userArray = array();
     } else {
         $userArray = $user->toArray();
         $userArray['title'] = $user->getTitle();
     }
     $data->assign('customer', $userArray);
     $reservationDetailsModel = new RM_ReservationDetails();
     $summaryModel = new RM_ReservationSummary();
     $details = $reservationDetailsModel->getAllByReservation($reservation);
     $arrayDetails = array();
     foreach ($details as $detail) {
         $arrayDetail = $detail->toArray();
         $unit = $detail->findUnit();
         $unitArray = $unit->toArray();
         $unitArray['id'] = $unit->getId();
         $unitArray['published'] = $unitArray->published ? $translate->_('MessageYes') : $translate->_('MessageNo');
         // format the start/end dates
         $arrayDetail['start_datetime'] = $config->convertDates($arrayDetail['start_datetime'], RM_Config::PHP_DATEFORMAT, RM_Config::JS_DATEFORMAT);
         $arrayDetail['end_datetime'] = $config->convertDates($arrayDetail['end_datetime'], RM_Config::PHP_DATEFORMAT, RM_Config::JS_DATEFORMAT);
         // extras
         $reservationDetailsExtra = $summaryModel->fetchByReservationDetail($detail)->toArray();
         foreach ($reservationDetailsExtra as $extra) {
             if ($extra['value'] == 0) {
                 $extra['value'] = "";
             }
             $unitArray['extras'][] = array("name" => $extra['name'], "value" => $extra['value'], "total_amount" => $extra['total_amount']);
         }
         $arrayDetail['unit'] = $unitArray;
         $arrayDetails[] = $arrayDetail;
     }
     $data->assign('details', $arrayDetails);
     $templateFile = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'userdata', 'views', 'admin', 'scripts', 'templates', 'invoice.phtml'));
     $template = new Dwoo_Template_File($templateFile);
     $dwoo = new Dwoo();
     return $dwoo->get($template, $data);
 }