improved cpev2

This commit is contained in:
Luca Haid
2025-07-22 10:38:42 +02:00
parent d8bff67391
commit e8be372560
3 changed files with 101 additions and 4 deletions

View File

@@ -0,0 +1,45 @@
<?php
$maxLength = max(mb_strlen($firstline ?? ''), mb_strlen($secondline ?? ''));
$fontSize = '12px';
if ($maxLength <= 15) $fontSize = '24px';
elseif ($maxLength <= 24) $fontSize = '18px';
elseif ($maxLength <= 50) $fontSize = '16px';
$this->setReturnValue(['filename' => "xyz." . time() . "pdf"]);
?>
<!DOCTYPE html>
<html>
<head>
<title>CPE-Etikett</title>
<meta charset="utf-8"/>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
font-family: "Open Sans", sans-serif, Verdana;
font-weight: bold;
text-align: center;
}
body {
display: flex;
align-items: center;
justify-content: center;
}
.content-block {
font-size: <?= $fontSize ?>;
}
</style>
</head>
<body>
<div class="content-block">
<div><?= $firstline ?></div>
<div><?= $secondline ?></div>
<div><?= $thirdline ?></div>
<div><?= $fourthline ?></div>
</div>
</body>
</html>

View File

@@ -482,9 +482,9 @@ class CpeprovisioningController extends mfBaseController
'show_snopp_button' => ($attrs['hostnetwork_order']->value ?? 0) == 1 && !str_contains($product->product->name, 'XDSL'),
'snopp_url' => 'https://snopp.breitband-steiermark.at/Termination/index?filter[status][]=connected&filter[address]=' . urlencode($order->owner->street),
'vlans' => [
'public' => ['tag' => $cpe->vlan_public ?? $vlanPublicDefault, 'checked' => $product->cpeprovisioning->vlan_public],
'nat' => ['tag' => $cpe->vlan_nat ?? $vlanNatDefault, 'checked' => $product->cpeprovisioning->vlan_nat],
'ipv6' => ['tag' => $cpe->vlan_ipv6 ?? $vlanIpv6Default, 'checked' => $product->cpeprovisioning->vlan_ipv6],
'public' => ['tag' => ($cpe ? $cpe->vlan_public : null) ?? $vlanPublicDefault, 'checked' => ($cpe ? $cpe->vlan_public : null)],
'nat' => ['tag' => ($cpe ? $cpe->vlan_nat : null) ?? $vlanNatDefault, 'checked' => ($cpe ? $cpe->vlan_nat : null)],
'ipv6' => ['tag' => ($cpe ? $cpe->vlan_ipv6 : null) ?? $vlanIpv6Default, 'checked' => ($cpe ? $cpe->vlan_ipv6 : null)],
],
'cpe_id' => $cpe->id ?? null,
'cpe_data' => $this->fixCpeData($cpe->data ?? null),
@@ -520,6 +520,7 @@ class CpeprovisioningController extends mfBaseController
// Pass API URLs and initial data to the frontend
"CPE_PROV_API_GET_URL" => $this->getUrl("Cpeprovisioning", "apiGet"),
"CPE_PROV_API_SAVE_URL" => $this->getUrl("Cpeprovisioning", "apiSave"),
"CPE_PROV_PRINT_PDF_URL" => $this->getUrl("Cpeprovisioning", "printPDF"),
"ORDER_URL" => $this->getUrl("Order"),
"NETWORKS" => NetworkModel::getAll(),
"ROUTER_OPTIONS" => [
@@ -540,6 +541,13 @@ class CpeprovisioningController extends mfBaseController
['value' => 'Mikrotik RB3011', 'text' => 'Mikrotik RB3011 (Inet, IPTV)'],
// CMTS Routers
['value' => 'FritzBox 6490 Cable', 'text' => 'FritzBox 6490 Cable (Inet, Phone, IPTV)'],
],
"ROUTER_SHIPPING_DATA" => [
"TP-Link Archer C80" => ["weight" => 1, "length" => 35, "width" => 24, "height" => 8],
"FritzBox 4040" => ["weight" => 1, "length" => 30, "width" => 24, "height" => 7],
"FritzBox 7530" => ["weight" => 1, "length" => 26, "width" => 19, "height" => 7],
"FritzBox 7590" => ["weight" => 1, "length" => 30, "width" => 24, "height" => 7],
"FritzBox 6490 Cable" => ["weight" => 1, "length" => 30, "width" => 26, "height" => 8]
]
]
);
@@ -552,5 +560,28 @@ class CpeprovisioningController extends mfBaseController
return $data;
}
protected function printPDFAction() {
$order_id = $this->request->order_id;
$order = OrderModel::getOne($order_id);
if (!$order) self::sendError("Order not found", 404);
$pdf_vars = [
'firstline' => $order->owner->getCompanyOrName(),
'secondline' => $order->owner->street,
'thirdline' => $order->owner->zip . " " . $order->owner->city,
'fourthline' => $order->owner->customer_number
];
$pdf = new PdfForm("Cpeprovisioning/PDF_MAIN", $pdf_vars);
$wkhtmltopdfArgs = "--page-height 32.5mm --page-width 57.5mm --margin-top 1mm --margin-bottom 0 --margin-left 0 --margin-right 0 --disable-smart-shrinking --encoding utf-8";
$filename = $pdf->render($wkhtmltopdfArgs);
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
readfile($filename);
die();
}
}

View File

@@ -51,6 +51,9 @@ Vue.component('Cpeprovisioning', {
<a target="_blank" :href="window.TT_CONFIG.ORDER_URL + '/Index/?id=' + row.order_id + '&addJournal=1'" class="mr-2">
<i class="fas fa-scroll"></i>
</a>
<a target="_blank" :href="window.TT_CONFIG.CPE_PROV_PRINT_PDF_URL + '?order_id=' + row.order_id" class="mr-2">
<i class="fas fa-print"></i>
</a>
<template v-if="row.vot || row.hw || row.voip || row.note">
<tt-tooltip v-if="row.vot" text="Vorortinstallation" position="top">
<i class="fas fa-tools text-purple mr-2"></i>
@@ -94,7 +97,7 @@ Vue.component('Cpeprovisioning', {
<tt-input label="ONT SN" v-model="row.ont_sn" @input="markDirty(row, 6)" sm/>
<h5 class="section-title">Versand</h5>
<tt-checkbox label="Versandauftrag" v-model="row.cpe_data.shipping" @input="markDirty(row, 7)" sm/>
<tt-checkbox label="Versandauftrag" v-model="row.cpe_data.shipping" @input="markDirty(row, 7);checkShipping(row)" sm/>
<tt-input label="Gewicht (kg)" v-model="row.cpe_data.ship_weight" @input="markDirty(row, 8)" sm type="number" :disabled="!row.cpe_data.shipping"/>
<tt-input label="Länge (cm)" v-model="row.cpe_data.ship_length" @input="markDirty(row, 9)" sm type="number" :disabled="!row.cpe_data.shipping"/>
<tt-input label="Breite (cm)" v-model="row.cpe_data.ship_width" @input="markDirty(row, 10)" sm type="number" :disabled="!row.cpe_data.shipping"/>
@@ -180,6 +183,24 @@ Vue.component('Cpeprovisioning', {
console.log(`Marking row as dirty for field ${field}`);
this.$set(row, 'isDirty', true);
},
async checkShipping (row) {
await this.$nextTick();
if (row.cpe_data.shipping && row.cpe_data.routertype) {
const shippingData = this.window.TT_CONFIG.ROUTER_SHIPPING_DATA[row.cpe_data.routertype];
if (shippingData) {
if (!row.cpe_data.ship_weight) row.cpe_data.ship_weight = shippingData.weight;
if (!row.cpe_data.ship_length) row.cpe_data.ship_length = shippingData.length;
if (!row.cpe_data.ship_width) row.cpe_data.ship_width = shippingData.width;
if (!row.cpe_data.ship_height) row.cpe_data.ship_height = shippingData.height;
}
} else {
row.cpe_data.ship_weight = '';
row.cpe_data.ship_length = '';
row.cpe_data.ship_width = '';
row.cpe_data.ship_height = '';
}
},
async saveCpe(row) {
this.$set(row, 'isSaving', true);