diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index adba566eabb..fe20da1bef9 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -36,16 +36,20 @@ if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); $mode = GETPOST('mode','alpha'); -$value = GETPOST('value','alpha'); -$varname = GETPOST('varname', 'alpha'); + $printername = GETPOST('printername', 'alpha'); $printerid = GETPOST('printerid', 'int'); $parameter = GETPOST('parameter', 'alpha'); +$template = GETPOST('template', 'alpha'); +$templatename = GETPOST('templatename', 'alpha'); +$templateid = GETPOST('templateid', 'int'); + $printer = new dolReceiptPrinter($db); if (!$mode) $mode='config'; +// used in library escpos maybe useful if php doesn't support gzdecode if (!function_exists('gzdecode')) { function gzdecode($data) { @@ -170,6 +174,35 @@ if ($action == 'testprinter' && $user->admin) } +if ($action == 'updatetemplate' && $user->admin) +{ + $error=0; + $db->begin(); + if (empty($templateid)) { + $error++; + setEventMessages($langs->trans("TemplateIdEmpty"), null, 'errors'); + } + + if (! $error) + { + $result= $printer->UpdateTemplate($templatename, $template, $templateid); + if ($result > 0) $error++; + + if (! $error) + { + $db->commit(); + setEventMessages($langs->trans("TemplateUpdated",$templatename), null); + } + else + { + $db->rollback(); + dol_print_error($db); + } + } + $action = ''; +} + + /* * View */ @@ -309,76 +342,6 @@ if ($mode == 'config' && $user->admin) if ($mode == 'template' && $user->admin) { - $tags = array( - 'dol_align_left', - 'dol_align_center', - 'dol_align_right', - 'dol_use_font_a', - 'dol_use_font_b', - 'dol_use_font_c', - 'dol_bold', - '/dol_bold', - 'dol_double_height', - '/dol_double_height', - 'dol_double_width', - '/dol_double_width', - 'dol_underline', - '/dol_underline', - 'dol_underline_2dots', - '/dol_underline', - 'dol_emphasized', - '/dol_emphasized', - 'dol_switch_colors', - '/dol_switch_colors', - 'dol_print_barcode', - 'dol_print_barcode_customer_id', - 'dol_set_print_width_57', - 'dol_cut_paper_full', - 'dol_cut_paper_partial', - 'dol_open_drawer', - 'dol_activate_buzzer', - 'dol_print_qrcode', - 'dol_print_date', - 'dol_print_date_time', - 'dol_print_year', - 'dol_print_month_letters', - 'dol_print_month', - 'dol_print_day', - 'dol_print_day_letters', - 'dol_print_table', - 'dol_print_cutlery', - 'dol_print_payment', - 'dol_print_logo', - 'dol_print_logo_old', - 'dol_print_order_lines', - 'dol_print_order_tax', - 'dol_print_order_local_tax', - 'dol_print_order_total', - 'dol_print_order_number', - 'dol_print_order_number_unique', - 'dol_print_customer_first_name', - 'dol_print_customer_last_name', - 'dol_print_customer_mail', - 'dol_print_customer_telephone', - 'dol_print_customer_mobile', - 'dol_print_customer_skype', - 'dol_print_customer_tax_number', - 'dol_print_customer_account_balance', - 'dol_print_vendor_last_name', - 'dol_print_vendor_first_name', - 'dol_print_vendor_mail', - 'dol_print_customer_points', - 'dol_print_order_points', - 'dol_print_if_customer', - 'dol_print_if_vendor', - 'dol_print_if_happy_hour', - 'dol_print_if_num_order_unique', - 'dol_print_if_customer_points', - 'dol_print_if_order_points', - 'dol_print_if_customer_tax_number', - 'dol_print_if_customer_account_balance_positive', - ); - print '