Ejemplo n.º 1
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     $this->model = $this->getModel();
     if ($this->params->get('cart_query_enabled', '1') != '1') {
         throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $auth = $this->params->get('cart_query_registered', '1') == '1' && $user->guest ? false : true;
     if (!$auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getQueryRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     $this->items = $this->basket->getItems();
     if (empty($this->items)) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return true;
     }
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->form = $this->get('Form');
     $data = JArrayHelper::fromObject($user_profile, false);
     $post_data = (array) $app->getUserState('com_djcatalog2.query.data', array());
     if (!empty($post_data)) {
         foreach ($post_data as $k => $v) {
             $data[$k] = $v;
         }
     }
     $this->user_valid = $this->model->validate($this->form, array('djcatalog2profile' => $data));
     $this->user_profile = $user_profile;
     $this->user = $user;
     $this->total = $this->basket->getTotal();
     $this->_prepareDocument();
     parent::display($tpl);
 }
Ejemplo n.º 2
0
 protected function allowQuery()
 {
     $app = JFactory::getApplication();
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     $params = JComponentHelper::getParams('com_djcatalog2');
     if ($params->get('cart_query_enabled', '1') != '1') {
         throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $auth = $params->get('cart_query_registered', '1') == '1' && $user->guest ? false : true;
     if (!$auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getQueryRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return false;
     }
     $basket = Djcatalog2HelperCart::getInstance(true);
     $basket->recalculate();
     if (empty($basket) || !$basket->getItems()) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return false;
     }
     return true;
 }
Ejemplo n.º 3
0
	<?php 
    /* ?>
    	<form action="<?php echo JRoute::_(DJCatalogHelperRoute::getCheckoutRoute());?>" method="post">
    		<input type="submit" value="<?php echo JText::_('COM_DJCATALOG2_CONFIRM_CART');?>" class="btn button btn-success djc_checkout_btn" />
    		<input type="hidden" name="option" value="com_djcatalog2" />
    		<input type="hidden" name="task" value="cart.checkout" />
    		<?php echo JHtml::_( 'form.token' ); ?>
    	</form>
    	<?php */
    ?>
	
	<?php 
    if ($this->params->get('cart_query_enabled', '1') == '1') {
        ?>
		<form action="<?php 
        echo JRoute::_(DJCatalogHelperRoute::getQueryRoute());
        ?>
" method="post">
			<input type="submit" value="<?php 
        echo JText::_('COM_DJCATALOG2_PROCEED_TO_CONTACT_FORM');
        ?>
" class="btn button btn-success djc_query_btn" />
			<input type="hidden" name="option" value="com_djcatalog2" />
			<input type="hidden" name="task" value="cart.query" />
			<?php 
        echo JHtml::_('form.token');
        ?>
		</form>
	<?php 
    }
}
Ejemplo n.º 4
0
" method="post" class="form-validate">
	<fieldset class="djc_checkout_notes">
	
		<?php 
if (empty($this->user_profile) || empty($this->user_profile->id) || $this->user_valid == false) {
    ?>
			<h2><?php 
    echo JText::_('COM_DJCATALOG2_USER_PROFILE');
    ?>
</h2>
			<?php 
    if ($user->guest) {
        ?>
				<p class="djc_login_link">
				<?php 
        $return_url = base64_encode(DJCatalogHelperRoute::getQueryRoute());
        $login_url = JRoute::_('index.php?option=com_users&view=login&return=' . $return_url);
        echo JText::sprintf('COM_DJCATALOG2_CLICK_TO_LOGIN', $login_url);
        ?>
				</p>
			<?php 
    }
    ?>
			<?php 
    $fields = $this->form->getFieldset();
    foreach ($fields as $field) {
        ?>
				<?php 
        if ($field->fieldname == 'customer_note') {
            ?>
				<h2><?php 
Ejemplo n.º 5
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     $this->model = $this->getModel();
     if ($this->params->get('cart_query_enabled', '1') != '1') {
         throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $auth = $this->params->get('cart_query_registered', '1') == '1' && $user->guest ? false : true;
     if (!$auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getQueryRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     $this->items = $this->basket->getItems();
     if (empty($this->items)) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return true;
     }
     if (count($this->items)) {
         JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models', 'DJCatalog2Model');
         $itemsModel = JModelLegacy::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
         $parents = array();
         foreach ($this->items as $item) {
             if ($item->parent_id > 0) {
                 $parents[] = $item->parent_id;
             }
         }
         if (count($parents) > 0) {
             $state = $itemsModel->getState();
             $itemsModel->setState('list.start', 0);
             $itemsModel->setState('list.limit', 0);
             $itemsModel->setState('filter.catalogue', false);
             $itemsModel->setState('list.ordering', 'i.name');
             $itemsModel->setState('list.direction', 'asc');
             $itemsModel->setState('filter.parent', '*');
             $itemsModel->setState('filter.state', '3');
             $itemsModel->setState('filter.item_ids', $parents);
             $parentItems = $itemsModel->getItems();
             foreach ($this->items as $id => $item) {
                 if ($item->parent_id > 0 && isset($parentItems[$item->parent_id])) {
                     $this->items[$id]->parent = $parentItems[$item->parent_id];
                 } else {
                     $this->items[$id]->parent = false;
                 }
             }
         }
     }
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->form = $this->get('Form');
     $data = JArrayHelper::fromObject($user_profile, false);
     $post_data = (array) $app->getUserState('com_djcatalog2.query.data', array());
     if (!empty($post_data)) {
         foreach ($post_data as $k => $v) {
             $data[$k] = $v;
         }
     }
     $this->user_valid = $this->model->validate($this->form, array('djcatalog2profile' => $data), 'djcatalog2profile');
     $this->user_profile = $user_profile;
     $this->user = $user;
     $this->total = $this->basket->getTotal();
     $this->_prepareDocument();
     parent::display($tpl);
 }