fix conflicts

This commit is contained in:
Marion Muszynski 2017-08-21 11:04:16 +02:00
commit 13576c64d8
14 changed files with 353 additions and 22 deletions

View File

@ -260,7 +260,7 @@ class AdminInvoices extends AdminTab
<input type="submit" name="submitPrintMPlusMR" class="btn btn-default btn-xs" value="'.$this->l('MR').'" />
</td>
<td style="padding:5px;">
<p><label style="float:none;"><input type="checkbox" name="gift" value="1" /> '.$this->l('Factures Cadeaux').'</label></p>
<p><label style="float:none;"><input type="checkbox" name="gift" value="1" checked/> '.$this->l('Factures Cadeaux').'</label></p>
</td>
<td></td>
</tr>';

View File

@ -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')))
{

View File

@ -1065,6 +1065,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),

View File

@ -37,7 +37,7 @@ class OrderHistory extends OrderHistoryCore {
if (isset($result['template']) AND Validate::isEmail($result['email']))
{
if($lastOrderState->id == 17 && $this->id_order_state == 4) {
if($lastOrderState && $lastOrderState->id == 17 && $this->id_order_state == 4) {
$result['template'] .= '_complete';
}

View File

@ -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::getIsset('giftmessage') ? 1 : 0;
if (Configuration::get('PS_TOKEN_ENABLE') == 1
&& strcasecmp(Tools::getToken(false), strval(Tools::getValue('token')))
@ -263,5 +264,30 @@ class CartController extends CartControllerCore
}
}
// @End adding Antadis
// @Adding Antadis - gift message
if($giftMessage){
if(Tools::getValue('action') == 'remove_all'){
self::$cart->gift = 0;
self::$cart->gift_message = '';
} elseif(Tools::getValue('action') == 'remove_message'){
self::$cart->gift = 1;
self::$cart->gift_message = '';
} elseif(Tools::getValue('action') == 'add_message'){
self::$cart->gift = 1;
if (!Validate::isMessage(Tools::getValue('message'))) {
die('{"hasError" : true, "errors" : ["'.Tools::displayError('Invalid gift message.', false).'"]}');
} else {
self::$cart->gift_message = strip_tags(Tools::getValue('message'));
}
}
if(self::$cart->update()){
die('{"hasError" : false, "action" : "'.Tools::getValue('action').'"}');
} else {
die('{"hasError" : true, "errors" : ["'.Tools::displayError('Invalid gift message.', false).'"]}');
}
}
// @End adding Antadis
}
}

View File

@ -262,13 +262,37 @@ class ParentOrderController extends ParentOrderControllerCore {
// }
if(count($this->errors) === 0) {
parent::_processCarrier();
//parent::_processCarrier();
$this->_processCarrierCustom();
}
} else {
parent::_processCarrier();
//parent::_processCarrier();
$this->_processCarrierCustom();
}
}
public function _processCarrierCustom() {
self::$cart->recyclable = (int)(Tools::getValue('recyclable'));
if (isset(self::$cookie->id_customer) AND self::$cookie->id_customer)
{
$address = new Address((int)(self::$cart->id_address_delivery));
if (!($id_zone = Address::getZoneById($address->id)))
$this->errors[] = Tools::displayError('No zone match with your address');
}
else
$id_zone = Country::getIdZone((int)Configuration::get('PS_COUNTRY_DEFAULT'));
if (Validate::isInt(Tools::getValue('id_carrier')) AND sizeof(Carrier::checkCarrierZone((int)(Tools::getValue('id_carrier')), (int)($id_zone))))
self::$cart->id_carrier = (int)(Tools::getValue('id_carrier'));
elseif (!self::$cart->isVirtualCart() AND (int)(Tools::getValue('id_carrier')) == 0)
$this->errors[] = Tools::displayError('Invalid carrier or no carrier selected');
Module::hookExec('processCarrier', array('cart' => self::$cart));
return self::$cart->update();
}
public function setMedia() {
parent::setMedia();

View File

@ -7291,4 +7291,63 @@ table#carrierTable tbody td {
top: 0;
width: 100%;
z-index: 800;
}
#order .gift_checkbox{
padding-left: 7px;
}
#order #center_column #gift_div textarea {
margin-bottom: 5px;
}
#my_gift{
text-align: center;
margin-bottom: 10px;
border: 1px solid #BDC2C9;
padding: 5px;
background-color: #F1F2F4;
position: relative;
}
.my_gift{
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;
}

View File

@ -32,7 +32,10 @@ $(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_navigation a#go_to_next_step').click(function(){ return giftMessage(true,true,false); });
$('.remove_message_gift').unbind('click').click(function(){ giftMessage(false,false,true); return false; });
}
});
@ -473,6 +476,85 @@ function updateCartSummary(json)
ajaxCart.refresh();
}
function giftMessage(add, next, all){
var async = true;
var got_next = false;
if(next==true){
got_next = true;
}
var action = "add_message";
if(add == false){
if(all == true || !$('input#gift').is(':checked')) {
action = "remove_all";
} else {
action = "remove_message";
}
}
if(add == true){
if(!$('input#gift').is(':checked')){
action = "remove_all";
} else {
action = "add_message";
async = false; // jquery 1.4.4, we have to wait for the response before going to next step
}
}
$.ajax({
type: 'POST',
url: baseDir + 'cart.php?giftmessage=1',
async: async,
cache: false,
dataType: 'json',
data: {
'ajax':true,
'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);
got_next = false;
}
else
{
if(jsonData.action == "add_message") {
message = escape($('#gift_message').val())
$('#my_gift_message').html($('#gift_message').val().replace(/\n/g, "<br/>"));
$('#my_gift').show();
if($('#gift_message').val()==''){
$('#my_gift').hide();
}
} else if (jsonData.action == "remove_all") {
$('#my_gift_message').html('');
$('#my_gift').hide();
$('#gift_message').val('');
$('#gift_div').hide();
$('#gift').removeAttr('checked');
} else if (jsonData.action == "remove_message") {
$('#my_gift_message').html('');
$('#my_gift').hide();
$('#gift_message').val('');
}
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
got_next = false;
console.log("ERROR\n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus + "\n" + 'errorThrown: ' + errorThrown);
}
});
return got_next;
}
function updateCustomizedDatas(json)
{
for(i in json)

View File

@ -252,7 +252,7 @@
</table>
<div style="display: none;" id="extra_carrier"></div>
{if $giftAllowed}
{* {if $giftAllowed}
<h3 class="gift_title">{l s='Gift'}</h3>
<p class="checkbox">
<input type="checkbox" name="gift" id="gift" value="1" {if $cart->gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />
@ -269,7 +269,7 @@
<label for="gift_message">{l s='If you wish, you can add a note to the gift:'}</label>
<textarea rows="5" cols="35" id="gift_message" name="gift_message">{$cart->gift_message|escape:'htmlall':'UTF-8'}</textarea>
</p>
{/if}
{/if} *}
{/if}
{/if}

View File

@ -316,6 +316,14 @@
</table>
</div>
{if $giftAllowed}
<p id="my_gift" {if $cart->gift == 0 || $cart->gift_message == ''} style="display:none;" {/if}>
<span class="remove_message_gift">X</span>
<span class="my_gift">{l s='My message : '}</span><br>
<span id="my_gift_message">{nl2br($cart->gift_message)|escape:'UTF-8'}<span>
</p>
{/if}
{if $site_version == 'es'}
<p class="safety-payment">{l s='Pago seguro, datos encriptados'}</p>
{/if}
@ -354,6 +362,31 @@
{/if}
<p class="shipping-calculate">{l s='Shipping calculated its step 3'}</p>
{if $giftAllowed}
<p class="checkbox gift_checkbox">
<input type="checkbox" name="gift" id="gift" value="1" {if $cart->gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />
<label for="gift">{l s='I would like the order to be gift-wrapped.'}</label>
</p>
<p id="gift_div" class="textarea">
<label for="gift_message">{l s='If you wish, you can add a note to the gift:'}</label>
<textarea rows="5" cols="35" id="gift_message" name="gift_message">{$cart->gift_message|escape:'htmlall':'UTF-8'}</textarea>
{* <a id="cart_add_gift_message" class="exclusive">{l s='Enregistré'}</a> <a id="cart_remove_gift_message" class="exclusive">{l s='Supprimer'}</a> *}
<div class="clear"></div>
</p>
{if !$virtual_cart && $giftAllowed && $cart->gift == 1}
<script type="text/javascript">
{literal}
// <![CDATA[
$('document').ready( function(){
if ($('input#gift').is(':checked'))
$('p#gift_div').show();
});
//]]>
{/literal}
</script>
{/if}
{/if}
{* Define the style if it doesn't exist in the PrestaShop version*}
{* Will be deleted for 1.5 version and more *}
{if !isset($addresses_style)}
@ -433,7 +466,7 @@
</p> -->
<p class="cart_navigation">
{if !$opc}<a href="{$link->getPageLink('order.php', true)}?step=1{if $back}&amp;back={$back}{/if}" class="exclusive" title="{l s='Next'}">{l s='Next'}</a>{/if}
{if !$opc}<a id="go_to_next_step" href="{$link->getPageLink('order.php', true)}?step=1{if $back}&amp;back={$back}{/if}" class="exclusive" title="{l s='Next'}">{l s='Next'}</a>{/if}
<a href="{if (isset($smarty.server.HTTP_REFERER) && strstr($smarty.server.HTTP_REFERER, $link->getPageLink('order.php'))) || !isset($smarty.server.HTTP_REFERER)}{$link->getPageLink('index.php')}{else}{$smarty.server.HTTP_REFERER|escape:'htmlall':'UTF-8'|secureReferrer}{/if}" class="button_large" title="{l s='Continue shopping'}">{l s='Continue shopping'}</a>
</p>
<p class="clear"><br /><br /></p>

View File

@ -2640,9 +2640,11 @@ body#order #safety-payment{
}
body#order #shipping_cost_third_step{
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
color:#434D52;
font-family:Tahoma;
font-size:12px;
margin-bottom: 15px;
}
body#order #safety-payment{
border-bottom: 1px solid #ccc;
@ -3431,6 +3433,7 @@ span.video_wrapper iframe{
}
body#order div#HOOK_SHOPPING_CART {
border-top: 1px solid #E1DDD5;
margin-top: 10px;
}
body#order div#HOOK_SHOPPING_CART #invite_credit
{
@ -5245,3 +5248,10 @@ h3.gift_title {
width: 100%;
margin-bottom: 10px;
}
/***** gift message on shopping cart *****/
.gift_checkbox input#gift{
margin-right: 5px;
}

View File

@ -33,6 +33,8 @@ $(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_navigation a#go_to_next_step').click(function(){ return giftMessage(true,true,false); });
}
});
@ -462,6 +464,72 @@ function updateCartSummary(json)
ajaxCart.refresh();
}
function giftMessage(add, next, all){
var async = true;
var got_next = false;
if(next==true){
got_next = true;
}
var action = "add_message";
if(add == false){
if(all == true || !$('input#gift').is(':checked')) {
action = "remove_all";
} else {
action = "remove_message";
}
}
if(add == true){
if(!$('input#gift').is(':checked')){
action = "remove_all";
} else {
action = "add_message";
async = false; // jquery 1.4.4, we have to wait for the response before going to next step
}
}
$.ajax({
type: 'POST',
url: baseDir + 'cart.php?giftmessage=1',
async: async,
cache: false,
dataType: 'json',
data: {
'ajax':true,
'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);
got_next = false;
}
else
{
if(jsonData.action == "remove_message") {
$('#gift_message').val('');
}else if(jsonData.action == "remove_all"){
$('#gift_message').val('');
$('#gift_div').hide();
$('#gift').removeAttr('checked');
}
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
got_next = false;
//alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
}
});
return got_next;
}
function updateCustomizedDatas(json)
{
for(i in json)

View File

@ -225,7 +225,7 @@
</table>
<div style="display: none;" id="extra_carrier"></div>
{if $giftAllowed}
{* {if $giftAllowed}
<h3 class="gift_title">{l s='Gift'}</h3>
<p class="checkbox">
<input type="checkbox" name="gift" id="gift" value="1" {if $cart->gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />
@ -242,7 +242,7 @@
<label for="gift_message">{l s='If you wish, you can add a note to the gift:'}</label>
<textarea rows="5" cols="35" id="gift_message" name="gift_message">{$cart->gift_message|escape:'htmlall':'UTF-8'}</textarea>
</p>
{/if}
{/if} *}
{/if}
{/if}

View File

@ -156,7 +156,7 @@
<tfoot>
<tr class="cart_total_price{if $shippingCost <= 0} alone{/if}">
<td colspan="2" class="tright">
{l s='Total products'}{if $display_tax_label} {l s='(tax incl.)'}{/if}
{l s='Total products'}{if $display_tax_label} {l s='(tax incl.)'}{/if}
</td>
<td colspan="3" class="tleft">
<span class="price" id="total_product">{displayPrice price=$total_products_wt}</span>
@ -228,7 +228,7 @@
<span>{l s='Got voucher ?'}</span>
<span>{l s='Click here to use it'}</span>
</a>
</div>
</div>
<script type="text/javascript">
{literal}
$(function(){
@ -282,8 +282,34 @@
<i class="icon-frais"></i>
<span>{l s='Shipping cost will be calculated on the third step'}</span>
</div>
{if $giftAllowed}
<p class="checkbox gift_checkbox">
<input type="checkbox" name="gift" id="gift" value="1" {if $cart->gift == 1}checked="checked"{/if} onclick="$('#gift_div').toggle('slow');" />
<label for="gift">{l s='I would like the order to be gift-wrapped.'}</label>
</p>
<p id="gift_div" class="textarea">
<label for="gift_message">{l s='If you wish, you can add a note to the gift:'}</label>
<textarea rows="5" cols="35" id="gift_message" name="gift_message">{$cart->gift_message|escape:'htmlall':'UTF-8'}</textarea>
<div class="clear"></div>
</p>
{if !$virtual_cart && $giftAllowed && $cart->gift == 1}
<script type="text/javascript">
{literal}
// <![CDATA[
$('document').ready( function(){
if ($('input#gift').is(':checked'))
$('p#gift_div').show();
});
//]]>
{/literal}
</script>
{/if}
{/if}
<div id="HOOK_SHOPPING_CART">{$HOOK_SHOPPING_CART}</div>
{* Define the style if it doesn't exist in the PrestaShop version*}
{* Will be deleted for 1.5 version and more *}
{if !isset($addresses_style)}
@ -354,7 +380,7 @@
{/if}*}
<p class="cart_navigation">
<a href="{if (isset($smarty.server.HTTP_REFERER) && strstr($smarty.server.HTTP_REFERER, $link->getPageLink('order.php'))) || !isset($smarty.server.HTTP_REFERER)}{$link->getPageLink('index.php')}{else}{$smarty.server.HTTP_REFERER|escape:'htmlall':'UTF-8'|secureReferrer}{/if}" class="button_large" title="{l s='Continue shopping'}">{l s='Continue shopping'}</a>
{if !$opc}<a href="{$link->getPageLink('order.php', true)}?step=1{if $back}&amp;back={$back}{/if}" class="exclusive" title="{l s='Next'}">{l s='Next'}</a>{/if}
{if !$opc}<a id="go_to_next_step" href="{$link->getPageLink('order.php', true)}?step=1{if $back}&amp;back={$back}{/if}" class="exclusive" title="{l s='Next'}">{l s='Next'}</a>{/if}
</p>
<div class="clear"></div>