diff --git a/htdocs/core/class/html.formbank.class.php b/htdocs/core/class/html.formbank.class.php index a9708a9d76d..a359bd194f7 100644 --- a/htdocs/core/class/html.formbank.class.php +++ b/htdocs/core/class/html.formbank.class.php @@ -23,6 +23,8 @@ * \brief File of class with all html predefined components */ +include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + /** * Class to manage generation of HTML components for bank module diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index 3818217e9fe..4c92fe888d2 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -157,7 +157,7 @@ button.actionbutton { vertical-align: middle; text-align: center; overflow: visible; /* removes extra width in IE */ - width: calc(33% - 2px); + width: calc(33.33% - 2px); height: calc(25% - 2px); margin: 1px; border-width: 0; @@ -274,10 +274,12 @@ table.postablelines tr td { div.paymentbordline { - width:50%; + width:calc(50% - 16px); background-color:#888; border-radius: 8px; margin-bottom: 4px; + display: inline-block; + padding: 5px; } @media only screen and (max-aspect-ratio: 6/4) { @@ -471,6 +473,14 @@ div.description_content { margin-left: 4px; font-size: 1.3em; } + +@media screen and (max-width: 767px) { + .topnav .login_block_other a { + padding: 5px 5px; + font-size: 1.2em; + } +} + .topnav-right > a { font-size: 17px; } @@ -572,7 +582,7 @@ div#moreinfo, div#infowarehouse { } .topnav input[type="text"] { - max-width: 100px; + max-width: 90px; } .topnav-right { diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 5039cfe8233..26b0e71a5fd 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; global $mysoc; -$langs->loadLangs(array("companies", "commercial", "bills", "cashdesk", "stocks")); +$langs->loadLangs(array("companies", "commercial", "bills", "cashdesk", "stocks", "banks")); $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); @@ -137,20 +137,36 @@ else $soc->fetch($conf->global->$constforcompanyid); * Actions */ +// Action to record a payment on a TakePOS invoice if ($action == 'valid' && $user->rights->facture->creer) { - if ($pay == "cash") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]}; // For backward compatibility - elseif ($pay == "card") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$_SESSION["takeposterminal"]}; // For backward compatibility - elseif ($pay == "cheque") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility - else { - $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"]; - $bankaccount = $conf->global->$accountname; - } + $bankaccount = 0; + $error = 0; + + if (! empty($conf->global->TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT)) { + $bankaccount = GETPOST('accountid', 'int'); + } + else { + if ($pay == "cash") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]}; // For backward compatibility + elseif ($pay == "card") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$_SESSION["takeposterminal"]}; // For backward compatibility + elseif ($pay == "cheque") $bankaccount = $conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]}; // For backward compatibility + else { + $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"]; + $bankaccount = $conf->global->$accountname; + } + } + + if ($bankaccount <= 0) { + $errormsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")); + $error++; + } + $now = dol_now(); $res = 0; $invoice = new Facture($db); $invoice->fetch($placeid); + if ($invoice->total_ttc < 0) { $invoice->type = $invoice::TYPE_CREDIT_NOTE; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE "; @@ -180,19 +196,20 @@ if ($action == 'valid' && $user->rights->facture->creer) //} $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if ($invoice->statut != Facture::STATUS_DRAFT) { + if ($error) { + dol_htmloutput_errors($errormsg, null, 1); + } elseif ($invoice->statut != Facture::STATUS_DRAFT) { //If invoice is validated but it is not fully paid is not error and make the payment - if ($invoice->getRemainToPay() > 0) $res = 1; - else { + if ($invoice->getRemainToPay() > 0) { + $res = 1; + } else { dol_syslog("Sale already validated"); dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); } - } elseif (count($invoice->lines) == 0) - { + } elseif (count($invoice->lines) == 0) { dol_syslog("Sale without lines"); dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1); - } elseif (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") - { + } elseif (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { $savconst = $conf->global->STOCK_CALCULATE_ON_BILL; $conf->global->STOCK_CALCULATE_ON_BILL = 1; @@ -219,7 +236,7 @@ if ($action == 'valid' && $user->rights->facture->creer) $remaintopay = $invoice->getRemainToPay(); // Add the payment - if ($res >= 0 && $remaintopay > 0) { + if (!$error && $res >= 0 && $remaintopay > 0) { $payment = new Paiement($db); $payment->datepaye = $now; $payment->fk_account = $bankaccount; diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 95bb9118b48..0f47c7f2b04 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -34,6 +34,8 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +$langs->loadLangs(array("main", "bills", "cashdesk", "banks")); + $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'); // $place is id of table for Bar or Restaurant $invoiceid = GETPOST('invoiceid', 'int'); @@ -70,16 +72,23 @@ if ($invoiceid > 0) $arrayofcss = array('/takepos/css/pos.css.php'); $arrayofjs = array(); +$head = ''; +$title = ''; +$disablejs = 0; +$disablehead = 0; + top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); -$langs->loadLangs(array("main", "bills", "cashdesk")); +// Define list of possible payments +$arrayOfValidPaymentModes = array(); +$arrayOfValidBankAccount = array(); $sql = "SELECT code, libelle as label FROM ".MAIN_DB_PREFIX."c_paiement"; $sql .= " WHERE entity IN (".getEntity('c_paiement').")"; $sql .= " AND active = 1"; $sql .= " ORDER BY libelle"; $resql = $db->query($sql); -$paiements = array(); + if ($resql) { while ($obj = $db->fetch_object($resql)) { $paycode = $obj->code; @@ -88,7 +97,10 @@ if ($resql) { if ($paycode == 'CHQ') $paycode = 'CHEQUE'; $accountname = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"]; - if (!empty($conf->global->$accountname) && $conf->global->$accountname > 0) array_push($paiements, $obj); + if (!empty($conf->global->$accountname) && $conf->global->$accountname > 0) { + $arrayOfValidBankAccount[$conf->global->$accountname] = $conf->global->$accountname; + $arrayOfValidPaymentModes[] = $obj; + } } } ?> @@ -172,12 +184,13 @@ else print "var received=0;"; function Validate(payment) { var invoiceid = 0 ? $invoiceid : 0); ?>; + var accountid = $("#selectaccountid").val(); var amountpayed = $("#change1").val(); if (amountpayed > total_ttc; ?>) { amountpayed = total_ttc; ?>; } console.log("We click on the payment mode to pay amount = "+amountpayed); - parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid, function() { + parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid+"&accountid="+accountid, function() { if (amountpayed > || amountpayed == || amountpayed==0 ) parent.$.colorbox.close(); else location.reload(); }); @@ -196,7 +209,7 @@ else print "var received=0;"; window.open('sumupmerchant://pay/1.0?affiliate-key=global->TAKEPOS_SUMUP_AFFILIATE ?>&app-id=global->TAKEPOS_SUMUP_APPID ?>&total=' + amountpayed + '¤cy=EUR&title=' + invoiceid + '&callback=/takepos/smpcb.php'); var loop = window.setInterval(function () { - $.ajax('/takepos/smpcb.php?status').done(function (data) { + $.ajax('/takepos/smpcb.php?status').done(function (data) { console.log(data); if (data === "SUCCESS") { parent.$("#poslines").load("invoice.php?place=&action=valid&pay=CB&amount=" + amountpayed + "&invoiceid=" + invoiceid, function () { @@ -214,26 +227,40 @@ else print "var received=0;"; } -