mirror of
https://github.com/grocy/grocy.git
synced 2025-10-14 09:11:11 +00:00
Squashed commit
Always execute migration 9999 (can be used to fix things manually) Optimized meal plan navigation / date range filtering Prepared next release Pulled translations from Transifex Various code optimizations
This commit is contained in:
@@ -10,6 +10,39 @@ use Mike42\Escpos\Printer;
|
||||
|
||||
class PrintService extends BaseService
|
||||
{
|
||||
/**
|
||||
* @param bool $printHeader Printing of Grocy logo
|
||||
* @param string[] $lines Items to print
|
||||
* @return string[] Returns array with result OK if no exception
|
||||
* @throws Exception If unable to print, an exception is thrown
|
||||
*/
|
||||
public function printShoppingList(bool $printHeader, array $lines): array
|
||||
{
|
||||
$printer = self::getPrinterHandle();
|
||||
if ($printer === false)
|
||||
{
|
||||
throw new Exception('Unable to connect to printer');
|
||||
}
|
||||
|
||||
if ($printHeader)
|
||||
{
|
||||
self::printHeader($printer);
|
||||
}
|
||||
|
||||
foreach ($lines as $line)
|
||||
{
|
||||
$printer->text($line);
|
||||
$printer->feed();
|
||||
}
|
||||
|
||||
$printer->feed(3);
|
||||
$printer->cut();
|
||||
$printer->close();
|
||||
return [
|
||||
'result' => 'OK'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the printer
|
||||
* @return Printer Printer handle
|
||||
@@ -50,37 +83,4 @@ class PrintService extends BaseService
|
||||
$printer->selectPrintMode();
|
||||
$printer->feed(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $printHeader Printing of Grocy logo
|
||||
* @param string[] $lines Items to print
|
||||
* @return string[] Returns array with result OK if no exception
|
||||
* @throws Exception If unable to print, an exception is thrown
|
||||
*/
|
||||
public function printShoppingList(bool $printHeader, array $lines): array
|
||||
{
|
||||
$printer = self::getPrinterHandle();
|
||||
if ($printer === false)
|
||||
{
|
||||
throw new Exception('Unable to connect to printer');
|
||||
}
|
||||
|
||||
if ($printHeader)
|
||||
{
|
||||
self::printHeader($printer);
|
||||
}
|
||||
|
||||
foreach ($lines as $line)
|
||||
{
|
||||
$printer->text($line);
|
||||
$printer->feed();
|
||||
}
|
||||
|
||||
$printer->feed(3);
|
||||
$printer->cut();
|
||||
$printer->close();
|
||||
return [
|
||||
'result' => 'OK'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user