You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using librebooking 4.0.0 for planning technician in our workshop.
I'm working on a printing page so my technicians can print out their reservation on a neat a4 with the availability to mark down their work.
But I can't get it work, can somebody check my file if they can see the error, all I get is a white page... help is appreciated:)
The printing button is already in place and is pointing to this file.
I have located this file in /planning2/custom/print/print_workbon.php where planning2 is my base folder for librebooking.
Thanks in advance, Ben
*/<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Instance ophalen
$cmd = new \SqlCommand("
SELECT reservation_instance_id, reservation_id, series_id, start_date, end_date
FROM reservation_instances
WHERE reference_number = :ref
");
$cmd->AddParameter(new \Parameter(':ref', $ref));
$instance = $db->Query($cmd)->GetRow();
if (!$instance) die('Geen reservering gevonden');
$seriesId = (int)$instance['series_id'];
// Series ophalen
$cmd = new \SqlCommand("
SELECT series_id, title, description, owner_id
FROM reservation_series
WHERE series_id = :sid
");
$cmd->AddParameter(new \Parameter(':sid', $seriesId));
$series = $db->Query($cmd)->GetRow();
if (!$series) die('Series niet gevonden');
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We're using librebooking 4.0.0 for planning technician in our workshop.
I'm working on a printing page so my technicians can print out their reservation on a neat a4 with the availability to mark down their work.
But I can't get it work, can somebody check my file if they can see the error, all I get is a white page... help is appreciated:)
The printing button is already in place and is pointing to this file.
I have located this file in /planning2/custom/print/print_workbon.php where planning2 is my base folder for librebooking.
Thanks in advance, Ben
*/<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
define('ROOT_DIR', dirname(DIR, 2) . '/');
// Core includes
require_once ROOT_DIR . 'lib/Common/namespace.php';
require_once ROOT_DIR . 'lib/Server/namespace.php';
require_once ROOT_DIR . 'lib/Config/namespace.php';
require_once ROOT_DIR . 'config/config.php';
// Database connectie
$db = \ServiceLocator::GetDatabase();
if (!$db) die('Database fout');
// res_id ophalen
$ref = $_GET['res_id'] ?? '';
if ($ref === '') die('Geen res_id opgegeven');
// Instance ophalen
$cmd = new \SqlCommand("
SELECT reservation_instance_id, reservation_id, series_id, start_date, end_date
FROM reservation_instances
WHERE reference_number = :ref
");
$cmd->AddParameter(new \Parameter(':ref', $ref));
$instance = $db->Query($cmd)->GetRow();
if (!$instance) die('Geen reservering gevonden');
$seriesId = (int)$instance['series_id'];
// Series ophalen
$cmd = new \SqlCommand("
SELECT series_id, title, description, owner_id
FROM reservation_series
WHERE series_id = :sid
");
$cmd->AddParameter(new \Parameter(':sid', $seriesId));
$series = $db->Query($cmd)->GetRow();
if (!$series) die('Series niet gevonden');
// Monteur ophalen
$cmd = new \SqlCommand("
SELECT fname, lname
FROM users
WHERE user_id = :uid
");
$cmd->AddParameter(new \Parameter(':uid', $series['owner_id']));
$user = $db->Query($cmd)->GetRow();
$monteurNaam = trim(($user['fname'] ?? '') . ' ' . ($user['lname'] ?? ''));
// Datum/tijd
$startTs = strtotime($instance['start_date']);
$endTs = strtotime($instance['end_date']);
$datum = date('d-m-Y', $startTs);
$tijdVan = date('H:i', $startTs);
$tijdTot = date('H:i', $endTs);
// Werkbonnummer + QR-code
$workorderNumber = 'WB-' . ($instance['reservation_id'] ?? $instance['reservation_instance_id']);
$plannerUrl = 'https://team.******.nl/planning2/Web/reservation.php?rn=' . urlencode($ref);
$qrUrl = 'https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=' . urlencode($plannerUrl);
// Custom attributes ophalen
$labelMap = [];
$cmd = new \SqlCommand("SELECT custom_attribute_id, display_label FROM custom_attributes");
$stmt = $db->Query($cmd);
while ($row = $stmt->GetRow()) {
$labelMap[(int)$row['custom_attribute_id']] = $row['display_label'];
}
$valueMap = [];
$cmd = new \SqlCommand("SELECT custom_attribute_id, attribute_value FROM custom_attribute_values WHERE entity_id = :sid");
$cmd->AddParameter(new \Parameter(':sid', $seriesId));
$stmt = $db->Query($cmd);
while ($row = $stmt->GetRow()) {
$valueMap[(int)$row['custom_attribute_id']] = $row['attribute_value'];
}
$attributes = [];
foreach ($valueMap as $attrId => $value) {
if (isset($labelMap[$attrId])) {
$attributes[$labelMap[$attrId]] = $value;
}
}
// Velden invullen
$klantNaam = $attributes['Klant'] ?? '';
$adres = $attributes['Adres + Huisnr.'] ?? '';
$postcode = $attributes['Postcode'] ?? '';
$plaats = $attributes['Plaats'] ?? '';
$tel1 = $attributes['Tel. 1'] ?? '';
$tel2 = $attributes['Tel. 2'] ?? '';
$email = $attributes['Emailadres'] ?? '';
$soortApparaat = $attributes['Soort Apparaat'] ?? '';
$klachtOmschrijving = $attributes['Klacht of Omschrijving'] ?? '';
$merk = $attributes['Merk'] ?? '';
$typeNummer = $attributes['Typenr./model'] ?? '';
$prodNummer = $attributes['Prod.no/PNC/Service nr./Art.no/FD'] ?? '';
$aankoopDatum = $attributes['Aankoopdatum'] ?? '';
$serieNummer = $attributes['Serienummer/Z-nr'] ?? '';
$certificaatNr = $attributes['Certificaat.no'] ?? '';
$soortAfspraak = $attributes['Soort Afspraak'] ?? '';
$specialeSoorten = ['Reparatie WGS','Reparatie klant','Reparatie GK','Reparatie Gecertificeerd'];
$toonVolledigFormulier = in_array($soortAfspraak, $specialeSoorten, true);
// Onderdelen/kosten
$kostenMatrix = [
'Reparatie WGS' => [['Voorrij- en onderzoekskosten', '€ 55,00']],
'Reparatie klant' => [['Onderzoekskosten', '€ 35,00']],
'Reparatie GK' => [['Voorrijkosten', '€ 35,00'], ['Onderzoekskosten', '€ 35,00']],
'Reparatie Gecertificeerd' => [['Reparatie onder garantie naar voorwaarden', '']],
];
$onderdelenRegels = $kostenMatrix[$soortAfspraak] ?? [];
while (count($onderdelenRegels) < 5) $onderdelenRegels[] = ['', ''];
?>
<title>Werkbon </title> <style> @page { size: A4; margin: 0; } body { font-family: Arial,sans-serif; font-size: 11pt; margin:4cm 1.5cm 4cm 1.5cm; } h1 { font-size: 20pt; margin:0 0 0.5cm 0; } .header { display:flex; justify-content:space-between; align-items:flex-start; height:4cm; } .qr { width:4cm; height:4cm; } .header-right { text-align:right; font-size:10pt; line-height:1.4; } .section { margin-bottom:0.9cm; } .section-title { font-weight:bold; font-size:13pt; margin-bottom:0.25cm; border-bottom:1px solid #000; padding-bottom:0.1cm; } table.details { width:100%; border-collapse:collapse; } table.details td { padding:3px 0; vertical-align:top; } .parts-table { width:100%; border-collapse:collapse; margin-top:0.25cm; } .parts-table th, .parts-table td { border:1px solid #000; padding:4px; vertical-align:top; } .signature-box { border-bottom:1px solid #000; height:1.2cm; width:8cm; } .write-box { border:1px solid #000; height:3.5cm; margin-bottom:0.4cm; } .footer-note { margin-top:1cm; font-size:8pt; color:#333; } </style>Werkbonnummer:
Monteur:
Werkbon
Werkzaamheden / bevindingen:
Opmerkingen:
Beta Was this translation helpful? Give feedback.
All reactions