terminal.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <?php
  2. /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
  4. * Copyright (C) 2021 Thibault FOUCART <support@ptibogxiv.net>
  5. * Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/takepos/admin/terminal.php
  22. * \ingroup takepos
  23. * \brief Setup page for TakePos module
  24. */
  25. // Load Dolibarr environment
  26. require '../../main.inc.php'; // Load $user and permissions
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  31. require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
  32. require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
  33. $terminal = GETPOST('terminal', 'int');
  34. // If socid provided by ajax company selector
  35. if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal.'_id'])) {
  36. $_GET['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
  37. $_POST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
  38. $_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
  39. }
  40. // Security check
  41. if (!$user->admin) {
  42. accessforbidden();
  43. }
  44. $langs->loadLangs(array("admin", "cashdesk", "printing", "receiptprinter"));
  45. global $db;
  46. $sql = "SELECT code, libelle as label FROM ".MAIN_DB_PREFIX."c_paiement";
  47. $sql .= " WHERE entity IN (".getEntity('c_paiement').")";
  48. $sql .= " AND active = 1";
  49. $sql .= " ORDER BY libelle";
  50. $resql = $db->query($sql);
  51. $paiements = array();
  52. if ($resql) {
  53. while ($obj = $db->fetch_object($resql)) {
  54. array_push($paiements, $obj);
  55. }
  56. }
  57. $terminaltouse = $terminal;
  58. /*
  59. * Actions
  60. */
  61. if (GETPOST('action', 'alpha') == 'set') {
  62. $db->begin();
  63. $res = dolibarr_set_const($db, "TAKEPOS_TERMINAL_NAME_".$terminaltouse, (!empty(GETPOST('terminalname'.$terminaltouse, 'restricthtml')) ? GETPOST('terminalname'.$terminaltouse, 'restricthtml') : $langs->trans("TerminalName", $terminaltouse)), 'chaine', 0, '', $conf->entity);
  64. $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY".$terminaltouse, (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity);
  65. $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
  66. $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
  67. $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
  68. if (isModEnabled('stripe') && getDolGlobalString('STRIPE_CARD_PRESENT')) {
  69. $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$terminaltouse, GETPOST('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
  70. }
  71. if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
  72. $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_SUMUP".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
  73. }
  74. foreach ($paiements as $modep) {
  75. if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) {
  76. continue;
  77. }
  78. $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
  79. $res = dolibarr_set_const($db, $name, (GETPOST($name, 'alpha') > 0 ? GETPOST($name, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
  80. }
  81. $res = dolibarr_set_const($db, "CASHDESK_ID_WAREHOUSE".$terminaltouse, (GETPOST('CASHDESK_ID_WAREHOUSE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
  82. $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK".$terminaltouse, GETPOST('CASHDESK_NO_DECREASE_STOCK'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
  83. $res = dolibarr_set_const($db, "TAKEPOS_PRINTER_TO_USE".$terminaltouse, GETPOST('TAKEPOS_PRINTER_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
  84. $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER1_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
  85. $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER2_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
  86. $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER3_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
  87. $res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
  88. $res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
  89. $res = dolibarr_set_const($db, 'CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, (GETPOST('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, 'int') > 0 ? GETPOST('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, 'int') : ''), 'chaine', 0, '', $conf->entity);
  90. $res = dolibarr_set_const($db, "TAKEPOS_ADDON".$terminaltouse, GETPOST('TAKEPOS_ADDON'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
  91. // add free text on each terminal of cash desk
  92. $res = dolibarr_set_const($db, 'TAKEPOS_HEADER'.$terminaltouse, GETPOST('TAKEPOS_HEADER'.$terminaltouse, 'restricthtml'), 'chaine', 0, '', $conf->entity);
  93. $res = dolibarr_set_const($db, 'TAKEPOS_FOOTER'.$terminaltouse, GETPOST('TAKEPOS_FOOTER'.$terminaltouse, 'restricthtml'), 'chaine', 0, '', $conf->entity);
  94. dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
  95. if (!($res > 0)) {
  96. $error++;
  97. }
  98. if (!$error) {
  99. $db->commit();
  100. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  101. } else {
  102. $db->rollback();
  103. setEventMessages($langs->trans("Error"), null, 'errors');
  104. }
  105. }
  106. /*
  107. * View
  108. */
  109. $form = new Form($db);
  110. $formproduct = new FormProduct($db);
  111. llxHeader('', $langs->trans("CashDeskSetup"));
  112. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  113. print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
  114. $head = takepos_admin_prepare_head();
  115. print dol_get_fiche_head($head, 'terminal'.$terminal, 'TakePOS', -1, 'cash-register');
  116. print '<br>';
  117. // Mode
  118. print '<form action="'.$_SERVER["PHP_SELF"].'?terminal='.(empty($terminal) ? 1 : $terminal).'" method="post">';
  119. print '<input type="hidden" name="token" value="'.newToken().'">';
  120. print '<input type="hidden" name="action" value="set">';
  121. print '<div class="div-table-responsive">';
  122. print '<table class="noborder centpercent">';
  123. print '<tr class="liste_titre">';
  124. print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
  125. print "</tr>\n";
  126. print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("TerminalNameDesc").'</td>';
  127. print '<td>';
  128. print '<input type="text" name="terminalname'.$terminal.'" value="'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$terminal, $langs->trans("TerminalName", $terminal)).'" >';
  129. print '</td></tr>';
  130. print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
  131. print '<td>';
  132. print img_picto('', 'company', 'class="pictofixedwidth"');
  133. $filter = '((s.client:IN:1,2,3) AND (s.status:=:1))';
  134. print $form->select_company(getDolGlobalInt('CASHDESK_ID_THIRDPARTY'.$terminaltouse), 'socid', $filter, 1, 0, 0, array(), 0, 'maxwidth500 widthcentpercentminusx');
  135. print '</td></tr>';
  136. $atleastonefound = 0;
  137. if (isModEnabled("banque")) {
  138. print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
  139. print '<td>';
  140. print img_picto('', 'bank_account', 'class="pictofixedwidth"');
  141. print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 0, "courant=2", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
  142. print ' <a href="'.DOL_URL_ROOT.'/compta/bank/card.php?action=create&type=2&backtopage='.urlencode($_SERVER["PHP_SELF"].'?terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("NewBankAccount").'"></span></a>';
  143. if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse)) {
  144. $atleastonefound++;
  145. }
  146. print '</td></tr>';
  147. print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
  148. print '<td>';
  149. print img_picto('', 'bank_account', 'class="pictofixedwidth"');
  150. print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 0, "courant=1", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
  151. print ' <a href="'.DOL_URL_ROOT.'/compta/bank/card.php?action=create&type=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("NewBankAccount").'"></span></a>';
  152. if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse)) {
  153. $atleastonefound++;
  154. }
  155. print '</td></tr>';
  156. print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
  157. print '<td>';
  158. print img_picto('', 'bank_account', 'class="pictofixedwidth"');
  159. print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 0, "courant=1", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
  160. print ' <a href="'.DOL_URL_ROOT.'/compta/bank/card.php?action=create&type=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("NewBankAccount").'"></span></a>';
  161. if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse)) {
  162. $atleastonefound++;
  163. }
  164. print '</td></tr>';
  165. if (isModEnabled('stripe') && getDolGlobalString('STRIPE_CARD_PRESENT')) {
  166. print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForStripeTerminal").'</td>'; // Force Stripe Terminal
  167. print '<td>';
  168. $service = 'StripeTest';
  169. $servicestatus = 0;
  170. if (getDolGlobalString('STRIPE_LIVE') && !GETPOST('forcesandbox', 'alpha')) {
  171. $service = 'StripeLive';
  172. $servicestatus = 1;
  173. }
  174. global $stripearrayofkeysbyenv;
  175. $site_account = $stripearrayofkeysbyenv[$servicestatus]['secret_key'];
  176. \Stripe\Stripe::setApiKey($site_account);
  177. if (isModEnabled('stripe') && (!getDolGlobalString('STRIPE_LIVE') || GETPOST('forcesandbox', 'alpha'))) {
  178. $service = 'StripeTest';
  179. $servicestatus = '0';
  180. dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
  181. } else {
  182. $service = 'StripeLive';
  183. $servicestatus = '1';
  184. }
  185. $stripe = new Stripe($db);
  186. $stripeacc = $stripe->getStripeAccount($service);
  187. if ($stripeacc) {
  188. $readers = \Stripe\Terminal\Reader::all('', array("location" => $conf->global->STRIPE_LOCATION, "stripe_account" => $stripeacc));
  189. } else {
  190. $readers = \Stripe\Terminal\Reader::all('', array("location" => $conf->global->STRIPE_LOCATION));
  191. }
  192. $reader = array();
  193. $reader[""] = $langs->trans("NoReader");
  194. foreach ($readers as $tmpreader) {
  195. $reader[$tmpreader->id] = $tmpreader->label.' ('.$tmpreader->status.')';
  196. }
  197. print $form->selectarray('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, $reader, getDolGlobalString('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse));
  198. print '</td></tr>';
  199. }
  200. if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
  201. print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSumup").'</td>';
  202. print '<td>';
  203. print img_picto('', 'bank_account', 'class="pictofixedwidth"');
  204. print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 0, "courant=1", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
  205. print ' <a href="'.DOL_URL_ROOT.'/compta/bank/card.php?action=create&type=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("NewBankAccount").'"></span></a>';
  206. if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse)) {
  207. $atleastonefound++;
  208. }
  209. print '</td></tr>';
  210. }
  211. foreach ($paiements as $modep) {
  212. if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) {
  213. continue; // Already managed before
  214. }
  215. $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
  216. print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->label).'</td>';
  217. print '<td>';
  218. if (!empty($conf->global->$name)) {
  219. $atleastonefound++;
  220. }
  221. $cour = preg_match('/^LIQ.*/', $modep->code) ? 2 : 1;
  222. print img_picto('', 'bank_account', 'class="pictofixedwidth"');
  223. print $form->select_comptes(getDolGlobalInt($name), $name, 0, "courant=".$cour, 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
  224. print ' <a href="'.DOL_URL_ROOT.'/compta/bank/card.php?action=create&type=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("NewBankAccount").'"></span></a>';
  225. print '</td></tr>';
  226. }
  227. }
  228. if (isModEnabled('stock')) {
  229. print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>'; // Force warehouse (this is not a default value)
  230. print '<td>';
  231. print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK'.$terminal, getDolGlobalInt('CASHDESK_NO_DECREASE_STOCK'.$terminal), 1);
  232. print '</td></tr>';
  233. $disabled = getDolGlobalString('CASHDESK_NO_DECREASE_STOCK'.$terminal);
  234. print '<tr class="oddeven"><td>';
  235. if (!$disabled) { print '<span class="fieldrequired">'; }
  236. print $langs->trans("CashDeskIdWareHouse");
  237. if (!$disabled) { print '</span>'; }
  238. if (!getDolGlobalString('CASHDESK_ID_WAREHOUSE'.$terminal)) {
  239. print img_warning($langs->trans("DisableStockChange").' - '.$langs->trans("NoWarehouseDefinedForTerminal"));
  240. }
  241. print '</td>'; // Force warehouse (this is not a default value)
  242. print '<td class="minwidth300">';
  243. if (!$disabled) {
  244. print img_picto('', 'stock', 'class="pictofixedwidth"');
  245. print $formproduct->selectWarehouses(getDolGlobalString('CASHDESK_ID_WAREHOUSE'.$terminal), 'CASHDESK_ID_WAREHOUSE'.$terminal, '', 1, $disabled, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx');
  246. print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?&terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
  247. } else {
  248. print '<span class="opacitymedium">'.$langs->trans("StockDecreaseForPointOfSaleDisabled").'</span>';
  249. }
  250. print '</td></tr>';
  251. if (isModEnabled('productbatch') && getDolGlobalString('CASHDESK_FORCE_DECREASE_STOCK') && !getDolGlobalString('CASHDESK_NO_DECREASE_STOCK'.$terminal)) {
  252. print '<tr class="oddeven"><td>'.$langs->trans('CashDeskForceDecreaseStockLabel').'</td>';
  253. print '<td>';
  254. print '<span class="opacitymedium">'.$langs->trans('CashDeskForceDecreaseStockDesc').'</span>';
  255. print '</td></tr>';
  256. }
  257. }
  258. if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
  259. // Select printer to use with terminal
  260. require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
  261. $printer = new dolReceiptPrinter($db);
  262. if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
  263. $printer->listprinters();
  264. $printers = array();
  265. foreach ($printer->listprinters as $key => $value) {
  266. $printers[$value['rowid']] = $value['name'];
  267. }
  268. print '<tr class="oddeven"><td>'.$langs->trans("MainPrinterToUse").'</td>';
  269. print '<td>';
  270. print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$terminal), 1);
  271. print '</td></tr>';
  272. if (getDolGlobalInt('TAKEPOS_ORDER_PRINTERS')) {
  273. print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 1</td>';
  274. print '<td>';
  275. print $form->selectarray('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal), 1);
  276. print '</td></tr>';
  277. print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 2</td>';
  278. print '<td>';
  279. print $form->selectarray('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal), 1);
  280. print '</td></tr>';
  281. print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 3</td>';
  282. print '<td>';
  283. print $form->selectarray('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal), 1);
  284. print '</td></tr>';
  285. }
  286. }
  287. $printer->listPrintersTemplates();
  288. $templates = array();
  289. foreach ($printer->listprinterstemplates as $key => $value) {
  290. $templates[$value['rowid']] = $value['name'];
  291. }
  292. print '<tr class="oddeven"><td>'.$langs->trans("MainTemplateToUse").' (<a href="'.DOL_URL_ROOT.'/admin/receiptprinter.php?mode=template">'.$langs->trans("SetupReceiptTemplate").'</a>)</td>';
  293. print '<td>';
  294. print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal, $templates, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal), 1);
  295. print '</td></tr>';
  296. if (getDolGlobalInt('TAKEPOS_ORDER_PRINTERS')) {
  297. print '<tr class="oddeven"><td>'.$langs->trans("OrderTemplateToUse").'</td>';
  298. print '<td>';
  299. print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal, $templates, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal), 1);
  300. print '</td></tr>';
  301. }
  302. }
  303. print '<tr class="oddeven"><td>'.$langs->trans('CashDeskReaderKeyCodeForEnter').'</td>';
  304. print '<td>';
  305. print '<input type="text" class="width50" name="CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse.'" value="'.getDolGlobalString('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse).'" />';
  306. print '</td></tr>';
  307. // Numbering module
  308. if (getDolGlobalString('TAKEPOS_ADDON') == "terminal") {
  309. print '<tr class="oddeven"><td>';
  310. print $langs->trans("BillsNumberingModule");
  311. print '<td colspan="2">';
  312. $array = array(0 => $langs->trans("Default"));
  313. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  314. foreach ($dirmodels as $reldir) {
  315. $dir = dol_buildpath($reldir."core/modules/facture/");
  316. if (is_dir($dir)) {
  317. $handle = opendir($dir);
  318. if (is_resource($handle)) {
  319. while (($file = readdir($handle)) !== false) {
  320. if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) {
  321. $filebis = $file;
  322. $classname = preg_replace('/\.php$/', '', $file);
  323. // For compatibility
  324. if (!is_file($dir.$filebis)) {
  325. $filebis = $file."/".$file.".modules.php";
  326. $classname = "mod_facture_".$file;
  327. }
  328. // Check if there is a filter on country
  329. preg_match('/\-(.*)_(.*)$/', $classname, $reg);
  330. if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
  331. continue;
  332. }
  333. $classname = preg_replace('/\-.*$/', '', $classname);
  334. if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
  335. // Charging the numbering class
  336. require_once $dir.$filebis;
  337. $module = new $classname($db);
  338. // Show modules according to features level
  339. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  340. continue;
  341. }
  342. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  343. continue;
  344. }
  345. if ($module->isEnabled()) {
  346. $array[preg_replace('/\-.*$/', '', preg_replace('/\.php$/', '', $file))] = preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
  347. }
  348. }
  349. }
  350. }
  351. closedir($handle);
  352. }
  353. }
  354. }
  355. print $form->selectarray('TAKEPOS_ADDON'.$terminaltouse, $array, getDolGlobalString('TAKEPOS_ADDON'.$terminaltouse, '0'), 0);
  356. print "</td></tr>\n";
  357. print '</table>';
  358. print '</div>';
  359. }
  360. print '</table>';
  361. print '</div>';
  362. // add free text on each terminal of cash desk
  363. $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
  364. $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans('Translation');
  365. $htmltext = '<i>'.$langs->trans('AvailableVariables').':<br>';
  366. foreach ($substitutionarray as $key => $val) {
  367. $htmltext .= $key.'<br>';
  368. }
  369. $htmltext .= '</i>';
  370. print '<br>';
  371. print load_fiche_titre($langs->trans('FreeLegalTextOnInvoices'), '', '');
  372. print '<div class="div-table-responsive-no-min">';
  373. print '<table class="noborder centpercent">';
  374. print '<tr class="liste_titre">';
  375. print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans('Value').'</td>';
  376. print '</tr>';
  377. // free text on header
  378. print '<tr class="oddeven">';
  379. print '<td>';
  380. print $form->textwithpicto($langs->trans('Header'), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
  381. print '</td>';
  382. print '<td>';
  383. $variablename = 'TAKEPOS_HEADER'.$terminaltouse;
  384. if (!getDolGlobalInt('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
  385. print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
  386. } else {
  387. include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  388. $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
  389. print $doleditor->Create();
  390. }
  391. print '</td></tr>';
  392. // free text on footer
  393. print '<tr class="oddeven">';
  394. print '<td>';
  395. print $form->textwithpicto($langs->trans('Footer'), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
  396. print '</td>';
  397. print '<td>';
  398. $variablename = 'TAKEPOS_FOOTER'.$terminaltouse;
  399. if (!getDolGlobalInt('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
  400. print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
  401. } else {
  402. include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  403. $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
  404. print $doleditor->Create();
  405. }
  406. print '</td></tr>';
  407. print '</table>';
  408. print '</div>';
  409. if ($atleastonefound == 0 && isModEnabled("banque")) {
  410. print info_admin($langs->trans("AtLeastOneDefaultBankAccountMandatory"), 0, 0, 'error');
  411. }
  412. print '<br>';
  413. print $form->buttonsSaveCancel("Save", '');
  414. print "</form>\n";
  415. print '<br>';
  416. llxFooter();
  417. $db->close();