function datepickerAction()
 {
     ob_clean();
     $unitID = $this->_getParam('unit_id', null);
     $unitModel = new RM_Units();
     $unit = $unitModel->get($unitID);
     $reservationModel = new RM_Reservations();
     $reservations = $reservationModel->fetchAllForUnitCalendar($unit);
     $config = new RM_Config();
     $RMdate = new RM_Date();
     $jsonDisabledPeriods = new stdClass();
     $jsonDisabledPeriods->start = array();
     $jsonDisabledPeriods->end = array();
     foreach ($reservations as $period) {
         $jsonPeriod = new stdClass();
         $jsonPeriod->start = $config->convertDates($period->start_datetime, RM_Config::JS_DATEFORMAT, RM_Config::PHP_DATEFORMAT);
         $jsonPeriod->end = $config->convertDates($period->end_datetime, RM_Config::JS_DATEFORMAT, RM_Config::PHP_DATEFORMAT);
         // store the start date picker blocked periods
         $jsonDisabledPeriods->start[] = clone $jsonPeriod;
         $jsonPeriod->start = $RMdate->dateAdd($config->convertDates($period->start_datetime, RM_Config::JS_DATEFORMAT, RM_Config::PHP_DATEFORMAT), 1);
         $jsonPeriod->end = $RMdate->dateAdd($config->convertDates($period->end_datetime, RM_Config::JS_DATEFORMAT, RM_Config::PHP_DATEFORMAT), 1);
         $jsonDisabledPeriods->end[] = clone $jsonPeriod;
     }
     $json = Zend_Json::encode($jsonDisabledPeriods);
     $this->view->calendardata = $json;
     $this->view->unit_id = $unitID;
     echo $this->view->render('DailyPrices/datepicker.phtml');
     die;
 }
示例#2
0
 public function convertToGUI($data)
 {
     $info = $this->info();
     foreach ($info['metadata'] as $column) {
         switch ($column['DATA_TYPE']) {
             case 'datetime':
             case 'date':
                 $config = new RM_Config();
                 $data[$column['COLUMN_NAME']] = $config->convertDates($data[$column['COLUMN_NAME']], RM_Config::MYSQL_DATEFORMAT, RM_Config::JS_DATEFORMAT);
                 break;
         }
     }
     return $data;
 }
示例#3
0
 /**
  * Full installation process of plugin
  *
  * @param string $tempFileName
  * @param string $tempFilePath
  * @param stdclass $json
  * @return stdclass
  */
 function install($tempFileName, $tempFilePath, $json)
 {
     // get config values
     $rmConfig = new RM_Config();
     $chmodOctal = intval($rmConfig->getValue('rm_config_chmod_value'), 8);
     $rootPath = RM_Environment::getConnector()->getRootPath();
     $chunks = explode('.', $tempFileName);
     $pluginName = $chunks[0];
     //Plugin name will be always the first chunk, example: price.0.1.1.zip
     $pluginModel = new RM_Plugins();
     $existingPlugin = $pluginModel->fetchByName($pluginName);
     if ($existingPlugin !== null) {
         unlink($tempFilePath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'PluginAlreadyInstalled'));
     }
     $pluginFolderPath = $rootPath . DIRECTORY_SEPARATOR . 'RM' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $pluginName;
     if (is_dir($pluginFolderPath)) {
         $result = RM_Filesystem::deleteFolder($pluginFolderPath);
         if ($result == false) {
             unlink($tempFilePath);
             throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'PluginFolderAlreadyExists') . ': ' . $pluginFolderPath);
         }
     }
     $result = mkdir($pluginFolderPath, $chmodOctal);
     if ($result == false) {
         unlink($tempFilePath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'CreatePluginFolderFailer'));
     } else {
         $json = $this->_addMessageToJson($json, $this->_translate->_('Admin.Plugins.InstallMsg', 'PluginFolderCreatedSuccessfully'));
     }
     //4. unzip plugin into new directory
     if (!extension_loaded('zlib')) {
         unlink($tempFilePath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'ZlibNotSupported'));
     }
     $zip = new PclZip($tempFilePath);
     $result = $zip->extract(PCLZIP_OPT_PATH, $pluginFolderPath);
     if (!$result) {
         unlink($tempFilePath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'UnzipFailed'));
     } else {
         $json = $this->_addMessageToJson($json, $this->_translate->_('Admin.Plugins.InstallMsg', 'UnzipSuccessfully'));
     }
     unlink($tempFilePath);
     chmod($pluginFolderPath, $chmodOctal);
     //4.0. create separate folder in 'userdata/plugins' for a new plugin
     $userdataFolderPath = $rootPath . DIRECTORY_SEPARATOR . 'RM' . DIRECTORY_SEPARATOR . 'userdata' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $pluginName;
     if (is_dir($userdataFolderPath)) {
         $result = RM_Filesystem::deleteFolder($userdataFolderPath);
         if ($result == false) {
             throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'PluginFolderAlreadyExists') . ': ' . $userdataFolderPath);
         }
     }
     $result = mkdir($userdataFolderPath . DIRECTORY_SEPARATOR, $chmodOctal);
     if ($result == false) {
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'CreatePluginUserdataFolderFailer'));
     } else {
         $json = $this->_addMessageToJson($json, $this->_translate->_('Admin.Plugins.InstallMsg', 'PluginFolderCreatedSuccessfully'));
     }
     @rename($pluginFolderPath . DIRECTORY_SEPARATOR . 'views', $userdataFolderPath . DIRECTORY_SEPARATOR . 'views');
     @chmod($pluginFolderPath . DIRECTORY_SEPARATOR . 'views', $chmodOctal);
     @rename($pluginFolderPath . DIRECTORY_SEPARATOR . 'languages', $userdataFolderPath . DIRECTORY_SEPARATOR . 'languages');
     @chmod($pluginFolderPath . DIRECTORY_SEPARATOR . 'languages', $chmodOctal);
     @rename($pluginFolderPath . DIRECTORY_SEPARATOR . 'css', $userdataFolderPath . DIRECTORY_SEPARATOR . 'css');
     @chmod($pluginFolderPath . DIRECTORY_SEPARATOR . 'css', $chmodOctal);
     @rename($pluginFolderPath . DIRECTORY_SEPARATOR . 'images', $userdataFolderPath . DIRECTORY_SEPARATOR . 'images');
     @chmod($pluginFolderPath . DIRECTORY_SEPARATOR . 'images', $chmodOctal);
     @chmod($userdataFolderPath, $chmodOctal);
     //5. get INI file
     $iniFilePath = $pluginFolderPath . DIRECTORY_SEPARATOR . self::$_iniFilename;
     if (is_file($iniFilePath) == false) {
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'NoIniFile'));
     }
     //6. parse INI file
     $parser = new RM_Plugin_Config_Parser();
     try {
         $config = $parser->getConfig($iniFilePath);
     } catch (RM_Exception $e) {
         //Error in ini file parsing
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($e->getMessage());
     }
     //Check: could be a module if no 'module' value is in config
     if ($config->information['module'] == "") {
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'WrongTryToInstallModule'));
     }
     $json = $this->_addMessageToJson($json, $this->_translate->_('Admin.Plugins.InstallMsg', 'UnzipSuccess'));
     //7. invoke SQL install file
     try {
         $result = self::installDatabase($pluginFolderPath);
     } catch (Exception $e) {
         self::uninstallDatabase($pluginFolderPath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($e->getMessage());
     }
     if ($result == false) {
         self::uninstallDatabase($pluginFolderPath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'WrongInstallSQLQueries'));
     } else {
         $json = $this->_addMessageToJson($json, $this->_translate->_('Admin.Plugins.InstallMsg', 'InstallSQLSuccess'));
     }
     //8. create a new record in Plugin database
     $pluginRow = array();
     $pluginRow = $config->information;
     $pluginRow['module_name'] = $pluginRow['module'];
     unset($pluginRow['module']);
     //convert creation date into MySQL format
     $rmConfig = new RM_Config();
     $pluginRow['creation_date'] = $rmConfig->convertDates(strtotime($pluginRow['creation_date']), RM_Config::TIMESTAMP_DATEFORMAT, RM_Config::MYSQL_DATEFORMAT);
     //TODO:
     //1.check the insertions
     $pkey = $pluginModel->insert($pluginRow);
     //Create a new records in dependencies database table
     $model = new RM_Dependencies();
     if (is_array($config->dependencies)) {
         foreach ($config->dependencies as $dependency) {
             $model->insert($dependency);
         }
     }
     //9. get the main class of the plugin
     $pluginClassFilepath = $pluginFolderPath . DIRECTORY_SEPARATOR . RM_Plugin_Config::CLASSES . DIRECTORY_SEPARATOR . 'RM' . DIRECTORY_SEPARATOR . 'Plugin' . DIRECTORY_SEPARATOR . $config->information['name'] . '.php';
     if (is_file($pluginClassFilepath) == false) {
         self::uninstallDatabase($pluginFolderPath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($this->_translate->_('Admin.Plugins.InstallMsg', 'DoesntExists'));
     }
     require_once $pluginClassFilepath;
     $pluginClassName = 'RM_Plugin_' . $config->information['name'];
     if (class_exists($pluginClassName) == false) {
         self::uninstallDatabase($pluginFolderPath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($pluginClassName . $this->_translate->_('Admin.Plugins.InstallMsg', 'DoesntExists'));
     }
     $pluginObject = new $pluginClassName();
     if (!$pluginObject instanceof RM_Plugin_Interface) {
         self::uninstallDatabase($pluginFolderPath);
         RM_Filesystem::deleteFolder($pluginFolderPath);
         throw new RM_Exception($pluginClassName . $this->_translate->_('Admin.Plugins.InstallMsg', 'WrongInterface'));
     }
     //10. invoke install method of that class (if we need something extra)
     $result = $pluginObject->install();
     $json = $this->_addMessageToJson($json, $this->_translate->_('Admin.Plugins.InstallMsg', 'InstallSuccess'));
     //Check dependencies and if some of them is validate==false disable plugin
     $dependencyManager = new RM_Dependency_Manager();
     $plugin = $pluginModel->find($pkey)->current();
     $dependencies = $dependencyManager->getDependencies($plugin);
     foreach ($dependencies as $dependency) {
         if ($dependency->validate() == false) {
             try {
                 $pluginModel->disable($plugin);
                 break;
             } catch (Exception $e) {
                 //TODO: add log message that we could not disable this module.
             }
         }
     }
     return $json;
 }
示例#4
0
 /**
  * Return JSON data for the chart
  *
  * @return string
  */
 function getData()
 {
     $config = new RM_Config();
     $units = $this->_getUnits();
     $datetimes = $this->_getDatetimes();
     $reservationDetailsModel = new RM_ReservationDetails();
     // for fusion charts we need xml, so the data needs to be formatted
     // so that the json data can render the xml using an xtemplate.
     // we need:-
     // array dates containing all dates of the period we need to chart.
     // array units containing 'name', 'color', array: 'data' containing the unit reservation count for each period
     $jsonSeries = new stdClass();
     $jsonDates = new stdClass();
     $feildsArray = array();
     $jsonSeriesArray = array();
     $jsonChartDataArray = array();
     $feildsArray[] = 'date';
     // this loop, loops through the units once to get the series data
     foreach ($units as $unit) {
         $feildsArray[] = 'unit' . $unit->getId();
         $jsonSeries->yField = 'unit' . $unit->getId();
         $jsonSeries->displayName = $unit->name;
         $jsonSeries->type = 'line';
         // the graph type
         $jsonSeries->style = '{color: 0x' . $unit->color . '}';
         // the graph type
         $jsonSeriesArray[] = clone $jsonSeries;
     }
     // this loop, loops through all dates and gets the data for each period
     for ($i = 0; $i < count($datetimes) - 1; $i++) {
         // get the date
         $date = $config->convertDates($datetimes[$i], RM_Config::PHP_DATEFORMAT, RM_Config::HUMAN_MONTH_DATEFORMAT);
         $chartData = array();
         $chartData['date'] = $date;
         // loop through each unit
         foreach ($units as $unit) {
             $SdateParts = explode("-", $datetimes[$i]);
             $startDatetimes = mktime(0, 0, 0, (int) $SdateParts[1], (int) $SdateParts[2], (int) $SdateParts[0]);
             // set the endDatetimes to the last day of the month
             $EdateParts = explode("-", $datetimes[$i + 1]);
             $endDatetimes = mktime(0, 0, 0, (int) $EdateParts[1], (int) $SdateParts[2], (int) $EdateParts[0]);
             //mktime($hour, $minute, $second, $month, $day, $year)
             $period = new RM_Reservation_Period(new RM_Date($datetimes[$i]), new RM_Date($datetimes[$i + 1]));
             $count = $reservationDetailsModel->getReservationCount($unit, $period);
             $chartData['unit' . $unit->getId()] = $count;
         }
         //$chartData->units = $dataArray;
         $jsonChartDataArray[] = $chartData;
     }
     $returnData = new stdClass();
     // fields: array containing all the fields ie: 'date', 'unit1', 'unit2', 'unit3'
     //
     // series: array containing objects for each series item:-
     // type: 'line',displayName: 'Unit 1',yField: 'unit1',style: {color:0x99BBE8}
     // note yField = the field name.
     //
     // data should contain the data:-
     // data: [
     //     {date:'Jul 07', unit1: 9, unit2: 11, unit3: 4},
     //     {date:'Aug 07', unit1: 5, unit2: 0, unit3: 3},
     //     {date:'Sep 07', unit1: 4, unit2: 0, unit3: 4},
     //     {date:'Oct 07', unit1: 8, unit2: 5, unit3: 5},
     //     {date:'Nov 07', unit1: 4, unit2: 6, unit3: 6},
     //     {date:'Dec 07', unit1: 0, unit2: 8, unit3: 7},
     //     {date:'Jan 08', unit1: 0, unit2: 11, unit3: 0},
     //     {date:'Feb 08', unit1: 8, unit2: 15, unit3: 7}
     // ]
     $returnData->fields = $feildsArray;
     $returnData->series = $jsonSeriesArray;
     $returnData->data = $jsonChartDataArray;
     return $returnData;
 }
示例#5
0
 public function listresJsonAction()
 {
     $id = $this->_getParam('id');
     $config = new RM_Config();
     // used for date conversion
     $model = new RM_Reservations();
     $Users_Reservation_Total = $model->fetchAllByUserID($id)->count();
     $Users_Reservation_Info = $model->fetchAllByUserID($id)->toArray();
     $jsonReservations = array();
     $reservationDetailsModel = new RM_ReservationDetails();
     foreach ($Users_Reservation_Info as $reservation) {
         $tempVal->reservation_id = $reservation['reservation_id'];
         $tempVal->unit_id = $reservation['unit_id'];
         //TODO: We need to convert this to a meaningful word ie: unitname (ID:X)
         $tempVal->start_date = $config->convertDates($reservation['start_datetime'], RM_Config::MYSQL_DATEFORMAT, RM_Config::JS_DATEFORMAT);
         $tempVal->end_date = $config->convertDates($reservation['end_datetime'], RM_Config::MYSQL_DATEFORMAT, RM_Config::JS_DATEFORMAT);
         $jsonReservations[] = clone $tempVal;
     }
     $ret = array("data" => '{"total": ' . $Users_Reservation_Total . ', "data" : ' . Zend_Json::encode($jsonReservations) . '}', 'encoded' => true);
     return $ret;
 }
 public function getreservationsJsonAction()
 {
     $unit_id = $this->_getParam('unitid');
     $date = $this->_getParam('date');
     // TODO: add admin selected language here:-
     $lang = RM_Environment::getInstance()->getLocale();
     $reservations = new RM_Reservations();
     $reservationDetails = $reservations->fetchAllByUnitDate($unit_id, $date, $lang);
     $jsonReservations = array();
     $config = new RM_Config();
     $usersObj = new RM_Users();
     foreach ($reservationDetails as $reservation) {
         $jsonData = new stdClass();
         $jsonData->reservation_id = $reservation->reservation_id;
         $jsonData->unit_id = $reservation->unit_id;
         $jsonData->start_date = $config->convertDates($reservation->start_datetime, RM_Config::PHP_DATEFORMAT, RM_Config::JS_DATEFORMAT);
         $jsonData->end_date = $config->convertDates($reservation->end_datetime, RM_Config::PHP_DATEFORMAT, RM_Config::JS_DATEFORMAT);
         $jsonData->total_price = $reservation->total_price;
         $jsonData->unit_name = $reservation->name;
         $jsonData->user_id = $reservation->user_id;
         if ($reservation->confirmed) {
             $confirmed = "<img src='" . RM_Environment::getConnector()->getRootURL() . "/RM/userdata/images/system/small/reservation_confirmed.png' border='0'>";
         } else {
             $confirmed = "<img src='" . RM_Environment::getConnector()->getRootURL() . "/RM/userdata/images/system/small/reservation_unconfirmed.png' border='0'>";
         }
         $jsonData->confirmed = $confirmed;
         $titleArray = str_replace(chr(39), chr(34), $this->_translate->_('Common.JSON', 'Titles'));
         $title = $usersObj->userTitle((int) $reservation->title, $titleArray);
         $jsonData->title = $title;
         $jsonData->first_name = $reservation->first_name;
         $jsonData->last_name = $reservation->last_name;
         $jsonReservations[] = clone $jsonData;
     }
     if (empty($jsonReservations)) {
         return array('data' => array('success' => false));
     }
     $json = "{\n            data : " . Zend_Json::encode($jsonReservations) . "\n        }";
     return array('data' => $json, 'encoded' => true);
 }
示例#7
0
 public function editJsonAction()
 {
     $json = new stdClass();
     $id = $this->_getParam('id');
     $iso = $this->_getParam('iso', RM_Environment::getInstance()->getLocale());
     $unitModel = new RM_Units();
     $unit = $unitModel->get($id, $iso);
     $config = new RM_UnitConfig();
     $fields = $config->getEditFormByUnit($unit);
     $config = new RM_Config();
     // view_preferences_1 provides non html editors, just raw editors
     foreach ($fields as $field) {
         if ($config->getValue('rm_config_editor') == "text" && $field->view_preferences_1 !== "") {
             $jsonFields[] = $field->view_preferences_1;
         } else {
             $jsonFields[] = $field->view_preferences;
         }
     }
     $reservationModel = new RM_Reservations();
     $reservations = $reservationModel->fetchAllByUnit($unit);
     $jsonReservations = array();
     /*
      * the reservation information required to add events to the calendar must include
      * the start and end date but also the unit color.
      */
     foreach ($reservations as $reservation) {
         $jsonReservation = new stdClass();
         $jsonReservation->start_date = $config->convertDates($reservation->start_datetime, RM_Config::MYSQL_DATEFORMAT, RM_Config::MYSQL_DATEFORMAT_SHORT);
         $jsonReservation->end_date = $config->convertDates($reservation->end_datetime, RM_Config::MYSQL_DATEFORMAT, RM_Config::MYSQL_DATEFORMAT_SHORT);
         $jsonReservation->color = $unit->color;
         // unit color
         $jsonReservations[] = $jsonReservation;
     }
     $priceSystems = RM_Environment::getInstance()->getPriceSystem()->getAllPriceSystems();
     $jsonPriceSystems = array();
     foreach ($priceSystems as $system) {
         $jsonPriceSystems[] = $system->name;
     }
     $priceSystem = RM_Environment::getInstance()->getPriceSystem()->getRealPriceSystem($unit);
     // group handling (only used when the groups is enabled)
     $isGroupTemplate = 0;
     if ($unit->isTemplateUnit() === (int) $unit->id) {
         $isGroupTemplate = 1;
     } elseif ($unit->isTemplateUnit() === null || $unit->isTemplateUnit() === 0) {
         // if this unit is not in a group then we set the isGroupTemplate true
         // as this is really the same as a template for the GUI
         $isGroupTemplate = 1;
     }
     $json = "{ unit : " . Zend_Json::encode($unitModel->convertToGUI($unit->toArray())) . ", isgrouptemplate: '" . $isGroupTemplate . "', fields : [" . implode(',', $jsonFields) . "], periods: " . Zend_Json::encode($jsonReservations) . ", language: '" . $iso . "', price: '" . $priceSystem->name . "', prices: " . Zend_Json::encode($jsonPriceSystems) . "}";
     return array('data' => $json, 'encoded' => true);
 }
示例#8
0
 /**
  * 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);
 }