diff --git a/.stickler.yml b/.stickler.yml
index b68804448b2..642dec27412 100644
--- a/.stickler.yml
+++ b/.stickler.yml
@@ -8,3 +8,7 @@ linters:
fixers:
enable: true
+
+files:
+ ignore:
+ - 'htdocs/includes/*'
diff --git a/COPYRIGHT b/COPYRIGHT
index 1af09e6fdaf..fe707c1d63d 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -2,7 +2,7 @@
License
-------
-Dolibarr is released under the terms of the GNU General Public License as
+Dolibarr is released under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of the License,
or (at your option) any later version (GPL-3+).
More information: https://www.gnu.org/licenses/gpl-3.0.txt
@@ -15,13 +15,13 @@ PHP libraries:
AdoDb-Date 0.36 Modified BSD License Yes Date convertion (not into rpm package)
CKEditor 4.12.1 LGPL-2.1+ Yes Editor WYSIWYG
EvalMath 1.0 BSD Yes Safe math expressions evaluation
-Escpos-php ? MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers
+Escpos-php 2.2 MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers
GeoIP 1.4 LGPL-2.1+ Yes Sample code to make geoip convert (not into deb package)
Mobiledetect 2.8.33 MIT License Yes Detect mobile devices browsers
NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency
ParseDown 1.6 MIT License Yes Markdown parser
-PHPDebugBar 1.15.0 MIT License Yes Used only by the module "debugbar" for developers
+PHPDebugBar 1.15.0 MIT License Yes Used only by the module "debugbar" for developers
PHPExcel 1.8.1 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
PHPSpreadSheet ? LGPL-2.1+ Yes Read/Write XLS files, read ODS files
php-iban 1.4.7 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP
@@ -37,7 +37,7 @@ TCPDF 6.3.2 LGPL-3+ Yes
TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement
JS libraries:
-Ace 1.4.6 BSD Yes JS library to get code syntaxique coloration in a textarea.
+Ace 1.4.6 BSD Yes JS library to get code syntaxique coloration in a textarea.
jQuery 3.4.1 MIT License Yes JS library
jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI
jQuery select2 4.0.5 GPL and Apache License Yes JS library plugin for sexier multiselect
diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php
index 6184bebd97f..9d3d125f3da 100644
--- a/htdocs/admin/receiptprinter.php
+++ b/htdocs/admin/receiptprinter.php
@@ -166,6 +166,29 @@ if ($action == 'testprinter' && $user->admin) {
$action = '';
}
+if ($action == 'testtemplate' && $user->admin) {
+ $error=0;
+ // if (empty($printerid)) {
+ // $error++;
+ // setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
+ // }
+
+ // if (! $error) {
+ // test
+ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+ $object = new Facture($db);
+ //$object->initAsSpecimen();
+ $object->fetch(18);
+ //var_dump($object->lines);
+ $ret = $printer->sendToPrinter($object, $templateid, 1);
+ if ($ret == 0) {
+ setEventMessages($langs->trans("TestTemplateToPrinter", $printername), null);
+ } else {
+ setEventMessages($printer->error, $printer->errors, 'errors');
+ }
+ //}
+ $action = '';
+}
if ($action == 'updatetemplate' && $user->admin) {
$error=0;
@@ -190,6 +213,29 @@ if ($action == 'updatetemplate' && $user->admin) {
$action = '';
}
+if ($action == 'addtemplate' && $user->admin) {
+ $error=0;
+ $db->begin();
+ if (empty($templatename)) {
+ $error++;
+ setEventMessages($langs->trans("TemplateNameEmpty"), null, 'errors');
+ }
+
+ if (! $error) {
+ $result= $printer->addTemplate($templatename, $template);
+ if ($result > 0) $error++;
+
+ if (! $error) {
+ $db->commit();
+ setEventMessages($langs->trans("TemplateAdded", $templatename), null);
+ } else {
+ $db->rollback();
+ dol_print_error($db);
+ }
+ }
+ $action = '';
+}
+
/*
* View
@@ -217,15 +263,13 @@ if ($mode == 'config' && $user->admin) {
print $langs->trans("ReceiptPrinterDesc")."
\n";
- print '
| '.$langs->trans("Name").' | '; print ''.$langs->trans("Type").' | '; print ''.$langs->trans("Profile").' | '; print ''.$langs->trans("Parameters").' | '; print ''; - print ' | '; - print ' | '; print " | '.$printer->profileresprint.' | '; print ''; print ' | '; - print ' | '; - print ' | '; print ''; } else { print ' | '.$printer->listprinters[$line]['name'].' | '; @@ -255,13 +297,13 @@ if ($mode == 'config' && $user->admin) { // edit icon print ''; print img_picto($langs->trans("Edit"), 'edit'); - print ' | '; + print ''; // delete icon - print ''; + print ''; print img_picto($langs->trans("Delete"), 'delete'); - print ' | '; + print ''; // test icon - print ''; + print ''; print img_picto($langs->trans("TestPrinter"), 'printer'); print ' | '; print ''; @@ -269,7 +311,7 @@ if ($mode == 'config' && $user->admin) { } } - if ($action!='editprinter') { + if ($action != 'editprinter') { if ($nbofprinters > 0) { print '
|---|---|---|---|---|---|---|---|---|
| '.$langs->trans("Name").' | '; @@ -277,8 +319,6 @@ if ($mode == 'config' && $user->admin) { print ''.$langs->trans("Profile").' | '; print ''.$langs->trans("Parameters").' | '; print ''; - print ' | '; - print ' | '; print " | |||
| '.$langs->trans("Name").' | '; print ''.$langs->trans("Template").' | '; @@ -359,8 +399,7 @@ if ($mode == 'template' && $user->admin) { setEventMessages($printer->error, $printer->errors, 'errors'); } else { $max = count($printer->listprinterstemplates); - for ($line=0; $line < $max; $line++) - { + for ($line=0; $line < $max; $line++) { print '|||||||
|---|---|---|---|---|---|---|---|---|
| '; print ' | '; print ''; - print ' | '; - print ' | '; } else { print ' | '.$printer->listprinterstemplates[$line]['name'].' | '; print ''.nl2br(htmlentities($printer->listprinterstemplates[$line]['template'])).' | '; // edit icon print ''; print img_picto($langs->trans("Edit"), 'edit'); - print ' | '; + print ''; // delete icon - print ''; + print ''; print img_picto($langs->trans("Delete"), 'delete'); - print ' | '; + print ''; // test icon - print ''; + print ''; print img_picto($langs->trans("TestPrinterTemplate"), 'printer'); print ' | '; } @@ -392,13 +429,19 @@ if ($mode == 'template' && $user->admin) { print '
| '.$langs->trans("Tag").' | '; print ''.$langs->trans("Description").' | '; @@ -414,18 +457,6 @@ if ($mode == 'template' && $user->admin) { dol_fiche_end(); } -// to remove after test -// $object=new stdClass(); -// $object->date_time = '2015-11-02 22:30:25'; -// $object->id = 1234; -// $object->customer_firstname = 'John'; -// $object->customer_lastname = 'Deuf'; -// $object->vendor_firstname = 'Jim'; -// $object->vendor_lastname = 'Big'; -// $object->barcode = '3700123862396'; -//$printer->sendToPrinter($object, 1, 16); -//setEventMessages($printer->error, $printer->errors, 'errors'); - // End of page llxFooter(); $db->close(); diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index ef529f39d9a..1d445614981 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015-2019 Frédéric France
|---|
'.print_r($this->connector, true).''; @@ -687,7 +800,7 @@ class dolReceiptPrinter extends Escpos $this->connector = 'CONNECTOR_UNKNOWN'; break; } - $this->printer = new Escpos($this->connector); + $this->printer = new Printer($this->connector, $this->profile); } catch (Exception $e) { $this->errors[] = $e->getMessage(); $error++; diff --git a/htdocs/includes/mike42/escpos-php/.coveralls.yml b/htdocs/includes/mike42/escpos-php/.coveralls.yml new file mode 100644 index 00000000000..b33373af905 --- /dev/null +++ b/htdocs/includes/mike42/escpos-php/.coveralls.yml @@ -0,0 +1,4 @@ +service_name: travis-ci +coverage_clover: build/logs/clover.xml +json_path: build/logs/coveralls-upload.json + diff --git a/htdocs/includes/mike42/escpos-php/.gitignore b/htdocs/includes/mike42/escpos-php/.gitignore index 0e8fc4a31ee..8632f891ad4 100644 --- a/htdocs/includes/mike42/escpos-php/.gitignore +++ b/htdocs/includes/mike42/escpos-php/.gitignore @@ -10,3 +10,7 @@ doc/doxygen_sqlite3.db # composer files vendor/ + +# other build files +build/* +*.phar diff --git a/htdocs/includes/mike42/escpos-php/.travis.yml b/htdocs/includes/mike42/escpos-php/.travis.yml new file mode 100644 index 00000000000..04ffb6523b6 --- /dev/null +++ b/htdocs/includes/mike42/escpos-php/.travis.yml @@ -0,0 +1,46 @@ +--- +dist: trusty +sudo: required + +language: php + +php: + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - 7.1 + - 7.2 + - nightly + - hhvm-3.21 + - hhvm-nightly + +matrix: + allow_failures: + - php: nightly + - php: hhvm-nightly + +before_install: + - sudo apt-get -qq update + - sudo apt-get install -y imagemagick ghostscript + +install: + - composer install + +before_script: + # Install 'imagick' plugin + - bash -c 'if [[ $TRAVIS_PHP_VERSION != hhvm* ]]; then printf "\n" | pecl install imagick; fi' + # Directory for coverage report + - mkdir -p build/logs/ + +script: + # Check code style + - php vendor/bin/phpcs --standard=psr2 src/ -n + # Run tests + - php vendor/bin/phpunit --coverage-clover build/logs/clover.xml + +after_success: + # Upload coverage statistics to coveralls service after test + - wget -c -nc https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar + - php coveralls.phar -v +... diff --git a/htdocs/includes/mike42/escpos-php/CONTRIBUTING.md b/htdocs/includes/mike42/escpos-php/CONTRIBUTING.md new file mode 100644 index 00000000000..326e1d093ac --- /dev/null +++ b/htdocs/includes/mike42/escpos-php/CONTRIBUTING.md @@ -0,0 +1,65 @@ +# How to contribute + +This project is open to many different types of contribution. You can help with improving the documentation and examples, sharing your insights on the issue tracker, adding fixes to the code, providing test cases, or just [writing about your hardware setup that you use](https://github.com/mike42/escpos-php/issues/new). + +## Issue tracker + +Open issues of all sorts are tracked on the [issue tracker](https://github.com/mike42/escpos-php/issues). Please check [the FAQ](https://github.com/mike42/escpos-php/blob/development/doc/FAQ.md) before you post, and practice good [bug tracker etiquette](https://bugzilla.mozilla.org/page.cgi?id=etiquette.html) to keep it running smoothly. + +Issues are [loosely categorised](https://github.com/mike42/escpos-php/labels), and will stay open while there is still something that can be resolved. + +Anybody may add to the discussion on the bug tracker. Just be sure to add new questions as separate issues, and to avoid commenting on closed issues. + +## Submitting changes + +Code changes may be submitted as a "[pull request](https://help.github.com/articles/about-pull-requests/)" at [mike42/escpos-php](https://github.com/mike42/escpos-php). The description should include some information about how the change improves the library. + +The project is MIT-licensed (see [LICENSE.md](https://github.com/mike42/escpos-php/blob/development/LICENSE.md) for details). You are not required to assign copyright in order to submit changes, but you do need to agree for your code to be distributed under this license in order for it to be accepted. + +### Documentation changes + +The official documentaton is also located in the main repository, under the [doc/](https://github.com/mike42/escpos-php/tree/development/doc) folder. + +You are welcome to post any suggested improvements as pull requests. + +### Release process + +Once a pull request is accepted, it usually appears in a release a few days later. + +Branches: + +- "development" is the most recent code, possibly containing unreleased fixes +- "master" contains the most recently released code (old versions are not maintained). + +The release process for your changes is: + +- Changes are submitted via pull request to the shared "development" branch. +- A new release is staged on the "master" branch via another pull request, and then tagged. + +## Code style + +This project uses the [PSR-2 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) for all PHP source code. + +## Testing and CI + +The tests are executed on [Travis CI](https://travis-ci.org/mike42/escpos-php) over PHP 5.4, 5.5, 5.6, 7.0, 7.1 and 7.2, plus the latest LTS version of HHVM, 3.21. Older versions of PHP are not supported in current releases. + +For development, it's suggested that you load `imagick`, `gd` and `Xdebug` PHP exensions, and install `composer`. + +Fetch a copy of this code and load dependencies with composer: + + git clone https://github.com/mike42/escpos-php + cd escpos-php/ + composer install + +Execute unit tests via `phpunit`: + + php vendor/bin/phpunit --coverage-text + +Code style can be checked via [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer): + + php vendor/bin/phpcs --standard=psr2 src/ -n + +The developer docs are built with [doxygen](https://github.com/doxygen/doxygen). Re-build them to check for documentation warnings: + + make -C doc clean && make -C doc diff --git a/htdocs/includes/mike42/escpos-php/CONTRIBUTORS.md b/htdocs/includes/mike42/escpos-php/CONTRIBUTORS.md new file mode 100644 index 00000000000..12f3acf95a5 --- /dev/null +++ b/htdocs/includes/mike42/escpos-php/CONTRIBUTORS.md @@ -0,0 +1,25 @@ +# escpos-php contributors + +This file contains a list of people who have made contributions of +code which appear in the public repository of escpos-php. + +Main repository: [mike42/escpos-php](https://github.com/mike42/escpos-php) ([online contributor list](https://github.com/mike42/escpos-php/graphs/contributors)) + +- [Michael Billington](https://github.com/mike42) +- [Alif Maulana El Fattah Nataly](https://github.com/alif25r) +- [Mareks Sudniks](https://github.com/marech) +- [matiasgaston](https://github.com/matiasgaston) +- [Mike Stivala](https://github.com/brndwgn) +- [Nicholas Long](https://github.com/longsview) +- [Evandro Araújo](https://github.com/evsar3) + +Via fork: [wdoyle/EpsonESCPOS-PHP](https://github.com/wdoyle/EpsonESCPOS-PHP): + +- [Warren Doyle](https://github.com/wdoyle) + +Via fork: [ronisaha/php-esc-pos](https://github.com/ronisaha/php-esc-pos): + +- [Roni Saha](https://github.com/ronisaha) +- [Gergely Radics](https://github.com/Gerifield) +- [vharo](https://github.com/vharo) + diff --git a/htdocs/includes/mike42/escpos-php/Escpos.php b/htdocs/includes/mike42/escpos-php/Escpos.php deleted file mode 100644 index b8568260738..00000000000 --- a/htdocs/includes/mike42/escpos-php/Escpos.php +++ /dev/null @@ -1,853 +0,0 @@ -, - * incorporating modifications by: - * - Roni Saha