diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 6a16357f6fa..c81a365bfbc 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1009,6 +1009,25 @@ function getParameterByName(name, valueifnotfound) function dolroundjs(number, decimals) { return +(Math.round(number + "e+" + decimals) + "e-" + decimals); } +/** + * Function similar to PHP price() + * + * @param {number|string} amount The amount to show + * @param {string} mode 'MT' or 'MU' + * @return {string} The amount with digits + */ +function pricejs(amount, mode) { + var main_max_dec_shown = global->MAIN_MAX_DECIMALS_SHOWN); ?>; + var main_rounding_unit = global->MAIN_MAX_DECIMALS_UNIT; ?>; + var main_rounding_tot = global->MAIN_MAX_DECIMALS_TOT; ?>; + + console.log(amount); + + if (mode == 'MU') return amount.toFixed(main_rounding_unit); + if (mode == 'MT') return amount.toFixed(main_rounding_tot); + return 'Bad value for parameter mode'; +} + /** * Function similar to PHP price2num() * diff --git a/htdocs/takepos/css/pos.css b/htdocs/takepos/css/pos.css index 086e4e5fcb0..4b90f712f1d 100644 --- a/htdocs/takepos/css/pos.css +++ b/htdocs/takepos/css/pos.css @@ -103,7 +103,6 @@ div.description{ width:100%; /* styling below */ background-color:black; - font-family: 'tahoma'; color:white; opacity:0.8; /* transparency */ filter:alpha(opacity=80); /* IE transparency */ @@ -209,6 +208,15 @@ div.catwatermark{ padding-left: 5px; } +.colorwhite { + color: white; +} +.colorred { + color: red; +} +.colorgreen { + color: green; +} p.description_content{ padding:10px; margin:0px; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 4d6299b3c0a..a0020ec1f41 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -36,10 +36,11 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $idproduct = GETPOST('idproduct', 'int'); $place = (GETPOSTISSET('place')?GETPOST('place', 'int'):0); // $place is id of POS -$number = GETPOST('number'); -$idline = GETPOST('idline'); +$number = GETPOST('number', 'alpha'); +$idline = GETPOST('idline', 'int'); $desc = GETPOST('desc', 'alpha'); -$pay = GETPOST('pay'); +$pay = GETPOST('pay', 'alpha'); +$amountofpayment = price2num(GETPOST('amount', 'alpha')); $placeid = 0; // $placeid is id of invoice @@ -48,28 +49,29 @@ $ret = $invoice->fetch('', '(PROV-POS-'.$place.')'); if ($ret > 0) $placeid = $invoice->id; $paycode = $pay; -if ($pay == 'cash') $paycode = 'LIQ'; -if ($pay == 'card') $paycode = 'CB'; -if ($pay == 'cheque') $paycode = 'CHQ'; - +if ($pay == 'cash') $paycode = 'LIQ'; // For backward compatibility +if ($pay == 'card') $paycode = 'CB'; // For backward compatibility +if ($pay == 'cheque') $paycode = 'CHQ'; // For backward compatibility + // Retrieve paiementid $sql = "SELECT id FROM ".MAIN_DB_PREFIX."c_paiement"; $sql.= " WHERE entity IN (".getEntity('c_paiement').")"; -$sql.= " AND code = '".$paycode."'"; +$sql.= " AND code = '".$db->escape($paycode)."'"; $resql = $db->query($sql); $codes = $db->fetch_array($resql); $paiementid=$codes[0]; + /* * Actions */ if ($action == 'valid' && $user->rights->facture->creer) { - if ($pay == "cash") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH; - elseif ($pay == "card") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CB; - elseif ($pay == "cheque") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; - else + if ($pay == "cash") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH; // For backward compatibility + elseif ($pay == "card") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CB; // For backward compatibility + elseif ($pay == "cheque") $bankaccount = $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; // For backward compatibility + else { $accountname="CASHDESK_ID_BANKACCOUNT_".$pay; $bankaccount=$conf->global->$accountname; @@ -79,22 +81,26 @@ if ($action == 'valid' && $user->rights->facture->creer) $invoice = new Facture($db); $invoice->fetch($placeid); - if (! empty($conf->stock->enabled) and $conf->global->CASHDESK_NO_DECREASE_STOCK!="1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); + if (! empty($conf->stock->enabled) && $conf->global->CASHDESK_NO_DECREASE_STOCK != "1") $invoice->validate($user, '', $conf->global->CASHDESK_ID_WAREHOUSE); else $invoice->validate($user); // Add the payment $payment=new Paiement($db); $payment->datepaye = $now; - $payment->bank_account = $bankaccount; - $payment->amounts[$invoice->id] = $invoice->total_ttc; + $payment->fk_account = $bankaccount; + $payment->amounts[$invoice->id] = $amountofpayment; $payment->paiementid=$paiementid; - $payment->num_paiement=$invoice->ref; + $payment->num_payment=$invoice->ref; $payment->create($user); $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - $invoice->set_paid($user); + + if ($amountofpayment == $invoice->getRemainToPay()) + { + $invoice->set_paid($user); + } } if (($action=="addline" || $action=="freezone") && $placeid == 0) @@ -388,7 +394,16 @@ if ($invoice->socid != $conf->global->CASHDESK_ID_THIRDPARTY) } if ($action=="valid") { - print '
'.$invoice->ref." ".$langs->trans('BillShortStatusValidated').'
'; + print ''; + if ($invoice->getRemainToPay() > 0) + { + print $invoice->getNomUrl(1)." ".$langs->trans('Generated'); + } + else + { + print $invoice->getNomUrl(1)." ".$langs->trans('BillShortStatusValidated'); + } + print '
'; if ($conf->global->TAKEPOSCONNECTOR) print '