public function calculateJsonAction() { $value = $this->_getParam('value'); if ($value === null) { return array('data' => array('success' => false)); } $extraID = $this->_getParam('extra_id'); if ($extraID === null) { return array('data' => array('success' => false)); } $extrasModel = new RM_Extras(); $extra = $extrasModel->find($extraID)->current(); if ($extra === null) { return array('data' => array('success' => false)); } $reservationDetailID = $this->_getParam('detail_id'); if ($reservationDetailID == null) { return array('data' => array('success' => false)); } $reservationDetailsModel = new RM_ReservationDetails(); $reservationDetail = $reservationDetailsModel->find($reservationDetailID)->current(); if ($reservationDetail == null) { return array('data' => array('success' => false)); } $config = new RM_Config(); $currencySymbol = $config->getValue('rm_config_currency_symbol'); // calculate the tax due on the extra... $extraSubTotal = $extra->calculate($reservationDetail); // we need to create a new reservation details object so that the tax can be calculated $periodObj = new RM_Reservation_Period(new RM_Date(strtotime($reservationDetail->start_datetime)), new RM_Date(strtotime($reservationDetail->end_datetime))); $persons = new RM_Reservation_Persons(array("adults" => $reservationDetail->adults, "children" => $reservationDetail->children, "infants" => $reservationDetail->infants)); $fullReservationDetails = new RM_Reservation_Details($reservationDetail->findUnit(), $periodObj, $persons, array()); return array('data' => array('success' => true, 'value' => $currencySymbol . $extraSubTotal * $value)); }
/** * Deletes Reservation Details (Assigned Units) from a Reservation. * * Used to delete assigned units from a reservation. The units assigned to a * reservation are stored in the details tables. This method will delete the * selected units based on the reservation id. * * @param request id the id of the reservation. * @param request ids an array of the Unit ID's to be deleted.. * @return json boolean response of true or false in json format (true is success) */ public function deletedetailJsonAction() { $reservationID = $this->_getParam('reservation_id'); if ($reservationID == null) { return array('data' => array('success' => false)); } $unitID = $this->_getParam('unit_id'); if ($unitID == null) { return array('data' => array('success' => false)); } $model = new RM_ReservationDetails(); $detail = $model->find($reservationID, $unitID)->current(); if ($detail == null) { return array('data' => array('success' => false)); } $result = $detail->delete(); $model = new RM_Reservations(); $reservation = $model->find($reservationID)->current(); $reservation->recalculate(); if ($result == 1) { return array('data' => array('success' => true)); } else { return array('data' => array('success' => false)); } }