function init_catalog_old($jsName, $containerId, $selectCallback, $categories, $products) { echo '<script type="text/javascript" src="inc/catalog-old.js"></script>'; echo '<script type="text/javascript">'; echo "var {$jsName} = new Catalog(\"{$containerId}\", \"{$selectCallback}\");\n"; echo "jQuery(document).ready(function() {\n"; echo "var html = \"<div class=\\\"catalog-categories-container\\\"></div>\";\n"; echo "html += \"<div class=\\\"catalog-products-container\\\"></div>\";\n"; echo "jQuery(\"#{$containerId}\").html(html);\n"; foreach ($categories as $cat) { echo $jsName . ".createCategory(\"" . $jsName . "\", \"" . $cat->id . "\"" . ", \"" . $cat->label . "\", " . ($cat->hasImage ? "true" : "false") . ");\n"; } foreach ($products as $product) { $taxCat = TaxesService::get($product->taxCatId); $tax = $taxCat->getCurrentTax(); $vatPrice = $product->priceSell * (1 + $tax->rate); $prd = '{' . jsonify("id", $product->id) . ', ' . jsonify("label", $product->label) . ', ' . jsonify("reference", $product->reference) . ', ' . jsonify("hasImage", $product->hasImage) . ', ' . jsonify("buy", $product->priceBuy) . ', ' . jsonify("sell", $product->priceSell) . ', ' . jsonify("vatSell", $vatPrice) . '}'; echo $jsName . ".addProductToCat(\"" . $product->id . "\", \"" . $product->categoryId . "\");\n"; echo $jsName . ".addProduct(" . $prd . ");\n"; } if (count($categories) > 0) { echo $jsName . ".changeCategory(\"" . $categories[0]->id . "\");\n"; } echo "});\n</script>"; }
function getTotalPrice() { $taxCat = TaxesService::get($this->taxCatId); $currentTax = $this->taxCat->getCurrentTax(); if ($currentTax != null) { return $this->priceSell * (1 + $currentTax->rate); } else { return $this->priceSell; } }
protected function proceed() { switch ($this->action) { case 'get': $this->succeed(TaxesService::get($this->params['id'])); break; case 'getAll': $this->succeed(TaxesService::getAll()); break; } }