-
-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for printing shoppinglist with thermal printer (#1273)
* Added escpos-php library * Added button to shoppinglist print menu * Added to translation * Added basic printing logic and API call * Working implementation for printing with the API * Added openapi json * Correctly parsing boolean parameter * Working button in UI * Change to grocy formatting * Add Date * Only show thermal print button when Feature Flag is set * Fixed API call and added error message parsing * Undo translation * Add flag to print quantities as well * Added printing notes * Added quantity conversion * Increse feed * Fixed that checkbox was undefined, as dialog was already closed * Added padding * Formatting * Added note about user permission * Fixed error when using notes instead of products * Review - Default FEATURE_FLAG_THERMAL_PRINTER to disabled - Added missing localization strings (and slightly adjusted one) * Fixed merge conflicts Co-authored-by: Bernd Bestel <bernd@berrnd.de>
- Loading branch information
Showing
14 changed files
with
410 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Grocy\Controllers; | ||
|
||
use Grocy\Controllers\Users\User; | ||
use Grocy\Services\StockService; | ||
|
||
class PrintApiController extends BaseApiController | ||
{ | ||
|
||
public function PrintShoppingListThermal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) { | ||
|
||
try | ||
{ | ||
User::checkPermission($request, User::PERMISSION_SHOPPINGLIST); | ||
|
||
$params = $request->getQueryParams(); | ||
|
||
$listId = 1; | ||
if (isset($params['list'])) { | ||
$listId = $params['list']; | ||
} | ||
|
||
$printHeader = true; | ||
if (isset($params['printHeader'])) { | ||
$printHeader = ($params['printHeader'] === "true"); | ||
} | ||
$items = $this->getStockService()->GetShoppinglistInPrintableStrings($listId); | ||
return $this->ApiResponse($response, $this->getPrintService()->printShoppingList($printHeader, $items)); | ||
} | ||
catch (\Exception $ex) | ||
{ | ||
return $this->GenericErrorResponse($response, $ex->getMessage()); | ||
} | ||
} | ||
|
||
public function __construct(\DI\Container $container) | ||
{ | ||
parent::__construct($container); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<?php | ||
|
||
namespace Grocy\Controllers; | ||
|
||
use Grocy\Controllers\Users\User; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.