31require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/receiptprinter.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
47$langs->loadLangs(array(
"admin",
"receiptprinter"));
53$action =
GETPOST(
'action',
'aZ09');
54$mode =
GETPOST(
'mode',
'alpha');
56$printername =
GETPOST(
'printername',
'alpha');
58$parameter =
GETPOST(
'parameter',
'alpha');
60$template =
GETPOST(
'template',
'alphanohtml');
61$templatename =
GETPOST(
'templatename',
'alpha');
65$hookmanager->initHooks(array(
'receiptPrinter',
'globalcard'));
71if (!function_exists(
'gzdecode')) {
79 function gzdecode($data)
81 return gzinflate(substr($data, 10, -8));
90if ($action ==
'addprinter' && $user->admin) {
92 if (empty($printername)) {
97 if (empty($parameter)) {
103 $result = $printer->addPrinter($printername,
GETPOSTINT(
'printertypeid'),
GETPOSTINT(
'printerprofileid'), $parameter);
119if ($action ==
'deleteprinter' && $user->admin) {
121 if (empty($printerid)) {
128 $result = $printer->deletePrinter($printerid);
144if ($action ==
'updateprinter' && $user->admin) {
146 if (empty($printerid)) {
153 $result = $printer->updatePrinter($printername,
GETPOSTINT(
'printertypeid'),
GETPOSTINT(
'printerprofileid'), $parameter, $printerid);
169if ($action ==
'testprinter' && $user->admin) {
171 if (empty($printerid)) {
178 $ret = $printer->sendTestToPrinter($printerid);
188if ($action ==
'testprinter2' && $user->admin) {
190 if (empty($printerid)) {
197 $ret = $printer->sendTestToPrinter($printerid, 1);
207if ($action ==
'testtemplate' && $user->admin) {
209 if (empty($printerid)) {
210 $ret = $printer->listPrinters();
214 } elseif (!empty($printer->listprinters)) {
216 $printerid = (int) min(array_column($printer->listprinters,
'rowid'));
219 if (!$error && empty($printerid)) {
226 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
231 $ret = $printer->sendToPrinter(
$object, $templateid, $printerid);
233 setEventMessages($langs->trans(
"TestTemplateToPrinter", $printername),
null);
241if ($action ==
'updatetemplate' && $user->admin) {
243 if (empty($templateid)) {
250 $result = $printer->updateTemplate($templatename, $template, $templateid);
266if ($action ==
'addtemplate' && $user->admin) {
268 if (empty($templatename)) {
275 $result = $printer->addTemplate($templatename, $template);
291if ($action ==
'deletetemplate' && $user->admin) {
293 if (empty($templateid)) {
300 $result = $printer->deleteTemplate($templateid);
321$form =
new Form($db);
323llxHeader(
'', $langs->trans(
"ReceiptPrinterSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-receiptprinter');
325$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
326print
load_fiche_titre($langs->trans(
"ReceiptPrinterSetup"), $linkback,
'title_setup');
332if ($mode ==
'config' && $user->admin) {
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>';
354 $htmltext = $langs->trans(
"PROFILE_DEFAULT").
' = '.$langs->trans(
"PROFILE_DEFAULT_HELP").
'<br>';
355 $htmltext .= $langs->trans(
"PROFILE_SIMPLE").
' = '.$langs->trans(
"PROFILE_SIMPLE_HELP").
'<br>';
356 $htmltext .= $langs->trans(
"PROFILE_EPOSTEP").
' = '.$langs->trans(
"PROFILE_EPOSTEP_HELP").
'<br>';
357 $htmltext .= $langs->trans(
"PROFILE_P822D").
' = '.$langs->trans(
"PROFILE_P822D_HELP").
'<br>';
358 $htmltext .= $langs->trans(
"PROFILE_STAR").
' = '.$langs->trans(
"PROFILE_STAR_HELP").
'<br>';
360 print $form->textwithpicto($langs->trans(
"Profile"), $htmltext);
362 print
'<th>'.$langs->trans(
"Parameters").
'</th>';
366 $ret = $printer->listprinters();
367 $nbofprinters = count($printer->listprinters);
369 if ($action !=
'editprinter') {
371 print
'<td><input class="minwidth100" type="text" name="printername"></td>';
372 $ret = $printer->selectTypePrinter();
373 print
'<td>'.$printer->resprint.
'</td>';
374 $ret = $printer->selectProfilePrinter();
375 print
'<td>'.$printer->profileresprint.
'</td>';
376 print
'<td><input class="minwidth150" type="text" name="parameter"></td>';
377 print
'<td class="right">';
378 if ($action !=
'editprinter') {
379 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'"></div>';
388 for ($line = 0; $line < $nbofprinters; $line++) {
389 print
'<tr class="oddeven">';
390 if ($action ==
'editprinter' && $printer->listprinters[$line][
'rowid'] == $printerid) {
391 print
'<input type="hidden" name="printerid" value="'.$printer->listprinters[$line][
'rowid'].
'">';
392 print
'<td><input type="text" class="minwidth200" name="printername" value="'.$printer->listprinters[$line][
'name'].
'"></td>';
393 $ret = $printer->selectTypePrinter((
string) $printer->listprinters[$line][
'fk_type']);
394 print
'<td>'.$printer->resprint.
'</td>';
395 $ret = $printer->selectProfilePrinter((
string) $printer->listprinters[$line][
'fk_profile']);
396 print
'<td>'.$printer->profileresprint.
'</td>';
397 print
'<td><input class="minwidth150" type="text" name="parameter" value="'.$printer->listprinters[$line][
'parameter'].
'"></td>';
399 print $form->buttonsSaveCancel(
"Save",
'');
403 print
'<td>'.$printer->listprinters[$line][
'name'].
'</td>';
404 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_type_name']).
'</td>';
405 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_profile_name']).
'</td>';
406 print
'<td>'.$printer->listprinters[$line][
'parameter'].
'</td>';
408 print
'<td class="center">';
409 print
'<a class="editfielda marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=editprinter&token='.
newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'">';
410 print
img_picto($langs->trans(
"Edit"),
'edit',
'class="paddingright"');
413 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']).
'">';
414 print
img_picto($langs->trans(
"Delete"),
'delete',
'class="paddingright"');
417 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']).
'">';
418 print
img_picto($langs->trans(
"TestPrinterDesc"),
'printer',
'class="paddingright paddingleft"').
'TXT';
421 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']).
'">';
422 print
img_picto($langs->trans(
"TestPrinterDesc2"),
'printer',
'class="paddingright paddingleft"').
'IMG';
440 print
'<span class="opacitymedium">'.$langs->trans(
"ReceiptPrinterTypeDesc").
'...</span><br><br>'.
"\n";
442 print
'<div class="div-table-responsive">';
443 print
'<table class="noborder centpercent">'.
"\n";
444 print
'<tr class="oddeven"><td class="minwidth100">'.$langs->trans(
"CONNECTOR_DUMMY").
'</td><td>'.$langs->trans(
"CONNECTOR_DUMMY_HELP").
'</td></tr>';
445 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>';
446 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>';
447 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>';
448 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>';
456if ($mode ==
'template' && $user->admin) {
463 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=template" autocomplete="off">';
464 print
'<input type="hidden" name="token" value="'.newToken().
'">';
465 if ($action !=
'edittemplate') {
466 print
'<input type="hidden" name="action" value="addtemplate">';
468 print
'<input type="hidden" name="action" value="updatetemplate">';
471 print
'<div class="div-table-responsive">';
472 print
'<table class="noborder centpercent">'.
"\n";
473 print
'<tr class="liste_titre">';
474 print
'<th>'.$langs->trans(
"Name").
'</th>';
475 print
'<th>'.$langs->trans(
"Template").
'</th>';
478 $ret = $printer->listPrintersTemplates();
483 $max = count($printer->listprinterstemplates);
484 for ($line = 0; $line < $max; $line++) {
485 print
'<tr class="oddeven">';
486 if (!is_array($printer->listprinterstemplates[$line])) {
489 if ($action ==
'edittemplate' && !empty($printer->listprinterstemplates[$line]) && !empty($printer->listprinterstemplates[$line][
'rowid']) && $printer->listprinterstemplates[$line][
'rowid'] == $templateid) {
490 print
'<input type="hidden" name="templateid" value="'.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
491 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'"></td>';
492 print
'<td class="wordbreak">';
493 print
'<textarea name="template" wrap="soft" cols="120" rows="12">'.($printer->listprinterstemplates[$line][
'template'] ??
'').
'</textarea>';
496 print $form->buttonsSaveCancel(
"Save",
'');
499 print
'<td>'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'</td>';
500 print
'<td class="wordbreak">'.dol_htmlentitiesbr($printer->listprinterstemplates[$line][
'template'] ??
'').
'</td>';
502 print
'<td class="center"><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=edittemplate&token='.
newToken().
'&templateid='.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
503 print
img_picto($langs->trans(
"Edit"),
'edit');
506 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'] ??
'').
'">';
507 print
img_picto($langs->trans(
"Delete"),
'delete');
510 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'] ??
'').
'">';
511 print
img_picto($langs->trans(
"TestPrinterTemplate"),
'printer');
518 if ($action !=
'edittemplate') {
520 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'"></td>';
521 print
'<td class="wordbreak">';
522 print
'<textarea name="template" wrap="soft" cols="120" rows="12">';
526 print
'<input type="hidden" name="templateid" value="'.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
527 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
541 print
'<div class="div-table-responsive">';
542 print
'<table class="noborder centpercent">'.
"\n";
543 print
'<tr class="liste_titre">';
544 print
'<th>'.$langs->trans(
"Tag").
'</th>';
545 print
'<th>'.$langs->trans(
"Description").
'</th>';
548 $langs->loadLangs(array(
"bills",
"companies"));
549 foreach ($printer->tags as $key => $val) {
550 print
'<tr class="oddeven">';
551 print
'<td>{'.$key.
'}</td><td>'.$langs->trans($val).
'</td>';
554 $reshook = $hookmanager->executeHooks(
'listReceiptPrinterTags', array(), $printer, $action);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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...
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.