/**
  * @ a description for the function TemplateFiller->.
  */
 function TemplateFiller($path_templates_dir = null)
 {
     parent::TmplIncluder();
     global $application;
     if ($path_templates_dir != null) {
         $this->TemplateDirPrefix = $path_templates_dir;
     }
     $this->MessageResources =& $application->getInstance('MessageResources');
     $this->prepared_template_cache = CCacheFactory::getCache('temporary', __CLASS__);
     if (!$this->www_address) {
         $this->www_address = $application->getAppIni('HTTP_URL');
         if ($application->getCurrentProtocol() == "https" && $application->getAppIni('HTTPS_URL')) {
             $this->www_address = $application->getAppIni('HTTPS_URL');
         }
     }
     if (!$this->templates_url) {
         //            $this->templates_url = $application->getAppIni('URL_THEME');
         $this->templates_url = $application->getAppIni('URL_TEMPLATES');
         if ($application->getCurrentProtocol() == "https" && $application->getAppIni('HTTPS_URL_TEMPLATES')) {
             $this->templates_url = $application->getAppIni('HTTPS_URL_TEMPLATES');
         }
     }
     if (!$this->site_url) {
         $this->site_url = $application->getAppIni('SITE_URL');
         if ($application->getCurrentProtocol() == "https" && $application->getAppIni('SITE_HTTPS_URL')) {
             $this->site_url = $application->getAppIni('SITE_HTTPS_URL');
         }
     }
 }
예제 #2
0
 /**
  * This function calculates hash from checkout form fields array.
  * @author Andrei V. Zhuravlev
  *
  */
 function updateCheckoutFormHash()
 {
     global $application;
     $tables = $this->getTables();
     $pa = $tables['person_attributes']['columns'];
     $piva = $tables['person_info_variants_to_attributes']['columns'];
     $s = new DB_Select();
     $s->addSelectTable('person_attributes');
     $s->addSelectTable('person_info_variants_to_attributes');
     $s->WhereField($piva['attribute_id'], DB_EQ, $pa['id']);
     $checkout_data = $application->db->getDB_Result($s);
     //query fields
     $hash = md5(serialize($checkout_data));
     /*$tables = Configuration::getTables();
             $ss = $tables['store_settings']['columns'];
     
             $u = new DB_Update('store_settings');
             $u->addUpdateValue('variable_value',$hash);
             $u->WhereValue('variable_name', DB_EQ, SYSCONFIG_CHECKOUT_FORM_HASH);
             $application->db->getDB_Result($u);*/
     $cache = CCacheFactory::getCache('hash');
     $cache->write(SYSCONFIG_CHECKOUT_FORM_HASH, $hash);
     return $hash;
 }
 function CQueryExecuter()
 {
     global $application;
     $this->cache = CCacheFactory::getCache('database');
 }
 /**
  *  Flatten layout data of specified page into 2D KV data
  *  @param $page Page name
  */
 function getPageMap($page)
 {
     global $application;
     $fb = modApiFunc('Look_Feel', 'isFacebook') ? '.fb' : '';
     $theme = modApiFunc('Look_Feel', 'getCurrentSkin');
     $cache = CCacheFactory::getCache('persistent', 'page_manager');
     $cached_map = $cache->read(md5($theme . $page . $fb));
     if ($cached_map !== null) {
         return $cached_map;
     }
     $map = array();
     $layout = $this->getLayoutTmpl($theme, $page, null, true);
     foreach ($layout['settings'] as $set) {
         $map[$set['name']] = $this->_desanitize_tags($set['content']);
     }
     foreach ($layout['rows'] as $row) {
         switch ($row['name']) {
             case 'header':
             case 'main_menu':
             case 'footer':
             case 'topslideshow':
                 $PHdata = $row['data']['placeholders'][0]['data'];
                 if (empty($PHdata['blocks']) || !is_array($PHdata['blocks'])) {
                     continue;
                 }
                 foreach ($PHdata['blocks'] as $block) {
                     if (empty($block['name'])) {
                         continue;
                     }
                     $map[$block['name']] = '';
                     if ($block['visibility'] == 'visible' && $PHdata['visibility'] == 'visible') {
                         $InfoBlock = $this->getBlockInfo($block['name'], $page);
                         $map[$block['name']] = $this->_unquote($InfoBlock['template']);
                     }
                 }
                 break;
             case 'main_content':
             default:
                 foreach ($row['data']['placeholders'] as $PH) {
                     $map[$PH['name']] = '';
                     if (empty($PH['data']['visibility']) || $PH['data']['visibility'] != 'visible' || empty($PH['data']['blocks']) || !is_array($PH['data']['blocks'])) {
                         continue;
                     }
                     foreach ($PH['data']['blocks'] as $block) {
                         if ($block['visibility'] == 'visible') {
                             $InfoBlock = $this->getBlockInfo($block['name'], $page);
                             $map[$PH['name']] .= $this->_unquote($InfoBlock['template']);
                         }
                     }
                 }
                 break;
         }
     }
     $cache->write(md5($theme . $page . $fb), $map);
     return $map;
 }
예제 #5
0
 /**
  * Initializes the session: e.g. retrieves session data from the database.
  */
 function start($sid = "")
 {
     global $zone, $application;
     $drop_session_cookie = false;
     if ($zone == "AdminZone") {
         ini_set("session.cookie_lifetime", 0);
         session_name("AZSESSID");
         if ($application->db->DB_isTableExists($application->getAppIni('DB_TABLE_PREFIX') . "settings") != null) {
             $duration_cfg = (int) modApiFunc("Settings", "getParamValue", "ADMIN_SESSION_DURATION", "ADM_SESSION_DURATION_VALUE");
         } else {
             $duration_cfg = 3600;
         }
         $ClientSessionLifetime = $duration_cfg;
     } else {
         if (isset($_COOKIE['save_session']) && $_COOKIE['save_session'] == "save") {
             if ($application->db->DB_isTableExists($application->getAppIni('DB_TABLE_PREFIX') . "settings") != null) {
                 $cz_duration_cfg = (int) modApiFunc("Settings", "getParamValue", "CUSTOMER_ACCOUNT_SETTINGS", "CUSTOMER_SESSION_DURATION_VALUE");
             } else {
                 $cz_duration_cfg = 3600 * 24 * 30;
                 //30 days
             }
             ini_set("session.cookie_lifetime", $cz_duration_cfg);
             ini_set("session.gc_maxlifetime", $cz_duration_cfg);
         } else {
             ini_set("session.cookie_lifetime", 0);
             #ini_set("session.gc_maxlifetime",  0);
             $drop_session_cookie = true;
         }
         session_name("CZSESSID");
     }
     if ($sid) {
         session_id($sid);
     }
     $session_save_handler = $application->getAppIni('SESSION_SAVE_HANDLER');
     if ($session_save_handler == 'DB') {
         // redefine session handler
         __set_session_db_handler();
     } elseif ($session_save_handler != 'PHP_INI') {
         ini_set("session.save_handler", $session_save_handler);
     }
     $session_save_path = $application->getAppIni('SESSION_SAVE_PATH');
     if ($session_save_path == 'AVACTIS_CACHE_DIR') {
         session_save_path($application->getAppIni("PATH_CACHE_DIR"));
     } elseif ($session_save_path != 'PHP_INI') {
         session_save_path($session_save_path);
     }
     session_start();
     global $application;
     $HTTP_URL = md5($application->getAppIni('HTTP_URL'));
     if (!isset($_COOKIE['HTTP_URL'])) {
         setcookie('HTTP_URL', $HTTP_URL, time());
     } elseif ($_COOKIE['HTTP_URL'] != $HTTP_URL) {
         setcookie('HTTP_URL', $HTTP_URL, time());
         session_destroy();
         if ($session_save_handler == 'DB') {
             // redefine session handler (http://bugs.php.net/bug.php?id=32330)
             // redefine session handler
             __set_session_db_handler();
         }
         session_start();
     }
     if ($zone == "CustomerZone") {
         $sess = session_get_cookie_params();
         if ($drop_session_cookie) {
             $t = 0;
         } else {
             $t = time() + $sess['lifetime'];
         }
         setcookie(session_name(), session_id(), $t, '/');
         if ($application->getCurrentProtocol() == 'http') {
             $temp_url = $application->getAppIni('SITE_HTTPS_URL');
         } else {
             $temp_url = $application->getAppIni('SITE_URL');
         }
         $temp_url = parse_url($temp_url);
         if (isset($temp_url['host'])) {
             setcookie(session_name(), session_id(), $t, '/', $temp_url['host']);
         }
     }
     //
     //                                   ,                                   .
     //        ,                   .
     //         ,                                ,                   .
     //                                                                  .
     //                          IP                             .
     //                                                                  .
     //                                                   .
     //
     $CURRENT_PRODUCT_VERSION = PRODUCT_VERSION;
     $current_hash = "";
     if ($zone != "AdminZone") {
         loadModuleFile('configuration/const.php');
         /*_use(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'configuration'.DIRECTORY_SEPARATOR.'configuration_api.php');
         
                     $tables = Configuration::getTables();
                     $ss = $tables['store_settings']['columns'];
         
                     $s = new DB_Select();
                     $s->addSelectTable('store_settings');
                     $s->addSelectValue('variable_value','value');
                     $s->WhereValue($ss['name'], DB_EQ, SYSCONFIG_CHECKOUT_FORM_HASH);
                     $v = $application->db->getDB_Result($s);
                     $current_hash = $v[0]['value'];*/
         $cache = CCacheFactory::getCache('hash');
         $current_hash = $cache->read(SYSCONFIG_CHECKOUT_FORM_HASH);
     }
     $current_ips = getClientIPs();
     if (!array_key_exists('PRODUCT_VERSION', $_SESSION) || $_SESSION['PRODUCT_VERSION'] != $CURRENT_PRODUCT_VERSION && $zone != "AdminZone" || (!array_key_exists(SYSCONFIG_CHECKOUT_FORM_HASH, $_SESSION) || $current_hash != $_SESSION[SYSCONFIG_CHECKOUT_FORM_HASH] && $zone != "AdminZone")) {
         if (!empty($_SESSION['CartContent']) && is_array($_SESSION['CartContent'])) {
             foreach ($_SESSION['CartContent'] as $cart_id => $cart_content) {
                 modApiFunc('Cart', 'removeGCfromDB', $cart_content['product_id']);
             }
         }
         //see this::session_clean1()
         session_unset();
         session_destroy();
         if ($session_save_handler == 'DB') {
             // redefine session handler (http://bugs.php.net/bug.php?id=32330)
             // redefine session handler
             __set_session_db_handler();
         }
         session_start();
     }
     $_SESSION['PRODUCT_VERSION'] = $CURRENT_PRODUCT_VERSION;
     $_SESSION[SYSCONFIG_CHECKOUT_FORM_HASH] = $current_hash;
     $_SESSION['REMOTE_ADDR'] = $current_ips;
     $_SESSION['HTTP_USER_AGENT'] = @$_SERVER['HTTP_USER_AGENT'];
     //
     foreach ($_SESSION as $key => $val) {
         $this->keyvalList[$key] = $val;
         //            $this->set($key, $val);
     }
     $this->started = TRUE;
     if ($zone == "AdminZone") {
         if (!$this->is_Set('ClientSessionLifetime')) {
             $this->set('ClientSessionLifetime', time());
         } else {
             $delta_time = time() - $this->get('ClientSessionLifetime');
             if ($delta_time > $ClientSessionLifetime && $ClientSessionLifetime != 0) {
                 $this->un_Set('currentUserID');
             }
             $this->set('ClientSessionLifetime', time());
         }
     }
 }
예제 #6
0
 /**
  * Divides cart into orders
  * Note: currently the function is turned off...
  */
 function buildOrders($throw_event = true)
 {
     global $application;
     $this->CartOrders = array();
     // paranoidal check...
     if (!is_array($this->CartContent)) {
         modApiFunc('Session', 'set', 'CartOrders', array());
         return;
     }
     $this->CartOrders[0] = array('Products' => array(), 'Content' => array(), 'Totals' => $this->getInitialTotals(), 'Entry' => 0, 'Lang' => modApiFunc('MultiLang', 'getLanguage'), 'Protocol' => $application->getCurrentProtocol());
     $this->CartOrders[0]['Products'] = $this->CartContent;
     // here we have cart divided...
     // calculating the order totals...
     foreach ($this->CartOrders as $k => $v) {
         $this->buildOrder($k);
     }
     // saving the result in the session
     modApiFunc('Session', 'set', 'CartOrders', $this->CartOrders);
     $this->buildDetailedCartContent();
     $taxes = modApiFunc('Taxes', 'getTax');
     foreach ($this->CartOrders as $k => $v) {
         $this->buildOrderTaxes($k, $taxes);
     }
     $this->buildDetailedCartContent();
     // saving the result in the session
     modApiFunc('Session', 'set', 'CartOrders', $this->CartOrders);
     if ($throw_event) {
         modApiFunc('EventsManager', 'throwEvent', 'CartChanged');
     }
     $cache = CCacheFactory::getCache('temporary');
     $cache->write('cart_content_hash', md5(serialize($this->CartContent)));
 }
예제 #7
0
 /**
  * Changes the storefront skin
  */
 function changeSkin($skin)
 {
     if ($this->checkSkin($skin)) {
         modApiFunc('Configuration', 'setValue', array(STOREFRONT_ACTIVE_SKIN => $skin));
         global $application;
         $cache = CCacheFactory::getCache('persistent', 'page_manager');
         $cache->erase();
         return $skin;
     }
     return '';
 }
예제 #8
0
 /**
  *                   $this->TaxDebug:
  * $this->TaxDebug = array(
  *                          "ProductsList" => array(
  *                                                  "0" => array(
  *                                                               "ID" => 1,
  *                                                               "Quantity_In_Cart" => 1,
  *                                                               "attributes" => array(
  *                                                                                     "SalePrice"     => array(
  *                                                                                                        "value"=>$CartItemSalePrice
  *                                                                                                             ),
  *                                                                                     "ShippingPrice" => array(
  *                                                                                                        "value"=>$ShippingPrice
  *                                                                                                             ),
  *                                                                                     "TaxClass"      => array(
  *                                                                                                        "value"=>$ProductTaxClass
  *                                                                                                             ),
  *                                                                                    ),
  *                                                                "CartItemSalePrice" => $CartItemSalePrice
  *                                                              )
  *                                                 ),
  *                          "AddressesList"=> array(
  *                                                  "1" => array(//ShippingAddress
  *                                                                             "CountryId" => $sa_c_id,
  *                                                                             "StateId"   => $sa_s_id
  *                                                                            ),
  *                                                  "2" => array(//CustomerAddress
  *                                                                             "CountryId" => $ca_c_id,
  *                                                                             "StateId"   => $ca_s_id
  *                                                                            ),
  *                                                  "3" => array(//BillingAddress
  *                                                                             "CountryId" => $ba_c_id,
  *                                                                             "StateId"   => $ba_s_id
  *                                                                            )
  *                                                 )
  *                        );
  */
 function getTax($included_only = false, $debug = false, $trace = false, $symbolic = false, $use_default_address_for_not_included_taxes = false)
 {
     static $__cache__ = array();
     global $application;
     $cache = CCacheFactory::getCache('temporary');
     $cart_content_hash = $cache->read('cart_content_hash');
     $__cache_key__ = md5($cart_content_hash . serialize($included_only) . serialize($debug) . serialize($trace) . serialize($symbolic) . serialize($use_default_address_for_not_included_taxes));
     if (isset($__cache__[$__cache_key__])) {
         // disabled due to http://projects.simbirsoft.com/issues/1391
         //return $__cache__[$__cache_key__];
     }
     //$fake_parameter_this_tax_debug = $this -> TaxDebug;
     $currency_id = modApiFunc("Localization", "getMainStoreCurrency");
     $TaxNames = modApiFunc("Taxes", "getTaxNames");
     if ($debug) {
         $ProductsList = $this->TaxDebug["ProductsList"];
         $CartSubtotal = $this->TaxDebug["CartSubtotal"];
         $OrderLevelShippingCost = $this->TaxDebug["OrderLevelShippingCost"];
         $TotalShippingCost = $OrderLevelShippingCost;
         $OrderLevelDiscount = $this->TaxDebug["OrderLevelDiscount"];
         $TotalDiscount = $OrderLevelDiscount;
         foreach ($this->TaxDebug["ProductsList"] as $productInfo) {
             $TotalShippingCost += $productInfo["Quantity_In_Cart"] * ($productInfo["attributes"]["PerItemShippingCost"]["value"] + $productInfo["attributes"]["PerItemHandlingCost"]["value"]);
             $TotalDiscount += $productInfo["Quantity_In_Cart"] * $productInfo["PerItemDiscount"];
         }
         $ShippingMethod = $this->TaxDebug["ShippingMethod"];
         $AddressesList = $this->TaxDebug["AddressesList"];
     } else {
         $ProductsList = modApiFunc("Cart", "getCartContentExt");
         #12.01 $CartSubtotal = modApiFunc("Cart", "getCartSubtotal");
         $CartSubtotal = modApiFunc("Cart", "getCartSubtotalExcludingTaxes");
         $ShippingMethod = modApiFunc("Checkout", "getChosenShippingModuleIdCZ");
         $TotalShippingCost = modApiFunc("Checkout", "getOrderPrice", "TotalShippingAndHandlingCost", $currency_id);
         $OrderLevelShippingCost = $TotalShippingCost - modApiFunc("Checkout", "getOrderPrice", "PerItemShippingCostSum", $currency_id) - modApiFunc("Checkout", "getOrderPrice", "PerItemHandlingCostSum", $currency_id);
         if ($OrderLevelShippingCost < 0) {
             $OrderLevelShippingCost = 0;
         }
         $OrderLevelDiscount = COMPUTATION_POSTPONED;
         $TotalDiscount = COMPUTATION_POSTPONED;
         $ShippingInfo = modApiFunc("Checkout", "getPrerequisiteValidationResults", "shippingInfo");
         $BillingInfo = modApiFunc("Checkout", "getPrerequisiteValidationResults", "billingInfo");
         $StoreOwnerInfo = modApiFunc("Checkout", "getPrerequisiteValidationResults", "storeOwnerInfo");
         //                          Checkout::storeOwnerInfo                isMet
         //                -               storeOwnerInfo          -                            ,
         //                      ?
         $store_owner_country = modApiFunc('Configuration', 'getValue', SYSCONFIG_STORE_OWNER_COUNTRY);
         $store_owner_state = modApiFunc('Configuration', 'getValue', SYSCONFIG_STORE_OWNER_STATE);
         $b_store_owner_address_correct = is_numeric($store_owner_country) && is_numeric($store_owner_state);
         $AddressesList = array("0" => !$b_store_owner_address_correct ? null : array("CountryId" => $store_owner_country, "StateId" => $store_owner_state), "1" => $ShippingInfo["isMet"] == false ? !$b_store_owner_address_correct || !$use_default_address_for_not_included_taxes ? null : array("CountryId" => $store_owner_country, "StateId" => $store_owner_state) : array("CountryId" => isset($ShippingInfo["validatedData"]["Country"]["value"]) ? $ShippingInfo["validatedData"]["Country"]["value"] : 0, "StateId" => empty($ShippingInfo["validatedData"]["Statemenu"]["value"]) ? STATE_ID_ALL : $ShippingInfo["validatedData"]["Statemenu"]["value"]), "2" => $BillingInfo["isMet"] == false ? !$b_store_owner_address_correct || !$use_default_address_for_not_included_taxes ? null : array("CountryId" => $store_owner_country, "StateId" => $store_owner_state) : array("CountryId" => isset($BillingInfo["validatedData"]["Country"]["value"]) ? $BillingInfo["validatedData"]["Country"]["value"] : 0, "StateId" => empty($BillingInfo["validatedData"]["Statemenu"]["value"]) ? STATE_ID_ALL : $BillingInfo["validatedData"]["Statemenu"]["value"]), TAXES_STORE_OWNER_ADDRESS_ID . "" => $StoreOwnerInfo["isMet"] == false ? !$b_store_owner_address_correct || !$use_default_address_for_not_included_taxes ? null : array("CountryId" => $store_owner_country, "StateId" => $store_owner_state) : array("CountryId" => isset($StoreOwnerInfo["validatedData"]["Country"]["value"]) ? $StoreOwnerInfo["validatedData"]["Country"]["value"] : 0, "StateId" => empty($StoreOwnerInfo["validatedData"]["Statemenu"]["value"]) ? STATE_ID_ALL : $StoreOwnerInfo["validatedData"]["Statemenu"]["value"]));
     }
     if (sizeof($ProductsList) > 0) {
         #Gets the Product Tax Class array
         $ProductTaxClassArray = array();
         #A products( of each type) array
         $productsQuantity = array();
         foreach ($ProductsList as $ProductInfo) {
             if (!in_array($ProductInfo["attributes"]["TaxClass"]["value"], $ProductTaxClassArray)) {
                 $ProductTaxClassArray[] = $ProductInfo["attributes"]["TaxClass"]["value"] ? $ProductInfo["attributes"]["TaxClass"]["value"] : 1;
             }
             $productsQuantity[$ProductInfo["CartID"]] = $ProductInfo["Quantity_In_Cart"];
         }
         /*
                     if(!in_array(1, $ProductTaxClassArray))
                     {
                         $ProductTaxClassArray[] = 1;
                     }*/
         #Gets an Address array
         $AddressArray = array("CountryId" => array(), "StateId" => array());
         foreach ($AddressesList as $AddressInfo) {
             if ($AddressInfo) {
                 if (!in_array($AddressInfo["CountryId"], $AddressArray["CountryId"])) {
                     $AddressArray["CountryId"][] = $AddressInfo["CountryId"];
                 }
                 if (!in_array($AddressInfo["StateId"], $AddressArray["StateId"])) {
                     $AddressArray["StateId"][] = $AddressInfo["StateId"];
                 }
             }
         }
         if (!in_array((int) 0, $AddressArray["StateId"])) {
             $AddressArray["StateId"][] = (int) 0;
         }
         if (sizeof($AddressArray["CountryId"]) == 0) {
             $AddressArray["CountryId"][] = (int) 0;
         }
         #Gets a list of applicable tax rates
         $ApplicableTaxes = array();
         $TaxRatesList = $this->getApplicableTaxRates($ProductTaxClassArray, $AddressArray);
         //            if ($trace)
         //            {
         //
         //                $TraceInfo = array(
         //                                    "ProductList" => $ProductsList
         //                                   ,"ProductTaxClassArray" => $ProductTaxClassArray
         //                                   ,"AddressesList"         => $AddressesList
         //                                   ,"TaxRatesList"         => $TaxRatesList
         //                                  );
         //                $this->addTraceInfo("1", $TraceInfo);
         //            }
         $Taxes = $this->getTaxes($included_only);
         foreach ($TaxRatesList as $TaxRateInfo) {
             if (isset($Taxes[$TaxRateInfo['TaxNameId']])) {
                 $Taxes[$TaxRateInfo['TaxNameId']]["applicable"] = true;
             }
         }
         if ($included_only === true) {
             //                    :
             $TaxRatesList_new = array();
             foreach ($TaxRatesList as $TaxRateInfo) {
                 if (isset($Taxes[$TaxRateInfo['TaxNameId']])) {
                     $TaxRatesList_new[] = $TaxRateInfo;
                 }
             }
             $TaxRatesList = $TaxRatesList_new;
         }
         //            if ($trace)
         //            {
         //                $TraceInfo = array(
         //                                    "TaxesArray" => $Taxes
         //                                  );
         //                $this->addTraceInfo("2", $TraceInfo);
         //            }
         /*
                               $TaxAmounts
             $TaxAmounts = array(
                                 "products" => array(
                                                     "ProdId1" = array(
                                                                      "TaxId1" => $amount1,
                                                                      "TaxId2" => $amount2,
                                                                      ...
                                                                      ),
                                                     "ProdId2" = array(
                                                                      "TaxId1" => $amount3,
                                                                      "TaxId2" => $amount4,
                                                                      ...
                                                                      ),
                                                    ),
                                 "TaxSubtotalAmount" = array(
                                                            "TaxId1" => $amount1 + $amount3 + ...,
                                                            "TaxId2" => $amount2 + $amount4 + ...,
                                                             ...
                                                            ),
                                 "TaxSubtotalAmountView" => array(), -                     Tax Display Options
                                 "TaxTotalAmount" => sum(TaxSubtotalAmount)
                                );
         */
         $thisTaxAmounts = array("products" => array(), "tax_on_shipping" => true, "TaxSubtotalAmount" => array(), "TaxSubtotalAmountView" => array(), "TaxTotalAmount" => (int) PRICE_N_A, "IncludedTaxTotalAmount" => (int) PRICE_N_A);
         #Calculate the tax
         foreach ($Taxes as $TaxId => $TaxInfo) {
             $thisTaxAmounts["TaxSubtotalAmount"][$TaxId] = (int) PRICE_N_A;
             $retval = $this->calculateTax($thisTaxAmounts, $Taxes, $TaxId, $TaxRatesList, $AddressesList, $ProductsList, $CartSubtotal, $OrderLevelShippingCost, $TotalShippingCost, $ShippingMethod, $OrderLevelDiscount, $TotalDiscount, $currency_id, $debug, $trace, $symbolic, NULL);
             //$flag);
             if ($retval == "fatal") {
                 return $thisTaxAmounts;
             }
         }
         $CartIDs = array();
         foreach ($ProductsList as $info) {
             $CartIDs[] = "" . $info['CartID'];
         }
         foreach ($thisTaxAmounts["products"] as $prodId => $taxAmountInfo) {
             //PATCH: :             .        calculateTax                   $this->TaxAmounts["products"]
             //          ,               $ProductsList,        .                          .
             if (!in_array("" . $prodId, $CartIDs)) {
                 continue;
             }
             //print prepareArrayDisplay($prodId);
             //print prepareArrayDisplay($taxAmountInfo);
             //$i = 1;
             //print $i.' '.prepareArrayDisplay($thisTaxAmounts["TaxTotalAmount"]);
             foreach ($taxAmountInfo as $taxId => $taxAmount) {
                 //$i++;
                 if (is_array($taxAmount)) {
                     continue;
                 }
                 if ($taxAmount == PRICE_N_A) {
                     //                    $this->TaxAmounts["TaxTotalAmount"] = (int)PRICE_N_A;
                     continue;
                 }
                 if ($thisTaxAmounts["TaxSubtotalAmount"][$taxId] == PRICE_N_A) {
                     $thisTaxAmounts["TaxSubtotalAmount"][$taxId] = 0;
                 }
                 if ($thisTaxAmounts["IncludedTaxTotalAmount"] == PRICE_N_A) {
                     $thisTaxAmounts["IncludedTaxTotalAmount"] = 0;
                 }
                 if ($thisTaxAmounts["TaxTotalAmount"] == PRICE_N_A) {
                     $thisTaxAmounts["TaxTotalAmount"] = 0;
                 }
                 if (!isset($productsQuantity[$prodId])) {
                 }
                 $thisTaxAmounts["TaxSubtotalAmount"][$taxId] += modApiFunc("Localization", "roundMonetaryUnit", $productsQuantity[$prodId] * $taxAmount);
                 if ($TaxNames[$taxId]["included_into_price"] == "true") {
                     $thisTaxAmounts["IncludedTaxTotalAmount"] += modApiFunc("Localization", "roundMonetaryUnit", $productsQuantity[$prodId] * $taxAmount);
                 }
                 $thisTaxAmounts["TaxTotalAmount"] += modApiFunc("Localization", "roundMonetaryUnit", $productsQuantity[$prodId] * $taxAmount);
                 //print $i.' '.prepareArrayDisplay($thisTaxAmounts["TaxTotalAmount"]);
             }
             //print prepareArrayDisplay($thisTaxAmounts["TaxTotalAmount"]);
         }
     } else {
         $Taxes = $this->getTaxes();
         $TaxSubtotalAmount = array();
         foreach ($Taxes as $TaxId => $TaxInfo) {
             $TaxSubtotalAmount[$TaxId] = (int) PRICE_N_A;
         }
         $thisTaxAmounts = array("products" => array(), "tax_on_shipping" => true, "TaxSubtotalAmount" => $TaxSubtotalAmount, "TaxSubtotalAmountView" => array(), "TaxTotalAmount" => (int) PRICE_N_A);
     }
     $replace = array();
     foreach ($thisTaxAmounts["TaxSubtotalAmount"] as $taxId => $taxAmount) {
         $replace["{" . $taxId . "}"] = $taxAmount;
     }
     $DisplayOptions = $this->getTaxDisplayOptionsList();
     //                      included       ,
     //            .
     if ($included_only === true) {
         $DisplayOptions_new = array();
         foreach ($DisplayOptions as $tdo) {
             if (isset($Taxes[$tdo['Id']])) {
                 $DisplayOptions_new[] = $tdo;
             }
         }
         $DisplayOptions = $DisplayOptions_new;
     }
     foreach ($DisplayOptions as $DisplayOptionInfo) {
         if ($DisplayOptionInfo['tdoId'] != 3) {
             $_replace = $replace;
             if ($DisplayOptionInfo['tdoId'] == 1) {
                 foreach ($replace as $taxIdTag => $TaxAmount) {
                     if (!(_ml_strpos($DisplayOptionInfo['Formula'], $taxIdTag) === false) && $TaxAmount != PRICE_N_A) {
                         foreach ($_replace as $taxIdTag => $TaxAmount) {
                             if ($TaxAmount == PRICE_N_A) {
                                 $_replace[$taxIdTag] = 0;
                             }
                         }
                         break;
                     }
                 }
             }
             $is_included = false;
             $this_one_is_included = false;
             foreach ($thisTaxAmounts["TaxSubtotalAmount"] as $taxId => $taxAmount) {
                 if (!(_ml_strpos($DisplayOptionInfo['Formula'], "{" . $taxId . "}") === false)) {
                     $this_one_is_included = $Taxes[$taxId]["included_into_price"];
                 }
             }
             $DisplayOptionInfo['Formula'] = strtr($DisplayOptionInfo['Formula'], $_replace);
             if (_ml_strpos($DisplayOptionInfo['Formula'], sprintf("%d", PRICE_N_A)) === false) {
                 $TaxAmount = eval("return " . $DisplayOptionInfo['Formula'] . ";");
             } else {
                 $TaxAmount = (int) PRICE_N_A;
             }
             if (!($TaxAmount == PRICE_N_A && $DisplayOptionInfo['tdoId'] == 2)) {
                 $thisTaxAmounts["TaxSubtotalAmountView"][] = array("id" => $DisplayOptionInfo["Id"], 'view' => prepareHTMLDisplay($DisplayOptionInfo['View']), 'value' => $TaxAmount, "is_included" => $this_one_is_included);
             }
         }
     }
     $__cache__[$__cache_key__] = $thisTaxAmounts;
     return $thisTaxAmounts;
 }
예제 #9
0
 function CSV_Dynamic_Writer($uid)
 {
     $this->__uid = md5($uid);
     $this->__cache = CCacheFactory::getCache('persistent', $this->__uid);
     if (null === ($this->__csv_headers = $this->__cache->read('headers'))) {
         $this->__csv_headers = array();
     }
     if (null === ($this->__counter = $this->__cache->read('counter'))) {
         $this->__counter = 1;
     }
     $this->csv_delimitr = ';';
 }