From 73f7c8958bbf73d8e90de775352ec1fcb6af4baf Mon Sep 17 00:00:00 2001 From: "jove@bisquerra.com" Date: Sat, 7 Mar 2020 22:07:20 +0100 Subject: [PATCH 1/2] Remove unused variables in TakePOS --- htdocs/takepos/admin/other.php | 1 - htdocs/takepos/admin/setup.php | 1 - htdocs/takepos/receipt.php | 26 ++++++++++---------------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/htdocs/takepos/admin/other.php b/htdocs/takepos/admin/other.php index 383a710a47a..564b637d8e1 100644 --- a/htdocs/takepos/admin/other.php +++ b/htdocs/takepos/admin/other.php @@ -77,7 +77,6 @@ if (GETPOST('action', 'alpha') == 'set') { $res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_CUSTOM_RECEIPT", GETPOST('TAKEPOS_CUSTOM_RECEIPT', 'int'), 'int', 0, '', $conf->entity); //$res = dolibarr_set_const($db, "TAKEPOS_HEAD_BAR", GETPOST('TAKEPOS_HEAD_BAR', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); if (!empty($conf->global->TAKEPOS_ENABLE_SUMUP)) { diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index eef9497e9db..0e8ba28e0bb 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -79,7 +79,6 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_CUSTOM_RECEIPT", GETPOST('TAKEPOS_CUSTOM_RECEIPT', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ADDON", GETPOST('TAKEPOS_ADDON', 'alpha'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); if (!empty($conf->global->TAKEPOS_ENABLE_SUMUP)) { diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 1df223716fb..66043f7139c 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -85,31 +85,27 @@ if (!empty($hookmanager->resPrint)) {

global->TAKEPOS_CUSTOM_RECEIPT) +if (!empty($conf->global->TAKEPOS_HEADER)) { $substitutionarray = getCommonSubstitutionArray($langs); if (!empty($conf->global->TAKEPOS_HEADER)) - { - $newfreetext = make_substitutions($conf->global->TAKEPOS_HEADER, $substitutionarray); - echo $newfreetext; - } + $newfreetext = make_substitutions($conf->global->TAKEPOS_HEADER, $substitutionarray); + echo $newfreetext; } ?>

trans('Date')." ".dol_print_date($object->date, 'day').'
'; -if ($conf->global->TAKEPOS_CUSTOM_RECEIPT) print $conf->global->TAKEPOS_RECEIPT_NAME." "; +if (!empty($conf->global->TAKEPOS_RECEIPT_NAME)) print $conf->global->TAKEPOS_RECEIPT_NAME." "; if ($object->statut == Facture::STATUS_DRAFT) print str_replace(")", "", str_replace("-", " ".$langs->trans('Place')." ", str_replace("(PROV-POS", $langs->trans("Terminal")." ", $object->ref))); else print $object->ref; -if ($conf->global->TAKEPOS_CUSTOM_RECEIPT && $conf->global->TAKEPOS_SHOW_CUSTOMER) +if ($conf->global->TAKEPOS_SHOW_CUSTOMER) { - $soc = new Societe($db); - $soc->fetch($invoice->socid); - if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}) + if ($object->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}) { $soc = new Societe($db); - if ($invoice->socid > 0) $soc->fetch($invoice->socid); + if ($object->socid > 0) $soc->fetch($object->socid); else $soc->fetch($conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}); print "
".$langs->trans("Customer").': '.$soc->name; } @@ -183,13 +179,11 @@ if ($conf->global->TAKEPOS_CUSTOM_RECEIPT && $conf->global->TAKEPOS_SHOW_CUSTOME

global->TAKEPOS_CUSTOM_RECEIPT) +if (!empty($conf->global->TAKEPOS_FOOTER)) { $substitutionarray = getCommonSubstitutionArray($langs); - if (!empty($conf->global->TAKEPOS_FOOTER)) { - $newfreetext = make_substitutions($conf->global->TAKEPOS_FOOTER, $substitutionarray); - echo $newfreetext; - } + $newfreetext = make_substitutions($conf->global->TAKEPOS_FOOTER, $substitutionarray); + echo $newfreetext; } ?> From 2af9904c047ae4c244057e72053cb7dd15c688cd Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sat, 7 Mar 2020 22:56:43 +0100 Subject: [PATCH 2/2] Avoid higher payments than remain in TakePOS --- htdocs/takepos/invoice.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index e4ad387e1cc..4660032cc15 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -226,7 +226,8 @@ if ($action == 'valid' && $user->rights->facture->creer) $payment->amounts[$invoice->id] = $amountofpayment; // If user has not used change control, add total invoice payment - if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $remaintopay; + // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay + if ($amountofpayment == 0 || $amountofpayment>$remaintopay) $payment->amounts[$invoice->id] = $remaintopay; $payment->paiementid = $paiementid; $payment->num_payment = $invoice->ref;