Fix: use MAIN_JS_ON_PAYMENT just for the auto-completion payment
This commit is contained in:
parent
244af052cc
commit
196bb42636
@ -2,7 +2,7 @@
|
|||||||
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -243,35 +243,48 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Invoice with Paypal transaction
|
// Invoice with Paypal transaction
|
||||||
|
// TODO add hook possibility (regis)
|
||||||
if ($conf->paypalplus->enabled && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && ! empty($facture->ref_int))
|
if ($conf->paypalplus->enabled && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && ! empty($facture->ref_int))
|
||||||
{
|
{
|
||||||
if (! empty($conf->global->PAYPAL_BANK_ACCOUNT)) $accountid=$conf->global->PAYPAL_BANK_ACCOUNT;
|
if (! empty($conf->global->PAYPAL_BANK_ACCOUNT)) $accountid=$conf->global->PAYPAL_BANK_ACCOUNT;
|
||||||
$paymentnum=$facture->ref_int;
|
$paymentnum=$facture->ref_int;
|
||||||
}
|
}
|
||||||
if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_JS_ON_PAYMENT))
|
if ($conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
print "\n".'<script type="text/javascript" language="javascript">';
|
print "\n".'<script type="text/javascript" language="javascript">';
|
||||||
print 'jQuery(document).ready(function () {';
|
print '$(document).ready(function () {
|
||||||
print 'jQuery("#selectpaiementcode").change(function() {
|
setPaiementCode();
|
||||||
code=jQuery("#selectpaiementcode option:selected").val();
|
|
||||||
|
$("#selectpaiementcode").change(function() {
|
||||||
|
setPaiementCode();
|
||||||
|
});
|
||||||
|
|
||||||
|
function setPaiementCode()
|
||||||
|
{
|
||||||
|
var code = $("#selectpaiementcode option:selected").val();
|
||||||
|
|
||||||
if (code == \'CHQ\')
|
if (code == \'CHQ\')
|
||||||
{
|
{
|
||||||
jQuery(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
|
$(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
|
||||||
if (jQuery(\'#fieldchqemetteur\').val() == \'\')
|
if ($(\'#fieldchqemetteur\').val() == \'\')
|
||||||
{
|
{
|
||||||
jQuery(\'#fieldchqemetteur\').val(jQuery(\'#thirdpartylabel\').val());
|
$(\'#fieldchqemetteur\').val(jQuery(\'#thirdpartylabel\').val());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
jQuery(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
|
$(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
|
||||||
|
$(\'#fieldchqemetteur\').val(\'\');
|
||||||
}
|
}
|
||||||
});
|
}';
|
||||||
|
// For paiement auto-completion
|
||||||
|
if (! empty($conf->global->MAIN_JS_ON_PAYMENT))
|
||||||
|
{
|
||||||
|
print "\n".'
|
||||||
function elemToJson(selector)
|
function elemToJson(selector)
|
||||||
{
|
{
|
||||||
var subJson = {};
|
var subJson = {};
|
||||||
jQuery.map(selector.serializeArray(), function(n,i)
|
$.map(selector.serializeArray(), function(n,i)
|
||||||
{
|
{
|
||||||
subJson[n["name"]] = n["value"];
|
subJson[n["name"]] = n["value"];
|
||||||
});
|
});
|
||||||
@ -280,17 +293,19 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
|||||||
function callForResult(imgId)
|
function callForResult(imgId)
|
||||||
{
|
{
|
||||||
var json = {};
|
var json = {};
|
||||||
var form = jQuery("#payment_form");
|
var form = $("#payment_form");
|
||||||
|
|
||||||
json["amountPayment"] = jQuery("#amountpayment").attr("value");
|
json["amountPayment"] = $("#amountpayment").attr("value");
|
||||||
json["amounts"] = elemToJson(form.find("input[name*=\"amount_\"]"));
|
json["amounts"] = elemToJson(form.find("input[name*=\"amount_\"]"));
|
||||||
json["remains"] = elemToJson(form.find("input[name*=\"remain_\"]"));
|
json["remains"] = elemToJson(form.find("input[name*=\"remain_\"]"));
|
||||||
|
|
||||||
if(imgId != null)json["imgClicked"] = imgId;
|
if (imgId != null) {
|
||||||
|
json["imgClicked"] = imgId;
|
||||||
|
}
|
||||||
|
|
||||||
jQuery.post("ajaxpayment.php", json, function(data)
|
$.post("ajaxpayment.php", json, function(data)
|
||||||
{
|
{
|
||||||
json = jQuery.parseJSON(data);
|
json = $.parseJSON(data);
|
||||||
|
|
||||||
form.data(json);
|
form.data(json);
|
||||||
|
|
||||||
@ -298,40 +313,40 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
|||||||
{
|
{
|
||||||
if (key == "result") {
|
if (key == "result") {
|
||||||
if (json["makeRed"]) {
|
if (json["makeRed"]) {
|
||||||
jQuery("#"+key).css("color", "red");
|
$("#"+key).css("color", "red");
|
||||||
} else {
|
} else {
|
||||||
jQuery("#"+key).removeAttr("style");
|
$("#"+key).removeAttr("style");
|
||||||
}
|
}
|
||||||
json[key]=json["label"]+" "+json[key];
|
json[key]=json["label"]+" "+json[key];
|
||||||
jQuery("#"+key).text(json[key]);
|
$("#"+key).text(json[key]);
|
||||||
} else {
|
} else {
|
||||||
form.find("input[name*=\""+key+"\"]").each(function() {
|
form.find("input[name*=\""+key+"\"]").each(function() {
|
||||||
jQuery(this).attr("value", json[key]);
|
$(this).attr("value", json[key]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
function callToBreakdown(imgSelector) {
|
function callToBreakdown(imgSelector) {
|
||||||
var form = jQuery("#payment_form"), imgId;
|
var form = $("#payment_form"), imgId;
|
||||||
|
|
||||||
imgId = imgSelector.attr("id");
|
imgId = imgSelector.attr("id");
|
||||||
callForResult(imgId);
|
callForResult(imgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
jQuery("#payment_form").find("img").click(function() {
|
$("#payment_form").find("img").click(function() {
|
||||||
callToBreakdown(jQuery(this));
|
callToBreakdown(jQuery(this));
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery("#payment_form").find("input[name*=\"amount_\"]").change(function() {
|
$("#payment_form").find("input[name*=\"amount_\"]").change(function() {
|
||||||
callForResult();
|
callForResult();
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery("#amountpayment").change(function() {
|
$("#amountpayment").change(function() {
|
||||||
callForResult();
|
callForResult();
|
||||||
});
|
});';
|
||||||
});
|
}
|
||||||
|
print '});
|
||||||
</script>'."\n";
|
</script>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user