27 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/receiptprinter.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolreceiptprinter.class.php';
35 $langs->loadLangs(array(
"admin",
"receiptprinter"));
39 $action =
GETPOST(
'action',
'aZ09');
40 $mode =
GETPOST(
'mode',
'alpha');
42 $printername =
GETPOST(
'printername',
'alpha');
43 $printerid =
GETPOST(
'printerid',
'int');
44 $parameter =
GETPOST(
'parameter',
'alpha');
46 $template =
GETPOST(
'template',
'nohtml');
47 $templatename =
GETPOST(
'templatename',
'alpha');
48 $templateid =
GETPOST(
'templateid',
'int');
52 if (!$mode) $mode =
'config';
55 if (!function_exists(
'gzdecode')) {
62 function gzdecode($data)
64 return gzinflate(substr($data, 10, -8));
73 if ($action ==
'addprinter' && $user->admin) {
75 if (empty($printername)) {
80 if (empty($parameter)) {
86 $result = $printer->addPrinter($printername,
GETPOST(
'printertypeid',
'int'),
GETPOST(
'printerprofileid',
'int'), $parameter);
87 if ($result > 0) $error++;
101 if ($action ==
'deleteprinter' && $user->admin) {
103 if (empty($printerid)) {
110 $result = $printer->deletePrinter($printerid);
111 if ($result > 0) $error++;
125 if ($action ==
'updateprinter' && $user->admin) {
127 if (empty($printerid)) {
134 $result = $printer->updatePrinter($printername,
GETPOST(
'printertypeid',
'int'),
GETPOST(
'printerprofileid',
'int'), $parameter, $printerid);
135 if ($result > 0) $error++;
148 if ($action ==
'testprinter' && $user->admin) {
150 if (empty($printerid)) {
157 $ret = $printer->sendTestToPrinter($printerid);
167 if ($action ==
'testtemplate' && $user->admin) {
176 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
181 $ret = $printer->sendToPrinter($object, $templateid, 1);
183 setEventMessages($langs->trans(
"TestTemplateToPrinter", $printername), null);
191 if ($action ==
'updatetemplate' && $user->admin) {
193 if (empty($templateid)) {
200 $result = $printer->updateTemplate($templatename, $template, $templateid);
201 if ($result > 0) $error++;
214 if ($action ==
'addtemplate' && $user->admin) {
216 if (empty($templatename)) {
223 $result = $printer->addTemplate($templatename, $template);
224 if ($result > 0) $error++;
237 if ($action ==
'deletetemplate' && $user->admin) {
239 if (empty($templateid)) {
246 $result = $printer->deleteTemplate($templateid);
247 if ($result > 0) $error++;
265 $form =
new Form($db);
267 llxHeader(
'', $langs->trans(
"ReceiptPrinterSetup"));
269 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
275 if ($mode ==
'config' && $user->admin) {
276 print '<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=config" autocomplete="off">';
277 print '<input type="hidden" name="token" value="'.newToken().
'">';
278 if ($action !=
'editprinter') {
279 print '<input type="hidden" name="action" value="addprinter">';
281 print '<input type="hidden" name="action" value="updateprinter">';
287 print '<span class="opacitymedium">'.$langs->trans(
"ReceiptPrinterDesc").
"</span><br><br>\n";
289 print '<table class="noborder centpercent">'.
"\n";
290 print '<tr class="liste_titre">';
291 print '<th>'.$langs->trans(
"Name").
'</th>';
292 print '<th>'.$langs->trans(
"Type").
'</th>';
293 print '<th>'.$langs->trans(
"Profile").
'</th>';
294 print '<th>'.$langs->trans(
"Parameters").
'</th>';
297 $ret = $printer->listprinters();
298 $nbofprinters = count($printer->listprinters);
300 if ($action !=
'editprinter') {
302 print '<td><input size="50" type="text" name="printername"></td>';
303 $ret = $printer->selectTypePrinter();
304 print '<td>'.$printer->resprint.
'</td>';
305 $ret = $printer->selectProfilePrinter();
306 print '<td>'.$printer->profileresprint.
'</td>';
307 print '<td><input size="60" type="text" name="parameter"></td>';
308 print '<td class="right">';
309 if ($action !=
'editprinter') {
310 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'"></div>';
319 for ($line = 0; $line < $nbofprinters; $line++) {
320 print '<tr class="oddeven">';
321 if ($action ==
'editprinter' && $printer->listprinters[$line][
'rowid'] == $printerid) {
322 print '<input type="hidden" name="printerid" value="'.$printer->listprinters[$line][
'rowid'].
'">';
323 print '<td><input size="50" type="text" name="printername" value="'.$printer->listprinters[$line][
'name'].
'"></td>';
324 $ret = $printer->selectTypePrinter($printer->listprinters[$line][
'fk_type']);
325 print '<td>'.$printer->resprint.
'</td>';
326 $ret = $printer->selectProfilePrinter($printer->listprinters[$line][
'fk_profile']);
327 print '<td>'.$printer->profileresprint.
'</td>';
328 print '<td><input size="60" type="text" name="parameter" value="'.$printer->listprinters[$line][
'parameter'].
'"></td>';
330 print '<div class="center"><input type="submit" class="button button-save" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'"></div>';
334 print '<td>'.$printer->listprinters[$line][
'name'].
'</td>';
335 print '<td>'.$langs->trans($printer->listprinters[$line][
'fk_type_name']).
'</td>';
336 print '<td>'.$langs->trans($printer->listprinters[$line][
'fk_profile_name']).
'</td>';
337 print '<td>'.$printer->listprinters[$line][
'parameter'].
'</td>';
339 print '<td class="right"><a class="editfielda marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=editprinter&printerid='.$printer->listprinters[$line][
'rowid'].
'">';
343 print
'<a class="marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=deleteprinter&token='.
newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'&printername='.$printer->listprinters[$line][
'name'].
'">';
344 print
img_picto($langs->trans(
"Delete"),
'delete');
347 print
'<a class="marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=config&action=testprinter&token='.
newToken().
'&printerid='.$printer->listprinters[$line][
'rowid'].
'&printername='.$printer->listprinters[$line][
'name'].
'">';
348 print
img_picto($langs->trans(
"TestPrinter"),
'printer');
366 print '<table class="noborder centpercent">'.
"\n";
367 print '<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_DUMMY").
':</td><td>'.$langs->trans(
"CONNECTOR_DUMMY_HELP").
'</td></tr>';
368 print '<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_NETWORK_PRINT").
':</td><td>'.$langs->trans(
"CONNECTOR_NETWORK_PRINT_HELP").
'</td></tr>';
369 print '<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_FILE_PRINT").
':</td><td>'.$langs->trans(
"CONNECTOR_FILE_PRINT_HELP").
'</td></tr>';
370 print '<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_WINDOWS_PRINT").
':</td><td>'.$langs->trans(
"CONNECTOR_WINDOWS_PRINT_HELP").
'</td></tr>';
371 print '<tr class="oddeven"><td>'.$langs->trans(
"CONNECTOR_CUPS_PRINT").
':</td><td>'.$langs->trans(
"CONNECTOR_CUPS_PRINT_HELP").
'</td></tr>';
379 print '<table class="noborder centpercent">'.
"\n";
380 print '<tr class="oddeven"><td>'.$langs->trans(
"PROFILE_DEFAULT").
':</td><td>'.$langs->trans(
"PROFILE_DEFAULT_HELP").
'</td></tr>';
381 print '<tr class="oddeven"><td>'.$langs->trans(
"PROFILE_SIMPLE").
':</td><td>'.$langs->trans(
"PROFILE_SIMPLE_HELP").
'</td></tr>';
382 print '<tr class="oddeven"><td>'.$langs->trans(
"PROFILE_EPOSTEP").
':</td><td>'.$langs->trans(
"PROFILE_EPOSTEP_HELP").
'</td></tr>';
383 print '<tr class="oddeven"><td>'.$langs->trans(
"PROFILE_P822D").
':</td><td>'.$langs->trans(
"PROFILE_P822D_HELP").
'</td></tr>';
384 print '<tr class="oddeven"><td>'.$langs->trans(
"PROFILE_STAR").
':</td><td>'.$langs->trans(
"PROFILE_STAR_HELP").
'</td></tr>';
389 if ($mode ==
'template' && $user->admin) {
392 print '<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=template" autocomplete="off">';
393 print '<input type="hidden" name="token" value="'.newToken().
'">';
394 if ($action !=
'edittemplate') {
395 print '<input type="hidden" name="action" value="addtemplate">';
397 print '<input type="hidden" name="action" value="updatetemplate">';
400 print '<table class="noborder centpercent">'.
"\n";
401 print '<tr class="liste_titre">';
402 print '<th>'.$langs->trans(
"Name").
'</th>';
403 print '<th>'.$langs->trans(
"Template").
'</th>';
406 $ret = $printer->listPrintersTemplates();
411 $max = count($printer->listprinterstemplates);
412 for ($line = 0; $line < $max; $line++) {
413 print '<tr class="oddeven">';
414 if ($action ==
'edittemplate' && $printer->listprinterstemplates[$line][
'rowid'] == $templateid) {
415 print '<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line][
'rowid'].
'">';
416 print '<td><input size="50" type="text" name="templatename" value="'.$printer->listprinterstemplates[$line][
'name'].
'"></td>';
418 print '<textarea name="template" wrap="soft" cols="120" rows="12">'.$printer->listprinterstemplates[$line][
'template'].
'</textarea>';
422 print '<td>'.$printer->listprinterstemplates[$line][
'name'].
'</td>';
423 print '<td>'.dol_htmlentitiesbr($printer->listprinterstemplates[$line][
'template']).
'</td>';
425 print '<td><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=edittemplate&templateid='.$printer->listprinterstemplates[$line][
'rowid'].
'">';
429 print
'<a class="paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=deletetemplate&templateid='.$printer->listprinterstemplates[$line][
'rowid'].
'&templatename='.$printer->listprinterstemplates[$line][
'name'].
'">';
430 print
img_picto($langs->trans(
"Delete"),
'delete');
433 print
'<a class="paddingleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?mode=template&action=testtemplate&templateid='.$printer->listprinterstemplates[$line][
'rowid'].
'&templatename='.$printer->listprinterstemplates[$line][
'name'].
'">';
434 print
img_picto($langs->trans(
"TestPrinterTemplate"),
'printer');
441 if ($action !=
'edittemplate') {
443 print '<td><input size="50" type="text" name="templatename" value="'.$printer->listprinterstemplates[$line][
'name'].
'"></td>';
445 print '<textarea name="template" wrap="soft" cols="120" rows="12">';
455 if ($action !=
'edittemplate') {
456 print '<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line][
'rowid'].
'">';
457 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Add")).
'"></div>';
459 print '<div class="center"><input type="submit" class="button button-save" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'"></div>';
467 print '<table class="noborder centpercent">'.
"\n";
468 print '<tr class="liste_titre">';
469 print '<th>'.$langs->trans(
"Tag").
'</th>';
470 print '<th>'.$langs->trans(
"Description").
'</th>';
473 $langs->loadLangs(array(
"bills",
"companies"));
474 foreach ($printer->tags as $key => $val) {
475 print '<tr class="oddeven">';
476 print '<td>{'.$key.
'}</td><td>'.$langs->trans($val).
'</td>';
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= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage Receipt Printers.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
receiptprinteradmin_prepare_head($mode)
Define head array for tabs of receipt printer setup pages.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage invoices.