function display($tpl = null) { // Load the helper(s) if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $model = tmsModel::getModel(); $config = JFactory::getConfig(); $layoutName = vRequest::getCmd('layout', 'default'); if ($layoutName == 'edit') { $cid = vRequest::getInt('cid'); $task = vRequest::getCmd('task', 'add'); if ($task != 'add' && !empty($cid) && !empty($cid[0])) { $cid = (int) $cid[0]; } else { $cid = 0; } $model->setId($cid); $this->dateavailability = $model->getdateavailability(); $this->SetViewTitle('', $this->dateavailability->dateavailability_name); $this->addStandardEditViewCommands(); } else { $model_product = tmsModel::getModel('product'); $model_tour_class = tmsModel::getModel('tourclass'); require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmdateavailability.php'; $this->list_tour = tsmdateavailability::get_list_tour_private(); $this->list_tour_class = $model_tour_class->getItemList(); $this->SetViewTitle(); $this->addStandardDefaultViewCommandsdateavailability(); $this->addStandardDefaultViewLists($model, 0, 'ASC'); $this->list_date_availability = $model->getItemList(vRequest::getCmd('search')); $this->pagination = $model->getPagination(); } parent::display($tpl); }
public function create_children_dateavailability($tsmart_date_availability_id) { $query = $this->_db->getQuery(true); $query->delete('#__tsmart_dateavailability')->where('tsmart_dateavailability_parent_id=' . (int) $tsmart_date_availability_id); $this->_db->setQuery($query); $ok = $this->_db->execute(); if (!$ok) { $this->setError($this->_db->getErrorMsg()); return false; } $table_dateavailability = $this->getTable(); $table_dateavailability->load($tsmart_date_availability_id); $date_type = $table_dateavailability->date_type; if ($date_type == 'day_select') { $days_seleted = explode(',', $table_dateavailability->days_seleted); } else { $sale_period_from = $table_dateavailability->sale_period_from; $sale_period_to = $table_dateavailability->sale_period_to; $days_seleted = TSMUtility::dateRange($sale_period_from, $sale_period_to); $weekly = $table_dateavailability->weekly; $weekly = explode(',', $weekly); foreach ($days_seleted as $key => $day) { $day_of_week = strtolower(date('D', strtotime($day))); if (!in_array($day_of_week, $weekly)) { unset($days_seleted[$key]); } } } require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmdateavailability.php'; foreach ($days_seleted as $day) { $table_dateavailability->dateavailability_date = $day; $day = JFactory::getDate($day); $table_dateavailability->tsmart_date_availability_id = 0; $table_dateavailability->dateavailability_code = tsmdateavailability::get_format_dateavailability_code($tsmart_date_availability_id, $day); $table_dateavailability->tsmart_dateavailability_parent_id = $tsmart_date_availability_id; $ok = $table_dateavailability->store(); if (!$ok) { $this->setError($table_dateavailability->getErrors()); return false; } } return true; }