Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receipt Printer conf and lang #3889

Merged
merged 3 commits into from
Nov 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ source_file = htdocs/langs/en_US/propal.lang
source_lang = en_US
type = MOZILLAPROPERTIES

[dolibarr.receiptprinter]
file_filter = htdocs/langs/<lang>/receiptprinter.lang
source_file = htdocs/langs/en_US/receiptprinter.lang
source_lang = en_US
type = MOZILLAPROPERTIES

[dolibarr.resource]
file_filter = htdocs/langs/<lang>/resource.lang
source_file = htdocs/langs/en_US/resource.lang
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"ext-curl": "*",
"ccampbell/chromephp": "^4.1",
"ckeditor/ckeditor": "4.3.3",
"mike42/escpos-php": "dev-master",
"mobiledetect/mobiledetectlib": "2.8.3",
"phpoffice/phpexcel": "1.8.0",
"restler/framework": "^3.0",
Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/receiptprinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ function gzdecode($data)
}

// to remove after test
$object->date = '2015-11-02 22:30:25';
$object->date_time = '2015-11-02 22:30:25';
$object->id = 1234;
$object->customer_firstname = 'John';
$object->customer_lastname = 'Deuf';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/cashdesk/admin/cashdesk.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
{
$var=! $var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("DolibarrReceiptPrinter");
print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')';
print '<td colspan="2">';
print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER",$conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER,1);
print "</td></tr>\n";
Expand Down
17 changes: 13 additions & 4 deletions htdocs/core/class/dolreceiptprinter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
*
*/

require_once DOL_DOCUMENT_ROOT .'/includes/escpos/Escpos.php';
require_once DOL_DOCUMENT_ROOT .'/includes/mike42/escpos-php/Escpos.php';


/**
Expand Down Expand Up @@ -429,6 +429,7 @@ function SendToPrinter($object, $templateid, $printerid)
$this->template = str_replace('<dol_print_customer_account_balance>', $object->customer_account_balance, $this->template);
$this->template = str_replace('<dol_print_vendor_firstname>', $object->vendor_firstname, $this->template);
$this->template = str_replace('<dol_print_vendor_lastname>', $object->vendor_lastname, $this->template);
$this->template = str_replace('<dol_print_date_time>', $object->date_time, $this->template);

// parse template
$p = xml_parser_create();
Expand All @@ -438,6 +439,7 @@ function SendToPrinter($object, $templateid, $printerid)
//print '<pre>'.print_r($vals, true).'</pre>';
// print ticket
$level = 0;
$html = '<table border="1" style="width:210px"><pre>';
$ret = $this->InitPrinter($printerid);
if ($ret>0) {
setEventMessages($this->error, $this->errors, 'errors');
Expand All @@ -446,33 +448,37 @@ function SendToPrinter($object, $templateid, $printerid)
switch ($vals[$line]['tag']) {
case 'DOL_ALIGN_CENTER':
$this->printer->setJustification(Escpos::JUSTIFY_CENTER);
$html.='<center>';
$this->printer->text($vals[$line]['value']);
break;
case 'DOL_ALIGN_RIGHT':
$this->printer->setJustification(Escpos::JUSTIFY_RIGHT);
$html.='<right>';
break;
case 'DOL_ALIGN_LEFT':
$this->printer->setJustification(Escpos::JUSTIFY_LEFT);
$html.='<left>';
break;
case 'DOL_OPEN_DRAWER':
$this->printer->pulse();
$html.= ' &#991;'.nl2br($vals[$line]['value']);
break;
case 'DOL_PRINT_BARCODE':
// $vals[$line]['value'] -> barcode($content, $type)
$this->printer->barcode($object->barcode);
break;
case 'DOL_PRINT_DATE_TIME':
$this->printer->text($object->date);
break;
case 'DOL_PRINT_QRCODE':
// $vals[$line]['value'] -> qrCode($content, $ec, $size, $model)
$this->printer->qrcode($vals[$line]['value']);
$html.='QRCODE: '.$vals[$line]['value'];
break;
case 'DOL_CUT_PAPER_FULL':
$this->printer->cut(Escpos::CUT_FULL);
$html.= ' &#9986;'.nl2br($vals[$line]['value']);
break;
case 'DOL_CUT_PAPER_PARTIAL':
$this->printer->cut(Escpos::CUT_PARTIAL);
$html.= ' &#9986;'.nl2br($vals[$line]['value']);
break;
case 'DOL_USE_FONT_A':
$this->printer->setFont(Escpos::FONT_A);
Expand All @@ -488,11 +494,14 @@ function SendToPrinter($object, $templateid, $printerid)
break;
default:
$this->printer->text($vals[$line]['value']);
$html.= nl2br($vals[$line]['value']);
$this->errors[] = 'UnknowTag: &lt;'.strtolower($vals[$line]['tag']).'&gt;';
$error++;
break;
}
}
$html.= '</pre></table>';
print $html;
// Close and print
// uncomment next line to see content sent to printer
//print '<pre>'.print_r($this->connector, true).'</pre>';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/modReceiptPrinter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function __construct($db)
$this->name = preg_replace('/^mod/i','',get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
$this->description = "ReceiptPrinterDesc";
$this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version
$this->version = 'development'; // 'development' or 'experimental' or 'dolibarr' or version
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
$this->special = 1;
Expand Down
12 changes: 0 additions & 12 deletions htdocs/includes/escpos/.gitignore

This file was deleted.

Loading