// 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">
|
||||
$(document).ready(function() {
|
||||
$('#formAdd{$table}').submit(function() {
|
||||
$('#formAdd{$table}').submit(function(e) {
|
||||
e.preventDefault();
|
||||
var form_datas = new Object;
|
||||
form_datas['liteDisplaying'] = 1;
|
||||
var form_inputs = $('#formAdd{$table} input, #formAdd{$table} textarea, #formAdd{$table} button');
|
||||
@@ -38,7 +39,7 @@
|
||||
form_datas[this.name] = this.value;
|
||||
});
|
||||
$.each(form_selects, function() {
|
||||
form_datas[this.name] = $(this+' option:selected').val();
|
||||
form_datas[this.name] = this.options.selectedIndex;
|
||||
});
|
||||
$.ajax({
|
||||
type: this.method,
|
||||
@@ -48,10 +49,9 @@
|
||||
data : form_datas,
|
||||
success : function(res)
|
||||
{
|
||||
$('#content').html(res);
|
||||
$('#fancybox-content').html(res);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
});
|
||||
$('#show_old_carts').click();
|
||||
$.ajaxSetup({ type:"post" });
|
||||
$("#voucher").autocomplete('{$link->getAdminLink('AdminDiscounts')}', {
|
||||
$("#voucher").autocomplete('{$link->getAdminLink('AdminCartRules')}', {
|
||||
minChars: 3,
|
||||
max: 15,
|
||||
width: 250,
|
||||
@@ -106,9 +106,9 @@
|
||||
},
|
||||
extraParams: {
|
||||
ajax: "1",
|
||||
token: "{getAdminToken tab='AdminDiscounts'}",
|
||||
tab: "AdminDiscounts",
|
||||
action: "searchVouchers"
|
||||
token: "{getAdminToken tab='AdminCartRules'}",
|
||||
tab: "AdminCartRules",
|
||||
action: "searchCartRuleVouchers"
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -124,7 +124,7 @@
|
||||
token: "{getAdminToken tab='AdminCarts'}",
|
||||
tab: "AdminCarts",
|
||||
action: "addVoucher",
|
||||
id_voucher: data.id_discount,
|
||||
id_cart_rule: data.id_cart_rule,
|
||||
id_cart: id_cart
|
||||
},
|
||||
success : function(res)
|
||||
@@ -148,54 +148,87 @@
|
||||
setupCustomer('{$cart->id_customer}');
|
||||
useCart('{$cart->id}');
|
||||
{/if}
|
||||
$('#loader, #loader_container').ajaxStart(function() {
|
||||
$(this).fadeIn();
|
||||
});
|
||||
resetBind();
|
||||
});
|
||||
|
||||
function resetBind()
|
||||
{
|
||||
$(".fancybox").fancybox();
|
||||
/*$("#new_address").fancybox({
|
||||
onClosed: useCart(id_cart)
|
||||
});*/
|
||||
$(".delete_product").unbind('click').click(function() {
|
||||
|
||||
$('.delete_product').live('click', function(e) {
|
||||
e.preventDefault();
|
||||
var to_delete = $(this).attr('rel').split('_');
|
||||
deleteProduct(to_delete[1], to_delete[2]);
|
||||
});
|
||||
$('.delete_discount').unbind('click').click(function() {
|
||||
deleteDiscount($(this).attr('rel'));
|
||||
$('.delete_discount').live('click', function(e) {
|
||||
e.preventDefault();
|
||||
deleteVoucher($(this).attr('rel'));
|
||||
});
|
||||
$(".use_cart").unbind('click').click(function() {
|
||||
$('.use_cart').live('click', function(e) {
|
||||
e.preventDefault();
|
||||
useCart($(this).attr('rel'));
|
||||
});
|
||||
$('#loader, #loader_container').ajaxStart(function() {
|
||||
$(this).fadeIn();
|
||||
});
|
||||
$('#loader, #loader_container').ajaxComplete(function() {
|
||||
$(this).fadeOut();
|
||||
});
|
||||
$(".duplicate_order").unbind('click').click(function() {
|
||||
|
||||
$('.duplicate_order').live('click', function(e) {
|
||||
e.preventDefault();
|
||||
duplicateOrder($(this).attr('rel'));
|
||||
});
|
||||
$('.cart_quantity').change(function() {
|
||||
$('.cart_quantity').live('change', function(e) {
|
||||
e.preventDefault();
|
||||
if ($(this).val() != cart_quantity[$(this).attr('rel')])
|
||||
{
|
||||
var product = $(this).attr('rel').split('_');
|
||||
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 sign = '';
|
||||
if ($(this).hasClass('decreaseqty_product'))
|
||||
sign = '-';
|
||||
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);
|
||||
});
|
||||
$('.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)
|
||||
@@ -233,6 +266,7 @@
|
||||
{
|
||||
id_cart = id_new_cart;
|
||||
$('#id_cart').val(id_cart);
|
||||
$('#id_cart').val(id_cart);
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url: "{$link->getAdminLink('AdminCarts')}",
|
||||
@@ -252,7 +286,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
function deleteDiscount(id_voucher)
|
||||
function deleteVoucher(id_cart_rule)
|
||||
{
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
@@ -263,8 +297,8 @@
|
||||
ajax: "1",
|
||||
token: "{getAdminToken tab='AdminCarts'}",
|
||||
tab: "AdminCarts",
|
||||
action: "deleteDiscount",
|
||||
id_voucher: id_voucher,
|
||||
action: "deleteVoucher",
|
||||
id_voucher: id_cart_rule,
|
||||
id_cart: id_cart,
|
||||
},
|
||||
success : function(res)
|
||||
@@ -387,6 +421,7 @@
|
||||
if (res.id_cart)
|
||||
{
|
||||
id_cart = res.id_cart;
|
||||
$('#id_cart').val(id_cart);
|
||||
}
|
||||
displaySummary(res);
|
||||
resetBind();
|
||||
|
||||
@@ -1028,9 +1028,6 @@ class AdminControllerCore extends Controller
|
||||
'token_admin_messages' => Tools::getAdminTokenLite('AdminMessages'),
|
||||
'token_admin_employees' => Tools::getAdminTokenLite('AdminEmployees'),
|
||||
'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),
|
||||
'last_name' => htmlentities($this->context->employee->lastname, ENT_COMPAT, 'UTF-8'),
|
||||
'base_url' => $this->context->shop->getBaseURL(),
|
||||
@@ -1104,9 +1101,6 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'table' => $this->table,
|
||||
'current' => self::$currentIndex,
|
||||
'token' => $this->token,
|
||||
'content' => $this->content,
|
||||
'url_post' => self::$currentIndex.'&token='.$this->token,
|
||||
));
|
||||
@@ -1522,6 +1516,11 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
if ($this->ajax && method_exists($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');
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -317,9 +317,9 @@ class AdminCartsController extends AdminController
|
||||
$errors = array();
|
||||
$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');
|
||||
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;
|
||||
if (!sizeof($errors))
|
||||
if (!$this->context->cart->addCartRule((int)$cartRule->id))
|
||||
@@ -419,6 +419,11 @@ class AdminCartsController extends AdminController
|
||||
echo Tools::jsonEncode($this->ajaxReturnVars());
|
||||
}
|
||||
|
||||
public function ajaxProcessUpdateProductPrice()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function getOrderTotalUsingTaxCalculationMethod($id_cart)
|
||||
{
|
||||
return Cart::getTotalCart($id_cart, true);
|
||||
|
||||
BIN
img/bg_loader.png
Normal file
BIN
img/bg_loader.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 109 B |
Reference in New Issue
Block a user