mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
Add flag to print quantities as well
This commit is contained in:
parent
039bdb58fd
commit
f007b92911
|
|
@ -98,6 +98,7 @@ Setting('DEFAULT_PERMISSIONS', ['ADMIN']);
|
|||
// When using a thermal printer (thermal printers are receipt printers, not regular printers)
|
||||
// The printer must support the ESC/POS protocol, see https://github.com/mike42/escpos-php
|
||||
Setting('TPRINTER_IS_NETWORK_PRINTER', false); // Set to true if it is a network printer
|
||||
Setting('TPRINTER_PRINT_QUANTITY_NAME', true); // Set to true if you want to print the quantity name as well
|
||||
//Configuration below for network printers. If you are using a USB/serial printer, skip to next section
|
||||
Setting('TPRINTER_IP', '127.0.0.1'); // IP of the network printer
|
||||
Setting('TPRINTER_PORT', 9100); // Port of printer, eg. 9100
|
||||
|
|
|
|||
|
|
@ -941,19 +941,23 @@ class StockService extends BaseService
|
|||
* @return string[] Returns an array in the format "[amount] [name of product]"
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function GetShoppinglistInPrintableStrings($listId = 1): array
|
||||
{
|
||||
if (!$this->ShoppingListExists($listId))
|
||||
{
|
||||
public function GetShoppinglistInPrintableStrings($listId = 1): array {
|
||||
if (!$this->ShoppingListExists($listId)) {
|
||||
throw new \Exception('Shopping list does not exist');
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$rowsShoppingListProducts = $this->getDatabase()->shopping_list()->where('shopping_list_id = :1', $listId)->fetchAll();
|
||||
foreach ($rowsShoppingListProducts as $row)
|
||||
{
|
||||
$product = $this->getDatabase()->products()->where('id = :1', $row['product_id'])->fetch();
|
||||
array_push($result, $row["amount"] . " " . $product["name"]);
|
||||
$rowsShoppingListProducts = $this->getDatabase()->uihelper_shopping_list()->where('shopping_list_id = :1', $listId)->fetchAll();
|
||||
foreach ($rowsShoppingListProducts as $row) {
|
||||
if (GROCY_TPRINTER_PRINT_QUANTITY_NAME) {
|
||||
$quantityname = $row["qu_name"];
|
||||
if ($row["amount"] > 1) {
|
||||
$quantityname = $row["qu_name_plural"];
|
||||
}
|
||||
array_push($result, $row["amount"] . ' ' . $quantityname . ' ' . $row["product_name"]);
|
||||
} else {
|
||||
array_push($result, $row["amount"] . ' ' . $row["product_name"]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user