PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.11
Booking for Appointments and Events Calendar – Amelia v1.2.11
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / WP / InstallActions / DB / Notification / NotificationsTable.php
ameliabooking / src / Infrastructure / WP / InstallActions / DB / Notification Last commit date
NotificationsLogTable.php 4 years ago NotificationsSMSHistoryTable.php 4 years ago NotificationsTable.php 2 years ago NotificationsTableInsertRows.php 1 year ago NotificationsToEntitiesTable.php 4 years ago
NotificationsTable.php
65 lines
1 <?php
2
3 namespace AmeliaBooking\Infrastructure\WP\InstallActions\DB\Notification;
4
5 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
6 use AmeliaBooking\Domain\ValueObjects\String\Name;
7 use AmeliaBooking\Domain\ValueObjects\String\NotificationSendTo;
8 use AmeliaBooking\Domain\ValueObjects\String\NotificationType;
9 use AmeliaBooking\Infrastructure\WP\InstallActions\DB\AbstractDatabaseTable;
10
11 /**
12 * Class NotificationsTable
13 *
14 * @package AmeliaBooking\Infrastructure\WP\InstallActions\DB\Notification
15 */
16 class NotificationsTable extends AbstractDatabaseTable
17 {
18
19 const TABLE = 'notifications';
20
21 /**
22 * @return string
23 * @throws InvalidArgumentException
24 */
25 public static function buildTable()
26 {
27 global $wpdb;
28
29 $table = self::getTableName();
30
31 $name = Name::MAX_LENGTH;
32 $typeEmail = NotificationType::EMAIL;
33 $typeSms = NotificationType::SMS;
34 $typeWhatsApp = NotificationType::WHATSAPP;
35 $sendToCustomer = NotificationSendTo::CUSTOMER;
36 $sendToProvider = NotificationSendTo::PROVIDER;
37
38 if ($wpdb->get_var("SHOW TABLES LIKE '{$table}'") === $table &&
39 $wpdb->query("SHOW KEYS FROM {$table} WHERE Key_name = 'name'")
40 ) {
41 $wpdb->query("ALTER TABLE {$table} DROP INDEX name");
42 }
43
44 return "CREATE TABLE {$table} (
45 `id` INT(11) NOT NULL AUTO_INCREMENT,
46 `name` VARCHAR({$name}) NOT NULL DEFAULT '',
47 `customName` VARCHAR(255) DEFAULT NULL,
48 `status` ENUM('enabled', 'disabled') NOT NULL DEFAULT 'enabled',
49 `type` ENUM('{$typeEmail}', '{$typeSms}', '{$typeWhatsApp}') NOT NULL,
50 `entity` ENUM('appointment', 'event') NOT NULL DEFAULT 'appointment',
51 `time` TIME NULL DEFAULT NULL,
52 `timeBefore` INT(11) NULL DEFAULT NULL,
53 `timeAfter` INT(11) NULL DEFAULT NULL,
54 `sendTo` ENUM('{$sendToCustomer}', '{$sendToProvider}') NOT NULL,
55 `subject` VARCHAR(255) NOT NULL DEFAULT '',
56 `content` TEXT NULL,
57 `translations` TEXT NULL DEFAULT NULL,
58 `sendOnlyMe` TINYINT(1) DEFAULT 0,
59 `whatsAppTemplate` VARCHAR(255) NULL DEFAULT NULL,
60 `minimumTimeBeforeBooking` TEXT NULL DEFAULT NULL,
61 PRIMARY KEY (`id`)
62 ) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci";
63 }
64 }
65