Ejemplo n.º 1
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()->toSql();
     $default_group = Citruscart::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#__citruscart_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);
 }
Ejemplo n.º 2
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_from_expires'] = $app->getUserStateFromRequest($ns . 'date_from_expires', 'filter_date_from_expires', '', '');
     $state['filter_date_to_expires'] = $app->getUserStateFromRequest($ns . 'date_to_expires', 'filter_date_to_expires', '', '');
     $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 (Citruscart::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;
 }
Ejemplo n.º 3
0
 /**
  *
  * @return void
  **/
 function _default($tpl = null)
 {
     Citruscart::load('CitruscartSelect', 'library.select');
     Citruscart::load('CitruscartGrid', 'library.grid');
     Citruscart::load('CitruscartTools', 'library.tools');
     /* Get the application */
     $app = JFactory::getApplication();
     // check config
     $row = Citruscart::getInstance();
     $this->assign('row', $row);
     // add toolbar buttons
     JToolBarHelper::apply('save');
     JToolBarHelper::cancel('close', 'COM_CITRUSCART_CLOSE');
     // plugins
     $filtered = array();
     $items = CitruscartTools::getPlugins();
     for ($i = 0; $i < count($items); $i++) {
         $item = $items[$i];
         // Check if they have an event
         if ($hasEvent = CitruscartTools::hasEvent($item, 'onListConfigCitruscart')) {
             // 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 = JSession::getFormToken();
     $validate = JSession::getFormToken();
     $form = array();
     $view = strtolower($app->input->get('view'));
     //$view = strtolower( JRequest::getVar('view') );
     $form['action'] = "index.php?option=com_citruscart&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_CITRUSCART_REQUIRED');
     $required->image = "<img src='" . JURI::root() . "/media/citruscart/images/required_16.png' alt='{$required->text}'>";
     $this->assign('required', $required);
     // Elements
     $elementArticleModel = JModelLegacy::getInstance('ElementArticle', 'CitruscartModel');
     $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);
 }
Ejemplo n.º 4
0
 /**
  * Set the CSV of states to be reported on
  * @param $csv
  * @return unknown_type
  */
 function setStatesCSV($csv = '')
 {
     if (empty($csv)) {
         $csv = Citruscart::getInstance()->get('orderstates_csv', '2, 3, 5, 17');
     }
     $array = explode(',', $csv);
     $this->_statesCSV = "'" . implode("','", $array) . "'";
 }
Ejemplo n.º 5
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->defines = Citruscart::getInstance();
     if (JDEBUG) {
         $this->cache_enabled = false;
     }
 }
Ejemplo n.º 6
0
 function __construct($config = array())
 {
     parent::__construct($config);
     $this->defines = Citruscart::getInstance();
     Citruscart::load("CitruscartHelperRoute", 'helpers.route');
     $this->router = new CitruscartHelperRoute();
     $this->user = JFactory::getUser();
 }
Ejemplo n.º 7
0
 /**
  * save a record
  * @return void
  */
 function save()
 {
     $app = JFactory::getApplication();
     $error = false;
     $errorMsg = "";
     $model = $this->getModel($this->get('suffix'));
     $config = Citruscart::getInstance();
     $properties = $config->getProperties();
     foreach ($properties as $key => $value) {
         unset($row);
         $row = $model->getTable('config');
         $newvalue = $app->input->getHtml($key);
         $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_CITRUSCART_COULD_NOT_STORE') . " {$key} :: " . $row->getError() . " - ";
             }
         }
     }
     $model->clearCache();
     if (!$error) {
         $this->messagetype = 'message';
         $this->message = JText::_('COM_CITRUSCART_SAVED');
         JFactory::getApplication()->triggerEvent('onAfterSave' . $this->get('suffix'), array($row));
     } else {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_CITRUSCART_SAVE_FAILED') . " - " . $errorMsg;
     }
     $redirect = "index.php?option=com_citruscart&view=" . $this->get('suffix');
     $group = $app->input->get('group');
     switch ($group) {
         default:
             if ($group) {
                 $redirect .= "&task=" . $group;
             }
             break;
     }
     //$format = JRequest::getVar('format');
     $format = $app->input->get('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);
 }
Ejemplo n.º 8
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 = Citruscart::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;
 }
Ejemplo n.º 9
0
 /**
  * Checks the extension is installed
  *
  * @return boolean
  */
 function _isInstalled()
 {
     $success = false;
     jimport('joomla.filesystem.file');
     if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_citruscart/defines.php')) {
         $success = true;
         if (!class_exists('Citruscart')) {
             JLoader::register("Citruscart", JPATH_ADMINISTRATOR . "/components/com_citruscart/defines.php");
         }
         $this->defines = Citruscart::getInstance();
         Citruscart::load('CitruscartHelperProduct', 'helpers.product');
     }
     return $success;
 }
Ejemplo n.º 10
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('Citruscart')) {
         JLoader::register("Citruscart", JPATH_ADMINISTRATOR . "/components/com_citruscart/defines.php");
     }
     // load the config class
     Citruscart::load('Citruscart', 'defines');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
     $this->defines = Citruscart::getInstance();
     Citruscart::load("CitruscartHelperRoute", 'helpers.route');
     $this->router = new CitruscartHelperRoute();
     $this->user = JFactory::getUser();
 }
 /**
  * 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 = Citruscart::getInstance();
     $lastchecked = $config->get('subscriptions_last_checked');
     $date = JFactory::getDate();
     $today = $date->format("%Y-%m-%d 00:00:00");
     if ($lastchecked < $today) {
         if (JFactory::getApplication()->isAdmin() && !empty(JFactory::getUser()->id)) {
             JError::raiseNotice('plgSystemCitruscart_Subscriptions::canRun', sprintf(JText::_('COM_CITRUSCART_CITRUSCART_MSG_SENDING_SUBSCRIPTION_EMAIL_NOTICES'), $lastchecked, $today));
         }
         $success = true;
     }
     return $success;
 }
Ejemplo n.º 12
0
 /**
  * Method to check if we can still add a product to compare 
  * @return boolean
  */
 public function checkLimit()
 {
     $canAdd = true;
     $model = JModelLegacy::getInstance('ProductCompare', 'CitruscartModel');
     $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 = Citruscart::getInstance()->get('compared_products', '5');
     if ($total >= $limit) {
         $canAdd = false;
     }
     return $canAdd;
 }
Ejemplo n.º 13
0
 /**
  * Checks the entry to maintain DB integrity
  * @return unknown_type
  */
 function check()
 {
     $config = Citruscart::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_CITRUSCART_USER_REQUIRED'));
         }
     }
     Citruscart::load('CitruscartHelperAddresses', 'helpers.addresses');
     $elements = CitruscartHelperAddresses::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_CITRUSCART_PLEASE_INCLUDE_AN_ADDRESS_TITLE" . $address_type));
     }
     $address_checks = array(array('first_name', 'name', "COM_CITRUSCART_FIRST_NAME_REQUIRED"), array('middle_name', 'middle', "COM_CITRUSCART_MIDDLE_NAME_REQUIRED"), array('last_name', 'last', "COM_CITRUSCART_LAST_NAME_REQUIRED"), array('address_1', 'address1', "COM_CITRUSCART_AT_LEAST_ONE_ADDRESS_LINE_IS_REQUIRED"), array('address_2', 'address2', "COM_CITRUSCART_SECOND_ADDRESS_LINE_IS_REQUIRED"), array('company', 'company', "COM_CITRUSCART_COMPANY_REQUIRED"), array('tax_number', 'tax_number', "COM_CITRUSCART_COMPANY_TAX_NUMBER_REQUIRED"), array('city', 'city', "COM_CITRUSCART_CITY_REQUIRED"), array('postal_code', 'zip', "COM_CITRUSCART_POSTAL_CODE_REQUIRED"), array('phone_1', 'phone', "COM_CITRUSCART_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_CITRUSCART_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 (isset($elements['zone'][1])) {
             $this->setError(JText::_('COM_CITRUSCART_ZONE_REQUIRED'));
         } else {
             $this->zone_id = 9999;
         }
     }
     return parent::check();
 }
Ejemplo n.º 14
0
 /**
  * Protected! Use the getInstance
  */
 protected function CitruscartHelperImage()
 {
     // Parent Helper Construction
     parent::__construct();
     $config = Citruscart::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 = Citruscart::getPath('products_images');
     $this->category_img_path = Citruscart::getPath('categories_images');
     $this->manufacturer_img_path = Citruscart::getPath('manufacturers_images');
     $this->product_thumb_path = Citruscart::getPath('products_thumbs');
     $this->category_thumb_path = Citruscart::getPath('categories_thumbs');
     $this->manufacturer_thumb_path = Citruscart::getPath('manufacturers_thumbs');
 }
Ejemplo n.º 15
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 = JModelLegacy::getInstance('Countries', 'CitruscartModel');
     $countryModel->setId(Citruscart::getInstance()->get('shop_country'));
     $countryItem = $countryModel->getItem();
     if ($countryItem) {
         $shop_info['shop_country_name'] = $countryItem->country_name;
     }
     // Get the shop zone name
     $zoneModel = JModelLegacy::getInstance('Zones', 'CitruscartModel');
     $zoneModel->setId(Citruscart::getInstance()->get('shop_zone'));
     $zoneItem = $zoneModel->getItem();
     if ($zoneItem) {
         $shop_info['shop_zone_name'] = $zoneItem->zone_name;
     }
     $this->assign('shop_info', (object) $shop_info);
 }
Ejemplo n.º 16
0
 /**
  * _lastfive function.
  *
  * @access private
  * @return void
  */
 function _orders()
 {
     jimport('joomla.application.component.model');
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
     $model = JModelLegacy::getInstance('Orders', 'CitruscartModel');
     $model->setState('order', 'tbl.created_date');
     $model->setState('direction', 'DESC');
     $model->setState('limit', $this->_params->get('num_orders', '5'));
     $model->setState('limitstart', '0');
     $orders = $model->getList();
     $csv = Citruscart::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;
 }
Ejemplo n.º 17
0
 /**
  *
  * @return unknown_type
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $config = Citruscart::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;
 }
Ejemplo n.º 18
0
 /**
  * Delete also the prices linked to this group
  */
 function delete($oid = null)
 {
     $k = $this->_tbl_key;
     $default_user_group = Citruscart::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 = JModelLegacy::getInstance('UserGroups', 'CitruscartModel');
             $model->setState('filter_group', $this->{$k});
             $links = $model->getList();
             if ($links) {
                 $table = JTable::getInstance('UserGroups', 'CitruscartTable');
                 foreach ($links as $link) {
                     $table->delete($link->user_id);
                 }
             }
             // Delete prices
             $model = JModelLegacy::getInstance('ProductPrices', 'CitruscartModel');
             $model->setState('filter_user_group', $this->{$k});
             $prices = $model->getList();
             if ($prices) {
                 $table = JTable::getInstance('ProductPrices', 'CitruscartTable');
                 foreach ($prices as $price) {
                     $table->delete($price->user_id);
                 }
             }
         }
     } else {
         $this->setError(JText::_('COM_CITRUSCART_COM_CITRUSCART_YOU_CANT_DELETE_THE_DEFAULT_USER_GROUP'));
         return false;
     }
     return $return;
 }
Ejemplo n.º 19
0
 function getCart()
 {
     Citruscart::load('CitruscartHelperCarts', 'helpers.carts');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
     JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_citruscart/models');
     // determine whether we're working with a session or db cart
     $suffix = CitruscartHelperCarts::getSuffix();
     $model = JModelLegacy::getInstance('Carts', 'CitruscartModel');
     $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);
     Citruscart::load('Citruscart', 'defines');
     $config = Citruscart::getInstance();
     $show_tax = $config->get('display_prices_with_tax');
     $this->using_default_geozone = false;
     if ($show_tax) {
         Citruscart::load('CitruscartHelperUser', 'helpers.user');
         $geozones = CitruscartHelperUser::getGeoZones(JFactory::getUser()->id);
         if (empty($geozones)) {
             // use the default
             $this->using_default_geozone = true;
             $table = JTable::getInstance('Geozones', 'CitruscartTable');
             $table->load(array('geozone_id' => Citruscart::getInstance()->get('default_tax_geozone')));
             $geozones = array($table);
         }
         Citruscart::load("CitruscartHelperProduct", 'helpers.product');
         foreach ($list as &$item) {
             $taxtotal = CitruscartHelperProduct::getTaxTotal($item->product_id, $geozones);
             $item->product_price = $item->product_price + $taxtotal->tax_total;
             $item->taxtotal = $taxtotal;
         }
     }
     return $list;
 }
Ejemplo n.º 20
0
 protected function _buildQueryFields(&$query)
 {
     Citruscart::load('CitruscartHelperUser', 'helpers.user');
     $date = JFactory::getDate()->toSql();
     $filter_product = $this->getState('filter_product');
     $user = CitruscartHelperBase::getInstance('user');
     if (strlen($filter_product)) {
         $default_group = $user->getUserGroup(JFactory::getUser()->id, (int) $filter_product);
     } else {
         $default_group = Citruscart::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                #__citruscart_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                #__citruscart_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);
 }
Ejemplo n.º 21
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;
     }
     Citruscart::load('CitruscartHelperShipping', 'helpers.shipping');
     Citruscart::load('CitruscartQuery', 'library.query');
     Citruscart::load('CitruscartTools', 'library.tools');
     if ($billing_address) {
         $billing_zones = CitruscartHelperShipping::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 = CitruscartHelperUser::getGeoZones(JFactory::getUser()->id);
         if (empty($geozones)) {
             // use the default
             $billing_zones = array(Citruscart::getInstance()->get('default_tax_geozone'));
         } else {
             foreach ($geozones as $key => $value) {
                 $billing_zones[$key] = $value->geozone_id;
             }
         }
     }
     return CitruscartHelperTax::calculateGeozonesTax($products, $source, $billing_zones);
 }
Ejemplo n.º 22
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 Citruscart::getInstance()->get('display_tweet_message', 'Check this out!') . ' ' . CitruscartHelperProduct::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 = Citruscart::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 
    }
Ejemplo n.º 23
0
 /**
  *
  * Method to validate a user password via PHP
  * @param $pass								Password for validation
  * @param $force_validation		Can forces this method to validate the password, even thought PHP validation is turned off
  *
  * @return	Array with result of password validation (position 0) and list of requirements which the password does not fullfil (position 1)
  */
 function validatePassword($password, $force_validation = false)
 {
     $errors = array();
     $result = true;
     $defines = Citruscart::getInstance();
     $validate_php = $force_validation || $defines->get('password_php_validate', 0);
     if (!$validate_php) {
         return array($result, $errors);
     }
     $min_length = $defines->get('password_min_length', 5);
     $req_num = $defines->get('password_req_num', 1);
     $req_alpha = $defines->get('password_req_alpha', 1);
     $req_spec = $defines->get('password_req_spec', 1);
     if (strlen($password) < $min_length) {
         $result = false;
         $errors[] = JText::sprintf("COM_CITRUSCART_PASSWORD_MIN_LENGTH", $min_length);
     }
     if ($req_num && !preg_match('/[0-9]/', $password)) {
         $result = false;
         $errors[] = JText::_("COM_CITRUSCART_PASSWORD_REQ_NUMBER");
     }
     if ($req_alpha && !preg_match('/[a-zA-Z]/', $password)) {
         $result = false;
         $errors[] = JText::_("COM_CITRUSCART_PASSWORD_REQ_ALPHA");
     }
     if ($req_spec && !preg_match('/[\\/\\|_\\-\\+=\\."\':;\\[\\]~<>!@?#$%\\^&\\*()]/', $password)) {
         $result = false;
         $errors[] = JText::_("COM_CITRUSCART_PASSWORD_REQ_SPEC");
     }
     return array($result, $errors);
 }
Ejemplo n.º 24
0
 /**
  * Batch resize of thumbs
  * @author Skullbock
  */
 function recreateThumbs()
 {
     $app = JFactory::getApplication();
     $per_step = 100;
     $from_id = $app->input->getInt('from_id', 0);
     $to = $from_id + $per_step;
     Citruscart::load('CitruscartHelperManufacturer', 'helpers.manufacturer');
     Citruscart::load('CitruscartImage', 'library.image');
     $width = Citruscart::getInstance()->get('manufacturer_img_width', '0');
     $height = Citruscart::getInstance()->get('manufacturer_img_height', '0');
     $model = $this->getModel('Manufacturers', 'CitruscartModel');
     $model->setState('limistart', $from_id);
     $model->setState('limit', $to);
     $row = $model->getTable();
     $count = $model->getTotal();
     $manufacturers = $model->getList();
     $i = 0;
     $last_id = $from_id;
     foreach ($manufacturers as $p) {
         $i++;
         $image = $p->manufacturer_full_image;
         if ($image != '') {
             $img = new CitruscartImage($image, 'manufacturer');
             $img->setDirectory(Citruscart::getPath('manufacturers_images'));
             // Thumb
             Citruscart::load('CitruscartHelperImage', 'helpers.image');
             $imgHelper = CitruscartHelperBase::getInstance('Image', 'CitruscartHelper');
             $imgHelper->resizeImage($img, 'manufacturer');
         }
         $last_id = $p->manufacturer_id;
     }
     if ($i < $count) {
         $redirect = "index.php?option=com_citruscart&controller=manufacturers&task=recreateThumbs&from_id=" . ($last_id + 1);
     } else {
         $redirect = "index.php?option=com_citruscart&view=config";
     }
     $redirect = JRoute::_($redirect, false);
     $this->setRedirect($redirect, JText::_('COM_CITRUSCART_DONE'), 'notice');
     return;
 }
Ejemplo n.º 25
0
<?php

/*------------------------------------------------------------------------
# com_citruscart - citruscart
# ------------------------------------------------------------------------
# author    Citruscart Team - Citruscart http://www.citruscart.com
# copyright Copyright (C) 2014 - 2019 Citruscart.com All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://citruscart.com
# Technical Support:  Forum - http://citruscart.com/forum/index.html
-------------------------------------------------------------------------*/
defined('_JEXEC') or die('Restricted access');
JHtml::_('script', 'media/citruscart/js/citruscart.js', false, false);
$row = $this->row;
$config = Citruscart::getInstance();
?>

<table>
    <tbody>
    <?php 
if ($config->get('show_field_address_name', '3') != '0') {
    ?>
    <tr>
		<th style="width: 100px; text-align: right;" class="key">
            <?php 
    echo JText::_('COM_CITRUSCART_ADDRESS_TITLE');
    ?>
		</th>
		<td>
            <?php 
    echo JText::_('COM_CITRUSCART_ADDRESS_TITLE_FOR_YOUR_REFERENCE');
Ejemplo n.º 26
0
 /**
  * Generates hash from provided shipping values
  * @param $values Shipping values
  *
  * @return Hash as a string
  */
 public static function generateShippingHash($values)
 {
     static $sw = '';
     // using values shipping_type, shipping_price, shipping_name, shipping_code, shipping_tax, shipping_extra, shipping_tracking_id
     if ($sw == '') {
         $config = Citruscart::getInstance();
         $sw = $config->get('secret_word');
     }
     if (!isset($values['tracking_id'])) {
         $values['tracking_id'] = '';
     }
     $hash = $values['type'] . $values['price'] . $values['name'] . $values['code'] . $values['tax'] . $values['extra'] . $values['tracking_id'];
     return sha1($hash . $sw);
 }
Ejemplo n.º 27
0
                <td>
                    **********
                </td>
                <td>
                    <a href="<?php 
echo JRoute::_($this->url_profile);
?>
">
                        <?php 
echo JText::_('COM_CITRUSCART_EDIT');
?>
                    </a>
                </td>
            </tr>
            <?php 
if (Citruscart::getInstance()->get('display_subnum', 0)) {
    ?>
            <tr>
                <th style="width: 100px;">
                    <?php 
    echo JText::_('COM_CITRUSCART_SUB_NUM');
    ?>
                </th>
                <td colspan="2">
		            	<?php 
    Citruscart::load('CitruscartHelperSubscription', 'helpers.subscription');
    ?>
    	        		<?php 
    echo CitruscartHelperSubscription::displaySubNum($userinfo->sub_number);
    ?>
                </td>
Ejemplo n.º 28
0
					</a>
					<?php 
}
?>
				</div>

				<div id="citruscart_comments">
					<textarea id="customer_note" name="customer_note" rows="5" cols="41"></textarea>
				</div>
				</div>

				<div class="reset marginbot"></div>
				<div class="citruscart-expanded" id="shipping_terms-pane">
				 <?php 
if (Citruscart::getInstance()->get('require_terms', '1')) {
    $terms_article = Citruscart::getInstance()->get('article_terms');
    $terms_link = JRoute::_('index.php?option=com_content&view=article&id=' . $terms_article);
    ?>
	            	<div><?php 
    echo JText::_('COM_CITRUSCART_TERMS_AND_CONDITIONS');
    ?>
</div>
					<div id="shipping_terms" >
						<br/>
						<input type="checkbox" name="shipping_terms" value="1" /> <a href="<?php 
    echo $terms_link;
    ?>
" target="_blank"><?php 
    echo JText::_('COM_CITRUSCART_ACCEPT_TERMS_AND_CONDITIONS');
    ?>
</a>
Ejemplo n.º 29
0
        ?>
                            </a>
                        </span>
                        <br/>
                        <h6>
                        	<span id="product_price_<?php 
        echo $item->product_id;
        ?>
" class="product_price">
					    	<?php 
        echo CitruscartHelperProduct::dispayPriceWithTax($item->price, @$item->tax, @$this->show_tax);
        ?>
					    	 <!-- For UE States, we should let the admin choose to show (+19% vat) and (link to the shipping rates) -->
					    	<br />
					    	<?php 
        if (Citruscart::getInstance()->get('display_prices_with_shipping') && !empty($item->product_ships)) {
            ?>
					    	<?php 
            echo CitruscartUrl::popup(JRoute::_($this->shipping_cost_link . '&tmpl=component'), JText::_('COM_CITRUSCART_LINK_TO_SHIPPING_COST'));
            ?>
					    	<?php 
        }
        ?>
					   		 </span></h6>
               </li>
               <!-- manufacturers unorder list ends -->
            <?php 
    }
    ?>
        </div>
        <form action="<?php 
Ejemplo n.º 30
0
            <input type="hidden" name="filter_category" value="<?php 
    echo $vars->filter_category;
    ?>
" />
            <input type="hidden" id="task" name="task" value="" />
            <?php 
    echo JHTML::_('form.token');
    ?>

            <?php 
    $onclick = "citruscartFormValidation( '" . JRoute::_($vars->validation) . "', 'validationmessage_children', 'addchildrentocart', document.adminFormChildren );";
    ?>

            <?php 
    if (empty($item->product_check_inventory) || !empty($item->product_check_inventory) && empty($this->invalidQuantity)) {
        switch (Citruscart::getInstance()->get('cartbutton', 'image')) {
            case "button":
                ?>
                        <input onclick="<?php 
                echo $onclick;
                ?>
" value="<?php 
                echo JText::_('COM_CITRUSCART_ADD_TO_CART');
                ?>
" type="button" class="btn" />
                        <?php 
                break;
            case "image":
            default:
                ?>
                        <img class='addcart' src='<?php