diff --git a/application/models/Admins_model.php b/application/models/Admins_model.php index 34927213..bc041687 100644 --- a/application/models/Admins_model.php +++ b/application/models/Admins_model.php @@ -196,6 +196,9 @@ class Admins_model extends EA_Model { $settings = $admin['settings']; unset($admin['settings']); + $admin['create_datetime'] = date('Y-m-d H:i:s'); + $admin['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->insert('users', $admin)) { throw new RuntimeException('Could not insert admin.'); @@ -237,6 +240,8 @@ class Admins_model extends EA_Model { $settings['password'] = hash_password($existing_settings['salt'], $settings['password']); } + $admin['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->update('users', $admin, ['id' => $admin['id']])) { throw new RuntimeException('Could not update admin.'); diff --git a/application/models/Appointments_model.php b/application/models/Appointments_model.php index 61c1f5ef..97115bea 100644 --- a/application/models/Appointments_model.php +++ b/application/models/Appointments_model.php @@ -175,6 +175,8 @@ class Appointments_model extends EA_Model { protected function insert(array $appointment): int { $appointment['book_datetime'] = date('Y-m-d H:i:s'); + $appointment['create_datetime'] = date('Y-m-d H:i:s'); + $appointment['update_datetime'] = date('Y-m-d H:i:s'); $appointment['hash'] = random_string('alnum', 12); if ( ! $this->db->insert('appointments', $appointment)) @@ -196,6 +198,8 @@ class Appointments_model extends EA_Model { */ protected function update(array $appointment): int { + $appointment['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->update('appointments', $appointment, ['id' => $appointment['id']])) { throw new RuntimeException('Could not update appointment record.'); diff --git a/application/models/Categories_model.php b/application/models/Categories_model.php index 1cc5511b..0467fe20 100644 --- a/application/models/Categories_model.php +++ b/application/models/Categories_model.php @@ -98,6 +98,9 @@ class Categories_model extends EA_Model { */ protected function insert(array $category): int { + $category['create_datetime'] = date('Y-m-d H:i:s'); + $category['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->insert('categories', $category)) { throw new RuntimeException('Could not insert category.'); @@ -117,6 +120,8 @@ class Categories_model extends EA_Model { */ protected function update(array $category): int { + $category['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->update('categories', $category, ['id' => $category['id']])) { throw new RuntimeException('Could not update service categories.'); diff --git a/application/models/Consents_model.php b/application/models/Consents_model.php index 76b5b6bc..abfc64ec 100644 --- a/application/models/Consents_model.php +++ b/application/models/Consents_model.php @@ -82,8 +82,7 @@ class Consents_model extends EA_Model { */ protected function insert(array $consent): int { - $consent['created'] = date('Y-m-d H:i:s'); - $consent['modified'] = date('Y-m-d H:i:s'); + $consent['update_datetime'] = date('Y-m-d H:i:s'); if ( ! $this->db->insert('consents', $consent)) { @@ -104,7 +103,7 @@ class Consents_model extends EA_Model { */ protected function update(array $consent): int { - $consent['modified'] = date('Y-m-d H:i:s'); + $consent['update_datetime'] = date('Y-m-d H:i:s'); if ( ! $this->db->update('consents', $consent, ['id' => $consent['id']])) { diff --git a/application/models/Customers_model.php b/application/models/Customers_model.php index 4417ae3a..f6f33cb2 100644 --- a/application/models/Customers_model.php +++ b/application/models/Customers_model.php @@ -157,6 +157,8 @@ class Customers_model extends EA_Model { */ protected function insert(array $customer): int { + $customer['create_datetime'] = date('Y-m-d H:i:s'); + $customer['update_datetime'] = date('Y-m-d H:i:s'); $customer['id_roles'] = $this->get_customer_role_id(); if ( ! $this->db->insert('users', $customer)) @@ -178,6 +180,8 @@ class Customers_model extends EA_Model { */ protected function update(array $customer): int { + $customer['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->update('users', $customer, ['id' => $customer['id']])) { throw new RuntimeException('Could not update customer.'); diff --git a/application/models/Providers_model.php b/application/models/Providers_model.php index 1fa3d004..00977eb2 100755 --- a/application/models/Providers_model.php +++ b/application/models/Providers_model.php @@ -206,6 +206,8 @@ class Providers_model extends EA_Model { */ protected function insert(array $provider): int { + $provider['create_datetime'] = date('Y-m-d H:i:s'); + $provider['update_datetime'] = date('Y-m-d H:i:s'); $provider['id_roles'] = $this->get_provider_role_id(); $service_ids = $provider['services']; @@ -240,6 +242,8 @@ class Providers_model extends EA_Model { */ protected function update(array $provider): int { + $provider['update_datetime'] = date('Y-m-d H:i:s'); + $service_ids = $provider['services']; unset($provider['services']); diff --git a/application/models/Roles_model.php b/application/models/Roles_model.php index 1f3ecdf1..32ebec3c 100644 --- a/application/models/Roles_model.php +++ b/application/models/Roles_model.php @@ -96,6 +96,9 @@ class Roles_model extends EA_Model { */ protected function insert(array $role): int { + $role['create_datetime'] = date('Y-m-d H:i:s'); + $role['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->insert('roles', $role)) { throw new RuntimeException('Could not insert role.'); @@ -115,6 +118,8 @@ class Roles_model extends EA_Model { */ protected function update(array $role): int { + $role['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->update('roles', $role, ['id' => $role['id']])) { throw new RuntimeException('Could not update role.'); diff --git a/application/models/Secretaries_model.php b/application/models/Secretaries_model.php index 288a064b..299c7ac9 100644 --- a/application/models/Secretaries_model.php +++ b/application/models/Secretaries_model.php @@ -204,6 +204,9 @@ class Secretaries_model extends EA_Model { */ protected function insert(array $secretary): int { + $secretary['create_datetime'] = date('Y-m-d H:i:s'); + $secretary['update_datetime'] = date('Y-m-d H:i:s'); + $secretary['id_roles'] = $this->get_secretary_role_id(); $providers = $secretary['providers'] ?? []; @@ -239,6 +242,8 @@ class Secretaries_model extends EA_Model { */ protected function update(array $secretary): int { + $secretary['update_datetime'] = date('Y-m-d H:i:s'); + $provider_ids = $secretary['providers'] ?? []; unset($secretary['providers']); diff --git a/application/models/Services_model.php b/application/models/Services_model.php index 47d83685..b7aaeff0 100644 --- a/application/models/Services_model.php +++ b/application/models/Services_model.php @@ -154,6 +154,9 @@ class Services_model extends EA_Model { */ protected function insert(array $service): int { + $service['create_datetime'] = date('Y-m-d H:i:s'); + $service['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->insert('services', $service)) { throw new RuntimeException('Could not insert service.'); @@ -173,6 +176,8 @@ class Services_model extends EA_Model { */ protected function update(array $service): int { + $service['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->update('services', $service, ['id' => $service['id']])) { throw new RuntimeException('Could not update service.'); diff --git a/application/models/Settings_model.php b/application/models/Settings_model.php index 26f8120a..9d0c4651 100644 --- a/application/models/Settings_model.php +++ b/application/models/Settings_model.php @@ -97,6 +97,9 @@ class Settings_model extends EA_Model { */ protected function insert(array $setting): int { + $setting['create_datetime'] = date('Y-m-d H:i:s'); + $setting['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->insert('settings', $setting)) { throw new RuntimeException('Could not insert setting.'); @@ -116,6 +119,8 @@ class Settings_model extends EA_Model { */ protected function update(array $setting): int { + $setting['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->update('settings', $setting, ['id' => $setting['id']])) { throw new RuntimeException('Could not update setting.'); diff --git a/application/models/Unavailabilities_model.php b/application/models/Unavailabilities_model.php index f2559b07..a560c4d9 100644 --- a/application/models/Unavailabilities_model.php +++ b/application/models/Unavailabilities_model.php @@ -129,6 +129,8 @@ class Unavailabilities_model extends EA_Model { protected function insert(array $unavailability): int { $unavailability['book_datetime'] = date('Y-m-d H:i:s'); + $unavailability['create_datetime'] = date('Y-m-d H:i:s'); + $unavailability['update_datetime'] = date('Y-m-d H:i:s'); $unavailability['hash'] = random_string('alnum', 12); $unavailability['is_unavailability'] = TRUE; @@ -151,6 +153,8 @@ class Unavailabilities_model extends EA_Model { */ protected function update(array $unavailability): int { + $unavailability['update_datetime'] = date('Y-m-d H:i:s'); + if ( ! $this->db->update('appointments', $unavailability, ['id' => $unavailability['id']])) { throw new RuntimeException('Could not update unavailability record.'); diff --git a/application/models/Users_model.php b/application/models/Users_model.php index 36ee2c59..607cfe71 100644 --- a/application/models/Users_model.php +++ b/application/models/Users_model.php @@ -113,6 +113,9 @@ class Users_model extends EA_Model { */ protected function insert(array $user): int { + $user['create_datetime'] = date('Y-m-d H:i:s'); + $user['update_datetime'] = date('Y-m-d H:i:s'); + $settings = $user['settings']; unset($user['settings']); @@ -141,6 +144,8 @@ class Users_model extends EA_Model { */ protected function update(array $user): int { + $user['update_datetime'] = date('Y-m-d H:i:s'); + $settings = $user['settings']; unset($user['settings']);