Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion Lib/Tickets/BaseTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use FacturaScripts\Dinamic\Model\User;
use Mike42\Escpos\PrintConnectors\DummyPrintConnector;
use Mike42\Escpos\Printer;
use FacturaScripts\Dinamic\Model\Contacto;

/**
* @author Carlos Garcia Gomez <carlos@facturascripts.com>
Expand Down Expand Up @@ -544,7 +545,31 @@ protected static function setHeader(ModelClass $model, TicketPrinter $printer, s
// imprimimos la fecha y el cliente
if (in_array($model->modelClassName(), ['PresupuestoCliente', 'PedidoCliente', 'AlbaranCliente', 'FacturaCliente'])) {
static::$escpos->text(static::sanitize(static::$i18n->trans('date') . ': ' . $model->fecha . ' ' . $model->hora) . "\n");
static::$escpos->text(static::sanitize(static::$i18n->trans('customer') . ': ' . $model->nombrecliente) . "\n\n");
static::$escpos->text(static::sanitize(static::$i18n->trans('customer') . ': ' . $model->nombrecliente) . "\n");

// si se debe imprimir la dirección de envio
if ($printer->print_shipping_address) {
static::$escpos->text(static::sanitize(static::$i18n->trans('address') . ': '));
$shippingAddress = new Contacto();

if(empty($model->idcontactoenv) && empty($model->direccion)){
// si las dos están vacías entonces un -
static::$escpos->text(static::sanitize(' - '));

} else if ($shippingAddress->load($model->idcontactoenv)) {
// si existe el contacto de envio lo imprimimos
static::$escpos->text(static::sanitize($shippingAddress->direccion) . "\n");
static::$escpos->text(static::sanitize(
$shippingAddress->codpostal . ' (' . $shippingAddress->ciudad . '), ' . $shippingAddress->provincia
) . ", ");

}else{
// sino imprimimos la direccion de factura
static::$escpos->text(static::sanitize($model->direccion) . "\n");
}
}

static::$escpos->text("\n");
}

// añadimos la cabecera
Expand Down
4 changes: 4 additions & 0 deletions Model/TicketPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class TicketPrinter extends ModelClass
/** @var bool */
public $print_stored_logo;

/** @var bool */
public $print_shipping_address;

/** @var int */
public $title_font_size;

Expand All @@ -127,6 +130,7 @@ public function clear(): void
$this->print_lines_total = true;
$this->print_payment_methods = false;
$this->print_stored_logo = false;
$this->print_shipping_address = false;
$this->title_font_size = 2;
}

Expand Down
5 changes: 5 additions & 0 deletions Table/tickets_printers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
<type>boolean</type>
<default>false</default>
</column>
<column>
<name>print_shipping_address</name>
<type>boolean</type>
<default>false</default>
</column>
<column>
<name>print_invoice_receipts</name>
<type>boolean</type>
Expand Down
4 changes: 3 additions & 1 deletion Translation/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,7 @@
"unknown-device": "Unknown device",
"vendor-id": "Vendor ID",
"vendor-product-id-required-to-print": "Vendor ID and Product ID are required to print.",
"you-can-adjust-parameters": "You can adjust the parameters if necessary."
"you-can-adjust-parameters": "You can adjust the parameters if necessary.",
"last-activity": "Last activity",
"print-shipping-address": "Print shipping address"
}
4 changes: 3 additions & 1 deletion Translation/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,7 @@
"unknown-device": "Dispositivo desconocido",
"vendor-id": "Vendor ID",
"vendor-product-id-required-to-print": "El Vendor ID y el Product ID son necesarios para imprimir.",
"you-can-adjust-parameters": "Puede ajustar los parámetros si es necesario."
"you-can-adjust-parameters": "Puede ajustar los parámetros si es necesario.",
"last-activity": "Última actividad",
"print-shipping-address": "Imprimir dirección de envío"
}
3 changes: 3 additions & 0 deletions XMLView/EditTicketPrinter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<column name="print-logo" order="150">
<widget type="checkbox" fieldname="print_stored_logo"/>
</column>
<column name="print-shipping-address" order="160">
<widget type="checkbox" fieldname="print_shipping_address"/>
</column>
</group>
<group name="header" title="header" icon="fa-solid fa-arrows-up-to-line" numcolumns="6">
<column name="ticket-head" numcolumns="12" order="100">
Expand Down