28require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/receiptprinter.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
36$langs->loadLangs(array(
"admin",
"receiptprinter"));
42$action =
GETPOST(
'action',
'aZ09');
43$mode =
GETPOST(
'mode',
'alpha');
45$printername =
GETPOST(
'printername',
'alpha');
46$printerid =
GETPOST(
'printerid',
'int');
47$parameter =
GETPOST(
'parameter',
'alpha');
49$template =
GETPOST(
'template',
'alphanohtml');
50$templatename =
GETPOST(
'templatename',
'alpha');
51$templateid =
GETPOST(
'templateid',
'int');
60if (!function_exists(
'gzdecode')) {
67 function gzdecode($data)
69 return gzinflate(substr($data, 10, -8));
78if ($action ==
'addprinter' && $user->admin) {
80 if (empty($printername)) {
85 if (empty($parameter)) {
91 $result = $printer->addPrinter($printername,
GETPOST(
'printertypeid',
'int'),
GETPOST(
'printerprofileid',
'int'), $parameter);
107if ($action ==
'deleteprinter' && $user->admin) {
109 if (empty($printerid)) {
116 $result = $printer->deletePrinter($printerid);
132if ($action ==
'updateprinter' && $user->admin) {
134 if (empty($printerid)) {
141 $result = $printer->updatePrinter($printername,
GETPOST(
'printertypeid',
'int'),
GETPOST(
'printerprofileid',
'int'), $parameter, $printerid);
157if ($action ==
'testprinter' && $user->admin) {
159 if (empty($printerid)) {
166 $ret = $printer->sendTestToPrinter($printerid);
176if ($action ==
'testprinter2' && $user->admin) {
178 if (empty($printerid)) {
185 $ret = $printer->sendTestToPrinter($printerid, 1);
195if ($action ==
'testtemplate' && $user->admin) {
204 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
206 $object->initAsSpecimen();
209 $ret = $printer->sendToPrinter($object, $templateid, 1);
211 setEventMessages($langs->trans(
"TestTemplateToPrinter", $printername),
null);
219if ($action ==
'updatetemplate' && $user->admin) {
221 if (empty($templateid)) {
228 $result = $printer->updateTemplate($templatename, $template, $templateid);
244if ($action ==
'addtemplate' && $user->admin) {
246 if (empty($templatename)) {
253 $result = $printer->addTemplate($templatename, $template);
269if ($action ==
'deletetemplate' && $user->admin) {
271 if (empty($templateid)) {
278 $result = $printer->deleteTemplate($templateid);
299$form =
new Form($db);
301llxHeader(
'', $langs->trans(
"ReceiptPrinterSetup"));
303$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
304print
load_fiche_titre($langs->trans(
"ReceiptPrinterSetup"), $linkback,
'title_setup');
309if ($mode ==
'config' && $user->admin) {
310 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=config" autocomplete="off">';
311 print
'<input type="hidden" name="token" value="'.newToken().
'">';
312 if ($action !=
'editprinter') {
313 print
'<input type="hidden" name="action" value="addprinter">';
315 print
'<input type="hidden" name="action" value="updateprinter">';
325 print
'<div class="div-table-responsive">';
326 print
'<table class="noborder centpercent">'.
"\n";
327 print
'<tr class="liste_titre">';
328 print
'<th>'.$langs->trans(
"Name").
'</th>';
329 print
'<th>'.$langs->trans(
"Type").
'</th>';
331 $htmltext = $langs->trans(
"PROFILE_DEFAULT").
' = '.$langs->trans(
"PROFILE_DEFAULT_HELP").
'<br>';
332 $htmltext .= $langs->trans(
"PROFILE_SIMPLE").
' = '.$langs->trans(
"PROFILE_SIMPLE_HELP").
'<br>';
333 $htmltext .= $langs->trans(
"PROFILE_EPOSTEP").
' = '.$langs->trans(
"PROFILE_EPOSTEP_HELP").
'<br>';
334 $htmltext .= $langs->trans(
"PROFILE_P822D").
' = '.$langs->trans(
"PROFILE_P822D_HELP").
'<br>';
335 $htmltext .= $langs->trans(
"PROFILE_STAR").
' = '.$langs->trans(
"PROFILE_STAR_HELP").
'<br>';
337 print $form->textwithpicto($langs->trans(
"Profile"), $htmltext);
339 print
'<th>'.$langs->trans(
"Parameters").
'</th>';
343 $ret = $printer->listprinters();
344 $nbofprinters = count($printer->listprinters);
346 if ($action !=
'editprinter') {
348 print
'<td><input class="minwidth200" type="text" name="printername"></td>';
349 $ret = $printer->selectTypePrinter();
350 print
'<td>'.$printer->resprint.
'</td>';
351 $ret = $printer->selectProfilePrinter();
352 print
'<td>'.$printer->profileresprint.
'</td>';
353 print
'<td><input size="60" type="text" name="parameter"></td>';
354 print
'<td class="right">';
355 if ($action !=
'editprinter') {
356 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'"></div>';
365 for ($line = 0; $line < $nbofprinters; $line++) {
366 print
'<tr class="oddeven">';
367 if ($action ==
'editprinter' && $printer->listprinters[$line][
'rowid'] == $printerid) {
368 print
'<input type="hidden" name="printerid" value="'.$printer->listprinters[$line][
'rowid'].
'">';
369 print
'<td><input type="text" class="minwidth200" name="printername" value="'.$printer->listprinters[$line][
'name'].
'"></td>';
370 $ret = $printer->selectTypePrinter($printer->listprinters[$line][
'fk_type']);
371 print
'<td>'.$printer->resprint.
'</td>';
372 $ret = $printer->selectProfilePrinter($printer->listprinters[$line][
'fk_profile']);
373 print
'<td>'.$printer->profileresprint.
'</td>';
374 print
'<td><input size="60" type="text" name="parameter" value="'.$printer->listprinters[$line][
'parameter'].
'"></td>';
376 print $form->buttonsSaveCancel(
"Save",
'');
380 print
'<td>'.$printer->listprinters[$line][
'name'].
'</td>';
381 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_type_name']).
'</td>';
382 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_profile_name']).
'</td>';
383 print
'<td>'.$printer->listprinters[$line][
'parameter'].
'</td>';
385 print
'<td class="center">';
386 print
'<a class="editfielda marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=editprinter&token='.newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'">';
387 print
img_picto($langs->trans(
"Edit"),
'edit',
'class="paddingright"');
390 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']).
'">';
391 print
img_picto($langs->trans(
"Delete"),
'delete',
'class="paddingright"');
394 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']).
'">';
395 print
img_picto($langs->trans(
"TestPrinterDesc"),
'printer',
'class="paddingright paddingleft"').
'TXT';
398 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']).
'">';
399 print
img_picto($langs->trans(
"TestPrinterDesc2"),
'printer',
'class="paddingright paddingleft"').
'IMG';
417 print
'<span class="opacitymedium">'.$langs->trans(
"ReceiptPrinterTypeDesc").
'...</span><br><br>'.
"\n";
419 print
'<div class="div-table-responsive">';
420 print
'<table class="noborder centpercent">'.
"\n";
421 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_DUMMY").
'</td><td>'.$langs->trans(
"CONNECTOR_DUMMY_HELP").
'</td></tr>';
422 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>';
423 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>';
424 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>';
425 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>';
433if ($mode ==
'template' && $user->admin) {
440 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=template" autocomplete="off">';
441 print
'<input type="hidden" name="token" value="'.newToken().
'">';
442 if ($action !=
'edittemplate') {
443 print
'<input type="hidden" name="action" value="addtemplate">';
445 print
'<input type="hidden" name="action" value="updatetemplate">';
448 print
'<div class="div-table-responsive">';
449 print
'<table class="noborder centpercent">'.
"\n";
450 print
'<tr class="liste_titre">';
451 print
'<th>'.$langs->trans(
"Name").
'</th>';
452 print
'<th>'.$langs->trans(
"Template").
'</th>';
455 $ret = $printer->listPrintersTemplates();
460 $max = count($printer->listprinterstemplates);
461 for ($line = 0; $line < $max; $line++) {
462 print
'<tr class="oddeven">';
463 if ($action ==
'edittemplate' && $printer->listprinterstemplates[$line][
'rowid'] == $templateid) {
464 print
'<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line][
'rowid'].
'">';
465 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.$printer->listprinterstemplates[$line][
'name'].
'"></td>';
466 print
'<td class="wordbreak">';
467 print
'<textarea name="template" wrap="soft" cols="120" rows="12">'.$printer->listprinterstemplates[$line][
'template'].
'</textarea>';
470 print $form->buttonsSaveCancel(
"Save",
'');
473 print
'<td>'.$printer->listprinterstemplates[$line][
'name'].
'</td>';
474 print
'<td class="wordbreak">'.dol_htmlentitiesbr($printer->listprinterstemplates[$line][
'template']).
'</td>';
476 print
'<td class="center"><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=edittemplate&token='.newToken().
'&templateid='.$printer->listprinterstemplates[$line][
'rowid'].
'">';
477 print
img_picto($langs->trans(
"Edit"),
'edit');
480 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']).
'">';
481 print
img_picto($langs->trans(
"Delete"),
'delete');
484 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']).
'">';
485 print
img_picto($langs->trans(
"TestPrinterTemplate"),
'printer');
492 if ($action !=
'edittemplate') {
494 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.$printer->listprinterstemplates[$line][
'name'].
'"></td>';
495 print
'<td class="wordbreak">';
496 print
'<textarea name="template" wrap="soft" cols="120" rows="12">';
500 print
'<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line][
'rowid'].
'">';
501 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
515 print
'<div class="div-table-responsive">';
516 print
'<table class="noborder centpercent">'.
"\n";
517 print
'<tr class="liste_titre">';
518 print
'<th>'.$langs->trans(
"Tag").
'</th>';
519 print
'<th>'.$langs->trans(
"Description").
'</th>';
522 $langs->loadLangs(array(
"bills",
"companies"));
523 foreach ($printer->tags as $key => $val) {
524 print
'<tr class="oddeven">';
525 print
'<td>{'.$key.
'}</td><td>'.$langs->trans($val).
'</td>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage invoices.
Class to manage Receipt Printers.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.