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';
38$langs->loadLangs(array(
"admin",
"receiptprinter"));
44$action =
GETPOST(
'action',
'aZ09');
45$mode =
GETPOST(
'mode',
'alpha');
47$printername =
GETPOST(
'printername',
'alpha');
49$parameter =
GETPOST(
'parameter',
'alpha');
51$template =
GETPOST(
'template',
'alphanohtml');
52$templatename =
GETPOST(
'templatename',
'alpha');
56$hookmanager->initHooks(array(
'receiptPrinter',
'globalcard'));
62if (!function_exists(
'gzdecode')) {
70 function gzdecode($data)
72 return gzinflate(substr($data, 10, -8));
81if ($action ==
'addprinter' && $user->admin) {
83 if (empty($printername)) {
88 if (empty($parameter)) {
94 $result = $printer->addPrinter($printername,
GETPOSTINT(
'printertypeid'),
GETPOSTINT(
'printerprofileid'), $parameter);
110if ($action ==
'deleteprinter' && $user->admin) {
112 if (empty($printerid)) {
119 $result = $printer->deletePrinter($printerid);
135if ($action ==
'updateprinter' && $user->admin) {
137 if (empty($printerid)) {
144 $result = $printer->updatePrinter($printername,
GETPOSTINT(
'printertypeid'),
GETPOSTINT(
'printerprofileid'), $parameter, $printerid);
160if ($action ==
'testprinter' && $user->admin) {
162 if (empty($printerid)) {
169 $ret = $printer->sendTestToPrinter($printerid);
179if ($action ==
'testprinter2' && $user->admin) {
181 if (empty($printerid)) {
188 $ret = $printer->sendTestToPrinter($printerid, 1);
198if ($action ==
'testtemplate' && $user->admin) {
207 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
212 $ret = $printer->sendToPrinter(
$object, $templateid, 1);
214 setEventMessages($langs->trans(
"TestTemplateToPrinter", $printername),
null);
222if ($action ==
'updatetemplate' && $user->admin) {
224 if (empty($templateid)) {
231 $result = $printer->updateTemplate($templatename, $template, $templateid);
247if ($action ==
'addtemplate' && $user->admin) {
249 if (empty($templatename)) {
256 $result = $printer->addTemplate($templatename, $template);
272if ($action ==
'deletetemplate' && $user->admin) {
274 if (empty($templateid)) {
281 $result = $printer->deleteTemplate($templateid);
302$form =
new Form($db);
304llxHeader(
'', $langs->trans(
"ReceiptPrinterSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-receiptprinter');
306$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
307print
load_fiche_titre($langs->trans(
"ReceiptPrinterSetup"), $linkback,
'title_setup');
312if ($mode ==
'config' && $user->admin) {
313 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=config" autocomplete="off">';
314 print
'<input type="hidden" name="token" value="'.newToken().
'">';
315 if ($action !=
'editprinter') {
316 print
'<input type="hidden" name="action" value="addprinter">';
318 print
'<input type="hidden" name="action" value="updateprinter">';
328 print
'<div class="div-table-responsive">';
329 print
'<table class="noborder centpercent">'.
"\n";
330 print
'<tr class="liste_titre">';
331 print
'<th>'.$langs->trans(
"Name").
'</th>';
332 print
'<th>'.$langs->trans(
"Type").
'</th>';
334 $htmltext = $langs->trans(
"PROFILE_DEFAULT").
' = '.$langs->trans(
"PROFILE_DEFAULT_HELP").
'<br>';
335 $htmltext .= $langs->trans(
"PROFILE_SIMPLE").
' = '.$langs->trans(
"PROFILE_SIMPLE_HELP").
'<br>';
336 $htmltext .= $langs->trans(
"PROFILE_EPOSTEP").
' = '.$langs->trans(
"PROFILE_EPOSTEP_HELP").
'<br>';
337 $htmltext .= $langs->trans(
"PROFILE_P822D").
' = '.$langs->trans(
"PROFILE_P822D_HELP").
'<br>';
338 $htmltext .= $langs->trans(
"PROFILE_STAR").
' = '.$langs->trans(
"PROFILE_STAR_HELP").
'<br>';
340 print $form->textwithpicto($langs->trans(
"Profile"), $htmltext);
342 print
'<th>'.$langs->trans(
"Parameters").
'</th>';
346 $ret = $printer->listprinters();
347 $nbofprinters = count($printer->listprinters);
349 if ($action !=
'editprinter') {
351 print
'<td><input class="minwidth200" type="text" name="printername"></td>';
352 $ret = $printer->selectTypePrinter();
353 print
'<td>'.$printer->resprint.
'</td>';
354 $ret = $printer->selectProfilePrinter();
355 print
'<td>'.$printer->profileresprint.
'</td>';
356 print
'<td><input size="60" type="text" name="parameter"></td>';
357 print
'<td class="right">';
358 if ($action !=
'editprinter') {
359 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'"></div>';
368 for ($line = 0; $line < $nbofprinters; $line++) {
369 print
'<tr class="oddeven">';
370 if ($action ==
'editprinter' && $printer->listprinters[$line][
'rowid'] == $printerid) {
371 print
'<input type="hidden" name="printerid" value="'.$printer->listprinters[$line][
'rowid'].
'">';
372 print
'<td><input type="text" class="minwidth200" name="printername" value="'.$printer->listprinters[$line][
'name'].
'"></td>';
373 $ret = $printer->selectTypePrinter($printer->listprinters[$line][
'fk_type']);
374 print
'<td>'.$printer->resprint.
'</td>';
375 $ret = $printer->selectProfilePrinter($printer->listprinters[$line][
'fk_profile']);
376 print
'<td>'.$printer->profileresprint.
'</td>';
377 print
'<td><input size="60" type="text" name="parameter" value="'.$printer->listprinters[$line][
'parameter'].
'"></td>';
379 print $form->buttonsSaveCancel(
"Save",
'');
383 print
'<td>'.$printer->listprinters[$line][
'name'].
'</td>';
384 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_type_name']).
'</td>';
385 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_profile_name']).
'</td>';
386 print
'<td>'.$printer->listprinters[$line][
'parameter'].
'</td>';
388 print
'<td class="center">';
389 print
'<a class="editfielda marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=editprinter&token='.
newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'">';
390 print
img_picto($langs->trans(
"Edit"),
'edit',
'class="paddingright"');
393 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']).
'">';
394 print
img_picto($langs->trans(
"Delete"),
'delete',
'class="paddingright"');
397 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']).
'">';
398 print
img_picto($langs->trans(
"TestPrinterDesc"),
'printer',
'class="paddingright paddingleft"').
'TXT';
401 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']).
'">';
402 print
img_picto($langs->trans(
"TestPrinterDesc2"),
'printer',
'class="paddingright paddingleft"').
'IMG';
420 print
'<span class="opacitymedium">'.$langs->trans(
"ReceiptPrinterTypeDesc").
'...</span><br><br>'.
"\n";
422 print
'<div class="div-table-responsive">';
423 print
'<table class="noborder centpercent">'.
"\n";
424 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_DUMMY").
'</td><td>'.$langs->trans(
"CONNECTOR_DUMMY_HELP").
'</td></tr>';
425 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>';
426 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>';
427 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>';
428 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>';
436if ($mode ==
'template' && $user->admin) {
443 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=template" autocomplete="off">';
444 print
'<input type="hidden" name="token" value="'.newToken().
'">';
445 if ($action !=
'edittemplate') {
446 print
'<input type="hidden" name="action" value="addtemplate">';
448 print
'<input type="hidden" name="action" value="updatetemplate">';
451 print
'<div class="div-table-responsive">';
452 print
'<table class="noborder centpercent">'.
"\n";
453 print
'<tr class="liste_titre">';
454 print
'<th>'.$langs->trans(
"Name").
'</th>';
455 print
'<th>'.$langs->trans(
"Template").
'</th>';
458 $ret = $printer->listPrintersTemplates();
463 $max = count($printer->listprinterstemplates);
464 for ($line = 0; $line < $max; $line++) {
465 print
'<tr class="oddeven">';
466 if (!is_array($printer->listprinterstemplates[$line])) {
469 if ($action ==
'edittemplate' && !empty($printer->listprinterstemplates[$line]) && !empty($printer->listprinterstemplates[$line][
'rowid']) && $printer->listprinterstemplates[$line][
'rowid'] == $templateid) {
470 print
'<input type="hidden" name="templateid" value="'.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
471 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'"></td>';
472 print
'<td class="wordbreak">';
473 print
'<textarea name="template" wrap="soft" cols="120" rows="12">'.($printer->listprinterstemplates[$line][
'template'] ??
'').
'</textarea>';
476 print $form->buttonsSaveCancel(
"Save",
'');
479 print
'<td>'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'</td>';
480 print
'<td class="wordbreak">'.dol_htmlentitiesbr($printer->listprinterstemplates[$line][
'template'] ??
'').
'</td>';
482 print
'<td class="center"><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=edittemplate&token='.
newToken().
'&templateid='.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
483 print
img_picto($langs->trans(
"Edit"),
'edit');
486 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'] ??
'').
'">';
487 print
img_picto($langs->trans(
"Delete"),
'delete');
490 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'] ??
'').
'">';
491 print
img_picto($langs->trans(
"TestPrinterTemplate"),
'printer');
498 if ($action !=
'edittemplate') {
500 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'"></td>';
501 print
'<td class="wordbreak">';
502 print
'<textarea name="template" wrap="soft" cols="120" rows="12">';
506 print
'<input type="hidden" name="templateid" value="'.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
507 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
521 print
'<div class="div-table-responsive">';
522 print
'<table class="noborder centpercent">'.
"\n";
523 print
'<tr class="liste_titre">';
524 print
'<th>'.$langs->trans(
"Tag").
'</th>';
525 print
'<th>'.$langs->trans(
"Description").
'</th>';
528 $langs->loadLangs(array(
"bills",
"companies"));
529 foreach ($printer->tags as $key => $val) {
530 print
'<tr class="oddeven">';
531 print
'<td>{'.$key.
'}</td><td>'.$langs->trans($val).
'</td>';
534 $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()
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.