コード例 #1
0
ファイル: vattype.php プロジェクト: nfrp/ezpublish
function applyChanges($module, $http, $vatTypeArray = false)
{
    $errors = array();
    if ($vatTypeArray === false) {
        $vatTypeArray = eZVatType::fetchList(true, true);
    }
    $db = eZDB::instance();
    $db->begin();
    foreach ($vatTypeArray as $vatType) {
        $id = $vatType->attribute('id');
        if ($id == -1) {
            // avoid storing changes to the "fake" dynamic VAT type
            continue;
        }
        if ($http->hasPostVariable("vattype_name_" . $id)) {
            $name = $http->postVariable("vattype_name_" . $id);
        }
        if ($http->hasPostVariable("vattype_percentage_" . $id)) {
            $percentage = $http->postVariable("vattype_percentage_" . $id);
        }
        if (!$name || $percentage < 0 || $percentage > 100) {
            if (!$name) {
                $errors[] = ezpI18n::tr('kernel/shop/vattype', 'Empty VAT type names are not allowed (corrected).');
            } else {
                $errors[] = ezpI18n::tr('kernel/shop/vattype', 'Wrong VAT percentage (corrected).');
            }
            continue;
        }
        $vatType->setAttribute('name', $name);
        $vatType->setAttribute('percentage', $percentage);
        $vatType->store();
    }
    $db->commit();
    return $errors;
}
コード例 #2
0
ファイル: ezmultipricetype.php プロジェクト: legende91/ez
 function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
 {
     $vatNode = $attributeParametersNode->getElementsByTagName('vat-included')->item(0);
     $vatIncluded = strtolower($vatNode->getAttribute('is-set')) == 'true';
     if ($vatIncluded) {
         $vatIncluded = self::INCLUDED_VAT;
     } else {
         $vatIncluded = self::EXCLUDED_VAT;
     }
     $classAttribute->setAttribute(self::INCLUDE_VAT_FIELD, $vatIncluded);
     $vatTypeNode = $attributeParametersNode->getElementsByTagName('vat-type')->item(0);
     $vatName = $vatTypeNode->getAttribute('name');
     $vatPercentage = $vatTypeNode->getAttribute('percentage');
     $vatID = false;
     $vatTypes = eZVatType::fetchList();
     foreach ($vatTypes as $vatType) {
         if ($vatType->attribute('name') == $vatName and $vatType->attribute('percentage') == $vatPercentage) {
             $vatID = $vatType->attribute('id');
             break;
         }
     }
     if (!$vatID) {
         $vatType = eZVatType::create();
         $vatType->setAttribute('name', $vatName);
         $vatType->setAttribute('percentage', $vatPercentage);
         $vatType->store();
         $vatID = $vatType->attribute('id');
     }
     $classAttribute->setAttribute(self::VAT_ID_FIELD, $vatID);
     $defaultCurrency = $attributeParametersNode->getElementsByTagName('default-currency')->item(0);
     $currencyCode = $defaultCurrency->getAttribute('code');
     $classAttribute->setAttribute(self::DEFAULT_CURRENCY_CODE_FIELD, $currencyCode);
 }
コード例 #3
0
 function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
 {
     $vatNode = $attributeParametersNode->getElementsByTagName('vat-included')->item(0);
     $vatIncluded = strtolower($vatNode->getAttribute('is-set')) == 'true';
     $classAttribute->setAttribute(eZPriceType::INCLUDE_VAT_FIELD, $vatIncluded);
     $vatTypeNode = $attributeParametersNode->getElementsByTagName('vat-type')->item(0);
     $vatName = $vatTypeNode->getAttribute('name');
     $vatPercentage = $vatTypeNode->getAttribute('percentage');
     $vatID = false;
     $vatTypes = eZVatType::fetchList();
     foreach ($vatTypes as $vatType) {
         if ($vatType->attribute('name') == $vatName and $vatType->attribute('percentage') == $vatPercentage) {
             $vatID = $vatType->attribute('id');
             break;
         }
     }
     if (!$vatID) {
         $vatType = eZVatType::create();
         $vatType->setAttribute('name', $vatName);
         $vatType->setAttribute('percentage', $vatPercentage);
         $vatType->store();
         $vatID = $vatType->attribute('id');
     }
     $classAttribute->setAttribute(eZPriceType::VAT_ID_FIELD, $vatID);
 }
コード例 #4
0
ファイル: ezvattype.php プロジェクト: runelangseid/ezpublish
 function VATTypeList()
 {
     if (!isset($this->VatTypeList)) {
         $this->VatTypeList = eZVatType::fetchList();
         if (!isset($this->VatTypeList)) {
             $this->VatTypeList = array();
         }
     }
     return $this->VatTypeList;
 }
コード例 #5
0
if (is_numeric($ruleID)) {
    $tplVatRule = eZVatRule::fetch($ruleID);
    $tplCountry = $tplVatRule->attribute('country_code');
    $tplCategoryIDs = $tplVatRule->attribute('product_categories_ids');
    $tplVatTypeID = $tplVatRule->attribute('vat_type');
    $pathText = ezpI18n::tr('kernel/shop/editvatrule', 'Edit VAT charging rule');
} else {
    $tplVatRule = null;
    $tplCountry = false;
    $tplVatTypeID = false;
    $tplCategoryIDs = array();
    $pathText = ezpI18n::tr('kernel/shop/editvatrule', 'Create new VAT charging rule');
}
if ($errors !== false) {
    $tplCountry = $chosenCountry;
    $tplCategoryIDs = $chosenCategories;
    $tplVatTypeID = $chosenVatType;
}
$vatTypes = eZVatType::fetchList(true, true);
$tpl = eZTemplate::factory();
$tpl->setVariable('error_header', $errorHeader);
$tpl->setVariable('errors', $errors);
$tpl->setVariable('all_vat_types', $vatTypes);
$tpl->setVariable('all_product_categories', $productCategories);
$tpl->setVariable('rule', $tplVatRule);
$tpl->setVariable('country_code', $tplCountry);
$tpl->setVariable('category_ids', $tplCategoryIDs);
$tpl->setVariable('vat_type_id', $tplVatTypeID);
$Result = array();
$Result['content'] = $tpl->fetch("design:shop/editvatrule.tpl");
$Result['path'] = array(array('text' => $pathText, 'url' => false));