95 lines
6.2 KiB
PHP
95 lines
6.2 KiB
PHP
<?php
|
|
|
|
namespace objects;
|
|
|
|
use classes\db;
|
|
use classes\object_property;
|
|
use traits\db_object_t;
|
|
|
|
class bookings_o extends db
|
|
{
|
|
use db_object_t;
|
|
|
|
public object_property $customer_number;
|
|
public object_property $wash_type;
|
|
public object_property $contact_email;
|
|
public object_property $reference_number;
|
|
public object_property $regNrTraekker;
|
|
public object_property $regNrTrailer;
|
|
public object_property $washCertificateEmail;
|
|
public object_property $date;
|
|
public object_property $department;
|
|
public object_property $pickup_bool;
|
|
public object_property $notes;
|
|
public object_property $washCertificateStatus;
|
|
public object_property $washCertificateUrl;
|
|
public object_property $status;
|
|
|
|
public function structure(): void
|
|
{
|
|
$this->setTable('bookings');
|
|
}
|
|
|
|
public function add(int $customer_number, string $wash_type, string $contact_email, string $reference_number, string $regNrTraekker, string $regNrTrailer, string $washCertificateEmail, string $date, string $department, int $pickup_bool, string $notes, string $washCertificateStatus, string $washCertificateUrl, string $status): void
|
|
{
|
|
global $db;
|
|
// Avoid SQL injection
|
|
$wash_type = $db->escape_string($wash_type);
|
|
$contact_email = $db->escape_string($contact_email);
|
|
$reference_number = $db->escape_string($reference_number);
|
|
$regNrTraekker = $db->escape_string($regNrTraekker);
|
|
$regNrTrailer = $db->escape_string($regNrTrailer);
|
|
$washCertificateEmail = $db->escape_string($washCertificateEmail);
|
|
$date = $db->escape_string($date);
|
|
$department = $db->escape_string($department);
|
|
$notes = $db->escape_string($notes);
|
|
$washCertificateStatus = $db->escape_string($washCertificateStatus);
|
|
$washCertificateUrl = $db->escape_string($washCertificateUrl);
|
|
$status = $db->escape_string($status);
|
|
// Create a new record in the database ( Replace the code, if an entry already exists )
|
|
$sql = "INSERT INTO $this->table (customer_number, wash_type, contact_email, reference_number, regNrTraekker, regNrTrailer, washCertificateEmail, date, department, pickup_bool, notes, washCertificateStatus, washCertificateUrl, status) VALUES ($customer_number, '$wash_type', '$contact_email', '$reference_number', '$regNrTraekker', '$regNrTrailer', '$washCertificateEmail', '$date', '$department', $pickup_bool, '$notes', '$washCertificateStatus', '$washCertificateUrl', '$status')";
|
|
$db->query($sql);
|
|
|
|
// Get the id of the new record
|
|
$this->id = $db->insert_id();
|
|
}
|
|
|
|
public function addOrUpdate($id, $customer_number, $wash_type, $contact_email, $reference_number, $regNrTraekker, $regNrTrailer, $washCertificateEmail, $date, $department, $pickup_bool, $notes, $washCertificateStatus, $washCertificateUrl, $status): void
|
|
{
|
|
global $db;
|
|
// Avoid SQL injection
|
|
$wash_type = $db->escape_string($wash_type);
|
|
$contact_email = $db->escape_string($contact_email);
|
|
$reference_number = $db->escape_string($reference_number);
|
|
$regNrTraekker = $db->escape_string($regNrTraekker);
|
|
$regNrTrailer = $db->escape_string($regNrTrailer);
|
|
$washCertificateEmail = $db->escape_string($washCertificateEmail);
|
|
$date = $db->escape_string($date);
|
|
$department = $db->escape_string($department);
|
|
$notes = $db->escape_string($notes);
|
|
$washCertificateStatus = $db->escape_string($washCertificateStatus);
|
|
$washCertificateUrl = $db->escape_string($washCertificateUrl);
|
|
$status = $db->escape_string($status);
|
|
// Create a new record in the database ( Replace the code, if an entry already exists )
|
|
$sql = "INSERT INTO $this->table (id, customer_number, wash_type, contact_email, reference_number, regNrTraekker, regNrTrailer, washCertificateEmail, date, department, pickup_bool, notes, washCertificateStatus, washCertificateUrl, status) VALUES ($id, $customer_number, '$wash_type', '$contact_email', '$reference_number', '$regNrTraekker', '$regNrTrailer', '$washCertificateEmail', '$date', '$department', $pickup_bool, '$notes', '$washCertificateStatus', '$washCertificateUrl', '$status') ON DUPLICATE KEY UPDATE customer_number = $customer_number, wash_type = '$wash_type', contact_email = '$contact_email', reference_number = '$reference_number', regNrTraekker = '$regNrTraekker', regNrTrailer = '$regNrTrailer', washCertificateEmail = '$washCertificateEmail', date = '$date', department = '$department', pickup_bool = $pickup_bool, notes = '$notes', washCertificateStatus = '$washCertificateStatus', washCertificateUrl = '$washCertificateUrl', status = '$status'";
|
|
$db->query($sql);
|
|
}
|
|
|
|
public function getObjectProperties(): void
|
|
{
|
|
$this->customer_number = new object_property($this->table, $this->id, 'customer_number', 'int', true);
|
|
$this->wash_type = new object_property($this->table, $this->id, 'wash_type', 'string', true);
|
|
$this->contact_email = new object_property($this->table, $this->id, 'contact_email', 'string', true);
|
|
$this->reference_number = new object_property($this->table, $this->id, 'reference_number', 'string', true);
|
|
$this->regNrTraekker = new object_property($this->table, $this->id, 'regNrTraekker', 'string', true);
|
|
$this->regNrTrailer = new object_property($this->table, $this->id, 'regNrTrailer', 'string', true);
|
|
$this->washCertificateEmail = new object_property($this->table, $this->id, 'washCertificateEmail', 'string', true);
|
|
$this->date = new object_property($this->table, $this->id, 'date', 'string', true);
|
|
$this->department = new object_property($this->table, $this->id, 'department', 'string', true);
|
|
$this->pickup_bool = new object_property($this->table, $this->id, 'pickup_bool', 'int', true);
|
|
$this->notes = new object_property($this->table, $this->id, 'notes', 'string', true);
|
|
$this->washCertificateStatus = new object_property($this->table, $this->id, 'washCertificateStatus', 'string', true);
|
|
$this->washCertificateUrl = new object_property($this->table, $this->id, 'washCertificateUrl', 'string', true);
|
|
$this->status = new object_property($this->table, $this->id, 'status', 'string', true);
|
|
}
|
|
} |