28 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/receiptprinter.lib.php';
33 require_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');
60 if (!function_exists(
'gzdecode')) {
67 function gzdecode($data)
69 return gzinflate(substr($data, 10, -8));
78 if ($action ==
'addprinter' && $user->admin) {
80 if (empty($printername)) {
85 if (empty($parameter)) {
91 $result = $printer->addPrinter($printername,
GETPOST(
'printertypeid',
'int'),
GETPOST(
'printerprofileid',
'int'), $parameter);
107 if ($action ==
'deleteprinter' && $user->admin) {
109 if (empty($printerid)) {
116 $result = $printer->deletePrinter($printerid);
132 if ($action ==
'updateprinter' && $user->admin) {
134 if (empty($printerid)) {
141 $result = $printer->updatePrinter($printername,
GETPOST(
'printertypeid',
'int'),
GETPOST(
'printerprofileid',
'int'), $parameter, $printerid);
157 if ($action ==
'testprinter' && $user->admin) {
159 if (empty($printerid)) {
166 $ret = $printer->sendTestToPrinter($printerid);
176 if ($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);
200 if ($action ==
'updatetemplate' && $user->admin) {
202 if (empty($templateid)) {
209 $result = $printer->updateTemplate($templatename, $template, $templateid);
225 if ($action ==
'addtemplate' && $user->admin) {
227 if (empty($templatename)) {
234 $result = $printer->addTemplate($templatename, $template);
250 if ($action ==
'deletetemplate' && $user->admin) {
252 if (empty($templateid)) {
259 $result = $printer->deleteTemplate($templateid);
282 llxHeader(
'', $langs->trans(
"ReceiptPrinterSetup"));
284 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
285 print
load_fiche_titre($langs->trans(
"ReceiptPrinterSetup"), $linkback,
'title_setup');
290 if ($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>';
320 $ret = $printer->listprinters();
321 $nbofprinters = count($printer->listprinters);
323 if ($action !=
'editprinter') {
325 print
'<td><input class="minwidth200" type="text" name="printername"></td>';
326 $ret = $printer->selectTypePrinter();
327 print
'<td>'.$printer->resprint.
'</td>';
328 $ret = $printer->selectProfilePrinter();
329 print
'<td>'.$printer->profileresprint.
'</td>';
330 print
'<td><input size="60" type="text" name="parameter"></td>';
331 print
'<td class="right">';
332 if ($action !=
'editprinter') {
333 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'"></div>';
342 for ($line = 0; $line < $nbofprinters; $line++) {
343 print
'<tr class="oddeven">';
344 if ($action ==
'editprinter' && $printer->listprinters[$line][
'rowid'] == $printerid) {
345 print
'<input type="hidden" name="printerid" value="'.$printer->listprinters[$line][
'rowid'].
'">';
346 print
'<td><input type="text" class="minwidth200" name="printername" value="'.$printer->listprinters[$line][
'name'].
'"></td>';
347 $ret = $printer->selectTypePrinter($printer->listprinters[$line][
'fk_type']);
348 print
'<td>'.$printer->resprint.
'</td>';
349 $ret = $printer->selectProfilePrinter($printer->listprinters[$line][
'fk_profile']);
350 print
'<td>'.$printer->profileresprint.
'</td>';
351 print
'<td><input size="60" type="text" name="parameter" value="'.$printer->listprinters[$line][
'parameter'].
'"></td>';
353 print
$form->buttonsSaveCancel(
"Save",
'');
357 print
'<td>'.$printer->listprinters[$line][
'name'].
'</td>';
358 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_type_name']).
'</td>';
359 print
'<td>'.$langs->trans($printer->listprinters[$line][
'fk_profile_name']).
'</td>';
360 print
'<td>'.$printer->listprinters[$line][
'parameter'].
'</td>';
362 print
'<td class="right"><a class="editfielda marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=editprinter&token='.
newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'">';
363 print
img_picto($langs->trans(
"Edit"),
'edit');
366 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']).
'">';
367 print
img_picto($langs->trans(
"Delete"),
'delete');
370 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']).
'">';
371 print
img_picto($langs->trans(
"TestPrinter"),
'printer');
387 print
load_fiche_titre($langs->trans(
"ReceiptPrinterTypeDesc"),
'',
'').
"\n";
389 print
'<table class="noborder centpercent">'.
"\n";
390 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_DUMMY").
':</td><td>'.$langs->trans(
"CONNECTOR_DUMMY_HELP").
'</td></tr>';
391 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_NETWORK_PRINT").
':</td><td>'.$langs->trans(
"CONNECTOR_NETWORK_PRINT_HELP").
'</td></tr>';
392 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_FILE_PRINT").
':</td><td>'.$langs->trans(
"CONNECTOR_FILE_PRINT_HELP").
'</td></tr>';
393 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_WINDOWS_PRINT").
':</td><td>'.$langs->trans(
"CONNECTOR_WINDOWS_PRINT_HELP").
'</td></tr>';
394 print
'<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_CUPS_PRINT").
':</td><td>'.$langs->trans(
"CONNECTOR_CUPS_PRINT_HELP").
'</td></tr>';
401 if ($mode ==
'template' && $user->admin) {
404 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=template" autocomplete="off">';
405 print
'<input type="hidden" name="token" value="'.newToken().
'">';
406 if ($action !=
'edittemplate') {
407 print
'<input type="hidden" name="action" value="addtemplate">';
409 print
'<input type="hidden" name="action" value="updatetemplate">';
412 print
'<table class="noborder centpercent">'.
"\n";
413 print
'<tr class="liste_titre">';
414 print
'<th>'.$langs->trans(
"Name").
'</th>';
415 print
'<th>'.$langs->trans(
"Template").
'</th>';
418 $ret = $printer->listPrintersTemplates();
423 $max = count($printer->listprinterstemplates);
424 for ($line = 0; $line < $max; $line++) {
425 print
'<tr class="oddeven">';
426 if ($action ==
'edittemplate' && $printer->listprinterstemplates[$line][
'rowid'] == $templateid) {
427 print
'<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line][
'rowid'].
'">';
428 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.$printer->listprinterstemplates[$line][
'name'].
'"></td>';
430 print
'<textarea name="template" wrap="soft" cols="120" rows="12">'.$printer->listprinterstemplates[$line][
'template'].
'</textarea>';
433 print
$form->buttonsSaveCancel(
"Save",
'');
436 print
'<td>'.$printer->listprinterstemplates[$line][
'name'].
'</td>';
437 print
'<td>'.dol_htmlentitiesbr($printer->listprinterstemplates[$line][
'template']).
'</td>';
439 print
'<td><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=edittemplate&token='.
newToken().
'&templateid='.$printer->listprinterstemplates[$line][
'rowid'].
'">';
440 print
img_picto($langs->trans(
"Edit"),
'edit');
443 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']).
'">';
444 print
img_picto($langs->trans(
"Delete"),
'delete');
447 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']).
'">';
448 print
img_picto($langs->trans(
"TestPrinterTemplate"),
'printer');
455 if ($action !=
'edittemplate') {
457 print
'<td><input type="text" class="minwidth200" name="templatename" value="'.$printer->listprinterstemplates[$line][
'name'].
'"></td>';
459 print
'<textarea name="template" wrap="soft" cols="120" rows="12">';
463 print
'<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line][
'rowid'].
'">';
464 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'">';
477 print
'<table class="noborder centpercent">'.
"\n";
478 print
'<tr class="liste_titre">';
479 print
'<th>'.$langs->trans(
"Tag").
'</th>';
480 print
'<th>'.$langs->trans(
"Description").
'</th>';
483 $langs->loadLangs(array(
"bills",
"companies"));
484 foreach ($printer->tags as $key => $val) {
485 print
'<tr class="oddeven">';
486 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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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='')
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.