Fix: 3 fixes on option MAIN_JS_ON_PAYMENT (css, bad path, removed
forced var)
This commit is contained in:
parent
8c27a3202b
commit
5b02ff3a86
@ -18,7 +18,6 @@
|
|||||||
/**
|
/**
|
||||||
* \file htdocs/compta/ajaxpayment.php
|
* \file htdocs/compta/ajaxpayment.php
|
||||||
* \brief File to return Ajax response on payment breakdown process
|
* \brief File to return Ajax response on payment breakdown process
|
||||||
* \version ajaxpayment.php,v 1.0
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
||||||
@ -45,10 +44,7 @@ $currentInvId = $_POST['imgClicked']; // from DOM elements : imgId (equals invo
|
|||||||
|
|
||||||
// Getting the posted keys=>values, sanitize the ones who are from text inputs
|
// Getting the posted keys=>values, sanitize the ones who are from text inputs
|
||||||
// from text inputs : total amount
|
// from text inputs : total amount
|
||||||
$amountPayment = $amountPayment!='' ? ( is_numeric(price2num($amountPayment)) ? price2num($amountPayment)
|
$amountPayment = $amountPayment!='' ? ( is_numeric(price2num($amountPayment)) ? price2num($amountPayment) : '' ) : ''; // keep void if not a valid entry
|
||||||
: ''
|
|
||||||
)
|
|
||||||
: ''; // keep void if not a valid entry
|
|
||||||
// Checkamounts
|
// Checkamounts
|
||||||
foreach ($amounts as $key => $value)
|
foreach ($amounts as $key => $value)
|
||||||
{
|
{
|
||||||
@ -60,7 +56,7 @@ foreach ($amounts as $key => $value)
|
|||||||
$result = $amountPayment != '' ? $amountPayment - array_sum($amounts) : $amountPayment + array_sum($amounts); // Remaining amountPayment
|
$result = $amountPayment != '' ? $amountPayment - array_sum($amounts) : $amountPayment + array_sum($amounts); // Remaining amountPayment
|
||||||
$toJsonArray = array();
|
$toJsonArray = array();
|
||||||
$totalRemaining = price2num(array_sum($remains));
|
$totalRemaining = price2num(array_sum($remains));
|
||||||
$toJsonArray['label'] = $amountPayment == '' ? $langs->transnoentities('AmountToBeCharged') : $langs->transnoentities('RemainingAmountPayment');
|
$toJsonArray['label'] = $amountPayment == '' ? '' : $langs->transnoentities('RemainingAmountPayment');
|
||||||
if($currentInvId) // Here to breakdown
|
if($currentInvId) // Here to breakdown
|
||||||
{
|
{
|
||||||
// Get the current amount (from form) and the corresponding remainToPay (from invoice)
|
// Get the current amount (from form) and the corresponding remainToPay (from invoice)
|
||||||
|
|||||||
@ -280,12 +280,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
|||||||
$(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
|
$(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
|
||||||
$(\'#fieldchqemetteur\').val(\'\');
|
$(\'#fieldchqemetteur\').val(\'\');
|
||||||
}
|
}
|
||||||
}';
|
}
|
||||||
// For paiement auto-completion
|
|
||||||
if (! empty($conf->global->MAIN_JS_ON_PAYMENT))
|
function _elemToJson(selector)
|
||||||
{
|
|
||||||
print "\n".'
|
|
||||||
function elemToJson(selector)
|
|
||||||
{
|
{
|
||||||
var subJson = {};
|
var subJson = {};
|
||||||
$.map(selector.serializeArray(), function(n,i)
|
$.map(selector.serializeArray(), function(n,i)
|
||||||
@ -300,14 +297,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
|||||||
var form = $("#payment_form");
|
var form = $("#payment_form");
|
||||||
|
|
||||||
json["amountPayment"] = $("#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) {
|
if (imgId != null) {
|
||||||
json["imgClicked"] = imgId;
|
json["imgClicked"] = imgId;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.post("ajaxpayment.php", json, function(data)
|
$.post("'.DOL_URL_ROOT.'/compta/ajaxpayment.php", json, function(data)
|
||||||
{
|
{
|
||||||
json = $.parseJSON(data);
|
json = $.parseJSON(data);
|
||||||
|
|
||||||
@ -317,9 +314,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
|||||||
{
|
{
|
||||||
if (key == "result") {
|
if (key == "result") {
|
||||||
if (json["makeRed"]) {
|
if (json["makeRed"]) {
|
||||||
$("#"+key).css("color", "red");
|
$("#"+key).addClass("error");
|
||||||
} else {
|
} else {
|
||||||
$("#"+key).removeAttr("style");
|
$("#"+key).removeClass("error");
|
||||||
}
|
}
|
||||||
json[key]=json["label"]+" "+json[key];
|
json[key]=json["label"]+" "+json[key];
|
||||||
$("#"+key).text(json[key]);
|
$("#"+key).text(json[key]);
|
||||||
@ -331,27 +328,27 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function callToBreakdown(imgSelector) {
|
|
||||||
var form = $("#payment_form"), imgId;
|
|
||||||
|
|
||||||
imgId = imgSelector.attr("id");
|
|
||||||
callForResult(imgId);
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#payment_form").find("img").click(function() {
|
|
||||||
callToBreakdown(jQuery(this));
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#payment_form").find("input[name*=\"amount_\"]").change(function() {
|
$("#payment_form").find("input[name*=\"amount_\"]").change(function() {
|
||||||
callForResult();
|
callForResult();
|
||||||
});
|
});
|
||||||
|
$("#payment_form").find("input[name*=\"amount_\"]").keyup(function() {
|
||||||
|
callForResult();
|
||||||
|
});
|
||||||
|
';
|
||||||
|
|
||||||
|
if (! empty($conf->global->MAIN_JS_ON_PAYMENT))
|
||||||
|
{
|
||||||
|
print ' $("#payment_form").find("img").click(function() {
|
||||||
|
callForResult(jQuery(this).attr("id"));
|
||||||
|
});
|
||||||
|
|
||||||
$("#amountpayment").change(function() {
|
$("#amountpayment").change(function() {
|
||||||
callForResult();
|
callForResult();
|
||||||
});';
|
});';
|
||||||
}
|
}
|
||||||
print '});
|
|
||||||
</script>'."\n";
|
print ' });'."\n";
|
||||||
|
print ' </script>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<form id="payment_form" name="add_paiement" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
print '<form id="payment_form" name="add_paiement" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
|
|||||||
@ -212,6 +212,6 @@ if (! defined('NOREQUIRETRAN'))
|
|||||||
if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR');
|
if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR');
|
||||||
|
|
||||||
// We force feature to help debug
|
// We force feature to help debug
|
||||||
$conf->global->MAIN_JS_ON_PAYMENT=0; // We set to zero to unifrmize way of working between customer and supplier payments
|
//$conf->global->MAIN_JS_ON_PAYMENT=0;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -1441,7 +1441,7 @@ font-family: <?php print $fontlist ?>;
|
|||||||
|
|
||||||
.ok { color: #114466; }
|
.ok { color: #114466; }
|
||||||
.warning { color: #887711; }
|
.warning { color: #887711; }
|
||||||
.error { color: #550000; font-weight: bold; }
|
.error { color: #550000 !important; font-weight: bold; }
|
||||||
|
|
||||||
td.highlights { background: #f9c5c6; }
|
td.highlights { background: #f9c5c6; }
|
||||||
|
|
||||||
|
|||||||
@ -1595,7 +1595,7 @@ font-family: <?php print $fontlist ?>;
|
|||||||
|
|
||||||
.ok { color: #114466; }
|
.ok { color: #114466; }
|
||||||
.warning { color: #887711; }
|
.warning { color: #887711; }
|
||||||
.error { color: #550000; font-weight: bold; }
|
.error { color: #550000 !important; font-weight: bold; }
|
||||||
|
|
||||||
td.highlights { background: #f9c5c6; }
|
td.highlights { background: #f9c5c6; }
|
||||||
|
|
||||||
|
|||||||
@ -1511,7 +1511,7 @@ font-family: <?php print $fontlist ?>;
|
|||||||
*/
|
*/
|
||||||
.ok { color: #114466; }
|
.ok { color: #114466; }
|
||||||
.warning { color: #887711; }
|
.warning { color: #887711; }
|
||||||
.error { color: #550000; font-weight: bold; }
|
.error { color: #550000 !important; font-weight: bold; }
|
||||||
|
|
||||||
div.ok {
|
div.ok {
|
||||||
color: #114466;
|
color: #114466;
|
||||||
|
|||||||
@ -1762,9 +1762,7 @@ tr.fiche {
|
|||||||
*/
|
*/
|
||||||
.ok { color: #114466; }
|
.ok { color: #114466; }
|
||||||
.warning { color: #887711; }
|
.warning { color: #887711; }
|
||||||
.error { color: #550000; font-weight: bold; }
|
.error { color: #550000 !important; font-weight: bold; }
|
||||||
|
|
||||||
td.highlights { background: #f9c5c6; }
|
|
||||||
|
|
||||||
div.ok {
|
div.ok {
|
||||||
color: #114466;
|
color: #114466;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user