function SelectAjaxRoom($row, $hotel) { $rooms = hotelguide_rooms::getRoomsTree($hotel); $javascript = ''; $output = hotelguide_rooms::buildroomselect($rooms, 'parent_id', $row->parent_id, false, 'class="inputbox" size="1" style="font-size: 10px; width: 200px; text-align:left;"' . $javascript); return $output; }
/** * Method to get item data * * @access public * @return object */ function getData() { // Lets load the Items if it doesn't already exist if (empty($this->_data)) { $query = $this->_buildQuery(); $this->_db->setQuery($query); $rows = $this->_db->loadObjectList(); //establish the hierarchy of the categories $children = array(); //set depth limit $levellimit = 10; foreach ($rows as $child) { $parent = $child->parent_id; $list = @$children[$parent] ? $children[$parent] : array(); array_push($list, $child); $children[$parent] = $list; } //get list of the items $list = hotelguide_rooms::treerecurse(0, '', array(), $children, false, max(0, $levellimit - 1)); $total = count($list); jimport('joomla.html.pagination'); $this->_pagination = new JPagination($total, $this->getState('limitstart'), $this->getState('limit')); $this->_data = array_slice($list, $this->_pagination->limitstart, $this->_pagination->limit); } return $this->_data; }
function displayDefault() { global $mainframe, $hgconf; jimport('joomla.html.pane'); JHTML::_('behavior.tooltip'); JHTML::_('behavior.formvalidation'); JHTML::_('behavior.calendar'); //initialise variables $document =& JFactory::getDocument(); $user =& JFactory::getUser(); $db =& JFactory::getDBO(); $lang =& JFactory::getLanguage(); $tabs =& JPane::getInstance('tabs'); //get vars $cid = JRequest::getVar('cid'); $document->addScript(JURI::base() . 'components/com_hotelguide/assets/js/ratescreen.js'); //Get data from the model $model =& $this->getModel(); $row =& $this->get('Item'); // $rates = & $this->get('Rates'); if ($row->hotel) { $query = 'SELECT c.name, c.symbol' . ' FROM #__hg_hotelitems AS i' . ' LEFT JOIN #__hg_currency AS c ON c.id = i.currency' . ' WHERE i.id = ' . $row->hotel; $db->setQuery($query); $currency = $db->loadObject(); } //create the toolbar if ($cid) { JToolBarHelper::title(JText::_('HG_EDIT_ROOM'), 'room'); } else { JToolBarHelper::title(JText::_('HG_NEW_ROOM'), 'room'); } JToolBarHelper::apply(); JToolBarHelper::save(); JToolBarHelper::custom('saveandnew', 'savenew.png', 'savenew.png', 'HG_SAVE_AND_NEW', false); JToolBarHelper::cancel(); $rooms = hotelguide_rooms::getRoomsTree($row->hotel); //remove the current room to prevent selection as parent for itself foreach ($rooms as $room) { if ($room->id == $row->id) { unset($rooms[$room->id]); } } // fail if checked out not by 'me' if ($row->id) { if ($model->isCheckedOut($user->get('id'))) { JError::raiseWarning('SOME_ERROR_CODE', $row->title . ' ' . JText::_('HG_EDITED_BY_ANOTHER_ADMIN')); $mainframe->redirect('index.php?option=com_hotelguide&view=roomitems'); } } //clean data JFilterOutput::objectHTMLSafe($row, ENT_QUOTES); $lists = array(); $lists['parent_id'] = hotelguide_rooms::buildroomselect($rooms, 'parent_id', $row->parent_id, true); //assign data to template $this->assignRef('tabs', $tabs); $this->assignRef('lists', $lists); $this->assignRef('row', $row); $this->assignRef('hgconf', $hgconf); $this->assignRef('currency', $currency); $this->assignRef('rates', $rates); /* echo "<pre>"; echo "view="; print_r($rates); echo "</pre>"; */ }
function ChangeRoom() { $hotel = JRequest::getVar('hotel'); $rooms = hotelguide_rooms::getRoomsTree($hotel); $javascript = ''; $output = hotelguide_rooms::buildroomselect($rooms, 'parent_id', 0, true, 'class="inputbox" size="1" style="font-size: 10px; width: 200px; text-align:left;"' . $javascript); echo $output; }
/** * Get the room tree * based on the joomla 1.0 treerecurse * * @access public * @return array */ function treerecurse($id, $indent, $list, &$children, $title, $maxlevel = 9999, $level = 0, $type = 1) { if (@$children[$id] && $level <= $maxlevel) { foreach ($children[$id] as $v) { $id = $v->id; if ($type) { $pre = '<sup>|_</sup> '; $spacer = '. '; } else { $pre = '- '; $spacer = ' '; } if ($title) { if ($v->parent_id == 0) { $txt = '' . $v->title; } else { $txt = $pre . $v->title; } } else { if ($v->parent_id == 0) { $txt = ''; } else { $txt = $pre; } } $pt = $v->parent_id; $list[$id] = $v; $list[$id]->treename = "{$indent}{$txt}"; $list[$id]->children = count(@$children[$id]); $list = hotelguide_rooms::treerecurse($id, $indent . $spacer, $list, $children, $title, $maxlevel, $level + 1, $type); } } return $list; }