Ejemplo n.º 1
0
 /**
  *
  * @return unknown_type
  */
 function filterZones()
 {
     $app = JFactory::getApplication();
     JLoader::import('com_citruscart.library.json', JPATH_ADMINISTRATOR . '/components');
     Citruscart::load('CitruscartSelect', 'library.select');
     $idtag = 'zone_id';
     $countryid = $app->input->getInt('countryid', 0);
     $idprefix = $app->input->getInt('idprefix', 0);
     /*
     		$countryid = JRequest::getVar( 'countryid', '', 'request', 'int' );
     		$idprefix = JRequest::getVar( 'idprefix', '', 'request');
     */
     if (count($idprefix) > 0) {
         $idtag = $idprefix . $idtag;
     }
     $url = "index.php?option=com_citruscart&format=raw&controller=zones&task=addZone&geozoneid=";
     $attribs = array('class' => 'inputbox', 'size' => '1');
     $hookgeozone = $app->input->get('hookgeozone', TRUE);
     //$hookgeozone = JRequest::getVar( 'hookgeozone', TRUE, 'request', 'boolean' );
     if ($hookgeozone) {
         $attribs['onchange'] = 'citruscartDoTask( \'' . $url . '\'+document.getElementById(\'geozone_id\').value+\'&zoneid=\'+this.options[this.selectedIndex].value, \'current_zones_wrapper\', \'\');';
     }
     $html = CitruscartSelect::zone('', $idtag, $countryid, $attribs, $idtag, true);
     // set response array
     $response = array();
     $response['msg'] = $html;
     // encode and echo (need to echo to send back to browser)
     echo json_encode($response);
     return;
 }
 /**
  * Override parent::_getData()
  *
  * @return unknown_type
  */
 function _getData()
 {
     $app = JFactory::getApplication();
     Citruscart::load('CitruscartQuery', 'library.query');
     // just in case
     $db = JFactory::getDbo();
     $state = $this->_getState();
     $model = $this->_getModel();
     // filter only complete orders ( 3 - Shipped, 5 - Complete, 17 - Payment Received )
     $order_states = array('3', '5', '17');
     $model->setState('filter_orderstates', $order_states);
     $model->setState('order', '`price_total`');
     $model->setState('direction', 'DESC');
     $query = $model->getQuery(true);
     $query->group('p.manufacturer_id');
     $field[] = " SUM(tbl.orderitem_final_price) AS `price_total` ";
     $field[] = " SUM(tbl.orderitem_quantity) AS `count_items` ";
     $query->select($field);
     $model->setQuery($query);
     $list = $model->getList();
     if (!count($list)) {
         return $list;
     }
     return $list;
 }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
0
 /**
  * Method to calculate statistics about manufacturers in an order
  * 
  * @param $items Array of order items
  * 
  * @return	Array with list of manufacturers and their stats
  */
 function calculateStatsOrder($items)
 {
     $db = JFactory::getDbo();
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
     Citruscart::load('CitruscartQuery', 'library.query');
     $q = new CitruscartQuery();
     $q->select('manufacturer_id');
     $q->from('`#__citruscart_products`');
     $result = array();
     foreach ($items as $item) {
         $q->where('product_id = ' . (int) $item->product_id);
         $db->setQuery($q);
         $res = $db->loadObject();
         if ($res == null) {
             $man_id = 0;
         } else {
             $man_id = $res->manufacturer_id;
         }
         if (!isset($result[$man_id])) {
             $model = JModelLegacy::getInstance('Manufacturers', 'CitruscartModel');
             $model->setId($man_id);
             if (!($man_item = $model->getItem())) {
                 $man_item = new stdClass();
             }
             $result[$man_id] = $man_item;
             $result[$man_id]->subtotal = 0;
             $result[$man_id]->total_tax = 0;
         }
         $result[$man_id]->subtotal += $item->orderitem_final_price;
         $result[$man_id]->total_tax += $item->orderitem_tax;
     }
     return $result;
 }
Ejemplo n.º 5
0
 public function renderSubmenu()
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_citruscart/helpers/toolbar.php';
     $toolbar = new CitruscartToolBar();
     Citruscart::load('CitruscartToolbar', 'helpers.toolbar.php');
     $toolbar->renderLinkbar();
 }
Ejemplo n.º 6
0
 /**
  *
  * @return unknown_type
  */
 function getItems()
 {
     // 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');
     // get the model
     $model = JModelLegacy::getInstance('Manufacturers', 'CitruscartModel');
     // TODO Make this depend on the current filter_category?
     // setting the model's state tells it what items to return
     $model->setState('filter_enabled', '1');
     $model->setState('order', 'tbl.manufacturer_name');
     // set the states based on the parameters
     // using the set filters, get a list
     $items = $model->getList();
     if (!empty($items)) {
         foreach ($items as $item) {
             // this gives error
             $item->itemid = Citruscart::getClass("CitruscartHelperRoute", 'helpers.route')->manufacturer($item->manufacturer_id, false);
             if (empty($item->itemid)) {
                 $item->itemid = $this->params->get('itemid');
             }
         }
     }
     return $items;
 }
Ejemplo n.º 7
0
 /**
  *
  * @return unknown_type
  */
 function getItems()
 {
     // 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');
     // get the model
     Citruscart::load('CitruscartModelCategories', 'models.categories');
     $model = new CitruscartModelCategories(array());
     // $model = JModelLegacy::getInstance( 'Categories', 'CitruscartModel' ); doesnt work sometimes without no apparent reason
     // TODO Make this depend on the current filter_category?
     // setting the model's state tells it what items to return
     $model->setState('filter_enabled', '1');
     $model->setState('order', 'tbl.lft');
     // set the states based on the parameters
     // using the set filters, get a list
     $items = $model->getList();
     if (!empty($items)) {
         foreach ($items as $item) {
             Citruscart::load('CitruscartHelperRoute', 'helpers.route');
             $item->itemid = CitruscartHelperRoute::category($item->category_id, true);
             if (empty($item->itemid)) {
                 $item->itemid = $this->params->get('itemid');
             }
         }
     }
     return $items;
 }
Ejemplo n.º 8
0
 /**
  * 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;
 }
Ejemplo n.º 9
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.º 10
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.º 11
0
 /**
  * Include a particular Citruscart Model
  * @param $name the name of the mode (ex: products)
  */
 protected function includeCitruscartModel($name)
 {
     if (strtolower($name) != 'base') {
         Citruscart::load('CitruscartModel' . ucfirst(strtolower($name)), 'models.' . strtolower($name));
     } else {
         Citruscart::load('CitruscartModelBase', 'models._base');
     }
 }
Ejemplo n.º 12
0
 function __construct($config = array())
 {
     parent::__construct($config);
     if (empty($this->helpers)) {
         $this->helpers = array();
     }
     Citruscart::load("CitruscartHelperProduct", 'helpers.product');
     $this->helpers['product'] = new CitruscartHelperProduct();
 }
 /**
  * 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;
 }
Ejemplo n.º 14
0
 /**
  * constructor
  */
 function __construct()
 {
     if (empty(JFactory::getUser()->id)) {
         $url = JRoute::_("index.php?option=com_citruscart&view=productdownloads");
         Citruscart::load("CitruscartHelperUser", 'helpers.user');
         $redirect = JRoute::_(CitruscartHelperUser::getUserLoginUrl($url), false);
         JFactory::getApplication()->redirect($redirect);
         return;
     }
     parent::__construct();
     $this->set('suffix', 'productdownloads');
 }
Ejemplo n.º 15
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("CitruscartModelSubscriptions", "models.subscriptions");
             $model->setId($this->subscription_id);
             $subscription = $model->getItem();
             $helper->sendEmailNotices($subscription, 'subscription');
         }
     }
     return $return;
 }
Ejemplo n.º 16
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();
 }
Ejemplo n.º 17
0
 public static function getAddresses()
 {
     /* Get the application */
     $app = JFactory::getApplication();
     Citruscart::load('CitruscartHelperUser', 'helpers.user');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
     JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_citruscart/models');
     // get the user's addresses using the address model
     $model = JModelLegacy::getInstance('Addresses', 'CitruscartModel');
     $model->setState('filter_userid', $app->input->get('id', 0, 'request', 'int'));
     //$model->setState('filter_userid', JRequest::getVar('id', 0, 'request', 'int'));
     $model->setState('filter_deleted', 0);
     $userAddresses = $model->getList();
     return $userAddresses;
 }
 /**
  *
  * @return unknown_type
  */
 function onAfterInitialise()
 {
     $success = null;
     if (!$this->isInstalled()) {
         return $success;
     }
     if (!$this->canRun()) {
         return $success;
     }
     Citruscart::load('CitruscartHelperSubscription', 'helpers.subscription');
     $helper = new CitruscartHelperSubscription();
     $helper->checkExpired();
     $helper->checkExpiring();
     return $success;
 }
Ejemplo n.º 19
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;
 }
Ejemplo n.º 20
0
 /**
  * Displays the submit bug form
  */
 function submitBug()
 {
     /* Get the application */
     $app = JFactory::getApplication();
     //JRequest::setVar('Citruscart_display_submenu', 1 );
     $app->input->set('Citruscart_display_submenu', 1);
     Citruscart::load('CitruscartViewBase', 'views._base');
     $view = new CitruscartViewBase();
     $view->displayTitle(JText::_('COM_CITRUSCART_SUBMIT_BUG'));
     unset($view);
     ob_start();
     include dirname(__FILE__) . '/bug_report/tmpl/submitbug.php';
     $text = ob_get_contents();
     ob_end_clean();
     return $text;
 }
Ejemplo n.º 21
0
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     $prev = clone $this;
     if (!empty($this->id)) {
         $prev->load($this->id);
     }
     if ($save = parent::save($src, $orderingFilter, $ignore)) {
         if ($prev->subscription_enabled && empty($this->subscription_enabled)) {
             // if it was previously enabled and now is disabled
             Citruscart::load('CitruscartHelperJuga', 'helpers.juga');
             $helper = new CitruscartHelperJuga();
             $helper->doExpiredSubscription($this);
         }
     }
     return $save;
 }
 /**
  * Expected to be called from ajax
  */
 public function getProductAttributeOptions()
 {
     $app = JFactory::getApplication();
     $attribute_id = $app->input->getInt('attribute_id', 0);
     $name = $app->input->getString('select_name', 'parent');
     $id = $app->input->getString('select_id', '0');
     $response = array();
     $response['msg'] = '';
     $response['error'] = '';
     if ($attribute_id) {
         Citruscart::load('CitruscartSelect', 'library.select');
         $response['msg'] = CitruscartSelect::productattributeoptions($attribute_id, 0, $name . "[" . $id . "]");
     } else {
         $response['msg'] = '<input type="hidden" name="' . $name . "[" . $id . "]" . '" />';
     }
     echo json_encode($response);
 }
Ejemplo n.º 23
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.º 24
0
 /**
  * Sample use of the products model for getting products with certain properties
  * See admin/models/products.php for all the filters currently built into the model
  *
  * @param $parameters
  * @return unknown_type
  */
 function getOrders()
 {
     // 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');
     // get the model
     $model = JModelLegacy::getInstance('orders', 'CitruscartModel');
     $model->setState('limit', $this->params->get('max_number', '5'));
     $user = JFactory::getUser();
     $model->setState('filter_userid', $user->id);
     $orders = $model->getList();
     return $orders;
 }
Ejemplo n.º 25
0
 /**
  * (non-PHPdoc)
  * @see Citruscart/admin/CitruscartController::display()
  */
 function display($cachable = false, $urlparams = '')
 {
     Citruscart::load('CitruscartHelperBase', 'helpers._base');
     JFactory::getApplication()->input->set('view', $this->get('suffix'));
     $view = $this->getView($this->get('suffix'), JFactory::getDocument()->getType());
     $model = $this->getModel($this->get('suffix'));
     $this->_setModelState();
     $view->set('_doTask', true);
     $view->setModel($model, true);
     $view->setLayout('default');
     $user_id = JFactory::getUser()->id;
     $userinfo = JTable::getInstance('UserInfo', 'CitruscartTable');
     $userinfo->load(array('user_id' => $user_id));
     $view->assign('userinfo', $userinfo);
     $view->display();
     $this->footer();
     return;
 }
Ejemplo n.º 26
0
 /**
  * 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;
 }
Ejemplo n.º 27
0
 function listRateLevels($selected, $taxrate_id, $tax_class_id)
 {
     $list = array();
     Citruscart::load('CitruscartQuery', 'library.query');
     $q = new CitruscartQuery();
     $db = JFactory::getDbo();
     $q->select('max( level ) as `max_level`, min( level ) as `min_level`');
     $q->from('#__citruscart_taxrates');
     $q->where('tax_class_id = ' . $tax_class_id);
     $db->setQuery($q);
     $levels = $db->loadObject();
     if (!strlen($levels->min_level)) {
         $levels->min_level = 0;
     }
     for ($i = $levels->min_level; $i <= $levels->max_level + 1; $i++) {
         $list[] = JHTML::_('select.option', $i, 'Level - ' . $i);
     }
     return JHTML::_('select.genericlist', $list, 'levels[' . $taxrate_id . ']', array('class' => 'inputbox', 'size' => '1'), 'value', 'text', $selected);
 }
Ejemplo n.º 28
0
 /**
  *  Given the user id and the file id will return the row id on which entry is greate then 0
  *  
  *  @param user id
  *  @param productfile id
  *  @return productdown load id
  */
 function getProductDownloadInfo($productfile_id, $user_id)
 {
     Citruscart::load('CitruscartQuery', 'library.query');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
     $tableProductDownload = JTable::getInstance('ProductDownloads', 'CitruscartTable');
     $query = new CitruscartQuery();
     $select[] = "productdl.*";
     $query->select($select);
     $query->from($tableProductDownload->getTableName() . " AS productdl");
     $whereClause[] = "productdl.user_id = " . (int) $user_id;
     $whereClause[] = "productdl.productfile_id='" . $productfile_id . "'";
     $whereClause[] = "productdl.productdownload_max > 0";
     // Assumed that 0000-00-00 00:00:00 is the entry for the unlimited Downloads
     // TODO apply the where task for the Date
     $query->where($whereClause, "AND");
     $db = JFactory::getDBO();
     $db->setQuery((string) $query);
     $item = $db->loadObject();
     return $item;
 }
Ejemplo n.º 29
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);
 }
Ejemplo n.º 30
0
 /**
  * @Returns a selectlist of zones
  * @Called via Ajax
  *
  * @return unknown_type
  */
 function getZones()
 {
     $app = JFactory::getApplication();
     Citruscart::load('CitruscartSelect', 'library.select');
     $html = '';
     $text = '';
     $country_id = $app->input->getInt('country_id');
     $name = $app->input->get('name', 'zone_id');
     if (empty($country_id)) {
         $html = JText::_('COM_CITRUSCART_SELECT_COUNTRY_FIRST');
     } else {
         $html = CitruscartSelect::zone('', $name, $country_id);
     }
     $response = array();
     $response['msg'] = $html;
     $response['error'] = '';
     // encode and echo (need to echo to send back to browser)
     echo json_encode($response);
     return;
 }