Example #1
0
 /**
  * downloads a file
  *
  * @return void
  */
 function downloadFile()
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $productfile_id = $app->input->getInt('id', 0);
     //$productfile_id = intval( JRequest::getvar( 'id', '', 'request', 'int' ) );
     $product_id = $app->input->getInt('product_id', 0);
     $link = 'index.php?option=com_citruscart&view=products&task=edit&id=' . $product_id;
     Citruscart::load('CitruscartHelperBase', 'helpers._base');
     $helper = CitruscartHelperBase::getInstance('ProductDownload', 'CitruscartHelper');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_citruscart' . DS . 'tables');
     $productfile = JTable::getInstance('ProductFiles', 'CitruscartTable');
     $productfile->load($productfile_id);
     if (empty($productfile->productfile_id)) {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_CITRUSCART_INVALID FILE');
         $this->setRedirect($link, $this->message, $this->messagetype);
         return false;
     }
     // log and download
     Citruscart::load('CitruscartFile', 'library.file');
     // geting the ProductDownloadId to updated for which productdownload_max  is greater then 0
     $productToDownload = $helper->getProductDownloadInfo($productfile->productfile_id, $user->id);
     if ($downloadFile = CitruscartFile::download($productfile)) {
         $link = JRoute::_($link, false);
         $this->setRedirect($link);
     }
 }
 /**
  * Checks row for data integrity.
  * Assumes working dates have been converted to local time for display,
  * so will always convert working dates to GMT
  *
  * @return unknown_type
  */
 function check()
 {
     if (empty($this->product_id)) {
         $this->setError(JText::_('COM_CITRUSCART_PRODUCT_ASSOCIATION_REQUIRED'));
         return false;
     }
     $offset = JFactory::getConfig()->getValue('config.offset');
     if (isset($this->publishing_date)) {
         $this->publishing_date = date('Y-m-d H:i:s', strtotime(CitruscartHelperBase::getOffsetDate($this->publishing_date, -$offset)));
     }
     $nullDate = $this->_db->getNullDate();
     Citruscart::load('CitruscartHelperBase', 'helpers._base');
     if (empty($this->created_date) || $this->created_date == $nullDate) {
         $date = JFactory::getDate();
         $this->created_date = $date->toSql();
     }
     $date = JFactory::getDate();
     $this->modified_date = $date->toSql();
     $act = strtotime(Date('Y-m-d', strtotime($this->publishing_date)));
     $db = $this->_db;
     if (empty($this->product_issue_id)) {
         $q = 'SELECT `publishing_date` FROM `#__citruscart_productissues` WHERE `product_id`=' . $this->product_id . ' ORDER BY `publishing_date` DESC LIMIT 1';
         $db->setQuery($q);
         $next = $db->loadResult();
         if ($next === null) {
             return true;
         }
         $next = strtotime($next);
         if ($act <= $next) {
             $this->setError(JText::_('COM_CITRUSCART_PUBLISHING_DATE_IS_NOT_PRESERVING_ISSUE_ORDER') . ' - ' . $this->publishing_date);
             return false;
         }
     } else {
         $q = 'SELECT `publishing_date` FROM `#__citruscart_productissues` WHERE `product_issue_id`=' . $this->product_issue_id;
         $db->setQuery($q);
         $original = $db->loadResult();
         if ($act == strtotime(Date('Y-m-d', strtotime($original)))) {
             return true;
         }
         $q = 'SELECT `publishing_date` FROM `#__citruscart_productissues` WHERE `product_id`=' . $this->product_id . ' AND `publishing_date` < \'' . $original . '\' ORDER BY `publishing_date` DESC LIMIT 1';
         $db->setQuery($q);
         $prev = $db->loadResult();
         $q = 'SELECT `publishing_date` FROM `#__citruscart_productissues` WHERE `product_id`=' . $this->product_id . ' AND `publishing_date` > \'' . $original . '\' ORDER BY `publishing_date` ASC LIMIT 1';
         $db->setQuery($q);
         $next = $db->loadResult();
         if ($prev === null) {
             $prev = 0;
         } else {
             $prev = strtotime($prev);
         }
         if ($next) {
             $next = strtotime($next);
         }
         if ($prev >= $act || $next && $next <= $act) {
             $this->setError(JText::_('COM_CITRUSCART_PUBLISHING_DATE_IS_NOT_PRESERVING_ISSUE_ORDER') . ' - ' . $this->publishing_date);
             return false;
         }
     }
     return true;
 }
 /**
  * Run function after saving
  */
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     if ($return = parent::save($src, $orderingFilter, $ignore)) {
         Citruscart::load("CitruscartHelperProduct", 'helpers.product');
         $helper = CitruscartHelperBase::getInstance('product');
         $helper->doProductQuantitiesReconciliation($this->product_id, '0');
     }
     return $return;
 }
 /**
  * Checks row for data integrity.
  * Assumes working dates have been converted to local time for display,
  * so will always convert working dates to GMT
  *
  * @return unknown_type
  */
 function check()
 {
     if (empty($this->product_id)) {
         $this->setError(JText::_('COM_CITRUSCART_PRODUCT_ASSOCIATION_REQUIRED'));
         return false;
     }
     $nullDate = $this->_db->getNullDate();
     Citruscart::load('CitruscartHelperBase', 'helpers._base');
     $CitruscartHelperBase = new CitruscartHelperBase();
     $this->product_price_startdate = $this->product_price_startdate != $nullDate ? $CitruscartHelperBase->getOffsetDate($this->product_price_startdate) : $this->product_price_startdate;
     $this->product_price_enddate = $this->product_price_enddate != $nullDate ? $CitruscartHelperBase->getOffsetDate($this->product_price_enddate) : $this->product_price_enddate;
     if (empty($this->created_date) || $this->created_date == $nullDate) {
         $date = JFactory::getDate();
         $this->created_date = $date->toSql();
     }
     $date = JFactory::getDate();
     $this->modified_date = $date->toSql();
     return true;
 }
 /**
  * Method to get content article data for the frontpage
  *
  * @since 1.5
  */
 function getList()
 {
     $where = array();
     $mainframe = JFactory::getApplication();
     if (!empty($this->_list)) {
         return $this->_list;
     }
     // Initialize variables
     $db = $this->getDBO();
     $filter = null;
     // Get some variables from the request
     //		$sectionid			= JRequest::getVar( 'sectionid', -1, '', 'int' );
     //		$redirect			= $sectionid;
     //		$option				= JRequest::get( 'option' );
     $filter_order = $mainframe->getUserStateFromRequest('userelement.filter_order', 'filter_order', '', 'cmd');
     $filter_order_Dir = $mainframe->getUserStateFromRequest('userelement.filter_order_Dir', 'filter_order_Dir', '', 'word');
     $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
     $limitstart = $mainframe->getUserStateFromRequest('userelement.limitstart', 'limitstart', 0, 'int');
     $search = $mainframe->getUserStateFromRequest('userelement.search', 'search', '', 'string');
     $search = JString::strtolower($search);
     if (!$filter_order) {
         $filter_order = 'tbl.product_id';
     }
     $order = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir;
     $all = 1;
     // Keyword filter
     if ($search) {
         $where[] = 'LOWER( tbl.product_id ) LIKE ' . $db->q('%' . $db->escape($search, true) . '%', false);
         $where[] = 'LOWER( tbl.product_name ) LIKE ' . $db->q('%' . $db->escape($search, true) . '%', false);
     }
     // Build the where clause of the query
     $where = count($where) ? ' WHERE ' . implode(' OR ', $where) : '';
     // Get the total number of records
     $query = 'SELECT COUNT(tbl.product_id)' . ' FROM #__citruscart_products AS tbl' . $where;
     $db->setQuery($query);
     $total = $db->loadResult();
     // Create the pagination object
     jimport('joomla.html.pagination');
     $this->_page = new JPagination($total, $limitstart, $limit);
     // Get the products
     $query = 'SELECT tbl.*, pp.* ' . ' FROM #__citruscart_products AS tbl' . ' LEFT JOIN #__citruscart_productprices pp ON pp.product_id = tbl.product_id ' . $where . $order;
     $db->setQuery($query, $this->_page->limitstart, $this->_page->limit);
     $this->_list = $db->loadObjectList();
     //currency formatting
     Citruscart::load('CitruscartHelperBase', 'helpers._base');
     foreach ($this->_list as $item) {
         $item->product_price = CitruscartHelperBase::currency($item->product_price);
     }
     // If there is a db query error, throw a HTTP 500 and exit
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
         return false;
     }
     return $this->_list;
 }
 /**
  * Run function when saving
  * @see Citruscart/admin/tables/CitruscartTable#save()
  */
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     if ($return = parent::save($src, $orderingFilter, $ignore)) {
         $pa = JTable::getInstance('ProductAttributes', 'CitruscartTable');
         $pa->load($this->productattribute_id);
         Citruscart::load("CitruscartHelperProduct", 'helpers.product');
         $helper = CitruscartHelperBase::getInstance('product');
         $helper->doProductQuantitiesReconciliation($pa->product_id);
     }
     return $return;
 }
 /**
  * 
  * @param unknown_type $updateNulls
  * @return unknown_type
  */
 function store($updateNulls = false)
 {
     if ($return = parent::store($updateNulls)) {
         if ($this->notify_customer == '1') {
             Citruscart::load("CitruscartHelperBase", 'helpers._base');
             $helper = CitruscartHelperBase::getInstance('Email');
             $model = Citruscart::getClass("CitruscartModelSubscriptions", "models.subscriptions");
             $model->setId($this->subscription_id);
             $subscription = $model->getItem();
             $helper->sendEmailNotices($subscription, 'subscription');
         }
     }
     return $return;
 }
Example #8
0
 /**
  * 
  * @param unknown_type $updateNulls
  * @return unknown_type
  */
 function store($updateNulls = false)
 {
     if ($return = parent::store($updateNulls)) {
         if ($this->notify_customer == '1') {
             Citruscart::load("CitruscartHelperBase", 'helpers._base');
             $helper = CitruscartHelperBase::getInstance('Email');
             $model = Citruscart::getClass("CitruscartModelOrders", "models.orders");
             $model->setId($this->order_id);
             // this isn't necessary because you specify the requested PK id as a getItem() argument
             $order = $model->getItem($this->order_id, true);
             $helper->sendEmailNotices($order, 'order');
         }
     }
     return $return;
 }
Example #9
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');
 }
Example #10
0
 function display($cachable = false, $urlparams = false)
 {
     $uri = JURI::getInstance();
     $view = $this->getView($this->get('suffix'), JFactory::getDocument()->getType());
     $view->set('hidemenu', false);
     $view->set('_doTask', true);
     $view->setLayout('default');
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $url = "index.php?option=com_users&view=user&task=user.edit";
     } else {
         $url = "index.php?option=com_user&view=user&task=edit";
     }
     Citruscart::load("CitruscartHelperBase", 'helpers._base');
     $helper = CitruscartHelperBase::getInstance('Ambra');
     if ($helper->isInstalled()) {
         $url = "index.php?option=com_ambra&view=users&task=edit&return=" . base64_encode($uri->__toString());
     }
     $view->assign('url_profile', $url);
     parent::display($cachable, $urlparams);
 }
Example #11
0
 public function store($updateNulls = false)
 {
     // Check the table activation status first
     if (!$this->active) {
         // Activate it with a default value
         $this->setType('');
     }
     if ($this->getType() == 'datetime') {
         if (isset($this->eavvalue_value)) {
             $null_date = JFactory::getDbo()->getNullDate();
             if ($this->eavvalue_value == $null_date || $this->eavvalue_value == '') {
                 $this->eavvalue_value = $null_date;
             } else {
                 $offset = JFactory::getConfig()->getValue('config.offset');
                 $this->eavvalue_value = date('Y-m-d H:i:s', strtotime(CitruscartHelperBase::getOffsetDate($this->eavvalue_value, -$offset)));
             }
         }
     }
     return parent::store($updateNulls);
 }
 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);
 }
Example #13
0
        echo $item->shipping_address_2 ? $item->shipping_address_2 . ", " : "";
        echo $item->shipping_city . ", ";
        echo $item->shipping_zone_name . " ";
        echo $item->shipping_postal_code . " ";
        echo $item->shipping_country_name;
    }
    ?>
                    <?php 
    if (!empty($item->order_number)) {
        echo "<br/><b>" . JText::_('COM_CITRUSCART_ORDER_NUMBER') . "</b>: " . $item->order_number;
    }
    ?>
				</td>
				<td style="text-align: center;">
					<label class="label label-warning"><?php 
    echo CitruscartHelperBase::currency($item->order_total, $item->currency);
    ?>
</label>
                    <?php 
    if (!empty($item->commissions)) {
        ?>
                        <br/>
                        <?php 
        JHTML::_('behavior.tooltip');
        ?>
                        <a href="index.php?option=com_amigos&view=commissions&filter_orderid=<?php 
        echo $item->order_id;
        ?>
" target="_blank">
                            <img src='<?php 
        echo JURI::root(true);
        <div class='onDisplayProductAttributeOptions_wrapper'>
        <?php 
    echo $this->onDisplayProductAttributeOptions;
    ?>
        </div>
    <?php 
}
?>

    <?php 
echo JText::_('COM_CITRUSCART_QUANTITY');
?>
    <input type="text" name="quantity" value="1" size="10" />
    <br/>
    <?php 
echo JText::_('COM_CITRUSCART_BASE_PRICE');
?>
: <?php 
echo CitruscartHelperBase::currency($row->price);
?>
    <br/>

    <input type="submit" name="add_to_cart" value="<?php 
echo JText::_('COM_CITRUSCART_ADD_TO_ORDER');
?>
" class="btn btn-success" />
    <input type="hidden" name="task" id="task" value="addtocart" />
    <input type="hidden" name="product_id" value="<?php 
echo $row->product_id;
?>
" />
Example #15
0
                    <td colspan="2">
                        <input style="float: right;" type="submit" class="btn btn-success" value="<?php 
    echo JText::_('COM_CITRUSCART_UPDATE_QUANTITIES');
    ?>
" name="update" />
                    </td>
                </tr>
                <tr>
                    <td colspan="4" style="font-weight: bold;">
                        <?php 
    echo JText::_('COM_CITRUSCART_SUBTOTAL');
    ?>
                    </td>
                    <td style="text-align: right;">
                        <span id="totalAmountDue"><?php 
    echo CitruscartHelperBase::currency($subtotal);
    ?>
</span>
                    </td>
                </tr>
                <tr>
                	<td colspan="5" style="white-space: nowrap;">
                        <b><?php 
    echo JText::_('COM_CITRUSCART_TAX_AND_SHIPPING_TOTALS');
    ?>
</b>
                        <br/>
                        <?php 
    echo JText::_('COM_CITRUSCART_CALCULATED_DURING_CHECKOUT_PROCESS');
    ?>
              	 	</td>
Example #16
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');
/*Layout for displaying refreshed total amount.*/
JHTML::_('stylesheet', 'menu.css', 'media/citruscart/css/');
JHtml::_('script', 'media/citruscart/js/citruscart.js', false, false);
JHTML::_('script', 'joomla.javascript.js', 'includes/js/');
Citruscart::load('CitruscartGrid', 'library.grid');
$state = $this->state;
$order = $this->order;
$items = $this->orderitems;
echo CitruscartHelperBase::currency($items);
Example #17
0
                        <?php 
    Citruscart::load('CitruscartHelperShipping', 'helpers.shipping');
    ?>
                        <span style="float: right;">[<?php 
    echo CitruscartUrl::popup("index.php?option=com_citruscart&controller=shippingmethods&task=setrates&id=" . $item->shipping_method_id . "&tmpl=component", "Set Rates");
    ?>
]</span>
                        <?php 
    if ($shipping_method_type = CitruscartHelperShipping::getType($item->shipping_method_type)) {
        echo "<b>" . JText::_('COM_CITRUSCART_TYPE') . "</b>: " . $shipping_method_type->title;
    }
    if ($item->subtotal_minimum > '0') {
        echo "<br/><b>" . JText::_('COM_CITRUSCART_MINIMUM_ORDER_REQUIRED') . "</b>: " . CitruscartHelperBase::currency($item->subtotal_minimum);
    }
    if ($item->subtotal_maximum > '-1') {
        echo "<br/><b>" . JText::_('COM_CITRUSCART_SHIPPING_METHODS_SUBTOTAL_MAX') . "</b>: " . CitruscartHelperBase::currency($item->subtotal_maximum);
    }
    ?>
                    </div>
				</td>
				<td style="text-align: center;">
				    <?php 
    echo $item->tax_class_name;
    ?>
				</td>
				<td style="text-align: center;">
					<?php 
    echo CitruscartGrid::enable($item->shipping_method_enabled, $i, 'shipping_method_enabled.');
    ?>
				</td>
			</tr>
Example #18
0
 /**
  * Method to add translation strings to JS translation object
  *
  * @param $strings	Associative array with list of strings to translate
  *
  */
 public static function addJsTranslationStrings($strings)
 {
     if (self::$added_strings === null) {
         self::$added_strings = array();
     }
     JHTML::_('script', 'citruscart_lang.js', 'media/citruscart/js/');
     $js_strings = array();
     for ($i = 0, $c = count($strings); $i < $c; $i++) {
         if (in_array(strtoupper($strings[$i]), self::$added_strings) === false) {
             $js_strings[] = '"' . strtoupper($strings[$i]) . '":"' . JText::_($strings[$i]) . '"';
             self::$added_strings[] = strtoupper($strings[$i]);
         }
     }
     if (count($js_strings)) {
         $doc = JFactory::getDocument();
         $doc->addScriptDeclaration('Joomla.JText.load({' . implode(',', $js_strings) . '});');
     }
 }
Example #19
0
 /**
  * Checks that a password and password2 match
  * return unknown_type
  */
 function checkPassword2()
 {
     $input = JFactory::getApplication()->input;
     Citruscart::load('CitruscartHelperBase', 'helpers._base');
     $helper = CitruscartHelperBase::getInstance();
     $response = array();
     $response['msg'] = '';
     $response['error'] = '';
     // get elements from post
     $elements = json_decode(preg_replace('/[\\n\\r]+/', '\\n', $input->getString('elements')));
     // convert elements to array that can be binded
     $values = CitruscartHelperBase::elementsToArray($elements);
     $password = $values['password'];
     $password2 = $values['password2'];
     if (empty($password)) {
         $response['msg'] = $helper->validationMessage("COM_CITRUSCART_PASSWORD_CANNOT_BE_EMPTY", 'fail');
         $response['error'] = '1';
         echo json_encode($response);
         return;
     }
     if (empty($password2)) {
         $response['msg'] = $helper->validationMessage("COM_CITRUSCART_PASSWORD_VERIFY_CANNOT_BE_EMPTY", 'fail');
         $response['error'] = '1';
         echo json_encode($response);
         return;
     }
     $message = "";
     if ($password != $password2) {
         $message .= $helper->validationMessage('COM_CITRUSCART_PASSWORD_DO_NOT_MATCH', 'fail');
     } else {
         // no error
         $message .= $helper->validationMessage('COM_CITRUSCART_PASSWORD_VALID', 'success');
     }
     $response['msg'] = $message;
     $response['error'] = '1';
     echo json_encode($response);
     return;
 }
Example #20
0
 /**
  *
  * Get Avatar based on the installed community component
  * @param int $id - userid
  * @return object
  */
 function getAvatar($id)
 {
     $avatar = '';
     $found = false;
     Citruscart::load('CitruscartHelperAmbra', 'helpers.ambra');
     $helper_ambra = CitruscartHelperBase::getInstance('Ambra');
     //check if ambra installed
     if ($helper_ambra->isInstalled() && !$found) {
         if (!class_exists('Ambra')) {
             JLoader::register("Ambra", JPATH_ADMINISTRATOR . "/components/com_ambra/defines.php");
         }
         //Get Ambra Avatar
         if ($image = Ambra::getClass("AmbraHelperUser", 'helpers.user')->getAvatar($id)) {
             $link = JRoute::_(JURI::root() . 'index.php?option=com_ambra&view=users&id=' . $id, false);
             $avatar .= "<a href='{$link}' target='_blank'>";
             $avatar .= "<img src='{$image}' style='max-width:80px; border:1px solid #ccccce;' />";
             $avatar .= "</a>";
         }
         $found = true;
     }
     //check if jomsocial installed
     if (DSC::getApp()->isComponentInstalled('com_community') && !$found) {
         //Get JomSocial Avatar
         $database = JFactory::getDBO();
         $query = "\r\n\t\t\tSELECT\r\n\t\t\t\t*\r\n\t\t\tFROM\r\n\t\t\t\t#__community_users\r\n\t\t\tWHERE\r\n\t\t\t\t`userid` = '" . $id . "'\r\n\t\t\t";
         $database->setQuery($query);
         $result = $database->loadObject();
         if (isset($result->thumb)) {
             $image = JURI::root() . $result->thumb;
         }
         $link = JRoute::_(JURI::root() . 'index.php?option=com_community&view=profile&userid=' . $id, false);
         $avatar .= "<a href='{$link}' target='_blank'>";
         $avatar .= "<img src='{$image}' style='max-width:80px; border:1px solid #ccccce;' />";
         $avatar .= "</a>";
         $found = true;
     }
     //check if community builder is installed
     if (DSC::getApp()->isComponentInstalled('com_comprofiler') && !$found) {
         //Get JomSocial Avatar
         $database = JFactory::getDBO();
         $query = "\r\n\t\t\tSELECT\r\n\t\t\t\t*\r\n\t\t\tFROM\r\n\t\t\t\t#__comprofiler\r\n\t\t\tWHERE\r\n\t\t\t\t`id` = '" . $id . "'\r\n\t\t\t";
         $database->setQuery($query);
         $result = $database->loadObject();
         if (isset($result->avatar)) {
             $image = JURI::root() . 'images/comprofiler/' . $result->avatar;
         } else {
             $image = JRoute::_(JURI::root() . 'components/com_comprofiler/plugin/templates/default/images/avatar/nophoto_n.png');
         }
         $link = JRoute::_(JURI::root() . 'index.php?option=com_comprofiler&userid=' . $id, false);
         $avatar .= "<a href='{$link}' target='_blank'>";
         $avatar .= "<img src='{$image}' style='max-width:80px; border:1px solid #ccccce;' />";
         $avatar .= "</a>";
         $found = true;
     }
     return $avatar;
 }
Example #21
0
?>

    <?php 
if ($this->defines->get('display_credits', '0') && (double) $this->userinfo->credits_total > (double) '0.00') {
    ?>

        <fieldset id="opc-credit-form">
            <div id="opc-credit-validation"></div>

            <div id="credits_form">
                <label for="apply_credit_amount"><?php 
    echo JText::_('COM_CITRUSCART_STORE_CREDIT');
    ?>
</label>
                <div class="help-block"><?php 
    echo sprintf(JText::_('COM_CITRUSCART_YOU_HAVE_STORE_CREDIT'), CitruscartHelperBase::currency($this->userinfo->credits_total, $this->defines->get('default_currencyid', '1')));
    ?>
</div>
                <div class="input-append" id="opc-credit-input">
                    <input class="span2" type="text" id="apply_credit_amount" name="apply_credit_amount" />
                    <button id="opc-credit-button" class="btn" type="button"><?php 
    echo JText::_("COM_CITRUSCART_APPLY_CREDIT_TO_ORDER");
    ?>
</button>
                </div>

            </div>
            <div id='opc-credits'></div>
        </fieldset>

    <?php 
Example #22
0
 /**
  * Loads a row from the database and binds the fields to the object properties
  * If $load_eav is true, binds also the eav fields linked to this entity
  *
  * @access	public
  * @param	mixed	Optional primary key.  If not specifed, the value of current key is used
  * @param	bool	reset the object values?
  * @param	bool	load the eav values for this object
  *
  * @return	boolean	True if successful
  */
 function load($oid = null, $reset = true, $load_eav = true)
 {
     $eavs = array();
     /* Get the application */
     $app = JFactory::getApplication();
     $editable_by = $app->isAdmin() ? 1 : 2;
     if ($app->isAdmin()) {
         $view = $app->input->get('view', '');
         //$view = JRequest::get('view', '' );
         if ($view == 'pos') {
             // display all for POS
             $editable_by = array(1, 2);
         }
     }
     if (!is_array($oid)) {
         // load by primary key if not array
         $keyName = $this->getKeyName();
         $oid = array($keyName => $oid);
     }
     if (empty($oid)) {
         // if empty, use the value of the current key
         $keyName = $this->getKeyName();
         $oid = $this->{$keyName};
         if (empty($oid)) {
             // if still empty, fail
             $this->setError(JText::_('COM_CITRUSCART_CANNOT_LOAD_WITH_EMPTY_KEY'));
             return false;
         }
     }
     // allow $oid to be an array of key=>values to use when loading
     $oid = (array) $oid;
     $this->_linked_table_key = isset($this->_linked_table_key) ? $this->_linked_table_key : (isset($oid[$this->_linked_table_key_name]) ? $oid[$this->_linked_table_key_name] : '');
     if (!empty($reset)) {
         $this->reset();
     }
     $db = $this->getDBO();
     // initialize the query
     $query = new DSCQuery();
     $query->select('*');
     $query->from($this->getTableName());
     if ($load_eav) {
         Citruscart::load("CitruscartHelperBase", 'helpers._base');
         $eav_helper = CitruscartHelperBase::getInstance('Eav');
         $k = $this->_tbl_key;
         $id = $this->{$k};
         // Get the custom fields for this entities
         Citruscart::load('CitruscartHelperEav', 'helpers.eav');
         $eavs = CitruscartHelperEav::getAttributes($this->get('_suffix'), $id, true, $editable_by);
         // Is this a mirrored table (see decription at the beginning of this file)
         if (strlen($this->_linked_table) && $this->_linked_table_key) {
             // Copy the custom field value to this table
             $mirrored_eavs = $eav_helper->getAttributes($this->_linked_table, $this->_linked_table_key, true, $editable_by);
             $eavs = array_merge($eavs, $mirrored_eavs);
         }
     }
     foreach ($oid as $key => $value) {
         // Check that $key is field in table
         if (!in_array($key, array_keys($this->getProperties()))) {
             // Check if it is a eav field
             if ($load_eav) {
                 // loop through until the key is found or the eav are finished
                 $found = false;
                 $i = 0;
                 while (!$found && $i < count($eavs)) {
                     // Does the key exists?
                     if ($key == $eavs[$i]->eavattribute_alias) {
                         $found = true;
                     } else {
                         $i++;
                     }
                 }
                 // Was the key found?
                 if (!$found) {
                     // IF not return an error
                     $this->setError(get_class($this) . ' does not have the field ' . $key);
                     return false;
                 }
                 // key was found -> add this EAV field
                 $value_tbl_name = 'value_' . $eavs[$i]->eavattribute_alias;
                 // for some reason MySQL makes spaces around '-' charachter
                 // (which is often charachter in aliases) that's why we replace it with '_'
                 $value_tbl_name = str_replace("-", "_", $value_tbl_name);
                 // Join the table based on the type of the value
                 $table_type = $eav_helper->getType($eavs[$i]->eavattribute_alias);
                 // Join the tables
                 $query->join('LEFT', '#__citruscart_eavvalues' . $table_type . ' AS ' . $value_tbl_name . ' ON ( ' . $value_tbl_name . '.eavattribute_id = ' . $eavs[$i]->eavattribute_id . ' AND ' . $value_tbl_name . '.eaventity_id =  ' . $this->_tbl_key . ' )');
                 // Filter using '='
                 $query->where($value_tbl_name . ".eavvalue_value = '" . $value . "'");
                 // else let the store() method worry over this
             } else {
                 $this->setError(get_class($this) . ' does not have the field ' . $key);
                 return false;
             }
         } else {
             // add the key=>value pair to the query
             $value = $db->q($db->escape(trim(strtolower($value))));
             $query->where($key . ' = ' . $value);
         }
     }
     $db->setQuery((string) $query);
     if ($result = $db->loadAssoc()) {
         $result = $this->bind($result);
         if ($result) {
             // Only now load the eav, in necessary
             // Check if it is a eav field
             if ($load_eav) {
                 $k = $this->_tbl_key;
                 $id = $this->{$k};
                 // Get the custom fields for this entities
                 Citruscart::load('CitruscartHelperEav', 'helpers.eav');
                 $eavs = CitruscartHelperEav::getAttributes($this->get('_suffix'), $id, false, $editable_by);
                 // Is this a mirrored table (see decription at the beginning of this file)
                 if (strlen($this->_linked_table) && $this->_linked_table_key) {
                     // Copy the custom field value to this table
                     $mirrored_eavs = $eav_helper->getAttributes($this->_linked_table, $this->_linked_table_key);
                     $eavs = array_merge($eavs, $mirrored_eavs);
                 }
                 if (count($eavs)) {
                     foreach ($eavs as $eav) {
                         $key = $eav->eavattribute_alias;
                         $value = $eav_helper->getAttributeValue($eav, $this->get('_suffix'), $id);
                         $this->{$key} = $value;
                     }
                 }
             }
             $app->triggerEvent('onLoad' . $this->get('_suffix'), array(&$this));
         }
         return $result;
     } else {
         $this->setError($db->getErrorMsg());
         return false;
     }
 }
Example #23
0
 /**
  * Set basic properties for the item, whether in a list or a singleton
  *
  * @param unknown_type $item
  * @param unknown_type $key
  * @param unknown_type $refresh
  */
 protected function prepareItem(&$item, $key = 0, $refresh = false)
 {
     $input = JFactory::getApplication()->input;
     $getEav = $this->_getEav;
     $options = $this->_getEavOptions;
     $eavStates = count($this->getEavState()->getProperties());
     if (!empty($getEav) || $eavStates > 0) {
         $app = JFactory::getApplication();
         $editable_by = $app->isAdmin() ? 1 : 2;
         $view = $input->get('view', '');
         if ($app->isAdmin() && $view == 'pos') {
             $editable_by = array(1, 2);
         }
         Citruscart::load('CitruscartModelEavAttributes', 'models.eavattributes');
         Citruscart::load("CitruscartHelperBase", 'helpers._base');
         $eav_helper = CitruscartHelperBase::getInstance('Eav');
         $entity = $this->getTable()->get('_suffix');
         $tbl_key = $this->getTable()->getKeyName();
         $entity_id = $item->{$tbl_key};
         // add the custom fields as properties
         $eavs = $eav_helper->getAttributes($entity, $entity_id, false, $editable_by);
         // Mirrored table?
         if (!count($eavs) && strlen($this->getTable()->getLinkedTable())) {
             $entity = $this->getTable()->getLinkedTable();
             $entity_id = $item->{$this->getTable()->getLinkedTableKeyName()};
             $eavs = $eav_helper->getAttributes($entity, $entity_id, false, $editable_by);
         }
         foreach ($eavs as $eav) {
             $key = $eav->eavattribute_alias;
             $add = true;
             // Include Mode: Fetch only these fields
             if (array_key_exists('include', $options)) {
                 foreach ($options['include'] as $k) {
                     if ($key != $k) {
                         $add = false;
                     }
                 }
             } else {
                 // Exclude Mode: Fetch everything except these fields
                 if (array_key_exists('exclude', $options)) {
                     foreach ($options['exclude'] as $k) {
                         if ($key == $k) {
                             $add = false;
                         }
                     }
                 }
                 // Default Mode: Fetch Everything
             }
             if ($add) {
                 $value = $eav_helper->getAttributeValue($eav, $this->getTable()->get('_suffix'), $item->{$tbl_key}, false, true);
                 // Do NOT override properties
                 if (!property_exists($item, $key)) {
                     $item->{$key} = $value;
                 }
             }
         }
     }
     parent::prepareItem($item, $key, $refresh);
 }
Example #24
0
<?php

/*------------------------------------------------------------------------
# com_citruscart
# ------------------------------------------------------------------------
# author   Citruscart Team  - Citruscart http://www.citruscart.com
# copyright Copyright (C) 2014 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
-------------------------------------------------------------------------*/
/** ensure this file is being included by a parent file */
defined('_JEXEC') or die('Restricted access');
Citruscart::load("CitruscartHelperBase", 'helpers._base');
$currency_helper = CitruscartHelperBase::getInstance('Currency');
// Add CSS
$document->addStyleSheet(JURI::root(true) . '/modules/mod_citruscart_my_orders/tmpl/mod_citruscart_my_orders.css');
$user = JFactory::getUser();
if ($orders && $user->id) {
    $count = 0;
    foreach (@$orders as $order) {
        ?>
        <div class="mod_citruscart_my_orders_item">
            <?php 
        if ($params->get('display_date')) {
            ?>
                <span class="mod_citruscart_my_orders_item_date"><a href="<?php 
            echo $order->link;
            ?>
"><?php 
            echo JHTML::_('date', $order->created_date, Citruscart::getInstance()->get('date_format'));
Example #25
0
 /**
  * Briefly, this method "converts" the items in the cart to a order Object
  *
  * @return array of OrderItem
  */
 public static function getProductsInfo()
 {
     Citruscart::load("CitruscartHelperCarts", 'helpers.carts');
     $carthelper = new CitruscartHelperCarts();
     Citruscart::load("CitruscartHelperProduct", 'helpers.product');
     $product_helper = CitruscartHelperBase::getInstance('Product');
     JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_citruscart/models');
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
     $model = JModelLegacy::getInstance('Carts', 'CitruscartModel');
     $session = JFactory::getSession();
     $session_id = $session->getId();
     $user = JFactory::getUser();
     $model->setState('filter_user', $user->id);
     if (empty($user->id)) {
         $model->setState('filter_session', $session_id);
     }
     Citruscart::load("CitruscartHelperBase", 'helpers._base');
     $user_helper = CitruscartHelperBase::getInstance('User');
     $filter_group = $user_helper->getUserGroup($user->id);
     $model->setState('filter_group', $filter_group);
     $cartitems = $model->getList();
     $productitems = array();
     foreach ($cartitems as $cartitem) {
         unset($productModel);
         $productModel = JModelLegacy::getInstance('Products', 'CitruscartModel');
         $filter_group = $user_helper->getUserGroup($user->id, $cartitem->product_id);
         $productModel->setState('filter_group', $filter_group);
         $productModel->setId($cartitem->product_id);
         if ($productItem = $productModel->getItem(false)) {
             $productItem->price = $productItem->product_price = isset($cartitem->product_price_override->override) ? !$cartitem->product_price_override->override : "" ? $cartitem->product_price : $productItem->price;
             //we are not overriding the price if its a recurring && price
             if (!$productItem->product_recurs && isset($cartitem->product_price_override->override) ? $cartitem->product_price_override->override : "") {
                 // at this point, ->product_price holds the default price for the product,
                 // but the user may qualify for a discount based on volume or date, so let's get that price override
                 // TODO Shouldn't we remove this?  Is it necessary?  $cartitem has already done this in the carts model!
                 $productItem->product_price_override = $product_helper->getPrice($productItem->product_id, $cartitem->product_qty, $filter_group, JFactory::getDate()->toSql());
                 if (!empty($productItem->product_price_override)) {
                     $productItem->product_price = $productItem->product_price_override->product_price;
                 }
             }
             if ($productItem->product_check_inventory) {
                 // using a helper file,To determine the product's information related to inventory
                 $availableQuantity = $product_helper->getAvailableQuantity($productItem->product_id, $cartitem->product_attributes);
                 if ($availableQuantity->product_check_inventory && $cartitem->product_qty > $availableQuantity->quantity && $availableQuantity->quantity >= 1) {
                     JFactory::getApplication()->enqueueMessage(JText::sprintf("COM_CITRUSCART_CART_QUANTITY_ADJUSTED", $productItem->product_name, $cartitem->product_qty, $availableQuantity->quantity));
                     $cartitem->product_qty = $availableQuantity->quantity;
                 }
                 // removing the product from the cart if it's not available
                 if ($availableQuantity->quantity == 0) {
                     if (empty($cartitem->user_id)) {
                         $carthelper->removeCartItem($session_id, $cartitem->user_id, $cartitem->product_id);
                     } else {
                         $carthelper->removeCartItem($cartitem->session_id, $cartitem->user_id, $cartitem->product_id);
                     }
                     JFactory::getApplication()->enqueueMessage(JText::sprintf("COM_CITRUSCART_NOT_AVAILABLE") . " " . $productItem->product_name);
                     continue;
                 }
             }
             // TODO Push this into the orders object->addItem() method?
             $orderItem = JTable::getInstance('OrderItems', 'CitruscartTable');
             $orderItem->cart_id = $cartitem->cart_id;
             $orderItem->product_id = $productItem->product_id;
             $orderItem->orderitem_sku = $cartitem->product_sku;
             $orderItem->orderitem_name = $productItem->product_name;
             $orderItem->orderitem_quantity = $cartitem->product_qty;
             $orderItem->orderitem_price = $cartitem->product_price - $cartitem->orderitem_attributes_price;
             $orderItem->orderitem_attributes = $cartitem->product_attributes;
             $orderItem->orderitem_attribute_names = $cartitem->attributes_names;
             $orderItem->orderitem_attributes_price = $cartitem->orderitem_attributes_price;
             $orderItem->orderitem_attributes_weight = $cartitem->orderitem_attributes_weight;
             $orderItem->orderitem_weight = $cartitem->product_weight;
             $orderItem->orderitem_final_price = ($orderItem->orderitem_price + $orderItem->orderitem_attributes_price) * $orderItem->orderitem_quantity;
             $orderItem->orderitem_recurs = $productItem->product_recurs;
             if ($productItem->product_recurs) {
                 $orderItem->recurring_price = $productItem->recurring_price;
                 $orderItem->recurring_payments = $productItem->recurring_payments;
                 $orderItem->recurring_period_interval = $productItem->recurring_period_interval;
                 $orderItem->recurring_period_unit = $productItem->recurring_period_unit;
                 $orderItem->recurring_trial = $productItem->recurring_trial;
                 $orderItem->recurring_trial_period_interval = $productItem->recurring_trial_period_interval;
                 $orderItem->recurring_trial_period_unit = $productItem->recurring_trial_period_unit;
                 $orderItem->recurring_trial_price = $productItem->recurring_trial_price;
             }
             $results = JFactory::getApplication()->triggerEvent("onGetAdditionalOrderitemKeyValues", array($cartitem));
             foreach ($results as $result) {
                 foreach ($result as $key => $value) {
                     $orderItem->set($key, $value);
                 }
             }
             //adding plugin event, this is useful for editing the item before it is added for checkout from the cart. makes support for variable pricing
             JFactory::getApplication()->triggerEvent("onAddOrderitemFromCart", array($orderItem, $cartitem));
             // TODO When do attributes for selected item get set during admin-side order creation?
             array_push($productitems, $orderItem);
         }
     }
     return $productitems;
 }
Example #26
0
        echo $rate['tax'];
        ?>
,<?php 
        echo $rate['extra'];
        ?>
, '<?php 
        echo $rate['code'];
        ?>
');" <?php 
        echo $checked;
        ?>
 /> <?php 
        echo $rate['name'];
        ?>
 ( <?php 
        echo CitruscartHelperBase::currency($rate['total']);
        ?>
 )<br />
            <br/>
            <?php 
    }
} else {
    ?>
        <div class="note">
        <?php 
    echo JText::_('COM_CITRUSCART_NO_SHIPPING_NOTE');
    ?>
        </div>
        <?php 
}
$setval = false;
Example #27
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;
 }
 /**
  * Migrate the images
  *
  * param int $product_id
  * param string $images
  */
 private function _migrateImages($product_id, $images)
 {
     Citruscart::load('CitruscartImage', 'library.image');
     foreach ($images->children() as $image) {
         $check = false;
         $multiple = false;
         $image = (string) $image;
         if (JURI::isInternal($image)) {
             $internal = true;
             $int_image = JPATH_SITE . DIRECTORY_SEPARATOR . $image;
             if (is_dir($int_image)) {
                 $check = JFolder::exists($int_image);
                 $multiple = true;
             } else {
                 $check = JFile::exists($int_image);
             }
             // Now check the extracted images path
             if (!$check) {
                 $dir = $this->_temp_dir . DIRECTORY_SEPARATOR . 'images' . DS;
                 if (is_dir($dir . $image)) {
                     $check = JFolder::exists($dir . $image);
                     $multiple = true;
                 } else {
                     $check = JFile::exists($dir . $image);
                 }
                 if ($check) {
                     $image = $dir . $image;
                 }
             } else {
                 $image = $int_image;
             }
         } else {
             $internal = false;
             $check = $this->url_exists($image);
         }
         // Add a single image
         if (!$multiple) {
             $images_to_copy = array($image);
         } else {
             // Fetch the images from the folder and add them
             $images_to_copy = Citruscart::getClass("CitruscartHelperProduct", 'helpers.product')->getGalleryImages($image);
             foreach ($images_to_copy as &$i) {
                 $i = $image . DIRECTORY_SEPARATOR . $i;
             }
         }
         if ($check) {
             foreach ($images_to_copy as $image_to_copy) {
                 if ($internal) {
                     $img = new CitruscartImage($image_to_copy);
                 } else {
                     $tmp_path = JFactory::getApplication()->getCfg('tmp_path');
                     $file = fopen($image_to_copy, 'r');
                     $file_content = stream_get_contents($file);
                     fclose($file);
                     $file = fopen($tmp_path . DIRECTORY_SEPARATOR . $image_to_copy, 'w');
                     fwrite($file, $file_content);
                     fclose($file);
                     $img = new CitruscartImage($tmp_path . DIRECTORY_SEPARATOR . $image_to_copy);
                 }
                 Citruscart::load('CitruscartTableProducts', 'tables.products');
                 $product = JTable::getInstance('Products', 'CitruscartTable');
                 $product->load($product_id);
                 $path = $product->getImagePath();
                 $type = $img->getExtension();
                 $img->load();
                 $img->setDirectory($path);
                 // Save full Image
                 $img->save($path . $img->getPhysicalName());
                 // Save Thumb
                 Citruscart::load('CitruscartHelperImage', 'helpers.image');
                 $imgHelper = CitruscartHelperBase::getInstance('Image', 'CitruscartHelper');
                 $imgHelper->resizeImage($img, 'product');
             }
         }
     }
 }
Example #29
0
                    ?>
)
				                <?php 
                }
                ?>
                            <?php 
            }
            ?>
                        <?php 
        } else {
            ?>
                            <?php 
            echo JText::_('COM_CITRUSCART_PRICE');
            ?>
: <?php 
            echo CitruscartHelperBase::currency($item->product_price);
            ?>
                        <?php 
        }
        ?>

                        <br/> <?php 
        echo CitruscartHelperProduct::getRatingImage($item->product_rating);
        ?>
  <br/>

					    <?php 
        if (!empty($this->onDisplayCartItem) && !empty($this->onDisplayCartItem[$i])) {
            ?>
					        <div class='onDisplayCartItem_wrapper_<?php 
            echo $i;
Example #30
0
 /**
  * Get the price range based on the Highest and lowest prices
  * @return array
  */
 function getPriceRange()
 {
     // Check the registry to see if our Citruscart class has been overridden
     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');
     $ranges = array();
     $link = '';
     // get the model
     $model = JModelLegacy::getInstance('Products', 'CitruscartModel');
     $app = JFactory::getApplication();
     $ns = $app->getName() . '::' . 'com.citruscart.model.' . $model->getTable()->get('_suffix');
     //check if we are in the manufacturer view
     $view = JRequest::getWord('view');
     if ($view == 'manufacturers') {
         //get the current manufacturer
         $filter_manufacturer = $app->getUserStateFromRequest($ns . '.manufacturer', 'filter_manufacturer', '', 'int');
         if (empty($filter_manufacturer)) {
             return '';
         }
         $model->setState('filter_manufacturer', $filter_manufacturer);
         //create link to be concatinated
         $link = '&view=manufacturers&layout=products&task=products&filter_manufacturer=' . $filter_manufacturer;
     } else {
         //get the current category
         $filter_category = $app->getUserStateFromRequest($ns . '.category', 'filter_category', '', 'int');
         if (empty($filter_category)) {
             return '';
         }
         $model->setState('filter_category', $filter_category);
         //create link to be concatinated
         $link = '&filter_category=' . $filter_category;
     }
     //set the direction of the price
     $model->setState('order', 'price');
     $model->setState('direction', 'DESC');
     //get items
     $items = $model->getList();
     //check if we dont have product in the category
     if (empty($items)) {
         $ranges[$link] = JText::_('COM_CITRUSCART_NO_AVAILABLE_PRODUCT');
         return $ranges;
     }
     //get the highest price
     $priceHigh = abs($items['0']->price);
     //get the lowest price
     $priceLow = count($items) == 1 ? 0 : abs($items[count($items) - 1]->price);
     $range = (abs($priceHigh) - abs($priceLow)) / 4;
     //rounding
     $roundRange = $this->_priceRound($range, $this->params->get('round_digit'), true);
     $roundPriceLow = $this->_priceRound($priceLow, $this->params->get('round_digit'));
     $upperPrice = $this->params->get('filter_upper_limit');
     //load the helper base class
     Citruscart::load('CitruscartHelperBase', 'helpers._base');
     $ranges[$link . '&filter_price_from=' . $roundPriceLow . '&filter_price_to=' . $roundRange] = CitruscartHelperBase::currency($roundPriceLow) . ' - ' . CitruscartHelperBase::currency($roundRange);
     $ranges[$link . '&filter_price_from=' . $roundRange . '&filter_price_to=' . $roundRange * 2] = CitruscartHelperBase::currency($roundRange) . ' - ' . CitruscartHelperBase::currency($roundRange * 2);
     $ranges[$link . '&filter_price_from=' . $roundRange * 2 . '&filter_price_to=' . $roundRange * 3] = CitruscartHelperBase::currency($roundRange * 2) . ' - ' . CitruscartHelperBase::currency($roundRange * 3);
     $ranges[$link . '&filter_price_from=' . $roundRange * 3 . '&filter_price_to=' . $upperPrice] = CitruscartHelperBase::currency($roundRange * 3) . ' - ' . CitruscartHelperBase::currency($upperPrice);
     $ranges[$link . '&filter_price_from=' . $upperPrice] = JText::_('COM_CITRUSCART_MORE_THAN_') . CitruscartHelperBase::currency($upperPrice);
     return $ranges;
 }