예제 #1
0
$module = $Params['Module'];
$http = eZHTTPTool::instance();
$tpl = eZTemplate::factory();
if ($http->hasPostVariable("AddRuleButton")) {
    return $module->redirectTo($module->functionURI("editvatrule"));
}
if ($http->hasPostVariable("RemoveRuleButton")) {
    if (!$http->hasPostVariable("RuleIDList")) {
        $ruleIDList = array();
    } else {
        $ruleIDList = $http->postVariable("RuleIDList");
    }
    $db = eZDB::instance();
    $db->begin();
    foreach ($ruleIDList as $ruleID) {
        eZVatRule::removeVatRule($ruleID);
    }
    $db->commit();
}
if ($http->hasPostVariable("SaveCategoriesButton")) {
    $db = eZDB::instance();
    $db->begin();
    foreach ($productCategories as $cat) {
        $id = $cat->attribute('id');
        if (!$http->hasPostVariable("category_name_" . $id)) {
            continue;
        }
        $name = $http->postVariable("category_name_" . $id);
        $cat->setAttribute('name', $name);
        $cat->store();
    }
예제 #2
0
 /**
  * Remove given VAT type and all references to it.
  *
  * Drops VAT charging rules referencing the VAT type.
  * Resets VAT type in associated products to its default value for a product class.
  *
  * \param $vatID id of VAT type to remove.
  * \public
  * \static
  */
 function removeThis()
 {
     $vatID = $this->ID;
     $db = eZDB::instance();
     $db->begin();
     // remove dependent VAT rules
     $dependentRules = eZVatRule::fetchByVatType($vatID);
     foreach ($dependentRules as $rule) {
         eZVatRule::removeVatRule($rule->attribute('id'));
     }
     // replace VAT type in dependent products.
     eZVatType::resetToDefaultInProducts($vatID);
     // Remove the VAT type itself.
     eZPersistentObject::removeObject(eZVatType::definition(), array("id" => $vatID));
     $db->commit();
 }