// Some improvements on BackOffice orders
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9810 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -26,7 +26,8 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#formAdd{$table}').submit(function() {
|
$('#formAdd{$table}').submit(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
var form_datas = new Object;
|
var form_datas = new Object;
|
||||||
form_datas['liteDisplaying'] = 1;
|
form_datas['liteDisplaying'] = 1;
|
||||||
var form_inputs = $('#formAdd{$table} input, #formAdd{$table} textarea, #formAdd{$table} button');
|
var form_inputs = $('#formAdd{$table} input, #formAdd{$table} textarea, #formAdd{$table} button');
|
||||||
@@ -38,7 +39,7 @@
|
|||||||
form_datas[this.name] = this.value;
|
form_datas[this.name] = this.value;
|
||||||
});
|
});
|
||||||
$.each(form_selects, function() {
|
$.each(form_selects, function() {
|
||||||
form_datas[this.name] = $(this+' option:selected').val();
|
form_datas[this.name] = this.options.selectedIndex;
|
||||||
});
|
});
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: this.method,
|
type: this.method,
|
||||||
@@ -48,10 +49,9 @@
|
|||||||
data : form_datas,
|
data : form_datas,
|
||||||
success : function(res)
|
success : function(res)
|
||||||
{
|
{
|
||||||
$('#content').html(res);
|
$('#fancybox-content').html(res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -84,7 +84,7 @@
|
|||||||
});
|
});
|
||||||
$('#show_old_carts').click();
|
$('#show_old_carts').click();
|
||||||
$.ajaxSetup({ type:"post" });
|
$.ajaxSetup({ type:"post" });
|
||||||
$("#voucher").autocomplete('{$link->getAdminLink('AdminDiscounts')}', {
|
$("#voucher").autocomplete('{$link->getAdminLink('AdminCartRules')}', {
|
||||||
minChars: 3,
|
minChars: 3,
|
||||||
max: 15,
|
max: 15,
|
||||||
width: 250,
|
width: 250,
|
||||||
@@ -106,9 +106,9 @@
|
|||||||
},
|
},
|
||||||
extraParams: {
|
extraParams: {
|
||||||
ajax: "1",
|
ajax: "1",
|
||||||
token: "{getAdminToken tab='AdminDiscounts'}",
|
token: "{getAdminToken tab='AdminCartRules'}",
|
||||||
tab: "AdminDiscounts",
|
tab: "AdminCartRules",
|
||||||
action: "searchVouchers"
|
action: "searchCartRuleVouchers"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
token: "{getAdminToken tab='AdminCarts'}",
|
token: "{getAdminToken tab='AdminCarts'}",
|
||||||
tab: "AdminCarts",
|
tab: "AdminCarts",
|
||||||
action: "addVoucher",
|
action: "addVoucher",
|
||||||
id_voucher: data.id_discount,
|
id_cart_rule: data.id_cart_rule,
|
||||||
id_cart: id_cart
|
id_cart: id_cart
|
||||||
},
|
},
|
||||||
success : function(res)
|
success : function(res)
|
||||||
@@ -148,54 +148,87 @@
|
|||||||
setupCustomer('{$cart->id_customer}');
|
setupCustomer('{$cart->id_customer}');
|
||||||
useCart('{$cart->id}');
|
useCart('{$cart->id}');
|
||||||
{/if}
|
{/if}
|
||||||
$('#loader, #loader_container').ajaxStart(function() {
|
|
||||||
$(this).fadeIn();
|
|
||||||
});
|
|
||||||
resetBind();
|
|
||||||
});
|
|
||||||
|
|
||||||
function resetBind()
|
$('.delete_product').live('click', function(e) {
|
||||||
{
|
e.preventDefault();
|
||||||
$(".fancybox").fancybox();
|
|
||||||
/*$("#new_address").fancybox({
|
|
||||||
onClosed: useCart(id_cart)
|
|
||||||
});*/
|
|
||||||
$(".delete_product").unbind('click').click(function() {
|
|
||||||
var to_delete = $(this).attr('rel').split('_');
|
var to_delete = $(this).attr('rel').split('_');
|
||||||
deleteProduct(to_delete[1], to_delete[2]);
|
deleteProduct(to_delete[1], to_delete[2]);
|
||||||
});
|
});
|
||||||
$('.delete_discount').unbind('click').click(function() {
|
$('.delete_discount').live('click', function(e) {
|
||||||
deleteDiscount($(this).attr('rel'));
|
e.preventDefault();
|
||||||
|
deleteVoucher($(this).attr('rel'));
|
||||||
});
|
});
|
||||||
$(".use_cart").unbind('click').click(function() {
|
$('.use_cart').live('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
useCart($(this).attr('rel'));
|
useCart($(this).attr('rel'));
|
||||||
});
|
});
|
||||||
$('#loader, #loader_container').ajaxStart(function() {
|
|
||||||
$(this).fadeIn();
|
$('.duplicate_order').live('click', function(e) {
|
||||||
});
|
e.preventDefault();
|
||||||
$('#loader, #loader_container').ajaxComplete(function() {
|
|
||||||
$(this).fadeOut();
|
|
||||||
});
|
|
||||||
$(".duplicate_order").unbind('click').click(function() {
|
|
||||||
duplicateOrder($(this).attr('rel'));
|
duplicateOrder($(this).attr('rel'));
|
||||||
});
|
});
|
||||||
$('.cart_quantity').change(function() {
|
$('.cart_quantity').live('change', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
if ($(this).val() != cart_quantity[$(this).attr('rel')])
|
if ($(this).val() != cart_quantity[$(this).attr('rel')])
|
||||||
{
|
{
|
||||||
var product = $(this).attr('rel').split('_');
|
var product = $(this).attr('rel').split('_');
|
||||||
updateQty(product[0], product[1], $(this).val() - cart_quantity[$(this).attr('rel')]);
|
updateQty(product[0], product[1], $(this).val() - cart_quantity[$(this).attr('rel')]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('.increaseqty_product,.decreaseqty_product').unbind('click').click(function() {
|
$('.increaseqty_product,.decreaseqty_product').live('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
var product = $(this).attr('rel').split('_');
|
var product = $(this).attr('rel').split('_');
|
||||||
var sign = '';
|
var sign = '';
|
||||||
if ($(this).hasClass('decreaseqty_product'))
|
if ($(this).hasClass('decreaseqty_product'))
|
||||||
sign = '-';
|
sign = '-';
|
||||||
updateQty(product[0], product[1], sign+1);
|
updateQty(product[0], product[1], sign+1);
|
||||||
});
|
});
|
||||||
$('#id_product, .id_product_attribute').unbind('change').change(function() {
|
$('#id_product, .id_product_attribute').live('change', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
displayQtyInStock(this.id);
|
displayQtyInStock(this.id);
|
||||||
});
|
});
|
||||||
|
$('.product_unit_price').live('change', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var product = $(this).attr('rel').split('_');
|
||||||
|
updateProductPrice(product[0], product[1], $(this).val());
|
||||||
|
});
|
||||||
|
/*$('.fancybox').live('click', function(e) {
|
||||||
|
$(this).fancybox().trigger('click');
|
||||||
|
return false;
|
||||||
|
});*/
|
||||||
|
resetBind();
|
||||||
|
});
|
||||||
|
|
||||||
|
function resetBind()
|
||||||
|
{
|
||||||
|
$('.fancybox').fancybox();
|
||||||
|
/*$("#new_address").fancybox({
|
||||||
|
onClosed: useCart(id_cart)
|
||||||
|
});*/
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateProductPrice(id_product, id_product_attribute, new_price)
|
||||||
|
{
|
||||||
|
$.ajax({
|
||||||
|
type:"POST",
|
||||||
|
url: "{$link->getAdminLink('AdminCarts')}",
|
||||||
|
async: true,
|
||||||
|
dataType: "json",
|
||||||
|
data : {
|
||||||
|
ajax: "1",
|
||||||
|
token: "{getAdminToken tab='AdminCarts'}",
|
||||||
|
tab: "AdminCarts",
|
||||||
|
action: "updateProductPrice",
|
||||||
|
id_cart: id_cart,
|
||||||
|
id_product: id_product,
|
||||||
|
id_product_attribute: id_product_attribute,
|
||||||
|
price: new_price
|
||||||
|
},
|
||||||
|
success : function(res)
|
||||||
|
{
|
||||||
|
displaySummary(res);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayQtyInStock(id)
|
function displayQtyInStock(id)
|
||||||
@@ -233,6 +266,7 @@
|
|||||||
{
|
{
|
||||||
id_cart = id_new_cart;
|
id_cart = id_new_cart;
|
||||||
$('#id_cart').val(id_cart);
|
$('#id_cart').val(id_cart);
|
||||||
|
$('#id_cart').val(id_cart);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type:"POST",
|
type:"POST",
|
||||||
url: "{$link->getAdminLink('AdminCarts')}",
|
url: "{$link->getAdminLink('AdminCarts')}",
|
||||||
@@ -252,7 +286,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteDiscount(id_voucher)
|
function deleteVoucher(id_cart_rule)
|
||||||
{
|
{
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type:"POST",
|
type:"POST",
|
||||||
@@ -263,8 +297,8 @@
|
|||||||
ajax: "1",
|
ajax: "1",
|
||||||
token: "{getAdminToken tab='AdminCarts'}",
|
token: "{getAdminToken tab='AdminCarts'}",
|
||||||
tab: "AdminCarts",
|
tab: "AdminCarts",
|
||||||
action: "deleteDiscount",
|
action: "deleteVoucher",
|
||||||
id_voucher: id_voucher,
|
id_voucher: id_cart_rule,
|
||||||
id_cart: id_cart,
|
id_cart: id_cart,
|
||||||
},
|
},
|
||||||
success : function(res)
|
success : function(res)
|
||||||
@@ -387,6 +421,7 @@
|
|||||||
if (res.id_cart)
|
if (res.id_cart)
|
||||||
{
|
{
|
||||||
id_cart = res.id_cart;
|
id_cart = res.id_cart;
|
||||||
|
$('#id_cart').val(id_cart);
|
||||||
}
|
}
|
||||||
displaySummary(res);
|
displaySummary(res);
|
||||||
resetBind();
|
resetBind();
|
||||||
|
|||||||
@@ -1028,9 +1028,6 @@ class AdminControllerCore extends Controller
|
|||||||
'token_admin_messages' => Tools::getAdminTokenLite('AdminMessages'),
|
'token_admin_messages' => Tools::getAdminTokenLite('AdminMessages'),
|
||||||
'token_admin_employees' => Tools::getAdminTokenLite('AdminEmployees'),
|
'token_admin_employees' => Tools::getAdminTokenLite('AdminEmployees'),
|
||||||
'token_admin_search' => Tools::getAdminTokenLite('AdminSearch'),
|
'token_admin_search' => Tools::getAdminTokenLite('AdminSearch'),
|
||||||
'table' => $this->table,
|
|
||||||
'current' => self::$currentIndex,
|
|
||||||
'token' => $this->token,
|
|
||||||
'first_name' => Tools::substr($this->context->employee->firstname, 0, 1),
|
'first_name' => Tools::substr($this->context->employee->firstname, 0, 1),
|
||||||
'last_name' => htmlentities($this->context->employee->lastname, ENT_COMPAT, 'UTF-8'),
|
'last_name' => htmlentities($this->context->employee->lastname, ENT_COMPAT, 'UTF-8'),
|
||||||
'base_url' => $this->context->shop->getBaseURL(),
|
'base_url' => $this->context->shop->getBaseURL(),
|
||||||
@@ -1104,9 +1101,6 @@ class AdminControllerCore extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->context->smarty->assign(array(
|
$this->context->smarty->assign(array(
|
||||||
'table' => $this->table,
|
|
||||||
'current' => self::$currentIndex,
|
|
||||||
'token' => $this->token,
|
|
||||||
'content' => $this->content,
|
'content' => $this->content,
|
||||||
'url_post' => self::$currentIndex.'&token='.$this->token,
|
'url_post' => self::$currentIndex.'&token='.$this->token,
|
||||||
));
|
));
|
||||||
@@ -1522,6 +1516,11 @@ class AdminControllerCore extends Controller
|
|||||||
}
|
}
|
||||||
if ($this->ajax && method_exists($this, 'ajaxPreprocess'))
|
if ($this->ajax && method_exists($this, 'ajaxPreprocess'))
|
||||||
$this->ajaxPreProcess();
|
$this->ajaxPreProcess();
|
||||||
|
$this->context->smarty->assign(array(
|
||||||
|
'table' => $this->table,
|
||||||
|
'current' => self::$currentIndex,
|
||||||
|
'token' => $this->token,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -685,4 +685,12 @@ class CartRuleCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
return (bool)Configuration::get('PS_CART_RULE_FEATURE_ACTIVE');
|
return (bool)Configuration::get('PS_CART_RULE_FEATURE_ACTIVE');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getCartsRuleByCode($name, $id_lang)
|
||||||
|
{
|
||||||
|
return Db::getInstance()->ExecuteS('SELECT cr.*, crl.*
|
||||||
|
FROM '._DB_PREFIX_.'cart_rule cr
|
||||||
|
LEFT JOIN '._DB_PREFIX_.'cart_rule_lang crl ON (cr.id_cart_rule = crl.id_cart_rule AND crl.id_lang='.(int)$id_lang.')
|
||||||
|
WHERE name LIKE \'%'.pSQL($name).'%\'');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -252,12 +252,4 @@ class DiscountCore extends CartRule
|
|||||||
|
|
||||||
return $voucher;
|
return $voucher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getVoucherByName($name, $id_lang)
|
|
||||||
{
|
|
||||||
return Db::getInstance()->ExecuteS('SELECT d.*, dl.*
|
|
||||||
FROM '._DB_PREFIX_.'discount d
|
|
||||||
LEFT JOIN '._DB_PREFIX_.'discount_lang dl ON (d.id_discount = dl.id_discount AND dl.id_lang='.(int)$id_lang.')
|
|
||||||
WHERE name LIKE \'%'.pSQL($name).'%\'');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -323,4 +323,14 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
|
|
||||||
return parent::initForm();
|
return parent::initForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function displayAjaxSearchCartRuleVouchers()
|
||||||
|
{
|
||||||
|
if ($vouchers = CartRule::getCartsRuleByCode(Tools::getValue('q'), (int)Context::getContext()->cookie->id_lang))
|
||||||
|
$found = true;
|
||||||
|
else
|
||||||
|
$found = false;
|
||||||
|
echo Tools::jsonEncode(array('found' => $found, 'vouchers' => $vouchers));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -306,9 +306,9 @@ class AdminCartsController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ajaxProcessDeleteDiscount()
|
public function ajaxProcessDeleteVoucher()
|
||||||
{
|
{
|
||||||
if ($this->context->cart->deleteDiscount((int)Tools::getValue('id_voucher')))
|
if ($this->context->cart->removeCartRule((int)Tools::getValue('id_cart_rule')))
|
||||||
echo Tools::jsonEncode($this->ajaxReturnVars());
|
echo Tools::jsonEncode($this->ajaxReturnVars());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,9 +317,9 @@ class AdminCartsController extends AdminController
|
|||||||
$errors = array();
|
$errors = array();
|
||||||
$customer = new Customer((int)$this->context->cart->id_customer);
|
$customer = new Customer((int)$this->context->cart->id_customer);
|
||||||
|
|
||||||
if (!$id_cart_rule = Tools::getValue('id_voucher') OR !$cartRule = new CartRule((int)$id_cart_rule))
|
if (!$id_cart_rule = Tools::getValue('id_cart_rule') OR !$cartRule = new CartRule((int)$id_cart_rule))
|
||||||
$errors[] = Tools::displayError('Invalid voucher');
|
$errors[] = Tools::displayError('Invalid voucher');
|
||||||
elseif ($err = $this->context->cart->checkDiscountValidity($cartRule, $this->context->cart->getDiscounts(), $this->context->cart->getOrderTotal(), $this->context->cart->getProducts(), true, $customer))
|
elseif ($err = $cartRule->checkValidity($this->context))
|
||||||
$errors[] = $err;
|
$errors[] = $err;
|
||||||
if (!sizeof($errors))
|
if (!sizeof($errors))
|
||||||
if (!$this->context->cart->addCartRule((int)$cartRule->id))
|
if (!$this->context->cart->addCartRule((int)$cartRule->id))
|
||||||
@@ -419,6 +419,11 @@ class AdminCartsController extends AdminController
|
|||||||
echo Tools::jsonEncode($this->ajaxReturnVars());
|
echo Tools::jsonEncode($this->ajaxReturnVars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ajaxProcessUpdateProductPrice()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static function getOrderTotalUsingTaxCalculationMethod($id_cart)
|
public static function getOrderTotalUsingTaxCalculationMethod($id_cart)
|
||||||
{
|
{
|
||||||
return Cart::getTotalCart($id_cart, true);
|
return Cart::getTotalCart($id_cart, true);
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 109 B |
Reference in New Issue
Block a user