Fix autofill of amount on supplier payment page
This commit is contained in:
parent
1ad7210506
commit
e551c0a665
@ -99,7 +99,7 @@ if (empty($reshook))
|
||||
$atleastonepaymentnotnull = 0;
|
||||
|
||||
// Generate payment array and check if there is payment higher than invoice and payment date before invoice date
|
||||
$tmpinvoice=new Facture($db);
|
||||
$tmpinvoice=new Facture($db);
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
if (substr($key,0,7) == 'amount_')
|
||||
@ -188,7 +188,7 @@ if (empty($reshook))
|
||||
setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
|
||||
// Check if payments in both currency
|
||||
if ($totalpayment > 0 && $multicurrency_totalpayment > 0)
|
||||
{
|
||||
@ -228,7 +228,7 @@ if (empty($reshook))
|
||||
$newvalue = price2num($value,'MT');
|
||||
$amounts[$key] = -$newvalue;
|
||||
}
|
||||
|
||||
|
||||
foreach ($multicurrency_amounts as $key => $value) // How payment is dispatch
|
||||
{
|
||||
$newvalue = price2num($value,'MT');
|
||||
@ -319,7 +319,7 @@ llxHeader('', $langs->trans("Payment"));
|
||||
if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement')
|
||||
{
|
||||
$facture = new Facture($db);
|
||||
$result=$facture->fetch($facid);
|
||||
$result = $facture->fetch($facid);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
@ -389,7 +389,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
{
|
||||
subJson[n["name"]] = n["value"];
|
||||
});
|
||||
|
||||
|
||||
return subJson;
|
||||
}
|
||||
function callForResult(imgId)
|
||||
@ -516,31 +516,31 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '<tr><td>'.$langs->trans('Comments').'</td>';
|
||||
print '<td class="tdtop">';
|
||||
print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('comment').'</textarea></td></tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* List of unpaid invoices
|
||||
*/
|
||||
|
||||
|
||||
$sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type, ';
|
||||
$sql.= ' f.datef as df, f.fk_soc as socid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
|
||||
|
||||
|
||||
if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) {
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)';
|
||||
}
|
||||
|
||||
|
||||
$sql.= ' WHERE f.entity = '.$conf->entity;
|
||||
$sql.= ' AND (f.fk_soc = '.$facture->socid;
|
||||
|
||||
|
||||
if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) {
|
||||
$sql.= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')';
|
||||
}
|
||||
|
||||
|
||||
$sql.= ') AND f.paye = 0';
|
||||
$sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled
|
||||
if ($facture->type != 2)
|
||||
@ -577,7 +577,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
//print '<tr><td colspan="3">';
|
||||
print '<br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$arraytitle.'</td>';
|
||||
print '<td align="center">'.$langs->trans('Date').'</td>';
|
||||
@ -602,7 +602,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($objp->socid);
|
||||
@ -614,9 +614,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
$deposits=$invoice->getSumDepositsUsed();
|
||||
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
|
||||
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
|
||||
|
||||
|
||||
// Multicurrency Price
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
$multicurrency_payment = $invoice->getSommePaiement(1);
|
||||
$multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1);
|
||||
@ -624,7 +624,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
$multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,'MT');
|
||||
$multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,'MT');
|
||||
}
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td>';
|
||||
@ -634,36 +634,36 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
|
||||
// Date
|
||||
print '<td align="center">'.dol_print_date($db->jdate($objp->df),'day')."</td>\n";
|
||||
|
||||
|
||||
// Currency
|
||||
if (!empty($conf->multicurrency->enabled)) print '<td align="center">'.$objp->multicurrency_code."</td>\n";
|
||||
|
||||
|
||||
// Multicurrency Price
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
print '<td align="right">';
|
||||
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $objp->multicurrency_total_ttc);
|
||||
print '</td>';
|
||||
|
||||
|
||||
// Multicurrency Price
|
||||
print '<td align="right">';
|
||||
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
|
||||
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
|
||||
{
|
||||
print price($sign * $multicurrency_payment);
|
||||
if ($multicurrency_creditnotes) print '+'.price($multicurrency_creditnotes);
|
||||
if ($multicurrency_deposits) print '+'.price($multicurrency_deposits);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
||||
// Multicurrency Price
|
||||
print '<td align="right">';
|
||||
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
// Price
|
||||
print '<td align="right">'.price($sign * $objp->total_ttc).'</td>';
|
||||
|
||||
|
||||
// Received or paid back
|
||||
print '<td align="right">'.price($sign * $paiement);
|
||||
if ($creditnotes) print '+'.price($creditnotes);
|
||||
@ -685,7 +685,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'");
|
||||
print '<input type=hidden class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
|
||||
print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
|
||||
print '<input type="text" size="8" class="amount" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
|
||||
}
|
||||
else
|
||||
@ -696,14 +696,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print "</td>";
|
||||
|
||||
// Multicurrency Price
|
||||
if (! empty($conf->multicurrency->enabled))
|
||||
if (! empty($conf->multicurrency->enabled))
|
||||
{
|
||||
print '<td align="right">';
|
||||
|
||||
|
||||
// Add remind multicurrency amount
|
||||
$namef = 'multicurrency_amount_'.$objp->facid;
|
||||
$nameRemain = 'multicurrency_remain_'.$objp->facid;
|
||||
|
||||
|
||||
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
|
||||
{
|
||||
if ($action != 'add_paiement')
|
||||
@ -723,7 +723,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
}
|
||||
|
||||
// Warning
|
||||
print '<td align="center" width="16">';
|
||||
print '<td align="center" width="16">';
|
||||
//print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."<br>";
|
||||
if ($amounts[$invoice->id] && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id]))
|
||||
|| $multicurrency_amounts[$invoice->id] && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id])))
|
||||
@ -744,7 +744,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
$totalrecudeposits+=$deposits;
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
if ($i > 1)
|
||||
{
|
||||
// Print total
|
||||
@ -760,7 +760,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
if ($totalrecudeposits) print '+'.price($totalrecudeposits);
|
||||
print '</b></td>';
|
||||
print '<td align="right"><b>'.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,'MT')).'</b></td>';
|
||||
print '<td align="right" id="result" style="font-weight: bold;"></td>';
|
||||
print '<td align="right" id="result" style="font-weight: bold;"></td>'; // Autofilled
|
||||
if (!empty($conf->multicurrency->enabled)) print '<td align="right" id="multicurrency_result" style="font-weight: bold;"></td>';
|
||||
print '<td align="center"> </td>';
|
||||
print "</tr>\n";
|
||||
@ -802,9 +802,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
|
||||
print '<br>';
|
||||
if (!empty($totalpayment)) $text=$langs->trans('ConfirmCustomerPayment',$totalpayment,$langs->trans("Currency".$conf->currency));
|
||||
if (!empty($multicurrency_totalpayment))
|
||||
if (!empty($multicurrency_totalpayment))
|
||||
{
|
||||
$text.='<br />'.$langs->trans('ConfirmCustomerPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency"));
|
||||
$text.='<br>'.$langs->trans('ConfirmCustomerPayment',$multicurrency_totalpayment,$langs->trans("paymentInInvoiceCurrency"));
|
||||
}
|
||||
if (GETPOST('closepaidinvoices'))
|
||||
{
|
||||
@ -864,7 +864,7 @@ if (! GETPOST('action','aZ09'))
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$objp->facid.'">'.$objp->facnumber."</a></td>\n";
|
||||
print '<td>'.dol_print_date($db->jdate($objp->dp))."</td>\n";
|
||||
|
||||
@ -214,7 +214,7 @@ if (empty($reshook))
|
||||
setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
|
||||
// Check if payments in both currency
|
||||
if ($totalpayment > 0 && $multicurrency_totalpayment > 0)
|
||||
{
|
||||
@ -320,7 +320,7 @@ $form=new Form($db);
|
||||
if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement')
|
||||
{
|
||||
$object = new FactureFournisseur($db);
|
||||
$object->fetch($facid);
|
||||
$result = $object->fetch($facid);
|
||||
|
||||
$datefacture=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
||||
$dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datefacture);
|
||||
@ -341,9 +341,83 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$total = $obj->total;
|
||||
|
||||
|
||||
print load_fiche_titre($langs->trans('DoPayment'));
|
||||
|
||||
// Add realtime total information
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print "\n".'<script type="text/javascript" language="javascript">';
|
||||
print '$(document).ready(function () {
|
||||
|
||||
function _elemToJson(selector)
|
||||
{
|
||||
var subJson = {};
|
||||
$.map(selector.serializeArray(), function(n,i)
|
||||
{
|
||||
subJson[n["name"]] = n["value"];
|
||||
});
|
||||
|
||||
return subJson;
|
||||
}
|
||||
function callForResult(imgId)
|
||||
{
|
||||
var json = {};
|
||||
var form = $("#payment_form");
|
||||
|
||||
json["invoice_type"] = $("#invoice_type").val();
|
||||
json["amountPayment"] = $("#amountpayment").attr("value");
|
||||
json["amounts"] = _elemToJson(form.find("input.amount"));
|
||||
json["remains"] = _elemToJson(form.find("input.remain"));
|
||||
|
||||
if (imgId != null) {
|
||||
json["imgClicked"] = imgId;
|
||||
}
|
||||
|
||||
$.post("'.DOL_URL_ROOT.'/compta/ajaxpayment.php", json, function(data)
|
||||
{
|
||||
json = $.parseJSON(data);
|
||||
|
||||
form.data(json);
|
||||
|
||||
for (var key in json)
|
||||
{
|
||||
if (key == "result") {
|
||||
if (json["makeRed"]) {
|
||||
$("#"+key).addClass("error");
|
||||
} else {
|
||||
$("#"+key).removeClass("error");
|
||||
}
|
||||
json[key]=json["label"]+" "+json[key];
|
||||
$("#"+key).text(json[key]);
|
||||
} else {console.log(key);
|
||||
form.find("input[name*=\""+key+"\"]").each(function() {
|
||||
$(this).attr("value", json[key]);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$("#payment_form").find("input.amount").change(function() {
|
||||
callForResult();
|
||||
});
|
||||
$("#payment_form").find("input.amount").keyup(function() {
|
||||
callForResult();
|
||||
});
|
||||
';
|
||||
|
||||
print ' });'."\n";
|
||||
|
||||
//Add js for AutoFill
|
||||
print ' $(document).ready(function () {';
|
||||
print ' $(".AutoFillAmout").on(\'click touchstart\', function(){
|
||||
$("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
|
||||
});';
|
||||
print ' });'."\n";
|
||||
|
||||
print ' </script>'."\n";
|
||||
}
|
||||
|
||||
print '<form id="payment_form" name="addpaiement" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add_paiement">';
|
||||
@ -353,7 +427,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '<input type="hidden" name="societe" value="'.$obj->name.'">';
|
||||
|
||||
dol_fiche_head(null);
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans('Company').'</td><td>';
|
||||
@ -384,7 +458,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '</table>';
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
|
||||
$parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas);
|
||||
$reshook=$hookmanager->executeHooks('paymentsupplierinvoices',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||
@ -408,6 +482,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num > 0)
|
||||
{
|
||||
$sign=1;
|
||||
if ($object->type == 2) $sign=-1;
|
||||
|
||||
$i = 0;
|
||||
print '<br>';
|
||||
|
||||
@ -447,19 +524,37 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
|
||||
$invoice=new FactureFournisseur($db);
|
||||
$invoice->fetch($objp->facid);
|
||||
$paiement = $invoice->getSommePaiement();
|
||||
$creditnotes=$invoice->getSumCreditNotesUsed();
|
||||
$deposits=$invoice->getSumDepositsUsed();
|
||||
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
|
||||
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
|
||||
|
||||
// Multicurrency Price
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
$multicurrency_payment = $invoice->getSommePaiement(1);
|
||||
$multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1);
|
||||
$multicurrency_deposits=$invoice->getSumDepositsUsed(1);
|
||||
$multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,'MT');
|
||||
$multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,'MT');
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
|
||||
// Ref
|
||||
print '<td>';
|
||||
$invoicesupplierstatic->ref=$objp->ref;
|
||||
$invoicesupplierstatic->id=$objp->facid;
|
||||
print $invoicesupplierstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
|
||||
|
||||
// Ref supplier
|
||||
print '<td>'.$objp->ref_supplier.'</td>';
|
||||
|
||||
|
||||
// Date
|
||||
if ($objp->df > 0 )
|
||||
{
|
||||
@ -470,13 +565,13 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
{
|
||||
print '<td align="center"><b>!!!</b></td>';
|
||||
}
|
||||
|
||||
|
||||
// Multicurrency
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
// Currency
|
||||
print '<td align="center">'.$objp->multicurrency_code."</td>\n";
|
||||
|
||||
|
||||
print '<td align="right">';
|
||||
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
|
||||
{
|
||||
@ -485,14 +580,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '</td>';
|
||||
|
||||
print '<td align="right">';
|
||||
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
|
||||
{
|
||||
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
|
||||
{
|
||||
print price($objp->multicurrency_am);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
||||
print '<td align="right">';
|
||||
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
|
||||
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
|
||||
{
|
||||
print price($objp->multicurrency_total_ttc - $objp->multicurrency_am);
|
||||
}
|
||||
@ -500,32 +595,58 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
}
|
||||
|
||||
print '<td align="right">'.price($objp->total_ttc).'</td>';
|
||||
|
||||
|
||||
print '<td align="right">'.price($objp->am).'</td>';
|
||||
|
||||
print '<td align="right">'.price($objp->total_ttc - $objp->am).'</td>';
|
||||
|
||||
|
||||
print '<td align="right">'.price($remaintopay).'</td>';
|
||||
|
||||
// Amount
|
||||
print '<td align="center">';
|
||||
|
||||
$namef = 'amount_'.$objp->facid;
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($objp->total_ttc - $objp->am)."'");
|
||||
print '<input type="text" size="8" name="'.$namef.'" value="'.GETPOST($namef).'">';
|
||||
$nameRemain = 'remain_'.$objp->facid;
|
||||
|
||||
if ($action != 'add_paiement')
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'");
|
||||
print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
|
||||
print '<input type="text" size="8" class="amount" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" size="8" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>';
|
||||
print '<input type="hidden" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
|
||||
}
|
||||
print "</td>";
|
||||
|
||||
// Multicurrency
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
|
||||
// Multicurrency Price
|
||||
if (! empty($conf->multicurrency->enabled))
|
||||
{
|
||||
print '<td align="center">';
|
||||
print '<td align="right">';
|
||||
|
||||
// Add remind multicurrency amount
|
||||
$namef = 'multicurrency_amount_'.$objp->facid;
|
||||
$nameRemain = 'multicurrency_remain_'.$objp->facid;
|
||||
|
||||
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency)
|
||||
{
|
||||
$namef = 'multicurrency_amount_'.$objp->facid;
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($objp->multicurrency_total_ttc - $objp->multicurrency_am)."'");
|
||||
print '<input type="text" size="8" class="multicurrency_amount" name="'.$namef.'" value="'.GETPOST($namef).'">';
|
||||
if ($action != 'add_paiement')
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'");
|
||||
print '<input type=hidden class="multicurrency_remain" name="'.$nameRemain.'" value="'.$multicurrency_remaintopay.'">';
|
||||
print '<input type="text" size="8" class="multicurrency_amount" name="'.$namef.'" value="'.$_POST[$namef].'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" size="8" name="'.$namef.'_disabled" value="'.$_POST[$namef].'" disabled>';
|
||||
print '<input type="hidden" name="'.$namef.'" value="'.$_POST[$namef].'">';
|
||||
}
|
||||
}
|
||||
print "</td>";
|
||||
print "</td>";
|
||||
}
|
||||
|
||||
|
||||
print "</tr>\n";
|
||||
$total+=$objp->total_ht;
|
||||
$total_ttc+=$objp->total_ttc;
|
||||
@ -544,12 +665,12 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '<td align="right"><b>'.price($total_ttc).'</b></td>';
|
||||
print '<td align="right"><b>'.price($totalrecu).'</b></td>';
|
||||
print '<td align="right"><b>'.price($total_ttc - $totalrecu).'</b></td>';
|
||||
print '<td align="center"> </td>';
|
||||
if (!empty($conf->multicurrency->enabled)) print '<td> </td>';
|
||||
print '<td align="center" id="result" style="font-weight: bold;"></td>'; // Autofilled
|
||||
if (!empty($conf->multicurrency->enabled)) print '<td align="right" id="multicurrency_result" style="font-weight: bold;"></td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
|
||||
print "</div>";
|
||||
}
|
||||
$db->free($resql);
|
||||
@ -574,7 +695,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
|
||||
print '<br>';
|
||||
if (!empty($totalpayment)) $text=$langs->trans('ConfirmSupplierPayment',price($totalpayment),$langs->trans("Currency".$conf->currency));
|
||||
if (!empty($multicurrency_totalpayment))
|
||||
if (!empty($multicurrency_totalpayment))
|
||||
{
|
||||
$text.='<br>'.$langs->trans('ConfirmSupplierPayment',price($multicurrency_totalpayment),$langs->trans("paymentInInvoiceCurrency"));
|
||||
}
|
||||
@ -589,7 +710,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
else dol_print_error($db);
|
||||
else dol_print_error($db);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -635,14 +756,14 @@ if (empty($action))
|
||||
$sql.= " GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label";
|
||||
if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
|
||||
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
}
|
||||
|
||||
|
||||
$sql.= $db->plimit($limit+1, $offset);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -667,9 +788,9 @@ if (empty($action))
|
||||
$tmpkey=preg_replace('/search_options_/','',$key);
|
||||
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
|
||||
}
|
||||
|
||||
|
||||
$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
|
||||
|
||||
|
||||
print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit);
|
||||
|
||||
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
@ -680,24 +801,24 @@ if (empty($action))
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
|
||||
|
||||
$moreforfilter='';
|
||||
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
|
||||
|
||||
if ($moreforfilter)
|
||||
{
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
@ -739,11 +860,11 @@ if (empty($action))
|
||||
//print_liste_field_titre($langs->trans('Invoice'),$_SERVER["PHP_SELF"],'ref_supplier','',$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre('');
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Ref payment
|
||||
@ -764,7 +885,7 @@ if (empty($action))
|
||||
|
||||
// Payment number
|
||||
print '<td>'.$objp->num_paiement.'</td>';
|
||||
|
||||
|
||||
print '<td>';
|
||||
if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"),'account').' '.dol_trunc($objp->label,24).'</a>';
|
||||
else print ' ';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user