FIX TakePOS no invoice validation control and good payment translate

This commit is contained in:
Juanjo Menent 2019-09-24 10:08:48 +02:00
parent d22a1e2571
commit c97bd14278
2 changed files with 27 additions and 26 deletions

View File

@ -144,38 +144,39 @@ if ($action == 'valid' && $user->rights->facture->creer)
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey);
$invoice->validate($user, '', $conf->global->$constantforkey);
$res = $invoice->validate($user, '', $conf->global->$constantforkey);
$conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
}
else
{
$invoice->validate($user);
$res = $invoice->validate($user);
}
// Add the payment
$payment=new Paiement($db);
$payment->datepaye = $now;
$payment->fk_account = $bankaccount;
$payment->amounts[$invoice->id] = $amountofpayment;
if ($res > 0) {
$payment = new Paiement($db);
$payment->datepaye = $now;
$payment->fk_account = $bankaccount;
$payment->amounts[$invoice->id] = $amountofpayment;
$payment->paiementid=$paiementid;
$payment->num_payment=$invoice->ref;
$payment->paiementid = $paiementid;
$payment->num_payment = $invoice->ref;
$payment->create($user);
$payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
$payment->create($user);
$payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
$remaintopay = $invoice->getRemainToPay();
if ($remaintopay == 0)
{
dol_syslog("Invoice is paid, so we set it to pay");
$result = $invoice->set_paid($user);
if ($result > 0) $invoice->paye = 1;
}
else
{
dol_syslog("Invoice is not paid, remain to pay = ".$remaintopay);
}
$remaintopay = $invoice->getRemainToPay();
if ($remaintopay == 0) {
dol_syslog("Invoice is paid, so we set it to pay");
$result = $invoice->set_paid($user);
if ($result > 0) $invoice->paye = 1;
} else {
dol_syslog("Invoice is not paid, remain to pay = " . $remaintopay);
}
} else {
dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
}
}
if ($action == 'history')

View File

@ -190,7 +190,7 @@ else print "var received=0;";
</div>
<?php } ?>
<div style="width:40%; background-color:#333333; border-radius:8px; margin-bottom: 4px;">
<center><span style='font-family: verdana,arial,helvetica; font-size: 200%;'><font color="white"><?php echo $langs->trans("Received"); ?>: </font><span class="change1 colorred"><?php echo price(0) ?></span><input type="hidden" id="change1" class="change1" value="0"></font></center>
<center><span style='font-family: verdana,arial,helvetica; font-size: 200%;'><font color="white"><?php echo $langs->trans("Received"); ?>: </font><span class="change1 colorred"><?php echo price(0) ?></span><input type="hidden" id="change1" class="change1" value="0"></font></span></center>
</div>
<div style="width:40%; background-color:#333333; border-radius:8px; margin-bottom: 4px;">
<center><span style='font-family: verdana,arial,helvetica; font-size: 200%;'><font color="white"><?php echo $langs->trans("Change"); ?>: </font><span class="change2 colorwhite"><?php echo price(0) ?></span><input type="hidden" id="change2" class="change2" value="0"></font></span></center>
@ -225,7 +225,7 @@ $numpad=$conf->global->TAKEPOS_NUMPAD;
if ($paycode == 'CB') $paycode = 'card';
if ($paycode == 'CHQ') $paycode = 'cheque';
?>
<button type="button" class="calcbutton2" onclick="Validate('<?php echo $langs->trans($paycode); ?>');"><?php echo $langs->trans($paiements[0]->label); ?></button>
<button type="button" class="calcbutton2" onclick="Validate('<?php echo $langs->trans($paycode); ?>');"><?php echo $langs->trans("PaymentTypeShort".$paiements[0]->code); ?></button>
<?php } else { ?>
<button type="button" class="calcbutton2"><?php echo $langs->trans("NoPaimementModesDefined");?></button>
<?php } ?>
@ -238,7 +238,7 @@ $numpad=$conf->global->TAKEPOS_NUMPAD;
if ($paycode == 'CB') $paycode = 'card';
if ($paycode == 'CHQ') $paycode = 'cheque';
?>
<button type="button" class="calcbutton2" onclick="Validate('<?php echo $langs->trans($paycode); ?>');"><?php echo $langs->trans($paiements[1]->label); ?></button>
<button type="button" class="calcbutton2" onclick="Validate('<?php echo $langs->trans($paycode); ?>');"><?php echo $langs->trans("PaymentTypeShort".$paiements[1]->code); ?></button>
<?php } else {
$button = array_pop($action_buttons);
?>
@ -253,7 +253,7 @@ $button = array_pop($action_buttons);
if ($paycode == 'CB') $paycode = 'card';
if ($paycode == 'CHQ') $paycode = 'cheque';
?>
<button type="button" class="calcbutton2" onclick="Validate('<?php echo $langs->trans($paycode); ?>');"><?php echo $langs->trans($paiements[2]->label); ?></button>
<button type="button" class="calcbutton2" onclick="Validate('<?php echo $langs->trans($paycode); ?>');"><?php echo $langs->trans("PaymentTypeShort".$paiements[2]->code); ?></button>
<?php } else { ?>
<?php
$button = array_pop($action_buttons);
@ -267,7 +267,7 @@ $button = array_pop($action_buttons);
$i=3;
while($i < count($paiements)){
?>
<button type="button" class="calcbutton2" onclick="Validate('<?php echo $langs->trans($paiements[$i]->code); ?>');"><?php echo $langs->trans($paiements[$i]->label); ?></button>
<button type="button" class="calcbutton2" onclick="Validate('<?php echo $langs->trans($paiements[$i]->code); ?>');"><?php echo $langs->trans("PaymentTypeShort".$paiements[$i]->code); ?></button>
<?php
$i=$i+1;
}