Пример #1
0
 /**
  * Sets the model's state
  * 
  * @return array()
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'tbl.created_datetime', 'cmd');
     $state['direction'] = $app->getUserStateFromRequest($ns . '.filter_direction', 'filter_direction', 'DESC', 'word');
     $state['filter_orderid'] = $app->getUserStateFromRequest($ns . 'filter_orderid', 'filter_orderid', '', '');
     $state['filter_type'] = $app->getUserStateFromRequest($ns . 'filter_type', 'filter_type', '', '');
     $state['filter_transactionid'] = $app->getUserStateFromRequest($ns . 'filter_transactionid', 'filter_transactionid', '', '');
     $state['filter_user'] = $app->getUserStateFromRequest($ns . 'filter_user', 'filter_user', '', '');
     $state['filter_userid'] = $app->getUserStateFromRequest($ns . 'filter_userid', 'filter_userid', '', '');
     $state['filter_id_from'] = $app->getUserStateFromRequest($ns . 'id_from', 'filter_id_from', '', '');
     $state['filter_id_to'] = $app->getUserStateFromRequest($ns . 'id_to', 'filter_id_to', '', '');
     $state['filter_date_from'] = $app->getUserStateFromRequest($ns . 'date_from', 'filter_date_from', '', '');
     $state['filter_date_to'] = $app->getUserStateFromRequest($ns . 'date_to', 'filter_date_to', '', '');
     $state['filter_datetype'] = 'created';
     $state['filter_total_from'] = $app->getUserStateFromRequest($ns . 'filter_total_from', 'filter_total_from', '', '');
     $state['filter_total_to'] = $app->getUserStateFromRequest($ns . 'filter_total_to', 'filter_total_to', '', '');
     $state['filter_enabled'] = $app->getUserStateFromRequest($ns . 'filter_enabled', 'filter_enabled', '', '');
     $state['filter_lifetime'] = $app->getUserStateFromRequest($ns . 'filter_lifetime', 'filter_lifetime', '', '');
     if (Tienda::getInstance()->get('display_subnum', 0)) {
         $state['filter_subnum'] = $app->getUserStateFromRequest($ns . 'filter_subnum', 'filter_subnum', '', '');
     }
     foreach (@$state as $key => $value) {
         $model->setState($key, $value);
     }
     return $state;
 }
Пример #2
0
 /**
  * Gets an existing user or creates a new one
  * 
  * @param array $submitted_values Data for a new user
  * @param int $user_id Existing user id (optional)
  * @return JUser object
  * @access protected
  */
 function _getUser($submitted_values, $user_id = 0)
 {
     $config = Tienda::getInstance();
     if ($user_id) {
         $user = JFactory::getUser($user_id);
     } else {
         $user = JFactory::getUser();
     }
     if ($user->id) {
         return $user;
     }
     Tienda::load('TiendaHelperUser', 'helpers.user');
     $newuser_email = $submitted_values['email'];
     // create user from email
     jimport('joomla.user.helper');
     $details['name'] = $newuser_email;
     $details['username'] = $newuser_email;
     $details['email'] = $newuser_email;
     $details['password'] = JUserHelper::genRandomPassword();
     $details['password2'] = $details['password'];
     $details['block'] = $config->get('block_automatically_registered') ? '1' : '0';
     if ($user = TiendaHelperUser::createNewUser($details)) {
         if (!$config->get('block_automatically_registered')) {
             // login the new user
             $login = TiendaHelperUser::login($details, '1');
         }
         // indicate that user was registed by AS automatically
         $user->set('automatically_registered', true);
     }
     return $user;
 }
Пример #3
0
 /**
  * Renders the DirectPayment form
  * 
  * @param object $row
  * @param array $prepop Array of values to fill in the form fields
  * @param boolean $display_note
  * @param boolean $display_typeinfo
  * @return string
  * @access public
  */
 function renderForm($row, $prepop = array(), $display_note = '1', $display_typeinfo = '1')
 {
     $user = JFactory::getUser();
     $secure_post = $this->_params->get('secure_post', '0');
     $config = Tienda::getInstance();
     /*
      * get all necessary data and prepare vars for assigning to the template
      */
     $vars = new JObject();
     $vars->action_url = JRoute::_("index.php?option=com_tienda&controller=checkout&task=confirmPayment&orderpayment_type={$this->_plugin_type}&paction=process_direct_payment", false, $secure_post);
     $vars->prepop = $prepop;
     $vars->user = $user;
     $vars->cctype_input = $this->_getCardTypesInput('cardtype', !empty($prepop['cardtype']) ? $prepop['cardtype'] : '');
     $vars->country_input = $this->_getCountriesInput('country', !empty($prepop['country']) ? $prepop['country'] : '');
     $vars->row = $row;
     $vars->token_input = JHTML::_('form.token');
     $vars->display_note = $display_note;
     $vars->display_typeinfo = $display_typeinfo;
     $vars->display_value = $config->get('display_value', '1');
     $vars->display_period = $config->get('display_period', '1');
     $vars->currency_preval = $config->get('currency_preval', '$');
     $vars->currency_postval = $config->get('currency_postval', ' USD');
     $html = $this->_getLayout('directpayment_form', $vars);
     return $html;
 }
Пример #4
0
 protected function _buildQueryFields(&$query)
 {
     $field = array();
     $field[] = " p.product_name ";
     $field[] = " p.product_sku ";
     $field[] = " p.product_model ";
     $field[] = " p.product_full_image ";
     $field[] = " p.product_ships ";
     $field[] = " p.product_weight ";
     $field[] = " p.product_length ";
     $field[] = " p.product_width ";
     $field[] = " p.product_height ";
     $field[] = " p.product_recurs ";
     $field[] = " p.product_enabled ";
     $field[] = " p.product_notforsale ";
     $field[] = " p.product_rating ";
     $field[] = " p.product_comments ";
     $field[] = " m.manufacturer_name AS manufacturer_name ";
     // This subquery returns the default price for the product and allows for sorting by price
     $date = JFactory::getDate()->toMysql();
     $default_group = Tienda::getInstance()->get('default_user_group', '1');
     $filter_group = (int) $this->getState('filter_group');
     if (empty($filter_group)) {
         $filter_group = $default_group;
     }
     $field[] = "\n\t\t\t(\n\t\t\tSELECT\n\t\t\t\tprices.product_price\n\t\t\tFROM\n\t\t\t\t#__tienda_productprices AS prices\n\t\t\tWHERE\n\t\t\t\tprices.product_id = tbl.product_id\n\t\t\t\tAND prices.group_id = '{$filter_group}'\n\t\t\t\tAND prices.product_price_startdate <= '{$date}'\n\t\t\t\tAND (prices.product_price_enddate >= '{$date}' OR prices.product_price_enddate = '0000-00-00 00:00:00' )\n\t\t\t\tORDER BY prices.price_quantity_start ASC\n\t\t\tLIMIT 1\n\t\t\t)\n\t\tAS product_price ";
     $query->select($this->getState('select', 'tbl.*'));
     $query->select($field);
 }
Пример #5
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->defines = Tienda::getInstance();
     if (JDEBUG) {
         $this->cache_enabled = false;
     }
 }
Пример #6
0
 function __construct($config = array())
 {
     parent::__construct($config);
     $this->defines = Tienda::getInstance();
     Tienda::load("TiendaHelperRoute", 'helpers.route');
     $this->router = new TiendaHelperRoute();
     $this->user = JFactory::getUser();
 }
Пример #7
0
 /**
  * Set the CSV of states to be reported on
  * @param $csv
  * @return unknown_type
  */
 function setStatesCSV($csv = '')
 {
     if (empty($csv)) {
         $csv = Tienda::getInstance()->get('orderstates_csv', '2, 3, 5, 17');
     }
     $array = explode(',', $csv);
     $this->_statesCSV = "'" . implode("','", $array) . "'";
 }
Пример #8
0
 /**
  * 
  * @return void
  **/
 function _default($tpl = null)
 {
     Tienda::load('TiendaSelect', 'library.select');
     Tienda::load('TiendaGrid', 'library.grid');
     Tienda::load('TiendaTools', 'library.tools');
     // check config
     $row = Tienda::getInstance();
     $this->assign('row', $row);
     // add toolbar buttons
     JToolBarHelper::apply('save');
     JToolBarHelper::cancel('close', 'COM_TIENDA_CLOSE');
     // plugins
     $filtered = array();
     $items = TiendaTools::getPlugins();
     for ($i = 0; $i < count($items); $i++) {
         $item =& $items[$i];
         // Check if they have an event
         if ($hasEvent = TiendaTools::hasEvent($item, 'onListConfigTienda')) {
             // add item to filtered array
             $filtered[] = $item;
         }
     }
     $items = $filtered;
     $this->assign('items_sliders', $items);
     // Add pane
     jimport('joomla.html.pane');
     $sliders = JPane::getInstance('sliders');
     $this->assign('sliders', $sliders);
     // form
     $validate = JUtility::getToken();
     $form = array();
     $view = strtolower(JRequest::getVar('view'));
     $form['action'] = "index.php?option=com_tienda&controller={$view}&view={$view}";
     $form['validate'] = "<input type='hidden' name='{$validate}' value='1' />";
     $this->assign('form', $form);
     // set the required image
     // TODO Fix this to use defines
     $required = new stdClass();
     $required->text = JText::_('COM_TIENDA_REQUIRED');
     $required->image = "<img src='" . JURI::root() . "/media/com_tienda/images/required_16.png' alt='{$required->text}'>";
     $this->assign('required', $required);
     // Elements
     $elementArticleModel = JModel::getInstance('ElementArticle', 'TiendaModel');
     $this->assign('elementArticleModel', $elementArticleModel);
     // terms
     $elementArticle_terms = $elementArticleModel->fetchElement('article_terms', @$row->get('article_terms'));
     $resetArticle_terms = $elementArticleModel->clearElement('article_terms', '0');
     $this->assign('elementArticle_terms', $elementArticle_terms);
     $this->assign('resetArticle_terms', $resetArticle_terms);
     // shipping
     $elementArticle_shipping = $elementArticleModel->fetchElement('article_shipping', @$row->get('article_shipping'));
     $resetArticle_shipping = $elementArticleModel->clearElement('article_shipping', '0');
     $this->assign('elementArticle_shipping', $elementArticle_shipping);
     $this->assign('resetArticle_shipping', $resetArticle_shipping);
 }
Пример #9
0
 /**
  * save a record
  * @return void
  */
 function save()
 {
     $error = false;
     $errorMsg = "";
     $model = $this->getModel($this->get('suffix'));
     $config = Tienda::getInstance();
     $properties = $config->getProperties();
     foreach (@$properties as $key => $value) {
         unset($row);
         $row = $model->getTable('config');
         $newvalue = JRequest::getVar($key, '', 'post', 'string', JREQUEST_ALLOWRAW | JREQUEST_NOTRIM);
         $value_exists = array_key_exists($key, $_POST);
         if ($value_exists && !empty($key)) {
             // proceed if newvalue present in request. prevents overwriting for non-existent values.
             $row->load(array('config_name' => $key));
             $row->config_name = $key;
             $row->value = $newvalue;
             if (!$row->save()) {
                 $error = true;
                 $errorMsg .= JText::_('COM_TIENDA_COULD_NOT_STORE') . " {$key} :: " . $row->getError() . " - ";
             }
         }
     }
     $model->clearCache();
     if (!$error) {
         $this->messagetype = 'message';
         $this->message = JText::_('COM_TIENDA_SAVED');
         $dispatcher = JDispatcher::getInstance();
         $dispatcher->trigger('onAfterSave' . $this->get('suffix'), array($row));
     } else {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_TIENDA_SAVE_FAILED') . " - " . $errorMsg;
     }
     $redirect = "index.php?option=com_tienda&view=" . $this->get('suffix');
     $group = JRequest::getVar('group');
     switch ($group) {
         default:
             if ($group) {
                 $redirect .= "&task=" . $group;
             }
             break;
     }
     $format = JRequest::getVar('format');
     if ($format == 'raw') {
         $response = array();
         $response['error'] = $error;
         $response['msg'] = $this->message;
         echo json_encode($response);
         return;
     }
     $redirect = JRoute::_($redirect, false);
     $this->setRedirect($redirect, $this->message, $this->messagetype);
 }
Пример #10
0
 /**
  * Gets data about which address fields should be visible and validable on a form
  *
  * @params $address_type	Address type
  *
  * @return 2-dimensional associative array with data
  */
 public static function getAddressElementsData($address_type)
 {
     $config = Tienda::getInstance();
     $address_fields = array('address_name', 'title', 'name', 'middle', 'last', 'address1', 'address2', 'country', 'city', 'zip', 'zone', 'phone', 'company', 'tax_number');
     $elements = array();
     for ($i = 0, $c = count($address_fields); $i < $c; $i++) {
         $f = $address_fields[$i];
         $show = $config->get('show_field_' . $f, '3');
         $valid = $config->get('validate_field_' . $f, '3');
         $elements[$f] = array($show == '3' || $show == $address_type, $valid == '3' || $valid == $address_type);
     }
     return $elements;
 }
Пример #11
0
 /**
  * Checks the extension is installed
  * 
  * @return boolean
  */
 function _isInstalled()
 {
     $success = false;
     jimport('joomla.filesystem.file');
     if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_tienda/defines.php')) {
         $success = true;
         if (!class_exists('Tienda')) {
             JLoader::register("Tienda", JPATH_ADMINISTRATOR . "/components/com_tienda/defines.php");
         }
         $this->defines = Tienda::getInstance();
         Tienda::load('TiendaHelperProduct', 'helpers.product');
     }
     return $success;
 }
Пример #12
0
 /**
  * Sets the modules params as a property of the object
  * @param unknown_type $params
  * @return unknown_type
  */
 function __construct($params)
 {
     $this->params = $params;
     if (!class_exists('Tienda')) {
         JLoader::register("Tienda", JPATH_ADMINISTRATOR . "/components/com_tienda/defines.php");
     }
     // load the config class
     Tienda::load('Tienda', 'defines');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
     $this->defines = Tienda::getInstance();
     Tienda::load("TiendaHelperRoute", 'helpers.route');
     $this->router = new TiendaHelperRoute();
     $this->user = JFactory::getUser();
 }
Пример #13
0
 /**
  * Checks params and lastchecked to see if function should run again today
  *
  * @return unknown_type
  */
 function canRun()
 {
     $success = false;
     // Use config to store & retrieve lastchecked from the __config table
     $config = Tienda::getInstance();
     $lastchecked = $config->get('subscriptions_last_checked');
     $date = JFactory::getDate();
     $today = $date->toFormat("%Y-%m-%d 00:00:00");
     if ($lastchecked < $today) {
         if (JFactory::getApplication()->isAdmin() && !empty(JFactory::getUser()->id)) {
             JError::raiseNotice('plgSystemTienda_Subscriptions::canRun', sprintf(JText::_('COM_TIENDA_TIENDA_MSG_SENDING_SUBSCRIPTION_EMAIL_NOTICES'), $lastchecked, $today));
         }
         $success = true;
     }
     return $success;
 }
Пример #14
0
 /**
  * Method to check if we can still add a product to compare 
  * @return boolean
  */
 public function checkLimit()
 {
     $canAdd = true;
     $model = JModel::getInstance('ProductCompare', 'TiendaModel');
     $user = JFactory::getUser();
     $model->setState('filter_user', $user->id);
     if (empty($user->id)) {
         $session = JFactory::getSession();
         $model->setState('filter_session', $session->getId());
     }
     $total = $model->getTotal();
     $limit = Tienda::getInstance()->get('compared_products', '5');
     if ($total >= $limit) {
         $canAdd = false;
     }
     return $canAdd;
 }
Пример #15
0
 /**
  * Checks the entry to maintain DB integrity
  * @return unknown_type
  */
 function check()
 {
     $config = Tienda::getInstance();
     if (!$this->addresstype_id) {
         $this->addresstype_id = '1';
     }
     $address_type = $this->addresstype_id;
     if (empty($this->user_id)) {
         $this->user_id = JFactory::getUser()->id;
         if (empty($this->user_id)) {
             $this->setError(JText::_('COM_TIENDA_USER_REQUIRED'));
         }
     }
     Tienda::load('TiendaHelperAddresses', 'helpers.addresses');
     $elements = TiendaHelperAddresses::getAddressElementsData($address_type);
     if (empty($this->address_name)) {
         $this->address_name = $this->address_1;
     }
     if (empty($this->address_name) && $elements['address_name'][1]) {
         $this->setError(JText::_("COM_TIENDA_PLEASE_INCLUDE_AN_ADDRESS_TITLE" . $address_type));
     }
     $address_checks = array(array('first_name', 'name', "COM_TIENDA_FIRST_NAME_REQUIRED"), array('middle_name', 'middle', "COM_TIENDA_MIDDLE_NAME_REQUIRED"), array('last_name', 'last', "COM_TIENDA_LAST_NAME_REQUIRED"), array('address_1', 'address1', "COM_TIENDA_AT_LEAST_ONE_ADDRESS_LINE_IS_REQUIRED"), array('address_2', 'address2', "COM_TIENDA_SECOND_ADDRESS_LINE_IS_REQUIRED"), array('company', 'company', "COM_TIENDA_COMPANY_REQUIRED"), array('tax_number', 'tax_number', "COM_TIENDA_COMPANY_TAX_NUMBER_REQUIRED"), array('city', 'city', "COM_TIENDA_CITY_REQUIRED"), array('postal_code', 'zip', "COM_TIENDA_POSTAL_CODE_REQUIRED"), array('phone_1', 'phone', "COM_TIENDA_PHONE_REQUIRED"));
     for ($i = 0, $c = count($address_checks); $i < $c; $i++) {
         $current = $address_checks[$i];
         if (empty($this->{$current}[0]) && $elements[$current[1]][1]) {
             $this->setError(JText::_($current[2]));
         }
     }
     if (empty($this->country_id)) {
         if ($elements['country'][1]) {
             $this->setError(JText::_('COM_TIENDA_COUNTRY_REQUIRED'));
         } else {
             $this->country_id = 9999;
         }
     }
     $countryA = explode(',', trim($config->get('ignored_countries', '83,188,190')));
     if (empty($this->zone_id) && !in_array($this->country_id, $countryA)) {
         if ($elements['zone'][1]) {
             $this->setError(JText::_('COM_TIENDA_ZONE_REQUIRED'));
         } else {
             $this->zone_id = 9999;
         }
     }
     return parent::check();
 }
Пример #16
0
 /**
  * _lastfive function.
  * 
  * @access private
  * @return void
  */
 function _orders()
 {
     jimport('joomla.application.component.model');
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
     $model = JModel::getInstance('Orders', 'TiendaModel');
     $model->setState('order', 'tbl.created_date');
     $model->setState('direction', 'DESC');
     $model->setState('limit', $this->_params->get('num_orders', '5'));
     $model->setState('limitstart', '0');
     $csv = Tienda::getInstance()->get('orderstates_csv', '2, 3, 5, 17');
     $array = explode(',', $csv);
     $this->_statesCSV = "'" . implode("','", $array) . "'";
     // set query for orderstate range
     $ordersQuery = $model->getQuery();
     $ordersQuery->where("tbl.order_state_id IN (" . $this->_statesCSV . ")");
     $model->setQuery($ordersQuery);
     $return = $model->getList();
     return $return;
 }
Пример #17
0
 /**
  * Protected! Use the getInstance
  */
 protected function TiendaHelperImage()
 {
     // Parent Helper Construction
     parent::__construct();
     $config = Tienda::getInstance();
     // Load default Parameters
     $this->product_img_height = $config->get('product_img_height');
     $this->product_img_width = $config->get('product_img_width');
     $this->category_img_height = $config->get('category_img_height');
     $this->category_img_width = $config->get('category_img_width');
     $this->manufacturer_img_width = $config->get('manufacturer_img_width');
     $this->manufacturer_img_height = $config->get('manufacturer_img_height');
     $this->product_img_path = Tienda::getPath('products_images');
     $this->category_img_path = Tienda::getPath('categories_images');
     $this->manufacturer_img_path = Tienda::getPath('manufacturers_images');
     $this->product_thumb_path = Tienda::getPath('products_thumbs');
     $this->category_thumb_path = Tienda::getPath('categories_thumbs');
     $this->manufacturer_thumb_path = Tienda::getPath('manufacturers_thumbs');
 }
Пример #18
0
 /**
  * Method to build the script to be appended to the body	
  * @param object $order - order object 
  * @return string
  */
 function _buildScript($order)
 {
     $storeName = Tienda::getInstance()->get('shop_name');
     $tax = $order->order_tax + $order->order_shipping_tax;
     $script = "";
     $script .= "var _gaq = _gaq || [];\r\n";
     $script .= "_gaq.push(['_setAccount', '{$this->webid}']);\r\n";
     $script .= "_gaq.push(['_trackPageview']);\r\n";
     $script .= "_gaq.push(['_addTrans',\r\n";
     $script .= "\t'{$order->order_id}',\r\n";
     $script .= "\t'{$storeName}',\r\n";
     $script .= "\t'{$order->order_total}',\r\n";
     $script .= "\t'{$tax}',\r\n";
     $script .= "\t'{$order->orderinfo->billing_city}',\r\n";
     $script .= "\t'{$order->orderinfo->billing_zone_name}',\r\n";
     $script .= "\t'{$order->orderinfo->billing_country_name}'\r\n";
     $script .= "]);\r\n\r\n\r\n";
     Tienda::load("TiendaHelperProduct", 'helpers.product');
     $items = $order->getItems();
     foreach ($items as $item) {
         $catName = "";
         //get category
         if ($this->inccategory) {
             $catName = $this->_getCategoryName($item->product_id);
         }
         $script .= "_gaq.push(['_addItem',\r\n";
         $script .= "\t'{$order->order_id}',\r\n";
         $script .= "\t'{$item->product_id}',\r\n";
         $script .= "\t'{$item->orderitem_name}',\r\n";
         $script .= "\t'{$catName}',\r\n";
         $script .= "\t'{$item->orderitem_final_price}',\r\n";
         $script .= "\t'{$item->orderitem_quantity}',\r\n";
         $script .= "]);\r\n";
     }
     $script .= "_gaq.push(['_trackTrans']);\r\n";
     $script .= "(function() {\r\n";
     $script .= "var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\r\n";
     $script .= "ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\r\n";
     $script .= "var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\r\n";
     $script .= "})();\r\n";
     return $script;
 }
Пример #19
0
 /**
  * Basic methods for a form
  * @param $tpl
  * @return unknown_type
  */
 function _form($tpl = '')
 {
     parent::_form($tpl);
     $shop_info = array();
     // Get the shop country name
     $countryModel = JModel::getInstance('Countries', 'TiendaModel');
     $countryModel->setId(Tienda::getInstance()->get('shop_country'));
     $countryItem = $countryModel->getItem();
     if ($countryItem) {
         $shop_info['shop_country_name'] = $countryItem->country_name;
     }
     // Get the shop zone name
     $zoneModel = JModel::getInstance('Zones', 'TiendaModel');
     $zoneModel->setId(Tienda::getInstance()->get('shop_zone'));
     $zoneItem = $zoneModel->getItem();
     if ($zoneItem) {
         $shop_info['shop_zone_name'] = $zoneItem->zone_name;
     }
     $this->assign('shop_info', (object) $shop_info);
 }
Пример #20
0
 /**
  * 
  * @return unknown_type
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $config = Tienda::getInstance();
     // adjust offset for when filter has changed
     if ($app->getUserState($ns . 'product_id') != $app->getUserStateFromRequest($ns . 'product_id', 'filter_product_id', '', '')) {
         $state['limitstart'] = '0';
     }
     $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'tbl.productdownload_startdate', 'cmd');
     $state['direction'] = $app->getUserStateFromRequest($ns . '.filter_direction', 'filter_direction', 'DESC', 'word');
     $state['filter_product_id'] = $app->getUserStateFromRequest($ns . 'product_id', 'filter_product_id', '', 'integer');
     $state['filter_user'] = JFactory::getUser()->id;
     $state['filter'] = $app->getUserStateFromRequest($ns . 'filter', 'filter', '', 'word');
     foreach (@$state as $key => $value) {
         $model->setState($key, $value);
     }
     return $state;
 }
Пример #21
0
 /**
  * Delete also the prices linked to this group
  */
 function delete($oid = null)
 {
     $k = $this->_tbl_key;
     $default_user_group = Tienda::getInstance()->get('default_user_group', '1');
     if ($oid) {
         $key = $oid;
     } else {
         $key = $this->{$k};
     }
     if ($key != $default_user_group) {
         $return = parent::delete($oid);
         if ($return) {
             // Delete user group relationships
             $model = JModel::getInstance('UserGroups', 'TiendaModel');
             $model->setState('filter_group', $this->{$k});
             $links = $model->getList();
             if ($links) {
                 $table = JTable::getInstance('UserGroups', 'TiendaTable');
                 foreach ($links as $link) {
                     $table->delete($link->user_id);
                 }
             }
             // Delete prices
             $model = JModel::getInstance('ProductPrices', 'TiendaModel');
             $model->setState('filter_user_group', $this->{$k});
             $prices = $model->getList();
             if ($prices) {
                 $table = JTable::getInstance('ProductPrices', 'TiendaTable');
                 foreach ($prices as $price) {
                     $table->delete($price->user_id);
                 }
             }
         }
     } else {
         $this->setError(JText::_('COM_TIENDA_COM_TIENDA_YOU_CANT_DELETE_THE_DEFAULT_USER_GROUP'));
         return false;
     }
     return $return;
 }
Пример #22
0
 function getCart()
 {
     Tienda::load('TiendaHelperCarts', 'helpers.carts');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     JModel::addIncludePath(JPATH_SITE . '/components/com_tienda/models');
     // determine whether we're working with a session or db cart
     $suffix = TiendaHelperCarts::getSuffix();
     $model = JModel::getInstance('Carts', 'TiendaModel');
     $session = JFactory::getSession();
     $user = JFactory::getUser();
     $model->setState('filter_user', $user->id);
     if (empty($user->id)) {
         $model->setState('filter_session', $session->getId());
     }
     $list = $model->getList(false, false);
     Tienda::load('Tienda', 'defines');
     $config = Tienda::getInstance();
     $show_tax = $config->get('display_prices_with_tax');
     $this->using_default_geozone = false;
     if ($show_tax) {
         Tienda::load('TiendaHelperUser', 'helpers.user');
         $geozones = TiendaHelperUser::getGeoZones(JFactory::getUser()->id);
         if (empty($geozones)) {
             // use the default
             $this->using_default_geozone = true;
             $table = JTable::getInstance('Geozones', 'TiendaTable');
             $table->load(array('geozone_id' => Tienda::getInstance()->get('default_tax_geozone')));
             $geozones = array($table);
         }
         Tienda::load("TiendaHelperProduct", 'helpers.product');
         foreach ($list as &$item) {
             $taxtotal = TiendaHelperProduct::getTaxTotal($item->product_id, $geozones);
             $item->product_price = $item->product_price + $taxtotal->tax_total;
             $item->taxtotal = $taxtotal;
         }
     }
     return $list;
 }
Пример #23
0
 protected function _buildQueryFields(&$query)
 {
     Tienda::load('TiendaHelperUser', 'helpers.user');
     $date = JFactory::getDate()->toMysql();
     $filter_product = $this->getState('filter_product');
     $user = TiendaHelperBase::getInstance('user');
     if (strlen($filter_product)) {
         $default_group = $user->getUserGroup(JFactory::getUser()->id, (int) $filter_product);
     } else {
         $default_group = Tienda::getInstance()->get('default_user_group', '1');
     }
     $fields = array();
     $fields[] = " p_from.product_name as product_name_from ";
     $fields[] = " p_from.product_sku as product_sku_from ";
     $fields[] = " p_from.product_model as product_model_from ";
     $fields[] = "\n            (\n            SELECT \n                prices.product_price\n            FROM\n                #__tienda_productprices AS prices \n            WHERE \n                prices.product_id = tbl.product_id_from \n                AND prices.group_id = '{$default_group}'\n                AND prices.product_price_startdate <= '{$date}' \n                AND (prices.product_price_enddate >= '{$date}' OR prices.product_price_enddate = '0000-00-00 00:00:00' )\n                ORDER BY prices.price_quantity_start ASC\n            LIMIT 1\n            ) \n        AS product_price_from ";
     $fields[] = " p_to.product_name as product_name_to ";
     $fields[] = " p_to.product_sku as product_sku_to ";
     $fields[] = " p_to.product_model as product_model_to ";
     $fields[] = "\n            (\n            SELECT \n                prices.product_price\n            FROM\n                #__tienda_productprices AS prices \n            WHERE \n                prices.product_id = tbl.product_id_to \n                AND prices.group_id = '{$default_group}'\n                AND prices.product_price_startdate <= '{$date}' \n                AND (prices.product_price_enddate >= '{$date}' OR prices.product_price_enddate = '0000-00-00 00:00:00' )\n                ORDER BY prices.price_quantity_start ASC\n            LIMIT 1\n            ) \n        AS product_price_to ";
     $query->select($this->getState('select', 'tbl.*'));
     $query->select($fields);
 }
Пример #24
0
 /**
  * Prepares the payment form
  * and returns HTML Form to be displayed to the user
  * generally will have a message saying, 'confirm entries, then click complete order'
  * 
  * Submit button target for onsite payments & return URL for offsite payments should be:
  * index.php?option=com_tienda&view=checkout&task=confirmPayment&orderpayment_type=xxxxxx
  * where xxxxxxx = $_element = the plugin's filename 
  *  
  * @param $data     array       form post data
  * @return string   HTML to display
  */
 function _prePayment($data)
 {
     $opc = Tienda::getInstance()->get('one_page_checkout', 1);
     $user = JFactory::getUser();
     $vars = new JObject();
     $vars->mode = $this->params->get('sandbox') ? 'TEST' : '';
     $creds = array();
     $creds['pswd'] = $this->_getParam('api_password');
     $creds['partner'] = $this->_getParam('api_partner');
     $creds['merchant'] = $this->_getParam('api_merchant');
     // set paypal pro checkout type
     $order = JTable::getInstance('Orders', 'TiendaTable');
     JFactory::getSession()->set('tienda.order.id', $data['order_id']);
     $order->load($data['order_id']);
     $creds['user'] = $this->_getParam('api_username');
     $urls = array();
     $urls['return'] = JRoute::_(JURI::root() . "index.php?option=com_tienda&view=checkout&task=confirmPayment&orderpayment_type=" . $this->_element . "&paction=process&tmpl=component");
     $urls['cancel'] = JRoute::_(JURI::root() . "index.php?option=com_tienda&view=checkout&task=confirmPayment&orderpayment_type=" . $this->_element . "&paction=cancel&tmpl=component");
     $urls['error'] = JRoute::_(JURI::root() . "index.php?option=com_tienda&view=checkout&task=confirmPayment&orderpayment_type=" . $this->_element . "&paction=display_message&tmpl=component");
     $vars->security = $this->_getSecureToken($creds, $data['order_id'], $data['orderpayment_amount'], $data['orderinfo'], $urls);
     $session = JFactory::getSession();
     if (!isset($vars->security['SECURETOKENID'])) {
         // paypal couldnt generate the security data so store nonsense data that cant ever be generated
         $vars->security['SECURETOKENID'] = plgTiendaPayment_paypalpro::NO_SECURE_DATA;
     }
     $session->set('paypal_pro.security.id', $vars->security['SECURETOKENID']);
     if (!isset($vars->security['SECURETOKEN'])) {
         // paypal couldnt generate the security data so store nonsense data that cant ever be generated
         $vars->security['SECURETOKEN'] = plgTiendaPayment_paypalpro::NO_SECURE_DATA;
     }
     $session->set('paypal_pro.security.token', $vars->security['SECURETOKEN']);
     $session->set('paypal_pro.orderpayment.id', $data['orderpayment_id']);
     $vars->is_recurring = $order->isRecurring();
     $html = $this->_getLayout('prepayment', $vars);
     return $html;
 }
Пример #25
0
?>
            </tfoot>
        </table>
        <table class="adminlist" style="clear: both;">
                <tr>
                    <td colspan="2" style="white-space: nowrap;">
                        <b><?php 
echo JText::_('COM_TIENDA_TAX_AND_SHIPPING_TOTALS');
?>
</b>
                        <br/>
                    </td>
                    <td colspan="2" style="text-align: right;">
                    <?php 
$display_shipping_tax = Tienda::getInstance()->get('display_shipping_tax', '1');
$display_tax_checkout = Tienda::getInstance()->get('show_tax_checkout', '1');
switch ($display_tax_checkout) {
    case 1:
        // Tax Rates in Separate Lines
        $taxes = $order->getTaxRates();
        foreach ($taxes as $taxrate) {
            $tax_desc = $taxrate->tax_rate_description ? $taxrate->tax_rate_description : 'Tax';
            $amount = $taxrate->applied_tax;
            if ($amount) {
                echo JText::_($tax_desc) . ":<br />";
            }
        }
        break;
    case 2:
        // Tax Classes in Separate Lines
        $taxes = $order->getTaxClasses();
Пример #26
0
 /**
  * Calculate taxes on list of products
  *
  * @param $products						Array of products
  * @param $source						Source of tax calculation (final_price '1', product_price '2', orderitem_price '3')
  * @param $billing_address		Actual customer's billing address
  * @param $shipping_address		Actual customer's shipping address
  * @param $tax_type						for the future use
  *
  * @return Associative array with indexes product_id of products with arrays with list of their tax rates (names and rates)
  */
 public static function calculateTax($products, $source = 1, $billing_address = null, $shipping_address = null, $tax_type = null)
 {
     $result = new stdClass();
     $result->tax_total = 0.0;
     $result->tax_rate_rates = array();
     $result->tax_class_rates = array();
     $result->product_taxes = array();
     if (!is_array($products)) {
         return $result;
     }
     Tienda::load('TiendaHelperShipping', 'helpers.shipping');
     Tienda::load('TiendaQuery', 'library.query');
     Tienda::load('TiendaTools', 'library.tools');
     if ($billing_address) {
         $billing_zones = TiendaHelperShipping::getGeoZones($billing_address->zone_id, '1', $billing_address->postal_code);
     } else {
         $billing_zones = array();
     }
     if (!empty($billing_zones)) {
         foreach ($billing_zones as $key => $value) {
             $billing_zones[$key] = $value->geozone_id;
         }
     }
     //load the default geozones when user is logged out and the config is to show tax
     if (empty($billing_zones)) {
         $geozones = TiendaHelperUser::getGeoZones(JFactory::getUser()->id);
         if (empty($geozones)) {
             // use the default
             $billing_zones = array(Tienda::getInstance()->get('default_tax_geozone'));
         } else {
             foreach ($geozones as $key => $value) {
                 $billing_zones[$key] = $value->geozone_id;
             }
         }
     }
     return TiendaHelperTax::calculateGeozonesTax($products, $source, $billing_zones);
 }
Пример #27
0
<?php

defined('_JEXEC') or die('Restricted access');
JHTML::_('script', 'tienda.js', 'media/com_tienda/js/');
$items = @$this->items;
$show_manufacturer = Tienda::getInstance()->get('show_manufacturer_productcompare', '1');
$show_srp = Tienda::getInstance()->get('show_srp_productcompare', '1');
$show_addtocart = Tienda::getInstance()->get('show_addtocart_productcompare', '1');
$show_rating = Tienda::getInstance()->get('show_rating_productcompare', '1');
$show_model = Tienda::getInstance()->get('show_model_productcompare', '1');
$show_sku = Tienda::getInstance()->get('show_sku_productcompare', '1');
?>
<a name="tienda-compare"></a>
<h1><?php 
echo JText::_('COM_TIENDA_COMPARE');
?>
</h1>
<?php 
if (count($items)) {
    ?>
<div id="tiendaProductCompareScroll">
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tbody>
			<tr class="row0">
				<td valign="middle" class="first-cell center">
					<?php 
    echo JText::_('COM_TIENDA_COMPARE');
    ?>
				</td>
					<?php 
    foreach ($items as $item) {
Пример #28
0
 /**
  * Batch resize of thumbs
  * @author Skullbock
  */
 function recreateThumbs()
 {
     $per_step = 100;
     $from_id = JRequest::getInt('from_id', 0);
     $to = $from_id + $per_step;
     Tienda::load('TiendaHelperCategory', 'helpers.category');
     Tienda::load('TiendaImage', 'library.image');
     $width = Tienda::getInstance()->get('category_img_width', '0');
     $height = Tienda::getInstance()->get('category_img_height', '0');
     $model = $this->getModel('Categories', 'TiendaModel');
     $model->setState('limistart', $from_id);
     $model->setState('limit', $to);
     $row = $model->getTable();
     $count = $model->getTotal();
     $categories = $model->getList();
     $i = 0;
     $last_id = $from_id;
     foreach ($categories as $p) {
         $i++;
         $image = $p->category_full_image;
         $path = Tienda::getPath('categories_images');
         if ($image != '') {
             $img = new TiendaImage($path . '/' . $image);
             $img->setDirectory(Tienda::getPath('categories_images'));
             // Thumb
             Tienda::load('TiendaHelperImage', 'helpers.image');
             $imgHelper = TiendaHelperBase::getInstance('Image', 'TiendaHelper');
             $imgHelper->resizeImage($img, 'category');
         }
         $last_id = $p->category_id;
     }
     if ($i < $count) {
         $redirect = "index.php?option=com_tienda&controller=categories&task=recreateThumbs&from_id=" . ($last_id + 1);
     } else {
         $redirect = "index.php?option=com_tienda&view=config";
     }
     $redirect = JRoute::_($redirect, false);
     $this->setRedirect($redirect, JText::_('COM_TIENDA_DONE'), 'notice');
     return;
 }
Пример #29
0
 function sendNotification($msg, $user_id)
 {
     $config = Tienda::getInstance();
     $mainframe = JFactory::getApplication();
     $mailfrom = $config->get('shop_email', '');
     if (!strlen($mailfrom)) {
         $mailfrom = $mainframe->getCfg('mailfrom');
     }
     $fromname = $config->get('shop_email_from_name', '');
     if (!strlen($fromname)) {
         $fromname = $mainframe->getCfg('fromname');
     }
     $toemail = $this->params->get('person_email', '');
     if (!strlen($toemail)) {
         return;
     }
     $mailer = JFactory::getMailer();
     $mailer->addRecipient($toemail);
     $mailer->setSubject(sprintf($this->params->get('email_subject'), $user_id));
     $mailer->setBody(htmlspecialchars_decode($msg) . ' - ' . JText::_('COM_TIENDA_USER') . '=' . $user_id);
     $sender = array($from, $fromname);
     $mailer->setSender($sender);
     $mailer->send();
 }
Пример #30
0
        ?>
								<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
								<fb:like show_faces="false" width="375"></fb:like> 
							<?php 
    }
    if ($display_tw) {
        ?>
								<a href="http://twitter.com/share" class="twitter-share-button" data-text="<?php 
        echo Tienda::getInstance()->get('display_tweet_message', 'Check this out!') . ' ' . TiendaHelperProduct::getSocialBookMarkUri();
        ?>
" data-count="horizontal">Tweet</a>
								<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
							<?php 
    }
    if ($display_gp) {
        $google_plus1_size = Tienda::getInstance()->get('display_google_plus1_size', 'medium');
        ?>
								<g:plusone <?php 
        if (strlen($google_plus1_size)) {
            echo 'size="' . $google_plus1_size . '"';
        }
        ?>
></g:plusone>
								<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
							<?php 
    }
    if ($display_fb || $display_gp || $display_tw) {
        ?>
							</div>
							<?php 
    }