From b5fca7d839fe478b1db93e7750d6efd80a0488b6 Mon Sep 17 00:00:00 2001 From: rGaillard Date: Wed, 25 Jan 2012 15:24:11 +0000 Subject: [PATCH] // Debug BackOffice order git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12686 b9a71923-0436-4b27-9f14-aed3839534dd --- .../template/controllers/orders/form.tpl | 68 +++++++++---------- controllers/admin/AdminCartsController.php | 6 +- 2 files changed, 34 insertions(+), 40 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/orders/form.tpl b/admin-dev/themes/default/template/controllers/orders/form.tpl index f65161713..89b1d1d48 100755 --- a/admin-dev/themes/default/template/controllers/orders/form.tpl +++ b/admin-dev/themes/default/template/controllers/orders/form.tpl @@ -309,7 +309,7 @@ token: "{getAdminToken tab='AdminCarts'}", tab: "AdminCarts", action: "deleteVoucher", - id_voucher: id_cart_rule, + id_cart_rule: id_cart_rule, id_cart: id_cart, }, success : function(res) @@ -403,16 +403,6 @@ { var html_carts = ''; var html_orders = ''; - var addresses_options = ''; - if (res.addresses.length > 0) - { - var address_detail = res.addresses[0].company+' '+res.addresses[0].firstname+' '+res.addresses[0].lastname+'
'; - address_detail += res.addresses[0].address1+'
'; - address_detail += res.addresses[0].address2+'
'; - address_detail += res.addresses[0].postcode+' '+res.addresses[0].city+' '+res.addresses[0].country; - } - else - address_detail = '{l s='No addresses'}'; $.each(res.carts, function() { html_carts += ''+this.id_cart+''+this.date_add+''+this.total_price+''; html_carts += ''; @@ -425,23 +415,6 @@ }); $('#nonOrderedCarts table tbody').html(html_carts); $('#lastOrders table tbody').html(html_orders); - $.each(res.addresses, function () { - addresses_options += ''; - }); - - if (addresses_options == '') - { - $('#address_delivery').hide(); - $('#address_invoice').hide(); - } - else - { - $('#id_address_delivery').html(addresses_options); - $('#id_address_invoice').html(addresses_options); - $('#address_delivery').show(); - $('#address_invoice').show(); - } - $('#address_delivery_detail,#address_invoice_detail').html(address_detail); } if (res.id_cart) { @@ -576,6 +549,8 @@ { updateCartProducts(jsonSummary.summary.products); updateCartVouchers(jsonSummary.summary.discounts); + updateAddressesList(jsonSummary.addresses, jsonSummary.cart.id_address_delivery, jsonSummary.cart.id_address_invoice); + if (!jsonSummary.summary.products.length || !jsonSummary.addresses.length) $('#carriers_part,#summary_part').hide(); else @@ -764,6 +739,28 @@ } }); } + + function updateAddressesList(addresses, id_address_delivery, id_address_invoice) + { + var addresses_delivery_options = ''; + var addresses_invoice_options = ''; + var address_invoice_detail = ''; + var address_delivery_detail = ''; + + $.each(addresses, function() { + if (this.id_address == id_address_invoice) + address_invoice_detail = this.company+' '+this.firstname+' '+this.lastname+'
'+this.address1+'
'+this.address2+'
'+this.postcode+' '+this.city+' '+this.country; + if(this.id_address == id_address_delivery) + address_delivery_detail = this.company+' '+this.firstname+' '+this.lastname+'
'+this.address1+'
'+this.address2+'
'+this.postcode+' '+this.city+' '+this.country; + + addresses_delivery_options += ''; + addresses_invoice_options += ''; + }); + $('#id_address_delivery').html(addresses_delivery_options); + $('#id_address_invoice').html(addresses_invoice_options); + $('#address_delivery_detail').html(address_delivery_detail); + $('#address_invoice_detail').html(address_invoice_detail); + } function updateAddresses() { @@ -776,18 +773,15 @@ ajax: "1", token: "{getAdminToken tab='AdminCarts'}", tab: "AdminCarts", - action: "updateAddress", + action: "updateAddresses", id_customer: id_customer, + id_cart: id_cart, id_address_delivery: $('#id_address_delivery option:selected').val(), id_address_invoice: $('#id_address_invoice option:selected').val() }, success : function(res) { - if (res.errors) - $('#send_email_feedback').removeClass('conf').addClass('error'); - else - $('#send_email_feedback').removeClass('error').addClass('conf'); - $('#send_email_feedback').html(res.result); + displaySummary(res); var x; for(x in res.addresses) { @@ -865,8 +859,8 @@ {l s='Description'} {l s='Ref'} {l s='Unit price'} - {l s='Qty'} - {l s='Price'} + {l s='Qty'} + {l s='Price'} @@ -1067,4 +1061,4 @@
-
\ No newline at end of file + diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 500251db0..a9b73291d 100755 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -378,12 +378,12 @@ class AdminCartsControllerCore extends AdminController if ($this->tabAccess['edit'] === '1') { if (($id_address_delivery = (int)Tools::getValue('id_address_delivery')) && - $address_delivery = new Address((int)$id_address_delivery) && - $address_delivery->id_customer = $this->context->cart->id_customer) + ($address_delivery = new Address((int)$id_address_delivery)) && + $address_delivery->id_customer == $this->context->cart->id_customer) $this->context->cart->id_address_delivery = (int)$address_delivery->id; if (($id_address_invoice = (int)Tools::getValue('id_address_invoice')) && - $address_invoice = new Address((int)$id_address_invoice) && + ($address_invoice = new Address((int)$id_address_invoice)) && $address_invoice->id_customer = $this->context->cart->id_customer) $this->context->cart->id_address_invoice = (int)$address_invoice->id; $this->context->cart->save();