2019-09-29 18:56:24 +00:00
< ? php
2022-08-27 04:35:19 +00:00
/* Copyright ( C ) 2008 - 2011 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2011 - 2017 Juanjo Menent < jmenent @ 2 byte . es >
* Copyright ( C ) 2019 Andreu Bisquerra Gaya < jove @ bisquerra . com >
* Copyright ( C ) 2021 Nicolas ZABOURI < info @ inovea - conseil . com >
* Copyright ( C ) 2022 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2024-11-04 22:53:20 +00:00
* Copyright ( C ) 2024 Frédéric France < frederic . france @ free . fr >
2019-09-29 18:56:24 +00:00
*
* 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
2022-09-07 18:21:01 +00:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2019-09-29 18:56:24 +00:00
*/
/**
2022-08-27 03:39:27 +00:00
* \file htdocs / takepos / admin / receipt . php
2019-09-29 18:56:24 +00:00
* \ingroup takepos
* \brief Setup page for TakePos module
*/
2022-09-07 18:08:59 +00:00
// Load Dolibarr environment
2019-11-14 11:09:46 +00:00
require '../../main.inc.php' ; // Load $user and permissions
2024-11-04 22:53:20 +00:00
/**
* @ var Conf $conf
* @ var DoliDB $db
* @ var HookManager $hookmanager
* @ var Translate $langs
* @ var User $user
2026-01-03 15:50:59 +00:00
* @ var Societe $mysoc
2024-11-04 22:53:20 +00:00
*/
2026-01-02 16:00:43 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/pdf.lib.php' ;
require_once DOL_DOCUMENT_ROOT . " /core/lib/takepos.lib.php " ;
2026-02-17 20:21:48 +00:00
require_once DOL_DOCUMENT_ROOT . " /blockedlog/lib/blockedlog.lib.php " ;
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php' ;
2024-11-04 22:53:20 +00:00
2019-09-29 18:56:24 +00:00
// Security check
2021-02-26 20:17:52 +00:00
if ( ! $user -> admin ) {
accessforbidden ();
}
2019-09-29 18:56:24 +00:00
$langs -> loadLangs ( array ( " admin " , " cashdesk " , " commercial " ));
2022-09-22 19:18:35 +00:00
2019-09-29 18:56:24 +00:00
/*
* Actions
*/
2024-11-10 10:16:23 +00:00
$error = 0 ;
2019-09-29 18:56:24 +00:00
2021-02-26 20:17:52 +00:00
if ( GETPOST ( 'action' , 'alpha' ) == 'set' ) {
2019-09-29 18:56:24 +00:00
$db -> begin ();
2019-10-20 15:17:22 +00:00
2021-09-22 18:14:47 +00:00
$res = dolibarr_set_const ( $db , " TAKEPOS_HEADER " , GETPOST ( 'TAKEPOS_HEADER' , 'restricthtml' ), 'chaine' , 0 , '' , $conf -> entity );
$res = dolibarr_set_const ( $db , " TAKEPOS_FOOTER " , GETPOST ( 'TAKEPOS_FOOTER' , 'restricthtml' ), 'chaine' , 0 , '' , $conf -> entity );
2019-09-29 18:56:24 +00:00
$res = dolibarr_set_const ( $db , " TAKEPOS_RECEIPT_NAME " , GETPOST ( 'TAKEPOS_RECEIPT_NAME' , 'alpha' ), 'chaine' , 0 , '' , $conf -> entity );
2020-10-31 13:32:18 +00:00
$res = dolibarr_set_const ( $db , " TAKEPOS_PRINT_SERVER " , GETPOST ( 'TAKEPOS_PRINT_SERVER' , 'alpha' ), 'chaine' , 0 , '' , $conf -> entity );
2021-10-07 07:51:55 +00:00
$res = dolibarr_set_const ( $db , 'TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT' , GETPOST ( 'TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT' , 'alphanohtml' ), 'chaine' , 0 , '' , $conf -> entity );
2019-10-20 15:17:22 +00:00
2019-09-29 18:56:24 +00:00
dol_syslog ( " admin/cashdesk: level " . GETPOST ( 'level' , 'alpha' ));
2021-02-26 20:17:52 +00:00
if ( ! ( $res > 0 )) {
$error ++ ;
}
2019-09-29 18:56:24 +00:00
2021-02-26 20:17:52 +00:00
if ( ! $error ) {
2020-10-31 13:32:18 +00:00
$db -> commit ();
setEventMessages ( $langs -> trans ( " SetupSaved " ), null , 'mesgs' );
} else {
$db -> rollback ();
setEventMessages ( $langs -> trans ( " Error " ), null , 'errors' );
}
2021-02-26 20:17:52 +00:00
} elseif ( GETPOST ( 'action' , 'alpha' ) == 'setmethod' ) {
2020-10-31 13:32:18 +00:00
dolibarr_set_const ( $db , " TAKEPOS_PRINT_METHOD " , GETPOST ( 'value' , 'alpha' ), 'chaine' , 0 , '' , $conf -> entity );
2020-11-11 20:51:32 +00:00
// TakePOS connector require ReceiptPrinter module
2022-09-22 19:18:35 +00:00
if ( getDolGlobalString ( 'TAKEPOS_PRINT_METHOD' ) == " takeposconnector " && ! isModEnabled ( 'receiptprinter' )) {
2026-02-09 21:43:56 +00:00
activateModule ( " modReceiptPrinter " , 1 , 0 );
2021-02-26 20:17:52 +00:00
}
2020-02-20 14:16:17 +00:00
}
2019-09-29 18:56:24 +00:00
/*
* View
*/
2019-11-14 11:09:46 +00:00
$form = new Form ( $db );
2019-09-29 18:56:24 +00:00
2024-06-09 09:49:33 +00:00
llxHeader ( '' , $langs -> trans ( " CashDeskSetup " ), '' , '' , 0 , 0 , '' , '' , '' , 'mod-takepos page-admin_receipt' );
2019-09-29 18:56:24 +00:00
2026-06-15 12:43:25 +00:00
$linkback = '<a href="' . dolBuildUrl ( DOL_URL_ROOT . '/admin/modules.php' , [ 'restore_lastsearch_values' => 1 ]) . '">' . img_picto ( $langs -> trans ( " BackToModuleList " ), 'back' , 'class="pictofixedwidth"' ) . '<span class="hideonsmartphone">' . $langs -> trans ( " BackToModuleList " ) . '</span></a>' ;
2026-01-02 16:00:43 +00:00
2019-09-29 18:56:24 +00:00
print load_fiche_titre ( $langs -> trans ( " CashDeskSetup " ) . ' (TakePOS)' , $linkback , 'title_setup' );
2026-01-02 16:00:43 +00:00
2020-08-20 20:17:34 +00:00
$head = takepos_admin_prepare_head ();
2020-10-22 20:50:03 +00:00
print dol_get_fiche_head ( $head , 'receipt' , 'TakePOS' , - 1 , 'cash-register' );
2019-09-29 18:56:24 +00:00
2026-01-02 16:00:43 +00:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="post">' ;
2019-12-18 22:12:31 +00:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-09-29 18:56:24 +00:00
print '<input type="hidden" name="action" value="set">' ;
2021-04-28 16:04:00 +00:00
print load_fiche_titre ( $langs -> trans ( " Receipt " ), '' , '' );
2020-02-20 14:16:17 +00:00
2020-08-13 11:46:53 +00:00
print '<div class="div-table-responsive-no-min">' ;
2020-02-20 14:16:17 +00:00
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Parameters " ) . '</td><td>' . $langs -> trans ( " Value " ) . '</td>' ;
print " </tr> \n " ;
2020-08-13 11:46:53 +00:00
// VAT Grouped on ticket
print '<tr class="oddeven"><td>' ;
print $langs -> trans ( 'TicketVatGrouped' );
print '<td colspan="2">' ;
2026-02-17 20:21:48 +00:00
if ( isALNERunningVersion ()) {
// Always forced to true
2026-02-17 21:00:22 +00:00
$conf -> global -> TAKEPOS_TICKET_VAT_GROUPPED = 1 ;
print img_picto ( $langs -> trans ( " Enabled " ), 'switch_on' , 'class="opacitymedium valignmiddle"' );
print ' <span class="opacitymedium valignmiddle">' . $langs -> trans ( " Always " ) . '</span>' ;
2026-02-17 20:21:48 +00:00
} else {
print ajax_constantonoff ( " TAKEPOS_TICKET_VAT_GROUPPED " , array (), $conf -> entity , 0 , 0 , 1 , 0 );
}
2020-08-13 11:46:53 +00:00
print " </td></tr> \n " ;
2022-09-22 19:18:35 +00:00
if ( getDolGlobalString ( 'TAKEPOS_PRINT_METHOD' ) == " browser " || getDolGlobalString ( 'TAKEPOS_PRINT_METHOD' ) == " takeposconnector " ) {
2026-04-30 00:16:26 +00:00
$substitutionarray = pdf_getSubstitutionArray ( $langs , array ( 'ticket' , 'member' , 'candidate' , 'shipping' ), null , 2 , array ( 'mycompany' , 'company' , 'user' , 'object' , 'system' ));
2020-02-20 14:16:17 +00:00
$substitutionarray [ '__(AnyTranslationKey)__' ] = $langs -> trans ( " Translation " );
2023-03-25 11:40:23 +00:00
2026-01-04 14:36:32 +00:00
$htmltext = '<i class="small">' . $langs -> trans ( " AvailableVariables " ) . ':<br>' ;
2021-02-26 20:17:52 +00:00
foreach ( $substitutionarray as $key => $val ) {
$htmltext .= $key . '<br>' ;
}
2020-02-20 14:16:17 +00:00
$htmltext .= '</i>' ;
print '<tr class="oddeven"><td>' ;
print $form -> textwithpicto ( $langs -> trans ( " FreeLegalTextOnInvoices " ) . " - " . $langs -> trans ( " Header " ), $htmltext , 1 , 'help' , '' , 0 , 2 , 'freetexttooltip' ) . '<br>' ;
print '</td><td>' ;
$variablename = 'TAKEPOS_HEADER' ;
2022-09-22 19:18:35 +00:00
if ( ! getDolGlobalString ( 'PDF_ALLOW_HTML_FOR_FREE_TEXT' )) {
2022-06-21 18:25:25 +00:00
print '<textarea name="' . $variablename . '" class="flat" cols="120">' . getDolGlobalString ( $variablename ) . '</textarea>' ;
2020-05-21 13:05:19 +00:00
} else {
2020-02-20 14:16:17 +00:00
include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2022-06-21 21:39:31 +00:00
$doleditor = new DolEditor ( $variablename , getDolGlobalString ( $variablename ), '' , 80 , 'dolibarr_notes' );
2020-02-20 14:16:17 +00:00
print $doleditor -> Create ();
}
print " </td></tr> \n " ;
2020-02-20 14:45:42 +00:00
2020-02-20 14:16:17 +00:00
print '<tr class="oddeven"><td>' ;
print $form -> textwithpicto ( $langs -> trans ( " FreeLegalTextOnInvoices " ) . " - " . $langs -> trans ( " Footer " ), $htmltext , 1 , 'help' , '' , 0 , 2 , 'freetexttooltip' ) . '<br>' ;
print '</td><td>' ;
$variablename = 'TAKEPOS_FOOTER' ;
2022-09-22 19:18:35 +00:00
if ( ! getDolGlobalString ( 'PDF_ALLOW_HTML_FOR_FREE_TEXT' )) {
2022-06-21 18:25:25 +00:00
print '<textarea name="' . $variablename . '" class="flat" cols="120">' . getDolGlobalString ( $variablename ) . '</textarea>' ;
2020-05-21 13:05:19 +00:00
} else {
2020-02-20 14:16:17 +00:00
include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2022-06-21 21:39:31 +00:00
$doleditor = new DolEditor ( $variablename , getDolGlobalString ( $variablename ), '' , 80 , 'dolibarr_notes' );
2020-02-20 14:16:17 +00:00
print $doleditor -> Create ();
}
print " </td></tr> \n " ;
print '<tr class="oddeven"><td><label for="receipt_name">' . $langs -> trans ( " ReceiptName " ) . '</label></td><td>' ;
2022-09-22 19:18:35 +00:00
print '<input name="TAKEPOS_RECEIPT_NAME" id="TAKEPOS_RECEIPT_NAME" class="minwidth200" value="' . getDolGlobalString ( 'TAKEPOS_RECEIPT_NAME' ) . '">' ;
2020-02-20 14:16:17 +00:00
print '</td></tr>' ;
// Customer information
print '<tr class="oddeven"><td>' ;
2020-03-16 14:41:21 +00:00
print $langs -> trans ( 'PrintCustomerOnReceipts' );
2020-02-20 14:16:17 +00:00
print '<td colspan="2">' ;
2022-08-27 04:35:19 +00:00
print ajax_constantonoff ( " TAKEPOS_SHOW_CUSTOMER " , array (), $conf -> entity , 0 , 0 , 1 , 0 );
2020-02-20 14:16:17 +00:00
print " </td></tr> \n " ;
2020-08-22 16:45:54 +00:00
2020-08-22 16:28:15 +00:00
// Print payment method
2026-05-26 16:48:53 +00:00
// When LNE is own, we show an information to the user to help him understand that the feature is forced.
2020-08-22 16:28:15 +00:00
print '<tr class="oddeven"><td>' ;
print $langs -> trans ( 'PrintPaymentMethodOnReceipts' );
print '<td colspan="2">' ;
2025-10-28 12:07:19 +00:00
include_once DOL_DOCUMENT_ROOT . '/blockedlog/lib/blockedlog.lib.php' ;
if ( isALNERunningVersion ()) {
$conf -> global -> TAKEPOS_PRINT_PAYMENT_METHOD = 1 ;
print ajax_constantonoff ( " TAKEPOS_PRINT_PAYMENT_METHOD " , array (), $conf -> entity , 0 , 0 , 1 , 0 , 0 , 0 , '' , '' , 'inline-block' , 0 , '' , 1 );
2026-01-03 16:24:43 +00:00
print '<span class="opacitymedium">' . $langs -> trans ( " Always " ) . '</span>' ;
2025-10-28 12:07:19 +00:00
} else {
print ajax_constantonoff ( " TAKEPOS_PRINT_PAYMENT_METHOD " , array (), $conf -> entity , 0 , 0 , 1 , 0 );
}
2020-08-22 16:28:15 +00:00
print " </td></tr> \n " ;
2020-02-20 14:16:17 +00:00
}
2019-09-29 18:56:24 +00:00
2021-02-24 14:48:15 +00:00
// Show price without vat
print '<tr class="oddeven"><td>' ;
print $langs -> trans ( 'ShowPriceHTOnReceipt' );
print '<td colspan="2">' ;
2026-01-03 16:24:43 +00:00
if ( isALNERunningVersion ()) {
2026-02-17 21:00:22 +00:00
$conf -> global -> TAKEPOS_SHOW_HT_RECEIPT = 1 ;
2026-01-03 16:24:43 +00:00
print ajax_constantonoff ( " TAKEPOS_SHOW_HT_RECEIPT " , array (), $conf -> entity , 0 , 0 , 1 , 0 , 0 , 0 , '' , '' , 'inline-block' , 0 , '' , 1 );
print '<span class="opacitymedium">' . $langs -> trans ( " Always " ) . '</span>' ;
} else {
print ajax_constantonoff ( " TAKEPOS_SHOW_HT_RECEIPT " , array (), $conf -> entity , 0 , 0 , 1 , 0 );
}
2021-02-24 14:48:15 +00:00
print " </td></tr> \n " ;
2022-08-27 06:28:39 +00:00
if ( getDolGlobalString ( 'TAKEPOS_PRINT_METHOD' ) == " takeposconnector " && filter_var ( getDolGlobalString ( 'TAKEPOS_PRINT_SERVER' ), FILTER_VALIDATE_URL ) == true ) {
2020-09-13 19:12:14 +00:00
print '<tr class="oddeven"><td>' ;
print $langs -> trans ( 'WeighingScale' );
print '<td colspan="2">' ;
print ajax_constantonoff ( " TAKEPOS_WEIGHING_SCALE " , array (), $conf -> entity , 0 , 0 , 1 , 0 );
print " </td></tr> \n " ;
}
2022-09-22 19:18:35 +00:00
if ( getDolGlobalString ( 'TAKEPOS_PRINT_METHOD' ) == " takeposconnector " && filter_var ( getDolGlobalString ( 'TAKEPOS_PRINT_SERVER' ), FILTER_VALIDATE_URL ) == true ) {
2021-08-08 17:16:11 +00:00
print '<tr class="oddeven"><td>' ;
print $langs -> trans ( 'CustomerDisplay' );
print '<td colspan="2">' ;
print ajax_constantonoff ( " TAKEPOS_CUSTOMER_DISPLAY " , array (), $conf -> entity , 0 , 0 , 1 , 0 );
print " </td></tr> \n " ;
}
2021-10-07 07:51:55 +00:00
// Print without details
2026-05-26 16:48:53 +00:00
if ( getDolGlobalString ( 'TAKEPOS_ENABLE_PRINT_WITHOUT_DETAILS' )) { // Note that even if option is set manually, if version is certified, option will be disabled later and above all in the page that generate the documents/receipts.
2021-10-07 07:51:55 +00:00
print '<tr class="oddeven"><td>' ;
2026-05-26 16:48:53 +00:00
print $langs -> trans ( 'PrintWithoutDetailsButton' );
2021-10-07 07:51:55 +00:00
print '<td colspan="2">' ;
2026-05-26 16:48:53 +00:00
if ( isALNERunningVersion ()) {
// Always forced to true
$conf -> global -> TAKEPOS_PRINT_WITHOUT_DETAILS = 1 ;
print img_picto ( $langs -> trans ( " Disabled " ), 'switch_off' , 'class="opacitymedium valignmiddle"' );
print ' <span class="opacitymedium valignmiddle">' . $form -> textwithpicto ( $langs -> trans ( " NotAvailable " ), $langs -> trans ( " NotAvailableForCountryWhenModuleIsOn " , $mysoc -> country_code , $langs -> transnoentitiesnoconv ( 'Module3200Name' ))) . '</span>' ;
} else {
print ajax_constantonoff ( 'TAKEPOS_PRINT_WITHOUT_DETAILS' , array (), $conf -> entity , 0 , 0 , 1 , 0 , 0 , 0 , '' , '' , 'inline-block' , 0 , '' );
}
2021-10-07 07:51:55 +00:00
print " </td></tr> \n " ;
2026-05-26 16:48:53 +00:00
if ( getDolGlobalString ( 'TAKEPOS_PRINT_WITHOUT_DETAILS' )) {
print '<tr class="oddeven"><td>' ;
print $langs -> trans ( 'PrintWithoutDetailsLabelDefault' );
print '<td colspan="2">' ;
print '<input type="text" name="TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT" value="' . getDolGlobalString ( 'TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT' ) . '" />' ;
print " </td></tr> \n " ;
}
2021-10-07 07:51:55 +00:00
}
2026-01-03 15:50:59 +00:00
// Gift receipt
print '<tr class="oddeven"><td>' ;
print $langs -> trans ( 'GiftReceiptButton' );
print '<td>' ;
if ( isALNERunningVersion ()) {
2026-01-03 16:24:43 +00:00
print ajax_constantonoff ( " TAKEPOS_GIFT_RECEIPT " , array (), $conf -> entity , 0 , 0 , 1 , 0 , 0 , 0 , '' , '' , 'inline-block' , 0 , '' , 1 );
2026-01-04 14:36:32 +00:00
print '<span class="opacitymedium">' . $form -> textwithpicto ( $langs -> trans ( " NotAvailable " ), $langs -> trans ( " NotAvailableForCountryWhenModuleIsOn " , $mysoc -> country_code , $langs -> transnoentitiesnoconv ( 'Module3200Name' ))) . '</span>' ;
2026-01-03 15:50:59 +00:00
} else {
print ajax_constantonoff ( " TAKEPOS_GIFT_RECEIPT " , array (), $conf -> entity , 0 , 0 , 1 , 0 );
}
print " </td></tr> \n " ;
2023-03-25 11:40:23 +00:00
// Auto print tickets
print '<tr class="oddeven"><td>' ;
print $langs -> trans ( " AutoPrintTickets " );
print '<td colspan="2">' ;
print ajax_constantonoff ( " TAKEPOS_AUTO_PRINT_TICKETS " , array (), $conf -> entity , 0 , 0 , 1 , 0 );
print " </td></tr> \n " ;
2019-09-29 18:56:24 +00:00
print '</table>' ;
2020-08-13 11:46:53 +00:00
print '</div>' ;
2019-09-29 18:56:24 +00:00
2021-08-20 12:41:30 +00:00
print $form -> buttonsSaveCancel ( " Save " , '' );
2019-09-29 18:56:24 +00:00
print " </form> \n " ;
2024-08-30 13:06:19 +00:00
print '<br>' ;
2022-11-02 06:28:14 +00:00
print load_fiche_titre ( $langs -> trans ( " Preview " ), '' , '' );
print '<div style="width: 50%; float:center;background-color:#606060">' ;
print '<center>' ;
2025-08-21 16:25:52 +00:00
// Call takepos/receipt.php
2025-10-19 23:47:43 +00:00
print '<iframe id="iframe" allowtransparency="true" style="background: #FFFFFF;" src="' . DOL_URL_ROOT . '/takepos/receipt.php?forcenoautoopen=1&specimen=1" width="80%" height="600"></iframe>' ;
2025-08-21 16:25:52 +00:00
2022-11-02 06:28:14 +00:00
print '</center>' ;
print '</div>' ;
2019-09-29 18:56:24 +00:00
print '<br>' ;
llxFooter ();
$db -> close ();