Example #1
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $layout = $jinput->get('layout', 'edit');
     $model = $this->getModel('taxprofile');
     if ($layout == 'edit') {
         $this->state = $this->get('State');
         $this->item = $this->get('Item');
         $this->form = $this->get('Form');
         // Get taxprofile_id
         $taxprofile_id = $app->input->get('id', 0);
         // Getting saved tax rules.
         if (!empty($taxprofile_id)) {
             $this->taxrules = $model->getTaxRules($taxprofile_id);
         }
         // Get store name while edit view
         if (!empty($this->item->id) && !empty($this->item->store_id)) {
             $comquick2cartHelper = new comquick2cartHelper();
             $this->storeDetails = $comquick2cartHelper->getSoreInfo($this->item->store_id);
             // Getting tax rates and Adress types
             $this->taxrate = $model->getTaxRateListSelect($this->item->store_id, '');
             $this->address = $model->getAddressList();
         }
         // Check for errors.
         if (count($errors = $this->get('Errors'))) {
             throw new Exception(implode("\n", $errors));
         }
         $this->addToolbar();
     } else {
         $this->taxRule_id = $jinput->get('id');
         $defaultTaxRateId = '';
         $defaultAddressId = '';
         // Getting saved tax rules.
         if (!empty($this->taxRule_id)) {
             $this->taxrules = $model->getTaxRules('', $this->taxRule_id);
             if (!empty($this->taxrules)) {
                 $defaultTaxRateId = $this->taxrules[0]->taxrate_id;
                 $defaultAddressId = $this->taxrules[0]->address;
             }
             // Get store id of taxrule
             $taxHelper = new taxHelper();
             $store_id = $taxHelper->getStoreIdFromTaxrule($this->taxRule_id);
             if (empty($store_id)) {
                 $this->qtcStoreNotFoundMsg();
             }
             // Getting tax rates and Adress types
             $this->taxrate = $model->getTaxRateListSelect($store_id, $defaultTaxRateId);
             $this->address = $model->getAddressList($defaultAddressId);
         }
     }
     parent::display($tpl);
 }
Example #2
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $comquick2cartHelper = new comquick2cartHelper();
     $zoneHelper = new zoneHelper();
     // Check whether view is accessible to user
     if (!$zoneHelper->isUserAccessible()) {
         return;
     }
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $user = JFactory::getUser();
     $this->params = $app->getParams('com_quick2cart');
     $layout = $jinput->get('layout', 'default');
     $model = $this->getModel('taxprofileform');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new Exception(implode("\n", $errors));
     }
     if ($layout == 'default') {
         $this->state = $this->get('State');
         $this->item = $this->get('Data');
         $this->form = $this->get('Form');
         // Get taxprofile_id
         $taxprofile_id = $app->input->get('id', 0);
         // Getting saved tax rules.
         if (!empty($taxprofile_id)) {
             $this->taxrules = $model->getTaxRules($taxprofile_id);
         }
         // Check whether user is authorized for this zone ?
         if (!empty($this->item->store_id)) {
             $status = $comquick2cartHelper->store_authorize('taxprofileform_default', $this->item->store_id);
             if (!$status) {
                 $zoneHelper->showUnauthorizedMsg();
                 return false;
             }
         }
         // Get store name while edit view
         if (!empty($this->item->id) && !empty($this->item->store_id)) {
             $comquick2cartHelper = new comquick2cartHelper();
             $this->storeDetails = $comquick2cartHelper->getSoreInfo($this->item->store_id);
             // Getting tax rates and Adress types
             $this->taxrate = $model->getTaxRateListSelect($this->item->store_id, '');
             $this->address = $model->getAddressList();
         }
         // Check for errors.
         if (count($errors = $this->get('Errors'))) {
             throw new Exception(implode("\n", $errors));
         }
     } else {
         $this->taxRule_id = $jinput->get('id');
         $defaultTaxRateId = '';
         $defaultAddressId = '';
         // Getting saved tax rules.
         if (!empty($this->taxRule_id)) {
             $this->taxrules = $model->getTaxRules('', $this->taxRule_id);
             if (!empty($this->taxrules)) {
                 $defaultTaxRateId = $this->taxrules[0]->taxrate_id;
                 $defaultAddressId = $this->taxrules[0]->address;
             }
             // Get store id of taxrule
             $taxHelper = new taxHelper();
             $store_id = $taxHelper->getStoreIdFromTaxrule($this->taxRule_id);
             if (empty($store_id)) {
                 $this->qtcStoreNotFoundMsg();
             }
             // Getting tax rates and Adress types
             $this->taxrate = $model->getTaxRateListSelect($store_id, $defaultTaxRateId);
             $this->address = $model->getAddressList($defaultAddressId);
         }
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }