Merge branch 'master' of https://github.com/thelia/thelia into coupon
# By Etienne Roudeix (7) and Manuel Raynaud (7) # Via Etienne Roudeix (2) and Manuel Raynaud (1) * 'master' of https://github.com/thelia/thelia: tax in loops remove test finish simple list customer page in backoffice debug bar mock getTotalAmoutn in order class tax engine escae output only if it's not an object tax faker insert 19.6 tva create admin customer view and add output info in customer loop update format smarty plugin tax engine model tax engine model create customer admin controller and index controller
This commit is contained in:
@@ -87,7 +87,7 @@ class Address extends BaseLoop
|
||||
$customer = $this->getCustomer();
|
||||
|
||||
if ($customer === 'current') {
|
||||
$currentCustomer = $this->request->getSession()->getCustomerUser();
|
||||
$currentCustomer = $this->securityContext->getCustomerUser();
|
||||
if ($currentCustomer === null) {
|
||||
return new LoopResult();
|
||||
} else {
|
||||
|
||||
@@ -64,6 +64,7 @@ class Customer extends BaseLoop
|
||||
)
|
||||
),
|
||||
Argument::createBooleanTypeArgument('reseller'),
|
||||
Argument::createBooleanTypeArgument('last_order'),
|
||||
Argument::createIntTypeArgument('sponsor')
|
||||
);
|
||||
}
|
||||
@@ -80,7 +81,7 @@ class Customer extends BaseLoop
|
||||
$current = $this->getCurrent();
|
||||
|
||||
if ($current === true) {
|
||||
$currentCustomer = $this->request->getSession()->getCustomerUser();
|
||||
$currentCustomer = $this->securityContext->getCustomerUser();
|
||||
if ($currentCustomer === null) {
|
||||
return new LoopResult();
|
||||
} else {
|
||||
@@ -130,6 +131,20 @@ class Customer extends BaseLoop
|
||||
$loopResultRow->set("SPONSOR", $customer->getSponsor());
|
||||
$loopResultRow->set("DISCOUNT", $customer->getDiscount());
|
||||
|
||||
$lastOrderDate = "";
|
||||
$lastOrderAmount = "";
|
||||
|
||||
if ($this->getLastOrder()) {
|
||||
$order = $customer->getOrders()->getFirst();
|
||||
if ($order) {
|
||||
$lastOrderDate = $order->getCreatedAt();
|
||||
$lastOrderAmount = $order->getTotalAmount();
|
||||
}
|
||||
}
|
||||
|
||||
$loopResultRow->set("LASTORDER_DATE", $lastOrderDate);
|
||||
$loopResultRow->set("LASTORDER_AMOUNT", $lastOrderAmount);
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\Map\FeatureProductTableMap;
|
||||
use Thelia\Model\Map\ProductPriceTableMap;
|
||||
use Thelia\Model\Map\ProductSaleElementsTableMap;
|
||||
@@ -333,10 +334,10 @@ class Product extends BaseI18nLoop
|
||||
foreach($isProductPriceLeftJoinList as $pSE => $isProductPriceLeftJoin) {
|
||||
$booleanMatchedPriceList[] = 'CASE WHEN `' . $pSE . '`.PROMO=1 THEN `' . $isProductPriceLeftJoin . '`.PROMO_PRICE ELSE `' . $isProductPriceLeftJoin . '`.PRICE END';
|
||||
}
|
||||
$search->withColumn('MAX(' . implode(' OR ', $booleanMatchedPromoList) . ')', 'main_product_is_promo');
|
||||
$search->withColumn('MAX(' . implode(' OR ', $booleanMatchedNewnessList) . ')', 'main_product_is_new');
|
||||
$search->withColumn('MAX(' . implode(' OR ', $booleanMatchedPriceList) . ')', 'real_highest_price');
|
||||
$search->withColumn('MIN(' . implode(' OR ', $booleanMatchedPriceList) . ')', 'real_lowest_price');
|
||||
$search->withColumn('ROUND(MAX(' . implode(' OR ', $booleanMatchedPromoList) . '), 2)', 'main_product_is_promo');
|
||||
$search->withColumn('ROUND(MAX(' . implode(' OR ', $booleanMatchedNewnessList) . '), 2)', 'main_product_is_new');
|
||||
$search->withColumn('ROUND(MAX(' . implode(' OR ', $booleanMatchedPriceList) . '), 2)', 'real_highest_price');
|
||||
$search->withColumn('ROUND(MIN(' . implode(' OR ', $booleanMatchedPriceList) . '), 2)', 'real_lowest_price');
|
||||
|
||||
|
||||
$current = $this->getCurrent();
|
||||
@@ -509,6 +510,12 @@ class Product extends BaseI18nLoop
|
||||
foreach ($products as $product) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $product, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$price = $product->getRealLowestPrice();
|
||||
$taxedPrice = $product->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
|
||||
|
||||
$loopResultRow->set("ID", $product->getId())
|
||||
->set("REF",$product->getRef())
|
||||
->set("IS_TRANSLATED",$product->getVirtualColumn('IS_TRANSLATED'))
|
||||
@@ -518,7 +525,9 @@ class Product extends BaseI18nLoop
|
||||
->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("URL", $product->getUrl($locale))
|
||||
->set("BEST_PRICE", $product->getVirtualColumn('real_lowest_price'))
|
||||
->set("BEST_PRICE", $price)
|
||||
->set("BEST_PRICE_TAX", $taxedPrice - $price)
|
||||
->set("BEST_TAXED_PRICE", $taxedPrice)
|
||||
->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo'))
|
||||
->set("IS_NEW", $product->getVirtualColumn('main_product_is_new'))
|
||||
->set("POSITION", $product->getPosition())
|
||||
|
||||
@@ -35,6 +35,7 @@ use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Base\ProductSaleElementsQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
@@ -124,6 +125,15 @@ class ProductSaleElements extends BaseLoop
|
||||
foreach ($PSEValues as $PSEValue) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $PSEValue, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$price = $PSEValue->getPrice();
|
||||
$taxedPrice = $PSEValue->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
$promoPrice = $PSEValue->getPromoPrice();
|
||||
$taxedPromoPrice = $PSEValue->getTaxedPromoPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
|
||||
$loopResultRow->set("ID", $PSEValue->getId())
|
||||
->set("QUANTITY", $PSEValue->getQuantity())
|
||||
->set("IS_PROMO", $PSEValue->getPromo() === 1 ? 1 : 0)
|
||||
@@ -131,8 +141,12 @@ class ProductSaleElements extends BaseLoop
|
||||
->set("WEIGHT", $PSEValue->getWeight())
|
||||
|
||||
->set("CURRENCY", $PSEValue->getVirtualColumn('price_CURRENCY_ID'))
|
||||
->set("PRICE", $PSEValue->getVirtualColumn('price_PRICE'))
|
||||
->set("PROMO_PRICE", $PSEValue->getVirtualColumn('price_PROMO_PRICE'));
|
||||
->set("PRICE", $price)
|
||||
->set("PRICE_TAX", $taxedPrice - $price)
|
||||
->set("TAXED_PRICE", $taxedPrice)
|
||||
->set("PROMO_PRICE", $promoPrice)
|
||||
->set("PROMO_PRICE_TAX", $taxedPromoPrice - $promoPrice)
|
||||
->set("TAXED_PROMO_PRICE", $taxedPromoPrice);
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
@@ -113,9 +113,15 @@ class Format extends AbstractSmartyPlugin
|
||||
throw new SmartyPluginException("number is a mandatory parameter in format_number function");
|
||||
}
|
||||
|
||||
$number = $params["number"];
|
||||
|
||||
if(empty($number)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$lang = $this->request->getSession()->getLang();
|
||||
|
||||
$number = $params["number"];
|
||||
|
||||
$decimals = array_key_exists("decimals", $params) ? $params["decimals"] : $lang->getDecimals();
|
||||
$decPoint = array_key_exists("dec_point", $params) ? $params["dec_point"] : $lang->getDecimalSeparator();
|
||||
$thousandsSep = array_key_exists("thousands_sep", $params) ? $params["thousands_sep"] : $lang->getThousandsSeparator();
|
||||
|
||||
@@ -65,9 +65,7 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
$this->setTemplate($template ?: ConfigQuery::read('active-template', 'default'));
|
||||
|
||||
$this->debugging = $debug;
|
||||
|
||||
$this->escape_html = true;
|
||||
|
||||
|
||||
// Prevent smarty ErrorException: Notice: Undefined index bla bla bla...
|
||||
$this->error_reporting = E_ALL ^ E_NOTICE;
|
||||
|
||||
@@ -86,6 +84,7 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
|
||||
$this->registerFilter('pre', array($this, "preThelia"));
|
||||
$this->registerFilter('output', array($this, "removeBlankLines"));
|
||||
$this->registerFilter('variable', array(__CLASS__, "theliaEscape"));
|
||||
}
|
||||
|
||||
public function preThelia($tpl_source, \Smarty_Internal_Template $template)
|
||||
@@ -101,6 +100,15 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
return preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $tpl_source);
|
||||
}
|
||||
|
||||
public static function theliaEscape($content, $smarty)
|
||||
{
|
||||
if(!is_object($content)) {
|
||||
return htmlspecialchars($content ,ENT_QUOTES, Smarty::$_CHARSET);
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
public function setTemplate($template_path_from_template_base)
|
||||
{
|
||||
$this->template = $template_path_from_template_base;
|
||||
|
||||
Reference in New Issue
Block a user