mirror of
https://github.com/grocy/grocy.git
synced 2026-04-12 07:16:15 +02:00
Only show thermal print button when Feature Flag is set
This commit is contained in:
parent
c58620f898
commit
8e0b995808
|
|
@ -428,13 +428,7 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
||||||
</label> \
|
</label> \
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
bootbox.dialog({
|
var printButtons = {
|
||||||
message: dialogHtml,
|
|
||||||
size: 'medium',
|
|
||||||
backdrop: true,
|
|
||||||
closeButton: false,
|
|
||||||
className: "d-print-none",
|
|
||||||
buttons: {
|
|
||||||
cancel: {
|
cancel: {
|
||||||
label: __t('Cancel'),
|
label: __t('Cancel'),
|
||||||
className: 'btn-secondary',
|
className: 'btn-secondary',
|
||||||
|
|
@ -494,6 +488,19 @@ $(document).on("click", "#print-shopping-list-button", function(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Grocy.FeatureFlags["GROCY_FEATURE_FLAG_THERMAL_PRINTER"])
|
||||||
|
{
|
||||||
|
delete printButtons['printtp'];
|
||||||
|
}
|
||||||
|
|
||||||
|
bootbox.dialog({
|
||||||
|
message: dialogHtml,
|
||||||
|
size: 'medium',
|
||||||
|
backdrop: true,
|
||||||
|
closeButton: false,
|
||||||
|
className: "d-print-none",
|
||||||
|
buttons: printButtons
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ class PrintService extends BaseService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialises the printer
|
* Initialises the printer
|
||||||
* @return Printer handle
|
* @return Printer Printer handle
|
||||||
* @throws Exception if unable to connect to printer
|
* @throws Exception If unable to connect to printer, an exception is thrown
|
||||||
*/
|
*/
|
||||||
private static function getPrinterHandle()
|
private static function getPrinterHandle()
|
||||||
{
|
{
|
||||||
|
|
@ -29,8 +29,8 @@ class PrintService extends BaseService
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints a grocy logo
|
* Prints the grocy logo and date
|
||||||
* @param $printer
|
* @param Printer $printer Printer handle
|
||||||
*/
|
*/
|
||||||
private static function printHeader(Printer $printer)
|
private static function printHeader(Printer $printer)
|
||||||
{
|
{
|
||||||
|
|
@ -48,17 +48,16 @@ class PrintService extends BaseService
|
||||||
$printer->feed(2);
|
$printer->feed(2);
|
||||||
$printer->text($dateFormatted);
|
$printer->text($dateFormatted);
|
||||||
$printer->selectPrintMode();
|
$printer->selectPrintMode();
|
||||||
$printer->feed(3);
|
$printer->feed(2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $printHeader Printing of Grocy logo
|
* @param bool $printHeader Printing of Grocy logo
|
||||||
* @param string[] $items Items to print
|
* @param string[] $lines Items to print
|
||||||
* @return string[]
|
* @return string[] Returns array with result OK if no exception
|
||||||
* @throws Exception
|
* @throws Exception If unable to print, an exception is thrown
|
||||||
*/
|
*/
|
||||||
public function printShoppingList(bool $printHeader, array $items): array
|
public function printShoppingList(bool $printHeader, array $lines): array
|
||||||
{
|
{
|
||||||
$printer = self::getPrinterHandle();
|
$printer = self::getPrinterHandle();
|
||||||
if ($printer === false)
|
if ($printer === false)
|
||||||
|
|
@ -69,9 +68,9 @@ class PrintService extends BaseService
|
||||||
self::printHeader($printer);
|
self::printHeader($printer);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($items as $item)
|
foreach ($lines as $line)
|
||||||
{
|
{
|
||||||
$printer->text($item);
|
$printer->text($line);
|
||||||
$printer->feed();
|
$printer->feed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user