Add all code files from IDE
This commit is contained in:
97
source/dbtools/Customer.php
Normal file
97
source/dbtools/Customer.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
class Customer extends Application
|
||||
{
|
||||
private $Virtualmin;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::_construct();
|
||||
|
||||
$this->Virtualmin = new VirtualminHandler();
|
||||
}
|
||||
|
||||
// By default, this function sets the customer as inactive (e.g. newly created, awating payment)
|
||||
// Returns the customer's hosting password
|
||||
public function newCustomer($Domain, $Name, $Email, $CheckoutID, $SubscriptionStatus, $Package, $PaddleSubscriptionID, $SystemStatus, $GDPRConsent, $hasVirtualServer = false, $attachedVServerID = null)
|
||||
{
|
||||
$passwordFactory = new RandomLib\Factory();
|
||||
$pGen = $passwordFactory->getLowStrengthGenerator();
|
||||
|
||||
$this->db->insert('Customers', [
|
||||
'CustomerName' => $Name,
|
||||
'CustomerEmail' => $Email,
|
||||
'CustomerCheckoutID' => $CheckoutID,
|
||||
'Package' => $Package,
|
||||
'SubscriptionStatus' => $SubscriptionStatus,
|
||||
'PaddleSubscriptionID' => $PaddleSubscriptionID,
|
||||
'SystemStatus' => $SystemStatus,
|
||||
'GDPRConsent' => $GDPRConsent,
|
||||
'hasVirtualServer' => $hasVirtualServer,
|
||||
'attachedVServerID' => $attachedVServerID,
|
||||
'PAC' => $pGen->generate(4)
|
||||
]);
|
||||
|
||||
$cPassword = $pGen->generate(16);
|
||||
$this->Virtualmin->CreateVirtualServer($Domain, $cPassword);
|
||||
|
||||
|
||||
return $cPassword;
|
||||
}
|
||||
|
||||
public function updateCustomerInformation($CustomerID, $UpdateField, $NewValue)
|
||||
{
|
||||
$db->update('Customers', [
|
||||
$UpdateField => $NewValue
|
||||
], [
|
||||
'ID' => $CustomerID
|
||||
]);
|
||||
}
|
||||
|
||||
public function eraseCustomer($CustomerID)
|
||||
{
|
||||
// Virtualmin: Delete virutal server attached to customer
|
||||
$db->delete('Customers', [
|
||||
'ID' => $CustomerID
|
||||
]);
|
||||
}
|
||||
|
||||
public function listCustomersByEmail($CEmail)
|
||||
{
|
||||
$Customer = $this->db->row(
|
||||
"SELECT * FROM Customers WHERE CustomerEmail = ?",
|
||||
$CEmail
|
||||
);
|
||||
|
||||
return $Customer
|
||||
}
|
||||
|
||||
public function translateEmailToID($Email)
|
||||
{
|
||||
$Customer = $this->listCustomersByEmail($Email);
|
||||
|
||||
return $Customer['ID'];
|
||||
}
|
||||
|
||||
public function customerExists($CustomerEmail)
|
||||
{
|
||||
|
||||
return $this->Exists("Customers", "CustomerEmail", $CustomerEmail);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getCustomerGDPRConsent($CustomerEmail)
|
||||
{
|
||||
$Customer = $this->listCustomersByEmail($CustomerEmail);
|
||||
|
||||
// assume this returns an array. do var_dump($Customer) if not
|
||||
return $Customer['GDPRConsent'];
|
||||
}
|
||||
|
||||
public function populate
|
||||
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user