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 ==
'testtemplate' && $user->admin) {
185 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
187 $object->initAsSpecimen();
190 $ret = $printer->sendToPrinter($object, $templateid, 1);
192 setEventMessages($langs->trans(
"TestTemplateToPrinter", $printername),
null);
200if ($action ==
'updatetemplate' && $user->admin) {
202 if (empty($templateid)) {
209 $result = $printer->updateTemplate($templatename, $template, $templateid);
225if ($action ==
'addtemplate' && $user->admin) {
227 if (empty($templatename)) {
234 $result = $printer->addTemplate($templatename, $template);
250if ($action ==
'deletetemplate' && $user->admin) {
252 if (empty($templateid)) {
259 $result = $printer->deleteTemplate($templateid);
280$form =
new Form($db);
282llxHeader(
'', $langs->trans(
"ReceiptPrinterSetup"));
284$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
285print
load_fiche_titre($langs->trans(
"ReceiptPrinterSetup"), $linkback,
'title_setup');
290if ($mode ==
'config' && $user->admin) {
291 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=config" autocomplete="off">';
292 print
'<input type="hidden" name="token" value="'.newToken().
'">';
293 if ($action !=
'editprinter') {
294 print
'<input type="hidden" name="action" value="addprinter">';
296 print
'<input type="hidden" name="action" value="updateprinter">';
302 print
'<span class="opacitymedium">'.$langs->trans(
"ReceiptPrinterDesc").
"</span><br><br>\n";
304 print
'<table class="noborder centpercent">'.
"\n";
305 print
'<tr class="liste_titre">';
306 print
'<th>'.$langs->trans(
"Name").
'</th>';
307 print
'<th>'.$langs->trans(
"Type").
'</th>';
309 $htmltext = $langs->trans(
"PROFILE_DEFAULT").
' = '.$langs->trans(
"PROFILE_DEFAULT_HELP").
'<br>';
310 $htmltext .= $langs->trans(
"PROFILE_SIMPLE").
' = '.$langs->trans(
"PROFILE_SIMPLE_HELP").
'<br>';
311 $htmltext .= $langs->trans(
"PROFILE_EPOSTEP").
' = '.$langs->trans(
"PROFILE_EPOSTEP_HELP").
'<br>';
312 $htmltext .= $langs->trans(
"PROFILE_P822D").
' = '.$langs->trans(
"PROFILE_P822D_HELP").
'<br>';
313 $htmltext .= $langs->trans(
"PROFILE_STAR").
' = '.$langs->trans(
"PROFILE_STAR_HELP").
'<br>';
315 print $form->textwithpicto($langs->trans(
"Profile"), $htmltext);
317 print
'<th>'.$langs->trans(
"Parameters").
'</th>';
321 $ret = $printer->listprinters();
322 $nbofprinters = count($printer->listprinters);
324 if ($action !=
'editprinter') {
326 print
'<td><input class="minwidth200" type="text" name="printername"></td>';
327 $ret = $printer->selectTypePrinter();
328 print
'<td>'.$printer->resprint.
'</td>';
329 $ret = $printer->selectProfilePrinter();
330 print
'<td>'.$printer->profileresprint.
'</td>';
331 print
'<td><input size="60" type="text" name="parameter"></td>';
332 print
'<td class="right">';
333 if ($action !=
'editprinter') {
334 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'"></div>';
343 for ($line = 0; $line < $nbofprinters; $line++) {
344 print
'<tr class="oddeven">';
345 if ($action ==
'editprinter' && $printer->listprinters[$line][
'rowid'] == $printerid) {
346 print
'<input type="hidden" name="printerid" value="'.$printer->listprinters[$line][
'rowid'].
'">';
347 print
'<td><input type="text" class="minwidth200" name="printername" value="'.$printer->listprinters[$line][
'name'].
'"></td>';
348 $ret = $printer->selectTypePrinter($printer->listprinters[$line][
'fk_type']);
349 print
'<td>'.$printer->resprint.
'</td>';
350 $ret = $printer->selectProfilePrinter($printer->listprinters[$line][
'fk_profile']);
351 print
'<td>'.$printer->profileresprint.
'</td>';
352 print
'<td><input size="60" type="text" name="parameter" value="'.$printer->listprinters[$line][
'parameter'].
'"></td>';
354 print $form->buttonsSaveCancel(
"Save",
'');
358 print
'<td>'.$printer->listprinters[$line][
'name'].
'</td>';
359 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_type_name']).
'</td>';
360 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_profile_name']).
'</td>';
361 print
'<td>'.$printer->listprinters[$line][
'parameter'].
'</td>';
363 print
'<td class="right"><a class="editfielda marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=editprinter&token='.newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'">';
364 print
img_picto($langs->trans(
"Edit"),
'edit');
367 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']).
'">';
368 print
img_picto($langs->trans(
"Delete"),
'delete');
371 print
'<a class="marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=testprinter&token='.newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'&printername='.urlencode($printer->listprinters[$line][
'name']).
'">';
372 print
img_picto($langs->trans(
"TestPrinter"),
'printer');
388 print
load_fiche_titre($langs->trans(
"ReceiptPrinterTypeDesc"),
'',
'').
"\n";
390 print
'<table class="noborder centpercent">'.
"\n";
391 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_DUMMY").
':</td><td>'.$langs->trans(
"CONNECTOR_DUMMY_HELP").
'</td></tr>';
392 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_NETWORK_PRINT").
':</td><td>'.$langs->trans(
"CONNECTOR_NETWORK_PRINT_HELP").
'</td></tr>';
393 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_FILE_PRINT").
':</td><td>'.$langs->trans(
"CONNECTOR_FILE_PRINT_HELP").
'</td></tr>';
394 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_WINDOWS_PRINT").
':</td><td>'.$langs->trans(
"CONNECTOR_WINDOWS_PRINT_HELP").
'</td></tr>';
395 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_CUPS_PRINT").
':</td><td>'.$langs->trans(
"CONNECTOR_CUPS_PRINT_HELP").
'</td></tr>';
402if ($mode ==
'template' && $user->admin) {
405 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=template" autocomplete="off">';
406 print
'<input type="hidden" name="token" value="'.newToken().
'">';
407 if ($action !=
'edittemplate') {
408 print
'<input type="hidden" name="action" value="addtemplate">';
410 print
'<input type="hidden" name="action" value="updatetemplate">';
413 print
'<table class="noborder centpercent">'.
"\n";
414 print
'<tr class="liste_titre">';
415 print
'<th>'.$langs->trans(
"Name").
'</th>';
416 print
'<th>'.$langs->trans(
"Template").
'</th>';
419 $ret = $printer->listPrintersTemplates();
424 $max = count($printer->listprinterstemplates);
425 for ($line = 0; $line < $max; $line++) {
426 print
'<tr class="oddeven">';
427 if ($action ==
'edittemplate' && $printer->listprinterstemplates[$line][
'rowid'] == $templateid) {
428 print
'<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line][
'rowid'].
'">';
429 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.$printer->listprinterstemplates[$line][
'name'].
'"></td>';
431 print
'<textarea name="template" wrap="soft" cols="120" rows="12">'.$printer->listprinterstemplates[$line][
'template'].
'</textarea>';
434 print $form->buttonsSaveCancel(
"Save",
'');
437 print
'<td>'.$printer->listprinterstemplates[$line][
'name'].
'</td>';
438 print
'<td>'.dol_htmlentitiesbr($printer->listprinterstemplates[$line][
'template']).
'</td>';
440 print
'<td><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=edittemplate&token='.newToken().
'&templateid='.$printer->listprinterstemplates[$line][
'rowid'].
'">';
441 print
img_picto($langs->trans(
"Edit"),
'edit');
444 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']).
'">';
445 print
img_picto($langs->trans(
"Delete"),
'delete');
448 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']).
'">';
449 print
img_picto($langs->trans(
"TestPrinterTemplate"),
'printer');
456 if ($action !=
'edittemplate') {
458 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.$printer->listprinterstemplates[$line][
'name'].
'"></td>';
460 print
'<textarea name="template" wrap="soft" cols="120" rows="12">';
464 print
'<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line][
'rowid'].
'">';
465 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
478 print
'<table class="noborder centpercent">'.
"\n";
479 print
'<tr class="liste_titre">';
480 print
'<th>'.$langs->trans(
"Tag").
'</th>';
481 print
'<th>'.$langs->trans(
"Description").
'</th>';
484 $langs->loadLangs(array(
"bills",
"companies"));
485 foreach ($printer->tags as $key => $val) {
486 print
'<tr class="oddeven">';
487 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.