From 5d7d0a4de7c24abe1c317b4bcf56db3c8d25b47e Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Mon, 23 Mar 2026 11:18:36 +0100 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20desactivado=20el=20abrir=20caj?= =?UTF-8?q?=C3=B3n=20por=20defecto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lib/Tickets/BaseTicket.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/Tickets/BaseTicket.php b/Lib/Tickets/BaseTicket.php index fbfc2b2..c69377c 100644 --- a/Lib/Tickets/BaseTicket.php +++ b/Lib/Tickets/BaseTicket.php @@ -38,7 +38,7 @@ abstract class BaseTicket /** @var array */ protected static $lines; - private static $openDrawer = true; + private static $openDrawer = false; abstract public static function print(ModelClass $model, TicketPrinter $printer, User $user, ?Agente $agent = null): bool; @@ -47,7 +47,13 @@ public static function setLines(?array $lines = null): void static::$lines = $lines; } - protected static function setOpenDrawer(bool $openDrawer): void + /** + * Esta función tiene que ser llamada antes que print() o getBody() para que tenga efecto. + * + * Esto es debido a que modifica la variable $openDrawer que si está activada injecta el código de abrir + * cajón en el body. + */ + protected static function setOpenDrawer(bool $openDrawer = true): void { static::$openDrawer = $openDrawer; } From 87b5cbf72794b1376d2fcc8a5c35845fd5c300ca Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Tue, 24 Mar 2026 08:07:41 +0100 Subject: [PATCH 2/2] feat: open drawler function --- Model/TicketPrinter.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Model/TicketPrinter.php b/Model/TicketPrinter.php index edf2ab9..50fb013 100644 --- a/Model/TicketPrinter.php +++ b/Model/TicketPrinter.php @@ -5,6 +5,7 @@ namespace FacturaScripts\Plugins\Tickets\Model; +use FacturaScripts\Core\Session; use FacturaScripts\Core\Template\ModelClass; use FacturaScripts\Core\Template\ModelTrait; use FacturaScripts\Core\Tools; @@ -165,6 +166,28 @@ public function getDashLine(): string return $line; } + /** + * Abre la caja de una impresora + * + * Esto lo consigue creando un ticket vacío que solo contiene la instrucción de abrir cajón + * + * @return true si se ha enviado la instrucción de abrir cajón y false en cambio. + */ + public function openDrawer(): bool + { + $ticket = new Ticket(); + $ticket->idprinter = $this->id; + $ticket->title = Tools::trans('open-drawer'); + $ticket->body = $this->getCommandStr('open'); + + $user = Session::user(); + if ($user) { + $ticket->nick = $user->nick; + } + + return $ticket->save(); + } + public function install(): string { // dependencias