Customer model will honor the display/require settings
This commit is contained in:
parent
afad7920eb
commit
bd9b5f196a
1 changed files with 39 additions and 25 deletions
|
@ -94,18 +94,31 @@ class Customers_model extends EA_Model {
|
|||
}
|
||||
|
||||
// Make sure all required fields are provided.
|
||||
$phone_number_required = filter_var(setting('require_phone_number'), FILTER_VALIDATE_BOOLEAN);
|
||||
$require_first_name = filter_var(setting('require_phone_number'), FILTER_VALIDATE_BOOLEAN);
|
||||
$require_last_name = filter_var(setting('require_last'), FILTER_VALIDATE_BOOLEAN);
|
||||
$require_email = filter_var(setting('require_email'), FILTER_VALIDATE_BOOLEAN);
|
||||
$require_phone_number = filter_var(setting('require_phone_number'), FILTER_VALIDATE_BOOLEAN);
|
||||
$require_address = filter_var(setting('require_address'), FILTER_VALIDATE_BOOLEAN);
|
||||
$require_city = filter_var(setting('require_city'), FILTER_VALIDATE_BOOLEAN);
|
||||
$require_zip_code = filter_var(setting('require_zip_code'), FILTER_VALIDATE_BOOLEAN);
|
||||
$require_notes = filter_var(setting('require_notes'), FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
if (
|
||||
empty($customer['first_name'])
|
||||
|| empty($customer['last_name'])
|
||||
|| empty($customer['email'])
|
||||
|| (empty($customer['phone_number']) && $phone_number_required)
|
||||
(empty($customer['first_name']) && $require_first_name)
|
||||
|| (empty($customer['last_name']) && $require_last_name)
|
||||
|| (empty($customer['email']) && $require_email)
|
||||
|| (empty($customer['phone_number']) && $require_phone_number)
|
||||
|| (empty($customer['address']) && $require_address)
|
||||
|| (empty($customer['city']) && $require_city)
|
||||
|| (empty($customer['zip_code']) && $require_zip_code)
|
||||
|| (empty($customer['notes']) && $require_notes)
|
||||
)
|
||||
{
|
||||
throw new InvalidArgumentException('Not all required fields are provided: ' . print_r($customer, TRUE));
|
||||
}
|
||||
|
||||
if ( ! empty($customer['email']))
|
||||
{
|
||||
// Validate the email address.
|
||||
if ( ! filter_var($customer['email'], FILTER_VALIDATE_EMAIL))
|
||||
{
|
||||
|
@ -131,6 +144,7 @@ class Customers_model extends EA_Model {
|
|||
throw new InvalidArgumentException('The provided email address is already in use, please use a different one.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new customer into the database.
|
||||
|
@ -317,7 +331,7 @@ class Customers_model extends EA_Model {
|
|||
{
|
||||
if (empty($customer['email']))
|
||||
{
|
||||
throw new InvalidArgumentException('The customer email was not provided: ' . print_r($customer, TRUE));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$count = $this
|
||||
|
|
Loading…
Reference in a new issue