/** * Check if an item is checked out * * This function can be used as a static function too, when you do so you need to also provide the * a value for the $against parameter. * * @static * @access public * @param integer $with The userid to preform the match with, if an item is checked out * by this user the function will return false * @param integer $against The userid to perform the match against when the function is used as * a static function. * @return boolean */ function isCheckedOut($with = 0, $against = null) { if (isset($this) && is_a($this, 'tsmTable') && is_null($against)) { $against = $this->get('locked_by'); } //item is not checked out, or being checked out by the same user if (!$against || $against == $with) { return false; } $session = tsmTable::getInstance('session'); return $session->exists($against); }
public static function storeConfig() { $user = JFactory::getUser(); if ($user->authorise('core.admin', 'com_tsmart')) { $installed = tsmartModelConfig::checktsmartInstalled(); if ($installed) { tsmartModelConfig::installVMconfigTable(); $confData = array(); $confData['tsmart_config_id'] = 1; $confData['config'] = tsmConfig::$_jpConfig->toString(); $confTable = tsmTable::getInstance('configs', 'Table', array()); if (!$confTable->bindChecknStore($confData)) { vmError('storeConfig was not able to store config'); } } } }
public function save_departure_item($data) { $tsmart_product_id = $data['tour_id']; $departure_name = $data['departure_name']; $tour_service_class_id = $data['tour_service_class_id']; if ($departure_name == '') { vmError('please set departure name'); return false; } $list_basic_available2 = $this->get_departure_item($data); if (count($list_basic_available2) == 0) { vmError('there are no departure available'); return false; } $list_date_available = array(); if (count($list_basic_available2)) { foreach ($list_basic_available2 as $item) { $list_date_available[] = $item->date_select; } } //lấy ra group_size_id từ bản ghi đầu tiên $tsmart_group_size_id = reset($list_basic_available2)->tsmart_group_size_id; $list_date_available = '"' . implode('","', $list_date_available) . '"'; //check exists data $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('tsmart_departure_id')->from('#__tsmart_departure')->where('departure_date IN(' . $list_date_available . ')')->where('tsmart_product_id=' . (int) $tsmart_product_id)->where('tsmart_service_class_id=' . (int) $tour_service_class_id)->where('tsmart_group_size_id=' . (int) $tsmart_group_size_id); $list_tsmart_departure_id = $db->setQuery($query)->loadObjectList(); if (count($list_tsmart_departure_id) > 1) { vmError('there are some departure exists'); return false; } $tsmart_departure_id = parent::store($data); $db = JFactory::getDbo(); if (!$tsmart_departure_id) { vmError('can not save departure ' . $db->getErrorMsg()); return false; } $query = $db->getQuery(true); $table_departure = tsmTable::getInstance('Departure', 'Table'); $table_departure->bind($data); $table_departure->store(); $tsmart_departure_id = $table_departure->tsmart_departure_id; //inser to group size foreach ($list_basic_available2 as $item) { $table_departure->tsmart_departure_id = 0; $table_departure->published = 1; $table_departure->tsmart_departure_id = $tsmart_departure_id; $table_departure->tsmart_product_id = $tsmart_product_id; $table_departure->departure_date = JFactory::getDate($item->date_select)->toSql(); $table_departure->tsmart_service_class_id = $item->service_class_id; $table_departure->tsmart_group_size_id = $item->tsmart_group_size_id; $table_departure->senior_price = $item->senior_price; $table_departure->adult_price = $item->price_adult; $table_departure->teen_price = $item->price_teen; $table_departure->infant_price = $item->price_infant; $table_departure->children1_price = $item->price_children1; $table_departure->children2_price = $item->price_children2; $table_departure->private_room_price = $item->price_private_room; $table_departure->senior_departure_price = $item->departure_price->price_senior; $table_departure->adult_departure_price = $item->departure_price->price_adult; $table_departure->teen_departure_price = $item->departure_price->price_teen; $table_departure->infant_departure_price = $item->departure_price->price_infant; $table_departure->children1_departure_price = $item->departure_price->price_children1; $table_departure->children2_departure_price = $item->departure_price->price_children2; $table_departure->private_room_departure_price = $item->departure_price->price_private_room; $table_departure->store(); $err = $db->getErrorMsg(); if (!empty($err)) { vmError('can not insert group size in this tour', $err); } } $table_departure->delete($tsmart_departure_id); $err = $db->getErrorMsg(); if (!empty($err)) { vmError('can not insert group size in this tour', $err); } return $list_basic_available2; }
/** * Method to load and return a model object. * * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE * * @param string $name The name of the view * @param string $prefix The class prefix. Optional. * @param array $config Configuration settings to pass to JTable::getInstance * * @return mixed Model object or boolean false if failed * * @since 11.1 * @see JTable::getInstance */ protected function _createTable($name, $prefix = 'Table', $config = array()) { // Clean the model name $name = preg_replace('/[^A-Z0-9_]/i', '', $name); $prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); // Make sure we are returning a DBO object if (!array_key_exists('dbo', $config)) { $config['dbo'] = JFactory::getDbo(); } return tsmTable::getInstance($name, $prefix, $config); }