From c6c5ad32ca5b006ec981049e49ce9d082f78ba08 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Wed, 28 Jun 2017 15:00:53 +0200 Subject: [PATCH 1/4] fix delete customer --- adm/tabs/AdminCustomers.php | 59 +++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/adm/tabs/AdminCustomers.php b/adm/tabs/AdminCustomers.php index 50d8ffa2..618a3753 100755 --- a/adm/tabs/AdminCustomers.php +++ b/adm/tabs/AdminCustomers.php @@ -1,6 +1,6 @@ delete = true; $this->deleted = true; $this->requiredDatabase = true; - + $this->_select = ' IFNULL(ci.`version`, "fr") AS `version` '; @@ -78,11 +78,11 @@ class AdminCustomers extends AdminTab parent::__construct(); } - + public function postProcess() { global $currentIndex; - + if (Tools::isSubmit('submitDel'.$this->table) OR Tools::isSubmit('delete'.$this->table)) { $deleteForm = ' @@ -108,11 +108,11 @@ class AdminCustomers extends AdminTab
 
'; } - + if (Tools::getValue('submitAdd'.$this->table)) { $groupList = Tools::getValue('groupBox'); - + /* Checking fields validity */ $this->validateRules(); if (!sizeof($this->_errors)) @@ -128,7 +128,7 @@ class AdminCustomers extends AdminTab if (Validate::isLoadedObject($object)) { $customer_email = strval(Tools::getValue('email')); - + // check if e-mail already used if ($customer_email != $object->email) { @@ -137,14 +137,14 @@ class AdminCustomers extends AdminTab if ($customer->id) $this->_errors[] = Tools::displayError('An account already exists for this e-mail address:').' '.$customer_email; } - + if (!is_array($groupList) OR sizeof($groupList) == 0) $this->_errors[] = Tools::displayError('Customer must be in at least one group.'); else if (!in_array(Tools::getValue('id_default_group'), $groupList)) $this->_errors[] = Tools::displayError('Default customer group must be selected in group box.'); - - // Updating customer use credits + + // Updating customer use credits $sql = 'SELECT id_customer FROM `'._DB_PREFIX_.'customer_credits` WHERE id_customer = ' .$object->id; if(Db::getInstance()->getValue($sql)){ // already present @@ -157,7 +157,7 @@ class AdminCustomers extends AdminTab Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'customer_credits` VALUES ('. $object->id . ')'); } } - + // Updating customer's group if (!sizeof($this->_errors)) { @@ -207,6 +207,7 @@ class AdminCustomers extends AdminTab case 'real': $this->deleted = false; Discount::deleteByIdCustomer((int)(Tools::getValue('id_customer'))); + Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'customer_thread` SET `id_customer` = 0 WHERE `id_customer` = '.(int)(Tools::getValue('id_customer'))); break; case 'deleted': $this->deleted = true; @@ -226,8 +227,10 @@ class AdminCustomers extends AdminTab { case 'real': $this->deleted = false; - foreach (Tools::getValue('customerBox') as $id_customer) + foreach (Tools::getValue('customerBox') as $id_customer){ + Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'customer_thread` SET `id_customer` = 0 WHERE `id_customer` = '.(int)$id_customer); Discount::deleteByIdCustomer((int)($id_customer)); + } break; case 'deleted': $this->deleted = true; @@ -266,7 +269,7 @@ class AdminCustomers extends AdminTab $update = Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'customer` SET newsletter = '.($customer->newsletter ? 0 : 1).' WHERE `id_customer` = '.(int)($customer->id)); if (!$update) $this->_errors[] = Tools::displayError('An error occurred while updating customer.'); - Tools::redirectAdmin($currentIndex.'&token='.$this->token); + Tools::redirectAdmin($currentIndex.'&token='.$this->token); }elseif (Tools::isSubmit('changeOptinVal') AND Tools::getValue('id_customer')) { @@ -279,7 +282,7 @@ class AdminCustomers extends AdminTab $this->_errors[] = Tools::displayError('An error occurred while updating customer.'); Tools::redirectAdmin($currentIndex.'&token='.$this->token); } - + return parent::postProcess(); } @@ -351,7 +354,7 @@ class AdminCustomers extends AdminTab echo '
 
'; - + echo '
'.$this->l('Add a private note').'

'.$this->l('This note will be displayed to all the employees but not to the customer.').'

@@ -381,8 +384,8 @@ class AdminCustomers extends AdminTab }); } '; - - + + echo '

'.$this->l('Messages').' ('.sizeof($messages).')

'; if (sizeof($messages)) { @@ -496,7 +499,7 @@ class AdminCustomers extends AdminTab } else echo $customer->firstname.' '.$customer->lastname.' '.$this->l('has not placed any orders yet'); - + if ($products AND sizeof($products)) { echo '
 
@@ -592,7 +595,7 @@ class AdminCustomers extends AdminTab else echo $customer->firstname.' '.$customer->lastname.' '.$this->l('has no discount vouchers').'.'; echo '
 
'; - + echo '

'.$this->l('Carts').' ('.sizeof($carts).')

'; if ($carts AND sizeof($carts)) @@ -628,7 +631,7 @@ class AdminCustomers extends AdminTab else echo $this->l('No cart available').'.'; echo '
'; - + $interested = Db::getInstance()->ExecuteS('SELECT DISTINCT id_product FROM '._DB_PREFIX_.'cart_product cp INNER JOIN '._DB_PREFIX_.'cart c on c.id_cart = cp.id_cart WHERE c.id_customer = '.(int)$customer->id.' AND cp.id_product NOT IN ( SELECT product_id FROM '._DB_PREFIX_.'orders o inner join '._DB_PREFIX_.'order_detail od ON o.id_order = od.id_order WHERE o.valid = 1 AND o.id_customer = '.(int)$customer->id.')'); if (count($interested)) @@ -648,12 +651,12 @@ class AdminCustomers extends AdminTab } echo ''; } - + echo '
 
'; /* Last connections */ $connections = $customer->getLastConnections(); - if (sizeof($connections)) + if (sizeof($connections)) { echo '

'.$this->l('Last connections').'

@@ -674,7 +677,7 @@ class AdminCustomers extends AdminTab '; echo '
 
'; } - if (sizeof($referrers)) + if (sizeof($referrers)) { echo '

'.$this->l('Referrers').'

@@ -696,10 +699,10 @@ class AdminCustomers extends AdminTab { global $currentIndex; parent::displayForm(); - + if (!($obj = $this->loadObject(true))) return; - + $birthday = explode('-', $this->getFieldValue($obj, 'birthday')); $customer_groups = Tools::getValue('groupBox', $obj->getGroups()); $groups = Group::getGroups($this->_defaultFormLanguage, true); @@ -710,7 +713,7 @@ class AdminCustomers extends AdminTab }else{ $obj->use_credits = "1"; } - + echo ' '.($obj->id ? '' : '').' @@ -805,7 +808,7 @@ class AdminCustomers extends AdminTab getFieldValue($obj, 'optin') ? 'checked="checked" ' : '').'/>

'.$this->l('Customer will receive your ads via e-mail').'

- +
getFieldValue($obj, 'use_credits') ? 'checked="checked" ' : '').'/> @@ -865,7 +868,7 @@ class AdminCustomers extends AdminTab global $cookie; return parent::getList((int)($cookie->id_lang), !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL); } - + public function beforeDelete($object) { return $object->isUsed(); From 7a6771ba27adfc84ce569b26f2bccfb40fc36d18 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Thu, 29 Jun 2017 14:24:12 +0200 Subject: [PATCH 2/4] add javascript back to last page --- themes/site_mobile/product.tpl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/themes/site_mobile/product.tpl b/themes/site_mobile/product.tpl index e71bbd0d..f236c15e 100755 --- a/themes/site_mobile/product.tpl +++ b/themes/site_mobile/product.tpl @@ -100,11 +100,14 @@ var oneQuantityAvailableSentence = '{l s='Warning: 1 item in stock!' js=1}';

- {if isset($smarty.server.HTTP_REFERER) && preg_replace('#^https?://[^/]+/#', '/', $smarty.server.HTTP_REFERER) != $request_uri} + + {l s='Back'} + + {* {if isset($smarty.server.HTTP_REFERER) && preg_replace('#^https?://[^/]+/#', '/', $smarty.server.HTTP_REFERER) != $request_uri} {l s='Back'} - {/if} + {/if} *} {$product->name|truncate:30:'...':true:false}

From 13b68d20aead6fd7da60851df0919061036dca34 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Fri, 30 Jun 2017 12:57:06 +0200 Subject: [PATCH 3/4] moving gift message to shopping cart step --- controllers/ParentOrderController.php | 20 +++++----- override/classes/Cart.php | 1 + override/controllers/CartController.php | 15 +++++++ themes/site/css/style.css | 11 +++++ themes/site/js/cart-summary.js | 53 ++++++++++++++++++++++++- themes/site/order-carrier.tpl | 4 +- themes/site/shopping-cart.tpl | 30 ++++++++++++++ 7 files changed, 122 insertions(+), 12 deletions(-) diff --git a/controllers/ParentOrderController.php b/controllers/ParentOrderController.php index 1047787d..4aa282aa 100755 --- a/controllers/ParentOrderController.php +++ b/controllers/ParentOrderController.php @@ -32,7 +32,7 @@ class ParentOrderControllerCore extends FrontController { public $ssl = true; public $php_self = 'order.php'; - + public $nbProducts; public function __construct() @@ -200,14 +200,15 @@ class ParentOrderControllerCore extends FrontController protected function _processCarrier() { self::$cart->recyclable = (int)(Tools::getValue('recyclable')); - self::$cart->gift = (int)(Tools::getValue('gift')); - if ((int)(Tools::getValue('gift'))) - { - if (!Validate::isMessage($_POST['gift_message'])) - $this->errors[] = Tools::displayError('Invalid gift message'); - else - self::$cart->gift_message = strip_tags($_POST['gift_message']); - } + // @Override Antadis - Gift cart updated on step 1 + // self::$cart->gift = (int)(Tools::getValue('gift')); + // if ((int)(Tools::getValue('gift'))) + // { + // if (!Validate::isMessage($_POST['gift_message'])) + // $this->errors[] = Tools::displayError('Invalid gift message'); + // else + // self::$cart->gift_message = strip_tags($_POST['gift_message']); + // } if (isset(self::$cookie->id_customer) AND self::$cookie->id_customer) { @@ -290,6 +291,7 @@ class ParentOrderControllerCore extends FrontController protected function _assignAddress() { + //if guest checkout disabled and flag is_guest in cookies is actived if (Configuration::get('PS_GUEST_CHECKOUT_ENABLED') == 0 AND ((int) self::$cookie->is_guest != Configuration::get('PS_GUEST_CHECKOUT_ENABLED'))) { diff --git a/override/classes/Cart.php b/override/classes/Cart.php index a699907c..c49312b0 100755 --- a/override/classes/Cart.php +++ b/override/classes/Cart.php @@ -1046,6 +1046,7 @@ class Cart extends CartCore { 'products' => $products, 'discounts' => $this->getDiscounts(false, true), 'is_virtual_cart' => (int)$this->isVirtualCart(), + 'giftAllowed' => (int)(Configuration::get('PS_GIFT_WRAPPING')), 'total_discounts' => $this->getOrderTotal(true, Cart::ONLY_DISCOUNTS), 'total_discounts_tax_exc' => $this->getOrderTotal(false, Cart::ONLY_DISCOUNTS), 'total_wrapping' => $this->getOrderTotal(true, Cart::ONLY_WRAPPING), diff --git a/override/controllers/CartController.php b/override/controllers/CartController.php index abe42da0..559db8da 100644 --- a/override/controllers/CartController.php +++ b/override/controllers/CartController.php @@ -42,6 +42,7 @@ class CartController extends CartControllerCore $add = Tools::getIsset('add') ? 1 : 0; $delete = Tools::getIsset('delete') ? 1 : 0; $removeAll = Tools::getIsset('removeall') ? 1 : 0; + $giftMessage = Tools::getValue('giftmessage'); if (Configuration::get('PS_TOKEN_ENABLE') == 1 && strcasecmp(Tools::getToken(false), strval(Tools::getValue('token'))) @@ -300,6 +301,20 @@ class CartController extends CartControllerCore } } } + + if($giftMessage){ + if(Tools::getValue('action') == 'remove_message'){ + self::$cart->gift = 0; + self::$cart->gift_message = ''; + } elseif(Tools::getValue('action') == 'add_message'){ + self::$cart->gift = 1; + self::$cart->gift_message = strip_tags(Tools::getValue('message')); + } + + if(self::$cart->update()){ + die('{"hasError" : false, "action" : "'.Tools::getValue('action').'"}'); + } + } // @End adding Antadis } } \ No newline at end of file diff --git a/themes/site/css/style.css b/themes/site/css/style.css index f937b85d..a696ec3e 100755 --- a/themes/site/css/style.css +++ b/themes/site/css/style.css @@ -7283,4 +7283,15 @@ table#carrierTable tbody td { top: 0; width: 100%; z-index: 800; +} + +#my_gift{ + text-align: center; + margin-bottom: 10px; +} +.my_gift{ + color: #514c8c; +} +#cart_remove_gift_message{ + float:right; } \ No newline at end of file diff --git a/themes/site/js/cart-summary.js b/themes/site/js/cart-summary.js index 0cb806a2..0aeb8f75 100755 --- a/themes/site/js/cart-summary.js +++ b/themes/site/js/cart-summary.js @@ -32,7 +32,9 @@ $(document).ready(function() $('.cart_quantity_up').unbind('click').click(function(){ upQuantity($(this).attr('id').replace('cart_quantity_up_', '')); return false; }); $('.cart_quantity_down').unbind('click').click(function(){ downQuantity($(this).attr('id').replace('cart_quantity_down_', '')); return false; }); $('.cart_quantity_delete' ).unbind('click').click(function(){ deletProductFromSummary($(this).attr('id')); return false; }); - $('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: updateQty }); + $('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: updateQty }); + $('#cart_add_gift_message').unbind('click').click(function(){ console.log('add'); giftMessage(true); return false; }); + $('#cart_remove_gift_message').unbind('click').click(function(){ console.log('remove'); giftMessage(false); return false; }); } }); @@ -473,6 +475,55 @@ function updateCartSummary(json) ajaxCart.refresh(); } +function giftMessage(add){ + var action = "add_message"; + if(add == false){ + var action = "remove_message"; + } + $.ajax({ + type: 'POST', + url: baseDir + 'cart.php', + async: true, + cache: false, + dataType: 'json', + data: { + 'ajax':true, + 'giftmessage' : 1, + 'action': action, + 'message': $('#gift_message').val(), + 'token': static_token + }, + success: function(jsonData) + { + if (jsonData.hasError) + { + var errors = ''; + for(error in jsonData.errors) + //IE6 bug fix + if(error != 'indexOf') + errors += jsonData.errors[error] + "\n"; + alert(errors); + } + else + { + console.log(jsonData); + if(jsonData.action == "add_message") { + message = escape($('#gift_message').val()) + $('#my_gift_message').html($('#gift_message').val().replace(/\n/g, "
")); + $('#my_gift').show(); + } else { + $('#my_gift_message').html(''); + $('#my_gift').hide(); + $('#gift_message').val(''); + $('#gift_div').hide(); + $('#gift').removeAttr('checked'); + } + } + }, + error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);} + }); +} + function updateCustomizedDatas(json) { for(i in json) diff --git a/themes/site/order-carrier.tpl b/themes/site/order-carrier.tpl index 35ca2cfb..f44ac994 100755 --- a/themes/site/order-carrier.tpl +++ b/themes/site/order-carrier.tpl @@ -252,7 +252,7 @@
- {if $giftAllowed} + {* {if $giftAllowed}

{l s='Gift'}

gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" /> @@ -269,7 +269,7 @@

- {/if} + {/if} *} {/if} {/if} diff --git a/themes/site/shopping-cart.tpl b/themes/site/shopping-cart.tpl index c42861b4..1c7c8672 100755 --- a/themes/site/shopping-cart.tpl +++ b/themes/site/shopping-cart.tpl @@ -316,6 +316,36 @@ +{if $giftAllowed} +

gift == 0} style="display:none;" {/if}> + {l s='My message : '}
+ {nl2br($cart->gift_message)|escape:'UTF-8'} +

+

{l s='Gift'}

+

+ gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" /> + +

+

+ + + {l s='Enregistré'} {l s='Supprimer'} +

+

+ {if !$virtual_cart && $giftAllowed && $cart->gift == 1} + + {/if} +{/if} + {if $site_version == 'es'}

{l s='Pago seguro, datos encriptados'}

{/if} From 40fe9a97b850e4545db728b1994d660f43051620 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Mon, 3 Jul 2017 10:15:21 +0200 Subject: [PATCH 4/4] fix css --- themes/site/css/style.css | 51 ++++++++++++++++++++++++++++++++-- themes/site/js/cart-summary.js | 6 ++-- themes/site/shopping-cart.tpl | 2 +- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/themes/site/css/style.css b/themes/site/css/style.css index a696ec3e..9366ead6 100755 --- a/themes/site/css/style.css +++ b/themes/site/css/style.css @@ -7285,13 +7285,58 @@ table#carrierTable tbody td { z-index: 800; } +#order #center_column #gift_div textarea { + margin-bottom: 5px; +} #my_gift{ - text-align: center; - margin-bottom: 10px; + text-align: center; + margin-bottom: 10px; + border: 1px solid #BDC2C9; + padding: 5px; + background-color: #F1F2F4; + position: relative; } .my_gift{ - color: #514c8c; + font-size: 16px; + color: #514c8c; + font-weight: normal; + text-shadow: 0px 1px 0px #ffffff; + line-height: 1.5em; + text-transform: none; + margin-bottom: 10px; + font-family: georgia, times new roman, serif; + font-style: italic; +} +.remove_message_gift{ + background: #e26ea2; + color: #fff; + position: absolute; + top: 5px; + right: 5px; + padding: 2px 7px; + -moz-border-radius: 50%; + -webkit-border-radius: 50%; + border-radius: 50%; + cursor: pointer; +} +#cart_add_gift_message, +#cart_remove_gift_message{ + text-align: center; + text-transform: none; + border: 0px; + color: #ffffff; + padding: 5px 10px; + text-decoration: none; + font-weight: normal; + background: #504d8b; + -moz-border-radius: 20px; + -webkit-border-radius: 20px; + border-radius: 20px; + font-family: georgia, times new roman, serif; + font-style: italic; + font-size: 13px; } #cart_remove_gift_message{ float:right; + background: #e26ea2; } \ No newline at end of file diff --git a/themes/site/js/cart-summary.js b/themes/site/js/cart-summary.js index 0aeb8f75..8ac8b697 100755 --- a/themes/site/js/cart-summary.js +++ b/themes/site/js/cart-summary.js @@ -33,8 +33,9 @@ $(document).ready(function() $('.cart_quantity_down').unbind('click').click(function(){ downQuantity($(this).attr('id').replace('cart_quantity_down_', '')); return false; }); $('.cart_quantity_delete' ).unbind('click').click(function(){ deletProductFromSummary($(this).attr('id')); return false; }); $('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: updateQty }); - $('#cart_add_gift_message').unbind('click').click(function(){ console.log('add'); giftMessage(true); return false; }); - $('#cart_remove_gift_message').unbind('click').click(function(){ console.log('remove'); giftMessage(false); return false; }); + $('#cart_add_gift_message').unbind('click').click(function(){giftMessage(true); return false; }); + $('#cart_remove_gift_message').unbind('click').click(function(){giftMessage(false); return false; }); + $('.remove_message_gift').unbind('click').click(function(){giftMessage(false); return false; }); } }); @@ -506,7 +507,6 @@ function giftMessage(add){ } else { - console.log(jsonData); if(jsonData.action == "add_message") { message = escape($('#gift_message').val()) $('#my_gift_message').html($('#gift_message').val().replace(/\n/g, "
")); diff --git a/themes/site/shopping-cart.tpl b/themes/site/shopping-cart.tpl index 1c7c8672..873db872 100755 --- a/themes/site/shopping-cart.tpl +++ b/themes/site/shopping-cart.tpl @@ -318,10 +318,10 @@ {if $giftAllowed}

gift == 0} style="display:none;" {/if}> + X {l s='My message : '}
{nl2br($cart->gift_message)|escape:'UTF-8'}

-

{l s='Gift'}

gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />