Пример #1
0
 public static function installDefaultTaxClass($pkg)
 {
     $defaultTaxClass = StoreTaxClass::getByHandle("default");
     if (!is_object($defaultTaxClass)) {
         $data = array('taxClassName' => t('Default'), 'taxClassLocked' => true);
         $defaultTaxClass = StoreTaxClass::add($data);
     }
     //for older versions of store, we need to make sure all products have some sort of tax class.
     $db = Database::get();
     $productsWithNoTaxClass = $db->GetAll("SELECT * FROM VividStoreProducts WHERE pTaxClass = ''");
     $tcID = $defaultTaxClass->getTaxClassID();
     foreach ($productsWithNoTaxClass as $p) {
         $db->Query("UPDATE VividStoreProducts SET pTaxClass=? WHERE pID = ?", array($tcID, $p['pID']));
     }
 }
Пример #2
0
 public function validate($args)
 {
     $e = Loader::helper('validation/error');
     if ($args['symbol'] == "") {
         $e->add(t('You must set a currency symbol'));
     }
     if ($args['taxEnabled'] == 'yes') {
         if (!is_numeric(trim($args['taxRate']))) {
             $e->add(t('Tax Rate must be set, and a number'));
         }
     }
     if ($args['shippingEnabled'] == 'yes') {
         if (!is_numeric(trim($args['shippingBasePrice']))) {
             $e->add(t('Shipping Base Rate must be set, and a number'));
         }
         if (!is_numeric(trim($args['shippingItemPrice']))) {
             $e->add(t('Shipping Base Rate must be set, and a number (even if just zero)'));
         }
     }
     $paymentMethodsEnabled = 0;
     foreach ($args['paymentMethodEnabled'] as $method) {
         if ($method == 1) {
             $paymentMethodsEnabled++;
         }
     }
     if ($paymentMethodsEnabled == 0) {
         $e->add(t('At least one payment method must be enabled'));
     }
     foreach ($args['paymentMethodEnabled'] as $pmID => $value) {
         $pm = StorePaymentMethod::getByID($pmID);
         $controller = $pm->getMethodController();
         $e = $controller->validate($args, $e);
     }
     if (!isset($args['osName'])) {
         $e->add(t('You must have at least one Order Status.'));
     }
     //before changing tax settings to "Extract", make sure there's only one rate per class
     $taxClasses = StoreTaxClass::getTaxClasses();
     foreach ($taxClasses as $taxClass) {
         $taxClassRates = $taxClass->getTaxClassRates();
         if (count($taxClassRates) > 1) {
             $e->add(t("The %s Tax Class can't contain more than 1 Tax Rate if you change how the taxes are calculated", $taxClass->getTaxClassName()));
         }
     }
     return $e;
 }
Пример #3
0
 public function getTaxClass()
 {
     return StoreTaxClass::getByID($this->pTaxClass);
 }
Пример #4
0
 public function save_class()
 {
     $data = $this->post();
     $errors = $this->validateClass($data);
     $this->error = null;
     //clear errors
     $this->error = $errors;
     if ($this->post('taxClassID')) {
         $this->edit_class($this->post('taxClassID'));
     } else {
         $this->add_class();
     }
     if (!$errors->has()) {
         if ($this->post('taxClassID')) {
             //update
             $taxClass = StoreTaxClass::getByID($this->post('taxClassID'));
             $taxClass->update($data);
             $this->redirect('/dashboard/store/settings/tax/class_updated');
         } else {
             //add.
             StoreTaxClass::add($data);
             $this->redirect('/dashboard/store/settings/tax/class_added');
         }
     }
 }
Пример #5
0
 public function loadFormAssets()
 {
     $this->requireAsset('redactor');
     $this->requireAsset('core/file-manager');
     $this->requireAsset('core/sitemap');
     $this->set('fp', FilePermissions::getGlobal());
     $this->set('tp', new TaskPermission());
     $this->set('al', Core::make('helper/concrete/asset_library'));
     $this->addHeaderItem('<style type="text/css">.redactor_editor{padding:20px}</style>');
     $this->requireAsset('css', 'vividStoreDashboard');
     $this->requireAsset('javascript', 'vividStoreFunctions');
     $attrList = StoreProductKey::getList();
     $this->set('attribs', $attrList);
     $pageType = PageType::getByHandle("store_product");
     $pageTemplates = $pageType->getPageTypePageTemplateObjects();
     $templates = array();
     foreach ($pageTemplates as $pt) {
         $templates[$pt->getPageTemplateID()] = $pt->getPageTemplateName();
     }
     $this->set('pageTemplates', $templates);
     $taxClasses = array();
     foreach (StoreTaxClass::getTaxClasses() as $taxClass) {
         $taxClasses[$taxClass->getTaxClassID()] = $taxClass->getTaxClassName();
     }
     $this->set('taxClasses', $taxClasses);
 }
Пример #6
0
 public function delete_class($tcID)
 {
     TaxClass::getByID($tcID)->delete();
     $this->redirect("/dashboard/store/settings/tax/class_deleted");
 }