31require
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/receiptprinter.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
45$langs->loadLangs(array(
"admin",
"receiptprinter"));
51$action =
GETPOST(
'action',
'aZ09');
52$mode =
GETPOST(
'mode',
'alpha');
54$printername =
GETPOST(
'printername',
'alpha');
57$parameter =
GETPOST(
'parameter',
'alpha');
59$template =
GETPOST(
'template',
'alphanohtml');
60$templatename =
GETPOST(
'templatename',
'alpha');
64$hookmanager->initHooks(array(
'receiptPrinter',
'globalcard'));
70if (!function_exists(
'gzdecode')) {
78 function gzdecode($data)
80 return gzinflate(substr($data, 10, -8));
89if ($action ==
'addprinter') {
91 if (empty($printername)) {
96 if (empty($parameter) && $printertypeid > 1) {
102 $result = $printer->addPrinter($printername, $printertypeid,
GETPOSTINT(
'printerprofileid'), $parameter);
118if ($action ==
'deleteprinter') {
120 if (empty($printerid)) {
127 $result = $printer->deletePrinter($printerid);
143if ($action ==
'updateprinter') {
145 if (empty($printerid)) {
152 $result = $printer->updatePrinter($printername,
GETPOSTINT(
'printertypeid'),
GETPOSTINT(
'printerprofileid'), $parameter, $printerid);
168if ($action ==
'testprinter') {
170 if (empty($printerid)) {
177 $ret = $printer->sendTestToPrinter($printerid);
187if ($action ==
'testprinter2') {
189 if (empty($printerid)) {
196 $ret = $printer->sendTestToPrinter($printerid, 1);
206if ($action ==
'testtemplate') {
208 if (empty($printerid)) {
209 $ret = $printer->listPrinters();
213 } elseif (!empty($printer->listprinters)) {
215 $printerid = (int) min(array_column($printer->listprinters,
'rowid'));
218 if (!$error && empty($printerid)) {
225 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
230 $ret = $printer->sendToPrinter(
$object, $templateid, $printerid);
232 setEventMessages($langs->trans(
"TestTemplateToPrinter", $printername),
null);
240if ($action ==
'updatetemplate') {
242 if (empty($templateid)) {
249 $result = $printer->updateTemplate($templatename, $template, $templateid);
265if ($action ==
'addtemplate') {
267 if (empty($templatename)) {
274 $result = $printer->addTemplate($templatename, $template);
290if ($action ==
'deletetemplate') {
292 if (empty($templateid)) {
299 $result = $printer->deleteTemplate($templateid);
320$form =
new Form($db);
322llxHeader(
'', $langs->trans(
"ReceiptPrinterSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-receiptprinter');
324$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>';
326print
load_fiche_titre($langs->trans(
"ReceiptPrinterSetup"), $linkback,
'title_setup');
332if ($mode ==
'config') {
333 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=config" autocomplete="off">';
334 print
'<input type="hidden" name="token" value="'.newToken().
'">';
335 if ($action !=
'editprinter') {
336 print
'<input type="hidden" name="action" value="addprinter">';
338 print
'<input type="hidden" name="action" value="updateprinter">';
348 print
'<div class="div-table-responsive">';
349 print
'<table class="noborder centpercent">'.
"\n";
350 print
'<tr class="liste_titre">';
351 print
'<th>'.$langs->trans(
"Name").
'</th>';
352 print
'<th>'.$langs->trans(
"Type").
'</th>';
364 print
'<th>'.$langs->trans(
"Parameters").
'</th>';
368 $ret = $printer->listprinters();
369 $nbofprinters = count($printer->listprinters);
371 if ($action !=
'editprinter') {
373 print
'<td><input class="minwidth100" type="text" name="printername"></td>';
374 $ret = $printer->selectTypePrinter();
375 print
'<td>'.$printer->resprint.
'</td>';
380 print
'<td><input class="minwidth150" type="text" name="parameter"></td>';
381 print
'<td class="right">';
382 if ($action !=
'editprinter') {
383 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'"></div>';
392 for ($line = 0; $line < $nbofprinters; $line++) {
393 print
'<tr class="oddeven">';
394 if ($action ==
'editprinter' && $printer->listprinters[$line][
'rowid'] == $printerid) {
395 print
'<input type="hidden" name="printerid" value="'.$printer->listprinters[$line][
'rowid'].
'">';
396 print
'<td><input type="text" class="minwidth200" name="printername" value="'.$printer->listprinters[$line][
'name'].
'"></td>';
397 $ret = $printer->selectTypePrinter((
string) $printer->listprinters[$line][
'fk_type']);
398 print
'<td>'.$printer->resprint.
'</td>';
403 print
'<td><input class="minwidth150" type="text" name="parameter" value="'.$printer->listprinters[$line][
'parameter'].
'"></td>';
405 print $form->buttonsSaveCancel(
"Save",
'');
409 print
'<td>'.$printer->listprinters[$line][
'name'].
'</td>';
410 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_type_name']).
'</td>';
414 print
'<td>'.$printer->listprinters[$line][
'parameter'].
'</td>';
416 print
'<td class="center">';
417 print
'<a class="editfielda marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=editprinter&token='.
newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'">';
418 print
img_picto($langs->trans(
"Edit"),
'edit',
'class="paddingright"');
421 print
'<a class="marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=deleteprinter&token='.
newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'&printername='.urlencode($printer->listprinters[$line][
'name']).
'">';
422 print
img_picto($langs->trans(
"Delete"),
'delete',
'class="paddingright"');
425 print
'<a class="marginrightonly nowraponall" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=testprinter&token='.
newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'&printername='.urlencode($printer->listprinters[$line][
'name']).
'">';
426 print
img_picto($langs->trans(
"TestPrinterDesc"),
'printer',
'class="paddingright paddingleft"').
'TXT';
429 print
'<a class="marginrightonly nowraponall" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=testprinter2&token='.
newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'&printername='.urlencode($printer->listprinters[$line][
'name']).
'">';
430 print
img_picto($langs->trans(
"TestPrinterDesc2"),
'printer',
'class="paddingright paddingleft"').
'IMG';
448 print
'<span class="opacitymedium">'.$langs->trans(
"ReceiptPrinterTypeDesc").
'...</span><br><br>'.
"\n";
450 print
'<div class="div-table-responsive">';
451 print
'<table class="noborder centpercent">'.
"\n";
452 print
'<tr class="oddeven"><td class="minwidth100">'.$langs->trans(
"CONNECTOR_DUMMY").
'</td><td>'.$langs->trans(
"CONNECTOR_DUMMY_HELP").
'</td></tr>';
453 print
'<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans(
"CONNECTOR_FILE_PRINT"), $langs->trans(
"FromServerPointOfView")).
'</td><td>'.$langs->trans(
"CONNECTOR_FILE_PRINT_HELP").
'</td></tr>';
454 print
'<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans(
"CONNECTOR_WINDOWS_PRINT"), $langs->trans(
"FromServerPointOfView")).
'</td><td>'.$langs->trans(
"CONNECTOR_WINDOWS_PRINT_HELP").
'</td></tr>';
455 print
'<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans(
"CONNECTOR_NETWORK_PRINT"), $langs->trans(
"FromServerPointOfView")).
'</td><td>'.$langs->trans(
"CONNECTOR_NETWORK_PRINT_HELP").
'</td></tr>';
456 print
'<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans(
"CONNECTOR_CUPS_PRINT"), $langs->trans(
"FromServerPointOfView")).
'</td><td>'.$langs->trans(
"CONNECTOR_CUPS_PRINT_HELP").
'</td></tr>';
464if ($mode ==
'template') {
471 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=template" autocomplete="off">';
472 print
'<input type="hidden" name="token" value="'.newToken().
'">';
473 if ($action !=
'edittemplate') {
474 print
'<input type="hidden" name="action" value="addtemplate">';
476 print
'<input type="hidden" name="action" value="updatetemplate">';
479 print
'<div class="div-table-responsive">';
480 print
'<table class="noborder centpercent">'.
"\n";
481 print
'<tr class="liste_titre">';
482 print
'<th>'.$langs->trans(
"Name").
'</th>';
483 print
'<th>'.$langs->trans(
"Template").
'</th>';
486 $ret = $printer->listPrintersTemplates();
491 $max = count($printer->listprinterstemplates);
492 for ($line = 0; $line < $max; $line++) {
493 print
'<tr class="oddeven">';
494 if (!is_array($printer->listprinterstemplates[$line])) {
497 if ($action ==
'edittemplate' && !empty($printer->listprinterstemplates[$line]) && !empty($printer->listprinterstemplates[$line][
'rowid']) && $printer->listprinterstemplates[$line][
'rowid'] == $templateid) {
498 print
'<input type="hidden" name="templateid" value="'.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
499 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'"></td>';
500 print
'<td class="wordbreak">';
501 print
'<textarea name="template" wrap="soft" cols="120" rows="12">'.($printer->listprinterstemplates[$line][
'template'] ??
'').
'</textarea>';
504 print $form->buttonsSaveCancel(
"Save",
'');
507 print
'<td>'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'</td>';
508 print
'<td class="wordbreak">'.dol_htmlentitiesbr($printer->listprinterstemplates[$line][
'template'] ??
'').
'</td>';
510 print
'<td class="center"><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=edittemplate&token='.
newToken().
'&templateid='.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
511 print
img_picto($langs->trans(
"Edit"),
'edit');
514 print
'<a class="paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=deletetemplate&token='.
newToken().
'&templateid='.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'&templatename='.urlencode($printer->listprinterstemplates[$line][
'name'] ??
'').
'">';
515 print
img_picto($langs->trans(
"Delete"),
'delete');
518 print
'<a class="paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=testtemplate&token='.
newToken().
'&templateid='.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'&templatename='.urlencode($printer->listprinterstemplates[$line][
'name'] ??
'').
'">';
519 print
img_picto($langs->trans(
"TestPrinterTemplate"),
'printer');
526 if ($action !=
'edittemplate') {
528 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'"></td>';
529 print
'<td class="wordbreak">';
530 print
'<textarea name="template" wrap="soft" cols="120" rows="12">';
534 print
'<input type="hidden" name="templateid" value="'.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
535 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
549 print
'<div class="div-table-responsive">';
550 print
'<table class="noborder centpercent">'.
"\n";
551 print
'<tr class="liste_titre">';
552 print
'<th>'.$langs->trans(
"Tag").
'</th>';
553 print
'<th>'.$langs->trans(
"Description").
'</th>';
556 $langs->loadLangs(array(
"bills",
"companies"));
557 foreach ($printer->tags as $key => $val) {
558 print
'<tr class="oddeven">';
559 print
'<td>{'.$key.
'}</td><td>'.$langs->trans($val).
'</td>';
562 $reshook = $hookmanager->executeHooks(
'listReceiptPrinterTags', array(), $printer, $action);
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage invoices.
Class to manage Receipt Printers.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
receiptprinteradmin_prepare_head($mode)
Define head array for tabs of receipt printer setup pages.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.