* Copyright (C) 2021-2022 Thibault FOUCART * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/takepos/pay.php * \ingroup takepos * \brief Page with the content of the popup to enter payments */ // if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language // if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language // if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); } if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); } // Load Dolibarr environment require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; // Load translation files required by the page $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 = GETPOSTINT('invoiceid'); $hookmanager->initHooks(array('takepospay')); if (!$user->hasRight('takepos', 'run')) { accessforbidden(); } /* * View */ $arrayofcss = array('/takepos/css/pos.css.php'); $arrayofjs = array(); $head = ''; $title = ''; $disablejs = 0; $disablehead = 0; $head = ''; if (getDolGlobalInt('TAKEPOS_COLOR_THEME') == 1) { $head .= ''; } top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); ?> getStripeAccount($service); // Get Stripe OAuth connect account (no remote access to Stripe here) include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $invoicetmp = new Facture($db); $invoicetmp->fetch($invoiceid); $stripecu = $stripe->getStripeCustomerAccount($invoicetmp->socid, $servicestatus, $site_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here) $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".(empty($_SESSION['takeposterminal']) ? '' : $_SESSION['takeposterminal']); $usestripeterminals = getDolGlobalString('STRIPE_LOCATION'); if ($usestripeterminals) { ?> trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning', 1); } $invoice = new Facture($db); if ($invoiceid > 0) { $invoice->fetch($invoiceid); } else { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture"; $sql .= " WHERE entity IN (".getEntity('invoice').")"; $sql .= " AND ref = '(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); $obj = $db->fetch_object($resql); if ($obj) { $invoiceid = $obj->rowid; } if (!$invoiceid) { $invoiceid = 0; // Invoice does not exist yet } else { $invoice->fetch($invoiceid); } } ?> query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { $paycode = $obj->code; if ($paycode == 'LIQ') { $paycode = 'CASH'; } if ($paycode == 'CB') { $paycode = 'CB'; } if ($paycode == 'CHQ') { $paycode = 'CHEQUE'; } $accountname = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"]; if (getDolGlobalInt($accountname) > 0) { $arrayOfValidBankAccount[getDolGlobalInt($accountname)] = getDolGlobalInt($accountname); $arrayOfValidPaymentModes[] = $obj; } if (!isModEnabled('bank')) { if ($paycode == 'CASH' || $paycode == 'CB') { $arrayOfValidPaymentModes[] = $obj; } } } } ?> currency != $sessioncurrency) { // Only show customer currency if multicurrency module is enabled, if currency selected and if this currency selected is not the same as main currency $showothercurrency = 1; include_once DOL_DOCUMENT_ROOT . '/multicurrency/class/multicurrency.class.php'; $multicurrency = new MultiCurrency($db); $multicurrency->fetch(0, $sessioncurrency); } ?>
trans('TotalTTC'); ?>: total_ttc, 1, '', 1, -1, -1, $conf->currency); if ($showothercurrency) { print '   (' . price($invoice->total_ht * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')'; } ?>
total_ttc) { ?>
trans('RemainToPay'); ?>: multicurrency_code); if ($showothercurrency) { print '   (' . price($remaintopay * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')'; } ?>
trans("Received"); ?>: multicurrency_code); if ($showothercurrency) { print '   (' . price(0 * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')'; } ?>
trans("Change"); ?>: multicurrency_code); if ($showothercurrency) { print '   (' . price(0 * $multicurrency->rate->rate) . ' ' . $sessioncurrency . ')'; } ?>
'; $filter = ''; $form = new Form($db); print ''.$langs->trans("BankAccount").': '; $form->select_comptes(0, 'accountid', 0, $filter, 1, ''); print ajax_combobox('selectaccountid'); print '
'; } ?>
"reset()", "span" => "style='font-size: 150%;'", "text" => "C", "class" => "poscolorblue" ), array( "function" => "parent.$.colorbox.close();", "span" => "id='printtext' style='font-weight: bold; font-size: 18pt;'", "text" => "X", "class" => "poscolordelete" ), ); $numpad = getDolGlobalString('TAKEPOS_NUMPAD'); if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && getDolGlobalString('STRIPE_CARD_PRESENT')) { print ''; dol_htmloutput_mesg($langs->trans('ConnectingToStripeTerminal', 'Stripe'), '', 'warning', 1); print ''; } print ''; print ''; print ''; ?> 0) { $paycode = $arrayOfValidPaymentModes[0]->code; $payIcon = ''; if ($paycode == 'LIQ') { if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) { $payIcon = 'coins'; } } elseif ($paycode == 'CB') { if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) { $payIcon = 'credit-card'; } } elseif ($paycode == 'CHQ') { if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) { $payIcon = 'money-check'; } } print ''; } else { print ''; } print ''; print ''; print ''; ?> 1) { $paycode = $arrayOfValidPaymentModes[1]->code; $payIcon = ''; if ($paycode == 'LIQ') { if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) { $payIcon = 'coins'; } } elseif ($paycode == 'CB') { if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) { $payIcon = 'credit-card'; } } elseif ($paycode == 'CHQ') { if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) { $payIcon = 'money-check'; } } print ''; } else { $button = array_pop($action_buttons); print ''; } print ''; print ''; print ''; ?> 2) { $paycode = $arrayOfValidPaymentModes[2]->code; $payIcon = ''; if ($paycode == 'LIQ') { if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) { $payIcon = 'coins'; } } elseif ($paycode == 'CB') { if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) { $payIcon = 'credit-card'; } } elseif ($paycode == 'CHQ') { if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) { $payIcon = 'money-check'; } } print ''; } else { $button = array_pop($action_buttons); print ''; } print ''; print ''; print ''; $i = 3; while ($i < count($arrayOfValidPaymentModes)) { $paycode = $arrayOfValidPaymentModes[$i]->code; $payIcon = ''; if ($paycode == 'LIQ') { if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) { $payIcon = 'coins'; } } elseif ($paycode == 'CB') { if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) { $payIcon = 'credit-card'; } } elseif ($paycode == 'CHQ') { if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString('TAKEPOS_NUMPAD_USE_PAYMENT_ICON')) { $payIcon = 'money-check'; } } print ''; $i += 1; } if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && getDolGlobalString('STRIPE_CARD_PRESENT')) { $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$_SESSION["takeposterminal"]; print ''; if (getDolGlobalString($keyforstripeterminalbank)) { // Nothing } else { $langs->loadLangs(array("errors", "admin")); //print ''; } } $keyforsumupbank = "CASHDESK_ID_BANKACCOUNT_SUMUP".$_SESSION["takeposterminal"]; if (getDolGlobalInt("TAKEPOS_ENABLE_SUMUP")) { if (getDolGlobalString($keyforsumupbank)) { print ''; } else { $langs->loadLangs(array("errors", "admin")); print ''; } } $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $invoice, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } $class = ($i == 3) ? "calcbutton3" : "calcbutton2"; foreach ($action_buttons as $button) { $newclass = $class.($button["class"] ? " ".$button["class"] : ""); print ''; } if (getDolGlobalString('TAKEPOS_DELAYED_PAYMENT')) { print ''; } ?> executeHooks('completePayment', $parameters, $invoice); print $hookmanager->resPrint; ?>