first commit

This commit is contained in:
2025-04-30 23:59:49 +02:00
commit 652863d54f
117 changed files with 12276 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
<?php
namespace controls;
class Scanner
{
static public function scanner_view()
{
if ( !\S::get_session('user') )
return \Tpl::view('admin-panel/login');
return \Tpl::view( 'tickets/scanner-view');
}
static public function scanner_get_data() {
$ticketHash = \S::get( 'scannerData' );
$ticketData = \factory\Tickets::get_order_details_by_hash( $ticketHash );
$dateNow = date('Y-m-d');
$datePay = date("Y-m-d", strtotime($ticketData['payment_date']));
$dateInterval = abs(strtotime($dateNow) - strtotime($datePay));
$dateInterval = round($dateInterval / 86400, 1);
if ($ticketData) {
$message = '</br>';
$message .= '<strong><p style="font-size: 25px; margin-bottom: 0;">Status płatności: </p></strong>';
$message .= '<strong><p style="font-size: 25px;">';
$message .= $ticketData['payment_status'] ? '<span class="c_green">Zapłacono</span>' : '<span class="c_red">Nie zapłacono</span>';
$message .= '</p></strong>';
$message .= '<hr>';
$message .= '<strong><p style="font-size: 25px; margin-bottom: 0;">Status biletu: </p></strong>';
$message .= '<strong><p style="font-size: 25px; margin-bottom: 0;"';
if($dateInterval > 30 and !$ticketData['used_ticket']){
$message .= '<span class="c_red">Bilet nieważny</span>';
} else {
$message .= $ticketData['used_ticket'] ? '<span class="c_red">Wykorzystany</span>' : '<span class="c_green">Nie wykorzystany</span>';
}
$message .= '</p></strong>';
if($ticketData['used_ticket']){
$message .= '<p style="font-size: 20px;">' . $ticketData['used_ticket_date'] . '</p>';
}
$message .= '<hr>';
$message .= '<strong><p>Bilety: </p></strong>';
$message .= '<ul>';
foreach ($ticketData['tickets'] as $value){
$message .= '<li>' . $value['name'] . ' (x ' . $value["quantity"] . ')</li>';
}
$message .= '</ul>';
$message .= '<p>Cena: <strong>' . $ticketData['order_price'] . '</strong></p>';
$message .= '<hr>';
$message .= '<strong><p>Dane klienta:</p></strong>';
$message .= '<input type="hidden" id="order-id" value="' . $ticketData['id'] . '">';
$message .= '<p>Imie: <strong>' . $ticketData['name'] . '</strong></p>';
$message .= '<p>Nazwisko: <strong>' . $ticketData['surname'] . '</strong></p>';
$message .= '<p>Email: <strong>' . $ticketData['email'] . '</strong></p>';
$message .= '<p>Kod pocztowy: <strong>' . $ticketData['zip_code'] . '</strong></p>';
$message .= '<p>Miasto: <strong>' . $ticketData['city'] . '</strong></p>';
$message .= '<hr>';
if($dateInterval < 30){
if (\S::get_session('user')){
if(!$ticketData['used_ticket']){
$message .= '<button class="btn-t1" id="btn-used" style="margin: 30px auto; display: block;">Oznacz jako wykorzystany</button>';
}
}
}
}
else
{
$message = '</br>';
$message .= '<strong><p style="font-size: 30px; text-align: center;">Nie poprawny kod QR</p></strong>';
}
echo json_encode($message);
exit;
}
static public function use_ticket() {
global $mdb;
$order_id = \S::get('order_id');
$date = date('Y-m-d H:i:s');
$mdb->update('orders', ['used_ticket' => 1, 'used_ticket_date' => $date], ['id' => $order_id]);
echo json_encode([
'useStatus' => true
]);
exit;
}
}