public function loadJsonAction() { $unit_id = $this->_getParam('id'); $locationsDAO = new RM_Locations(); $locationInfo = $locationsDAO->fetchByUnit($unit_id)->toArray(); return array('data' => $locationInfo, 'encoded' => false); }
public function getadminmapAction() { // do a quick net check $parsed = parse_url('http://maps.google.com/maps'); $host = $parsed["host"]; $fp = @fsockopen($host, 80, $errno, $errstr, 20); if (!$fp) { $this->view->error = RM_Environment::getInstance()->getTranslation(RM_Environment::TRANSLATE_ERRORS)->_('Admin.GMaps.Errors', 'ConnectionError'); } else { $this->view->error = 'false'; // get the unit information ob_clean(); $unitID = $this->_getParam('unit_id'); $locationsModel = new RM_Locations(); $location = $locationsModel->fetchByUnit($unitID)->toArray(); if (!empty($location)) { $location = $location[0]; // get the coordinates $coordinates = new stdClass(); // set default map center points... if (empty($location['longitude']) || empty($location['latitude'])) { $location['longitude'] = 150.644; $location['latitude'] = -34.397; } $coordinates->longitude = $location['longitude']; $coordinates->latitude = $location['latitude']; $this->view->coordinates = $coordinates; // construct the address for GMAPs to use $address = ""; if ($location['address1']) { $address .= $location['address1']; } if ($location['address2']) { $address .= ", " . $location['address2']; } if ($location['city']) { $address .= ", " . $location['city']; } if ($location['address1']) { $address .= ", " . $location['state']; } if ($location['address1']) { $address .= ", " . $location['postcode']; } if ($location['address1']) { $address .= ", " . $location['country']; } $this->view->address = $address; } // gmaps settings $settingsObj = new RM_GMaps(); $settings = $settingsObj->getSettings()->toArray(); $this->view->settings = $settings[0]; } // call the view echo $this->view->render('GMaps/adminmap.phtml'); die; }
/** * This gathers all the data required for the user end google maps view */ public function mapAction() { // get the unit information ob_clean(); $unitID = $this->_getParam('unit_id'); $locationsModel = new RM_Locations(); $location = $locationsModel->fetchByUnit($unitID)->toArray(); if (!empty($location)) { $location = $location[0]; } else { $location['address1'] = ""; $location['address2'] = ""; $location['city'] = ""; $location['state'] = ""; $location['postcode'] = ""; $location['country'] = ""; } // get the coordinates $coordinates = new stdClass(); // set default map center points... if (empty($location['longitude']) || empty($location['latitude'])) { $location['longitude'] = 150.644; $location['latitude'] = -34.397; } $coordinates->longitude = $location['longitude']; $coordinates->latitude = $location['latitude']; $this->view->coordinates = $coordinates; // construct the address for GMAPs to use $address = ""; if ($location['address1']) { $address .= $location['address1']; } if ($location['address2']) { $address .= ", " . $location['address2']; } if ($location['city']) { $address .= ", " . $location['city']; } if ($location['address1']) { $address .= ", " . $location['state']; } if ($location['address1']) { $address .= ", " . $location['postcode']; } if ($location['address1']) { $address .= ", " . $location['country']; } $this->view->address = $address; // gmaps settings $settingsObj = new RM_GMaps(); $settings = $settingsObj->getSettings()->toArray(); $this->view->settings = $settings[0]; // call the view echo $this->view->render('GMaps/map.phtml'); die; }
public function getListHTML(RM_Unit_Row $unit) { //We need to check does Unit have an address or lan/lat to show a map or not $locationsModel = new RM_Locations(); if ($locationsModel->fetchByUnit($unit->id)->current() == null) { return ""; } $icon = RM_Environment::getConnector()->getRootURL() . 'RM/userdata/plugins/GMaps/images/tray_icon.gif'; return "<a href='javascript:void(0)' onclick=\"RM_doShadowBox('" . RM_Environment::getInstance()->getRouter()->_('GMaps', 'map', array("unit_id" => $unit->id, "page" => "map.phtml")) . "', '', 500, 400, 'iframe' )\" ><img width='30px' height='30px' src='" . $icon . "' border='0'></a>"; }
function copyInformation(RM_Unit_Row $original, RM_Unit_Row $copy) { $locationsModel = new RM_Locations(); $location = $locationsModel->fetchByUnit($original->id)->current(); if ($location == null) { return; } $copyLocationData = $location->toArray(); unset($copyLocationData['id']); $copyLocation = $locationsModel->createRow($copyLocationData); $copyLocationID = $copyLocation->save(); $unitLocationsModel = new RM_UnitLocations(); $unitLocation = $unitLocationsModel->createRow(array('unit_id' => $copy->id, 'location_id' => $copyLocationID)); $unitLocation->save(); }
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; }
/** * Replace all placeholders with information from current made reservations * * @param RM_Reservation_Manager $manager * @param string $template * @return */ private function _parseCompleteTemplate(RM_Reservation_Manager $manager, $template) { $data = new Dwoo_Data(); $reservationModel = new RM_Reservations(); $reservation = $reservationModel->find($manager->getReservationID())->current(); $summaryModel = new RM_ReservationSummary(); $unitModel = new RM_Units(); $details = $reservation->getDetails(); $arrayDetails = array(); foreach ($details as $detailRow) { $detail = $detailRow->transform(); $unitArray = $detail->getUnit()->toArray(); $periodArray = $detail->getPeriod()->toArray(); $periodArrayWithTime = $detail->getPeriod()->toArray(true); $personsArray = $detailRow->getPersons(); //$unitID = $detail->getUnit()->getId(); $unitID = $unitArray['id']; $unit = $unitModel->get($unitID); $locationModel = new RM_Locations(); $location = $locationModel->fetchByUnit($unitID)->current(); $arrayDetails[] = array('unit' => $unit->toArray(), 'period' => $periodArray, 'periodtime' => $periodArrayWithTime, 'persons' => $personsArray, 'summary' => $summaryModel->fetchByReservationDetail($detailRow)->toArray(), 'location' => $location !== null ? $location->toArray() : $locationModel->createRow()->toArray()); } $data->assign('details', $arrayDetails); $data->assign('user', $manager->getUser()->toArray()); $reservationArray = $reservation->toArray(); $reservationArray['confirmed'] = $reservation->isPaid() ? $this->_translate->_('MessageYes') : $this->_translate->_('MessageNo'); $reservationArray['total'] = $reservation->getTotalPrice(); $reservationArray['paid'] = $reservation->getTotalPaid(); $reservationArray['due'] = $reservationArray['total'] - $reservationArray['paid']; $data->assign('reservation', $reservationArray); $dwooTemplate = new Dwoo_Template_String($template); $dwoo = new Dwoo(); return $dwoo->get($dwooTemplate, $data); }