Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-02-22 23:03:13 +01:00
parent c8181621af
commit 58b2373712
19 changed files with 19094 additions and 49 deletions

View File

@@ -1,4 +1,4 @@
<?
<?php
namespace controls;
@@ -75,7 +75,7 @@ class Apanel
$ticket_id = \S::get('ticket_id');
if ($basket[$ticket_id])
if (!empty($basket[$ticket_id]))
{
$basket[$ticket_id]['quantity']++;
}

View File

@@ -16,7 +16,7 @@ class Scanner
$ticketData = \factory\Tickets::get_order_details_by_hash( $ticketHash );
$dateNow = date('Y-m-d');
$datePay = date("Y-m-d", strtotime($ticketData['payment_date']));
$datePay = date("Y-m-d", strtotime($ticketData['payment_date'] ?? 'now'));
$dateInterval = abs(strtotime($dateNow) - strtotime($datePay));
$dateInterval = round($dateInterval / 86400, 1);

View File

@@ -8,11 +8,12 @@ class Site
$class = '\controls\\';
$results = explode( '_', \S::get( 'module' ) );
$module = \S::get( 'module' ) ?? '';
$results = explode( '_', $module );
if ( is_array( $results ) ) foreach ( $results as $row )
$class .= ucfirst( $row );
$action = \S::get( 'action' );
$action = \S::get( 'action' ) ?? '';
if ( class_exists( $class ) and method_exists( new $class, $action ) )
{

View File

@@ -1,4 +1,4 @@
<?
<?php
namespace controls;
@@ -35,7 +35,7 @@ class Tickets
$basket = \S::get_session('basket');
$ticket_id = \S::get('ticket_id');
if ( $basket[$ticket_id][$diffDays] )
if ( !empty($basket[$ticket_id][$diffDays]) )
{
$basket[$ticket_id][$diffDays]['quantity']++;
}
@@ -97,7 +97,7 @@ class Tickets
$ticket_id = \S::get('ticket_id');
$diffdays = \S::get('diffdays');
if ($basket[$ticket_id][$diffdays]['quantity'] > 0)
if (isset($basket[$ticket_id][$diffdays]) && $basket[$ticket_id][$diffdays]['quantity'] > 0)
{
$basket[$ticket_id][$diffdays]['quantity']--;
@@ -235,23 +235,23 @@ class Tickets
}
}
$hash = md5(trim($_POST['email']) . trim($_POST['city']) . trim(date("Y-m-d H:i:s")));
$hash = md5(trim((string)($_POST['email'] ?? '')) . trim((string)($_POST['city'] ?? '')) . trim(date("Y-m-d H:i:s")));
//* Zapisywanie do DB klienta
$mdb->insert('orders', [
'name' => trim($_POST['name']),
'surname' => trim($_POST['surname']),
'email' => trim($_POST['email']),
'zip_code' => trim($_POST['zip_code']),
'city' => trim($_POST['city']),
'street' => trim($_POST['street']),
'order_price' => trim($finalPrice),
'name' => trim((string)($_POST['name'] ?? '')),
'surname' => trim((string)($_POST['surname'] ?? '')),
'email' => trim((string)($_POST['email'] ?? '')),
'zip_code' => trim((string)($_POST['zip_code'] ?? '')),
'city' => trim((string)($_POST['city'] ?? '')),
'street' => trim((string)($_POST['street'] ?? '')),
'order_price' => $finalPrice,
'date_added' => $date,
'hash' => $hash,
'vat' => trim($_POST['vat'] == 'on' ? '1' : '0'),
'company_name' => trim($_POST['company_name']),
'nip' => trim($_POST['nip']),
'gift_address' => trim($_POST['gift_address'])
'vat' => (($_POST['vat'] ?? '') == 'on' ? '1' : '0'),
'company_name' => trim((string)($_POST['company_name'] ?? '')),
'nip' => trim((string)($_POST['nip'] ?? '')),
'gift_address' => trim((string)($_POST['gift_address'] ?? ''))
] );
//* Id klienta
@@ -273,7 +273,7 @@ class Tickets
{
foreach ( $value as $key => $val )
{
if ( $val['date'] ) {
if ( !empty($val['date']) ) {
$dateFormatted = new \DateTime( $val['date'] );
$dateFormatted = $dateFormatted->format('Y-m-d');
} else
@@ -596,8 +596,10 @@ class Tickets
{
global $mdb;
$order = \factory\Tickets::get_order_details_by_hash(\S::get('order'));
$order_successful = false;
$order_fail = false;
if ( $order['payment_status'] and !$order['informed_user'] )
if ( $order && !empty($order['payment_status']) && empty($order['informed_user']) )
{
if ($order['payment_status'])
{