Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -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'])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user