30require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/receiptprinter.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
46$langs->loadLangs(array(
"admin",
"receiptprinter"));
52$action =
GETPOST(
'action',
'aZ09');
53$mode =
GETPOST(
'mode',
'alpha');
55$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' && $user->admin) {
91 if (empty($printername)) {
96 if (empty($parameter)) {
102 $result = $printer->addPrinter($printername,
GETPOSTINT(
'printertypeid'),
GETPOSTINT(
'printerprofileid'), $parameter);
118if ($action ==
'deleteprinter' && $user->admin) {
120 if (empty($printerid)) {
127 $result = $printer->deletePrinter($printerid);
143if ($action ==
'updateprinter' && $user->admin) {
145 if (empty($printerid)) {
152 $result = $printer->updatePrinter($printername,
GETPOSTINT(
'printertypeid'),
GETPOSTINT(
'printerprofileid'), $parameter, $printerid);
168if ($action ==
'testprinter' && $user->admin) {
170 if (empty($printerid)) {
177 $ret = $printer->sendTestToPrinter($printerid);
187if ($action ==
'testprinter2' && $user->admin) {
189 if (empty($printerid)) {
196 $ret = $printer->sendTestToPrinter($printerid, 1);
206if ($action ==
'testtemplate' && $user->admin) {
215 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
220 $ret = $printer->sendToPrinter(
$object, $templateid, 1);
222 setEventMessages($langs->trans(
"TestTemplateToPrinter", $printername),
null);
230if ($action ==
'updatetemplate' && $user->admin) {
232 if (empty($templateid)) {
239 $result = $printer->updateTemplate($templatename, $template, $templateid);
255if ($action ==
'addtemplate' && $user->admin) {
257 if (empty($templatename)) {
264 $result = $printer->addTemplate($templatename, $template);
280if ($action ==
'deletetemplate' && $user->admin) {
282 if (empty($templateid)) {
289 $result = $printer->deleteTemplate($templateid);
310$form =
new Form($db);
312llxHeader(
'', $langs->trans(
"ReceiptPrinterSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-receiptprinter');
314$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
315print
load_fiche_titre($langs->trans(
"ReceiptPrinterSetup"), $linkback,
'title_setup');
321if ($mode ==
'config' && $user->admin) {
322 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=config" autocomplete="off">';
323 print
'<input type="hidden" name="token" value="'.newToken().
'">';
324 if ($action !=
'editprinter') {
325 print
'<input type="hidden" name="action" value="addprinter">';
327 print
'<input type="hidden" name="action" value="updateprinter">';
337 print
'<div class="div-table-responsive">';
338 print
'<table class="noborder centpercent">'.
"\n";
339 print
'<tr class="liste_titre">';
340 print
'<th>'.$langs->trans(
"Name").
'</th>';
341 print
'<th>'.$langs->trans(
"Type").
'</th>';
343 $htmltext = $langs->trans(
"PROFILE_DEFAULT").
' = '.$langs->trans(
"PROFILE_DEFAULT_HELP").
'<br>';
344 $htmltext .= $langs->trans(
"PROFILE_SIMPLE").
' = '.$langs->trans(
"PROFILE_SIMPLE_HELP").
'<br>';
345 $htmltext .= $langs->trans(
"PROFILE_EPOSTEP").
' = '.$langs->trans(
"PROFILE_EPOSTEP_HELP").
'<br>';
346 $htmltext .= $langs->trans(
"PROFILE_P822D").
' = '.$langs->trans(
"PROFILE_P822D_HELP").
'<br>';
347 $htmltext .= $langs->trans(
"PROFILE_STAR").
' = '.$langs->trans(
"PROFILE_STAR_HELP").
'<br>';
349 print $form->textwithpicto($langs->trans(
"Profile"), $htmltext);
351 print
'<th>'.$langs->trans(
"Parameters").
'</th>';
355 $ret = $printer->listprinters();
356 $nbofprinters = count($printer->listprinters);
358 if ($action !=
'editprinter') {
360 print
'<td><input class="minwidth200" type="text" name="printername"></td>';
361 $ret = $printer->selectTypePrinter();
362 print
'<td>'.$printer->resprint.
'</td>';
363 $ret = $printer->selectProfilePrinter();
364 print
'<td>'.$printer->profileresprint.
'</td>';
365 print
'<td><input size="60" type="text" name="parameter"></td>';
366 print
'<td class="right">';
367 if ($action !=
'editprinter') {
368 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'"></div>';
377 for ($line = 0; $line < $nbofprinters; $line++) {
378 print
'<tr class="oddeven">';
379 if ($action ==
'editprinter' && $printer->listprinters[$line][
'rowid'] == $printerid) {
380 print
'<input type="hidden" name="printerid" value="'.$printer->listprinters[$line][
'rowid'].
'">';
381 print
'<td><input type="text" class="minwidth200" name="printername" value="'.$printer->listprinters[$line][
'name'].
'"></td>';
382 $ret = $printer->selectTypePrinter($printer->listprinters[$line][
'fk_type']);
383 print
'<td>'.$printer->resprint.
'</td>';
384 $ret = $printer->selectProfilePrinter($printer->listprinters[$line][
'fk_profile']);
385 print
'<td>'.$printer->profileresprint.
'</td>';
386 print
'<td><input size="60" type="text" name="parameter" value="'.$printer->listprinters[$line][
'parameter'].
'"></td>';
388 print $form->buttonsSaveCancel(
"Save",
'');
392 print
'<td>'.$printer->listprinters[$line][
'name'].
'</td>';
393 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_type_name']).
'</td>';
394 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_profile_name']).
'</td>';
395 print
'<td>'.$printer->listprinters[$line][
'parameter'].
'</td>';
397 print
'<td class="center">';
398 print
'<a class="editfielda marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=editprinter&token='.
newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'">';
399 print
img_picto($langs->trans(
"Edit"),
'edit',
'class="paddingright"');
402 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']).
'">';
403 print
img_picto($langs->trans(
"Delete"),
'delete',
'class="paddingright"');
406 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']).
'">';
407 print
img_picto($langs->trans(
"TestPrinterDesc"),
'printer',
'class="paddingright paddingleft"').
'TXT';
410 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']).
'">';
411 print
img_picto($langs->trans(
"TestPrinterDesc2"),
'printer',
'class="paddingright paddingleft"').
'IMG';
429 print
'<span class="opacitymedium">'.$langs->trans(
"ReceiptPrinterTypeDesc").
'...</span><br><br>'.
"\n";
431 print
'<div class="div-table-responsive">';
432 print
'<table class="noborder centpercent">'.
"\n";
433 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_DUMMY").
'</td><td>'.$langs->trans(
"CONNECTOR_DUMMY_HELP").
'</td></tr>';
434 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>';
435 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>';
436 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>';
437 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>';
445if ($mode ==
'template' && $user->admin) {
452 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=template" autocomplete="off">';
453 print
'<input type="hidden" name="token" value="'.newToken().
'">';
454 if ($action !=
'edittemplate') {
455 print
'<input type="hidden" name="action" value="addtemplate">';
457 print
'<input type="hidden" name="action" value="updatetemplate">';
460 print
'<div class="div-table-responsive">';
461 print
'<table class="noborder centpercent">'.
"\n";
462 print
'<tr class="liste_titre">';
463 print
'<th>'.$langs->trans(
"Name").
'</th>';
464 print
'<th>'.$langs->trans(
"Template").
'</th>';
467 $ret = $printer->listPrintersTemplates();
472 $max = count($printer->listprinterstemplates);
473 for ($line = 0; $line < $max; $line++) {
474 print
'<tr class="oddeven">';
475 if (!is_array($printer->listprinterstemplates[$line])) {
478 if ($action ==
'edittemplate' && !empty($printer->listprinterstemplates[$line]) && !empty($printer->listprinterstemplates[$line][
'rowid']) && $printer->listprinterstemplates[$line][
'rowid'] == $templateid) {
479 print
'<input type="hidden" name="templateid" value="'.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
480 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'"></td>';
481 print
'<td class="wordbreak">';
482 print
'<textarea name="template" wrap="soft" cols="120" rows="12">'.($printer->listprinterstemplates[$line][
'template'] ??
'').
'</textarea>';
485 print $form->buttonsSaveCancel(
"Save",
'');
488 print
'<td>'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'</td>';
489 print
'<td class="wordbreak">'.dol_htmlentitiesbr($printer->listprinterstemplates[$line][
'template'] ??
'').
'</td>';
491 print
'<td class="center"><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=edittemplate&token='.
newToken().
'&templateid='.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
492 print
img_picto($langs->trans(
"Edit"),
'edit');
495 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'] ??
'').
'">';
496 print
img_picto($langs->trans(
"Delete"),
'delete');
499 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'] ??
'').
'">';
500 print
img_picto($langs->trans(
"TestPrinterTemplate"),
'printer');
507 if ($action !=
'edittemplate') {
509 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'"></td>';
510 print
'<td class="wordbreak">';
511 print
'<textarea name="template" wrap="soft" cols="120" rows="12">';
515 print
'<input type="hidden" name="templateid" value="'.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
516 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
530 print
'<div class="div-table-responsive">';
531 print
'<table class="noborder centpercent">'.
"\n";
532 print
'<tr class="liste_titre">';
533 print
'<th>'.$langs->trans(
"Tag").
'</th>';
534 print
'<th>'.$langs->trans(
"Description").
'</th>';
537 $langs->loadLangs(array(
"bills",
"companies"));
538 foreach ($printer->tags as $key => $val) {
539 print
'<tr class="oddeven">';
540 print
'<td>{'.$key.
'}</td><td>'.$langs->trans($val).
'</td>';
543 $reshook = $hookmanager->executeHooks(
'listReceiptPrinterTags', array(), $printer, $action);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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)
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)
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.