mirror of
https://github.com/grocy/grocy.git
synced 2026-04-07 05:16: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)
|
// 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
|
// 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_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
|
//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_IP', '127.0.0.1'); // IP of the network printer
|
||||||
Setting('TPRINTER_PORT', 9100); // Port of printer, eg. 9100
|
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]"
|
* @return string[] Returns an array in the format "[amount] [name of product]"
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function GetShoppinglistInPrintableStrings($listId = 1): array
|
public function GetShoppinglistInPrintableStrings($listId = 1): array {
|
||||||
{
|
if (!$this->ShoppingListExists($listId)) {
|
||||||
if (!$this->ShoppingListExists($listId))
|
|
||||||
{
|
|
||||||
throw new \Exception('Shopping list does not exist');
|
throw new \Exception('Shopping list does not exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
$rowsShoppingListProducts = $this->getDatabase()->shopping_list()->where('shopping_list_id = :1', $listId)->fetchAll();
|
$rowsShoppingListProducts = $this->getDatabase()->uihelper_shopping_list()->where('shopping_list_id = :1', $listId)->fetchAll();
|
||||||
foreach ($rowsShoppingListProducts as $row)
|
foreach ($rowsShoppingListProducts as $row) {
|
||||||
{
|
if (GROCY_TPRINTER_PRINT_QUANTITY_NAME) {
|
||||||
$product = $this->getDatabase()->products()->where('id = :1', $row['product_id'])->fetch();
|
$quantityname = $row["qu_name"];
|
||||||
array_push($result, $row["amount"] . " " . $product["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;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user