Thanks again to Kharg who also gave me tips on how I can read out more data and use it further.
Code:
<?php
namespace Espo\Custom\EntryPoints;
use Espo\Core\Exceptions\NotFound;
class ConfirmOrder extends \Espo\Core\EntryPoints\Base
{
public static $authRequired = false; // This requires the user to be authenticated.
public function run()
{
$entityManager = $this->getContainer()->get('entityManager');
$id = $_GET['id'] ?? null;
if (!$id) {
$this->displayMessage('fehlende Bestell-ID.');
exit;
}
$shoppingList = $entityManager->getEntity('Einkaufsliste', $id);
if (!$shoppingList) {
$this->displayMessage('Bestellung nicht gefunden.');
exit;
}
$status = $shoppingList->get('status');
$eDatum = $shoppingList->get('einkaufsdatum');
$lDatum = $shoppingList->get('lieferdatum');
$lieferant = $shoppingList->get('lieferantenName');
$aktualisierung = $shoppingList->get('modifiedAt');
// Format the dates
if ($eDatum) {
$eDatumObj = new \DateTime($eDatum);
$eDatum = $eDatumObj->format('d.m.Y');
}
if ($lDatum) {
$lDatumObj = new \DateTime($lDatum);
$lDatum = $lDatumObj->format('d.m.Y');
}
if ($aktualisierung) {
$aktualisierungObj = new \DateTime($aktualisierung, new \DateTimeZone('UTC'));
$aktualisierungObj->setTimezone(new \DateTimeZone('Europe/Berlin'));
$aktualisierung = $aktualisierungObj->format('d.m.Y H:i:s');
}
// Set the message
$message = "";
if ($status === 'Bestellt') {
$shoppingList->set('status', 'Bestätigt');
$entityManager->saveEntity($shoppingList);
$message = "<i class='bi bi-check2-circle' style='font-size:54px;color:green'></i><br><font color='green'>Deine Bestellung wurde bestätigt.</font>";
} elseif ($status === 'Bestätigt') {
$message = "<i class='bi bi-info-circle-fill' style='font-size:54px;color:red;'></i><br><font color='red'>Diese Bestellung wurde bereits bestätigt.</font>";
} elseif ($status === 'Geliefert') {
$message = "<i class='bi bi-truck' style='font-size:54px;color:blue'></i><br><font color='blue'>Diese Bestellung wurde bereits geliefert.</font>";
} elseif ($status === 'offen') {
$message = "<i class='bi bi-bag-x' style='font-size:54px;color:red;'></i><br><font color='red'>Diese Bestellung wurde noch nicht freigegeben!</font>";
}else {
$message = "<i class='bi bi-bag-x' style='font-size:54px;color:red;'></i><br><font color='red'>Bestellung wurde nicht gefunden!</font>";
}
$this->displayMessage($status,$message, $eDatum, $lDatum, $lieferant, $aktualisierung);
}
private function displayMessage($status,$message, $eDatum, $lDatum, $lieferant = '', $aktualisierung)
{
echo <<<HTML
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>{$lieferant} - Bestellbestätigung</title>
<link href="https://icons.getbootstrap.com/assets/font/bootstrap-icons.min.css" rel="stylesheet">
<link rel="stylesheet" href="client/css/espo/espo.css">
<link rel="stylesheet" href="client/modules/KurtTheme/css/espo/modern.css?r=1696956647" id='main-stylesheet'>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.min.js" integrity="sha384-BBtl+eGJRgqQAUMxJ7pMwbEyER4l1g+O15P+16Ep7Q9Q+zqX6gSbd85u4mG4QzX+" crossorigin="anonymous"></script>
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
</head>
<body background-color="#A4876A">
<style>
.box {
position: relative;
width: 600px;
height: 600px;
background: #fff;
box-shadow: 0 0 15px rgba(0,0,0,.1);
}
/* common */
.ribbon {
width: 150px;
height: 150px;
overflow: hidden;
position: absolute;
}
.ribbon::before,
.ribbon::after {
position: absolute;
z-index: -1;
content: '';
display: block;
border: 5px solid #A4876A;
}
.ribbon span {
position: absolute;
display: block;
width: 225px;
padding: 15px 0;
background-color: #A4876A;
box-shadow: 0 5px 10px rgba(0,0,0,.1);
color: #fff;
font: 700 18px/1 'Lato', sans-serif;
text-shadow: 0 1px 1px rgba(0,0,0,.2);
text-transform: uppercase;
text-align: center;
}
/* top right*/
.ribbon-top-right {
top: -10px;
right: -10px;
}
.ribbon-top-right::before,
.ribbon-top-right::after {
border-top-color: transparent;
border-right-color: transparent;
}
.ribbon-top-right::before {
top: 0;
left: 0;
}
.ribbon-top-right::after {
bottom: 0;
right: 0;
}
.ribbon-top-right span {
left: -25px;
top: 30px;
transform: rotate(45deg);
}
.panel {
box-shadow: none !important;
}
</style>
<div class="container box">
<div class="ribbon ribbon-top-right"><span>{$status}</span></div>
<div class="panel panel-default block-center-md margin-top-2x">
<div class="panel-body">
<center><img src="Path to the image file" width="50%"></center>
<h1 class="text-3em text-soft margin-bottom-4x" align="center" style="text-shadow: #FC0 1px 0 10px;">Bestell-Status</h1>
<p class="text-large" align="center">{$message}</p>
<br>
<table align="center" border="0" width="75%" style="box-shadow: 0px 0px 12px 7px rgba(164, 135, 106, 1);padding:5px;">
<tr>
<td colspan="3" align="center"><h4><u>Bestelldetails</u></h4></td>
</tr>
<tr>
<td width="50%" align="right"><b>Bestelldatum:</b></td>
<td> </td>
<td>{$eDatum}</td>
</tr>
<tr>
<td align="right"><b>Lieferdatum:</b></td>
<td> </td>
<td>{$lDatum}</td>
</tr>
<tr>
<td align="right"><b>Lieferant:</b></td>
<td> </td>
<td>{$lieferant}</td>
</tr>
<tr>
<td align="right"><b>letzte Aktualiserung:</b></td>
<td> </td>
<td>{$aktualisierung}</td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>

Leave a comment: