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');
313if ($mode ==
'config' && $user->admin) {
314 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=config" autocomplete="off">';
315 print
'<input type="hidden" name="token" value="'.newToken().
'">';
316 if ($action !=
'editprinter') {
317 print
'<input type="hidden" name="action" value="addprinter">';
319 print
'<input type="hidden" name="action" value="updateprinter">';
329 print
'<div class="div-table-responsive">';
330 print
'<table class="noborder centpercent">'.
"\n";
331 print
'<tr class="liste_titre">';
332 print
'<th>'.$langs->trans(
"Name").
'</th>';
333 print
'<th>'.$langs->trans(
"Type").
'</th>';
335 $htmltext = $langs->trans(
"PROFILE_DEFAULT").
' = '.$langs->trans(
"PROFILE_DEFAULT_HELP").
'<br>';
336 $htmltext .= $langs->trans(
"PROFILE_SIMPLE").
' = '.$langs->trans(
"PROFILE_SIMPLE_HELP").
'<br>';
337 $htmltext .= $langs->trans(
"PROFILE_EPOSTEP").
' = '.$langs->trans(
"PROFILE_EPOSTEP_HELP").
'<br>';
338 $htmltext .= $langs->trans(
"PROFILE_P822D").
' = '.$langs->trans(
"PROFILE_P822D_HELP").
'<br>';
339 $htmltext .= $langs->trans(
"PROFILE_STAR").
' = '.$langs->trans(
"PROFILE_STAR_HELP").
'<br>';
341 print $form->textwithpicto($langs->trans(
"Profile"), $htmltext);
343 print
'<th>'.$langs->trans(
"Parameters").
'</th>';
347 $ret = $printer->listprinters();
348 $nbofprinters = count($printer->listprinters);
350 if ($action !=
'editprinter') {
352 print
'<td><input class="minwidth200" type="text" name="printername"></td>';
353 $ret = $printer->selectTypePrinter();
354 print
'<td>'.$printer->resprint.
'</td>';
355 $ret = $printer->selectProfilePrinter();
356 print
'<td>'.$printer->profileresprint.
'</td>';
357 print
'<td><input size="60" type="text" name="parameter"></td>';
358 print
'<td class="right">';
359 if ($action !=
'editprinter') {
360 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'"></div>';
369 for ($line = 0; $line < $nbofprinters; $line++) {
370 print
'<tr class="oddeven">';
371 if ($action ==
'editprinter' && $printer->listprinters[$line][
'rowid'] == $printerid) {
372 print
'<input type="hidden" name="printerid" value="'.$printer->listprinters[$line][
'rowid'].
'">';
373 print
'<td><input type="text" class="minwidth200" name="printername" value="'.$printer->listprinters[$line][
'name'].
'"></td>';
374 $ret = $printer->selectTypePrinter($printer->listprinters[$line][
'fk_type']);
375 print
'<td>'.$printer->resprint.
'</td>';
376 $ret = $printer->selectProfilePrinter($printer->listprinters[$line][
'fk_profile']);
377 print
'<td>'.$printer->profileresprint.
'</td>';
378 print
'<td><input size="60" type="text" name="parameter" value="'.$printer->listprinters[$line][
'parameter'].
'"></td>';
380 print $form->buttonsSaveCancel(
"Save",
'');
384 print
'<td>'.$printer->listprinters[$line][
'name'].
'</td>';
385 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_type_name']).
'</td>';
386 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_profile_name']).
'</td>';
387 print
'<td>'.$printer->listprinters[$line][
'parameter'].
'</td>';
389 print
'<td class="center">';
390 print
'<a class="editfielda marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=editprinter&token='.
newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'">';
391 print
img_picto($langs->trans(
"Edit"),
'edit',
'class="paddingright"');
394 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']).
'">';
395 print
img_picto($langs->trans(
"Delete"),
'delete',
'class="paddingright"');
398 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']).
'">';
399 print
img_picto($langs->trans(
"TestPrinterDesc"),
'printer',
'class="paddingright paddingleft"').
'TXT';
402 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']).
'">';
403 print
img_picto($langs->trans(
"TestPrinterDesc2"),
'printer',
'class="paddingright paddingleft"').
'IMG';
421 print
'<span class="opacitymedium">'.$langs->trans(
"ReceiptPrinterTypeDesc").
'...</span><br><br>'.
"\n";
423 print
'<div class="div-table-responsive">';
424 print
'<table class="noborder centpercent">'.
"\n";
425 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_DUMMY").
'</td><td>'.$langs->trans(
"CONNECTOR_DUMMY_HELP").
'</td></tr>';
426 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>';
427 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>';
428 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>';
429 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>';
437if ($mode ==
'template' && $user->admin) {
444 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=template" autocomplete="off">';
445 print
'<input type="hidden" name="token" value="'.newToken().
'">';
446 if ($action !=
'edittemplate') {
447 print
'<input type="hidden" name="action" value="addtemplate">';
449 print
'<input type="hidden" name="action" value="updatetemplate">';
452 print
'<div class="div-table-responsive">';
453 print
'<table class="noborder centpercent">'.
"\n";
454 print
'<tr class="liste_titre">';
455 print
'<th>'.$langs->trans(
"Name").
'</th>';
456 print
'<th>'.$langs->trans(
"Template").
'</th>';
459 $ret = $printer->listPrintersTemplates();
464 $max = count($printer->listprinterstemplates);
465 for ($line = 0; $line < $max; $line++) {
466 print
'<tr class="oddeven">';
467 if (!is_array($printer->listprinterstemplates[$line])) {
470 if ($action ==
'edittemplate' && !empty($printer->listprinterstemplates[$line]) && !empty($printer->listprinterstemplates[$line][
'rowid']) && $printer->listprinterstemplates[$line][
'rowid'] == $templateid) {
471 print
'<input type="hidden" name="templateid" value="'.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
472 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'"></td>';
473 print
'<td class="wordbreak">';
474 print
'<textarea name="template" wrap="soft" cols="120" rows="12">'.($printer->listprinterstemplates[$line][
'template'] ??
'').
'</textarea>';
477 print $form->buttonsSaveCancel(
"Save",
'');
480 print
'<td>'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'</td>';
481 print
'<td class="wordbreak">'.dol_htmlentitiesbr($printer->listprinterstemplates[$line][
'template'] ??
'').
'</td>';
483 print
'<td class="center"><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=edittemplate&token='.
newToken().
'&templateid='.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
484 print
img_picto($langs->trans(
"Edit"),
'edit');
487 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'] ??
'').
'">';
488 print
img_picto($langs->trans(
"Delete"),
'delete');
491 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'] ??
'').
'">';
492 print
img_picto($langs->trans(
"TestPrinterTemplate"),
'printer');
499 if ($action !=
'edittemplate') {
501 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.($printer->listprinterstemplates[$line][
'name'] ??
'').
'"></td>';
502 print
'<td class="wordbreak">';
503 print
'<textarea name="template" wrap="soft" cols="120" rows="12">';
507 print
'<input type="hidden" name="templateid" value="'.($printer->listprinterstemplates[$line][
'rowid'] ??
'').
'">';
508 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
522 print
'<div class="div-table-responsive">';
523 print
'<table class="noborder centpercent">'.
"\n";
524 print
'<tr class="liste_titre">';
525 print
'<th>'.$langs->trans(
"Tag").
'</th>';
526 print
'<th>'.$langs->trans(
"Description").
'</th>';
529 $langs->loadLangs(array(
"bills",
"companies"));
530 foreach ($printer->tags as $key => $val) {
531 print
'<tr class="oddeven">';
532 print
'<td>{'.$key.
'}</td><td>'.$langs->trans($val).
'</td>';
535 $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.