stuff
This commit is contained in:
@ -12,6 +12,7 @@ export default class extends Controller {
|
||||
"ticketType",
|
||||
"foodType",
|
||||
"note",
|
||||
"donation"
|
||||
];
|
||||
|
||||
stripe;
|
||||
@ -191,6 +192,7 @@ export default class extends Controller {
|
||||
lastname: this.lastnameTarget.value.trim(),
|
||||
email: this.emailTarget.value.trim(),
|
||||
phone: this.phoneTarget.value.trim(),
|
||||
donation: Number(this.donationTarget.value) ?? null
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4,19 +4,16 @@ namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Payment;
|
||||
use App\Enum\TicketData;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use App\Form\TicketType;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\CollectionField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TelephoneField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
use App\Form\TicketType;
|
||||
|
||||
class CustomerCrudController extends AbstractCrudController
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
|
||||
|
||||
class PaymentCrudController extends AbstractCrudController
|
||||
{
|
||||
@ -23,6 +24,8 @@ class PaymentCrudController extends AbstractCrudController
|
||||
->setCrudController(CustomerCrudController::class)
|
||||
->formatValue(fn($value, $payment) => $payment->getCustomer()->getEmail());
|
||||
yield BooleanField::new('completed', 'Bezahlt')->renderAsSwitch(false);
|
||||
yield NumberField::new('donation', 'Spende')
|
||||
->formatValue(fn (?float $donation) => ($donation??'0').'€');
|
||||
}
|
||||
|
||||
public function configureActions(Actions $actions): Actions
|
||||
|
@ -9,6 +9,7 @@ class PersonalData
|
||||
public string $lastname,
|
||||
public string $email,
|
||||
public string $phone,
|
||||
public ?float $donation,
|
||||
) {
|
||||
}
|
||||
}
|
@ -24,6 +24,9 @@ class Payment
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Customer $customer = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?float $donation = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@ -71,4 +74,16 @@ class Payment
|
||||
return $total + TicketData::TICKET_DATA[$ticket->getType()]['price'];
|
||||
}, 0);
|
||||
}
|
||||
|
||||
public function getDonation(): ?float
|
||||
{
|
||||
return $this->donation;
|
||||
}
|
||||
|
||||
public function setDonation(?float $donation): static
|
||||
{
|
||||
$this->donation = $donation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class TicketService
|
||||
|
||||
public function handleTicketData(TicketFormData $data): Session
|
||||
{
|
||||
$session = $this->createSession($this->getLineItems($data->tickets), $data->personal->email);
|
||||
$session = $this->createSession($this->getLineItems($data->tickets, $data->personal->donation), $data->personal->email);
|
||||
|
||||
$this->saveTicketData($data, $session->id);
|
||||
|
||||
@ -57,16 +57,30 @@ class TicketService
|
||||
$payment = (new Payment())
|
||||
->setSessionId($sessionId)
|
||||
->setCompleted(false)
|
||||
->setCustomer($this->createEntityFromData($data));
|
||||
->setCustomer($this->createEntityFromData($data))
|
||||
->setDonation($data->personal->donation);
|
||||
|
||||
$this->em->persist($payment);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
private function getLineItems(array $tickets): array
|
||||
private function getLineItems(array $tickets, float $donation = null): array
|
||||
{
|
||||
$lineItems = [];
|
||||
|
||||
if ($donation) {
|
||||
$lineItems[] = [
|
||||
'price_data' => [
|
||||
'currency' => 'eur',
|
||||
'product_data' => [
|
||||
'name' => 'Spende',
|
||||
],
|
||||
'unit_amount' => $donation * 100,
|
||||
],
|
||||
'quantity' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($tickets as $ticket) {
|
||||
$ticketData = TicketEnum::TICKET_DATA[$ticket->ticketType];
|
||||
$lineItems[] = [
|
||||
|
@ -12,16 +12,7 @@
|
||||
<tr>
|
||||
<td>
|
||||
<font color="#1f2937" size="5" face="Arial, Helvetica, sans-serif">Contact Details</font>
|
||||
|
||||
<table cellpadding="15" cellspacing="0" border="1" width="100%" bgcolor="#f9fafb" bordercolor="#e5e7eb" style="border-collapse: collapse; margin-top: 20px;">
|
||||
<tr>
|
||||
<td>
|
||||
<font color="#6b7280" size="2" face="Arial, Helvetica, sans-serif">Email</font><br>
|
||||
<font color="#1f2937" size="3" face="Arial, Helvetica, sans-serif">{{ data.email }}</font>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{% if data.phone %}
|
||||
<table cellpadding="15" cellspacing="0" border="1" width="100%" bgcolor="#f9fafb" bordercolor="#e5e7eb" style="border-collapse: collapse; margin-top: 20px;">
|
||||
<tr>
|
||||
<td>
|
||||
@ -30,7 +21,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{% endif %}
|
||||
<table cellpadding="15" cellspacing="0" border="1" width="100%" bgcolor="#f9fafb" bordercolor="#e5e7eb" style="border-collapse: collapse; margin-top: 20px;">
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -31,7 +31,7 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 w-full gap-3 mb-5">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-3 w-full gap-3 mb-5">
|
||||
<div class="bg-white/80 backdrop-blur-md shadow-xl rounded-2xl sm:rounded-3xl p-5 mb-3 sm:mb-12 transform transition-all duration-300 border border-gray-100">
|
||||
<h2 class="text-xl text-center font-semibold mb-4 bg-clip-text text-transparent bg-gradient-to-r from-red-500 to-orange-500">Datum & Uhrzeit</h2>
|
||||
<div class="space-y-3">
|
||||
@ -75,6 +75,39 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white/80 backdrop-blur-md shadow-xl rounded-2xl sm:rounded-3xl p-5 mb-3 sm:mb-12 transform transition-all duration-300 border border-gray-100">
|
||||
<h2 class="text-xl text-center font-semibold mb-4 bg-clip-text text-transparent bg-gradient-to-r from-red-500 to-orange-500">Ticket Preise</h2>
|
||||
<div class="space-y-3">
|
||||
<div class="flex items-center space-x-3">
|
||||
<twig:ux:icon name="heroicons:ticket" class="w-5 h-5 text-orange-600" />
|
||||
<div class="text-gray-700">
|
||||
<span class="font-medium">All-Inclusive Ticket</span>
|
||||
<span class="ml-2">50€</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-3">
|
||||
<twig:ux:icon name="heroicons:cake" class="w-5 h-5 text-orange-600" />
|
||||
<div class="text-gray-700">
|
||||
<span class="font-medium">After-Show Ticket</span>
|
||||
<span class="ml-2">20€</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-3">
|
||||
<twig:ux:icon name="heroicons:musical-note" class="w-5 h-5 text-orange-600" />
|
||||
<div class="text-gray-700">
|
||||
<span class="font-medium">Kind (6-12 Jahre)</span>
|
||||
<span class="ml-2">15€</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-3">
|
||||
<twig:ux:icon name="heroicons:musical-note" class="w-5 h-5 text-orange-600" />
|
||||
<div class="text-gray-700">
|
||||
<span class="font-medium">Kind (0-6 Jahre)</span>
|
||||
<span class="ml-2">0€</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center space-y-6">
|
||||
|
@ -49,6 +49,10 @@
|
||||
<twig:ux:icon name="ic:baseline-phone" class="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" />
|
||||
<input name="phone" data-form-target="phone" class="w-full pl-10 pr-4 py-3 rounded-xl border border-gray-200 focus:border-orange-500 focus:ring-2 focus:ring-orange-200 transition-all" type="tel" placeholder="Telefon (optional)">
|
||||
</div>
|
||||
<div class="relative">
|
||||
<twig:ux:icon name="tabler:coin" class="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" />
|
||||
<input name="donation" data-form-target="donation" class="w-full pl-10 pr-4 py-3 rounded-xl border border-gray-200 focus:border-orange-500 focus:ring-2 focus:ring-orange-200 transition-all" type="number" placeholder="Spende (optional)">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
Reference in New Issue
Block a user