| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
class booking_package_setting { |
| 7 |
|
| 8 |
public $prefix = null; |
| 9 |
|
| 10 |
public $pluginName = null; |
| 11 |
|
| 12 |
public $userRoleName = null; |
| 13 |
|
| 14 |
private $isExtensionsValid = null; |
| 15 |
|
| 16 |
public $request_timeout = 30; |
| 17 |
|
| 18 |
public $guestForDayOfTheWeekRates = 1; |
| 19 |
|
| 20 |
public $messagingApp = 0; |
| 21 |
|
| 22 |
public $maxBookingSlotsPerDay = 0; |
| 23 |
|
| 24 |
public $payWithPayPay = 0; |
| 25 |
|
| 26 |
public $form = array( |
| 27 |
array('id' => 'first_name', 'name' => 'First name', 'value' => '', 'type' => 'TEXT', 'active' => 'true', 'options' => '', 'required' => 'true', 'isName' => 'true', 'isAddress' => 'false', 'isEmail' => 'false', 'isTerms' => 'false'), |
| 28 |
array('id' => 'last_name', 'name' => 'Last name', 'value' => '', 'type' => 'TEXT', 'active' => 'true', 'options' => '', 'required' => 'true', 'isName' => 'true', 'isAddress' => 'false', 'isEmail' => 'false', 'isTerms' => 'false'), |
| 29 |
array('id' => 'email', 'name' => 'Email', 'value' => '', 'type' => 'TEXT', 'active' => 'true', 'options' => '', 'required' => 'true', 'isName' => 'false', 'isAddress' => 'false', 'isEmail' => 'true', 'isTerms' => 'false'), |
| 30 |
array('id' => 'phone', 'name' => 'Phone', 'value' => '', 'type' => 'TEXT', 'active' => 'true', 'options' => '', 'required' => 'true', 'isName' => 'false', 'isAddress' => 'false', 'isEmail' => 'false', 'isTerms' => 'false'), |
| 31 |
array('id' => 'zip', 'name' => 'Zip', 'value' => '', 'type' => 'TEXT', 'options' => '', 'required' => 'false', 'isName' => 'false', 'isAddress' => 'false', 'isEmail' => 'false', 'isTerms' => 'false'), |
| 32 |
array('id' => 'address', 'name' => 'Address', 'value' => '', 'type' => 'TEXT', 'active' => 'true', 'options' => '', 'required' => 'false', 'isName' => 'false', 'isAddress' => 'true', 'isEmail' => 'false', 'isTerms' => 'false'), |
| 33 |
array('id' => 'terms', 'name' => 'Terms of Service', 'value' => '', 'type' => 'CHECK', 'active' => 'true', 'options' => 'I agree', 'required' => 'false', 'isName' => 'false', 'isAddress' => 'true', 'isEmail' => 'false', 'isTerms' => 'true'), |
| 34 |
); |
| 35 |
|
| 36 |
public $email_message = array( |
| 37 |
"new_booking_notification" => array("key" => "new_booking_notification", "subject" => "", "content" => "", 'enable' => '0', 'format' => 'text', 'title' => 'New', 'message' => ''), |
| 38 |
"booking_approved_notification" => array("key" => "booking_approved_notification", "subject" => "", "content" => "", 'enable' => '0', 'format' => 'text', 'title' => 'Approved', 'message' => ''), |
| 39 |
"booking_pending_notification" => array("key" => "booking_pending_notification", "subject" => "", "content" => "", 'enable' => '0', 'format' => 'text', 'title' => 'Pending', 'message' => ''), |
| 40 |
"booking_updated_notification" => array("key" => "booking_updated_notification", "subject" => "", "content" => "", 'enable' => '0', 'format' => 'text', 'title' => 'Updated', 'message' => ''), |
| 41 |
"booking_reminder_notification" => array("key" => "booking_reminder_notification", "subject" => "", "content" => "", 'enable' => '0', 'format' => 'text', 'title' => 'Reminder', 'message' => ''), |
| 42 |
"booking_cancellation_notification" => array("key" => "booking_cancellation_notification", "subject" => "", "content" => "", 'enable' => '0', 'format' => 'text', 'title' => 'Canceled', 'message' => ''), |
| 43 |
"booking_deleted_notification" => array("key" => "booking_deleted_notification", "subject" => "", "content" => "", 'enable' => '0', 'format' => 'text', 'title' => 'Deleted', 'message' => ''), |
| 44 |
); |
| 45 |
|
| 46 |
public function __construct($prefix, $pluginName, $userRoleName = 'booking_package_user') { |
| 47 |
|
| 48 |
$this->prefix = $prefix; |
| 49 |
$this->pluginName = $pluginName; |
| 50 |
$this->userRoleName = $userRoleName; |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
public function setPayWithPayPay($payWithPayPay) { |
| 55 |
|
| 56 |
$this->payWithPayPay = $payWithPayPay; |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
public function setMessagingApp($messagingApp) { |
| 61 |
|
| 62 |
$this->messagingApp = $messagingApp; |
| 63 |
|
| 64 |
} |
| 65 |
|
| 66 |
public function setMaxBookingSlotsPerDay($maxBookingSlotsPerDay) { |
| 67 |
|
| 68 |
$this->maxBookingSlotsPerDay = $maxBookingSlotsPerDay; |
| 69 |
|
| 70 |
} |
| 71 |
|
| 72 |
public function setGuestForDayOfTheWeekRates($guestForDayOfTheWeekRates) { |
| 73 |
|
| 74 |
$this->guestForDayOfTheWeekRates = $guestForDayOfTheWeekRates; |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
public function userFunctions() { |
| 79 |
|
| 80 |
$userFunctions = array( |
| 81 |
'function_for_member' => array('name' => __('Allow User Accounts', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'CHECK', 'valueList' => array('0' => 'Enabled')), |
| 82 |
'reject_non_membder' => array('name' => __('Reject Bookings From Non-Registered Users', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'CHECK', 'valueList' => array('0' => 'Enabled')), |
| 83 |
'visitors_registration_for_member' => array('name' => __('Enable Customer Registration', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'CHECK', 'valueList' => array('0' => 'Enabled')), |
| 84 |
'check_email_for_member' => array('name' => __('Send Email Verification For Registration and Profile Updates', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'CHECK', 'valueList' => array('0' => 'Enabled')), |
| 85 |
'accept_subscribers_as_users' => array('name' => __('Accept Subscribers as Users', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'CHECK', 'valueList' => array('0' => 'Enabled')), |
| 86 |
'accept_contributors_as_users' => array('name' => __('Accept Contributors as Users', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'CHECK', 'valueList' => array('0' => 'Enabled')), |
| 87 |
'user_toolbar' => array('name' => __('Show Toolbar', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'CHECK', 'valueList' => array('0' => 'Enabled')), |
| 88 |
/** |
| 89 |
'subject_email_for_member' => array('Subject of email sent when confirming email address' => 'Active', 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT', 'valueList' => array()), |
| 90 |
'body_email_for_member' => array('Body of email sent when confirming email address' => 'Active', 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXTAREA', 'valueList' => array()), |
| 91 |
**/ |
| 92 |
'lost_password' => array('name' => sprintf(__('Enable "%s" Feature', 'booking-package'), __('Lost Password', 'booking-package')), 'value' => '0', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'CHECK', 'valueList' => array('0' => 'Enabled')), |
| 93 |
); |
| 94 |
|
| 95 |
return $userFunctions; |
| 96 |
|
| 97 |
} |
| 98 |
|
| 99 |
public function booking_sync() { |
| 100 |
|
| 101 |
$booking_syn = array( |
| 102 |
"iCal" => array( |
| 103 |
'ical_active' => array('name' => __('Status', 'booking-package'), 'value' => '0', 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('1' => __('Enabled', 'booking-package'), '0' => __('Disabled', 'booking-package'))), |
| 104 |
'syncPastCustomersForIcal' => array('name' => __('Data Range', 'booking-package'), 'value' => '0', 'inputLimit' => 1, 'inputType' => 'SELECT', 'valueList' => |
| 105 |
array( |
| 106 |
'7' => sprintf(__('Last %s days', 'booking-package'), 7), |
| 107 |
'14' => sprintf(__('Last %s days', 'booking-package'), 14), |
| 108 |
'30' => sprintf(__('Last %s days', 'booking-package'), 30), |
| 109 |
'60' => sprintf(__('Last %s days', 'booking-package'), 60), |
| 110 |
'90' => sprintf(__('Last %s days', 'booking-package'), 90), |
| 111 |
'180' => sprintf(__('Last %s days', 'booking-package'), 180), |
| 112 |
'365' => sprintf(__('Last %s days', 'booking-package'), 365), |
| 113 |
) |
| 114 |
), |
| 115 |
'ical_token' => array('name' => 'URL', 'value' => '', 'inputLimit' => 1, 'inputType' => 'CUSTOMIZE'), |
| 116 |
) |
| 117 |
); |
| 118 |
|
| 119 |
return $booking_syn; |
| 120 |
|
| 121 |
} |
| 122 |
|
| 123 |
public function defaultFrom() { |
| 124 |
|
| 125 |
$form = array( |
| 126 |
array('id' => 'first_name', 'name' => __('First name', 'booking-package'), 'value' => '', 'type' => 'TEXT', 'active' => 'true', 'options' => '', 'required' => 'true', 'isName' => 'true', 'isAddress' => 'false', 'isEmail' => 'false', 'isTerms' => 'false', 'targetCustomers' => 'customersAndUsers', 'placeholder' => '', 'uri' => '', 'description' => ''), |
| 127 |
array('id' => 'last_name', 'name' => __('Last name', 'booking-package'), 'value' => '', 'type' => 'TEXT', 'active' => 'true', 'options' => '', 'required' => 'true', 'isName' => 'true', 'isAddress' => 'false', 'isEmail' => 'false', 'isTerms' => 'false', 'targetCustomers' => 'customersAndUsers', 'placeholder' => '', 'uri' => '', 'description' => ''), |
| 128 |
array('id' => 'email', 'name' => __('Email', 'booking-package'), 'value' => '', 'type' => 'TEXT', 'active' => 'true', 'options' => '', 'required' => 'true', 'isName' => 'false', 'isAddress' => 'false', 'isEmail' => 'true', 'isTerms' => 'false', 'targetCustomers' => 'customersAndUsers', 'placeholder' => '', 'uri' => '', 'description' => ''), |
| 129 |
array('id' => 'phone', 'name' => __('Phone', 'booking-package'), 'value' => '', 'type' => 'TEXT', 'active' => 'true', 'options' => '', 'required' => 'true', 'isName' => 'false', 'isAddress' => 'false', 'isEmail' => 'false', 'isTerms' => 'false', 'targetCustomers' => 'customersAndUsers', 'placeholder' => '', 'uri' => '', 'description' => ''), |
| 130 |
array('id' => 'zip', 'name' => __('Zip', 'booking-package'), 'value' => '', 'type' => 'TEXT', 'active' => '', 'options' => '', 'required' => 'false', 'isName' => 'false', 'isAddress' => 'false', 'isEmail' => 'false', 'isTerms' => 'false', 'targetCustomers' => 'customersAndUsers', 'placeholder' => '', 'uri' => '', 'description' => ''), |
| 131 |
array('id' => 'address', 'name' => __('Address', 'booking-package'), 'value' => '', 'type' => 'TEXT', 'active' => 'true', 'options' => '', 'required' => 'false', 'isName' => 'false', 'isAddress' => 'true', 'isEmail' => 'false', 'isTerms' => 'false', 'targetCustomers' => 'customersAndUsers', 'placeholder' => '', 'uri' => '', 'description' => ''), |
| 132 |
array('id' => 'terms', 'name' => __('Terms of Service', 'booking-package'), 'value' => '', 'type' => 'CHECK', 'active' => 'true', 'options' => __('I agree', 'booking-package'), 'required' => 'false', 'isName' => 'false', 'isAddress' => 'true', 'isEmail' => 'false', 'isTerms' => 'true', 'targetCustomers' => 'customersAndUsers', 'placeholder' => '', 'uri' => '', 'description' => ''), |
| 133 |
); |
| 134 |
return $form; |
| 135 |
|
| 136 |
} |
| 137 |
|
| 138 |
public function guestsInputType(){ |
| 139 |
|
| 140 |
$guestsInputTypeList = array( |
| 141 |
'name' => array('key' => 'name', 'name' => __('Name', 'booking-package'), 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', 'target' => 'both', 'filterHookKey' => 'dynamicTextModification'), |
| 142 |
'description' => array('name' => __('Description', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXTAREA', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => '', 'target' => 'both', 'filterHookKey' => 'dynamicTextModification'), |
| 143 |
'active' => array('key' => 'active', 'name' => __('Status', 'booking-package'), 'value' => 'true', 'inputLimit' => 2, 'inputType' => 'CHECK', 'valueList' => array('true' => 'Enabled'), "class" => '', 'target' => 'both'), |
| 144 |
'required' => array('key' => 'required', 'name' => __('Required', 'booking-package'), 'value' => '0', 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array(1 => __('Yes', 'booking-package'), 0 => __('No', 'booking-package')), 'target' => 'both'), |
| 145 |
'costInServices' => array('key' => 'costInServices', 'name' => __('Applicable Price Level', 'booking-package'), 'value' => 'cost_1', 'inputLimit' => 1, 'inputType' => 'SELECT', 'valueList' => array('cost_1' => __(/**'Cost 1'**/ 'Base Price', 'booking-package'), 'cost_2' => sprintf(__('Price %s', 'booking-package'), '2'), 'cost_3' => sprintf(__('Price %s', 'booking-package'), '3'), 'cost_4' => sprintf(__('Price %s', 'booking-package'), '4'), 'cost_5' => sprintf(__('Price %s', 'booking-package'), '5'), 'cost_6' => sprintf(__('Price %s', 'booking-package'), '6')), 'target' => 'day'), |
| 146 |
'target' => array('key' => 'target', 'name' => __('Target', 'booking-package'), 'value' => 'adult', 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('adult' => __('Adults', 'booking-package'), 'children' => __('Children', 'booking-package')), 'target' => 'hotel'), |
| 147 |
'guestsInCapacity' => array('key' => 'guestsInCapacity', 'name' => __('Count Total Guests Toward Availability', 'booking-package'), 'value' => 'adult', 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('excluded' => __('Excluded', 'booking-package'), 'included' => __('Included', 'booking-package')), 'target' => 'day'), |
| 148 |
'reflectService' => array('key' => 'reflectService', 'name' => __('Enable Quantity-Based Price Adjustment for Services', 'booking-package'), 'value' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'valueList' => array(1 => __('Enabled', 'booking-package'), 0 => __('Disabled', 'booking-package')), 'target' => 'day'), |
| 149 |
'reflectAdditional' => array('key' => 'reflectAdditional', 'name' => __('Enable Quantity-Based Price Adjustment for Extra Charges', 'booking-package'), 'value' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'valueList' => array(1 => __('Enabled', 'booking-package'), 0 => __('Disabled', 'booking-package')), 'target' => 'day'), |
| 150 |
'json' => array( |
| 151 |
'key' => 'json', |
| 152 |
'name' => __('Options', 'booking-package'), |
| 153 |
'value' => '', |
| 154 |
'inputLimit' => 1, |
| 155 |
'inputType' => 'EXTRA', |
| 156 |
'filterHookKey' => 'dynamicTextModification', |
| 157 |
"optionsType" => array( |
| 158 |
"number" => array("type" => "TEXT", "value" => "", "target" => "both"), |
| 159 |
"name" => array("type" => "TEXT", "value" => "", "target" => "both"), |
| 160 |
"price" => array("type" => "TEXT", "value" => "", "target" => "both"), |
| 161 |
|
| 162 |
"prices" => array( |
| 163 |
"type" => "dayOfTheWeek", |
| 164 |
"target" => "hotel", |
| 165 |
"options" => array( |
| 166 |
array("key" => "priceOnMonday", "name" => __('Monday', 'booking-package'), "type" => "TEXT", "value" => "0", 'isExtensionsValid' => 0), |
| 167 |
array("key" => "priceOnTuesday", "name" => __('Tuesday', 'booking-package'), "type" => "TEXT", "value" => "0", 'isExtensionsValid' => 0), |
| 168 |
array("key" => "priceOnWednesday", "name" => __('Wednesday', 'booking-package'), "type" => "TEXT", "value" => "0", 'isExtensionsValid' => 0), |
| 169 |
array("key" => "priceOnThursday", "name" => __('Thursday', 'booking-package'), "type" => "TEXT", "value" => "0", 'isExtensionsValid' => 0), |
| 170 |
array("key" => "priceOnFriday", "name" => __('Friday', 'booking-package'), "type" => "TEXT", "value" => "0", 'isExtensionsValid' => 0), |
| 171 |
array("key" => "priceOnSaturday", "name" => __('Saturday', 'booking-package'), "type" => "TEXT", "value" => "0", 'isExtensionsValid' => 0), |
| 172 |
array("key" => "priceOnSunday", "name" => __('Sunday', 'booking-package'), "type" => "TEXT", "value" => "0", 'isExtensionsValid' => 0), |
| 173 |
array("key" => "priceOnDayBeforeNationalHoliday", "name" => __('The day Before National holiday', 'booking-package'), "type" => "TEXT", "value" => "0", 'isExtensionsValid' => 1), |
| 174 |
array("key" => "priceOnNationalHoliday", "name" => __('National holiday', 'booking-package'), "type" => "TEXT", "value" => "0", 'isExtensionsValid' => 1), |
| 175 |
), |
| 176 |
) |
| 177 |
|
| 178 |
), |
| 179 |
'titleList' => array( |
| 180 |
'number' => __('Number of Guests', 'booking-package'), |
| 181 |
'name' => __('Display Text', 'booking-package'), |
| 182 |
'price' => __('Extra Charge', 'booking-package'), |
| 183 |
'prices' => __('Costs', 'booking-package') |
| 184 |
), |
| 185 |
'target' => 'both' |
| 186 |
), |
| 187 |
); |
| 188 |
|
| 189 |
if ($this->guestForDayOfTheWeekRates === 0) { |
| 190 |
|
| 191 |
unset($guestsInputTypeList['json']['optionsType']['prices']); |
| 192 |
unset($guestsInputTypeList['json']['titleList']['prices']); |
| 193 |
|
| 194 |
} else { |
| 195 |
|
| 196 |
unset($guestsInputTypeList['json']['optionsType']['price']); |
| 197 |
unset($guestsInputTypeList['json']['titleList']['price']); |
| 198 |
|
| 199 |
} |
| 200 |
|
| 201 |
return $guestsInputTypeList; |
| 202 |
|
| 203 |
} |
| 204 |
|
| 205 |
public function couponsInputType(){ |
| 206 |
|
| 207 |
$month = array( |
| 208 |
'1' => array('key' => 1, 'name' => __('Jan', 'booking-package')), |
| 209 |
'2' => array('key' => 2, 'name' => __('Feb', 'booking-package')), |
| 210 |
'3' => array('key' => 3, 'name' => __('Mar', 'booking-package')), |
| 211 |
'4' => array('key' => 4, 'name' => __('Apr', 'booking-package')), |
| 212 |
'5' => array('key' => 5, 'name' => __('May', 'booking-package')), |
| 213 |
'6' => array('key' => 6, 'name' => __('Jun', 'booking-package')), |
| 214 |
'7' => array('key' => 7, 'name' => __('Jul', 'booking-package')), |
| 215 |
'8' => array('key' => 8, 'name' => __('Aug', 'booking-package')), |
| 216 |
'9' => array('key' => 9, 'name' => __('Sep', 'booking-package')), |
| 217 |
'10' => array('key' => 10, 'name' => __('Oct', 'booking-package')), |
| 218 |
'11' => array('key' => 11, 'name' => __('Nov', 'booking-package')), |
| 219 |
'12' => array('key' => 12, 'name' => __('Dec', 'booking-package')), |
| 220 |
); |
| 221 |
|
| 222 |
$day = array(); |
| 223 |
for ($i = 1; $i <= 31; $i++) { |
| 224 |
|
| 225 |
$day[$i] = array('key' => $i, 'name' => $i); |
| 226 |
|
| 227 |
} |
| 228 |
|
| 229 |
$yearList = array(); |
| 230 |
for ($i = 0; $i <= 10; $i++) { |
| 231 |
|
| 232 |
$year = date('Y') + $i; |
| 233 |
$yearList[$year] = array('key' => $year, 'name' => $year); |
| 234 |
|
| 235 |
} |
| 236 |
|
| 237 |
$couponsInputTypeList = array( |
| 238 |
'id' => array('key' => 'id', 'name' => __('Coupon code', 'booking-package'), 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', 'target' => 'both'), |
| 239 |
'name' => array('key' => 'name', 'name' => __('Name', 'booking-package'), 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', 'target' => 'both', 'filterHookKey' => 'dynamicTextModification'), |
| 240 |
'description' => array('key' => 'description', 'name' => __('Description', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXTAREA', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => '', 'filterHookKey' => 'dynamicTextModification'), |
| 241 |
'active' => array('key' => 'active', 'name' => __('Status', 'booking-package'), 'value' => 'true', 'inputLimit' => 2, 'inputType' => 'CHECK', 'valueList' => array('1' => 'Enabled'), "class" => ""), |
| 242 |
'target' => array('key' => 'target', 'name' => __('Target', 'booking-package'), 'value' => 'customers', 'inputLimit' => 1, 'inputType' => 'RADIO', 'target' => 'both', 'valueList' => array('visitors' => __('Customers', 'booking-package'), 'users' => __('Users', 'booking-package')), "class" => ""), |
| 243 |
'limited' => array('key' => 'limited', 'name' => __('Coupon Usage', 'booking-package'), 'value' => 'unlimited', 'inputLimit' => 1, 'inputType' => 'RADIO', 'target' => 'both', 'valueList' => array('unlimited' => __('Unlimited Usage', 'booking-package'), 'limited' => __('One-Time Use Per User', 'booking-package')), "class" => ""), |
| 244 |
'expirationDate' => array( |
| 245 |
'key' => 'expirationDate', |
| 246 |
'name' => __('Expiration Date', 'booking-package'), |
| 247 |
'target' => 'both', |
| 248 |
'disabled' => 0, |
| 249 |
'value' => '1', |
| 250 |
'inputLimit' => 2, |
| 251 |
'inputType' => 'MULTIPLE_FIELDS', |
| 252 |
'isExtensionsValid' => 1, |
| 253 |
'option' => 0, |
| 254 |
'valueList' => array( |
| 255 |
0 => array( |
| 256 |
'key' => 'expirationDateStatus', |
| 257 |
'name' => '', |
| 258 |
'value' => '0', |
| 259 |
'inputType' => 'CHECK', |
| 260 |
'isExtensionsValid' => 1, |
| 261 |
'actions' => null, |
| 262 |
'valueList' => array('1' => __('Enabled', 'booking-package')), |
| 263 |
), |
| 264 |
1 => array( |
| 265 |
'key' => 'expirationDateFromMonth', |
| 266 |
'name' => __('From', 'booking-package') . ': ', |
| 267 |
'value' => null, |
| 268 |
'inputType' => 'SELECT', |
| 269 |
'isExtensionsValid' => 1, |
| 270 |
'className' => 'expirationDateFrom', |
| 271 |
'actions' => null, |
| 272 |
'valueList' => $month, |
| 273 |
), |
| 274 |
2 => array( |
| 275 |
'key' => 'expirationDateFromDay', |
| 276 |
'name' => '', |
| 277 |
'value' => '', |
| 278 |
'inputType' => 'SELECT', |
| 279 |
'isExtensionsValid' => 1, |
| 280 |
'className' => 'expirationDateFrom', |
| 281 |
'actions' => null, |
| 282 |
'valueList' => $day, |
| 283 |
), |
| 284 |
3 => array( |
| 285 |
'key' => 'expirationDateFromYear', |
| 286 |
'name' => '', |
| 287 |
'value' => '', |
| 288 |
'inputType' => 'SELECT', |
| 289 |
'isExtensionsValid' => 1, |
| 290 |
'className' => 'expirationDateFrom', |
| 291 |
'actions' => null, |
| 292 |
'valueList' => $yearList, |
| 293 |
), |
| 294 |
4 => array( |
| 295 |
'key' => 'expirationDateToMonth', |
| 296 |
'name' => __('To', 'booking-package') . ': ', |
| 297 |
'value' => null, |
| 298 |
'inputType' => 'SELECT', |
| 299 |
'isExtensionsValid' => 1, |
| 300 |
'className' => 'expirationDateTo', |
| 301 |
'actions' => null, |
| 302 |
'valueList' => $month, |
| 303 |
), |
| 304 |
5 => array( |
| 305 |
'key' => 'expirationDateToDay', |
| 306 |
'name' => '', |
| 307 |
'value' => '', |
| 308 |
'inputType' => 'SELECT', |
| 309 |
'isExtensionsValid' => 1, |
| 310 |
'className' => 'expirationDateTo', |
| 311 |
'actions' => null, |
| 312 |
'valueList' => $day, |
| 313 |
), |
| 314 |
6 => array( |
| 315 |
'key' => 'expirationDateToYear', |
| 316 |
'name' => '', |
| 317 |
'value' => '', |
| 318 |
'inputType' => 'SELECT', |
| 319 |
'isExtensionsValid' => 1, |
| 320 |
'className' => 'expirationDateTo', |
| 321 |
'actions' => null, |
| 322 |
'valueList' => $yearList, |
| 323 |
), |
| 324 |
), |
| 325 |
), |
| 326 |
'method' => array('key' => 'method', 'name' => __('Discount Type', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'RADIO', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => array('subtraction' => __('Fixed Amount Discount', 'booking-package'), 'multiplication' => __('Percentage Discount', 'booking-package'))), |
| 327 |
'value' => array('key' => 'value', 'name' => __('Value', 'booking-package'), 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => ''), |
| 328 |
); |
| 329 |
|
| 330 |
return $couponsInputTypeList; |
| 331 |
} |
| 332 |
|
| 333 |
public function getCurrencies() { |
| 334 |
|
| 335 |
$currencies = array ( |
| 336 |
'aed' => array('name' => 'AED - United Arab Emirates Dirham', 'ISOdigits' => 2, 'decimals' => 2), |
| 337 |
'afn' => array('name' => 'AFN - Afghan Afghani', 'ISOdigits' => 2, 'decimals' => 2), |
| 338 |
'all' => array('name' => 'ALL - Albanian Lek', 'ISOdigits' => 2, 'decimals' => 2), |
| 339 |
'amd' => array('name' => 'AMD - Armenian Dram', 'ISOdigits' => 2, 'decimals' => 2), |
| 340 |
'ang' => array('name' => 'ANG - Netherlands Antillean Guilder', 'ISOdigits' => 2, 'decimals' => 2), |
| 341 |
'aoa' => array('name' => 'AOA - Angolan Kwanza', 'ISOdigits' => 2, 'decimals' => 2), |
| 342 |
'ars' => array('name' => 'ARS - Argentine Peso', 'ISOdigits' => 2, 'decimals' => 2), |
| 343 |
'aud' => array('name' => 'AUD - Australian Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 344 |
'awg' => array('name' => 'AWG - Aruban Florin', 'ISOdigits' => 2, 'decimals' => 2), |
| 345 |
'azn' => array('name' => 'AZN - Azerbaijani Manat', 'ISOdigits' => 2, 'decimals' => 2), |
| 346 |
'bam' => array('name' => 'BAM - Bosnia and Herzegovina Convertible Mark', 'ISOdigits' => 2, 'decimals' => 2), |
| 347 |
'bbd' => array('name' => 'BBD - Barbadian Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 348 |
'bdt' => array('name' => 'BDT - Bangladeshi Taka', 'ISOdigits' => 2, 'decimals' => 2), |
| 349 |
'bgn' => array('name' => 'BGN - Bulgarian Lev', 'ISOdigits' => 2, 'decimals' => 2), |
| 350 |
'bhd' => array('name' => 'BHD - Bahraini Dinar', 'ISOdigits' => 3, 'decimals' => 3), |
| 351 |
'bif' => array('name' => 'BIF - Burundian Franc', 'ISOdigits' => 0, 'decimals' => 2), |
| 352 |
'bmd' => array('name' => 'BMD - Bermudian Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 353 |
'bnd' => array('name' => 'BND - Brunei Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 354 |
'bob' => array('name' => 'BOB - Bolivian Boliviano', 'ISOdigits' => 2, 'decimals' => 2), |
| 355 |
'brl' => array('name' => 'BRL - Brazilian Real', 'ISOdigits' => 2, 'decimals' => 2), |
| 356 |
'bsd' => array('name' => 'BSD - Bahamian Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 357 |
'btn' => array('name' => 'BTN - Bhutanese Ngultrum', 'ISOdigits' => 2, 'decimals' => 2), |
| 358 |
'bwp' => array('name' => 'BWP - Botswana Pula', 'ISOdigits' => 2, 'decimals' => 2), |
| 359 |
'byn' => array('name' => 'BYN - Belarusian Ruble', 'ISOdigits' => 2, 'decimals' => 2), |
| 360 |
'bzd' => array('name' => 'BZD - Belize Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 361 |
'cad' => array('name' => 'CAD - Canadian Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 362 |
'cdf' => array('name' => 'CDF - Congolese Franc', 'ISOdigits' => 2, 'decimals' => 2), |
| 363 |
'chf' => array('name' => 'CHF - Swiss Franc', 'ISOdigits' => 2, 'decimals' => 2), |
| 364 |
'ckd' => array('name' => 'CKD - Cook Islands Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 365 |
'clp' => array('name' => 'CLP - Chilean Peso', 'ISOdigits' => 0, 'decimals' => 0), |
| 366 |
'cny' => array('name' => 'CNY - Chinese Yuan', 'ISOdigits' => 2, 'decimals' => 2), |
| 367 |
'cop' => array('name' => 'COP - Colombian Peso', 'ISOdigits' => 2, 'decimals' => 2), |
| 368 |
'crc' => array('name' => 'CRC - Costa Rican Colon', 'ISOdigits' => 2, 'decimals' => 2), |
| 369 |
'cuc' => array('name' => 'CUC - Cuban convertible Peso', 'ISOdigits' => 2, 'decimals' => 2), |
| 370 |
'cup' => array('name' => 'CUP - Cuban Peso', 'ISOdigits' => 2, 'decimals' => 2), |
| 371 |
'cve' => array('name' => 'CVE - Cabo Verdean Escudo', 'ISOdigits' => 2, 'decimals' => 2), |
| 372 |
'czk' => array('name' => 'CZK - Czech Koruna', 'ISOdigits' => 2, 'decimals' => 2), |
| 373 |
'djf' => array('name' => 'DJF - Djiboutian Franc', 'ISOdigits' => 0, 'decimals' => 2), |
| 374 |
'dkk' => array('name' => 'DKK - Danish Krone', 'ISOdigits' => 2, 'decimals' => 2), |
| 375 |
'dop' => array('name' => 'DOP - Dominican Peso', 'ISOdigits' => 2, 'decimals' => 2), |
| 376 |
'dzd' => array('name' => 'DZD - Algerian Dinar', 'ISOdigits' => 2, 'decimals' => 2), |
| 377 |
'egp' => array('name' => 'EGP - Egyptian Pound', 'ISOdigits' => 2, 'decimals' => 2), |
| 378 |
'ehp' => array('name' => 'EHP - Sahrawi Peseta', 'ISOdigits' => 2, 'decimals' => 2), |
| 379 |
'ern' => array('name' => 'ERN - Eritrean Nakfa', 'ISOdigits' => 2, 'decimals' => 2), |
| 380 |
'etb' => array('name' => 'ETB - Ethiopian Birr', 'ISOdigits' => 2, 'decimals' => 2), |
| 381 |
'eur' => array('name' => 'EUR - Euro', 'ISOdigits' => 2, 'decimals' => 2), |
| 382 |
'fjd' => array('name' => 'FJD - Fijian Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 383 |
'fkp' => array('name' => 'FKP - Falkland Islands Pound', 'ISOdigits' => 2, 'decimals' => 2), |
| 384 |
'fok' => array('name' => 'FOK - Faroese Króna', 'ISOdigits' => 2, 'decimals' => 2), |
| 385 |
'gbp' => array('name' => 'GBP - Pound Sterling', 'ISOdigits' => 2, 'decimals' => 2), |
| 386 |
'gel' => array('name' => 'GEL - Georgian Lari', 'ISOdigits' => 2, 'decimals' => 2), |
| 387 |
'ggp' => array('name' => 'GGP - Guernsey Pound', 'ISOdigits' => 2, 'decimals' => 2), |
| 388 |
'ghs' => array('name' => 'GHS - Ghanaian Cedi', 'ISOdigits' => 2, 'decimals' => 2), |
| 389 |
'gip' => array('name' => 'GIP - Gibraltar Pound', 'ISOdigits' => 2, 'decimals' => 2), |
| 390 |
'gmd' => array('name' => 'GMD - Gambian Dalasi', 'ISOdigits' => 2, 'decimals' => 2), |
| 391 |
'gnf' => array('name' => 'GNF - Guinean Franc', 'ISOdigits' => 0, 'decimals' => 2), |
| 392 |
'gtq' => array('name' => 'GTQ - Guatemalan Quetzal', 'ISOdigits' => 2, 'decimals' => 2), |
| 393 |
'gyd' => array('name' => 'GYD - Guyanese Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 394 |
'hkd' => array('name' => 'HKD - Hong Kong Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 395 |
'hnl' => array('name' => 'HNL - Honduran Lempira', 'ISOdigits' => 2, 'decimals' => 2), |
| 396 |
'hrk' => array('name' => 'HRK - Croatian Kuna', 'ISOdigits' => 2, 'decimals' => 2), |
| 397 |
'htg' => array('name' => 'HTG - Haitian Gourde', 'ISOdigits' => 2, 'decimals' => 2), |
| 398 |
'huf' => array('name' => 'HUF - Hungarian Forint', 'ISOdigits' => 2, 'decimals' => 2), |
| 399 |
'idr' => array('name' => 'IDR - Indonesian Rupiah', 'ISOdigits' => 2, 'decimals' => 2), |
| 400 |
'ils' => array('name' => 'ILS - Israeli new Shekel', 'ISOdigits' => 2, 'decimals' => 2), |
| 401 |
'imp' => array('name' => 'IMP - Manx Pound', 'ISOdigits' => 2, 'decimals' => 2), |
| 402 |
'inr' => array('name' => 'INR - Indian Rupee', 'ISOdigits' => 2, 'decimals' => 2), |
| 403 |
'iqd' => array('name' => 'IQD - Iraqi Dinar', 'ISOdigits' => 3, 'decimals' => 3), |
| 404 |
'irr' => array('name' => 'IRR - Iranian Rial', 'ISOdigits' => 2, 'decimals' => 2), |
| 405 |
'isk' => array('name' => 'ISK - Icelandic Krona', 'ISOdigits' => 0, 'decimals' => 2), |
| 406 |
'jep' => array('name' => 'JEP - Jersey Pound', 'ISOdigits' => 2, 'decimals' => 2), |
| 407 |
'jmd' => array('name' => 'JMD - Jamaican Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 408 |
'jod' => array('name' => 'JOD - Jordanian Dinar', 'ISOdigits' => 3, 'decimals' => 3), |
| 409 |
'jpy' => array('name' => 'JPY - Japanese Yen', 'ISOdigits' => 0, 'decimals' => 2), |
| 410 |
'kes' => array('name' => 'KES - Kenyan Shilling', 'ISOdigits' => 2, 'decimals' => 2), |
| 411 |
'kgs' => array('name' => 'KGS - Kyrgyzstani Som', 'ISOdigits' => 2, 'decimals' => 2), |
| 412 |
'khr' => array('name' => 'KHR - Cambodian Riel', 'ISOdigits' => 2, 'decimals' => 2), |
| 413 |
'kid' => array('name' => 'KID - Kiribati Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 414 |
'kmf' => array('name' => 'KMF - Comorian Franc', 'ISOdigits' => 0, 'decimals' => 2), |
| 415 |
'kpw' => array('name' => 'KPW - North Korean Won', 'ISOdigits' => 2, 'decimals' => 2), |
| 416 |
'krw' => array('name' => 'KRW - South Korean Won', 'ISOdigits' => 0, 'decimals' => 2), |
| 417 |
'kwd' => array('name' => 'KWD - Kuwaiti Dinar', 'ISOdigits' => 3, 'decimals' => 3), |
| 418 |
'kyd' => array('name' => 'KYD - Cayman Islands Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 419 |
'kzt' => array('name' => 'KZT - Kazakhstani Tenge', 'ISOdigits' => 2, 'decimals' => 2), |
| 420 |
'lak' => array('name' => 'LAK - Lao Kip', 'ISOdigits' => 2, 'decimals' => 2), |
| 421 |
'lbp' => array('name' => 'LBP - Lebanese Pound', 'ISOdigits' => 2, 'decimals' => 2), |
| 422 |
'lkr' => array('name' => 'LKR - Sri Lankan Rupee', 'ISOdigits' => 2, 'decimals' => 2), |
| 423 |
'lrd' => array('name' => 'LRD - Liberian Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 424 |
'lsl' => array('name' => 'LSL - Lesotho Loti', 'ISOdigits' => 2, 'decimals' => 2), |
| 425 |
'lyd' => array('name' => 'LYD - Libyan Dinar', 'ISOdigits' => 3, 'decimals' => 3), |
| 426 |
'mad' => array('name' => 'MAD - Moroccan Dirham', 'ISOdigits' => 2, 'decimals' => 2), |
| 427 |
'mdl' => array('name' => 'MDL - Moldovan Leu', 'ISOdigits' => 2, 'decimals' => 2), |
| 428 |
'mga' => array('name' => 'MGA - Malagasy Ariary', 'ISOdigits' => 2, 'decimals' => 0), |
| 429 |
'mkd' => array('name' => 'MKD - Macedonian Denar', 'ISOdigits' => 2, 'decimals' => 2), |
| 430 |
'mmk' => array('name' => 'MMK - Myanmar Kyat', 'ISOdigits' => 2, 'decimals' => 2), |
| 431 |
'mnt' => array('name' => 'MNT - Mongolian Tögrög', 'ISOdigits' => 2, 'decimals' => 2), |
| 432 |
'mop' => array('name' => 'MOP - Macanese Pataca', 'ISOdigits' => 2, 'decimals' => 2), |
| 433 |
'mru' => array('name' => 'MRU - Mauritanian Ouguiya', 'ISOdigits' => 2, 'decimals' => 0), |
| 434 |
'mur' => array('name' => 'MUR - Mauritian Rupee', 'ISOdigits' => 2, 'decimals' => 2), |
| 435 |
'mvr' => array('name' => 'MVR - Maldivian Rufiyaa', 'ISOdigits' => 2, 'decimals' => 2), |
| 436 |
'mwk' => array('name' => 'MWK - Malawian Kwacha', 'ISOdigits' => 2, 'decimals' => 2), |
| 437 |
'mxn' => array('name' => 'MXN - Mexican Peso', 'ISOdigits' => 2, 'decimals' => 2), |
| 438 |
'myr' => array('name' => 'MYR - Malaysian Ringgit', 'ISOdigits' => 2, 'decimals' => 2), |
| 439 |
'mzn' => array('name' => 'MZN - Mozambican Metical', 'ISOdigits' => 2, 'decimals' => 2), |
| 440 |
'nad' => array('name' => 'NAD - Namibian Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 441 |
'ngn' => array('name' => 'NGN - Nigerian Naira', 'ISOdigits' => 2, 'decimals' => 2), |
| 442 |
'nio' => array('name' => 'NIO - Nicaraguan Córdoba', 'ISOdigits' => 2, 'decimals' => 2), |
| 443 |
'nok' => array('name' => 'NOK - Norwegian Krone', 'ISOdigits' => 2, 'decimals' => 2), |
| 444 |
'npr' => array('name' => 'NPR - Nepalese Rupee', 'ISOdigits' => 2, 'decimals' => 2), |
| 445 |
'nzd' => array('name' => 'NZD - New Zealand Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 446 |
'omr' => array('name' => 'OMR - Omani Rial', 'ISOdigits' => 3, 'decimals' => 3), |
| 447 |
'pab' => array('name' => 'PAB - Panamanian Balboa', 'ISOdigits' => 2, 'decimals' => 2), |
| 448 |
'pen' => array('name' => 'PEN - Peruvian Sol', 'ISOdigits' => 2, 'decimals' => 2), |
| 449 |
'pgk' => array('name' => 'PGK - Papua New Guinean Kina', 'ISOdigits' => 2, 'decimals' => 2), |
| 450 |
'php' => array('name' => 'PHP - Philippine Peso', 'ISOdigits' => 2, 'decimals' => 2), |
| 451 |
'pkr' => array('name' => 'PKR - Pakistani Rupee', 'ISOdigits' => 2, 'decimals' => 2), |
| 452 |
'pln' => array('name' => 'PLN - Polish Zloty', 'ISOdigits' => 2, 'decimals' => 2), |
| 453 |
'pnd' => array('name' => 'PND - Pitcairn Islands Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 454 |
'prb' => array('name' => 'PRB - Transnistrian Ruble', 'ISOdigits' => 2, 'decimals' => 2), |
| 455 |
'pyg' => array('name' => 'PYG - Paraguayan Guaraní', 'ISOdigits' => 0, 'decimals' => 2), |
| 456 |
'qar' => array('name' => 'QAR - Qatari Riyal', 'ISOdigits' => 2, 'decimals' => 2), |
| 457 |
'ron' => array('name' => 'RON - Romanian Leu', 'ISOdigits' => 2, 'decimals' => 2), |
| 458 |
'rsd' => array('name' => 'RSD - Serbian Dinar', 'ISOdigits' => 2, 'decimals' => 2), |
| 459 |
'rub' => array('name' => 'RUB - Russian Ruble', 'ISOdigits' => 2, 'decimals' => 2), |
| 460 |
'rwf' => array('name' => 'RWF - Rwandan Franc', 'ISOdigits' => 0, 'decimals' => 2), |
| 461 |
'sar' => array('name' => 'SAR - Saudi Riyal', 'ISOdigits' => 2, 'decimals' => 2), |
| 462 |
'sbd' => array('name' => 'SBD - Solomon Islands Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 463 |
'scr' => array('name' => 'SCR - Seychellois Rupee', 'ISOdigits' => 2, 'decimals' => 2), |
| 464 |
'sdg' => array('name' => 'SDG - Sudanese Pound', 'ISOdigits' => 2, 'decimals' => 2), |
| 465 |
'sek' => array('name' => 'SEK - Swedish Krona', 'ISOdigits' => 2, 'decimals' => 2), |
| 466 |
'sgd' => array('name' => 'SGD - Singapore Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 467 |
'shp' => array('name' => 'SHP - Saint Helena Pound', 'ISOdigits' => 2, 'decimals' => 2), |
| 468 |
'sll' => array('name' => 'SLL - Sierra Leonean Leone', 'ISOdigits' => 2, 'decimals' => 2), |
| 469 |
'sls' => array('name' => 'SLS - Somaliland Shilling', 'ISOdigits' => 2, 'decimals' => 2), |
| 470 |
'sos' => array('name' => 'SOS - Somali Shilling', 'ISOdigits' => 2, 'decimals' => 2), |
| 471 |
'srd' => array('name' => 'SRD - Surinamese Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 472 |
'ssp' => array('name' => 'SSP - South Sudanese Pound', 'ISOdigits' => 2, 'decimals' => 2), |
| 473 |
'stn' => array('name' => 'STN - Sao Tome and Príncipe Dobra', 'ISOdigits' => 2, 'decimals' => 2), |
| 474 |
'svc' => array('name' => 'SVC - Salvadoran Colón', 'ISOdigits' => 2, 'decimals' => 2), |
| 475 |
'syp' => array('name' => 'SYP - Syrian Pound', 'ISOdigits' => 2, 'decimals' => 2), |
| 476 |
'szl' => array('name' => 'SZL - Swazi Lilangeni', 'ISOdigits' => 2, 'decimals' => 2), |
| 477 |
'thb' => array('name' => 'THB - Thai Baht', 'ISOdigits' => 2, 'decimals' => 2), |
| 478 |
'tjs' => array('name' => 'TJS - Tajikistani Somoni', 'ISOdigits' => 2, 'decimals' => 2), |
| 479 |
'tmt' => array('name' => 'TMT - Turkmenistan Manat', 'ISOdigits' => 2, 'decimals' => 2), |
| 480 |
'tnd' => array('name' => 'TND - Tunisian Dinar', 'ISOdigits' => 3, 'decimals' => 3), |
| 481 |
'top' => array('name' => 'TOP - Tongan Paʻanga', 'ISOdigits' => 2, 'decimals' => 2), |
| 482 |
'try' => array('name' => 'TRY - Turkish Lira', 'ISOdigits' => 2, 'decimals' => 2), |
| 483 |
'ttd' => array('name' => 'TTD - Trinidad and Tobago Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 484 |
'tvd' => array('name' => 'TVD - Tuvaluan Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 485 |
'twd' => array('name' => 'TWD - New Taiwan Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 486 |
'tzs' => array('name' => 'TZS - Tanzanian Shilling', 'ISOdigits' => 2, 'decimals' => 2), |
| 487 |
'uah' => array('name' => 'UAH - Ukrainian Hryvnia', 'ISOdigits' => 2, 'decimals' => 2), |
| 488 |
'ugx' => array('name' => 'UGX - Ugandan Shilling', 'ISOdigits' => 0, 'decimals' => 2), |
| 489 |
'usd' => array('name' => 'USD - United States Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 490 |
'uyu' => array('name' => 'UYU - Uruguayan Peso', 'ISOdigits' => 2, 'decimals' => 2), |
| 491 |
'uzs' => array('name' => 'UZS - Uzbekistani Som', 'ISOdigits' => 2, 'decimals' => 2), |
| 492 |
'ved' => array('name' => 'VED - Venezuelan bolívar digital', 'ISOdigits' => 2, 'decimals' => 2), |
| 493 |
'ves' => array('name' => 'VES - Venezuelan Bolívar Soberano', 'ISOdigits' => 2, 'decimals' => 2), |
| 494 |
'vnd' => array('name' => 'VND - Vietnamese Dong', 'ISOdigits' => 0, 'decimals' => 2), |
| 495 |
'vuv' => array('name' => 'VUV - Vanuatu Vatu', 'ISOdigits' => 0, 'decimals' => 0), |
| 496 |
'wst' => array('name' => 'WST - Samoan Tala', 'ISOdigits' => 2, 'decimals' => 2), |
| 497 |
'xaf' => array('name' => 'XAF - Central African CFA Franc BEAC', 'ISOdigits' => 0, 'decimals' => 2), |
| 498 |
'xcd' => array('name' => 'XCD - East Caribbean Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 499 |
'xof' => array('name' => 'XOF - West African CFA Franc BCEAO', 'ISOdigits' => 0, 'decimals' => 2), |
| 500 |
'xpf' => array('name' => 'XPF - CFP Franc (Franc Pacifique)', 'ISOdigits' => 0, 'decimals' => 0), |
| 501 |
'yer' => array('name' => 'YER - Yemeni Rial', 'ISOdigits' => 2, 'decimals' => 2), |
| 502 |
'zar' => array('name' => 'ZAR - South African Rand', 'ISOdigits' => 2, 'decimals' => 2), |
| 503 |
'zmw' => array('name' => 'ZMW - Zambian Kwacha', 'ISOdigits' => 2, 'decimals' => 2), |
| 504 |
'zwb' => array('name' => 'ZWB - RTGS Dollar', 'ISOdigits' => 0, 'decimals' => 0), |
| 505 |
'zwl' => array('name' => 'ZWL - Zimbabwean Dollar', 'ISOdigits' => 2, 'decimals' => 2), |
| 506 |
); |
| 507 |
|
| 508 |
return $currencies; |
| 509 |
|
| 510 |
} |
| 511 |
|
| 512 |
public function getList(){ |
| 513 |
|
| 514 |
$list = array( |
| 515 |
"General" => array( |
| 516 |
'site_name' => array('name' => __('Site Name', 'booking-package'), 'value' => 'Site Name', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 517 |
'account_email_address' => array( |
| 518 |
'key' => 'email_address', |
| 519 |
'name' => __('Email Address', 'booking-package'), |
| 520 |
'target' => 'both', |
| 521 |
'disabled' => 0, |
| 522 |
'value' => '1', |
| 523 |
'inputLimit' => 2, |
| 524 |
'inputType' => 'MULTIPLE_FIELDS', |
| 525 |
'isExtensionsValid' => 0, |
| 526 |
'option' => 0, |
| 527 |
'valueList' => array( |
| 528 |
0 => array( |
| 529 |
'key' => 'email_to', |
| 530 |
'name' => __('Recipient Email Address', 'booking-package') . ': ', |
| 531 |
'value' => '', |
| 532 |
'inputType' => 'TEXT', |
| 533 |
'isExtensionsValid' => 0, |
| 534 |
'actions' => null, |
| 535 |
'valueList' => array(), |
| 536 |
), |
| 537 |
1 => array( |
| 538 |
'key' => 'email_title_from', |
| 539 |
'name' => __('Sender Name', 'booking-package') . ': ', |
| 540 |
'value' => '', |
| 541 |
'inputType' => 'TEXT', |
| 542 |
'isExtensionsValid' => 0, |
| 543 |
'actions' => null, |
| 544 |
'valueList' => array(), |
| 545 |
), |
| 546 |
2 => array( |
| 547 |
'key' => 'email_from', |
| 548 |
'name' => __('Sending Email Address', 'booking-package') . ': ', |
| 549 |
'value' => '', |
| 550 |
'inputType' => 'TEXT', |
| 551 |
'isExtensionsValid' => 0, |
| 552 |
'actions' => null, |
| 553 |
'valueList' => array(), |
| 554 |
), |
| 555 |
), |
| 556 |
), |
| 557 |
/** |
| 558 |
'email_to' => array('name' => __('Recipient Email Address', 'booking-package'), 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 559 |
'email_from' => array('name' => __('Sending Email Address', 'booking-package'), 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 560 |
'email_title_from' => array('name' => __('Sender Name', 'booking-package'), 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 561 |
**/ |
| 562 |
'country' => array('name' => __('Country', 'booking-package'), 'value' => 'US', 'isExtensionsValid' => 0, 'inputLimit' => 2, 'inputType' => 'SELECT_GROUP', 'valueList' => array()), |
| 563 |
'currency' => array('name' => __('Currency', 'booking-package'), 'value' => 'usd', 'isExtensionsValid' => 0, 'inputLimit' => 2, 'inputType' => 'SELECT', 'valueList' => |
| 564 |
array( |
| 565 |
'usd' => 'USD - United States of America', |
| 566 |
'gbp' => 'GBP - United Kingdom', |
| 567 |
'eur' => 'EUR - EU', |
| 568 |
'jpy' => 'JPY - 日本円', |
| 569 |
'dkk' => 'DKK - Dansk krone', |
| 570 |
'cny' => 'CNY - 人民币', |
| 571 |
'twd' => 'TWD - 台湾� |
| 572 |
�', |
| 573 |
'thb' => 'THB - Thai Baht', |
| 574 |
'cop' => 'COP - Peso Colombiano', |
| 575 |
'cad' => 'CAD - Canadian Dollar', |
| 576 |
'aud' => 'AUD - Australian Dollar', |
| 577 |
'huf' => 'HUF - Magyar forint', |
| 578 |
'php' => 'PHP - Philippine Peso', |
| 579 |
'chf' => 'CHF - Swiss franc', |
| 580 |
'czk' => 'CZK - Koruna česká', |
| 581 |
'rub' => 'RUB - Российский рубль', |
| 582 |
'nzd' => 'NZD - New Zealand Dollar', |
| 583 |
'hrk' => 'HRK - Croatian kuna', |
| 584 |
'uah' => 'UAH - Українська гривня', |
| 585 |
'brl' => 'BRL - Real brasileiro', |
| 586 |
'krw' => 'KRW - 한국 원', |
| 587 |
'aed' => 'AED - United Arab Emirates', |
| 588 |
'gtq' => 'GTQ - Guatemalan Quetzal', |
| 589 |
'mxn' => 'MXN - Peso Mexicano', |
| 590 |
'ars' => 'ARS - Peso Argentino', |
| 591 |
'zar' => 'ZAR - South African Rand', |
| 592 |
'try' => 'TRY - Türk Lirası', |
| 593 |
'sek' => 'SEK - Svensk krona', |
| 594 |
'ron' => 'RON - Leu românesc', |
| 595 |
'inr' => 'INR - भारतीय रुपया', |
| 596 |
'sgd' => 'SGD - Singapore Dollar', |
| 597 |
'idr' => 'IDR - Rupiah Indonesia', |
| 598 |
) |
| 599 |
), |
| 600 |
'timezone' => array('name' => __('Default Timezone', 'booking-package'), 'value' => 'UTC', 'isExtensionsValid' => 0, 'inputLimit' => 2, 'inputType' => 'SELECT_TIMEZONE', 'valueList' => array()), |
| 601 |
'dateFormat' => array('name' => __('Date Format', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 0, 'inputLimit' => 2, 'inputType' => 'SELECT', 'valueList' => array()), |
| 602 |
'clock' => array('key' => 'clock', 'name' => __('Time Format', 'booking-package'), 'value' => '24hours', 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => |
| 603 |
array( |
| 604 |
'12a.m.p.m' => __('09:00 a.m.', 'booking-package'), |
| 605 |
'12ampm' => __('09:00 am', 'booking-package'), |
| 606 |
'12AMPM' => __('03:00 PM', 'booking-package'), |
| 607 |
'24hours' => '17:00' |
| 608 |
) |
| 609 |
), |
| 610 |
'positionTimeDate' => array('key' => 'positionTimeDate', 'name' => __('Position of Date and Time', 'booking-package'), 'value' => 'dateTime', 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => |
| 611 |
array( |
| 612 |
'timeDate' => __('Time', 'booking-package') . ' - ' . __('Date', 'booking-package'), |
| 613 |
'dateTime' => __('Date', 'booking-package') . ' - ' . __('Time', 'booking-package'), |
| 614 |
) |
| 615 |
), |
| 616 |
'positionOfWeek' => array('name' => __('Position of the Day of the Week', 'booking-package'), 'value' => 'before', 'isExtensionsValid' => 0, 'inputLimit' => 2, 'inputType' => 'RADIO', 'valueList' => array('before' => __('Before the date', 'booking-package'), 'after' => __('After the date', 'booking-package'))), |
| 617 |
'automaticApprove' => array('name' => __('Automatically Approve Bookings', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 0, 'inputLimit' => 2, 'inputType' => 'CHECK', 'valueList' => array('1' => __('Enabled', 'booking-package'))), |
| 618 |
'dataRetentionPeriod' => array('name' => __('Customer Data Retention Period', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 0, 'inputLimit' => 2, 'inputType' => 'SELECT', 'valueList' => |
| 619 |
array( |
| 620 |
'0' => __('Forever', 'booking-package'), |
| 621 |
'30' => sprintf(__('%d days', 'booking-package'), 30), |
| 622 |
'90' => sprintf(__('%d days', 'booking-package'), 90), |
| 623 |
'180' => sprintf(__('%d days', 'booking-package'), 180), |
| 624 |
'365' => sprintf(__('%d year', 'booking-package'), 1), |
| 625 |
'730' => sprintf(__('%d years', 'booking-package'), 2), |
| 626 |
'1095' => sprintf(__('%d years', 'booking-package'), 3), |
| 627 |
'1460' => sprintf(__('%d years', 'booking-package'), 4), |
| 628 |
'1825' => sprintf(__('%d years', 'booking-package'), 5), |
| 629 |
) |
| 630 |
), |
| 631 |
'ajax_url' => array('name' => __('AJAX URL for Public Page', 'booking-package'), 'value' => 'top', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'SELECT', 'valueList' => |
| 632 |
array( |
| 633 |
/** 'ajax' => plugins_url() . '/booking-package/ajax.php', **/ |
| 634 |
'top' => get_home_url(), |
| 635 |
'admin-ajax' => admin_url('admin-ajax.php'), |
| 636 |
'rest_url' => rest_url( 'booking-package/v1/request' ), |
| 637 |
)), |
| 638 |
'ajax_nonce_function' => array('name' => __('AJAX Nonce Validation Function', 'booking-package'), 'value' => 'custom_nonce_validation', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('check_ajax_referer' => 'check_ajax_referer()', 'wp_verify_nonce' => 'wp_verify_nonce()', 'custom_nonce_validation' => __('Use custom plugin nonce validation', 'booking-package'))), |
| 639 |
|
| 640 |
'javascriptSyntaxErrorNotification' => array('name' => __('Notify Developers on JavaScript Errors', 'booking-package'), 'deprecated' => false, 'value' => 1, 'isExtensionsValid' => 0, 'inputLimit' => 2, 'inputType' => 'CHECK', 'valueList' => array('1' => __('Automatically notify developers', 'booking-package'))), |
| 641 |
|
| 642 |
'characterCodeOfDownloadFile' => array('name' => __('Download File Character Encoding', 'booking-package'), 'value' => 'UTF-8', 'isExtensionsValid' => 0, 'inputLimit' => 2, 'inputType' => 'RADIO', 'valueList' => array('UTF-8' => 'UTF-8', 'EUC-JP' => 'EUC-JP', 'SJIS' => 'SJIS')), |
| 643 |
'lineBreakCodesInCsv' => array('name' => __('CSV File Line Break Code', 'booking-package'), 'value' => 'LF', 'isExtensionsValid' => 0, 'inputLimit' => 2, 'inputType' => 'RADIO', 'valueList' => array('LF' => 'LF', 'CRLF' => 'CRLF')), |
| 644 |
|
| 645 |
'googleAnalytics' => array('name' => __('Tracking ID for Google Analytics', 'booking-package'), 'deprecated' => true, 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 646 |
|
| 647 |
'customizeStatus' => array( |
| 648 |
'key' => 'customizeStatus', |
| 649 |
'name' => __('Color Settings for Booking Status', 'booking-package'), |
| 650 |
'disabled' => 0, |
| 651 |
'value' => '1', |
| 652 |
'inputLimit' => 2, |
| 653 |
'inputType' => 'MULTIPLE_FIELDS', |
| 654 |
'isExtensionsValid' => 0, |
| 655 |
'option' => 0, |
| 656 |
'valueList' => array( |
| 657 |
0 => array( |
| 658 |
'key' => 'statusFontColor', |
| 659 |
'name' => __('Font Color', 'booking-package') . ': ', |
| 660 |
'value' => '#fff', |
| 661 |
'inputType' => 'COLOR', |
| 662 |
'className' => 'multiple_fields_margin_top', |
| 663 |
'isExtensionsValid' => 0, |
| 664 |
'actions' => null, |
| 665 |
'valueList' => array(), |
| 666 |
), |
| 667 |
1 => array( |
| 668 |
'key' => 'statusBackgroundColorForApproved', |
| 669 |
'name' => __('Approved background color', 'booking-package') . ': ', |
| 670 |
'value' => '#98c878', |
| 671 |
'inputType' => 'COLOR', |
| 672 |
'className' => 'multiple_fields_margin_top', |
| 673 |
'isExtensionsValid' => 0, |
| 674 |
'actions' => null, |
| 675 |
'valueList' => array(), |
| 676 |
), |
| 677 |
2 => array( |
| 678 |
'key' => 'statusBackgroundColorForPending', |
| 679 |
'name' => __('Pending background color', 'booking-package') . ': ', |
| 680 |
'value' => '#f06767', |
| 681 |
'inputType' => 'COLOR', |
| 682 |
'className' => 'multiple_fields_margin_top', |
| 683 |
'isExtensionsValid' => 0, |
| 684 |
'actions' => null, |
| 685 |
'valueList' => array(), |
| 686 |
), |
| 687 |
3 => array( |
| 688 |
'key' => 'statusBackgroundColorForCanceled', |
| 689 |
'name' => __('Canceled background color', 'booking-package') . ': ', |
| 690 |
'value' => '#f0c267', |
| 691 |
'inputType' => 'COLOR', |
| 692 |
'className' => 'multiple_fields_margin_top', |
| 693 |
'isExtensionsValid' => 0, |
| 694 |
'actions' => null, |
| 695 |
'valueList' => array(), |
| 696 |
), |
| 697 |
), |
| 698 |
), |
| 699 |
|
| 700 |
|
| 701 |
), |
| 702 |
"Design" => array( |
| 703 |
'autoWindowScroll' => array('name' => __('Automatic Scroll to Top of Booking Form', 'booking-package'), 'value' => '1', 'isExtensionsValid' => 0, 'inputLimit' => 2, 'inputType' => 'CHECK', 'valueList' => array('1' => __('Enabled', 'booking-package'))), |
| 704 |
'headingPosition' => array('name' => __('Use Sticky Positioning for Visitor Calendar', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 0, 'inputLimit' => 2, 'inputType' => 'CHECK', 'valueList' => array('1' => __('Enabled', 'booking-package'))), |
| 705 |
'fontSize' => array('name' => __('Font Size', 'booking-package'), 'value' => '16px', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 706 |
#'fontColor' => array('name' => __('Font color', 'booking-package'), 'value' => '#969696', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT', 'js' => 'colorPicker'), |
| 707 |
'backgroundColor' => array('name' => __('Background Color', 'booking-package'), 'value' => '#FFF', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT', 'js' => 'colorPicker'), |
| 708 |
'calendarBackgroundColorWithSchedule' => array('name' => __('Calendar Background (With Schedule)', 'booking-package'), 'value' => '#FFF', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT', 'js' => 'colorPicker'), |
| 709 |
'calendarBackgroundColorWithNoSchedule' => array('name' => __('Calendar Background (No Schedule)', 'booking-package'), 'value' => '#EEE', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT', 'js' => 'colorPicker'), |
| 710 |
'backgroundColorOfRegularHolidays' => array('name' => __('Background Color of Closed Days', 'booking-package'), 'value' => '#FFD5D5', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT', 'js' => 'colorPicker'), |
| 711 |
|
| 712 |
'scheduleAndServiceBackgroundColor' => array('name' => __('Schedule/Service Item Background', 'booking-package'), 'value' => '#FFF', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT', 'js' => 'colorPicker'), |
| 713 |
'backgroundColorOfSelectedLabel' => array('name' => __('Selection Background Color', 'booking-package'), 'value' => '#EAEDF3', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT', 'js' => 'colorPicker'), |
| 714 |
'mouseHover' => array('name' => __('Link Hover Background Color', 'booking-package'), 'value' => '#EAEDF3', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT', 'js' => 'colorPicker'), |
| 715 |
'borderColor' => array('name' => __('Border Color', 'booking-package'), 'value' => '#ddd', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT', 'js' => 'colorPicker'), |
| 716 |
|
| 717 |
), |
| 718 |
"twilio" => array( |
| 719 |
'twilio_active' => array('name' => __('Active', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('1' => __('Enabled', 'booking-package'), '0' => __('Disabled', 'booking-package'))), |
| 720 |
'twilio_sendingMethod' => array('name' => __('Sending Method', 'booking-package'), 'value' => 'phoneNumber', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('phoneNumber' => __('Phone Number', 'booking-package'), 'senderID' => __('Alphanumeric Sender ID', 'booking-package'))), |
| 721 |
'twilio_sid' => array('name' => __('Account SID', 'booking-package'), 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 722 |
'twilio_service_sid' => array('name' => __('Messaging Service SID', 'booking-package'), 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 723 |
'twilio_token' => array('name' => __('Auth Token', 'booking-package'), 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 724 |
'twilio_countryCode' => array('name' => __('Country Calling Code', 'booking-package'), 'value' => '', 'placeholder' => '+1', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 725 |
'twilio_number' => array('name' => __('Phone Number', 'booking-package'), 'value' => '', 'placeholder' => '+11234567890', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 726 |
), |
| 727 |
"Messaging Services" => array( |
| 728 |
'whatsApp' => array( |
| 729 |
'key' => 'whatsApp', |
| 730 |
'name' => 'WhatsApp', |
| 731 |
'target' => 'day', |
| 732 |
'disabled' => 0, |
| 733 |
'value' => '1', |
| 734 |
'inputLimit' => 2, |
| 735 |
'inputType' => 'MULTIPLE_FIELDS', |
| 736 |
'isExtensionsValid' => 0, |
| 737 |
'option' => 0, |
| 738 |
'valueList' => array( |
| 739 |
0 => array( |
| 740 |
'key' => 'whatsApp_active', |
| 741 |
'name' => '', |
| 742 |
'value' => 0, |
| 743 |
'inputType' => 'RADIO', |
| 744 |
'inputLimit' => 0, |
| 745 |
'isExtensionsValid' => 0, |
| 746 |
'actions' => null, |
| 747 |
'valueList' => array(1 => __('Enabled', 'booking-package'), 0 => __('Disabled', 'booking-package')), |
| 748 |
), |
| 749 |
1 => array( |
| 750 |
'key' => 'whatsApp_countryCode', |
| 751 |
'name' => __('Country Calling Code', 'booking-package') . ': ', |
| 752 |
'value' => null, |
| 753 |
'inputType' => 'TEXT', |
| 754 |
'inputLimit' => 0, |
| 755 |
'placeholder' => '+1', |
| 756 |
'isExtensionsValid' => 0, |
| 757 |
'class' => 'multiple_fields_margin_top', |
| 758 |
'actions' => null, |
| 759 |
'valueList' => array(), |
| 760 |
), |
| 761 |
2 => array( |
| 762 |
'key' => 'whatsApp_phoneId', |
| 763 |
'name' => __('Phone Number ID', 'booking-package') . ': ', |
| 764 |
'value' => null, |
| 765 |
'inputType' => 'TEXT', |
| 766 |
'inputLimit' => 0, |
| 767 |
'isExtensionsValid' => 0, |
| 768 |
'class' => 'multiple_fields_margin_top', |
| 769 |
'actions' => null, |
| 770 |
'valueList' => array(), |
| 771 |
), |
| 772 |
3 => array( |
| 773 |
'key' => 'whatsApp_token', |
| 774 |
'name' => __('Token', 'booking-package') . ': ', |
| 775 |
'value' => null, |
| 776 |
'inputType' => 'TEXT', |
| 777 |
'inputLimit' => 0, |
| 778 |
'isExtensionsValid' => 0, |
| 779 |
'class' => 'multiple_fields_margin_top', |
| 780 |
'actions' => null, |
| 781 |
'valueList' => array(), |
| 782 |
), |
| 783 |
), |
| 784 |
), |
| 785 |
|
| 786 |
), |
| 787 |
|
| 788 |
"Stripe" => array( |
| 789 |
'stripe_active' => array('name' => __('Active', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('1' => __('Enabled', 'booking-package'), '0' => __('Disabled', 'booking-package'))), |
| 790 |
'stripe_public_key' => array('name' => __('Public Key', 'booking-package'), 'value' => '', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 791 |
'stripe_secret_key' => array('name' => __('Secret Key', 'booking-package'), 'value' => '', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 792 |
'stripe_capture_method' => array('name' => __('Capture Method for Payment Intent', 'booking-package'), 'value' => 'automatic', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('automatic' => __('Automatic', 'booking-package'), 'manual' => __('Manual', 'booking-package'))), |
| 793 |
'stripe_konbini_expiration_date' => array('name' => __('Expiration Time Limit for Convenience Store Payments', 'booking-package'), 'value' => '120', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'SELECT', 'valueList' => |
| 794 |
array( |
| 795 |
'60' => sprintf(__('%d minutes', 'booking-package'), 60), |
| 796 |
'120' => sprintf(__('%d minutes', 'booking-package'), 120), |
| 797 |
'180' => sprintf(__('%d minutes', 'booking-package'), 180), |
| 798 |
'360' => sprintf(__('%d minutes', 'booking-package'), 360), |
| 799 |
'720' => sprintf(__('%d minutes', 'booking-package'), 720), |
| 800 |
'1440' => sprintf(__('%d day', 'booking-package'), 1), |
| 801 |
'2880' => sprintf(__('%d days', 'booking-package'), 2), |
| 802 |
'4320' => sprintf(__('%d days', 'booking-package'), 3), |
| 803 |
'5760' => sprintf(__('%d days', 'booking-package'), 4), |
| 804 |
'7200' => sprintf(__('%d days', 'booking-package'), 5), |
| 805 |
'8640' => sprintf(__('%d days', 'booking-package'), 6), |
| 806 |
'10080' => sprintf(__('%d days', 'booking-package'), 7), |
| 807 |
), |
| 808 |
), |
| 809 |
), |
| 810 |
"PayPal" => array( |
| 811 |
'paypal_active' => array('name' => __('Active', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('1' => __('Enabled', 'booking-package'), '0' => __('Disabled', 'booking-package'))), |
| 812 |
'paypal_live' => array('name' => __('Mode', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('1' => __('Live', 'booking-package'), '0' => __('Test', 'booking-package'))), |
| 813 |
'paypal_client_id' => array('name' => __('Client ID', 'booking-package'), 'value' => '', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 814 |
'paypal_secret_key' => array('name' => __('Secret Key', 'booking-package'), 'value' => '', 'isExtensionsValid' => 1, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 815 |
), |
| 816 |
"reCAPTCHA" => array( |
| 817 |
'googleReCAPTCHA_active' => array('name' => __('Active', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('1' => __('Enabled', 'booking-package'), '0' => __('Disabled', 'booking-package'))), |
| 818 |
'googleReCAPTCHA_site_key' => array('name' => __('Site Key', 'booking-package'), 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 819 |
'googleReCAPTCHA_Secret_key' => array('name' => __('Secret Key', 'booking-package'), 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 820 |
'googleReCAPTCHA_version' => array('name' => __('Version', 'booking-package'), 'value' => 'v2', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('v2' => 'v2', 'v3' => 'v3')), |
| 821 |
), |
| 822 |
"hCaptcha" => array( |
| 823 |
'hCaptcha_active' => array('name' => __('Active', 'booking-package'), 'value' => '0', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('1' => __('Enabled', 'booking-package'), '0' => __('Disabled', 'booking-package'))), |
| 824 |
'hCaptcha_site_key' => array('name' => __('Site Key', 'booking-package'), 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 825 |
'hCaptcha_Secret_key' => array('name' => __('Secret Key', 'booking-package'), 'value' => '', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'TEXT'), |
| 826 |
'hCaptcha_Theme' => array('name' => __('Theme', 'booking-package'), 'value' => 'light', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('light' => __('Light', 'booking-package'), 'dark' => __('Dark', 'booking-package'))), |
| 827 |
'hCaptcha_Size' => array('name' => __('Size', 'booking-package'), 'value' => 'normal', 'isExtensionsValid' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('normal' => __('Normal', 'booking-package'), 'compact' => __('Compact', 'booking-package'))), |
| 828 |
|
| 829 |
), |
| 830 |
); |
| 831 |
|
| 832 |
$newDataFormatList = array(); |
| 833 |
|
| 834 |
$dateFormatList = array( |
| 835 |
array("format" => "m/d/Y / m/Y", "type" => "number"), |
| 836 |
array("format" => "m-d-Y / m-Y", "type" => "number"), |
| 837 |
array("format" => "% d, Y / %, Y", "type" => "string"), |
| 838 |
array("format" => "d/m/Y / m/Y", "type" => "number"), |
| 839 |
array("format" => "d-m-Y / m-Y", "type" => "number"), |
| 840 |
array("format" => "d %, Y / %, Y", "type" => "string"), |
| 841 |
array("format" => "Y/m/d / Y/m", "type" => "number"), |
| 842 |
array("format" => "Y-m-d / Y-m", "type" => "number"), |
| 843 |
array("format" => "d.m.Y / m.Y", "type" => "number"), |
| 844 |
array("format" => "d.m.Y / %.Y", "type" => "string"), |
| 845 |
array("format" => "d.%.Y / %.Y", "type" => "string"), |
| 846 |
array("format" => "% d Y / % Y", "type" => "string"), |
| 847 |
array("format" => "d % Y / % Y", "type" => "string"), |
| 848 |
array("format" => "d.m.Y / % Y", "type" => "string"), |
| 849 |
array("format" => "d.%.Y / % Y", "type" => "string"), |
| 850 |
array("format" => "Y年m月d日 / Y年m月", "type" => "number"), |
| 851 |
); |
| 852 |
|
| 853 |
$month = __(date('F'), 'booking-package'); |
| 854 |
for ($i = 0; $i < count($dateFormatList); $i++) { |
| 855 |
|
| 856 |
$format = $dateFormatList[$i]; |
| 857 |
$date = null; |
| 858 |
if ($format['type'] == 'number') { |
| 859 |
|
| 860 |
$date = date($format['format']); |
| 861 |
|
| 862 |
} else { |
| 863 |
|
| 864 |
$date = date($format['format']); |
| 865 |
$date = str_replace('%', $month, $date); |
| 866 |
|
| 867 |
} |
| 868 |
|
| 869 |
$dateFormatList[$i] = $date; |
| 870 |
|
| 871 |
} |
| 872 |
|
| 873 |
$list['General']['dateFormat']['valueList'] = $dateFormatList; |
| 874 |
|
| 875 |
if (class_exists('NumberFormatter') === true) { |
| 876 |
|
| 877 |
$currencies_name = array(); |
| 878 |
$currencies = $this->getCurrencies(); |
| 879 |
foreach ($currencies as $key => $value) { |
| 880 |
|
| 881 |
$currencies_name[$key] = $value['name']; |
| 882 |
|
| 883 |
} |
| 884 |
|
| 885 |
$list['General']['currency']['valueList'] = $currencies_name; |
| 886 |
|
| 887 |
} |
| 888 |
|
| 889 |
foreach ((array) $list as $listKey => $listValue) { |
| 890 |
|
| 891 |
$category = array(); |
| 892 |
foreach ((array) $listValue as $key => $value) { |
| 893 |
|
| 894 |
if ($value['inputType'] !== 'MULTIPLE_FIELDS') { |
| 895 |
|
| 896 |
$optionsValue = get_option($this->prefix . $key); |
| 897 |
if ($optionsValue !== false) { |
| 898 |
|
| 899 |
$value['value'] = $optionsValue; |
| 900 |
|
| 901 |
} |
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
} else { |
| 906 |
|
| 907 |
for ($i = 0; $i < count($value['valueList']); $i++) { |
| 908 |
|
| 909 |
$value['valueList'][$i]['key'] = $this->prefix . $value['valueList'][$i]['key']; |
| 910 |
$optionsValue = get_option($value['valueList'][$i]['key']); |
| 911 |
if ($optionsValue !== false) { |
| 912 |
|
| 913 |
$value['valueList'][$i]['value'] = $optionsValue; |
| 914 |
|
| 915 |
} |
| 916 |
|
| 917 |
} |
| 918 |
|
| 919 |
} |
| 920 |
|
| 921 |
$category[$this->prefix . $key] = $value; |
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
} |
| 926 |
|
| 927 |
$list[$listKey] = $category; |
| 928 |
|
| 929 |
} |
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
return $list; |
| 934 |
|
| 935 |
} |
| 936 |
|
| 937 |
public function getBookingSyncList($accountKey = false){ |
| 938 |
|
| 939 |
$list = array(); |
| 940 |
$booking_sync = $this->booking_sync(); |
| 941 |
foreach ((array) $booking_sync as $listKey => $listValue) { |
| 942 |
|
| 943 |
$category = array(); |
| 944 |
foreach ((array) $listValue as $key => $value) { |
| 945 |
|
| 946 |
$optionsValue = get_option($this->prefix.$key); |
| 947 |
if($optionsValue !== false){ |
| 948 |
|
| 949 |
$value['value'] = stripslashes($optionsValue); |
| 950 |
|
| 951 |
} |
| 952 |
|
| 953 |
$category[$this->prefix.$key] = $value; |
| 954 |
|
| 955 |
} |
| 956 |
|
| 957 |
$list[$listKey] = $category; |
| 958 |
|
| 959 |
} |
| 960 |
|
| 961 |
return $list; |
| 962 |
|
| 963 |
} |
| 964 |
|
| 965 |
public function getMemberSetting($extension = false){ |
| 966 |
|
| 967 |
$userFunctions = $this->userFunctions(); |
| 968 |
foreach ((array) $userFunctions as $key => $input) { |
| 969 |
|
| 970 |
$defaultValue = $input['value']; |
| 971 |
$value = get_option($this->prefix . $key); |
| 972 |
if ($value !== false) { |
| 973 |
|
| 974 |
$userFunctions[$key]['value'] = $value; |
| 975 |
|
| 976 |
} else { |
| 977 |
|
| 978 |
add_option($this->prefix . $key, sanitize_text_field($defaultValue)); |
| 979 |
|
| 980 |
} |
| 981 |
|
| 982 |
if ($extension !== true && $input['isExtensionsValid'] == 1) { |
| 983 |
|
| 984 |
$userFunctions[$key]['value'] = 0; |
| 985 |
|
| 986 |
} |
| 987 |
|
| 988 |
} |
| 989 |
|
| 990 |
return $userFunctions; |
| 991 |
|
| 992 |
} |
| 993 |
|
| 994 |
public function getMemberSettingValues(){ |
| 995 |
|
| 996 |
$userFunctions = $this->userFunctions(); |
| 997 |
$values = array( |
| 998 |
'function_for_member' => $userFunctions['function_for_member']['value'], |
| 999 |
'visitors_registration_for_member' => $userFunctions['visitors_registration_for_member']['value'], |
| 1000 |
'check_email_for_member' => $userFunctions['check_email_for_member']['value'], |
| 1001 |
'reject_non_membder' => $userFunctions['reject_non_membder']['value'], |
| 1002 |
'accept_subscribers_as_users' => $userFunctions['accept_subscribers_as_users']['value'], |
| 1003 |
'accept_contributors_as_users' => $userFunctions['accept_contributors_as_users']['value'], |
| 1004 |
/** |
| 1005 |
'accept_authors_as_users' => $userFunctions['accept_authors_as_users']['value'], |
| 1006 |
**/ |
| 1007 |
'user_toolbar' => $userFunctions['user_toolbar']['value'], |
| 1008 |
'lost_password' => $userFunctions['lost_password']['value'], |
| 1009 |
); |
| 1010 |
|
| 1011 |
foreach ((array) $values as $key => $value) { |
| 1012 |
|
| 1013 |
$value = get_option($this->prefix.$key, $value); |
| 1014 |
$values[$key] = $value; |
| 1015 |
|
| 1016 |
} |
| 1017 |
|
| 1018 |
$values['lost_password_url'] = wp_lostpassword_url(get_permalink()); |
| 1019 |
|
| 1020 |
return $values; |
| 1021 |
|
| 1022 |
} |
| 1023 |
|
| 1024 |
public function getEmailForUser() { |
| 1025 |
|
| 1026 |
$list = array( |
| 1027 |
'_' . $this->prefix . 'user_email_registered' => array( |
| 1028 |
'enable' => 0, |
| 1029 |
'enableSMS' => 0, |
| 1030 |
'notifyAdministrator' => 1, |
| 1031 |
'format' => 'text', |
| 1032 |
'title' => __('Registered', 'booking-package'), |
| 1033 |
'subject' => __('Registration Complete', 'booking-package'), |
| 1034 |
'content' => __('Your registration is complete.', 'booking-package'), |
| 1035 |
'subjectForAdmin' => __('Registration Complete', 'booking-package'), |
| 1036 |
'contentForAdmin' => __('Your registration is complete.', 'booking-package'), |
| 1037 |
), |
| 1038 |
'_' . $this->prefix . 'user_email_updated' => array( |
| 1039 |
'enable' => 0, |
| 1040 |
'enableSMS' => 0, |
| 1041 |
'notifyAdministrator' => 1, |
| 1042 |
'format' => 'text', |
| 1043 |
'title' => __('Updated', 'booking-package'), |
| 1044 |
'subject' => __('User Information Updated', 'booking-package'), |
| 1045 |
'content' => __('Your user information has been updated.', 'booking-package'), |
| 1046 |
'subjectForAdmin' => __('User Information Updated', 'booking-package'), |
| 1047 |
'contentForAdmin' => __('Your user information has been updated.', 'booking-package'), |
| 1048 |
), |
| 1049 |
'_' . $this->prefix . 'user_email_deleted' => array( |
| 1050 |
'enable' => 0, |
| 1051 |
'enableSMS' => 0, |
| 1052 |
'notifyAdministrator' => 1, |
| 1053 |
'format' => 'text', |
| 1054 |
'title' => __('Deleted', 'booking-package'), |
| 1055 |
'subject' => __('Account Deletion Notification', 'booking-package'), |
| 1056 |
'content' => __('Your account has been deleted.', 'booking-package'), |
| 1057 |
'subjectForAdmin' => __('Account Deletion Notification', 'booking-package'), |
| 1058 |
'contentForAdmin' => __('Your account has been deleted.', 'booking-package'), |
| 1059 |
), |
| 1060 |
); |
| 1061 |
|
| 1062 |
$emailMessageList = array(); |
| 1063 |
foreach ($list as $uniqueKey => $object) { |
| 1064 |
|
| 1065 |
$json = get_option($uniqueKey, null); |
| 1066 |
if (is_null($json) === true) { |
| 1067 |
|
| 1068 |
add_option($uniqueKey, json_encode($object)); |
| 1069 |
|
| 1070 |
|
| 1071 |
} else { |
| 1072 |
|
| 1073 |
$object = json_decode($json, true); |
| 1074 |
|
| 1075 |
} |
| 1076 |
$emailMessageList[$uniqueKey] = $object; |
| 1077 |
|
| 1078 |
} |
| 1079 |
|
| 1080 |
$formData = $this->getUserInputFields(); |
| 1081 |
|
| 1082 |
return array('emailMessageList' => $emailMessageList, 'formData' => $formData); |
| 1083 |
|
| 1084 |
} |
| 1085 |
|
| 1086 |
public function getEmailMessageList($accountKey = 1, $calendarName = null, $calendarAccount = null) { |
| 1087 |
|
| 1088 |
if (empty($calendarName)) { |
| 1089 |
|
| 1090 |
$calendarName = 'Your Calendar'; |
| 1091 |
|
| 1092 |
} |
| 1093 |
|
| 1094 |
$enable = 1; |
| 1095 |
$messages = array( |
| 1096 |
'new_booking_notification' => array( |
| 1097 |
'enable' => 1, |
| 1098 |
'subject' => "Booking notification for your visitors [Booking Package]", |
| 1099 |
'content' => sprintf("Hello,\n\nID: [id] \nFirst Name: [first_name] \nLast Name: [last_name] \nEmail: [email] \nPhone: [phone] \nAddress: [address] \n\nYou can edit this message anytime in the \"Notifications\" tab on the %s.\n\nThank you for trying Booking Package.", $calendarName), |
| 1100 |
'subjectForAdmin' => 'Booking notification for you [Booking Package]', |
| 1101 |
'contentForAdmin' => '', |
| 1102 |
), |
| 1103 |
'booking_approved_notification' => array('enable' => 0, 'subject' => "", 'content' => "", 'subjectForAdmin' => '', 'contentForAdmin' => '',), |
| 1104 |
'booking_cancellation_notification' => array('enable' => 0, 'subject' => "", 'content' => "", 'subjectForAdmin' => '', 'contentForAdmin' => '',), |
| 1105 |
'booking_deleted_notification' => array('enable' => 0, 'subject' => "", 'content' => "", 'subjectForAdmin' => '', 'contentForAdmin' => '',), |
| 1106 |
'booking_pending_notification' => array('enable' => 0, 'subject' => "", 'content' => "", 'subjectForAdmin' => '', 'contentForAdmin' => '',), |
| 1107 |
'booking_updated_notification' => array('enable' => 0, 'subject' => "", 'content' => "", 'subjectForAdmin' => '', 'contentForAdmin' => '',), |
| 1108 |
'booking_reminder_notification' => array('enable' => 0, 'subject' => "", 'content' => "", 'subjectForAdmin' => '', 'contentForAdmin' => '',), |
| 1109 |
); |
| 1110 |
|
| 1111 |
global $wpdb; |
| 1112 |
$table_name = $wpdb->prefix . "booking_package_email_settings"; |
| 1113 |
$email_message = $this->email_message; |
| 1114 |
foreach ((array) $email_message as $key => $value) { |
| 1115 |
|
| 1116 |
#var_dump($value); |
| 1117 |
$sql = $wpdb->prepare("SELECT * FROM ".$table_name." WHERE `accountKey` = %d AND `mail_id` = %s;", array(intval($accountKey), $value['key'])); |
| 1118 |
$row = $wpdb->get_row($sql, ARRAY_A); |
| 1119 |
if (is_null($row)) { |
| 1120 |
|
| 1121 |
#var_dump($row); |
| 1122 |
$wpdb->insert( |
| 1123 |
$table_name, |
| 1124 |
array( |
| 1125 |
'accountKey' => intval($accountKey), |
| 1126 |
'mail_id' => sanitize_text_field($value['key']), |
| 1127 |
'enable' => intval($messages[$key]['enable']), |
| 1128 |
'data' => date('U'), |
| 1129 |
'subject' => sanitize_text_field($messages[$key]['subject']), |
| 1130 |
'content' => htmlspecialchars($messages[$key]['content'], ENT_QUOTES|ENT_HTML5), |
| 1131 |
'subjectForAdmin' => sanitize_text_field($messages[$key]['subjectForAdmin']), |
| 1132 |
'contentForAdmin' => htmlspecialchars($messages[$key]['content'], ENT_QUOTES|ENT_HTML5), |
| 1133 |
'format' => 'text', |
| 1134 |
), |
| 1135 |
array('%d', '%s', '%d', '%d', '%s', '%s', '%s', '%s', '%s') |
| 1136 |
); |
| 1137 |
|
| 1138 |
} else { |
| 1139 |
|
| 1140 |
#var_dump($row); |
| 1141 |
$email_message[$key]['enable'] = intval($row['enable']); |
| 1142 |
$email_message[$key]['enableSMS'] = intval($row['enableSMS']); |
| 1143 |
$email_message[$key]['format'] = $row['format']; |
| 1144 |
$email_message[$key]['subjectForAdmin'] = $row['subjectForAdmin']; |
| 1145 |
$email_message[$key]['contentForAdmin'] = ''; |
| 1146 |
if (!is_null($row['contentForAdmin'])) { |
| 1147 |
|
| 1148 |
$email_message[$key]['contentForAdmin'] = htmlspecialchars_decode($row['contentForAdmin'], ENT_QUOTES|ENT_HTML5); |
| 1149 |
|
| 1150 |
} |
| 1151 |
|
| 1152 |
if (!is_null($row['subject'])) { |
| 1153 |
|
| 1154 |
$email_message[$key]['subject'] = $row['subject']; |
| 1155 |
|
| 1156 |
} |
| 1157 |
|
| 1158 |
if (!is_null($row['content'])) { |
| 1159 |
|
| 1160 |
$email_message[$key]['content'] = htmlspecialchars_decode($row['content'], ENT_QUOTES|ENT_HTML5); |
| 1161 |
|
| 1162 |
} |
| 1163 |
|
| 1164 |
$email_message[$key]['attachICalendar'] = intval($row['attachICalendar']); |
| 1165 |
$email_message[$key]['notifyAdministrator'] = intval($row['notifyAdministrator']); |
| 1166 |
$email_message[$key]['subjectForIcalendar'] = $row['subjectForIcalendar']; |
| 1167 |
$email_message[$key]['locationForIcalendar'] = $row['locationForIcalendar']; |
| 1168 |
$email_message[$key]['contentForIcalendar'] = ''; |
| 1169 |
if (!is_null($row['contentForIcalendar'])) { |
| 1170 |
|
| 1171 |
$email_message[$key]['contentForIcalendar'] = htmlspecialchars_decode($row['contentForIcalendar'], ENT_QUOTES|ENT_HTML5); |
| 1172 |
|
| 1173 |
} |
| 1174 |
|
| 1175 |
} |
| 1176 |
|
| 1177 |
#break; |
| 1178 |
|
| 1179 |
} |
| 1180 |
|
| 1181 |
#var_dump($email_message); |
| 1182 |
$response = array('emailMessageList' => $email_message); |
| 1183 |
$response['formData'] = $this->getForm($accountKey, false); |
| 1184 |
return $response; |
| 1185 |
|
| 1186 |
} |
| 1187 |
|
| 1188 |
public function getEmailMessage($keys = null){ |
| 1189 |
|
| 1190 |
$list = array(); |
| 1191 |
foreach ((array) $this->email_message as $key => $value) { |
| 1192 |
|
| 1193 |
$value['key'] = $this->prefix.$key; |
| 1194 |
|
| 1195 |
if($keys == null || in_array("subject", $keys) === true){ |
| 1196 |
|
| 1197 |
$optionsValue = get_option($this->prefix.$key."_subject", ""); |
| 1198 |
if($optionsValue !== false){ |
| 1199 |
|
| 1200 |
$value['subject'] = $optionsValue; |
| 1201 |
|
| 1202 |
} |
| 1203 |
|
| 1204 |
} |
| 1205 |
|
| 1206 |
if($keys == null || in_array("content", $keys) === true){ |
| 1207 |
|
| 1208 |
$optionsValue = get_option($this->prefix.$key."_content", "<div>No message</div>"); |
| 1209 |
if($optionsValue !== false){ |
| 1210 |
|
| 1211 |
$value['content'] = $optionsValue; |
| 1212 |
|
| 1213 |
} |
| 1214 |
|
| 1215 |
} |
| 1216 |
|
| 1217 |
if($keys == null || in_array("enable", $keys) === true){ |
| 1218 |
|
| 1219 |
$optionsValue = get_option($this->prefix.$key."_enable", 1); |
| 1220 |
if($optionsValue !== false){ |
| 1221 |
|
| 1222 |
$value['enable'] = $optionsValue; |
| 1223 |
|
| 1224 |
} |
| 1225 |
|
| 1226 |
} |
| 1227 |
|
| 1228 |
if($keys == null || in_array("format", $keys) === true){ |
| 1229 |
|
| 1230 |
$optionsValue = get_option($this->prefix.$key."_format", "html"); |
| 1231 |
if($optionsValue !== false){ |
| 1232 |
|
| 1233 |
$value['format'] = $optionsValue; |
| 1234 |
|
| 1235 |
} |
| 1236 |
|
| 1237 |
} |
| 1238 |
|
| 1239 |
$list[$key] = $value; |
| 1240 |
} |
| 1241 |
|
| 1242 |
return $list; |
| 1243 |
|
| 1244 |
} |
| 1245 |
|
| 1246 |
public function words() { |
| 1247 |
|
| 1248 |
$words = array( |
| 1249 |
__('Rates', 'booking-package'), |
| 1250 |
__('Extra Charges & Taxes', 'booking-package'), |
| 1251 |
__('Expiration Date for Convenience Store Payments', 'booking-package'), |
| 1252 |
|
| 1253 |
); |
| 1254 |
|
| 1255 |
return $words; |
| 1256 |
|
| 1257 |
} |
| 1258 |
|
| 1259 |
public function getElementForCalendarAccount(){ |
| 1260 |
|
| 1261 |
$preparationTime = array(); |
| 1262 |
for ($i = 0; $i <= 180; $i += 5) { |
| 1263 |
|
| 1264 |
array_push($preparationTime, array('key' => $i, 'name' => sprintf(__("%s minutes", 'booking-package'), $i))); |
| 1265 |
|
| 1266 |
} |
| 1267 |
|
| 1268 |
$calendarAccount = array( |
| 1269 |
'name' => array('key' => 'name', 'name' => 'Name', 'target' => 'both', 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', 'isExtensionsValid' => 0, 'option' => 0), |
| 1270 |
'type' => array( |
| 1271 |
'key' => 'type', |
| 1272 |
'name' => 'Select a type', |
| 1273 |
'target' => 'hidden', |
| 1274 |
'value' => 'day', |
| 1275 |
'inputLimit' => 1, |
| 1276 |
'inputType' => 'RADIO', |
| 1277 |
'isExtensionsValid' => 0, |
| 1278 |
'option' => 1, |
| 1279 |
'optionsList' => array( |
| 1280 |
/** |
| 1281 |
'cost' => 0, |
| 1282 |
**/ |
| 1283 |
'hotelCharges' => 0, |
| 1284 |
'maximumNights' => 0, |
| 1285 |
'minimumNights' => 0, |
| 1286 |
'subscriptionIdForStripe' => 1, |
| 1287 |
'termsOfServiceForSubscription' => 1, |
| 1288 |
/**'enableSubscriptionForStripe' => 1,**/ |
| 1289 |
'numberOfRoomsAvailable' => 0, |
| 1290 |
'numberOfPeopleInRoom' => 0, |
| 1291 |
'includeChildrenInRoom' => 0, |
| 1292 |
'expressionsCheck' => 0, |
| 1293 |
'preparationTime' => 1, |
| 1294 |
'flowOfBooking' => 1, |
| 1295 |
'courseBool' => 1, |
| 1296 |
'guestsBool' => 1, |
| 1297 |
'hasMultipleServices' => 1, |
| 1298 |
'courseTitle' => 1, |
| 1299 |
'displayRemainingCapacity' => 1, |
| 1300 |
'servicesPage' => 1, |
| 1301 |
'schedulesPage' => 1, |
| 1302 |
'minimum_guests' => 1, |
| 1303 |
'maximum_guests' => 1, |
| 1304 |
), 'valueList' => array( |
| 1305 |
'day' => 'Booking is completed within 24 hours (hair salon, hospital etc.)', |
| 1306 |
'hotel' => 'Accommodation (hotels, campgrounds, etc.)' |
| 1307 |
) |
| 1308 |
), |
| 1309 |
'account_email_address' => array( |
| 1310 |
'key' => 'email_address', |
| 1311 |
'name' => __('Email Address', 'booking-package'), |
| 1312 |
'target' => 'both', |
| 1313 |
'disabled' => 0, |
| 1314 |
'value' => '1', |
| 1315 |
'inputLimit' => 2, |
| 1316 |
'inputType' => 'MULTIPLE_FIELDS', |
| 1317 |
'isExtensionsValid' => 0, |
| 1318 |
'option' => 0, |
| 1319 |
'valueList' => array( |
| 1320 |
0 => array( |
| 1321 |
'key' => 'email_to', |
| 1322 |
'name' => __('Recipient Email Address', 'booking-package') . ': ', |
| 1323 |
'value' => '', |
| 1324 |
'inputType' => 'TEXT', |
| 1325 |
'isExtensionsValid' => 0, |
| 1326 |
'actions' => null, |
| 1327 |
'valueList' => array(), |
| 1328 |
), |
| 1329 |
1 => array( |
| 1330 |
'key' => 'email_from_title', |
| 1331 |
'name' => __('Sender Name', 'booking-package') . ': ', |
| 1332 |
'value' => '', |
| 1333 |
'inputType' => 'TEXT', |
| 1334 |
'isExtensionsValid' => 0, |
| 1335 |
'actions' => null, |
| 1336 |
'valueList' => array(), |
| 1337 |
), |
| 1338 |
2 => array( |
| 1339 |
'key' => 'email_from', |
| 1340 |
'name' => __('Sending Email Address', 'booking-package') . ': ', |
| 1341 |
'value' => '', |
| 1342 |
'inputType' => 'TEXT', |
| 1343 |
'isExtensionsValid' => 0, |
| 1344 |
'actions' => null, |
| 1345 |
'valueList' => array(), |
| 1346 |
), |
| 1347 |
), |
| 1348 |
), |
| 1349 |
/** |
| 1350 |
'email_to' => array('key' => 'email_to', 'name' => __('Recipient Email Address', 'booking-package'), 'target' => 'both', 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXT', 'isExtensionsValid' => 0, 'option' => 0), |
| 1351 |
'email_from' => array('key' => 'email_from', 'name' => __('Sending Email Address', 'booking-package'), 'target' => 'both', 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXT', 'isExtensionsValid' => 0, 'option' => 0), |
| 1352 |
'email_from_title' => array('key' => 'email_from_title', 'name' => __('Sender Name', 'booking-package'), 'target' => 'both', 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXT', 'isExtensionsValid' => 0, 'option' => 0), |
| 1353 |
**/ |
| 1354 |
'status' => array('key' => 'status', 'name' => __('Calendar Status', 'booking-package'), 'target' => 'both', 'value' => 'open', 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => array('open' => __('Enabled', 'booking-package'), 'closed' => __('Disabled', 'booking-package'))), |
| 1355 |
'maxAccountScheduleDay' => array('key' => 'maxAccountScheduleDay', 'name' => __('Number of Available Days From Today', 'booking-package'), 'target' => 'both', 'disabled' => 0, 'value' => '0', 'inputLimit' => 1, 'inputType' => 'TEXT', 'isExtensionsValid' => 0, 'option' => 0, 'filterHookKey' => 'numberOfAvailableDaysFromToday'), |
| 1356 |
'unavailableDaysFromToday' => array('key' => 'unavailableDaysFromToday', 'name' => __('Number of Unavailable Days From Today', 'booking-package'), 'target' => 'both', 'disabled' => 0, 'value' => '0', 'inputLimit' => 1, 'inputType' => 'SELECT', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23', '24' => '24', '25' => '25', '26' => '26', '27' => '27', '28' => '28', '29' => '29', '30' => '30')), |
| 1357 |
'maxBookingSlotsPerDay' => array( |
| 1358 |
'key' => 'maxBookingSlotsPerDay', |
| 1359 |
'name' => __('Max Booking Slots per Weekday', 'booking-package'), |
| 1360 |
'target' => 'day', |
| 1361 |
'disabled' => 0, |
| 1362 |
'value' => 'false', |
| 1363 |
'inputLimit' => 2, |
| 1364 |
'inputType' => 'MULTIPLE_FIELDS', |
| 1365 |
'isExtensionsValid' => 1, |
| 1366 |
'option' => 0, |
| 1367 |
'valueList' => array( |
| 1368 |
0 => array( |
| 1369 |
'key' => 'maxBookingSlotsPerDayStatus', |
| 1370 |
'name' => '', |
| 1371 |
'value' => null, |
| 1372 |
'inputType' => 'RADIO', |
| 1373 |
'class' => 'multiple_fields_margin_top', |
| 1374 |
'action' => null, |
| 1375 |
'extensionsValidMessage' => 1, |
| 1376 |
'isExtensionsValid' => 0, |
| 1377 |
'actions' => null, |
| 1378 |
'valueList' => array(1 => __('Enabled', 'booking-package'), 0 => __('Disabled', 'booking-package')), |
| 1379 |
), |
| 1380 |
1 => array( |
| 1381 |
'key' => 'maxBookingSlotsOnMonday', |
| 1382 |
'name' => __('Monday', 'booking-package'), |
| 1383 |
'value' => 0, |
| 1384 |
'inputType' => 'TEXT', |
| 1385 |
'class' => 'multiple_fields_margin_top', |
| 1386 |
'action' => null, |
| 1387 |
'isExtensionsValid' => 0, |
| 1388 |
), |
| 1389 |
2 => array( |
| 1390 |
'key' => 'maxBookingSlotsOnTuesday', |
| 1391 |
'name' => __('Tuesday', 'booking-package'), |
| 1392 |
'value' => 0, |
| 1393 |
'inputType' => 'TEXT', |
| 1394 |
'class' => 'multiple_fields_margin_top', |
| 1395 |
'action' => null, |
| 1396 |
'isExtensionsValid' => 0, |
| 1397 |
), |
| 1398 |
3 => array( |
| 1399 |
'key' => 'maxBookingSlotsOnWednesday', |
| 1400 |
'name' => __('Wednesday', 'booking-package'), |
| 1401 |
'value' => 0, |
| 1402 |
'inputType' => 'TEXT', |
| 1403 |
'class' => 'multiple_fields_margin_top', |
| 1404 |
'action' => null, |
| 1405 |
'isExtensionsValid' => 0, |
| 1406 |
), |
| 1407 |
4 => array( |
| 1408 |
'key' => 'maxBookingSlotsOnThursday', |
| 1409 |
'name' => __('Thursday', 'booking-package'), |
| 1410 |
'value' => 0, |
| 1411 |
'inputType' => 'TEXT', |
| 1412 |
'class' => 'multiple_fields_margin_top', |
| 1413 |
'action' => null, |
| 1414 |
'isExtensionsValid' => 0, |
| 1415 |
), |
| 1416 |
5 => array( |
| 1417 |
'key' => 'maxBookingSlotsOnFriday', |
| 1418 |
'name' => __('Friday', 'booking-package'), |
| 1419 |
'value' => 0, |
| 1420 |
'inputType' => 'TEXT', |
| 1421 |
'class' => 'multiple_fields_margin_top', |
| 1422 |
'action' => null, |
| 1423 |
'isExtensionsValid' => 0, |
| 1424 |
), |
| 1425 |
6 => array( |
| 1426 |
'key' => 'maxBookingSlotsOnSaturday', |
| 1427 |
'name' => __('Saturday', 'booking-package'), |
| 1428 |
'value' => 0, |
| 1429 |
'inputType' => 'TEXT', |
| 1430 |
'class' => 'multiple_fields_margin_top', |
| 1431 |
'action' => null, |
| 1432 |
'isExtensionsValid' => 0, |
| 1433 |
), |
| 1434 |
7 => array( |
| 1435 |
'key' => 'maxBookingSlotsOnSunday', |
| 1436 |
'name' => __('Sunday', 'booking-package'), |
| 1437 |
'value' => 0, |
| 1438 |
'inputType' => 'TEXT', |
| 1439 |
'class' => 'multiple_fields_margin_top', |
| 1440 |
'action' => null, |
| 1441 |
'isExtensionsValid' => 0, |
| 1442 |
), |
| 1443 |
8 => array( |
| 1444 |
'key' => 'maxBookingSlotsOnNationalHoliday', |
| 1445 |
'name' => __('Public Holiday', 'booking-package'), |
| 1446 |
'value' => 0, |
| 1447 |
'inputType' => 'TEXT', |
| 1448 |
'class' => 'multiple_fields_margin_top', |
| 1449 |
'action' => null, |
| 1450 |
'isExtensionsValid' => 0, |
| 1451 |
'message' => __('To disable the maximum booking slots for a specific weekday, please enter "0".', 'booking-package'), |
| 1452 |
), |
| 1453 |
), |
| 1454 |
"message" => '', |
| 1455 |
), |
| 1456 |
'calendar_sharing' => array( |
| 1457 |
'key' => 'calendar_sharing', |
| 1458 |
'name' => __('Share available time slots from other calendars', 'booking-package'), |
| 1459 |
'target' => 'both', |
| 1460 |
'disabled' => 0, |
| 1461 |
'value' => '1', |
| 1462 |
'inputLimit' => 2, |
| 1463 |
'inputType' => 'MULTIPLE_FIELDS', |
| 1464 |
'isExtensionsValid' => 1, |
| 1465 |
'option' => 0, |
| 1466 |
'valueList' => array( |
| 1467 |
0 => array( |
| 1468 |
'key' => 'schedulesSharing', |
| 1469 |
'name' => '', |
| 1470 |
'value' => null, |
| 1471 |
'inputType' => 'CHECK', |
| 1472 |
'isExtensionsValid' => 1, |
| 1473 |
'actions' => null, |
| 1474 |
'valueList' => array(1 => __('Enabled', 'booking-package')), |
| 1475 |
), |
| 1476 |
1 => array( |
| 1477 |
'key' => 'targetSchedules', |
| 1478 |
'name' => __('Select the calendar to share', 'booking-package') . ': ', |
| 1479 |
'value' => '0', |
| 1480 |
'inputType' => 'SELECT', |
| 1481 |
'isExtensionsValid' => 1, |
| 1482 |
'actions' => null, |
| 1483 |
'valueList' => array(), |
| 1484 |
), |
| 1485 |
), |
| 1486 |
), |
| 1487 |
|
| 1488 |
'timezone' => array('key' => 'timezone', 'name' => __('Timezone', 'booking-package'), 'target' => 'both', 'value' => 'open', 'inputLimit' => 1, 'inputType' => 'SELECT_TIMEZONE', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => array()), |
| 1489 |
'startOfWeek' => array('key' => 'startOfWeek', 'name' => __('Week Starts On', 'booking-package'), 'target' => 'both', 'disabled' => 0, 'value' => '0', 'inputLimit' => 1, 'inputType' => 'SELECT', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => array('0' => __('Sunday', 'booking-package'), '1' => __('Monday', 'booking-package'), '2' => __('Tuesday', 'booking-package'), '3' => __('Wednesday', 'booking-package'), '4' => __('Thursday', 'booking-package'), '5' => __('Friday', 'booking-package'), '6' => __('Saturday', 'booking-package'))), |
| 1490 |
'sendBookingVerificationCode' => array( |
| 1491 |
'key' => 'sendBookingVerificationCode', |
| 1492 |
'name' => __('Send Booking Verification Code', 'booking-package'), |
| 1493 |
'target' => 'both', |
| 1494 |
'disabled' => 0, |
| 1495 |
'value' => '1', |
| 1496 |
'inputLimit' => 2, |
| 1497 |
'inputType' => 'MULTIPLE_FIELDS', |
| 1498 |
'isExtensionsValid' => 1, |
| 1499 |
'option' => 0, |
| 1500 |
'valueList' => array( |
| 1501 |
0 => array( |
| 1502 |
'key' => 'bookingVerificationCode', |
| 1503 |
'name' => __('For Customers', 'booking-package') . ': ', |
| 1504 |
'value' => '30', |
| 1505 |
'inputType' => 'SELECT', |
| 1506 |
'isExtensionsValid' => 1, |
| 1507 |
'actions' => null, |
| 1508 |
'valueList' => array( |
| 1509 |
0 => array('key' => 'emailAndSms', 'name' => __('Enabled', 'booking-package') . ' - ' . __('Email and SMS', 'booking-package')), |
| 1510 |
1 => array('key' => 'email', 'name' => __('Enabled', 'booking-package') . ' - ' . __('Email', 'booking-package')), |
| 1511 |
2 => array('key' => 'sms', 'name' => __('Enabled', 'booking-package') . ' - ' . __('SMS', 'booking-package')), |
| 1512 |
3 => array('key' => 'false', 'name' => __('Disabled', 'booking-package')), |
| 1513 |
), |
| 1514 |
), |
| 1515 |
1 => array( |
| 1516 |
'key' => 'bookingVerificationCodeToUser', |
| 1517 |
'name' => __('For Users', 'booking-package') . ': ', |
| 1518 |
'value' => '30', |
| 1519 |
'inputType' => 'SELECT', |
| 1520 |
'isExtensionsValid' => 1, |
| 1521 |
'actions' => null, |
| 1522 |
'valueList' => array( |
| 1523 |
0 => array('key' => 'emailAndSms', 'name' => __('Enabled', 'booking-package') . ' - ' . __('Email and SMS', 'booking-package')), |
| 1524 |
1 => array('key' => 'email', 'name' => __('Enabled', 'booking-package') . ' - ' . __('Email', 'booking-package')), |
| 1525 |
2 => array('key' => 'sms', 'name' => __('Enabled', 'booking-package') . ' - ' . __('SMS', 'booking-package')), |
| 1526 |
3 => array('key' => 'false', 'name' => __('Disabled', 'booking-package')), |
| 1527 |
), |
| 1528 |
), |
| 1529 |
), |
| 1530 |
), |
| 1531 |
|
| 1532 |
'messagingService' => array('key' => 'messagingService', 'name' => __('Messaging Services', 'booking-package'), 'target' => 'both', 'value' => 'open', 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => array(0 => __('Disabled', 'booking-package'), /**'facebookMessenger' => 'Facebook Messenger',**/ 'whatsApp' => 'WhatsApp', /**'line' => 'LINE',**/ 'twilio' => 'twilio SMS')), |
| 1533 |
|
| 1534 |
'paymentMethod' => array('key' => 'paymentMethod', 'name' => __('Payment Methods', 'booking-package'), 'target' => 'both', 'value' => 'open', 'inputLimit' => 1, 'inputType' => 'CHECK', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => array('locally' => __('Local Payment', 'booking-package'), 'stripe' => __('Pay with Stripe', 'booking-package'), 'stripe_paypay' => sprintf( __('Pay with %s'), 'PayPay' ), 'stripe_konbini' => __('Pay at a convenience store with Stripe', 'booking-package'), 'paypal' => __('Pay with PayPal', 'booking-package'))), |
| 1535 |
'subscriptionIdForStripe' => array('key' => 'subscriptionIdForStripe', 'name' => 'Product ID of subscription for Stripe', 'target' => 'both', 'value' => '', 'inputLimit' => 2, 'inputType' => 'SUBSCRIPTION', 'optionKeys' => array('subscriptionIdForStripe' => array('title' => 'Product ID', 'inputType' => 'TEXT'), 'enableSubscriptionForStripe' => array('title' => __('Enabled', 'booking-package'), 'inputType' => 'CHECKBOX')), 'isExtensionsValid' => 1, 'option' => 0, 'optionValues' => array("enableSubscriptionForStripe" => "")), |
| 1536 |
'termsOfServiceForSubscription' => array('key' => 'termsOfServiceForSubscription', 'name' => 'The terms of service for subscription', 'target' => 'both', 'value' => '', 'inputLimit' => 2, 'inputType' => 'SUBSCRIPTION', 'optionKeys' => array('termsOfServiceForSubscription' => array('title' => 'URI', 'inputType' => 'TEXT'), 'enableTermsOfServiceForSubscription' => array('title' => __('Enabled', 'booking-package'), 'inputType' => 'CHECKBOX')), 'isExtensionsValid' => 1, 'option' => 0, 'optionValues' => array("enableTermsOfServiceForSubscription" => "")), |
| 1537 |
'privacyPolicyForSubscription' => array('key' => 'privacyPolicyForSubscription', 'name' => 'The privacy policy for subscription', 'target' => 'both', 'value' => '', 'inputLimit' => 2, 'inputType' => 'SUBSCRIPTION', 'optionKeys' => array('privacyPolicyForSubscription' => array('title' => 'URI', 'inputType' => 'TEXT'), 'enablePrivacyPolicyForSubscription' => array('title' => __('Enabled', 'booking-package'), 'inputType' => 'CHECKBOX')), 'isExtensionsValid' => 1, 'option' => 0, 'optionValues' => array("enablePrivacyPolicyForSubscription" => "")), |
| 1538 |
#'subscriptionIdForPayPal' => array('key' => 'subscriptionIdForPayPal', 'name' => 'Subscription ID for PayPal', 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXT', 'isExtensionsValid' => 1, 'option' => 0), |
| 1539 |
|
| 1540 |
'hotelCharges' => array( |
| 1541 |
'key' => 'hotelCharges', |
| 1542 |
'name' => __('Rates', 'booking-package'), |
| 1543 |
'target' => 'hotel', |
| 1544 |
'disabled' => 0, |
| 1545 |
'value' => 'false', |
| 1546 |
'inputLimit' => 1, |
| 1547 |
'inputType' => 'HOTEL_CHARGES', |
| 1548 |
'isExtensionsValid' => 0, |
| 1549 |
'option' => 0, |
| 1550 |
'valueList' => array( |
| 1551 |
0 => array( |
| 1552 |
'key' => 'hotelChargeOnMonday', |
| 1553 |
'name' => __('Monday', 'booking-package'), |
| 1554 |
'value' => 0, |
| 1555 |
'isExtensionsValid' => 0, |
| 1556 |
), |
| 1557 |
1 => array( |
| 1558 |
'key' => 'hotelChargeOnTuesday', |
| 1559 |
'name' => __('Tuesday', 'booking-package'), |
| 1560 |
'value' => 0, |
| 1561 |
'isExtensionsValid' => 0, |
| 1562 |
), |
| 1563 |
2 => array( |
| 1564 |
'key' => 'hotelChargeOnWednesday', |
| 1565 |
'name' => __('Wednesday', 'booking-package'), |
| 1566 |
'value' => 0, |
| 1567 |
'isExtensionsValid' => 0, |
| 1568 |
), |
| 1569 |
3 => array( |
| 1570 |
'key' => 'hotelChargeOnThursday', |
| 1571 |
'name' => __('Thursday', 'booking-package'), |
| 1572 |
'value' => 0, |
| 1573 |
'isExtensionsValid' => 0, |
| 1574 |
), |
| 1575 |
4 => array( |
| 1576 |
'key' => 'hotelChargeOnFriday', |
| 1577 |
'name' => __('Friday', 'booking-package'), |
| 1578 |
'value' => 0, |
| 1579 |
'isExtensionsValid' => 0, |
| 1580 |
), |
| 1581 |
5 => array( |
| 1582 |
'key' => 'hotelChargeOnSaturday', |
| 1583 |
'name' => __('Saturday', 'booking-package'), |
| 1584 |
'value' => 0, |
| 1585 |
'isExtensionsValid' => 0, |
| 1586 |
), |
| 1587 |
6 => array( |
| 1588 |
'key' => 'hotelChargeOnSunday', |
| 1589 |
'name' => __('Sunday', 'booking-package'), |
| 1590 |
'value' => 0, |
| 1591 |
'isExtensionsValid' => 0, |
| 1592 |
), |
| 1593 |
7 => array( |
| 1594 |
'key' => 'hotelChargeOnDayBeforeNationalHoliday', |
| 1595 |
'name' => __('Day Before Public Holiday', 'booking-package'), |
| 1596 |
'value' => 0, |
| 1597 |
'isExtensionsValid' => 1, |
| 1598 |
), |
| 1599 |
8 => array( |
| 1600 |
'key' => 'hotelChargeOnNationalHoliday', |
| 1601 |
'name' => __('Public Holiday', 'booking-package'), |
| 1602 |
'value' => 0, |
| 1603 |
'isExtensionsValid' => 1, |
| 1604 |
), |
| 1605 |
), |
| 1606 |
"message" => '', |
| 1607 |
), |
| 1608 |
|
| 1609 |
'minimumNights' => array('key' => 'minimumNights', 'name' => __('Minimum Stay (Nights)', 'booking-package'), 'target' => 'hotel', 'disabled' => 0, 'value' => '1', 'inputLimit' => 2, 'inputType' => 'TEXT', 'isExtensionsValid' => 1, 'option' => 0), |
| 1610 |
'maximumNights' => array('key' => 'maximumNights', 'name' => __('Maximum Stay (Nights)', 'booking-package'), 'target' => 'hotel', 'disabled' => 0, 'value' => '1', 'inputLimit' => 2, 'inputType' => 'TEXT', 'isExtensionsValid' => 1, 'option' => 0), |
| 1611 |
'numberOfRoomsAvailable' => array('key' => 'numberOfRoomsAvailable', 'name' => __('Number of Available Rooms', 'booking-package'), 'target' => 'hotel', 'disabled' => 0, 'value' => '1', 'inputLimit' => 2, 'inputType' => 'TEXT', 'isExtensionsValid' => 0, 'option' => 0), |
| 1612 |
'numberOfPeopleInRoom' => array('key' => 'numberOfPeopleInRoom', 'name' => __('Maximum Guests per Room', 'booking-package'), 'target' => 'hotel', 'disabled' => 0, 'value' => '2', 'inputLimit' => 2, 'inputType' => 'TEXT', 'isExtensionsValid' => 0, 'option' => 0), |
| 1613 |
'includeChildrenInRoom' => array('key' => 'includeChildrenInRoom', 'name' => __('Include Children in Maximum Guest Count', 'booking-package'), 'target' => 'hotel', 'disabled' => 0, 'value' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => array(1 => 'Include', 0 => 'Exclude')), |
| 1614 |
|
| 1615 |
'formatNightDay' => array('key' => 'formatNightDay', 'name' => __('Total Stay Display Format', 'booking-package'), 'target' => 'hotel', 'disabled' => 0, 'value' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => array(0 => 2 . ' ' . __('nights', 'booking-package'), 1 => sprintf(__('%s nights %s days', 'booking-package'), '2', '3'))), |
| 1616 |
|
| 1617 |
'expressionsCheck' => array('key' => 'expressionsCheck', 'name' => __('Arrival/Departure Display Format', 'booking-package'), 'target' => 'hotel', 'disabled' => 0, 'value' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => array(0 => __('Arrival (Check-in) & Departure (Check-out)', 'booking-package'), 1 => __('Arrival & Departure', 'booking-package'), 2 => __('Check-in & Check-out', 'booking-package'))), |
| 1618 |
'multipleRooms' => array('key' => 'multipleRooms', 'name' => __('Allow booking of multiple rooms', 'booking-package'), 'target' => 'hotel', 'disabled' => 0, 'value' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => array(1 => 'Enabled', 0 => 'Disabled')), |
| 1619 |
|
| 1620 |
'preparationTimeSetting' => array( |
| 1621 |
'key' => 'preparationTimeSetting', |
| 1622 |
'name' => __('Preparation Time', 'booking-package'), |
| 1623 |
'target' => 'day', |
| 1624 |
'disabled' => 0, |
| 1625 |
'value' => '1', |
| 1626 |
'inputLimit' => 2, |
| 1627 |
'inputType' => 'MULTIPLE_FIELDS', |
| 1628 |
'isExtensionsValid' => 1, |
| 1629 |
'option' => 0, |
| 1630 |
'valueList' => array( |
| 1631 |
0 => array( |
| 1632 |
'key' => 'preparationTime', |
| 1633 |
'name' => '', |
| 1634 |
'value' => null, |
| 1635 |
'inputType' => 'SELECT', |
| 1636 |
'isExtensionsValid' => 1, |
| 1637 |
'actions' => null, |
| 1638 |
'valueList' => $preparationTime, |
| 1639 |
), |
| 1640 |
1 => array( |
| 1641 |
'key' => 'positionPreparationTime', |
| 1642 |
'name' => __('Position', 'booking-package') . ': ', |
| 1643 |
'value' => null, |
| 1644 |
'inputType' => 'RADIO', |
| 1645 |
'isExtensionsValid' => 1, |
| 1646 |
'class' => 'multiple_fields_margin_top', |
| 1647 |
'actions' => null, |
| 1648 |
'valueList' => array('before_after' => __('Before and after the booking time slot', 'booking-package'), 'before' => __('Before the booking time slot', 'booking-package'), 'after' => __('After the booking time slot', 'booking-package')), |
| 1649 |
), |
| 1650 |
), |
| 1651 |
), |
| 1652 |
|
| 1653 |
'servicesFunction' => array( |
| 1654 |
'key' => 'servicesFunction', |
| 1655 |
'name' => __('Service', 'booking-package'), |
| 1656 |
'target' => 'day', |
| 1657 |
'disabled' => 0, |
| 1658 |
'value' => '1', |
| 1659 |
'inputLimit' => 2, |
| 1660 |
'inputType' => 'MULTIPLE_FIELDS', |
| 1661 |
'isExtensionsValid' => 0, |
| 1662 |
'option' => 0, |
| 1663 |
'valueList' => array( |
| 1664 |
0 => array( |
| 1665 |
'key' => 'courseBool', |
| 1666 |
'name' => '', |
| 1667 |
'value' => null, |
| 1668 |
'inputType' => 'RADIO', |
| 1669 |
'isExtensionsValid' => 0, |
| 1670 |
'actions' => null, |
| 1671 |
'valueList' => array(1 => __('Enabled', 'booking-package'), 0 => __('Disabled', 'booking-package')), |
| 1672 |
), |
| 1673 |
1 => array( |
| 1674 |
'key' => 'flowOfBooking', |
| 1675 |
'name' => __('Booking steps on the front-end', 'booking-package') . ': ', |
| 1676 |
'value' => 0, |
| 1677 |
'inputType' => 'RADIO', |
| 1678 |
'isExtensionsValid' => 0, |
| 1679 |
'class' => 'multiple_fields_margin_top', |
| 1680 |
'actions' => null, |
| 1681 |
'valueList' => array('calendar' => __('Start with date selection', 'booking-package'), 'services' => __('Start with service selection', 'booking-package')), |
| 1682 |
), |
| 1683 |
2 => array( |
| 1684 |
'key' => 'hasMultipleServices', |
| 1685 |
'name' => __('Allow selecting multiple services', 'booking-package') . ': ', |
| 1686 |
'value' => 0, |
| 1687 |
'inputType' => 'RADIO', |
| 1688 |
'isExtensionsValid' => 1, |
| 1689 |
'extensionsValidMessage' => 1, |
| 1690 |
'class' => 'multiple_fields_margin_top', |
| 1691 |
'actions' => null, |
| 1692 |
'valueList' => array(1 => __('Enabled', 'booking-package'), 0 => __('Disabled', 'booking-package')), |
| 1693 |
), |
| 1694 |
), |
| 1695 |
), |
| 1696 |
|
| 1697 |
'minimum_guests' => array( |
| 1698 |
'key' => 'minimum_guests', |
| 1699 |
'name' => __('Minimum the number of guests per one booking', 'booking-package'), |
| 1700 |
'target' => 'day', |
| 1701 |
'disabled' => 0, |
| 1702 |
'value' => '1', |
| 1703 |
'inputLimit' => 2, |
| 1704 |
'inputType' => 'MULTIPLE_FIELDS', |
| 1705 |
'isExtensionsValid' => 1, |
| 1706 |
'option' => 0, |
| 1707 |
'valueList' => array( |
| 1708 |
0 => array( |
| 1709 |
'key' => 'minimumGuests', |
| 1710 |
'name' => '', |
| 1711 |
'value' => null, |
| 1712 |
'inputType' => 'CHECK', |
| 1713 |
'isExtensionsValid' => 1, |
| 1714 |
'actions' => null, |
| 1715 |
'valueList' => array(1 => __('Enabled', 'booking-package')), |
| 1716 |
), |
| 1717 |
1 => array( |
| 1718 |
'key' => 'minimumGuestsRequiredNo', |
| 1719 |
'name' => __('Includes "No" selected on "Required" in the Guests', 'booking-package') . ': ', |
| 1720 |
'value' => null, |
| 1721 |
'inputType' => 'CHECK', |
| 1722 |
'isExtensionsValid' => 1, |
| 1723 |
'class' => 'multiple_fields_margin_top', |
| 1724 |
'actions' => null, |
| 1725 |
'valueList' => array(1 => __('Included', 'booking-package')), |
| 1726 |
), |
| 1727 |
2 => array( |
| 1728 |
'key' => 'minimumGuestsOfValue', |
| 1729 |
'name' => __('Number of Guests', 'booking-package') . ': ', |
| 1730 |
'value' => 0, |
| 1731 |
'inputType' => 'TEXT', |
| 1732 |
'isExtensionsValid' => 1, |
| 1733 |
'class' => 'multiple_fields_margin_top', |
| 1734 |
'actions' => null, |
| 1735 |
'valueList' => array(), |
| 1736 |
), |
| 1737 |
), |
| 1738 |
), |
| 1739 |
|
| 1740 |
'maximum_guests' => array( |
| 1741 |
'key' => 'maximum_guests', |
| 1742 |
'name' => __('Maximum the number of guests per one booking', 'booking-package'), |
| 1743 |
'target' => 'day', |
| 1744 |
'disabled' => 0, |
| 1745 |
'value' => '1', |
| 1746 |
'inputLimit' => 2, |
| 1747 |
'inputType' => 'MULTIPLE_FIELDS', |
| 1748 |
'isExtensionsValid' => 1, |
| 1749 |
'option' => 0, |
| 1750 |
'valueList' => array( |
| 1751 |
0 => array( |
| 1752 |
'key' => 'maximumGuests', |
| 1753 |
'name' => '', |
| 1754 |
'value' => null, |
| 1755 |
'inputType' => 'CHECK', |
| 1756 |
'isExtensionsValid' => 1, |
| 1757 |
'actions' => null, |
| 1758 |
'valueList' => array(1 => __('Enabled', 'booking-package')), |
| 1759 |
), |
| 1760 |
1 => array( |
| 1761 |
'key' => 'maximumGuestsRequiredNo', |
| 1762 |
'name' => __('Includes "No" selected on "Required" in the Guests', 'booking-package') . ': ', |
| 1763 |
'value' => null, |
| 1764 |
'inputType' => 'CHECK', |
| 1765 |
'isExtensionsValid' => 1, |
| 1766 |
'class' => 'multiple_fields_margin_top', |
| 1767 |
'actions' => null, |
| 1768 |
'valueList' => array(1 => __('Included', 'booking-package')), |
| 1769 |
), |
| 1770 |
2 => array( |
| 1771 |
'key' => 'maximumGuestsOfValue', |
| 1772 |
'name' => __('Number of Guests', 'booking-package') . ': ', |
| 1773 |
'value' => 0, |
| 1774 |
'inputType' => 'TEXT', |
| 1775 |
'isExtensionsValid' => 1, |
| 1776 |
'class' => 'multiple_fields_margin_top', |
| 1777 |
'actions' => null, |
| 1778 |
'valueList' => array(), |
| 1779 |
), |
| 1780 |
), |
| 1781 |
), |
| 1782 |
|
| 1783 |
|
| 1784 |
'displayRemainingSlots' => array( |
| 1785 |
'key' => 'displayRemainingSlots', |
| 1786 |
'name' => __('Display Remaining Slots on Calendar', 'booking-package'), |
| 1787 |
'target' => 'both', |
| 1788 |
'disabled' => 0, |
| 1789 |
'value' => '1', |
| 1790 |
'inputLimit' => 2, |
| 1791 |
'inputType' => 'MULTIPLE_FIELDS', |
| 1792 |
'isExtensionsValid' => 0, |
| 1793 |
'option' => 0, |
| 1794 |
'message' => __('Use <a href="https://material.io/tools/icons/?style=baseline" target="_blank">Material icons</a> web font.', 'booking-package'), |
| 1795 |
'valueList' => array( |
| 1796 |
0 => array( |
| 1797 |
'key' => 'displayRemainingSlotsInCalendar', |
| 1798 |
'name' => __('Display Method', 'booking-package') . ': ', |
| 1799 |
'value' => 0, |
| 1800 |
'inputType' => 'RADIO', |
| 1801 |
'isExtensionsValid' => 0, |
| 1802 |
'actions' => null, |
| 1803 |
'valueList' => array(0 => __('Disabled', 'booking-package'), 'int' => __('Show numbers', 'booking-package'), 'text' => __('Show text/symbols', 'booking-package')), |
| 1804 |
), |
| 1805 |
1 => array( |
| 1806 |
'key' => 'displayThresholdOfRemainingCapacity', |
| 1807 |
'name' => __('Remaining slots threshold', 'booking-package') . ': ', |
| 1808 |
'value' => '50', |
| 1809 |
'inputType' => 'SELECT', |
| 1810 |
'isExtensionsValid' => 0, |
| 1811 |
'actions' => null, |
| 1812 |
'valueList' => array( |
| 1813 |
90 => array('key' => 90, 'name' => '90%'), |
| 1814 |
80 => array('key' => 80, 'name' => '80%'), |
| 1815 |
70 => array('key' => 70, 'name' => '70%'), |
| 1816 |
60 => array('key' => 60, 'name' => '60%'), |
| 1817 |
50 => array('key' => 50, 'name' => '50%'), |
| 1818 |
40 => array('key' => 40, 'name' => '40%'), |
| 1819 |
30 => array('key' => 30, 'name' => '30%'), |
| 1820 |
20 => array('key' => 20, 'name' => '20%'), |
| 1821 |
10 => array('key' => 10, 'name' => '10%'), |
| 1822 |
), |
| 1823 |
), |
| 1824 |
2 => array( |
| 1825 |
'key' => 'displayRemainingCapacityHasMoreThenThreshold', |
| 1826 |
'name' => __('When slots exceed threshold', 'booking-package') . ': ', |
| 1827 |
'value' => array(), |
| 1828 |
'inputType' => 'REMAINING_CAPACITY', |
| 1829 |
'className' => 'multiple_fields_margin_top', |
| 1830 |
'isExtensionsValid' => 0, |
| 1831 |
'actions' => null, |
| 1832 |
'valueList' => array(), |
| 1833 |
), |
| 1834 |
3 => array( |
| 1835 |
'key' => 'displayRemainingCapacityHasLessThenThreshold', |
| 1836 |
'name' => __('When slots are below threshold', 'booking-package') . ': ', |
| 1837 |
'value' => array(), |
| 1838 |
'inputType' => 'REMAINING_CAPACITY', |
| 1839 |
'className' => 'multiple_fields_margin_top', |
| 1840 |
'isExtensionsValid' => 0, |
| 1841 |
'actions' => null, |
| 1842 |
'valueList' => array(), |
| 1843 |
), |
| 1844 |
4 => array( |
| 1845 |
'key' => 'displayRemainingCapacityHas0', |
| 1846 |
'name' => __('When no slots remain (0%)', 'booking-package') . ': ', |
| 1847 |
'value' => array(), |
| 1848 |
'inputType' => 'REMAINING_CAPACITY', |
| 1849 |
'className' => 'multiple_fields_margin_top', |
| 1850 |
'isExtensionsValid' => 0, |
| 1851 |
'actions' => null, |
| 1852 |
'valueList' => array(), |
| 1853 |
), |
| 1854 |
), |
| 1855 |
), |
| 1856 |
|
| 1857 |
'displayRemainingCapacity' => array('key' => 'displayRemainingCapacity', 'name' => __('Display Remaining Slots per Time Slot', 'booking-package'), 'target' => 'day', 'value' => 0, 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'option' => 0, 'valueList' => array(1 => 'Enabled', 0 => 'Disabled')), |
| 1858 |
'fixCalendar' => array('key' => 'fixCalendar', 'name' => __('Fixed Calendar', 'booking-package'), 'target' => 'both', 'value' => 'false', 'inputLimit' => 1, 'inputType' => 'FIX_CALENDAR', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => array(0 => 'month', 1 => 'year')), |
| 1859 |
'insertConfirmedPage' => array('key' => 'insertConfirmedPage', 'name' => __('Insert Booking Confirmation Page Before Completion Page', 'booking-package'), 'target' => 'both', 'value' => '0', 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'option' => 0, 'valueList' => array(1 => 'Enabled', 0 => 'Disabled')), |
| 1860 |
'blockSameTimeBookingByUser' => array('key' => 'blockSameTimeBookingByUser', 'name' => __('Prevent Multiple Bookings', 'booking-package'), 'target' => 'day', 'value' => '0', 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'option' => 0, 'valueList' => array(1 => 'Enabled', 0 => 'Disabled')), |
| 1861 |
|
| 1862 |
'bookingReminder' => array('key' => 'bookingReminder', 'name' => __('Reminder Notification Time', 'booking-package'), 'target' => 'both', 'disabled' => 0, 'value' => '0', 'inputLimit' => 1, 'inputType' => 'SELECT', 'isExtensionsValid' => 1, 'option' => 0, 'filterHookKey' => 'reminderNotificationTime', 'message' => __('Reminders are sent only for \'Approved\' bookings.', 'booking-package'), |
| 1863 |
'valueList' => array( |
| 1864 |
'60' => sprintf(__('About %d hour before', 'booking-package'), 1), |
| 1865 |
'120' => sprintf(__('About %d hours before', 'booking-package'), 2), |
| 1866 |
'180' => sprintf(__('About %d hours before', 'booking-package'), 3), |
| 1867 |
'240' => sprintf(__('About %d hours before', 'booking-package'), 4), |
| 1868 |
'300' => sprintf(__('About %d hours before', 'booking-package'), 5), |
| 1869 |
'360' => sprintf(__('About %d hours before', 'booking-package'), 6), |
| 1870 |
'420' => sprintf(__('About %d hours before', 'booking-package'), 7), |
| 1871 |
'480' => sprintf(__('About %d hours before', 'booking-package'), 8), |
| 1872 |
'540' => sprintf(__('About %d hours before', 'booking-package'), 9), |
| 1873 |
'600' => sprintf(__('About %d hours before', 'booking-package'), 10), |
| 1874 |
'660' => sprintf(__('About %d hours before', 'booking-package'), 11), |
| 1875 |
'720' => sprintf(__('About %d hours before', 'booking-package'), 12), |
| 1876 |
'1440' => sprintf(__('About %d hours before', 'booking-package'), 24), |
| 1877 |
'2160' => sprintf(__('About %d hours before', 'booking-package'), 36), |
| 1878 |
'2880' => sprintf(__('About %d hours before', 'booking-package'), 48), |
| 1879 |
'3600' => sprintf(__('About %d hours before', 'booking-package'), 60), |
| 1880 |
'4320' => sprintf(__('About %d hours before', 'booking-package'), 72), |
| 1881 |
'5760' => sprintf(__('About %d hours before', 'booking-package'), 96), |
| 1882 |
'7200' => sprintf(__('About %d hours before', 'booking-package'), 120), |
| 1883 |
'8640' => sprintf(__('About %d hours before', 'booking-package'), 144), |
| 1884 |
'10080' => sprintf(__('About %d hours before', 'booking-package'), 168), |
| 1885 |
) |
| 1886 |
), |
| 1887 |
'displayDetailsOfCanceled' => array('key' => 'displayDetailsOfCanceled', 'name' => __('Show Canceled Booking Details on "Booked Customers"', 'booking-package'), 'target' => 'both', 'value' => 'false', 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 0, 'option' => 0, 'valueList' => array(1 => 'Enabled', 0 => 'Disabled')), |
| 1888 |
'cancellation_of_booking' => array( |
| 1889 |
'key' => 'cancellation_of_booking', |
| 1890 |
'name' => __('Allow Customer Cancellations', 'booking-package'), |
| 1891 |
'target' => 'both', |
| 1892 |
'disabled' => 0, |
| 1893 |
'value' => '1', |
| 1894 |
'inputLimit' => 2, |
| 1895 |
'inputType' => 'MULTIPLE_FIELDS', |
| 1896 |
'isExtensionsValid' => 1, |
| 1897 |
'option' => 0, |
| 1898 |
'valueList' => array( |
| 1899 |
0 => array( |
| 1900 |
'key' => 'cancellationOfBooking', |
| 1901 |
'name' => '', |
| 1902 |
'value' => null, |
| 1903 |
'inputType' => 'RADIO', |
| 1904 |
'isExtensionsValid' => 1, |
| 1905 |
'actions' => null, |
| 1906 |
'valueList' => array(1 => __('Enabled', 'booking-package'), 0 => __('Disabled', 'booking-package')), |
| 1907 |
), |
| 1908 |
1 => array( |
| 1909 |
'key' => 'allowCancellationVisitor', |
| 1910 |
'name' => __('Allow Cancellation Up To', 'booking-package') . ': ', |
| 1911 |
'value' => '30', |
| 1912 |
'inputType' => 'SELECT', |
| 1913 |
'isExtensionsValid' => 1, |
| 1914 |
/** 'insertAfterElement' => '%s the booking start time', **/ |
| 1915 |
'filterHookKey' => 'cancellationLimitTime', |
| 1916 |
'actions' => null, |
| 1917 |
'valueList' => array( |
| 1918 |
30 => array('key' => 30, 'name' => sprintf(__('%s minutes before', 'booking-package'), "30")), |
| 1919 |
60 => array('key' => 60, 'name' => sprintf(__('%s hour before', 'booking-package'), "1")), |
| 1920 |
120 => array('key' => 120, 'name' => sprintf(__('%s hours before', 'booking-package'), "2")), |
| 1921 |
240 => array('key' => 240, 'name' => sprintf(__('%s hours before', 'booking-package'), "4")), |
| 1922 |
480 => array('key' => 480, 'name' => sprintf(__('%s hours before', 'booking-package'), "8")), |
| 1923 |
720 => array('key' => 720, 'name' => sprintf(__('%s hours before', 'booking-package'), "12")), |
| 1924 |
1440 => array('key' => 1440, 'name' => sprintf(__('%s day before', 'booking-package'), "1")), |
| 1925 |
2880 => array('key' => 2880, 'name' => sprintf(__('%s days before', 'booking-package'), "2")), |
| 1926 |
4320 => array('key' => 4320, 'name' => sprintf(__('%s days before', 'booking-package'), "3")), |
| 1927 |
5760 => array('key' => 5760, 'name' => sprintf(__('%s days before', 'booking-package'), "4")), |
| 1928 |
7200 => array('key' => 7200, 'name' => sprintf(__('%s days before', 'booking-package'), "5")), |
| 1929 |
8640 => array('key' => 8640, 'name' => sprintf(__('%s days before', 'booking-package'), "6")), |
| 1930 |
10080 => array('key' => 10080, 'name' => sprintf(__('%s days before', 'booking-package'), "7")), |
| 1931 |
11520 => array('key' => 11520, 'name' => sprintf(__('%s days before', 'booking-package'), "8")), |
| 1932 |
12960 => array('key' => 12960, 'name' => sprintf(__('%s days before', 'booking-package'), "9")), |
| 1933 |
14400 => array('key' => 14400, 'name' => sprintf(__('%s days before', 'booking-package'), "10")), |
| 1934 |
15840 => array('key' => 15840, 'name' => sprintf(__('%s days before', 'booking-package'), "11")), |
| 1935 |
17280 => array('key' => 17280, 'name' => sprintf(__('%s days before', 'booking-package'), "12")), |
| 1936 |
18720 => array('key' => 18720, 'name' => sprintf(__('%s days before', 'booking-package'), "13")), |
| 1937 |
20160 => array('key' => 20160, 'name' => sprintf(__('%s days before', 'booking-package'), "14")), |
| 1938 |
), |
| 1939 |
), |
| 1940 |
2 => array( |
| 1941 |
'key' => 'refuseCancellationOfBooking', |
| 1942 |
'name' => __('Applicable Booking Status', 'booking-package') . ': ', |
| 1943 |
'value' => '30', |
| 1944 |
'inputType' => 'SELECT', |
| 1945 |
'isExtensionsValid' => 1, |
| 1946 |
'actions' => null, |
| 1947 |
'valueList' => array( |
| 1948 |
0 => array('key' => 'not_refuse', 'name' => __('Pending and Approved', 'booking-package')), |
| 1949 |
1 => array('key' => 'pending', 'name' => __('Pending', 'booking-package')), |
| 1950 |
2 => array('key' => 'approved', 'name' => __('Approved', 'booking-package')), |
| 1951 |
), |
| 1952 |
), |
| 1953 |
), |
| 1954 |
), |
| 1955 |
/** |
| 1956 |
'refuseCancellationOfBooking' => array('key' => 'refuseCancellationOfBooking', 'name' => __('Status to approve cancellation of booking', 'booking-package').":", 'target' => 'both', 'value' => 'false', 'inputLimit' => 1, 'inputType' => 'SELECT', 'isExtensionsValid' => 1, 'option' => 0, |
| 1957 |
'valueList' => array( |
| 1958 |
'not_refuse' => __('Pending and Approved', 'booking-package'), |
| 1959 |
'pending' => __('Pending', 'booking-package'), |
| 1960 |
'approved' => __('Approved', 'booking-package'), |
| 1961 |
) |
| 1962 |
), |
| 1963 |
**/ |
| 1964 |
|
| 1965 |
'insertCustomPage' => array( |
| 1966 |
'key' => 'insertCustomPage', |
| 1967 |
'name' => __('Insert Custom Page at Each Step', 'booking-package'), |
| 1968 |
'target' => 'both', |
| 1969 |
'disabled' => 0, |
| 1970 |
'value' => '1', |
| 1971 |
'inputLimit' => 2, |
| 1972 |
'inputType' => 'MULTIPLE_FIELDS', |
| 1973 |
'isExtensionsValid' => 0, |
| 1974 |
'option' => 0, |
| 1975 |
'message' => __('To add custom pages to the select box, you need to add a custom field named "booking-package" to the page, with a value of "front-end.".', 'booking-package'), |
| 1976 |
'valueList' => array( |
| 1977 |
0 => array( |
| 1978 |
'key' => 'calenarPage', |
| 1979 |
'name' => __('Calendar', 'booking-package') . ': ', |
| 1980 |
'value' => 0, |
| 1981 |
'inputType' => 'SELECT', |
| 1982 |
'isExtensionsValid' => 0, |
| 1983 |
'target' => 'both', |
| 1984 |
'actions' => null, |
| 1985 |
'valueList' => array(), |
| 1986 |
), |
| 1987 |
1 => array( |
| 1988 |
'key' => 'schedulesPage', |
| 1989 |
'name' => __('Time Slot Selection', 'booking-package') . ': ', |
| 1990 |
'value' => 0, |
| 1991 |
'inputType' => 'SELECT', |
| 1992 |
'isExtensionsValid' => 0, |
| 1993 |
'target' => 'day', |
| 1994 |
'actions' => null, |
| 1995 |
'valueList' => array( |
| 1996 |
90 => array('key' => 90, 'name' => '90%'), |
| 1997 |
80 => array('key' => 80, 'name' => '80%'), |
| 1998 |
), |
| 1999 |
), |
| 2000 |
2 => array( |
| 2001 |
'key' => 'servicesPage', |
| 2002 |
'name' => __('Service Selection', 'booking-package') . ': ', |
| 2003 |
'value' => 0, |
| 2004 |
'inputType' => 'SELECT', |
| 2005 |
'isExtensionsValid' => 0, |
| 2006 |
'target' => 'day', |
| 2007 |
'actions' => null, |
| 2008 |
'valueList' => array( |
| 2009 |
90 => array('key' => 90, 'name' => '90%'), |
| 2010 |
80 => array('key' => 80, 'name' => '80%'), |
| 2011 |
), |
| 2012 |
), |
| 2013 |
3 => array( |
| 2014 |
'key' => 'visitorDetailsPage', |
| 2015 |
'name' => __('Booking Form', 'booking-package') . ': ', |
| 2016 |
'value' => 0, |
| 2017 |
'inputType' => 'SELECT', |
| 2018 |
'isExtensionsValid' => 0, |
| 2019 |
'target' => 'both', |
| 2020 |
'actions' => null, |
| 2021 |
'valueList' => array( |
| 2022 |
90 => array('key' => 90, 'name' => '90%'), |
| 2023 |
80 => array('key' => 80, 'name' => '80%'), |
| 2024 |
), |
| 2025 |
), |
| 2026 |
4 => array( |
| 2027 |
'key' => 'confirmDetailsPage', |
| 2028 |
'name' => __('Booking Confirmation Form', 'booking-package') . ': ', |
| 2029 |
'value' => 0, |
| 2030 |
'inputType' => 'SELECT', |
| 2031 |
'isExtensionsValid' => 0, |
| 2032 |
'target' => 'both', |
| 2033 |
'actions' => null, |
| 2034 |
'valueList' => array( |
| 2035 |
90 => array('key' => 90, 'name' => '90%'), |
| 2036 |
80 => array('key' => 80, 'name' => '80%'), |
| 2037 |
), |
| 2038 |
), |
| 2039 |
5 => array( |
| 2040 |
'key' => 'thanksPage', |
| 2041 |
'name' => __('Booking Completion Form', 'booking-package') . ': ', |
| 2042 |
'value' => 0, |
| 2043 |
'inputType' => 'SELECT', |
| 2044 |
'isExtensionsValid' => 0, |
| 2045 |
'actions' => null, |
| 2046 |
'valueList' => array( |
| 2047 |
90 => array('key' => 90, 'name' => '90%'), |
| 2048 |
80 => array('key' => 80, 'name' => '80%'), |
| 2049 |
), |
| 2050 |
), |
| 2051 |
|
| 2052 |
), |
| 2053 |
), |
| 2054 |
|
| 2055 |
'redirect_Page' => array( |
| 2056 |
'key' => 'redirect_Page', |
| 2057 |
'name' => __('Redirect After Booking', 'booking-package'), |
| 2058 |
'target' => 'both', |
| 2059 |
'disabled' => 0, |
| 2060 |
'value' => '1', |
| 2061 |
'inputLimit' => 2, |
| 2062 |
'inputType' => 'MULTIPLE_FIELDS', |
| 2063 |
'isExtensionsValid' => 0, |
| 2064 |
'option' => 0, |
| 2065 |
'valueList' => array( |
| 2066 |
0 => array( |
| 2067 |
'key' => 'redirectMode', |
| 2068 |
'name' => '', |
| 2069 |
'value' => 'page', |
| 2070 |
'inputType' => 'RADIO', |
| 2071 |
'isExtensionsValid' => 0, |
| 2072 |
'actions' => null, |
| 2073 |
'valueList' => array('page' => __('Pages', 'booking-package'), 'url' => __('URL', 'booking-package')), |
| 2074 |
), |
| 2075 |
1 => array( |
| 2076 |
'key' => 'redirectPage', |
| 2077 |
'name' => __('Pages', 'booking-package') . ': ', |
| 2078 |
'value' => null, |
| 2079 |
'inputType' => 'SELECT', |
| 2080 |
'isExtensionsValid' => 0, |
| 2081 |
'className' => 'multiple_fields_margin_top', |
| 2082 |
'actions' => null, |
| 2083 |
'valueList' => array(1 => __('Enabled', 'booking-package')), |
| 2084 |
'message' => __('To add custom pages to the select box, you need to add a custom field named "booking-package" to the page, with a value of "front-end.".', 'booking-package'), |
| 2085 |
), |
| 2086 |
2 => array( |
| 2087 |
'key' => 'redirectURL', |
| 2088 |
'name' => __('URL', 'booking-package') . ': ', |
| 2089 |
'value' => '', |
| 2090 |
'inputType' => 'TEXT', |
| 2091 |
'isExtensionsValid' => 0, |
| 2092 |
'className' => 'multiple_fields_margin_top', |
| 2093 |
'actions' => null, |
| 2094 |
'valueList' => array(), |
| 2095 |
), |
| 2096 |
), |
| 2097 |
), |
| 2098 |
|
| 2099 |
); |
| 2100 |
|
| 2101 |
if ($this->payWithPayPay === 0) { |
| 2102 |
|
| 2103 |
unset($calendarAccount['paymentMethod']['valueList']['stripe_paypay']); |
| 2104 |
|
| 2105 |
} |
| 2106 |
|
| 2107 |
if ($this->maxBookingSlotsPerDay === 0) { |
| 2108 |
|
| 2109 |
unset($calendarAccount['maxBookingSlotsPerDay']); |
| 2110 |
|
| 2111 |
} |
| 2112 |
|
| 2113 |
return $calendarAccount; |
| 2114 |
|
| 2115 |
} |
| 2116 |
|
| 2117 |
public function getCourseData(){ |
| 2118 |
|
| 2119 |
$month = array( |
| 2120 |
'1' => array('key' => 1, 'name' => __('Jan', 'booking-package')), |
| 2121 |
'2' => array('key' => 2, 'name' => __('Feb', 'booking-package')), |
| 2122 |
'3' => array('key' => 3, 'name' => __('Mar', 'booking-package')), |
| 2123 |
'4' => array('key' => 4, 'name' => __('Apr', 'booking-package')), |
| 2124 |
'5' => array('key' => 5, 'name' => __('May', 'booking-package')), |
| 2125 |
'6' => array('key' => 6, 'name' => __('Jun', 'booking-package')), |
| 2126 |
'7' => array('key' => 7, 'name' => __('Jul', 'booking-package')), |
| 2127 |
'8' => array('key' => 8, 'name' => __('Aug', 'booking-package')), |
| 2128 |
'9' => array('key' => 9, 'name' => __('Sep', 'booking-package')), |
| 2129 |
'10' => array('key' => 10, 'name' => __('Oct', 'booking-package')), |
| 2130 |
'11' => array('key' => 11, 'name' => __('Nov', 'booking-package')), |
| 2131 |
'12' => array('key' => 12, 'name' => __('Dec', 'booking-package')), |
| 2132 |
); |
| 2133 |
|
| 2134 |
$day = array(); |
| 2135 |
for ($i = 1; $i <= 31; $i++) { |
| 2136 |
|
| 2137 |
$day[$i] = array('key' => $i, 'name' => $i); |
| 2138 |
|
| 2139 |
} |
| 2140 |
|
| 2141 |
$yearList = array(); |
| 2142 |
for ($i = 0; $i <= 10; $i++) { |
| 2143 |
|
| 2144 |
$year = date('Y') + $i; |
| 2145 |
$yearList[$year] = array('key' => $year, 'name' => $year); |
| 2146 |
|
| 2147 |
} |
| 2148 |
|
| 2149 |
$addNewCourse = array( |
| 2150 |
'name' => array('name' => __('Name', 'booking-package'), 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => '', 'filterHookKey' => 'dynamicTextModification'), |
| 2151 |
'description' => array('name' => __('Description', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXTAREA', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => '', 'filterHookKey' => 'dynamicTextModification'), |
| 2152 |
'active' => array('name' => __('Status', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'CHECK', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => array('true' => __('Enabled', 'booking-package'))), |
| 2153 |
'target' => array('name' => __('Target', 'booking-package'), 'value' => '', 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 0, 'valueList' => array('visitors_users' => __('Customers and Users', 'booking-package'), 'visitors' => __('Customers', 'booking-package'), 'users' => __('Users', 'booking-package'))), |
| 2154 |
'stopService' => array( |
| 2155 |
'key' => 'stopService', |
| 2156 |
'name' => __('Stop Offering This Service Under the Following Conditions', 'booking-package'), |
| 2157 |
'value' => '', |
| 2158 |
'inputLimit' => 1, |
| 2159 |
'inputType' => 'MULTIPLE_FIELDS', |
| 2160 |
'isExtensionsValid' => 1, |
| 2161 |
'message' => sprintf( __("If you select any option other than '%s', the '%s' feature will be disabled.", 'booking-package'), __('Disabled', 'booking-package'), __('Allow selecting multiple services', 'booking-package') ), |
| 2162 |
'valueList' => array( |
| 2163 |
0 => array( |
| 2164 |
'key' => 'stopServiceUnderFollowingConditions', |
| 2165 |
'name' => /**'Under the following conditions'**/ '', |
| 2166 |
'value' => null, |
| 2167 |
'inputType' => 'RADIO', |
| 2168 |
'isExtensionsValid' => 1, |
| 2169 |
'actions' => null, |
| 2170 |
'valueList' => array( |
| 2171 |
'doNotStop' => __('Disabled', 'booking-package'), |
| 2172 |
'isNotEqual' => sprintf( __("When the '%s' and '%s' values for the time slot do not match.", 'booking-package'), __('Available Slots', 'booking-package'), __('Remaining Slots', 'booking-package') ), |
| 2173 |
'isEqual' => sprintf( __("When the '%s' and '%s' values for the time slot are equal.", 'booking-package'), __('Available Slots', 'booking-package'), __('Remaining Slots', 'booking-package') ), |
| 2174 |
'specifiedNumberOfTimes' => __('When the specified booking limit is reached.', 'booking-package'), |
| 2175 |
), |
| 2176 |
'className' => 'stopServiceUnderFollowingConditions', |
| 2177 |
), |
| 2178 |
1 => array( |
| 2179 |
'key' => 'doNotStopServiceAsException', |
| 2180 |
'name' => '', |
| 2181 |
'value' => null, |
| 2182 |
'inputType' => 'CHECK', |
| 2183 |
'isExtensionsValid' => 1, |
| 2184 |
'actions' => null, |
| 2185 |
'valueList' => array( |
| 2186 |
'sameServiceIsNotStopped' => __('Allow booking this service if its start time overlaps with the start time of an existing booking for the same service.', 'booking-package'), |
| 2187 |
), |
| 2188 |
'className' => 'doNotStopServiceAsException', |
| 2189 |
), |
| 2190 |
2 => array( |
| 2191 |
'key' => 'stopServiceForDayOfTimes', |
| 2192 |
'name' => __('Target', 'booking-package') . ': ', |
| 2193 |
'value' => null, |
| 2194 |
'inputType' => 'RADIO', |
| 2195 |
'isExtensionsValid' => 1, |
| 2196 |
'actions' => null, |
| 2197 |
'valueList' => array( |
| 2198 |
'day' => __('Total bookings per day', 'booking-package'), |
| 2199 |
'timeSlot' => __('Bookings per time slot', 'booking-package'), |
| 2200 |
'startTimeSlot' => __('Maximum bookings per start time slot', 'booking-package'), |
| 2201 |
), |
| 2202 |
'className' => 'stopServiceForDayOfTimes', |
| 2203 |
), |
| 2204 |
3 => array( |
| 2205 |
'key' => 'stopServiceForSpecifiedNumberOfTimes', |
| 2206 |
'name' => __('Limit', 'booking-package') . ': ', |
| 2207 |
'value' => null, |
| 2208 |
'inputType' => 'TEXT', |
| 2209 |
'isExtensionsValid' => 1, |
| 2210 |
'actions' => null, |
| 2211 |
'valueList' => array(), |
| 2212 |
'className' => 'stopServiceForSpecifiedNumberOfTimes', |
| 2213 |
), |
| 2214 |
), |
| 2215 |
), |
| 2216 |
'costs' => array( |
| 2217 |
'key' => 'costs', |
| 2218 |
'name' => __('Prices', 'booking-package'), |
| 2219 |
'target' => 'day', |
| 2220 |
'disabled' => 0, |
| 2221 |
'value' => '1', |
| 2222 |
'inputLimit' => 2, |
| 2223 |
'inputType' => 'MULTIPLE_FIELDS', |
| 2224 |
'isExtensionsValid' => 0, |
| 2225 |
'option' => 0, |
| 2226 |
'message' => '', |
| 2227 |
'valueList' => array( |
| 2228 |
0 => array( |
| 2229 |
'key' => 'cost_1', |
| 2230 |
'name' => __(/**'Cost 1'**/ 'Base Price', 'booking-package'), |
| 2231 |
'value' => null, |
| 2232 |
'inputType' => 'TEXT', |
| 2233 |
'isExtensionsValid' => 0, |
| 2234 |
'actions' => null, |
| 2235 |
'valueList' => array(), |
| 2236 |
'className' => 'costs', |
| 2237 |
), |
| 2238 |
1 => array( |
| 2239 |
'key' => 'cost_2', |
| 2240 |
'name' => sprintf(__('Price %s', 'booking-package'), '2'), |
| 2241 |
'value' => null, |
| 2242 |
'inputType' => 'TEXT', |
| 2243 |
'isExtensionsValid' => 1, |
| 2244 |
'actions' => null, |
| 2245 |
'valueList' => array(), |
| 2246 |
'className' => 'costs', |
| 2247 |
), |
| 2248 |
2 => array( |
| 2249 |
'key' => 'cost_3', |
| 2250 |
'name' => sprintf(__('Price %s', 'booking-package'), '3'), |
| 2251 |
'value' => null, |
| 2252 |
'inputType' => 'TEXT', |
| 2253 |
'isExtensionsValid' => 1, |
| 2254 |
'actions' => null, |
| 2255 |
'valueList' => array(), |
| 2256 |
'className' => 'costs', |
| 2257 |
), |
| 2258 |
3 => array( |
| 2259 |
'key' => 'cost_4', |
| 2260 |
'name' => sprintf(__('Price %s', 'booking-package'), '4'), |
| 2261 |
'value' => null, |
| 2262 |
'inputType' => 'TEXT', |
| 2263 |
'isExtensionsValid' => 1, |
| 2264 |
'actions' => null, |
| 2265 |
'valueList' => array(), |
| 2266 |
'className' => 'costs', |
| 2267 |
), |
| 2268 |
4 => array( |
| 2269 |
'key' => 'cost_5', |
| 2270 |
'name' => sprintf(__('Price %s', 'booking-package'), '5'), |
| 2271 |
'value' => null, |
| 2272 |
'inputType' => 'TEXT', |
| 2273 |
'isExtensionsValid' => 1, |
| 2274 |
'actions' => null, |
| 2275 |
'valueList' => array(), |
| 2276 |
'className' => 'costs', |
| 2277 |
), |
| 2278 |
5 => array( |
| 2279 |
'key' => 'cost_6', |
| 2280 |
'name' => sprintf(__('Price %s', 'booking-package'), '6'), |
| 2281 |
'value' => null, |
| 2282 |
'inputType' => 'TEXT', |
| 2283 |
'isExtensionsValid' => 1, |
| 2284 |
'actions' => null, |
| 2285 |
'valueList' => array(), |
| 2286 |
'className' => 'costs', |
| 2287 |
), |
| 2288 |
), |
| 2289 |
), |
| 2290 |
'expirationDate' => array( |
| 2291 |
'key' => 'expirationDate', |
| 2292 |
'name' => __('Expiration Date', 'booking-package'), |
| 2293 |
'target' => 'both', |
| 2294 |
'disabled' => 0, |
| 2295 |
'value' => '1', |
| 2296 |
'inputLimit' => 2, |
| 2297 |
'inputType' => 'MULTIPLE_FIELDS', |
| 2298 |
'isExtensionsValid' => 0, |
| 2299 |
'option' => 0, |
| 2300 |
'valueList' => array( |
| 2301 |
0 => array( |
| 2302 |
'key' => 'expirationDateStatus', |
| 2303 |
'name' => '', |
| 2304 |
'value' => '0', |
| 2305 |
'inputType' => 'CHECK', |
| 2306 |
'isExtensionsValid' => 0, |
| 2307 |
'actions' => null, |
| 2308 |
'valueList' => array('1' => __('Enabled', 'booking-package')), |
| 2309 |
), |
| 2310 |
1 => array( |
| 2311 |
'key' => 'expirationDateFromMonth', |
| 2312 |
'name' => __('From:', 'booking-package') . ' ', |
| 2313 |
'value' => null, |
| 2314 |
'inputType' => 'SELECT', |
| 2315 |
'isExtensionsValid' => 0, |
| 2316 |
'className' => 'expirationDateFrom', |
| 2317 |
'actions' => null, |
| 2318 |
'valueList' => $month, |
| 2319 |
), |
| 2320 |
2 => array( |
| 2321 |
'key' => 'expirationDateFromDay', |
| 2322 |
'name' => '', |
| 2323 |
'value' => '', |
| 2324 |
'inputType' => 'SELECT', |
| 2325 |
'isExtensionsValid' => 0, |
| 2326 |
'className' => 'expirationDateFrom', |
| 2327 |
'actions' => null, |
| 2328 |
'valueList' => $day, |
| 2329 |
), |
| 2330 |
3 => array( |
| 2331 |
'key' => 'expirationDateFromYear', |
| 2332 |
'name' => '', |
| 2333 |
'value' => '', |
| 2334 |
'inputType' => 'SELECT', |
| 2335 |
'isExtensionsValid' => 0, |
| 2336 |
'className' => 'expirationDateFrom', |
| 2337 |
'actions' => null, |
| 2338 |
'valueList' => $yearList, |
| 2339 |
), |
| 2340 |
4 => array( |
| 2341 |
'key' => 'expirationDateToMonth', |
| 2342 |
'name' => __('To:', 'booking-package') . ' ', |
| 2343 |
'value' => null, |
| 2344 |
'inputType' => 'SELECT', |
| 2345 |
'isExtensionsValid' => 0, |
| 2346 |
'className' => 'expirationDateTo', |
| 2347 |
'actions' => null, |
| 2348 |
'valueList' => $month, |
| 2349 |
), |
| 2350 |
5 => array( |
| 2351 |
'key' => 'expirationDateToDay', |
| 2352 |
'name' => '', |
| 2353 |
'value' => '', |
| 2354 |
'inputType' => 'SELECT', |
| 2355 |
'isExtensionsValid' => 0, |
| 2356 |
'className' => 'expirationDateTo', |
| 2357 |
'actions' => null, |
| 2358 |
'valueList' => $day, |
| 2359 |
), |
| 2360 |
6 => array( |
| 2361 |
'key' => 'expirationDateToYear', |
| 2362 |
'name' => '', |
| 2363 |
'value' => '', |
| 2364 |
'inputType' => 'SELECT', |
| 2365 |
'isExtensionsValid' => 0, |
| 2366 |
'className' => 'expirationDateTo', |
| 2367 |
'actions' => null, |
| 2368 |
'valueList' => $yearList, |
| 2369 |
), |
| 2370 |
), |
| 2371 |
), |
| 2372 |
'time' => array('name' => __('Duration Time', 'booking-package'), 'value' => '', 'inputLimit' => 1, 'inputType' => 'SELECT', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => array()), |
| 2373 |
'timeToProvide' => array('name' => __('Specify the Time Slots for Each Day of the Week', 'booking-package'), 'value' => '0', 'inputLimit' => 2, 'inputType' => 'TIME_TO_PROVIDE', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 1, 'valueList' => array()), |
| 2374 |
'selectOptions' => array('name' => __('Allow Selecting Multiple Options', 'booking-package'), 'value' => '0', 'inputLimit' => 2, 'inputType' => 'CHECK', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 1, 'valueList' => array('1' => __('Enabled', 'booking-package'))), |
| 2375 |
'options' => array( |
| 2376 |
'name' => __('Options', 'booking-package'), |
| 2377 |
'value' => '', |
| 2378 |
'inputLimit' => 2, |
| 2379 |
'inputType' => 'EXTRA', |
| 2380 |
'isExtensionsValid' => 1, |
| 2381 |
'isExtensionsValidPanel' => 0, |
| 2382 |
'format' => 'json', |
| 2383 |
'valueList' => '', |
| 2384 |
'filterHookKey' => 'dynamicTextModification', |
| 2385 |
"optionsType" => array( |
| 2386 |
"name" => array("type" => "TEXT", "value" => "", "target" => "both"), |
| 2387 |
/** "cost" => array("type" => "TEXT", "value" => "", "target" => "both"), **/ |
| 2388 |
"cost_1" => array("type" => "TEXT", "value" => "", "target" => "both"), |
| 2389 |
"cost_2" => array("type" => "TEXT", "value" => "", "target" => "both"), |
| 2390 |
"cost_3" => array("type" => "TEXT", "value" => "", "target" => "both"), |
| 2391 |
"cost_4" => array("type" => "TEXT", "value" => "", "target" => "both"), |
| 2392 |
"cost_5" => array("type" => "TEXT", "value" => "", "target" => "both"), |
| 2393 |
"cost_6" => array("type" => "TEXT", "value" => "", "target" => "both"), |
| 2394 |
"time" => array("type" => "SELECT", "value" => 0, "target" => "both", "start" => 0, "end" => 725, "addition" => 5, 'unit' => __("%s min", 'booking-package')) |
| 2395 |
), |
| 2396 |
'titleList' => array('name' => __('Name', 'booking-package'), |
| 2397 |
/** 'cost' => __('Price', 'booking-package'), **/ |
| 2398 |
'cost_1' => __(/**'Cost 1'**/ 'Base Price', 'booking-package'), |
| 2399 |
'cost_2' => sprintf(__('Price %s', 'booking-package'), '2'), |
| 2400 |
'cost_3' => sprintf(__('Price %s', 'booking-package'), '3'), |
| 2401 |
'cost_4' => sprintf(__('Price %s', 'booking-package'), '4'), |
| 2402 |
'cost_5' => sprintf(__('Price %s', 'booking-package'), '5'), |
| 2403 |
'cost_6' => sprintf(__('Price %s', 'booking-package'), '6'), |
| 2404 |
|
| 2405 |
'time' => __('Additional Duration', 'booking-package')) |
| 2406 |
), |
| 2407 |
); |
| 2408 |
return $addNewCourse; |
| 2409 |
|
| 2410 |
} |
| 2411 |
|
| 2412 |
public function getSubscriptionsData(){ |
| 2413 |
|
| 2414 |
$addSubscriptions = array( |
| 2415 |
'subscription' => array('name' => 'Subscription', 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => ''), |
| 2416 |
'name' => array('name' => 'Name', 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => ''), |
| 2417 |
'active' => array('name' => 'Status', 'value' => '', 'inputLimit' => 2, 'inputType' => 'CHECK', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => array('true' => __('Enabled', 'booking-package'))), |
| 2418 |
'renewal' => array('name' => 'Automatic subscription renewal', 'value' => '', 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'valueList' => array('0' => __('Invalid', 'booking-package'), '1' => __('Valid', 'booking-package')), "message" => ''), |
| 2419 |
'limit' => array('name' => 'Booking limit', 'value' => '', 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'valueList' => array('0' => __('Invalid', 'booking-package'), '1' => __('Valid', 'booking-package')), "message" => ''), |
| 2420 |
'numberOfTimes' => array('name' => 'Number of times users can book by the following deadline', 'value' => '', 'inputLimit' => 1, 'inputType' => 'SELECT', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => array(1 => '1', 2 => '2')), |
| 2421 |
); |
| 2422 |
|
| 2423 |
return $addSubscriptions; |
| 2424 |
|
| 2425 |
} |
| 2426 |
|
| 2427 |
public function getTaxesData(){ |
| 2428 |
|
| 2429 |
$month = array( |
| 2430 |
'1' => array('key' => 1, 'name' => __('Jan', 'booking-package')), |
| 2431 |
'2' => array('key' => 2, 'name' => __('Feb', 'booking-package')), |
| 2432 |
'3' => array('key' => 3, 'name' => __('Mar', 'booking-package')), |
| 2433 |
'4' => array('key' => 4, 'name' => __('Apr', 'booking-package')), |
| 2434 |
'5' => array('key' => 5, 'name' => __('May', 'booking-package')), |
| 2435 |
'6' => array('key' => 6, 'name' => __('Jun', 'booking-package')), |
| 2436 |
'7' => array('key' => 7, 'name' => __('Jul', 'booking-package')), |
| 2437 |
'8' => array('key' => 8, 'name' => __('Aug', 'booking-package')), |
| 2438 |
'9' => array('key' => 9, 'name' => __('Sep', 'booking-package')), |
| 2439 |
'10' => array('key' => 10, 'name' => __('Oct', 'booking-package')), |
| 2440 |
'11' => array('key' => 11, 'name' => __('Nov', 'booking-package')), |
| 2441 |
'12' => array('key' => 12, 'name' => __('Dec', 'booking-package')), |
| 2442 |
); |
| 2443 |
|
| 2444 |
$day = array(); |
| 2445 |
for ($i = 1; $i <= 31; $i++) { |
| 2446 |
|
| 2447 |
$day[$i] = array('key' => $i, 'name' => $i); |
| 2448 |
|
| 2449 |
} |
| 2450 |
|
| 2451 |
$yearList = array(); |
| 2452 |
for ($i = 0; $i <= 10; $i++) { |
| 2453 |
|
| 2454 |
$year = date('Y') + $i; |
| 2455 |
$yearList[$year] = array('key' => $year, 'name' => $year); |
| 2456 |
|
| 2457 |
} |
| 2458 |
|
| 2459 |
$addSubscriptions = array( |
| 2460 |
'name' => array('name' => __('Name', 'booking-package'), 'type' => 'both', 'gen' => 'both', 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 1, 'valueList' => '', 'filterHookKey' => 'dynamicTextModification'), |
| 2461 |
'active' => array('name' => __('Status', 'booking-package'), 'type' => 'both', 'gen' => 'both', 'value' => '', 'inputLimit' => 2, 'inputType' => 'CHECK', 'isExtensionsValid' => 0, 'isExtensionsValidPanel' => 1, 'valueList' => array('true' => __('Enabled', 'booking-package')), 'actions' => null), |
| 2462 |
'type' => array('name' => __('Type', 'booking-package'), 'type' => 'both', 'gen' => '1', 'value' => '', 'inputLimit' => 2, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 1, 'valueList' => array('tax' => __('Tax', 'booking-package'), 'surcharge' => __('Extra Charge', 'booking-package')), 'option' => 1, 'optionsList' => array('tax' => 1, 'method' => 1), 'actions' => null), |
| 2463 |
'tax' => array('name' => __('Tax', 'booking-package'), 'type' => 'tax', 'gen' => 'both', 'value' => '', 'inputLimit' => 2, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 1, 'valueList' => array('tax_exclusive' => __('Tax-exclusive pricing', 'booking-package'), 'tax_inclusive' => __('Tax-inclusive pricing', 'booking-package')), 'actions' => null, 'valueClasses' => array('tax_exclusive' => 'tax_exclusive', 'tax_inclusive' => 'tax_inclusive'), 'disabled' => 1), |
| 2464 |
'method' => array('name' => __('Calculation Method', 'booking-package'), 'type' => 'tax', 'gen' => 'both', 'value' => '', 'inputLimit' => 2, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 1, 'valueList' => array('addition' => __('Add Fixed Amount', 'booking-package'), 'multiplication' => __('Apply Percentage', 'booking-package')), 'actions' => null, 'valueClasses' => array('addition' => 'calculationMethod', 'multiplication' => 'calculationMethod')), |
| 2465 |
'target' => array('name' => __('Target', 'booking-package'), 'type' => 'both', 'gen' => 'both', 'value' => '', 'inputLimit' => 2, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 1, 'valueList' => array('room' => __('Per Room', 'booking-package'), 'guest' => __('Per Guest', 'booking-package')), 'actions' => null, 'valueClasses' => array('room' => 'target_room', 'guest' => 'target_guest')), |
| 2466 |
'scope' => array('name' => __('Range of tax or surcharge', 'booking-package'), 'type' => 'both', 'gen' => 'both', 'value' => '', 'inputLimit' => 2, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 1, 'valueList' => array('day' => __('Per day', 'booking-package'), 'booking' => __('Per one booking', 'booking-package'), 'bookingEachGuests' => __('Per one booking for all guests', 'booking-package')), 'actions' => null), |
| 2467 |
'value' => array('name' => __('Value', 'booking-package'), 'type' => 'both', 'gen' => 'both', 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 1, 'valueList' => '', 'actions' => null), |
| 2468 |
'expirationDate' => array( |
| 2469 |
'key' => 'expirationDate', |
| 2470 |
'name' => __('Expiration Date', 'booking-package'), |
| 2471 |
'type' => 'both', |
| 2472 |
'gen' => 'both', |
| 2473 |
'target' => 'both', |
| 2474 |
'disabled' => 0, |
| 2475 |
'value' => '1', |
| 2476 |
'inputLimit' => 2, |
| 2477 |
'inputType' => 'MULTIPLE_FIELDS', |
| 2478 |
'isExtensionsValid' => 1, |
| 2479 |
'option' => 0, |
| 2480 |
'actions' => null, |
| 2481 |
'valueList' => array( |
| 2482 |
0 => array( |
| 2483 |
'key' => 'expirationDateStatus', |
| 2484 |
'name' => '', |
| 2485 |
'value' => '0', |
| 2486 |
'inputType' => 'CHECK', |
| 2487 |
'isExtensionsValid' => 1, |
| 2488 |
'actions' => null, |
| 2489 |
'valueList' => array('1' => __('Enabled', 'booking-package')), |
| 2490 |
), |
| 2491 |
1 => array( |
| 2492 |
'key' => 'expirationDateFromMonth', |
| 2493 |
'name' => __('From', 'booking-package') . ': ', |
| 2494 |
'value' => null, |
| 2495 |
'inputType' => 'SELECT', |
| 2496 |
'isExtensionsValid' => 1, |
| 2497 |
'className' => 'expirationDateFrom', |
| 2498 |
'actions' => null, |
| 2499 |
'valueList' => $month, |
| 2500 |
), |
| 2501 |
2 => array( |
| 2502 |
'key' => 'expirationDateFromDay', |
| 2503 |
'name' => '', |
| 2504 |
'value' => '', |
| 2505 |
'inputType' => 'SELECT', |
| 2506 |
'isExtensionsValid' => 1, |
| 2507 |
'className' => 'expirationDateFrom', |
| 2508 |
'actions' => null, |
| 2509 |
'valueList' => $day, |
| 2510 |
), |
| 2511 |
3 => array( |
| 2512 |
'key' => 'expirationDateFromYear', |
| 2513 |
'name' => '', |
| 2514 |
'value' => '', |
| 2515 |
'inputType' => 'SELECT', |
| 2516 |
'isExtensionsValid' => 1, |
| 2517 |
'className' => 'expirationDateFrom', |
| 2518 |
'actions' => null, |
| 2519 |
'valueList' => $yearList, |
| 2520 |
), |
| 2521 |
4 => array( |
| 2522 |
'key' => 'expirationDateToMonth', |
| 2523 |
'name' => __('To', 'booking-package') . ': ', |
| 2524 |
'value' => null, |
| 2525 |
'inputType' => 'SELECT', |
| 2526 |
'isExtensionsValid' => 1, |
| 2527 |
'className' => 'expirationDateTo', |
| 2528 |
'actions' => null, |
| 2529 |
'valueList' => $month, |
| 2530 |
), |
| 2531 |
5 => array( |
| 2532 |
'key' => 'expirationDateToDay', |
| 2533 |
'name' => '', |
| 2534 |
'value' => '', |
| 2535 |
'inputType' => 'SELECT', |
| 2536 |
'isExtensionsValid' => 1, |
| 2537 |
'className' => 'expirationDateTo', |
| 2538 |
'actions' => null, |
| 2539 |
'valueList' => $day, |
| 2540 |
), |
| 2541 |
6 => array( |
| 2542 |
'key' => 'expirationDateToYear', |
| 2543 |
'name' => '', |
| 2544 |
'value' => '', |
| 2545 |
'inputType' => 'SELECT', |
| 2546 |
'isExtensionsValid' => 1, |
| 2547 |
'className' => 'expirationDateTo', |
| 2548 |
'actions' => null, |
| 2549 |
'valueList' => $yearList, |
| 2550 |
), |
| 2551 |
), |
| 2552 |
), |
| 2553 |
); |
| 2554 |
|
| 2555 |
return $addSubscriptions; |
| 2556 |
|
| 2557 |
} |
| 2558 |
|
| 2559 |
public function getOptionsForHotelData(){ |
| 2560 |
|
| 2561 |
$options = array( |
| 2562 |
'name' => array('name' => __('Name', 'booking-package'), 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 0, 'valueList' => '', 'disabled' => 0, 'filterHookKey' => 'dynamicTextModification'), |
| 2563 |
'description' => array('name' => __('Description', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXTAREA', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 0, 'valueList' => '', 'target' => 'both', 'filterHookKey' => 'dynamicTextModification'), |
| 2564 |
'active' => array('name' => __('Status', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'CHECK', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 0, 'valueList' => array('true' => __('Enabled', 'booking-package'))), |
| 2565 |
'required' => array('key' => 'required', 'name' => 'Required', 'value' => 'true', 'inputLimit' => 1, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 0, 'valueList' => array('true' => __('Yes', 'booking-package'), 'false' => __('No', 'booking-package')), "class" => ""), |
| 2566 |
'range' => array('name' => __('Pricing Basis', 'booking-package'), 'value' => 'allDays', 'inputLimit' => 2, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 0, 'valueList' => array('allDays' => __('Charge per Day', 'booking-package'), 'oneBooking' => __('Charge Once per Booking', 'booking-package')), 'actions' => null), |
| 2567 |
'target' => array('name' => __('Calculation Basis', 'booking-package'), 'value' => 'guests', 'inputLimit' => 2, 'inputType' => 'RADIO', 'isExtensionsValid' => 1, 'isExtensionsValidPanel' => 0, 'valueList' => array('guests' => __('Per Guest', 'booking-package'), 'room' => __('Per Room', 'booking-package')), 'actions' => null), |
| 2568 |
'json' => array( |
| 2569 |
'name' => __('Options', 'booking-package'), |
| 2570 |
'value' => '', |
| 2571 |
'inputLimit' => 2, |
| 2572 |
'inputType' => 'EXTRA', |
| 2573 |
'isExtensionsValid' => 1, |
| 2574 |
'isExtensionsValidPanel' => 0, |
| 2575 |
'format' => 'json', |
| 2576 |
'valueList' => '', |
| 2577 |
'filterHookKey' => 'dynamicTextModification', |
| 2578 |
"optionsType" => array( |
| 2579 |
"name" => array("type" => "TEXT", "value" => "", "target" => "both"), |
| 2580 |
"adult" => array("type" => "TEXT", "value" => "", "target" => "both", "class" => array("optionWithChargeAdult")), |
| 2581 |
"child" => array("type" => "TEXT", "value" => "", "target" => "both", "class" => array("optionWithChargeChild")), |
| 2582 |
"room" => array("type" => "TEXT", "value" => "", "target" => "both", "class" => array("optionWithChargeRoom")) |
| 2583 |
), |
| 2584 |
'titleList' => array( |
| 2585 |
'name' => __('Display Text', 'booking-package'), |
| 2586 |
'adult' => __('Extra Charge per Adult', 'booking-package'), |
| 2587 |
'child' => __('Extra Charge per Child', 'booking-package'), |
| 2588 |
'room' => __('Extra Charge per Room', 'booking-package') |
| 2589 |
) |
| 2590 |
), |
| 2591 |
); |
| 2592 |
|
| 2593 |
return $options; |
| 2594 |
|
| 2595 |
} |
| 2596 |
|
| 2597 |
public function getFormInputTypeForUser() { |
| 2598 |
|
| 2599 |
$input = array( |
| 2600 |
'id' => array('key' => 'id', 'name' => __('Unique ID', 'booking-package'), 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', "class" => ""), |
| 2601 |
'name' => array('key' => 'name', 'name' => __('Name', 'booking-package'), 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', "class" => ""), |
| 2602 |
'uri' => array('key' => 'uri', 'name' => 'URL', 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXT', "class" => ""), |
| 2603 |
'placeholder' => array('key' => 'placeholder', 'name' => __('Placeholder Text', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXT', "class" => ""), |
| 2604 |
'description' => array('key' => 'description', 'name' => __('Description', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXTAREA', "class" => ""), |
| 2605 |
'active' => array('key' => 'active', 'name' => __('Status', 'booking-package'), 'value' => array('Enabled'), 'inputLimit' => 2, 'inputType' => 'CHECK', 'valueList' => array(__('Enabled', 'booking-package')), "class" => ""), |
| 2606 |
'required' => array('key' => 'required', 'name' => __('Required', 'booking-package'), 'value' => array('Enabled'), 'inputLimit' => 1, 'inputType' => 'CHECK', 'valueList' => array(__('Enabled', 'booking-package')), "class" => ""), |
| 2607 |
'type' => array('key' => 'type', 'name' => __('Type', 'booking-package'), 'value' => 'TEXT', 'inputLimit' => 1, 'inputType' => 'SELECT', 'valueList' => array('TEXT' => 'TEXT', 'SELECT' => 'SELECT', 'CHECK' => 'CHECK', 'RADIO' => 'RADIO', 'TEXTAREA' => 'TEXTAREA'), "class" => ""), |
| 2608 |
'options' => array('key' => 'options', 'name' => __('Options', 'booking-package'), 'value' => array(''), 'inputLimit' => 2, 'inputType' => 'OPTION', 'format' => 'array', "class" => "", "options" => array("name" => "text"), 'format' => 'jsonString', 'optionsType' => array(array("type" => "TEXT", "value" => "", "target" => "both"))), |
| 2609 |
); |
| 2610 |
|
| 2611 |
foreach ($input as $key => $value) { |
| 2612 |
|
| 2613 |
$input[$key]['disabled'] = 0; |
| 2614 |
$input[$key]['id'] = $value['key']; |
| 2615 |
$input[$key]['type'] = $value['inputType']; |
| 2616 |
|
| 2617 |
if (isset($value['valueList']) === true) { |
| 2618 |
|
| 2619 |
$input[$key]['options'] = $value['valueList']; |
| 2620 |
|
| 2621 |
} |
| 2622 |
|
| 2623 |
} |
| 2624 |
|
| 2625 |
return $input; |
| 2626 |
|
| 2627 |
} |
| 2628 |
|
| 2629 |
public function getFormInputType(){ |
| 2630 |
|
| 2631 |
$formInputType = array( |
| 2632 |
'id' => array('key' => 'id', 'name' => __('Unique ID', 'booking-package'), 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', "class" => ""), |
| 2633 |
'name' => array('key' => 'name', 'name' => __('Name', 'booking-package'), 'value' => '', 'inputLimit' => 1, 'inputType' => 'TEXT', "class" => "", 'filterHookKey' => 'dynamicTextModification'), |
| 2634 |
'value' => array('key' => 'value', 'name' => __('Value', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXT', "class" => "hidden_panel"), |
| 2635 |
'groupId' => array('key' => 'groupId', 'name' => 'Group ID', 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXT', "class" => ""), |
| 2636 |
#'groupName' => array('key' => 'groupName', 'name' => 'Group name', 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXT', "class" => ""), |
| 2637 |
'uri' => array('key' => 'uri', 'name' => 'URL', 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXT', "class" => "", 'filterHookKey' => 'dynamicTextModification'), |
| 2638 |
'placeholder' => array('key' => 'placeholder', 'name' => __('Placeholder Text', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXT', "class" => "", 'filterHookKey' => 'dynamicTextModification'), |
| 2639 |
'description' => array('key' => 'description', 'name' => __('Description', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'TEXTAREA', "class" => "", 'filterHookKey' => 'dynamicTextModification'), |
| 2640 |
'active' => array('key' => 'active', 'name' => __('Status', 'booking-package'), 'value' => 'true', 'inputLimit' => 2, 'inputType' => 'CHECK', 'valueList' => array('true' => __('Enabled', 'booking-package')), "class" => ""), |
| 2641 |
'required' => array('key' => 'required', 'name' => __('Required', 'booking-package'), 'value' => 'false', 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('true' => __('Yes - Front-end and Dashboard', 'booking-package'), 'true_frontEnd' => __('Yes - Front-end only', 'booking-package'), 'false' => __('No', 'booking-package')), "class" => ""), |
| 2642 |
'isName' => array('key' => 'isName', 'name' => sprintf(__('Use as %s Field', 'booking-package'), __('Name', 'booking-package')), 'value' => 'false', 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('true' => __('Yes', 'booking-package'), 'false' => __('No', 'booking-package')), "class" => ""), |
| 2643 |
'isEmail' => array('key' => 'isEmail', 'name' => sprintf(__('Use as %s Field', 'booking-package'), __('Email', 'booking-package')), 'value' => 'false', 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('true' => __('Yes', 'booking-package'), 'false' => __('No', 'booking-package')), "class" => ""), |
| 2644 |
'isSMS' => array('key' => 'isSMS', 'name' => sprintf(__('Use as %s Field', 'booking-package'), 'SMS'), 'value' => 'false', 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('true' => __('Yes', 'booking-package'), 'false' => __('No', 'booking-package')), "class" => "", 'message' => sprintf(__('If you select "%s," you will need to change the value of "Messaging Services" in the %s tab.', 'booking-package'), __('Yes', 'booking-package'), __('Settings', 'booking-package'))), |
| 2645 |
'isAddress' => array('key' => 'isAddress', 'name' => sprintf(__('Use as %s Field', 'booking-package'), __('Location', 'booking-package')), 'value' => 'false', 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('true' => __('Yes', 'booking-package'), 'false' => __('No', 'booking-package')), "class" => ""), |
| 2646 |
'isTerms' => array('key' => 'isTerms', 'name' => sprintf(__('Use as %s Field', 'booking-package'), __('Agreement (Terms/Privacy)', 'booking-package')), 'value' => 'false', 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('true' => __('Yes', 'booking-package'), 'false' => __('No', 'booking-package')), "class" => ""), |
| 2647 |
'isAutocomplete' => array('key' => 'isAutocomplete', 'name' => __('Save User Input Values', 'booking-package'), 'value' => 'false', 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('true' => __('Yes', 'booking-package'), 'false' => __('No', 'booking-package')), "class" => ""), |
| 2648 |
'targetCustomers' => array('key' => 'targetCustomers', 'name' => __('Target', 'booking-package'), 'value' => 'customers', 'inputLimit' => 1, 'inputType' => 'RADIO', 'valueList' => array('customersAndUsers' => __('Customers and Users', 'booking-package'), 'visitors' => __('Customers', 'booking-package'), 'users' => __('Users', 'booking-package')), "class" => ""), |
| 2649 |
'type' => array('key' => 'type', 'name' => __('Type', 'booking-package'), 'value' => 'TEXT', 'inputLimit' => 1, 'inputType' => 'SELECT', 'valueList' => array('TEXT' => 'TEXT', 'SELECT' => 'SELECT', 'CHECK' => 'CHECK', 'RADIO' => 'RADIO', 'TEXTAREA' => 'TEXTAREA'), "class" => ""), |
| 2650 |
'options' => array('key' => 'options', 'name' => __('Options', 'booking-package'), 'value' => '', 'inputLimit' => 2, 'inputType' => 'OPTION', 'format' => 'array', "class" => "", "options" => array("name" => "text"), 'format' => 'jsonString', 'optionsType' => array(array("type" => "TEXT", "value" => "", "target" => "both")), 'filterHookKey' => 'dynamicTextModification'), |
| 2651 |
); |
| 2652 |
|
| 2653 |
if ($this->messagingApp === 0) { |
| 2654 |
|
| 2655 |
unset($formInputType['isSMS']['message']); |
| 2656 |
|
| 2657 |
} |
| 2658 |
|
| 2659 |
return $formInputType; |
| 2660 |
|
| 2661 |
} |
| 2662 |
|
| 2663 |
public function updateMemberSetting(){ |
| 2664 |
|
| 2665 |
global $wpdb; |
| 2666 |
$isExtensionsValid = $this->getExtensionsValid(); |
| 2667 |
$user_toolbar = intval(get_option($this->prefix . 'user_toolbar', 0)); |
| 2668 |
if (isset($_POST['user_toolbar']) && intval($_POST['user_toolbar']) != $user_toolbar) { |
| 2669 |
|
| 2670 |
$bool = 'false'; |
| 2671 |
if (intval($_POST['user_toolbar']) == 1) { |
| 2672 |
|
| 2673 |
$bool = 'true'; |
| 2674 |
|
| 2675 |
} |
| 2676 |
$table_name = $wpdb->prefix."booking_package_users"; |
| 2677 |
$sql = $wpdb->prepare("SELECT `key` FROM ".$table_name.";", array()); |
| 2678 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 2679 |
for ($i = 0; $i < count($rows); $i++) { |
| 2680 |
|
| 2681 |
$key = intval($rows[$i]['key']); |
| 2682 |
update_user_meta($key, 'show_admin_bar_front', $bool); |
| 2683 |
|
| 2684 |
} |
| 2685 |
|
| 2686 |
} |
| 2687 |
|
| 2688 |
$userFunctions = $this->userFunctions(); |
| 2689 |
foreach ((array) $userFunctions as $key => $input) { |
| 2690 |
|
| 2691 |
if (isset($_POST[$key])) { |
| 2692 |
|
| 2693 |
$value = sanitize_text_field($_POST[$key]); |
| 2694 |
if ($isExtensionsValid !== true && $input['inputType'] == "CHECK") { |
| 2695 |
|
| 2696 |
$value = 0; |
| 2697 |
|
| 2698 |
} |
| 2699 |
|
| 2700 |
if ($input['inputType'] == "TEXTAREA") { |
| 2701 |
|
| 2702 |
$value = sanitize_textarea_field($_POST[$key]); |
| 2703 |
|
| 2704 |
} |
| 2705 |
|
| 2706 |
update_option($this->prefix.$key, $value); |
| 2707 |
$userFunctions[$key]["value"] = $value; |
| 2708 |
|
| 2709 |
} |
| 2710 |
|
| 2711 |
} |
| 2712 |
|
| 2713 |
return $userFunctions; |
| 2714 |
|
| 2715 |
} |
| 2716 |
|
| 2717 |
public function update($post){ |
| 2718 |
|
| 2719 |
$extentionBool = $this->getExtensionsValid(); |
| 2720 |
$list = $this->getList(); |
| 2721 |
if (isset($_POST['type']) && $_POST['type'] == "bookingSync") { |
| 2722 |
|
| 2723 |
$list = $this->getBookingSyncList(); |
| 2724 |
|
| 2725 |
} |
| 2726 |
|
| 2727 |
foreach ((array) $list as $listKey => $listValue) { |
| 2728 |
/** |
| 2729 |
if ($extentionBool === false && $listKey == 'Stripe') { |
| 2730 |
|
| 2731 |
continue; |
| 2732 |
|
| 2733 |
} |
| 2734 |
**/ |
| 2735 |
|
| 2736 |
$category = array(); |
| 2737 |
foreach ((array) $listValue as $key => $value) { |
| 2738 |
|
| 2739 |
|
| 2740 |
if (isset($post[$key]) === true) { |
| 2741 |
|
| 2742 |
$value = ""; |
| 2743 |
if (isset($listValue['inputType']) && $listValue['inputType'] == "TEXTAREA") { |
| 2744 |
|
| 2745 |
$value = sanitize_textarea_field($post[$key]); |
| 2746 |
if ($key == 'booking_package_googleCalendar_json') { |
| 2747 |
|
| 2748 |
$value = array(); |
| 2749 |
$json = json_decode($post[$key], true); |
| 2750 |
foreach ((array) $json as $jsonKey => $jsonValue) { |
| 2751 |
|
| 2752 |
$value[sanitize_text_field($jsonKey)] = sanitize_text_field($jsonValue); |
| 2753 |
|
| 2754 |
} |
| 2755 |
|
| 2756 |
$value = json_encode($value); |
| 2757 |
|
| 2758 |
} |
| 2759 |
|
| 2760 |
} else if (isset($listValue['inputType']) && $listValue['inputType'] == "MULTIPLE_FIELDS") { |
| 2761 |
|
| 2762 |
var_dump($listValue); |
| 2763 |
|
| 2764 |
} else { |
| 2765 |
|
| 2766 |
$value = sanitize_text_field(trim($post[$key])); |
| 2767 |
|
| 2768 |
} |
| 2769 |
#$value = sanitize_text_field($post[$key]); |
| 2770 |
|
| 2771 |
if (get_option($key) === false) { |
| 2772 |
|
| 2773 |
add_option($key, $value); |
| 2774 |
|
| 2775 |
} else { |
| 2776 |
|
| 2777 |
update_option($key, $value); |
| 2778 |
|
| 2779 |
} |
| 2780 |
|
| 2781 |
} |
| 2782 |
|
| 2783 |
if (isset($listValue[$key]['inputType']) && $listValue[$key]['inputType'] == "MULTIPLE_FIELDS") { |
| 2784 |
|
| 2785 |
$options = $listValue[$key]['valueList']; |
| 2786 |
for ($i = 0; $i < count($options); $i++) { |
| 2787 |
|
| 2788 |
|
| 2789 |
$optionKey = $options[$i]['key']; |
| 2790 |
if (isset($post[$optionKey]) === true) { |
| 2791 |
|
| 2792 |
if (get_option($optionKey) === false) { |
| 2793 |
|
| 2794 |
add_option($optionKey, sanitize_text_field($post[$optionKey])); |
| 2795 |
|
| 2796 |
} else { |
| 2797 |
|
| 2798 |
update_option($optionKey, sanitize_text_field($post[$optionKey])); |
| 2799 |
|
| 2800 |
} |
| 2801 |
|
| 2802 |
} |
| 2803 |
|
| 2804 |
} |
| 2805 |
|
| 2806 |
} |
| 2807 |
|
| 2808 |
$category[$key] = $value; |
| 2809 |
|
| 2810 |
} |
| 2811 |
|
| 2812 |
$list[$listKey] = $category; |
| 2813 |
|
| 2814 |
} |
| 2815 |
|
| 2816 |
return $list; |
| 2817 |
|
| 2818 |
} |
| 2819 |
|
| 2820 |
public function refreshToken($key, $home = false){ |
| 2821 |
|
| 2822 |
$key = sanitize_text_field($key); |
| 2823 |
$token = hash('ripemd160', sanitize_text_field($home)); |
| 2824 |
if($home === false){ |
| 2825 |
|
| 2826 |
#$timezone = get_option('timezone_string'); |
| 2827 |
#date_default_timezone_set($timezone); |
| 2828 |
$token = hash('ripemd160', date('U')); |
| 2829 |
|
| 2830 |
} |
| 2831 |
|
| 2832 |
update_option($key, $token); |
| 2833 |
return array('status' => 'success', 'token' => $token, 'key' => $key); |
| 2834 |
|
| 2835 |
} |
| 2836 |
|
| 2837 |
public function initialUserInputFields () { |
| 2838 |
|
| 2839 |
$requiredKeys = array('user_login', 'user_email', 'user_pass'); |
| 2840 |
$initialUserInputFields = array( |
| 2841 |
'user_login' => array('id' => 'user_login', 'active' => 'true', 'name' => 'Username', 'value' => '', 'isName' => 'true', 'options' => array(), 'description' => '', 'placeholder' => '', 'uri' => '', 'required' => 'true', 'type' => 'TEXT'), |
| 2842 |
'user_email' => array('id' => 'user_email', 'active' => 'true', 'name' => 'Email', 'value' => '', 'isName' => 'true', 'options' => array(), 'description' => '', 'placeholder' => '', 'uri' => '', 'required' => 'true', 'type' => 'TEXT'), |
| 2843 |
'user_pass' => array('id' => 'user_pass', 'active' => 'true', 'name' => 'Password', 'value' => '', 'isName' => 'true', 'options' => array(), 'description' => '', 'placeholder' => '', 'uri' => '', 'required' => 'true', 'type' => 'PASSWORD'), |
| 2844 |
'first_name' => array('id' => 'first_name', 'active' => 'false', 'name' => __('First name', 'Booking-Package'), 'value' => '', 'isName' => 'true', 'options' => array(), 'description' => '', 'placeholder' => '', 'uri' => '', 'required' => 'true', 'type' => 'TEXT'), |
| 2845 |
'last_name' => array('id' => 'last_name', 'active' => 'false', 'name' => __('Last name', 'booking-package'), 'value' => '', 'isName' => 'true', 'options' => array(), 'description' => '', 'placeholder' => '', 'uri' => '', 'required' => 'true', 'type' => 'TEXT'), |
| 2846 |
); |
| 2847 |
$userInputFields = get_option("_" . $this->prefix . "getUserInputFields", null); |
| 2848 |
if (empty($userInputFields) === true) { |
| 2849 |
|
| 2850 |
$userInputFields = $initialUserInputFields; |
| 2851 |
add_option("_" . $this->prefix . "getUserInputFields", json_encode($userInputFields)); |
| 2852 |
|
| 2853 |
} else { |
| 2854 |
|
| 2855 |
$userInputFields = json_decode($userInputFields, true); |
| 2856 |
$required = true; |
| 2857 |
for ($i = 0; $i < count($requiredKeys); $i++) { |
| 2858 |
|
| 2859 |
if (array_key_exists($requiredKeys[$i], $userInputFields) === false) { |
| 2860 |
|
| 2861 |
$required = false; |
| 2862 |
break; |
| 2863 |
|
| 2864 |
} |
| 2865 |
|
| 2866 |
} |
| 2867 |
|
| 2868 |
if ($required === false) { |
| 2869 |
|
| 2870 |
$userInputFields = array_merge($initialUserInputFields, $userInputFields); |
| 2871 |
update_option("_" . $this->prefix . "getUserInputFields", json_encode($userInputFields)); |
| 2872 |
|
| 2873 |
} |
| 2874 |
|
| 2875 |
} |
| 2876 |
|
| 2877 |
return array_values($userInputFields); |
| 2878 |
|
| 2879 |
} |
| 2880 |
|
| 2881 |
public function updateUserInputFields($mode) { |
| 2882 |
|
| 2883 |
function checkEnabled($json) { |
| 2884 |
|
| 2885 |
if (count($json['active']) === 0) { |
| 2886 |
|
| 2887 |
$json['active'] = 'false'; |
| 2888 |
|
| 2889 |
} else { |
| 2890 |
|
| 2891 |
$json['active'] = 'true'; |
| 2892 |
|
| 2893 |
} |
| 2894 |
|
| 2895 |
if (count($json['required']) === 0) { |
| 2896 |
|
| 2897 |
$json['required'] = 'false'; |
| 2898 |
|
| 2899 |
} else { |
| 2900 |
|
| 2901 |
$json['required'] = 'true'; |
| 2902 |
|
| 2903 |
} |
| 2904 |
|
| 2905 |
if (array_key_exists('value', $json) === false) { |
| 2906 |
|
| 2907 |
$json['value'] = ''; |
| 2908 |
|
| 2909 |
} |
| 2910 |
|
| 2911 |
return $json; |
| 2912 |
|
| 2913 |
} |
| 2914 |
|
| 2915 |
function updateUserInputFields($items) { |
| 2916 |
|
| 2917 |
$defaultName = array('user_login' => 'Username', 'user_email' => 'Email', 'user_pass' => 'Password'); |
| 2918 |
$userInputFields = array(); |
| 2919 |
for ($i = 0; $i < count($items); $i++) { |
| 2920 |
|
| 2921 |
$item = $items[$i]; |
| 2922 |
if (array_key_exists($item['id'], $defaultName) === true) { |
| 2923 |
|
| 2924 |
$item['name'] = $defaultName[ $item['id'] ]; |
| 2925 |
|
| 2926 |
} |
| 2927 |
|
| 2928 |
$userInputFields[$item['id']] = $item; |
| 2929 |
|
| 2930 |
} |
| 2931 |
|
| 2932 |
return $userInputFields; |
| 2933 |
|
| 2934 |
} |
| 2935 |
|
| 2936 |
$userInputFields = $this->initialUserInputFields(); |
| 2937 |
if ($mode === 'addUserInput') { |
| 2938 |
|
| 2939 |
$json = json_decode(sanitize_text_field( stripslashes($_POST['jsonStr']) ), true); |
| 2940 |
$json = checkEnabled($json); |
| 2941 |
array_push($userInputFields, $json); |
| 2942 |
$userInputFields = updateUserInputFields($userInputFields); |
| 2943 |
update_option("_" . $this->prefix . "getUserInputFields", json_encode($userInputFields)); |
| 2944 |
|
| 2945 |
} else if ($mode === 'editUserInput') { |
| 2946 |
|
| 2947 |
$json = json_decode(sanitize_text_field( stripslashes($_POST['jsonStr']) ), true); |
| 2948 |
$json = checkEnabled($json); |
| 2949 |
if ($json['id'] === 'user_pass') { |
| 2950 |
|
| 2951 |
$json['type'] = 'PASSWORD'; |
| 2952 |
|
| 2953 |
} |
| 2954 |
for ($i = 0; $i < count($userInputFields); $i++) { |
| 2955 |
|
| 2956 |
if ($userInputFields[$i]['id'] === $json['id']) { |
| 2957 |
|
| 2958 |
$userInputFields[$i] = $json; |
| 2959 |
break; |
| 2960 |
|
| 2961 |
} |
| 2962 |
|
| 2963 |
} |
| 2964 |
$userInputFields = updateUserInputFields($userInputFields); |
| 2965 |
update_option("_" . $this->prefix . "getUserInputFields", json_encode($userInputFields)); |
| 2966 |
|
| 2967 |
} else if ($mode === 'deleteUserInput') { |
| 2968 |
|
| 2969 |
array_splice($userInputFields, intval($_POST['index']), 1); |
| 2970 |
$userInputFields = updateUserInputFields($userInputFields); |
| 2971 |
update_option("_" . $this->prefix . "getUserInputFields", json_encode($userInputFields)); |
| 2972 |
|
| 2973 |
} else if ($mode === 'changedOrderUserInput') { |
| 2974 |
|
| 2975 |
$sortedUserInputFields = array(); |
| 2976 |
$json = json_decode(sanitize_text_field( stripslashes($_POST['keys']) ), true); |
| 2977 |
for ($i = 0; $i < count($json); $i++) { |
| 2978 |
|
| 2979 |
$item = (function($id, $userInputFields) { |
| 2980 |
|
| 2981 |
for ($i = 0; $i < count($userInputFields); $i++) { |
| 2982 |
|
| 2983 |
if ($id === $userInputFields[$i]['id']) { |
| 2984 |
|
| 2985 |
return $userInputFields[$i]; |
| 2986 |
|
| 2987 |
} |
| 2988 |
|
| 2989 |
} |
| 2990 |
|
| 2991 |
})($json[$i], $userInputFields); |
| 2992 |
array_push($sortedUserInputFields, $item); |
| 2993 |
|
| 2994 |
|
| 2995 |
} |
| 2996 |
|
| 2997 |
$userInputFields = updateUserInputFields($sortedUserInputFields); |
| 2998 |
update_option("_" . $this->prefix . "getUserInputFields", json_encode($userInputFields)); |
| 2999 |
|
| 3000 |
} |
| 3001 |
|
| 3002 |
|
| 3003 |
|
| 3004 |
|
| 3005 |
return array_values($userInputFields); |
| 3006 |
|
| 3007 |
} |
| 3008 |
|
| 3009 |
public function getUserInputFields() { |
| 3010 |
|
| 3011 |
$userInputFields = $this->initialUserInputFields(); |
| 3012 |
return $userInputFields; |
| 3013 |
|
| 3014 |
} |
| 3015 |
|
| 3016 |
public function getForm($accountKey = 1, $originalActive = false){ |
| 3017 |
|
| 3018 |
global $wpdb; |
| 3019 |
$table_name = $wpdb->prefix."booking_package_form"; |
| 3020 |
#$wpdb->query("DROP TABLE IF EXISTS ".$table_name.";"); |
| 3021 |
$sql = $wpdb->prepare("SELECT * FROM ".$table_name." WHERE `accountKey` = %d;", array(intval($accountKey))); |
| 3022 |
$row = $wpdb->get_row($sql, ARRAY_A); |
| 3023 |
if (is_null($row)) { |
| 3024 |
|
| 3025 |
$wpdb->insert( |
| 3026 |
$table_name, |
| 3027 |
array( |
| 3028 |
'accountKey' => intval($accountKey), |
| 3029 |
'data' => json_encode($this->defaultFrom()) |
| 3030 |
), |
| 3031 |
array('%d', '%s') |
| 3032 |
); |
| 3033 |
|
| 3034 |
return $this->defaultFrom(); |
| 3035 |
|
| 3036 |
} else { |
| 3037 |
|
| 3038 |
$form = array(); |
| 3039 |
$data = json_decode($row['data'], true); |
| 3040 |
if (is_array($data)) { |
| 3041 |
|
| 3042 |
foreach ((array) $data as $key => $value) { |
| 3043 |
|
| 3044 |
if (isset($value['active']) === false) { |
| 3045 |
|
| 3046 |
$value['active'] = ''; |
| 3047 |
|
| 3048 |
} |
| 3049 |
|
| 3050 |
#$options = json_decode($value['options'], true); |
| 3051 |
if (is_string($value['options']) === true) { |
| 3052 |
|
| 3053 |
$value['options'] = explode(',', $value['options']); |
| 3054 |
|
| 3055 |
} |
| 3056 |
|
| 3057 |
if ($originalActive === true) { |
| 3058 |
|
| 3059 |
$value['originalActive'] = $value['active']; |
| 3060 |
|
| 3061 |
} |
| 3062 |
|
| 3063 |
if (isset($value['isAutocomplete']) === false) { |
| 3064 |
|
| 3065 |
$value['isAutocomplete'] = 'true'; |
| 3066 |
|
| 3067 |
} |
| 3068 |
|
| 3069 |
if (isset($value['isSMS']) === false) { |
| 3070 |
|
| 3071 |
$value['isSMS'] = 'false'; |
| 3072 |
|
| 3073 |
} |
| 3074 |
|
| 3075 |
if (isset($value['placeholder']) === false) { |
| 3076 |
|
| 3077 |
$value['placeholder'] = ''; |
| 3078 |
|
| 3079 |
} |
| 3080 |
|
| 3081 |
array_push($form, $value); |
| 3082 |
|
| 3083 |
} |
| 3084 |
|
| 3085 |
} |
| 3086 |
|
| 3087 |
return $form; |
| 3088 |
#return json_decode($row['data'], true); |
| 3089 |
|
| 3090 |
} |
| 3091 |
|
| 3092 |
} |
| 3093 |
|
| 3094 |
/** |
| 3095 |
public function getFormList(){ |
| 3096 |
|
| 3097 |
global $wpdb; |
| 3098 |
$table_name = $wpdb->prefix."booking_package_form"; |
| 3099 |
$sql = $wpdb->prepare("SELECT * FROM ".$table_name." WHERE `accountKey` = %d;", array(intval($accountKey))); |
| 3100 |
|
| 3101 |
} |
| 3102 |
**/ |
| 3103 |
|
| 3104 |
public static function isIndexedArray($array) { |
| 3105 |
|
| 3106 |
if (!is_array($array)) { |
| 3107 |
return false; |
| 3108 |
} |
| 3109 |
|
| 3110 |
if ($array === []) { |
| 3111 |
return true; |
| 3112 |
} |
| 3113 |
|
| 3114 |
return array_keys($array) === range(0, count($array) - 1); |
| 3115 |
|
| 3116 |
} |
| 3117 |
|
| 3118 |
public function getTranslateUserInputField($field, $calendar_account_id) { |
| 3119 |
|
| 3120 |
|
| 3121 |
|
| 3122 |
} |
| 3123 |
|
| 3124 |
public function getTranslateFormField($field, $calendar_account_id, $local, $type = 'form_field') { |
| 3125 |
|
| 3126 |
$keys = ['uri', 'placeholder', 'description']; |
| 3127 |
for ($i = 0; $i < count($keys); $i++) { |
| 3128 |
|
| 3129 |
$key = $keys[$i]; |
| 3130 |
if (array_key_exists($key, $field) === false) { |
| 3131 |
|
| 3132 |
$field[$key] = ''; |
| 3133 |
|
| 3134 |
} |
| 3135 |
|
| 3136 |
} |
| 3137 |
|
| 3138 |
$string_array = array('name' => $field['name'], 'url' => $field['uri'], 'placeholder' => $field['placeholder'], 'description' => $field['description'], 'options' => $field['options']); |
| 3139 |
$translated_texts = apply_filters('booking_package_get_translate_text', $string_array, $type, $field['id'], intval($calendar_account_id), $local); |
| 3140 |
if (is_array($translated_texts) && array_key_exists('name', $translated_texts) && array_key_exists('url', $translated_texts) && array_key_exists('placeholder', $translated_texts) && array_key_exists('description', $translated_texts) && array_key_exists('options', $translated_texts) ) { |
| 3141 |
|
| 3142 |
$field['name'] = $translated_texts['name']; |
| 3143 |
$field['uri'] = $translated_texts['url']; |
| 3144 |
$field['placeholder'] = $translated_texts['placeholder']; |
| 3145 |
$field['description'] = $translated_texts['description']; |
| 3146 |
if ($this->isIndexedArray($translated_texts['options']) === true && count($field['options']) === count($translated_texts['options'])) { |
| 3147 |
|
| 3148 |
$field['options'] = $translated_texts['options']; |
| 3149 |
|
| 3150 |
} |
| 3151 |
|
| 3152 |
} |
| 3153 |
|
| 3154 |
return $field; |
| 3155 |
|
| 3156 |
} |
| 3157 |
|
| 3158 |
public function getTranslateTax($tax, $calendar_account_id) { |
| 3159 |
|
| 3160 |
$type = 'tax'; |
| 3161 |
if ($tax['type'] === 'surcharge') { |
| 3162 |
|
| 3163 |
$type = 'extra_charge'; |
| 3164 |
|
| 3165 |
} |
| 3166 |
$optionNames = array(); |
| 3167 |
$string_array = array('name' => $tax['name'], 'description' => '', 'options' => $optionNames); |
| 3168 |
$translated_texts = apply_filters('booking_package_get_translate_text', $string_array, $type, intval($tax['key']), intval($calendar_account_id), get_locale()); |
| 3169 |
if (is_array($translated_texts) && array_key_exists('name', $translated_texts) && array_key_exists('description', $translated_texts) && array_key_exists('options', $translated_texts) ) { |
| 3170 |
|
| 3171 |
$tax['name'] = $translated_texts['name']; |
| 3172 |
|
| 3173 |
} |
| 3174 |
|
| 3175 |
return $tax; |
| 3176 |
|
| 3177 |
} |
| 3178 |
|
| 3179 |
public function getTranslateService($service, $calendar_account_id) { |
| 3180 |
|
| 3181 |
$optionNames = array(); |
| 3182 |
$options = json_decode($service['options'], true); |
| 3183 |
for ($i = 0; $i < count($options); $i++) { |
| 3184 |
|
| 3185 |
array_push($optionNames, $options[$i]['name']); |
| 3186 |
|
| 3187 |
} |
| 3188 |
|
| 3189 |
$string_array = array('name' => $service['name'], 'description' => $service['description'], 'options' => $optionNames); |
| 3190 |
$translated_texts = apply_filters('booking_package_get_translate_text', $string_array, 'service', intval($service['key']), intval($calendar_account_id), get_locale()); |
| 3191 |
if (is_array($translated_texts) && array_key_exists('name', $translated_texts) && array_key_exists('description', $translated_texts) && array_key_exists('options', $translated_texts) ) { |
| 3192 |
|
| 3193 |
$service['name'] = $translated_texts['name']; |
| 3194 |
$service['description'] = $translated_texts['description']; |
| 3195 |
if ($this->isIndexedArray($translated_texts['options']) === true && count($optionNames) === count($translated_texts['options'])) { |
| 3196 |
|
| 3197 |
for ($i = 0; $i < count($translated_texts['options']); $i++) { |
| 3198 |
|
| 3199 |
$options[$i]['name'] = $translated_texts['options'][$i]; |
| 3200 |
|
| 3201 |
} |
| 3202 |
$service['options'] = json_encode($options); |
| 3203 |
|
| 3204 |
} |
| 3205 |
|
| 3206 |
} |
| 3207 |
|
| 3208 |
return $service; |
| 3209 |
|
| 3210 |
} |
| 3211 |
|
| 3212 |
public function getTranslateGuest($guest, $calendar_account_id) { |
| 3213 |
|
| 3214 |
$optionNames = array(); |
| 3215 |
$options = json_decode($guest['json'], true); |
| 3216 |
for ($i = 0; $i < count($options); $i++) { |
| 3217 |
|
| 3218 |
array_push($optionNames, $options[$i]['name']); |
| 3219 |
|
| 3220 |
} |
| 3221 |
|
| 3222 |
$string_array = array('name' => $guest['name'], 'description' => $guest['description'], 'options' => $optionNames); |
| 3223 |
$translated_texts = apply_filters('booking_package_get_translate_text', $string_array, 'guest', intval($guest['key']), intval($calendar_account_id), get_locale()); |
| 3224 |
if (is_array($translated_texts) && array_key_exists('name', $translated_texts) && array_key_exists('description', $translated_texts) && array_key_exists('options', $translated_texts) ) { |
| 3225 |
|
| 3226 |
$guest['name'] = $translated_texts['name']; |
| 3227 |
$guest['description'] = $translated_texts['description']; |
| 3228 |
if ($this->isIndexedArray($translated_texts['options']) === true && count($optionNames) === count($translated_texts['options'])) { |
| 3229 |
|
| 3230 |
for ($i = 0; $i < count($translated_texts['options']); $i++) { |
| 3231 |
|
| 3232 |
#$index = $i + 1; |
| 3233 |
$options[$i]['name'] = $translated_texts['options'][$i]; |
| 3234 |
|
| 3235 |
} |
| 3236 |
$guest['json'] = json_encode($options); |
| 3237 |
|
| 3238 |
} |
| 3239 |
|
| 3240 |
} |
| 3241 |
|
| 3242 |
return $guest; |
| 3243 |
|
| 3244 |
} |
| 3245 |
|
| 3246 |
public function getTranslateOption($option, $calendar_account_id) { |
| 3247 |
|
| 3248 |
$optionNames = array(); |
| 3249 |
$choices = json_decode($option['json'], true); |
| 3250 |
for ($i = 0; $i < count($choices); $i++) { |
| 3251 |
|
| 3252 |
array_push($optionNames, $choices[$i]['name']); |
| 3253 |
|
| 3254 |
} |
| 3255 |
|
| 3256 |
$string_array = array('name' => $option['name'], 'description' => $option['description'], 'options' => $optionNames); |
| 3257 |
$translated_texts = apply_filters('booking_package_get_translate_text', $string_array, 'option', intval($option['key']), intval($calendar_account_id), get_locale()); |
| 3258 |
if (is_array($translated_texts) && array_key_exists('name', $translated_texts) && array_key_exists('description', $translated_texts) && array_key_exists('options', $translated_texts) ) { |
| 3259 |
|
| 3260 |
$option['name'] = $translated_texts['name']; |
| 3261 |
$option['description'] = $translated_texts['description']; |
| 3262 |
if ($this->isIndexedArray($translated_texts['options']) === true && count($optionNames) === count($translated_texts['options'])) { |
| 3263 |
|
| 3264 |
for ($i = 0; $i < count($translated_texts['options']); $i++) { |
| 3265 |
|
| 3266 |
$choices[$i]['name'] = $translated_texts['options'][$i]; |
| 3267 |
|
| 3268 |
} |
| 3269 |
$option['json'] = json_encode($choices); |
| 3270 |
|
| 3271 |
} |
| 3272 |
|
| 3273 |
} |
| 3274 |
|
| 3275 |
return $option; |
| 3276 |
|
| 3277 |
} |
| 3278 |
|
| 3279 |
public function getCourseList($accountKey = 1) { |
| 3280 |
|
| 3281 |
global $wpdb; |
| 3282 |
$table_name = $wpdb->prefix . "booking_package_services"; |
| 3283 |
$sql = $wpdb->prepare("SELECT * FROM ".$table_name." WHERE `accountKey` = %d ORDER BY ranking ASC;", array(intval($accountKey))); |
| 3284 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 3285 |
$isExtensionsValid = $this->getExtensionsValid(); |
| 3286 |
for ($i = 0; $i < count($rows); $i++) { |
| 3287 |
|
| 3288 |
$rows[$i]['timeToProvide'] = json_decode($rows[$i]['timeToProvide'], true); |
| 3289 |
if (is_null($rows[$i]['timeToProvide']) || is_string($rows[$i]['timeToProvide']) || $rows[$i]['timeToProvide'] === false) { |
| 3290 |
|
| 3291 |
$rows[$i]['timeToProvide'] = array(); |
| 3292 |
|
| 3293 |
} |
| 3294 |
|
| 3295 |
$options = json_decode($rows[$i]['options'], true); |
| 3296 |
if (is_array($options)) { |
| 3297 |
|
| 3298 |
if (count($options) > 0 && isset($options[0]['cost_1']) === false) { |
| 3299 |
|
| 3300 |
for ($a = 0; $a < count($options); $a++) { |
| 3301 |
|
| 3302 |
$options[$a]['cost_1'] = $options[$a]['cost']; |
| 3303 |
$options[$a]['cost_2'] = $options[$a]['cost']; |
| 3304 |
$options[$a]['cost_3'] = $options[$a]['cost']; |
| 3305 |
$options[$a]['cost_4'] = $options[$a]['cost']; |
| 3306 |
$options[$a]['cost_5'] = $options[$a]['cost']; |
| 3307 |
$options[$a]['cost_6'] = $options[$a]['cost']; |
| 3308 |
|
| 3309 |
} |
| 3310 |
|
| 3311 |
} |
| 3312 |
|
| 3313 |
$rows[$i]['options'] = json_encode($options); |
| 3314 |
|
| 3315 |
} else { |
| 3316 |
|
| 3317 |
$rows[$i]['options'] = "[]"; |
| 3318 |
|
| 3319 |
} |
| 3320 |
|
| 3321 |
if (is_null($rows[$i]['cost']) === true) { |
| 3322 |
|
| 3323 |
$rows[$i]['cost'] = 0; |
| 3324 |
|
| 3325 |
} |
| 3326 |
|
| 3327 |
if (is_null($rows[$i]['cost_1']) === true) { |
| 3328 |
|
| 3329 |
/** |
| 3330 |
$options = json_decode($rows[$i]['options'], true); |
| 3331 |
for ($a = 0; $a < count($options); $a++) { |
| 3332 |
|
| 3333 |
$options[$a]['cost_1'] = $options[$a]['cost']; |
| 3334 |
$options[$a]['cost_2'] = $options[$a]['cost']; |
| 3335 |
$options[$a]['cost_3'] = $options[$a]['cost']; |
| 3336 |
$options[$a]['cost_4'] = $options[$a]['cost']; |
| 3337 |
$options[$a]['cost_5'] = $options[$a]['cost']; |
| 3338 |
$options[$a]['cost_6'] = $options[$a]['cost']; |
| 3339 |
|
| 3340 |
} |
| 3341 |
|
| 3342 |
$rows[$i]['options'] = $options; |
| 3343 |
**/ |
| 3344 |
$options = json_encode($options); |
| 3345 |
$rows[$i]['cost_1'] = $rows[$i]['cost']; |
| 3346 |
$table_name = $wpdb->prefix . "booking_package_services"; |
| 3347 |
|
| 3348 |
try { |
| 3349 |
|
| 3350 |
$wpdb->query("START TRANSACTION"); |
| 3351 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 3352 |
$bool = $wpdb->update( |
| 3353 |
$table_name, |
| 3354 |
array( |
| 3355 |
'cost_1' => intval($rows[$i]['cost']), |
| 3356 |
'cost_2' => intval($rows[$i]['cost']), |
| 3357 |
'cost_3' => intval($rows[$i]['cost']), |
| 3358 |
'cost_4' => intval($rows[$i]['cost']), |
| 3359 |
'cost_5' => intval($rows[$i]['cost']), |
| 3360 |
'cost_6' => intval($rows[$i]['cost']), |
| 3361 |
'options' => $options, |
| 3362 |
), |
| 3363 |
array('key' => intval($rows[$i]['key'])), |
| 3364 |
array( |
| 3365 |
'%d', '%d', '%d', '%d', '%d', '%d', '%s', |
| 3366 |
), |
| 3367 |
array('%d') |
| 3368 |
); |
| 3369 |
|
| 3370 |
$wpdb->query('COMMIT'); |
| 3371 |
$wpdb->query('UNLOCK TABLES'); |
| 3372 |
|
| 3373 |
} catch (Exception $e) { |
| 3374 |
|
| 3375 |
$wpdb->query('ROLLBACK'); |
| 3376 |
$wpdb->query('UNLOCK TABLES'); |
| 3377 |
|
| 3378 |
}/** finally { |
| 3379 |
|
| 3380 |
$wpdb->query('UNLOCK TABLES'); |
| 3381 |
|
| 3382 |
}**/ |
| 3383 |
|
| 3384 |
} |
| 3385 |
|
| 3386 |
if ($isExtensionsValid === false) { |
| 3387 |
|
| 3388 |
$rows[$i]['options'] = "[]"; |
| 3389 |
$rows[$i]['timeToProvide'] = array(); |
| 3390 |
$rows[$i]['stopServiceUnderFollowingConditions'] = 'doNotStop'; |
| 3391 |
$rows[$i]['cost_2'] = $rows[$i]['cost_1']; |
| 3392 |
$rows[$i]['cost_3'] = $rows[$i]['cost_1']; |
| 3393 |
$rows[$i]['cost_4'] = $rows[$i]['cost_1']; |
| 3394 |
$rows[$i]['cost_5'] = $rows[$i]['cost_1']; |
| 3395 |
$rows[$i]['cost_6'] = $rows[$i]['cost_1']; |
| 3396 |
|
| 3397 |
} |
| 3398 |
|
| 3399 |
} |
| 3400 |
/** |
| 3401 |
if ($isExtensionsValid === false) { |
| 3402 |
|
| 3403 |
for($i = 0; $i < count($rows); $i++){ |
| 3404 |
|
| 3405 |
$rows[$i]['options'] = "[]"; |
| 3406 |
|
| 3407 |
} |
| 3408 |
|
| 3409 |
} |
| 3410 |
**/ |
| 3411 |
return $rows; |
| 3412 |
|
| 3413 |
} |
| 3414 |
|
| 3415 |
/** |
| 3416 |
public function getAllCourseList(){ |
| 3417 |
|
| 3418 |
global $wpdb; |
| 3419 |
$table_name = $wpdb->prefix . "booking_package_services"; |
| 3420 |
$sql = $wpdb->prepare("SELECT * FROM ".$table_name." WHERE `accountKey` = %d ORDER BY ranking ASC;", array(intval($accountKey))); |
| 3421 |
|
| 3422 |
|
| 3423 |
} |
| 3424 |
**/ |
| 3425 |
|
| 3426 |
public function getCouponsList($accountKey = false) { |
| 3427 |
|
| 3428 |
global $wpdb; |
| 3429 |
$table_name = $wpdb->prefix."booking_package_coupons"; |
| 3430 |
$sql = $wpdb->prepare("SELECT * FROM ".$table_name." WHERE `status` = 'active' AND `accountKey` = %d ORDER BY `key` ASC;", array(intval($accountKey))); |
| 3431 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 3432 |
return $rows; |
| 3433 |
|
| 3434 |
} |
| 3435 |
|
| 3436 |
public function addCoupons($accountKey = false) { |
| 3437 |
|
| 3438 |
global $wpdb; |
| 3439 |
$id = strtoupper(uniqid('coupon_')); |
| 3440 |
$expirationDate = $this->validExpirationDate(); |
| 3441 |
$expirationDateStatus = $expirationDate['expirationDateStatus']; |
| 3442 |
$expirationDateFrom = $expirationDate['expirationDateFrom']; |
| 3443 |
$expirationDateTo = $expirationDate['expirationDateTo']; |
| 3444 |
$active = 0; |
| 3445 |
if (intval($_POST['active']) == 1) { |
| 3446 |
|
| 3447 |
$active = 1; |
| 3448 |
|
| 3449 |
} |
| 3450 |
|
| 3451 |
$table_name = $wpdb->prefix."booking_package_coupons"; |
| 3452 |
$wpdb->insert( |
| 3453 |
$table_name, |
| 3454 |
array( |
| 3455 |
'accountKey' => intval($accountKey), |
| 3456 |
'id' => sanitize_text_field($id), |
| 3457 |
'name' => sanitize_text_field(stripslashes($_POST['name'])), |
| 3458 |
'target' => sanitize_text_field($_POST['target']), |
| 3459 |
'limited' => sanitize_text_field($_POST['limited']), |
| 3460 |
'method' => sanitize_text_field($_POST['method']), |
| 3461 |
'value' => intval($_POST['value']), |
| 3462 |
'expirationDateStatus' => intval($expirationDateStatus), |
| 3463 |
'expirationDateFrom' => intval($expirationDateFrom), |
| 3464 |
'expirationDateTo' => intval($expirationDateTo), |
| 3465 |
'description' => sanitize_textarea_field(stripslashes($_POST['description'])), |
| 3466 |
'active' => intval($active), |
| 3467 |
), |
| 3468 |
array('%d', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%d') |
| 3469 |
); |
| 3470 |
|
| 3471 |
|
| 3472 |
return $this->getCouponsList($accountKey); |
| 3473 |
|
| 3474 |
} |
| 3475 |
|
| 3476 |
public function deleteCouponsItem($accountKey = false) { |
| 3477 |
|
| 3478 |
global $wpdb; |
| 3479 |
$table_name = $wpdb->prefix . "booking_package_coupons"; |
| 3480 |
try { |
| 3481 |
|
| 3482 |
$wpdb->query("START TRANSACTION"); |
| 3483 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 3484 |
$wpdb->update( |
| 3485 |
$table_name, |
| 3486 |
array( |
| 3487 |
'status' => 'deleted', |
| 3488 |
), |
| 3489 |
array('key' => intval($_POST['key'])), |
| 3490 |
array(), |
| 3491 |
array('%d') |
| 3492 |
); |
| 3493 |
|
| 3494 |
$wpdb->query('COMMIT'); |
| 3495 |
$wpdb->query('UNLOCK TABLES'); |
| 3496 |
|
| 3497 |
} catch (Exception $e) { |
| 3498 |
|
| 3499 |
$wpdb->query('ROLLBACK'); |
| 3500 |
$wpdb->query('UNLOCK TABLES'); |
| 3501 |
|
| 3502 |
}/** finally { |
| 3503 |
|
| 3504 |
$wpdb->query('UNLOCK TABLES'); |
| 3505 |
|
| 3506 |
}**/ |
| 3507 |
|
| 3508 |
return $this->getCouponsList($accountKey); |
| 3509 |
|
| 3510 |
} |
| 3511 |
|
| 3512 |
public function updateCoupons($accountKey = false) { |
| 3513 |
|
| 3514 |
global $wpdb; |
| 3515 |
$table_name = $wpdb->prefix."booking_package_coupons"; |
| 3516 |
$sql = $wpdb->prepare( |
| 3517 |
"SELECT * FROM ".$table_name." WHERE `status` = 'active' AND `key` = %d ORDER BY `key` ASC;", |
| 3518 |
array(intval($_POST['key'])) |
| 3519 |
); |
| 3520 |
$coupon = $wpdb->get_row($sql, ARRAY_A); |
| 3521 |
if (!empty($coupon)) { |
| 3522 |
|
| 3523 |
if (!empty($_POST['id']) && $_POST['id'] != $coupon['id']) { |
| 3524 |
|
| 3525 |
$sql = $wpdb->prepare( |
| 3526 |
"SELECT * FROM ".$table_name." WHERE `status` = 'active' AND `accountKey` = %d AND `id` = %s;", |
| 3527 |
array( |
| 3528 |
intval($_POST['key']), |
| 3529 |
sanitize_text_field($_POST['id']) |
| 3530 |
) |
| 3531 |
); |
| 3532 |
$row = $wpdb->get_row($sql, ARRAY_A); |
| 3533 |
if (!empty($row)) { |
| 3534 |
|
| 3535 |
$_POST['id'] = $coupon['id']; |
| 3536 |
|
| 3537 |
} |
| 3538 |
|
| 3539 |
} |
| 3540 |
|
| 3541 |
$expirationDate = $this->validExpirationDate(); |
| 3542 |
$expirationDateStatus = $expirationDate['expirationDateStatus']; |
| 3543 |
$expirationDateFrom = $expirationDate['expirationDateFrom']; |
| 3544 |
$expirationDateTo = $expirationDate['expirationDateTo']; |
| 3545 |
$active = 0; |
| 3546 |
if (intval($_POST['active']) == 1) { |
| 3547 |
|
| 3548 |
$active = 1; |
| 3549 |
|
| 3550 |
} |
| 3551 |
|
| 3552 |
try { |
| 3553 |
|
| 3554 |
$wpdb->query("START TRANSACTION"); |
| 3555 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 3556 |
$wpdb->update( |
| 3557 |
$table_name, |
| 3558 |
array( |
| 3559 |
'id' => sanitize_text_field($_POST['id']), |
| 3560 |
'name' => sanitize_text_field(stripslashes($_POST['name'])), |
| 3561 |
'target' => sanitize_text_field($_POST['target']), |
| 3562 |
'limited' => sanitize_text_field($_POST['limited']), |
| 3563 |
'method' => sanitize_text_field($_POST['method']), |
| 3564 |
'value' => intval($_POST['value']), |
| 3565 |
'expirationDateStatus' => intval($expirationDateStatus), |
| 3566 |
'expirationDateFrom' => intval($expirationDateFrom), |
| 3567 |
'expirationDateTo' => intval($expirationDateTo), |
| 3568 |
'description' => sanitize_textarea_field(stripslashes($_POST['description'])), |
| 3569 |
'active' => intval($active), |
| 3570 |
), |
| 3571 |
array('key' => intval($_POST['key'])), |
| 3572 |
array('%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%d'), |
| 3573 |
array('%d') |
| 3574 |
); |
| 3575 |
|
| 3576 |
$wpdb->query('COMMIT'); |
| 3577 |
$wpdb->query('UNLOCK TABLES'); |
| 3578 |
|
| 3579 |
} catch (Exception $e) { |
| 3580 |
|
| 3581 |
$wpdb->query('ROLLBACK'); |
| 3582 |
$wpdb->query('UNLOCK TABLES'); |
| 3583 |
|
| 3584 |
}/** finally { |
| 3585 |
|
| 3586 |
$wpdb->query('UNLOCK TABLES'); |
| 3587 |
|
| 3588 |
}**/ |
| 3589 |
|
| 3590 |
} |
| 3591 |
|
| 3592 |
|
| 3593 |
|
| 3594 |
return $this->getCouponsList($accountKey); |
| 3595 |
|
| 3596 |
} |
| 3597 |
|
| 3598 |
public function getListOfDaysOfWeek() { |
| 3599 |
|
| 3600 |
$numberKeys = array(); |
| 3601 |
$guestsList = $this->guestsInputType(); |
| 3602 |
if (isset($guestsList['json']['optionsType']['prices'])) { |
| 3603 |
|
| 3604 |
$dayOfWeeks = $guestsList['json']['optionsType']['prices']['options']; |
| 3605 |
for ($i = 0; $i < count($dayOfWeeks); $i++) { |
| 3606 |
|
| 3607 |
array_push($numberKeys, $dayOfWeeks[$i]['key']); |
| 3608 |
|
| 3609 |
} |
| 3610 |
|
| 3611 |
} |
| 3612 |
|
| 3613 |
return $numberKeys; |
| 3614 |
|
| 3615 |
} |
| 3616 |
|
| 3617 |
public function getObjectOfDaysOfWeek() { |
| 3618 |
|
| 3619 |
$numberObject = array(); |
| 3620 |
$numberKeys = $this->getListOfDaysOfWeek(); |
| 3621 |
for ($i = 0; $i < count($numberKeys); $i++) { |
| 3622 |
|
| 3623 |
$numberObject[$numberKeys[$i]] = 0; |
| 3624 |
|
| 3625 |
} |
| 3626 |
|
| 3627 |
return $numberObject; |
| 3628 |
|
| 3629 |
} |
| 3630 |
|
| 3631 |
public function getStaffList($accountKey = false, $booking = false) { |
| 3632 |
|
| 3633 |
global $wpdb; |
| 3634 |
$table_name = $wpdb->prefix . "booking_package_staff"; |
| 3635 |
return array(); |
| 3636 |
|
| 3637 |
} |
| 3638 |
|
| 3639 |
public function addStaff($accountKey = false) { |
| 3640 |
|
| 3641 |
global $wpdb; |
| 3642 |
$table_name = $wpdb->prefix . "booking_package_staff"; |
| 3643 |
return array(); |
| 3644 |
|
| 3645 |
} |
| 3646 |
|
| 3647 |
public function updateStaff($accountKey = false) { |
| 3648 |
|
| 3649 |
global $wpdb; |
| 3650 |
$table_name = $wpdb->prefix . "booking_package_staff"; |
| 3651 |
return array(); |
| 3652 |
|
| 3653 |
} |
| 3654 |
|
| 3655 |
public function deleteStaffItem($accountKey = false) { |
| 3656 |
|
| 3657 |
global $wpdb; |
| 3658 |
if($accountKey != false){ |
| 3659 |
|
| 3660 |
$table_name = $wpdb->prefix . "booking_package_staff"; |
| 3661 |
#$wpdb->delete($table_name, array('key' => intval($_POST['key'])), array('%d')); |
| 3662 |
|
| 3663 |
return $this->getStaffList($accountKey); |
| 3664 |
|
| 3665 |
} |
| 3666 |
|
| 3667 |
die(); |
| 3668 |
|
| 3669 |
} |
| 3670 |
|
| 3671 |
public function changeStaffRank($accountKey = false) { |
| 3672 |
|
| 3673 |
global $wpdb; |
| 3674 |
if($accountKey != false){ |
| 3675 |
|
| 3676 |
$table_name = $wpdb->prefix . "booking_package_staff"; |
| 3677 |
/** |
| 3678 |
$keyList = explode(",", $_POST['keyList']); |
| 3679 |
for($i = 0; $i < count($keyList); $i++){ |
| 3680 |
|
| 3681 |
$ranking = $i + 1; |
| 3682 |
$wpdb->update( |
| 3683 |
$table_name, |
| 3684 |
array( |
| 3685 |
'ranking' => intval($ranking) |
| 3686 |
), |
| 3687 |
array('key' => intval($keyList[$i]), 'accountKey' => intval($accountKey)), |
| 3688 |
array('%d'), |
| 3689 |
array('%d', '%d') |
| 3690 |
); |
| 3691 |
|
| 3692 |
} |
| 3693 |
**/ |
| 3694 |
return $this->getStaffList($accountKey); |
| 3695 |
|
| 3696 |
} |
| 3697 |
|
| 3698 |
die(); |
| 3699 |
|
| 3700 |
} |
| 3701 |
|
| 3702 |
public function getGuestsList($accountKey = false, $booking = false) { |
| 3703 |
|
| 3704 |
global $wpdb; |
| 3705 |
$numberKeys = $this->getListOfDaysOfWeek(); |
| 3706 |
$isExtensionsValid = $this->getExtensionsValid(); |
| 3707 |
$table_name = $wpdb->prefix . "booking_package_guests"; |
| 3708 |
$sql = $wpdb->prepare("SELECT * FROM " . $table_name . " WHERE `accountKey` = %d ORDER BY ranking ASC;", array(intval($accountKey))); |
| 3709 |
if ($booking === true) { |
| 3710 |
|
| 3711 |
$sql = $wpdb->prepare("SELECT * FROM " . $table_name . " WHERE `accountKey` = %d AND `active` = 'true' ORDER BY ranking ASC;", array(intval($accountKey))); |
| 3712 |
|
| 3713 |
} |
| 3714 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 3715 |
foreach ((array) $rows as $key => $value) { |
| 3716 |
|
| 3717 |
$updatePrices = false; |
| 3718 |
$list = array(); |
| 3719 |
|
| 3720 |
if ($booking === true) { |
| 3721 |
|
| 3722 |
$value = $this->getTranslateGuest($value, intval($accountKey) ); |
| 3723 |
$list = json_decode($value['json'], true); |
| 3724 |
array_unshift($list, array("number" => 0, "price" => 0, "name" => __("Select", 'booking-package'))); |
| 3725 |
if ($isExtensionsValid !== true) { |
| 3726 |
|
| 3727 |
$value['costInServices'] = 'cost_1'; |
| 3728 |
$value['reflectService'] = '0'; |
| 3729 |
$value['reflectAdditional'] = '0'; |
| 3730 |
|
| 3731 |
} |
| 3732 |
|
| 3733 |
} else { |
| 3734 |
|
| 3735 |
$list = json_decode($value['json'], true); |
| 3736 |
|
| 3737 |
} |
| 3738 |
|
| 3739 |
for ($i = 0; $i < count($list); $i++) { |
| 3740 |
|
| 3741 |
if (isset($list[$i]['price']) === false) { |
| 3742 |
|
| 3743 |
$list[$i]['price'] = 0; |
| 3744 |
|
| 3745 |
} |
| 3746 |
|
| 3747 |
for ($a = 0; $a < count($numberKeys); $a++) { |
| 3748 |
|
| 3749 |
if (isset($list[$i][$numberKeys[$a]]) === false) { |
| 3750 |
|
| 3751 |
$list[$i][$numberKeys[$a]] = $list[$i]['price']; |
| 3752 |
|
| 3753 |
} |
| 3754 |
|
| 3755 |
if (empty($list[$i][$numberKeys[$a]])) { |
| 3756 |
|
| 3757 |
$list[$i][$numberKeys[$a]] = 0; |
| 3758 |
|
| 3759 |
} |
| 3760 |
|
| 3761 |
if ($isExtensionsValid === false && ($numberKeys[$a] == 'priceOnDayBeforeNationalHoliday' || $numberKeys[$a] == 'priceOnNationalHoliday')) { |
| 3762 |
|
| 3763 |
$list[$i][$numberKeys[$a]] = 0; |
| 3764 |
|
| 3765 |
} |
| 3766 |
|
| 3767 |
} |
| 3768 |
|
| 3769 |
} |
| 3770 |
|
| 3771 |
$value['json'] = json_encode($list); |
| 3772 |
$rows[$key] = $value; |
| 3773 |
|
| 3774 |
} |
| 3775 |
|
| 3776 |
return $rows; |
| 3777 |
|
| 3778 |
} |
| 3779 |
|
| 3780 |
public function checkDuplicateOptionNumbers($options, $uniqueKey = 'number') { |
| 3781 |
|
| 3782 |
$numbers = array(); |
| 3783 |
foreach ($options as $option) { |
| 3784 |
|
| 3785 |
$number = null; |
| 3786 |
if (is_object($option) && isset($option[$uniqueKey])) { |
| 3787 |
|
| 3788 |
$number = $option[$uniqueKey]; |
| 3789 |
|
| 3790 |
} elseif (is_array($option) && isset($option[$uniqueKey])) { |
| 3791 |
|
| 3792 |
$number = $option[$uniqueKey]; |
| 3793 |
|
| 3794 |
} |
| 3795 |
|
| 3796 |
if ($number !== null) { |
| 3797 |
|
| 3798 |
if (in_array($number, $numbers, true)) { |
| 3799 |
|
| 3800 |
return true; |
| 3801 |
|
| 3802 |
} |
| 3803 |
|
| 3804 |
array_push($numbers, $number); |
| 3805 |
|
| 3806 |
} |
| 3807 |
|
| 3808 |
} |
| 3809 |
|
| 3810 |
return false; |
| 3811 |
|
| 3812 |
} |
| 3813 |
|
| 3814 |
public function updateGuests($accountKey = false){ |
| 3815 |
|
| 3816 |
global $wpdb; |
| 3817 |
if ($accountKey != false) { |
| 3818 |
/** |
| 3819 |
$numberKeys = array( |
| 3820 |
'number', |
| 3821 |
'price', |
| 3822 |
'priceOnMonday', |
| 3823 |
'priceOnTuesday', |
| 3824 |
'priceOnWednesday', |
| 3825 |
'priceOnThursday', |
| 3826 |
'priceOnFriday', |
| 3827 |
'priceOnSaturday', |
| 3828 |
'priceOnSunday', |
| 3829 |
'priceOnDayBeforeNationalHoliday', |
| 3830 |
'priceOnNationalHoliday', |
| 3831 |
); |
| 3832 |
**/ |
| 3833 |
|
| 3834 |
$numberKeys = $this->getListOfDaysOfWeek(); |
| 3835 |
array_unshift($numberKeys, 'number', 'price'); |
| 3836 |
$json = array(); |
| 3837 |
if (isset($_POST['json'])) { |
| 3838 |
|
| 3839 |
$jsonList = json_decode(stripslashes($_POST['json']), true); |
| 3840 |
for ($i = 0; $i < count($jsonList); $i++) { |
| 3841 |
|
| 3842 |
$object = array(); |
| 3843 |
foreach ((array) $jsonList[$i] as $key => $value) { |
| 3844 |
|
| 3845 |
$object[sanitize_text_field($key)] = sanitize_text_field($value); |
| 3846 |
$isNumber = array_search($key, $numberKeys); |
| 3847 |
if ($isNumber !== false) { |
| 3848 |
|
| 3849 |
$value = $this->getOnlyNumbers($value); |
| 3850 |
$object[sanitize_text_field($key)] = intval($value); |
| 3851 |
|
| 3852 |
} |
| 3853 |
|
| 3854 |
if ($this->guestForDayOfTheWeekRates === 0) { |
| 3855 |
|
| 3856 |
if ($key !== 'number' && $key !== 'price' && $key !== 'name') { |
| 3857 |
|
| 3858 |
unset($object[sanitize_text_field($key)]); |
| 3859 |
|
| 3860 |
} |
| 3861 |
|
| 3862 |
|
| 3863 |
} |
| 3864 |
|
| 3865 |
} |
| 3866 |
|
| 3867 |
array_push($json, $object); |
| 3868 |
|
| 3869 |
} |
| 3870 |
|
| 3871 |
if ($this->checkDuplicateOptionNumbers($json, 'number') === true) { |
| 3872 |
|
| 3873 |
return array('status' => 'error', 'message' => sprintf(__('The value for \'%s\' in the options must be a unique number that does not duplicate values from other settings.', 'booking-package'), __('Number of Guests', 'booking-package') ) ); |
| 3874 |
|
| 3875 |
} |
| 3876 |
|
| 3877 |
$guestsInCapacity = 'included'; |
| 3878 |
if (isset($_POST['guestsInCapacity'])) { |
| 3879 |
|
| 3880 |
$guestsInCapacity = $_POST['guestsInCapacity']; |
| 3881 |
if (empty($_POST['guestsInCapacity']) === true) { |
| 3882 |
|
| 3883 |
$guestsInCapacity = 'included'; |
| 3884 |
|
| 3885 |
} |
| 3886 |
|
| 3887 |
} |
| 3888 |
|
| 3889 |
$reflectService = 0; |
| 3890 |
if (isset($_POST['reflectService'])) { |
| 3891 |
|
| 3892 |
$reflectService = intval($_POST['reflectService']); |
| 3893 |
|
| 3894 |
} |
| 3895 |
|
| 3896 |
$reflectAdditional = 0; |
| 3897 |
if (isset($_POST['reflectAdditional'])) { |
| 3898 |
|
| 3899 |
$reflectAdditional = intval($_POST['reflectAdditional']); |
| 3900 |
|
| 3901 |
} |
| 3902 |
|
| 3903 |
$costInServices = 'cost_1'; |
| 3904 |
if (isset($_POST['costInServices']) && $this->getExtensionsValid() === true) { |
| 3905 |
|
| 3906 |
$costInServices = $_POST['costInServices']; |
| 3907 |
|
| 3908 |
} |
| 3909 |
|
| 3910 |
$table_name = $wpdb->prefix."booking_package_guests"; |
| 3911 |
try { |
| 3912 |
|
| 3913 |
$wpdb->query("START TRANSACTION"); |
| 3914 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 3915 |
$wpdb->update( |
| 3916 |
$table_name, |
| 3917 |
array( |
| 3918 |
'name' => sanitize_text_field(stripslashes($_POST['name'])), |
| 3919 |
'costInServices' => sanitize_text_field($costInServices), |
| 3920 |
'target' => sanitize_text_field($_POST['target']), |
| 3921 |
'guestsInCapacity' => sanitize_text_field($guestsInCapacity), |
| 3922 |
'json' => json_encode($json), |
| 3923 |
'required' => intval($_POST['required']), |
| 3924 |
'reflectService' => intval($reflectService), |
| 3925 |
'reflectAdditional' => intval($reflectAdditional), |
| 3926 |
'description' => sanitize_textarea_field(stripslashes($_POST['description'])), |
| 3927 |
'active' => sanitize_text_field($_POST['active']), |
| 3928 |
), |
| 3929 |
array('key' => intval($_POST['key'])), |
| 3930 |
array('%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%s', '%s'), |
| 3931 |
array('%d') |
| 3932 |
); |
| 3933 |
|
| 3934 |
$wpdb->query('COMMIT'); |
| 3935 |
$wpdb->query('UNLOCK TABLES'); |
| 3936 |
|
| 3937 |
} catch (Exception $e) { |
| 3938 |
|
| 3939 |
$wpdb->query('ROLLBACK'); |
| 3940 |
$wpdb->query('UNLOCK TABLES'); |
| 3941 |
|
| 3942 |
}/** finally { |
| 3943 |
|
| 3944 |
$wpdb->query('UNLOCK TABLES'); |
| 3945 |
|
| 3946 |
}**/ |
| 3947 |
|
| 3948 |
} |
| 3949 |
|
| 3950 |
#return $json; |
| 3951 |
return $this->getGuestsList($accountKey); |
| 3952 |
|
| 3953 |
} |
| 3954 |
|
| 3955 |
die(); |
| 3956 |
|
| 3957 |
} |
| 3958 |
|
| 3959 |
public function addGuests($accountKey = false){ |
| 3960 |
|
| 3961 |
global $wpdb; |
| 3962 |
if ($accountKey != false) { |
| 3963 |
|
| 3964 |
/** |
| 3965 |
$numberKeys = array( |
| 3966 |
'number', |
| 3967 |
'price', |
| 3968 |
'priceOnMonday', |
| 3969 |
'priceOnTuesday', |
| 3970 |
'priceOnWednesday', |
| 3971 |
'priceOnThursday', |
| 3972 |
'priceOnFriday', |
| 3973 |
'priceOnSaturday', |
| 3974 |
'priceOnSunday', |
| 3975 |
'priceOnDayBeforeNationalHoliday', |
| 3976 |
'priceOnNationalHoliday', |
| 3977 |
); |
| 3978 |
**/ |
| 3979 |
$numberKeys = $this->getListOfDaysOfWeek(); |
| 3980 |
array_unshift($numberKeys, 'number', 'price'); |
| 3981 |
$json = array(); |
| 3982 |
if (isset($_POST['json'])) { |
| 3983 |
|
| 3984 |
$jsonList = json_decode(stripslashes($_POST['json']), true); |
| 3985 |
for ($i = 0; $i < count($jsonList); $i++) { |
| 3986 |
|
| 3987 |
$object = array(); |
| 3988 |
foreach ((array) $jsonList[$i] as $key => $value) { |
| 3989 |
|
| 3990 |
$object[sanitize_text_field($key)] = sanitize_text_field($value); |
| 3991 |
$isNumber = array_search($key, $numberKeys); |
| 3992 |
if ($isNumber !== false) { |
| 3993 |
|
| 3994 |
$value = $this->getOnlyNumbers($value); |
| 3995 |
$object[sanitize_text_field($key)] = intval($value); |
| 3996 |
|
| 3997 |
} |
| 3998 |
/** |
| 3999 |
if ($key == 'number' || $key == 'price') { |
| 4000 |
|
| 4001 |
$value = $this->getOnlyNumbers($value); |
| 4002 |
$object[sanitize_text_field($key)] = intval($value); |
| 4003 |
|
| 4004 |
} |
| 4005 |
**/ |
| 4006 |
|
| 4007 |
} |
| 4008 |
|
| 4009 |
array_push($json, $object); |
| 4010 |
|
| 4011 |
} |
| 4012 |
|
| 4013 |
if ($this->checkDuplicateOptionNumbers($json, 'number') === true) { |
| 4014 |
|
| 4015 |
return array('status' => 'error', 'message' => sprintf(__('The value for \'%s\' in the options must be a unique number that does not duplicate values from other settings.', 'booking-package'), __('Number of Guests', 'booking-package') ) ); |
| 4016 |
|
| 4017 |
} |
| 4018 |
|
| 4019 |
$guestsInCapacity = 'included'; |
| 4020 |
if (isset($_POST['guestsInCapacity'])) { |
| 4021 |
|
| 4022 |
$guestsInCapacity = $_POST['guestsInCapacity']; |
| 4023 |
if (empty($_POST['guestsInCapacity']) === true) { |
| 4024 |
|
| 4025 |
$guestsInCapacity = 'included'; |
| 4026 |
|
| 4027 |
} |
| 4028 |
|
| 4029 |
} |
| 4030 |
|
| 4031 |
$reflectService = 0; |
| 4032 |
if (isset($_POST['reflectService'])) { |
| 4033 |
|
| 4034 |
$reflectService = intval($_POST['reflectService']); |
| 4035 |
|
| 4036 |
} |
| 4037 |
|
| 4038 |
$reflectAdditional = 0; |
| 4039 |
if (isset($_POST['reflectAdditional'])) { |
| 4040 |
|
| 4041 |
$reflectAdditional = intval($_POST['reflectAdditional']); |
| 4042 |
|
| 4043 |
} |
| 4044 |
|
| 4045 |
$costInServices = 'cost_1'; |
| 4046 |
if (isset($_POST['costInServices']) && $this->getExtensionsValid() === true) { |
| 4047 |
|
| 4048 |
$costInServices = $_POST['costInServices']; |
| 4049 |
|
| 4050 |
} |
| 4051 |
|
| 4052 |
$table_name = $wpdb->prefix."booking_package_guests"; |
| 4053 |
$sql = $wpdb->prepare("SELECT COUNT(*) FROM ".$table_name." WHERE `accountKey` = %d;", array(intval($accountKey))); |
| 4054 |
$row = $wpdb->get_row($sql, ARRAY_A); |
| 4055 |
$count = $row['COUNT(*)'] + 1; |
| 4056 |
#var_dump($count); |
| 4057 |
|
| 4058 |
$wpdb->insert( |
| 4059 |
$table_name, |
| 4060 |
array( |
| 4061 |
'accountKey' => intval($accountKey), |
| 4062 |
'name' => sanitize_text_field(stripslashes($_POST['name'])), |
| 4063 |
'costInServices' => sanitize_text_field($costInServices), |
| 4064 |
'target' => sanitize_text_field($_POST['target']), |
| 4065 |
'guestsInCapacity' => sanitize_text_field($guestsInCapacity), |
| 4066 |
'json' => json_encode($json), |
| 4067 |
'ranking' => intval($count), |
| 4068 |
'required' => intval($_POST['required']), |
| 4069 |
'reflectService' => intval($reflectService), |
| 4070 |
'reflectAdditional' => intval($reflectAdditional), |
| 4071 |
'description' => sanitize_textarea_field(stripslashes($_POST['description'])), |
| 4072 |
'active' => sanitize_text_field($_POST['active']), |
| 4073 |
), |
| 4074 |
array('%d', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%s') |
| 4075 |
); |
| 4076 |
|
| 4077 |
} |
| 4078 |
|
| 4079 |
return $this->getGuestsList($accountKey); |
| 4080 |
|
| 4081 |
} |
| 4082 |
|
| 4083 |
die(); |
| 4084 |
|
| 4085 |
} |
| 4086 |
|
| 4087 |
public function deleteGuestsItem($accountKey = false){ |
| 4088 |
|
| 4089 |
global $wpdb; |
| 4090 |
if($accountKey != false){ |
| 4091 |
|
| 4092 |
$table_name = $wpdb->prefix."booking_package_guests"; |
| 4093 |
$wpdb->delete($table_name, array('key' => intval($_POST['key'])), array('%d')); |
| 4094 |
|
| 4095 |
return $this->getGuestsList($accountKey); |
| 4096 |
|
| 4097 |
} |
| 4098 |
|
| 4099 |
die(); |
| 4100 |
|
| 4101 |
} |
| 4102 |
|
| 4103 |
public function changeGuestsRank($accountKey = false){ |
| 4104 |
|
| 4105 |
global $wpdb; |
| 4106 |
if($accountKey != false){ |
| 4107 |
|
| 4108 |
$table_name = $wpdb->prefix . "booking_package_guests"; |
| 4109 |
try { |
| 4110 |
|
| 4111 |
$wpdb->query("START TRANSACTION"); |
| 4112 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 4113 |
$keyList = explode(",", $_POST['keyList']); |
| 4114 |
for($i = 0; $i < count($keyList); $i++){ |
| 4115 |
|
| 4116 |
$ranking = $i + 1; |
| 4117 |
$wpdb->update( |
| 4118 |
$table_name, |
| 4119 |
array( |
| 4120 |
'ranking' => intval($ranking) |
| 4121 |
), |
| 4122 |
array('key' => intval($keyList[$i]), 'accountKey' => intval($accountKey)), |
| 4123 |
array('%d'), |
| 4124 |
array('%d', '%d') |
| 4125 |
); |
| 4126 |
|
| 4127 |
} |
| 4128 |
|
| 4129 |
$wpdb->query('COMMIT'); |
| 4130 |
$wpdb->query('UNLOCK TABLES'); |
| 4131 |
|
| 4132 |
} catch (Exception $e) { |
| 4133 |
|
| 4134 |
$wpdb->query('ROLLBACK'); |
| 4135 |
$wpdb->query('UNLOCK TABLES'); |
| 4136 |
|
| 4137 |
}/** finally { |
| 4138 |
|
| 4139 |
$wpdb->query('UNLOCK TABLES'); |
| 4140 |
|
| 4141 |
}**/ |
| 4142 |
|
| 4143 |
return $this->getGuestsList($accountKey); |
| 4144 |
|
| 4145 |
} |
| 4146 |
|
| 4147 |
die(); |
| 4148 |
|
| 4149 |
} |
| 4150 |
|
| 4151 |
public function validExpirationDate() { |
| 4152 |
|
| 4153 |
$response = array('expirationDateStatus' => 0, 'expirationDateFrom' => 0, 'expirationDateTo' => 0); |
| 4154 |
if (isset($_POST['expirationDateStatus'])) { |
| 4155 |
|
| 4156 |
if (empty($_POST['expirationDateStatus']) === false) { |
| 4157 |
|
| 4158 |
$response['expirationDateStatus'] = $_POST['expirationDateStatus']; |
| 4159 |
|
| 4160 |
} |
| 4161 |
$response['expirationDateFrom'] = $_POST['expirationDateFromYear'] . sprintf('%02d', $_POST['expirationDateFromMonth']) . sprintf('%02d', $_POST['expirationDateFromDay']); |
| 4162 |
$response['expirationDateTo'] = $_POST['expirationDateToYear'] . sprintf('%02d', $_POST['expirationDateToMonth']) . sprintf('%02d', $_POST['expirationDateToDay']); |
| 4163 |
|
| 4164 |
} |
| 4165 |
|
| 4166 |
return $response; |
| 4167 |
|
| 4168 |
} |
| 4169 |
|
| 4170 |
public function getBlockEmailLists($schedule) { |
| 4171 |
|
| 4172 |
global $wpdb; |
| 4173 |
$response = array(); |
| 4174 |
$dateFormat = intval(get_option($this->prefix."dateFormat", 0)); |
| 4175 |
$positionOfWeek = get_option($this->prefix."positionOfWeek", "before"); |
| 4176 |
|
| 4177 |
$table_name = $wpdb->prefix . "booking_package_block_list"; |
| 4178 |
#$sql = $wpdb->prepare("SELECT * FROM " . $table_name . " ORDER BY date DESC;", array()); |
| 4179 |
$rows = $wpdb->get_results("SELECT * FROM " . $table_name . " ORDER BY date DESC;", ARRAY_A); |
| 4180 |
foreach ((array) $rows as $key => $value) { |
| 4181 |
|
| 4182 |
$value['date'] = $schedule->dateFormat($dateFormat, $positionOfWeek, $value['date'], '', true, true, 'text'); |
| 4183 |
array_push($response, $value); |
| 4184 |
|
| 4185 |
} |
| 4186 |
|
| 4187 |
return $response; |
| 4188 |
|
| 4189 |
} |
| 4190 |
|
| 4191 |
public function addBlockEmail($email, $schedule) { |
| 4192 |
|
| 4193 |
global $wpdb; |
| 4194 |
$lastKey = null; |
| 4195 |
$email = sanitize_text_field(trim($email)); |
| 4196 |
$dateFormat = intval(get_option($this->prefix."dateFormat", 0)); |
| 4197 |
$positionOfWeek = get_option($this->prefix."positionOfWeek", "before"); |
| 4198 |
$date = date("U"); |
| 4199 |
$table_name = $wpdb->prefix . "booking_package_block_list"; |
| 4200 |
$sql = $wpdb->prepare( |
| 4201 |
"SELECT `key` FROM `" . $table_name . "` WHERE `value` = %s;", |
| 4202 |
array($email) |
| 4203 |
); |
| 4204 |
$row = $wpdb->get_row($sql, ARRAY_A); |
| 4205 |
|
| 4206 |
if (is_null($row)) { |
| 4207 |
|
| 4208 |
$wpdb->insert( |
| 4209 |
$table_name, |
| 4210 |
array( |
| 4211 |
'type' => 'email', |
| 4212 |
'value' => $email, |
| 4213 |
'date' => intval($date), |
| 4214 |
), |
| 4215 |
array('%s', '%s', '%d') |
| 4216 |
); |
| 4217 |
$lastKey = $wpdb->insert_id; |
| 4218 |
$date = $schedule->dateFormat($dateFormat, $positionOfWeek, $date, '', true, true, 'text'); |
| 4219 |
$blocskList = $this->getBlockEmailLists($schedule); |
| 4220 |
return array('status' => 'success', 'key' => $lastKey, 'email' => $email, 'date' => $date, 'blocskList' => $blocskList); |
| 4221 |
|
| 4222 |
} |
| 4223 |
|
| 4224 |
return array('status' => 'error', 'message' => sprintf(__('You have already added the "%s".', 'booking-package'), $email)); |
| 4225 |
|
| 4226 |
} |
| 4227 |
|
| 4228 |
public function deleteBlockEmail($key, $schedule) { |
| 4229 |
|
| 4230 |
global $wpdb; |
| 4231 |
$table_name = $wpdb->prefix . "booking_package_block_list"; |
| 4232 |
$wpdb->delete( |
| 4233 |
$table_name, |
| 4234 |
array( |
| 4235 |
'key' => intval($key) |
| 4236 |
), |
| 4237 |
array('%d') |
| 4238 |
); |
| 4239 |
|
| 4240 |
return $this->getBlockEmailLists($schedule); |
| 4241 |
|
| 4242 |
} |
| 4243 |
|
| 4244 |
public function addCourse(){ |
| 4245 |
|
| 4246 |
$accountKey = 1; |
| 4247 |
if (isset($_POST['accountKey'])) { |
| 4248 |
|
| 4249 |
$accountKey = $_POST['accountKey']; |
| 4250 |
|
| 4251 |
} |
| 4252 |
|
| 4253 |
$expirationDate = $this->validExpirationDate(); |
| 4254 |
$expirationDateStatus = $expirationDate['expirationDateStatus']; |
| 4255 |
$expirationDateFrom = $expirationDate['expirationDateFrom']; |
| 4256 |
$expirationDateTo = $expirationDate['expirationDateTo']; |
| 4257 |
|
| 4258 |
$options = array(); |
| 4259 |
if (isset($_POST['options'])) { |
| 4260 |
|
| 4261 |
$jsonList = json_decode(stripslashes($_POST['options']), true); |
| 4262 |
for ($i = 0; $i < count($jsonList); $i++) { |
| 4263 |
|
| 4264 |
$object = array(); |
| 4265 |
foreach ((array) $jsonList[$i] as $key => $value) { |
| 4266 |
|
| 4267 |
if ($key == 'cost_1' || $key == 'cost_2' || $key == 'cost_3' || $key == 'cost_4' || $key == 'cost_5' || $key == 'cost_6') { |
| 4268 |
|
| 4269 |
if (is_int($value) === false) { |
| 4270 |
|
| 4271 |
$value = $this->getOnlyNumbers($value); |
| 4272 |
|
| 4273 |
} |
| 4274 |
|
| 4275 |
} |
| 4276 |
|
| 4277 |
$object[sanitize_text_field($key)] = sanitize_text_field($value); |
| 4278 |
|
| 4279 |
} |
| 4280 |
array_push($options, $object); |
| 4281 |
|
| 4282 |
} |
| 4283 |
|
| 4284 |
if ($this->getExtensionsValid() === false) { |
| 4285 |
|
| 4286 |
$options = array(); |
| 4287 |
|
| 4288 |
} |
| 4289 |
|
| 4290 |
} |
| 4291 |
|
| 4292 |
$timeToProvide = array(); |
| 4293 |
if (isset($_POST['timeToProvide'])) { |
| 4294 |
|
| 4295 |
$jsonList = json_decode(stripslashes($_POST['timeToProvide']), true); |
| 4296 |
for ($i = 0; $i < count($jsonList); $i++) { |
| 4297 |
|
| 4298 |
$object = array(); |
| 4299 |
foreach ((array) $jsonList[$i] as $key => $value) { |
| 4300 |
|
| 4301 |
$object[sanitize_text_field($key)] = sanitize_text_field($value); |
| 4302 |
|
| 4303 |
} |
| 4304 |
array_push($timeToProvide, $object); |
| 4305 |
|
| 4306 |
} |
| 4307 |
|
| 4308 |
|
| 4309 |
if ($this->getExtensionsValid() === false) { |
| 4310 |
|
| 4311 |
$timeToProvide = array(); |
| 4312 |
|
| 4313 |
} |
| 4314 |
|
| 4315 |
} |
| 4316 |
|
| 4317 |
if (!isset($_POST['target'])) { |
| 4318 |
|
| 4319 |
$_POST['target'] = 'visitors_users'; |
| 4320 |
|
| 4321 |
} |
| 4322 |
|
| 4323 |
if (!isset($_POST['stopServiceUnderFollowingConditions'])) { |
| 4324 |
|
| 4325 |
$_POST['stopServiceUnderFollowingConditions'] = 'doNotStop'; |
| 4326 |
$_POST['stopServiceForDayOfTimes'] = 'timeSlot'; |
| 4327 |
$_POST['stopServiceForSpecifiedNumberOfTimes'] = 0; |
| 4328 |
|
| 4329 |
} |
| 4330 |
|
| 4331 |
if (!isset($_POST['doNotStopServiceAsException']) || empty($_POST['doNotStopServiceAsException'])) { |
| 4332 |
|
| 4333 |
$_POST['doNotStopServiceAsException'] = 'hasNotException'; |
| 4334 |
|
| 4335 |
} |
| 4336 |
|
| 4337 |
for ($i = 1; $i <= 6; $i++) { |
| 4338 |
|
| 4339 |
if (!isset($_POST['cost_' . $i])) { |
| 4340 |
|
| 4341 |
$_POST['cost_' . $i] = 0; |
| 4342 |
|
| 4343 |
} |
| 4344 |
|
| 4345 |
if (is_int($_POST['cost_' . $i]) === false) { |
| 4346 |
|
| 4347 |
$_POST['cost_' . $i] = $this->getOnlyNumbers($_POST['cost_' . $i]); |
| 4348 |
|
| 4349 |
} |
| 4350 |
|
| 4351 |
if ($i > 1 && $this->getExtensionsValid() === false) { |
| 4352 |
|
| 4353 |
$_POST['cost_' . $i] = 0; |
| 4354 |
|
| 4355 |
} |
| 4356 |
|
| 4357 |
} |
| 4358 |
|
| 4359 |
global $wpdb; |
| 4360 |
$table_name = $wpdb->prefix . "booking_package_services"; |
| 4361 |
$wpdb->insert( |
| 4362 |
$table_name, |
| 4363 |
array( |
| 4364 |
'accountKey' => intval($accountKey), |
| 4365 |
'name' => sanitize_text_field($_POST['name']), |
| 4366 |
'description' => sanitize_textarea_field($_POST['description']), |
| 4367 |
'cost_1' => intval($_POST['cost_1']), |
| 4368 |
'cost_2' => intval($_POST['cost_2']), |
| 4369 |
'cost_3' => intval($_POST['cost_3']), |
| 4370 |
'cost_4' => intval($_POST['cost_4']), |
| 4371 |
'cost_5' => intval($_POST['cost_5']), |
| 4372 |
'cost_6' => intval($_POST['cost_6']), |
| 4373 |
'time' => intval($_POST['time']), |
| 4374 |
'ranking' => intval($_POST['rank']), |
| 4375 |
'active' => sanitize_text_field($_POST['active']), |
| 4376 |
'target' => sanitize_text_field($_POST['target']), |
| 4377 |
'selectOptions' => intval($_POST['selectOptions']), |
| 4378 |
'options' => json_encode($options), |
| 4379 |
'timeToProvide' => json_encode($timeToProvide), |
| 4380 |
'expirationDateStatus' => intval($expirationDateStatus), |
| 4381 |
'expirationDateFrom' => intval($expirationDateFrom), |
| 4382 |
'expirationDateTo' => intval($expirationDateTo), |
| 4383 |
'stopServiceUnderFollowingConditions' => sanitize_text_field($_POST['stopServiceUnderFollowingConditions']), |
| 4384 |
'doNotStopServiceAsException' => sanitize_text_field($_POST['doNotStopServiceAsException']), |
| 4385 |
'stopServiceForDayOfTimes' => sanitize_text_field($_POST['stopServiceForDayOfTimes']), |
| 4386 |
'stopServiceForSpecifiedNumberOfTimes' => intval($_POST['stopServiceForSpecifiedNumberOfTimes']), |
| 4387 |
), |
| 4388 |
array( |
| 4389 |
'%d', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', |
| 4390 |
'%d', '%s', '%s', '%d', '%s', '%s', '%d', '%d', '%d', '%s', |
| 4391 |
'%s', '%s', '%d', |
| 4392 |
) |
| 4393 |
); |
| 4394 |
/** |
| 4395 |
$sql = $wpdb->prepare("SELECT * FROM ".$table_name." WHERE `accountKey` = %d ORDER BY ranking ASC;", array(intval($accountKey))); |
| 4396 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 4397 |
return $rows; |
| 4398 |
**/ |
| 4399 |
return $this->getCourseList($accountKey); |
| 4400 |
|
| 4401 |
} |
| 4402 |
|
| 4403 |
public function updateCourse(){ |
| 4404 |
|
| 4405 |
$accountKey = 1; |
| 4406 |
if (isset($_POST['accountKey'])) { |
| 4407 |
|
| 4408 |
$accountKey = $_POST['accountKey']; |
| 4409 |
|
| 4410 |
} |
| 4411 |
|
| 4412 |
$expirationDate = $this->validExpirationDate(); |
| 4413 |
$expirationDateStatus = $expirationDate['expirationDateStatus']; |
| 4414 |
$expirationDateFrom = $expirationDate['expirationDateFrom']; |
| 4415 |
$expirationDateTo = $expirationDate['expirationDateTo']; |
| 4416 |
|
| 4417 |
$options = array(); |
| 4418 |
if (isset($_POST['options'])) { |
| 4419 |
|
| 4420 |
$jsonList = json_decode(stripslashes($_POST['options']), true); |
| 4421 |
for ($i = 0; $i < count($jsonList); $i++) { |
| 4422 |
|
| 4423 |
$object = array(); |
| 4424 |
foreach ((array) $jsonList[$i] as $key => $value) { |
| 4425 |
|
| 4426 |
if ($key == 'cost_1' || $key == 'cost_2' || $key == 'cost_3' || $key == 'cost_4' || $key == 'cost_5' || $key == 'cost_6') { |
| 4427 |
|
| 4428 |
if (is_int($value) === false) { |
| 4429 |
|
| 4430 |
$value = $this->getOnlyNumbers($value); |
| 4431 |
|
| 4432 |
} |
| 4433 |
|
| 4434 |
} |
| 4435 |
|
| 4436 |
$object[sanitize_text_field($key)] = sanitize_text_field($value); |
| 4437 |
|
| 4438 |
} |
| 4439 |
|
| 4440 |
array_push($options, $object); |
| 4441 |
|
| 4442 |
} |
| 4443 |
|
| 4444 |
if ($this->getExtensionsValid() === false) { |
| 4445 |
|
| 4446 |
$options = array(); |
| 4447 |
|
| 4448 |
} |
| 4449 |
|
| 4450 |
} |
| 4451 |
|
| 4452 |
$timeToProvide = array(); |
| 4453 |
if (isset($_POST['timeToProvide'])) { |
| 4454 |
|
| 4455 |
$jsonList = json_decode(stripslashes($_POST['timeToProvide']), true); |
| 4456 |
for ($i = 0; $i < count($jsonList); $i++) { |
| 4457 |
|
| 4458 |
$object = array(); |
| 4459 |
if (is_array($jsonList[$i])) { |
| 4460 |
|
| 4461 |
foreach ((array) $jsonList[$i] as $key => $value) { |
| 4462 |
|
| 4463 |
$object[sanitize_text_field($key)] = sanitize_text_field($value); |
| 4464 |
|
| 4465 |
} |
| 4466 |
|
| 4467 |
} |
| 4468 |
|
| 4469 |
array_push($timeToProvide, $object); |
| 4470 |
|
| 4471 |
} |
| 4472 |
|
| 4473 |
|
| 4474 |
if ($this->getExtensionsValid() === false) { |
| 4475 |
|
| 4476 |
$timeToProvide = array(); |
| 4477 |
|
| 4478 |
} |
| 4479 |
|
| 4480 |
} |
| 4481 |
|
| 4482 |
if (!isset($_POST['target'])) { |
| 4483 |
|
| 4484 |
$_POST['target'] = 'visitors_users'; |
| 4485 |
|
| 4486 |
} |
| 4487 |
|
| 4488 |
if (!isset($_POST['stopServiceUnderFollowingConditions'])) { |
| 4489 |
|
| 4490 |
$_POST['stopServiceUnderFollowingConditions'] = 'doNotStop'; |
| 4491 |
$_POST['stopServiceForDayOfTimes'] = 'timeSlot'; |
| 4492 |
$_POST['stopServiceForSpecifiedNumberOfTimes'] = 0; |
| 4493 |
|
| 4494 |
} |
| 4495 |
|
| 4496 |
if (!isset($_POST['doNotStopServiceAsException']) || empty($_POST['doNotStopServiceAsException'])) { |
| 4497 |
|
| 4498 |
$_POST['doNotStopServiceAsException'] = 'hasNotException'; |
| 4499 |
|
| 4500 |
} |
| 4501 |
|
| 4502 |
for ($i = 1; $i <= 6; $i++) { |
| 4503 |
|
| 4504 |
if (!isset($_POST['cost_' . $i])) { |
| 4505 |
|
| 4506 |
$_POST['cost_' . $i] = 0; |
| 4507 |
|
| 4508 |
} |
| 4509 |
|
| 4510 |
if (is_int($_POST['cost_' . $i]) === false) { |
| 4511 |
|
| 4512 |
$_POST['cost_' . $i] = $this->getOnlyNumbers($_POST['cost_' . $i]); |
| 4513 |
|
| 4514 |
} |
| 4515 |
|
| 4516 |
if ($i > 1 && $this->getExtensionsValid() === false) { |
| 4517 |
|
| 4518 |
$_POST['cost_' . $i] = 0; |
| 4519 |
|
| 4520 |
} |
| 4521 |
|
| 4522 |
} |
| 4523 |
|
| 4524 |
global $wpdb; |
| 4525 |
$table_name = $wpdb->prefix . "booking_package_services"; |
| 4526 |
try { |
| 4527 |
|
| 4528 |
$wpdb->query("START TRANSACTION"); |
| 4529 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 4530 |
$wpdb->update( |
| 4531 |
$table_name, |
| 4532 |
array( |
| 4533 |
'name' => sanitize_text_field(stripslashes($_POST['name'])), |
| 4534 |
'description' => sanitize_textarea_field(stripslashes($_POST['description'])), |
| 4535 |
'time' => intval($_POST['time']), |
| 4536 |
'cost_1' => intval($_POST['cost_1']), |
| 4537 |
'cost_2' => intval($_POST['cost_2']), |
| 4538 |
'cost_3' => intval($_POST['cost_3']), |
| 4539 |
'cost_4' => intval($_POST['cost_4']), |
| 4540 |
'cost_5' => intval($_POST['cost_5']), |
| 4541 |
'cost_6' => intval($_POST['cost_6']), |
| 4542 |
'active' => sanitize_text_field($_POST['active']), |
| 4543 |
'target' => sanitize_text_field($_POST['target']), |
| 4544 |
'selectOptions' => intval($_POST['selectOptions']), |
| 4545 |
'options' => json_encode($options), |
| 4546 |
'timeToProvide' => json_encode($timeToProvide), |
| 4547 |
'expirationDateStatus' => intval($expirationDateStatus), |
| 4548 |
'expirationDateFrom' => intval($expirationDateFrom), |
| 4549 |
'expirationDateTo' => intval($expirationDateTo), |
| 4550 |
'stopServiceUnderFollowingConditions' => sanitize_text_field($_POST['stopServiceUnderFollowingConditions']), |
| 4551 |
'doNotStopServiceAsException' => sanitize_text_field($_POST['doNotStopServiceAsException']), |
| 4552 |
'stopServiceForDayOfTimes' => sanitize_text_field($_POST['stopServiceForDayOfTimes']), |
| 4553 |
'stopServiceForSpecifiedNumberOfTimes' => intval($_POST['stopServiceForSpecifiedNumberOfTimes']), |
| 4554 |
), |
| 4555 |
array('key' => intval($_POST['key'])), |
| 4556 |
array( |
| 4557 |
'%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', |
| 4558 |
'%s', '%d', '%s', '%s', '%d', '%d', '%d', '%s', '%s', '%s', |
| 4559 |
'%d', |
| 4560 |
), |
| 4561 |
array('%d') |
| 4562 |
); |
| 4563 |
|
| 4564 |
$wpdb->query('COMMIT'); |
| 4565 |
$wpdb->query('UNLOCK TABLES'); |
| 4566 |
|
| 4567 |
} catch (Exception $e) { |
| 4568 |
|
| 4569 |
$wpdb->query('ROLLBACK'); |
| 4570 |
$wpdb->query('UNLOCK TABLES'); |
| 4571 |
|
| 4572 |
}/** finally { |
| 4573 |
|
| 4574 |
$wpdb->query('UNLOCK TABLES'); |
| 4575 |
|
| 4576 |
}**/ |
| 4577 |
|
| 4578 |
|
| 4579 |
|
| 4580 |
return $this->getCourseList($accountKey); |
| 4581 |
|
| 4582 |
} |
| 4583 |
|
| 4584 |
public function copyCourse() { |
| 4585 |
|
| 4586 |
$accountKey = 1; |
| 4587 |
if(isset($_POST['accountKey'])){ |
| 4588 |
|
| 4589 |
$accountKey = $_POST['accountKey']; |
| 4590 |
|
| 4591 |
} |
| 4592 |
|
| 4593 |
global $wpdb; |
| 4594 |
$table_name = $wpdb->prefix . "booking_package_services"; |
| 4595 |
$tmp_table_name = $table_name."_tmp"; |
| 4596 |
|
| 4597 |
$sql = $wpdb->prepare('SELECT COUNT(`key`) as `count` FROM ' . $table_name . ' WHERE `accountKey` = %d', array(intval($accountKey))); |
| 4598 |
$row = $wpdb->get_row($sql, ARRAY_A); |
| 4599 |
$ranking = $row['count'] + 1; |
| 4600 |
|
| 4601 |
$sql = $wpdb->prepare("CREATE TEMPORARY TABLE " . $tmp_table_name . " SELECT * FROM " . $table_name . " WHERE `key` = %d;", array(intval($_POST['key']))); |
| 4602 |
$wpdb->query($sql); |
| 4603 |
$wpdb->query("ALTER TABLE " . $tmp_table_name . " drop `key`;"); |
| 4604 |
$sql = $wpdb->prepare("UPDATE " . $tmp_table_name . " SET `name` = CONCAT(name, ' Copy'), `ranking` = %d, `active` = '';", array(intval($ranking))); |
| 4605 |
$wpdb->query($sql); |
| 4606 |
#$wpdb->query("UPDATE " . $tmp_table_name . " SET `name` = CONCAT(name, ' Copy'), `active` = '';"); |
| 4607 |
$wpdb->query("INSERT INTO " . $table_name . " SELECT 0," . $tmp_table_name . ".* FROM " . $tmp_table_name . ";"); |
| 4608 |
$wpdb->query("DROP TABLE " . $tmp_table_name . ";"); |
| 4609 |
|
| 4610 |
$sql = $wpdb->prepare("SELECT * FROM ".$table_name." WHERE `accountKey` = %d ORDER BY ranking ASC;", array(intval($accountKey))); |
| 4611 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 4612 |
return $rows; |
| 4613 |
|
| 4614 |
} |
| 4615 |
|
| 4616 |
public function deleteCourse(){ |
| 4617 |
|
| 4618 |
$accountKey = 1; |
| 4619 |
if(isset($_POST['accountKey'])){ |
| 4620 |
|
| 4621 |
$accountKey = $_POST['accountKey']; |
| 4622 |
|
| 4623 |
} |
| 4624 |
|
| 4625 |
global $wpdb; |
| 4626 |
$table_name = $wpdb->prefix . "booking_package_services"; |
| 4627 |
$wpdb->delete($table_name, array('key' => intval($_POST['key'])), array('%d')); |
| 4628 |
$sql = $wpdb->prepare("SELECT * FROM ".$table_name." WHERE `accountKey` = %d ORDER BY ranking ASC;", array(intval($accountKey))); |
| 4629 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 4630 |
return $rows; |
| 4631 |
|
| 4632 |
} |
| 4633 |
|
| 4634 |
public function getSubscriptions(){ |
| 4635 |
|
| 4636 |
global $wpdb; |
| 4637 |
$table_name = $wpdb->prefix."booking_package_subscriptions"; |
| 4638 |
$sql = $wpdb->prepare("SELECT * FROM ".$table_name." WHERE `accountKey` = %d ORDER BY ranking ASC;", array(intval($_POST['accountKey']))); |
| 4639 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 4640 |
$isExtensionsValid = $this->getExtensionsValid(); |
| 4641 |
if ($isExtensionsValid === false) { |
| 4642 |
|
| 4643 |
return array(); |
| 4644 |
|
| 4645 |
} else { |
| 4646 |
|
| 4647 |
return $rows; |
| 4648 |
|
| 4649 |
} |
| 4650 |
|
| 4651 |
} |
| 4652 |
|
| 4653 |
public function addSubscriptions(){ |
| 4654 |
|
| 4655 |
$accountKey = $_POST['accountKey']; |
| 4656 |
if ($this->getExtensionsValid() === false) { |
| 4657 |
|
| 4658 |
return array(); |
| 4659 |
|
| 4660 |
} |
| 4661 |
|
| 4662 |
global $wpdb; |
| 4663 |
$table_name = $wpdb->prefix."booking_package_subscriptions"; |
| 4664 |
$wpdb->insert( $table_name, |
| 4665 |
array( |
| 4666 |
'accountKey' => intval($accountKey), |
| 4667 |
'name' => sanitize_text_field($_POST['name']), |
| 4668 |
'subscription' => sanitize_text_field($_POST['subscription']), |
| 4669 |
'active' => sanitize_text_field($_POST['active']), |
| 4670 |
'ranking' => intval($_POST['rank']), |
| 4671 |
'renewal' => intval($_POST['renewal']), |
| 4672 |
'limit' => intval($_POST['limit']), |
| 4673 |
'numberOfTimes' => intval($_POST['numberOfTimes']), |
| 4674 |
), |
| 4675 |
array('%d', '%s', '%s', '%s', '%d', '%d', '%d', '%d') |
| 4676 |
); |
| 4677 |
|
| 4678 |
$sql = $wpdb->prepare("SELECT * FROM ".$table_name." WHERE `accountKey` = %d ORDER BY ranking ASC;", array(intval($accountKey))); |
| 4679 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 4680 |
return $rows; |
| 4681 |
|
| 4682 |
} |
| 4683 |
|
| 4684 |
public function updateSubscriptions(){ |
| 4685 |
|
| 4686 |
$accountKey = $_POST['accountKey']; |
| 4687 |
if ($this->getExtensionsValid() === false) { |
| 4688 |
|
| 4689 |
return array(); |
| 4690 |
|
| 4691 |
} |
| 4692 |
|
| 4693 |
global $wpdb; |
| 4694 |
$table_name = $wpdb->prefix . "booking_package_subscriptions"; |
| 4695 |
try { |
| 4696 |
|
| 4697 |
$wpdb->query("START TRANSACTION"); |
| 4698 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 4699 |
$wpdb->update( |
| 4700 |
$table_name, |
| 4701 |
array( |
| 4702 |
'name' => sanitize_text_field($_POST['name']), |
| 4703 |
'active' => sanitize_text_field($_POST['active']), |
| 4704 |
'renewal' => intval($_POST['renewal']), |
| 4705 |
'limit' => intval($_POST['limit']), |
| 4706 |
'numberOfTimes' => intval($_POST['numberOfTimes']), |
| 4707 |
), |
| 4708 |
array('key' => intval($_POST['key'])), |
| 4709 |
array('%s', '%s', '%d', '%d', '%d'), |
| 4710 |
array('%d') |
| 4711 |
); |
| 4712 |
|
| 4713 |
$wpdb->query('COMMIT'); |
| 4714 |
$wpdb->query('UNLOCK TABLES'); |
| 4715 |
|
| 4716 |
} catch (Exception $e) { |
| 4717 |
|
| 4718 |
$wpdb->query('ROLLBACK'); |
| 4719 |
$wpdb->query('UNLOCK TABLES'); |
| 4720 |
|
| 4721 |
}/** finally { |
| 4722 |
|
| 4723 |
$wpdb->query('UNLOCK TABLES'); |
| 4724 |
|
| 4725 |
}**/ |
| 4726 |
|
| 4727 |
return $this->getSubscriptions(); |
| 4728 |
|
| 4729 |
} |
| 4730 |
|
| 4731 |
public function deleteSubscriptions(){ |
| 4732 |
|
| 4733 |
global $wpdb; |
| 4734 |
$table_name = $wpdb->prefix."booking_package_subscriptions"; |
| 4735 |
$wpdb->delete($table_name, array('key' => intval($_POST['key'])), array('%d')); |
| 4736 |
return $this->getSubscriptions(); |
| 4737 |
|
| 4738 |
} |
| 4739 |
|
| 4740 |
public function changeSubscriptionsRank(){ |
| 4741 |
|
| 4742 |
$keyList = explode(",", $_POST['keyList']); |
| 4743 |
$indexList = explode(",", $_POST['indexList']); |
| 4744 |
|
| 4745 |
global $wpdb; |
| 4746 |
$table_name = $wpdb->prefix . "booking_package_subscriptions"; |
| 4747 |
try { |
| 4748 |
|
| 4749 |
$wpdb->query("START TRANSACTION"); |
| 4750 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 4751 |
for($i = 0; $i < count($keyList); $i++){ |
| 4752 |
|
| 4753 |
$wpdb->update( |
| 4754 |
$table_name, |
| 4755 |
array('ranking' => intval($indexList[$i])), |
| 4756 |
array('key' => intval($keyList[$i])), |
| 4757 |
array('%d'), |
| 4758 |
array('%d') |
| 4759 |
); |
| 4760 |
|
| 4761 |
} |
| 4762 |
|
| 4763 |
$wpdb->query('COMMIT'); |
| 4764 |
$wpdb->query('UNLOCK TABLES'); |
| 4765 |
|
| 4766 |
} catch (Exception $e) { |
| 4767 |
|
| 4768 |
$wpdb->query('ROLLBACK'); |
| 4769 |
$wpdb->query('UNLOCK TABLES'); |
| 4770 |
|
| 4771 |
}/** finally { |
| 4772 |
|
| 4773 |
$wpdb->query('UNLOCK TABLES'); |
| 4774 |
|
| 4775 |
}**/ |
| 4776 |
|
| 4777 |
return $this->getSubscriptions(); |
| 4778 |
|
| 4779 |
} |
| 4780 |
|
| 4781 |
public function getTaxes($accountKey, $sort = 'no') { |
| 4782 |
|
| 4783 |
global $wpdb; |
| 4784 |
$table_name = $wpdb->prefix . "booking_package_taxes"; |
| 4785 |
$sql = $wpdb->prepare("SELECT * FROM " . $table_name . " WHERE `accountKey` = %d ORDER BY ranking ASC;", array(intval($accountKey))); |
| 4786 |
if ($sort === 'yes') { |
| 4787 |
|
| 4788 |
$sql = $wpdb->prepare("SELECT * FROM " . $table_name . " WHERE `accountKey` = %d ORDER BY (type = 'surcharge') DESC, (type = 'tax') DESC, ranking ASC;", array(intval($accountKey))); |
| 4789 |
|
| 4790 |
} |
| 4791 |
if (isset($_POST['taxType']) === true) { |
| 4792 |
|
| 4793 |
$sql = $wpdb->prepare( |
| 4794 |
"SELECT * FROM " . $table_name . " WHERE `accountKey` = %d AND `type` = %s ORDER BY ranking ASC;", |
| 4795 |
array( |
| 4796 |
intval($accountKey), |
| 4797 |
sanitize_text_field($_POST['taxType']) |
| 4798 |
) |
| 4799 |
); |
| 4800 |
|
| 4801 |
} |
| 4802 |
|
| 4803 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 4804 |
$isExtensionsValid = $this->getExtensionsValid(); |
| 4805 |
if ($isExtensionsValid === false) { |
| 4806 |
|
| 4807 |
return array(); |
| 4808 |
|
| 4809 |
} else { |
| 4810 |
|
| 4811 |
return $rows; |
| 4812 |
|
| 4813 |
} |
| 4814 |
|
| 4815 |
} |
| 4816 |
|
| 4817 |
public function addTax($accountKey) { |
| 4818 |
|
| 4819 |
$_POST['taxType'] = 'tax'; |
| 4820 |
$_POST['type'] = 'tax'; |
| 4821 |
$_POST['scope'] = 'day'; |
| 4822 |
return $this->addTaxAndExtraCharge($accountKey); |
| 4823 |
|
| 4824 |
} |
| 4825 |
|
| 4826 |
public function addExtraCharge($accountKey) { |
| 4827 |
|
| 4828 |
$_POST['taxType'] = 'surcharge'; |
| 4829 |
$_POST['type'] = 'surcharge'; |
| 4830 |
$_POST['method'] = 'addition'; |
| 4831 |
if ( !isset($_POST['scope']) ) { |
| 4832 |
|
| 4833 |
$_POST['scope'] = 'day'; |
| 4834 |
|
| 4835 |
} |
| 4836 |
|
| 4837 |
return $this->addTaxAndExtraCharge($accountKey); |
| 4838 |
|
| 4839 |
} |
| 4840 |
|
| 4841 |
public function addTaxAndExtraCharge($accountKey) { |
| 4842 |
|
| 4843 |
if ($_POST['type'] == 'surcharge') { |
| 4844 |
|
| 4845 |
$_POST['tax'] = 'tax_inclusive'; |
| 4846 |
|
| 4847 |
} |
| 4848 |
|
| 4849 |
$expirationDate = $this->validExpirationDate(); |
| 4850 |
$expirationDateStatus = $expirationDate['expirationDateStatus']; |
| 4851 |
$expirationDateFrom = $expirationDate['expirationDateFrom']; |
| 4852 |
$expirationDateTo = $expirationDate['expirationDateTo']; |
| 4853 |
|
| 4854 |
global $wpdb; |
| 4855 |
$table_name = $wpdb->prefix . "booking_package_taxes"; |
| 4856 |
$wpdb->insert( |
| 4857 |
$table_name, |
| 4858 |
array( |
| 4859 |
'accountKey' => intval($accountKey), |
| 4860 |
'name' => sanitize_text_field($_POST['name']), |
| 4861 |
'ranking' => intval($_POST['rank']), |
| 4862 |
'active' => sanitize_text_field($_POST['active']), |
| 4863 |
'type' => sanitize_text_field($_POST['type']), |
| 4864 |
'tax' => sanitize_text_field($_POST['tax']), |
| 4865 |
'method' => sanitize_text_field($_POST['method']), |
| 4866 |
'target' => sanitize_text_field($_POST['target']), |
| 4867 |
'scope' => sanitize_text_field($_POST['scope']), |
| 4868 |
'value' => floatval($_POST['value']), |
| 4869 |
'expirationDateStatus' => intval($expirationDateStatus), |
| 4870 |
'expirationDateFrom' => intval($expirationDateFrom), |
| 4871 |
'expirationDateTo' => intval($expirationDateTo), |
| 4872 |
'generation' => intval(2), |
| 4873 |
), |
| 4874 |
array('%d', '%s', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%f', '%d', '%d', '%d', '%d') |
| 4875 |
); |
| 4876 |
|
| 4877 |
return $this->getTaxes($accountKey); |
| 4878 |
|
| 4879 |
} |
| 4880 |
|
| 4881 |
public function updateTax($accountKey) { |
| 4882 |
|
| 4883 |
$_POST['taxType'] = 'tax'; |
| 4884 |
$_POST['type'] = 'tax'; |
| 4885 |
return $this->updateTaxAndExtraCharge($accountKey, 'tax'); |
| 4886 |
|
| 4887 |
} |
| 4888 |
|
| 4889 |
public function updateExtraCharge($accountKey) { |
| 4890 |
|
| 4891 |
$_POST['taxType'] = 'surcharge'; |
| 4892 |
$_POST['type'] = 'surcharge'; |
| 4893 |
$_POST['method'] = 'addition'; |
| 4894 |
return $this->updateTaxAndExtraCharge($accountKey, 'extraChaarge'); |
| 4895 |
|
| 4896 |
} |
| 4897 |
|
| 4898 |
public function updateTaxAndExtraCharge($accountKey, $mode) { |
| 4899 |
|
| 4900 |
$expirationDate = $this->validExpirationDate(); |
| 4901 |
$expirationDateStatus = $expirationDate['expirationDateStatus']; |
| 4902 |
$expirationDateFrom = $expirationDate['expirationDateFrom']; |
| 4903 |
$expirationDateTo = $expirationDate['expirationDateTo']; |
| 4904 |
|
| 4905 |
if (!isset($_POST['active']) || strlen($_POST['active']) == 0) { |
| 4906 |
|
| 4907 |
$_POST['active'] = "false"; |
| 4908 |
|
| 4909 |
} |
| 4910 |
|
| 4911 |
global $wpdb; |
| 4912 |
$table_name = $wpdb->prefix . "booking_package_taxes"; |
| 4913 |
$sql = $wpdb->prepare( |
| 4914 |
"SELECT `key`, `generation` FROM ".$table_name." WHERE `accountKey` = %d AND `key` = %d;", |
| 4915 |
array(intval($accountKey), intval($_POST['key'])) |
| 4916 |
); |
| 4917 |
$row = $wpdb->get_row($sql, ARRAY_A); |
| 4918 |
$generation = intval($row['generation']); |
| 4919 |
if ($generation == 2) { |
| 4920 |
|
| 4921 |
if ($mode == 'tax') { |
| 4922 |
|
| 4923 |
|
| 4924 |
$_POST['scope'] = 'day'; |
| 4925 |
|
| 4926 |
} else if ($mode == 'extraChaarge') { |
| 4927 |
|
| 4928 |
$_POST['tax'] = 'tax_inclusive'; |
| 4929 |
|
| 4930 |
} |
| 4931 |
|
| 4932 |
} else { |
| 4933 |
|
| 4934 |
if ($_POST['type'] == 'surcharge') { |
| 4935 |
|
| 4936 |
$_POST['tax'] = 'tax_inclusive'; |
| 4937 |
|
| 4938 |
} |
| 4939 |
|
| 4940 |
} |
| 4941 |
|
| 4942 |
try { |
| 4943 |
|
| 4944 |
$wpdb->query("START TRANSACTION"); |
| 4945 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 4946 |
$wpdb->update( |
| 4947 |
$table_name, |
| 4948 |
array( |
| 4949 |
'name' => sanitize_text_field($_POST['name']), |
| 4950 |
'active' => sanitize_text_field($_POST['active']), |
| 4951 |
'type' => sanitize_text_field($_POST['type']), |
| 4952 |
'tax' => sanitize_text_field($_POST['tax']), |
| 4953 |
'method' => sanitize_text_field($_POST['method']), |
| 4954 |
'target' => sanitize_text_field($_POST['target']), |
| 4955 |
'scope' => sanitize_text_field($_POST['scope']), |
| 4956 |
'value' => floatval($_POST['value']), |
| 4957 |
'expirationDateStatus' => intval($expirationDateStatus), |
| 4958 |
'expirationDateFrom' => intval($expirationDateFrom), |
| 4959 |
'expirationDateTo' => intval($expirationDateTo), |
| 4960 |
), |
| 4961 |
array('key' => intval($_POST['key'])), |
| 4962 |
array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%f', '%d', '%d', '%d'), |
| 4963 |
array('%d') |
| 4964 |
); |
| 4965 |
|
| 4966 |
$wpdb->query('COMMIT'); |
| 4967 |
$wpdb->query('UNLOCK TABLES'); |
| 4968 |
|
| 4969 |
} catch (Exception $e) { |
| 4970 |
|
| 4971 |
$wpdb->query('ROLLBACK'); |
| 4972 |
$wpdb->query('UNLOCK TABLES'); |
| 4973 |
|
| 4974 |
}/** finally { |
| 4975 |
|
| 4976 |
$wpdb->query('UNLOCK TABLES'); |
| 4977 |
|
| 4978 |
}**/ |
| 4979 |
|
| 4980 |
return $this->getTaxes($accountKey); |
| 4981 |
|
| 4982 |
} |
| 4983 |
|
| 4984 |
public function deleteTax($accountKey) { |
| 4985 |
|
| 4986 |
$_POST['taxType'] = 'tax'; |
| 4987 |
return $this->deleteTaxAndExtraCharge($accountKey); |
| 4988 |
|
| 4989 |
} |
| 4990 |
|
| 4991 |
public function deleteExtraCharge($accountKey) { |
| 4992 |
|
| 4993 |
$_POST['taxType'] = 'surcharge'; |
| 4994 |
return $this->deleteTaxAndExtraCharge($accountKey); |
| 4995 |
|
| 4996 |
} |
| 4997 |
|
| 4998 |
public function deleteTaxAndExtraCharge($accountKey) { |
| 4999 |
|
| 5000 |
global $wpdb; |
| 5001 |
$table_name = $wpdb->prefix . "booking_package_taxes"; |
| 5002 |
$wpdb->delete($table_name, array('key' => intval($_POST['key'])), array('%d')); |
| 5003 |
return $this->getTaxes($accountKey); |
| 5004 |
|
| 5005 |
} |
| 5006 |
|
| 5007 |
public function addTaxes($accountKey) { |
| 5008 |
|
| 5009 |
if ($_POST['type'] == 'surcharge') { |
| 5010 |
|
| 5011 |
$_POST['tax'] = 'tax_inclusive'; |
| 5012 |
|
| 5013 |
} |
| 5014 |
|
| 5015 |
$expirationDate = $this->validExpirationDate(); |
| 5016 |
$expirationDateStatus = $expirationDate['expirationDateStatus']; |
| 5017 |
$expirationDateFrom = $expirationDate['expirationDateFrom']; |
| 5018 |
$expirationDateTo = $expirationDate['expirationDateTo']; |
| 5019 |
|
| 5020 |
global $wpdb; |
| 5021 |
$table_name = $wpdb->prefix."booking_package_taxes"; |
| 5022 |
$wpdb->insert( |
| 5023 |
$table_name, |
| 5024 |
array( |
| 5025 |
'accountKey' => intval($accountKey), |
| 5026 |
'name' => sanitize_text_field($_POST['name']), |
| 5027 |
'ranking' => intval($_POST['rank']), |
| 5028 |
'active' => sanitize_text_field($_POST['active']), |
| 5029 |
'type' => sanitize_text_field($_POST['type']), |
| 5030 |
'tax' => sanitize_text_field($_POST['tax']), |
| 5031 |
'method' => sanitize_text_field($_POST['method']), |
| 5032 |
'target' => sanitize_text_field($_POST['target']), |
| 5033 |
'scope' => sanitize_text_field($_POST['scope']), |
| 5034 |
'value' => floatval($_POST['value']), |
| 5035 |
'expirationDateStatus' => intval($expirationDateStatus), |
| 5036 |
'expirationDateFrom' => intval($expirationDateFrom), |
| 5037 |
'expirationDateTo' => intval($expirationDateTo), |
| 5038 |
), |
| 5039 |
array('%d', '%s', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%f', '%d', '%d', '%d') |
| 5040 |
); |
| 5041 |
|
| 5042 |
return $this->getTaxes($accountKey); |
| 5043 |
|
| 5044 |
} |
| 5045 |
|
| 5046 |
public function updateTaxes($accountKey) { |
| 5047 |
|
| 5048 |
$expirationDate = $this->validExpirationDate(); |
| 5049 |
$expirationDateStatus = $expirationDate['expirationDateStatus']; |
| 5050 |
$expirationDateFrom = $expirationDate['expirationDateFrom']; |
| 5051 |
$expirationDateTo = $expirationDate['expirationDateTo']; |
| 5052 |
|
| 5053 |
if (!isset($_POST['active']) || strlen($_POST['active']) == 0) { |
| 5054 |
|
| 5055 |
$_POST['active'] = "false"; |
| 5056 |
|
| 5057 |
} |
| 5058 |
|
| 5059 |
if ($_POST['type'] == 'surcharge') { |
| 5060 |
|
| 5061 |
$_POST['tax'] = 'tax_inclusive'; |
| 5062 |
|
| 5063 |
} |
| 5064 |
|
| 5065 |
global $wpdb; |
| 5066 |
$table_name = $wpdb->prefix . "booking_package_taxes"; |
| 5067 |
try { |
| 5068 |
|
| 5069 |
$wpdb->query("START TRANSACTION"); |
| 5070 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 5071 |
$wpdb->update( |
| 5072 |
$table_name, |
| 5073 |
array( |
| 5074 |
'name' => sanitize_text_field($_POST['name']), |
| 5075 |
'active' => sanitize_text_field($_POST['active']), |
| 5076 |
'type' => sanitize_text_field($_POST['type']), |
| 5077 |
'tax' => sanitize_text_field($_POST['tax']), |
| 5078 |
'method' => sanitize_text_field($_POST['method']), |
| 5079 |
'target' => sanitize_text_field($_POST['target']), |
| 5080 |
'scope' => sanitize_text_field($_POST['scope']), |
| 5081 |
'value' => floatval($_POST['value']), |
| 5082 |
'expirationDateStatus' => intval($expirationDateStatus), |
| 5083 |
'expirationDateFrom' => intval($expirationDateFrom), |
| 5084 |
'expirationDateTo' => intval($expirationDateTo), |
| 5085 |
), |
| 5086 |
array('key' => intval($_POST['key'])), |
| 5087 |
array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%f', '%d', '%d', '%d'), |
| 5088 |
array('%d') |
| 5089 |
); |
| 5090 |
|
| 5091 |
$wpdb->query('COMMIT'); |
| 5092 |
$wpdb->query('UNLOCK TABLES'); |
| 5093 |
|
| 5094 |
} catch (Exception $e) { |
| 5095 |
|
| 5096 |
$wpdb->query('ROLLBACK'); |
| 5097 |
$wpdb->query('UNLOCK TABLES'); |
| 5098 |
|
| 5099 |
}/** finally { |
| 5100 |
|
| 5101 |
$wpdb->query('UNLOCK TABLES'); |
| 5102 |
|
| 5103 |
}**/ |
| 5104 |
|
| 5105 |
|
| 5106 |
return $this->getTaxes($accountKey); |
| 5107 |
|
| 5108 |
} |
| 5109 |
|
| 5110 |
public function deleteTaxes($accountKey){ |
| 5111 |
|
| 5112 |
global $wpdb; |
| 5113 |
$table_name = $wpdb->prefix."booking_package_taxes"; |
| 5114 |
$wpdb->delete($table_name, array('key' => intval($_POST['key'])), array('%d')); |
| 5115 |
return $this->getTaxes($accountKey); |
| 5116 |
|
| 5117 |
} |
| 5118 |
|
| 5119 |
public function changeTaxesRank($accountKey){ |
| 5120 |
|
| 5121 |
$keyList = explode(",", $_POST['keyList']); |
| 5122 |
$indexList = explode(",", $_POST['indexList']); |
| 5123 |
|
| 5124 |
global $wpdb; |
| 5125 |
$table_name = $wpdb->prefix . "booking_package_taxes"; |
| 5126 |
try { |
| 5127 |
|
| 5128 |
$wpdb->query("START TRANSACTION"); |
| 5129 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 5130 |
for ($i = 0; $i < count($keyList); $i++) { |
| 5131 |
|
| 5132 |
$wpdb->update( |
| 5133 |
$table_name, |
| 5134 |
array('ranking' => intval($indexList[$i])), |
| 5135 |
array('key' => intval($keyList[$i])), |
| 5136 |
array('%d'), |
| 5137 |
array('%d') |
| 5138 |
); |
| 5139 |
|
| 5140 |
} |
| 5141 |
|
| 5142 |
$wpdb->query('COMMIT'); |
| 5143 |
$wpdb->query('UNLOCK TABLES'); |
| 5144 |
|
| 5145 |
} catch (Exception $e) { |
| 5146 |
|
| 5147 |
$wpdb->query('ROLLBACK'); |
| 5148 |
$wpdb->query('UNLOCK TABLES'); |
| 5149 |
|
| 5150 |
}/** finally { |
| 5151 |
|
| 5152 |
$wpdb->query('UNLOCK TABLES'); |
| 5153 |
|
| 5154 |
}**/ |
| 5155 |
|
| 5156 |
|
| 5157 |
return $this->getTaxes($accountKey); |
| 5158 |
|
| 5159 |
} |
| 5160 |
|
| 5161 |
public function getOptionsForHotel($accountKey, $active = false, $booking = false) { |
| 5162 |
|
| 5163 |
global $wpdb; |
| 5164 |
$table_name = $wpdb->prefix . "booking_package_hotel_options"; |
| 5165 |
$sql = $wpdb->prepare("SELECT * FROM " . $table_name . " WHERE `accountKey` = %d ORDER BY ranking ASC;", array(intval($accountKey))); |
| 5166 |
if ($active === true) { |
| 5167 |
|
| 5168 |
$sql = $wpdb->prepare("SELECT * FROM " . $table_name . " WHERE `accountKey` = %d AND `active` = 'true' ORDER BY ranking ASC;", array(intval($accountKey))); |
| 5169 |
|
| 5170 |
} |
| 5171 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 5172 |
$isExtensionsValid = $this->getExtensionsValid(); |
| 5173 |
if ($isExtensionsValid === false) { |
| 5174 |
|
| 5175 |
return array(); |
| 5176 |
|
| 5177 |
} else { |
| 5178 |
|
| 5179 |
if ($booking === true) { |
| 5180 |
|
| 5181 |
foreach ((array) $rows as $key => $value) { |
| 5182 |
|
| 5183 |
$value = $this->getTranslateOption($value, intval($accountKey)); |
| 5184 |
$list = json_decode($value['json'], true); |
| 5185 |
array_unshift($list, array("adult" => 0, "child" => 0, "room" => 0, "name" => __("Select", 'booking-package'))); |
| 5186 |
for ($i = 0; $i < count($list); $i++) { |
| 5187 |
|
| 5188 |
$list[$i]['index'] = $i; |
| 5189 |
|
| 5190 |
} |
| 5191 |
$value['json'] = json_encode($list); |
| 5192 |
$rows[$key] = $value; |
| 5193 |
|
| 5194 |
} |
| 5195 |
|
| 5196 |
} |
| 5197 |
|
| 5198 |
return $rows; |
| 5199 |
|
| 5200 |
} |
| 5201 |
|
| 5202 |
} |
| 5203 |
|
| 5204 |
public function addOptionsForHotel($accountKey) { |
| 5205 |
|
| 5206 |
if (!isset($_POST['active']) || strlen($_POST['active']) == 0) { |
| 5207 |
|
| 5208 |
$_POST['active'] = "false"; |
| 5209 |
|
| 5210 |
} |
| 5211 |
|
| 5212 |
$required = 0; |
| 5213 |
if ($_POST['required'] == 'true') { |
| 5214 |
|
| 5215 |
$required = 1; |
| 5216 |
|
| 5217 |
} |
| 5218 |
|
| 5219 |
$json = array(); |
| 5220 |
if (isset($_POST['json'])) { |
| 5221 |
|
| 5222 |
$jsonList = json_decode(stripslashes($_POST['json']), true); |
| 5223 |
for ($i = 0; $i < count($jsonList); $i++) { |
| 5224 |
|
| 5225 |
$object = array(); |
| 5226 |
foreach ((array) $jsonList[$i] as $key => $value) { |
| 5227 |
|
| 5228 |
if ($key == 'adult' || $key == 'child' || $key == 'room') { |
| 5229 |
|
| 5230 |
if (is_int($value) === false) { |
| 5231 |
|
| 5232 |
$value = $this->getOnlyNumbers($value); |
| 5233 |
|
| 5234 |
} |
| 5235 |
|
| 5236 |
} |
| 5237 |
|
| 5238 |
$object[sanitize_text_field($key)] = sanitize_text_field($value); |
| 5239 |
|
| 5240 |
} |
| 5241 |
array_push($json, $object); |
| 5242 |
|
| 5243 |
} |
| 5244 |
|
| 5245 |
} |
| 5246 |
|
| 5247 |
if ($this->getExtensionsValid() === false) { |
| 5248 |
|
| 5249 |
$_POST['active'] = "false"; |
| 5250 |
$json = array(); |
| 5251 |
|
| 5252 |
} |
| 5253 |
|
| 5254 |
global $wpdb; |
| 5255 |
$table_name = $wpdb->prefix . "booking_package_hotel_options"; |
| 5256 |
$wpdb->insert( |
| 5257 |
$table_name, |
| 5258 |
array( |
| 5259 |
'accountKey' => intval($accountKey), |
| 5260 |
'name' => sanitize_text_field($_POST['name']), |
| 5261 |
'ranking' => intval($_POST['rank']), |
| 5262 |
'active' => sanitize_text_field($_POST['active']), |
| 5263 |
'required' => intval($required), |
| 5264 |
'target' => sanitize_text_field($_POST['target']), |
| 5265 |
'range' => sanitize_text_field($_POST['range']), |
| 5266 |
'chargeForAdults' => floatval(0), |
| 5267 |
'chargeForChildren' => floatval(0), |
| 5268 |
'chargeForRoom' => floatval(0), |
| 5269 |
"description" => sanitize_textarea_field($_POST["description"]), |
| 5270 |
'json' => json_encode($json), |
| 5271 |
), |
| 5272 |
array('%d', '%s', '%d', '%s', '%d', '%s', '%s', '%f', '%f', '%f', '%s', '%s') |
| 5273 |
); |
| 5274 |
|
| 5275 |
return $this->getOptionsForHotel($accountKey); |
| 5276 |
|
| 5277 |
} |
| 5278 |
|
| 5279 |
public function updateOptionsForHotel($accountKey) { |
| 5280 |
|
| 5281 |
if (!isset($_POST['active']) || strlen($_POST['active']) == 0) { |
| 5282 |
|
| 5283 |
$_POST['active'] = "false"; |
| 5284 |
|
| 5285 |
} |
| 5286 |
|
| 5287 |
$required = 0; |
| 5288 |
if ($_POST['required'] == 'true') { |
| 5289 |
|
| 5290 |
$required = 1; |
| 5291 |
|
| 5292 |
} |
| 5293 |
|
| 5294 |
$json = array(); |
| 5295 |
if (isset($_POST['json'])) { |
| 5296 |
|
| 5297 |
$jsonList = json_decode(stripslashes($_POST['json']), true); |
| 5298 |
for ($i = 0; $i < count($jsonList); $i++) { |
| 5299 |
|
| 5300 |
$object = array(); |
| 5301 |
foreach ((array) $jsonList[$i] as $key => $value) { |
| 5302 |
|
| 5303 |
if ($key == 'adult' || $key == 'child' || $key == 'room') { |
| 5304 |
|
| 5305 |
if (is_int($value) === false) { |
| 5306 |
|
| 5307 |
$value = $this->getOnlyNumbers($value); |
| 5308 |
|
| 5309 |
} |
| 5310 |
|
| 5311 |
} |
| 5312 |
|
| 5313 |
$object[sanitize_text_field($key)] = sanitize_text_field($value); |
| 5314 |
|
| 5315 |
} |
| 5316 |
array_push($json, $object); |
| 5317 |
|
| 5318 |
} |
| 5319 |
|
| 5320 |
|
| 5321 |
|
| 5322 |
} |
| 5323 |
|
| 5324 |
if ($this->getExtensionsValid() === false) { |
| 5325 |
|
| 5326 |
$_POST['active'] = "false"; |
| 5327 |
$json = array(); |
| 5328 |
|
| 5329 |
} |
| 5330 |
|
| 5331 |
global $wpdb; |
| 5332 |
$table_name = $wpdb->prefix . "booking_package_hotel_options"; |
| 5333 |
try { |
| 5334 |
|
| 5335 |
$wpdb->query("START TRANSACTION"); |
| 5336 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 5337 |
$wpdb->update( |
| 5338 |
$table_name, |
| 5339 |
array( |
| 5340 |
'name' => sanitize_text_field($_POST['name']), |
| 5341 |
'active' => sanitize_text_field($_POST['active']), |
| 5342 |
'required' => intval($required), |
| 5343 |
'range' => sanitize_text_field($_POST['range']), |
| 5344 |
'chargeForAdults' => floatval(0), |
| 5345 |
'chargeForChildren' => floatval(0), |
| 5346 |
'chargeForRoom' => floatval(0), |
| 5347 |
"description" => sanitize_textarea_field($_POST["description"]), |
| 5348 |
'json' => json_encode($json), |
| 5349 |
), |
| 5350 |
array('key' => intval($_POST['key'])), |
| 5351 |
array('%s', '%s', '%d', '%s', '%f', '%f', '%f', '%s', '%s'), |
| 5352 |
array('%d') |
| 5353 |
); |
| 5354 |
|
| 5355 |
$wpdb->query('COMMIT'); |
| 5356 |
$wpdb->query('UNLOCK TABLES'); |
| 5357 |
|
| 5358 |
} catch (Exception $e) { |
| 5359 |
|
| 5360 |
$wpdb->query('ROLLBACK'); |
| 5361 |
$wpdb->query('UNLOCK TABLES'); |
| 5362 |
|
| 5363 |
}/** finally { |
| 5364 |
|
| 5365 |
$wpdb->query('UNLOCK TABLES'); |
| 5366 |
|
| 5367 |
}**/ |
| 5368 |
|
| 5369 |
|
| 5370 |
return $this->getOptionsForHotel($accountKey); |
| 5371 |
|
| 5372 |
} |
| 5373 |
|
| 5374 |
public function deleteOptionsForHotel($accountKey){ |
| 5375 |
|
| 5376 |
global $wpdb; |
| 5377 |
$table_name = $wpdb->prefix . "booking_package_hotel_options"; |
| 5378 |
$wpdb->delete($table_name, array('key' => intval($_POST['key'])), array('%d')); |
| 5379 |
return $this->getOptionsForHotel($accountKey); |
| 5380 |
|
| 5381 |
} |
| 5382 |
|
| 5383 |
public function changeOptionsForHotelRank($accountKey){ |
| 5384 |
|
| 5385 |
$keyList = explode(",", $_POST['keyList']); |
| 5386 |
$indexList = explode(",", $_POST['indexList']); |
| 5387 |
|
| 5388 |
global $wpdb; |
| 5389 |
$table_name = $wpdb->prefix . "booking_package_hotel_options"; |
| 5390 |
try { |
| 5391 |
|
| 5392 |
$wpdb->query("START TRANSACTION"); |
| 5393 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 5394 |
for ($i = 0; $i < count($keyList); $i++) { |
| 5395 |
|
| 5396 |
$wpdb->update( |
| 5397 |
$table_name, |
| 5398 |
array('ranking' => intval($indexList[$i])), |
| 5399 |
array('key' => intval($keyList[$i])), |
| 5400 |
array('%d'), |
| 5401 |
array('%d') |
| 5402 |
); |
| 5403 |
|
| 5404 |
} |
| 5405 |
|
| 5406 |
$wpdb->query('COMMIT'); |
| 5407 |
$wpdb->query('UNLOCK TABLES'); |
| 5408 |
|
| 5409 |
} catch (Exception $e) { |
| 5410 |
|
| 5411 |
$wpdb->query('ROLLBACK'); |
| 5412 |
$wpdb->query('UNLOCK TABLES'); |
| 5413 |
|
| 5414 |
}/** finally { |
| 5415 |
|
| 5416 |
$wpdb->query('UNLOCK TABLES'); |
| 5417 |
|
| 5418 |
}**/ |
| 5419 |
|
| 5420 |
return $this->getOptionsForHotel($accountKey); |
| 5421 |
|
| 5422 |
} |
| 5423 |
|
| 5424 |
public function changeCourseRank(){ |
| 5425 |
|
| 5426 |
$accountKey = 1; |
| 5427 |
if (isset($_POST['accountKey'])) { |
| 5428 |
|
| 5429 |
$accountKey = $_POST['accountKey']; |
| 5430 |
|
| 5431 |
} |
| 5432 |
|
| 5433 |
$keyList = explode(",", $_POST['keyList']); |
| 5434 |
$indexList = explode(",", $_POST['indexList']); |
| 5435 |
|
| 5436 |
global $wpdb; |
| 5437 |
$table_name = $wpdb->prefix . "booking_package_services"; |
| 5438 |
try { |
| 5439 |
|
| 5440 |
$wpdb->query("START TRANSACTION"); |
| 5441 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 5442 |
for ($i = 0; $i < count($keyList); $i++) { |
| 5443 |
|
| 5444 |
$wpdb->update( |
| 5445 |
$table_name, |
| 5446 |
array('ranking' => intval($indexList[$i])), |
| 5447 |
array('key' => intval($keyList[$i])), |
| 5448 |
array('%d'), |
| 5449 |
array('%d') |
| 5450 |
); |
| 5451 |
|
| 5452 |
} |
| 5453 |
|
| 5454 |
$wpdb->query('COMMIT'); |
| 5455 |
$wpdb->query('UNLOCK TABLES'); |
| 5456 |
|
| 5457 |
} catch (Exception $e) { |
| 5458 |
|
| 5459 |
$wpdb->query('ROLLBACK'); |
| 5460 |
$wpdb->query('UNLOCK TABLES'); |
| 5461 |
|
| 5462 |
}/** finally { |
| 5463 |
|
| 5464 |
$wpdb->query('UNLOCK TABLES'); |
| 5465 |
|
| 5466 |
}**/ |
| 5467 |
|
| 5468 |
$sql = $wpdb->prepare("SELECT * FROM " . $table_name . " WHERE `accountKey` = %d ORDER BY ranking ASC;", array(intval($accountKey))); |
| 5469 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 5470 |
return $rows; |
| 5471 |
|
| 5472 |
} |
| 5473 |
|
| 5474 |
public function addForm(){ |
| 5475 |
|
| 5476 |
$accountKey = 1; |
| 5477 |
if (isset($_POST['accountKey'])) { |
| 5478 |
|
| 5479 |
$accountKey = $_POST['accountKey']; |
| 5480 |
|
| 5481 |
} |
| 5482 |
|
| 5483 |
if (isset($_POST['isSMS']) === false) { |
| 5484 |
|
| 5485 |
$_POST['isSMS'] = 'false'; |
| 5486 |
|
| 5487 |
} |
| 5488 |
|
| 5489 |
global $wpdb; |
| 5490 |
$table_name = $wpdb->prefix . "booking_package_form"; |
| 5491 |
$sql = $wpdb->prepare("SELECT * FROM " . $table_name . " WHERE `accountKey` = %d;", array(intval($accountKey))); |
| 5492 |
$row = $wpdb->get_row($sql, ARRAY_A); |
| 5493 |
if (is_null($row)) { |
| 5494 |
|
| 5495 |
return array('status' => 'error'); |
| 5496 |
|
| 5497 |
} else { |
| 5498 |
|
| 5499 |
$id = strtolower($_POST['id']); |
| 5500 |
$id = preg_replace('/[^0-9a-zA-Z_-]/', '', $id); |
| 5501 |
$id = preg_replace("/^( )|( )$/", "", $id ); |
| 5502 |
#$options = str_replace("\\\"", "\"", sanitize_text_field($_POST['options'])); |
| 5503 |
#$options = str_replace("\'", "'", $options); |
| 5504 |
$options = stripslashes($_POST['options']); |
| 5505 |
$options = sanitize_text_field($options); |
| 5506 |
$options = json_decode($options, true); |
| 5507 |
if (is_null($options) || is_bool($options) === true) { |
| 5508 |
|
| 5509 |
$options = array(); |
| 5510 |
|
| 5511 |
} |
| 5512 |
|
| 5513 |
foreach ($options as $key => $value) { |
| 5514 |
|
| 5515 |
if (is_null($value) || empty($value) || $value == 'null') { |
| 5516 |
|
| 5517 |
unset($options[$key]); |
| 5518 |
|
| 5519 |
} |
| 5520 |
|
| 5521 |
} |
| 5522 |
|
| 5523 |
$options = array_values($options); |
| 5524 |
|
| 5525 |
$data = json_decode($row['data'], true); |
| 5526 |
foreach ((array) $data as $key => $value) { |
| 5527 |
|
| 5528 |
if ($value['id'] == $id) { |
| 5529 |
|
| 5530 |
return array("status" => "error", "message" => "An ID with the same name already exists in the form.", 'id' => $id); |
| 5531 |
|
| 5532 |
} |
| 5533 |
|
| 5534 |
} |
| 5535 |
|
| 5536 |
$item = array( |
| 5537 |
"id" => $id, |
| 5538 |
"name" => sanitize_text_field($_POST["name"]), |
| 5539 |
"description" => sanitize_textarea_field($_POST["description"]), |
| 5540 |
"value" => "", |
| 5541 |
"uri" => sanitize_textarea_field($_POST["uri"]), |
| 5542 |
"type" => sanitize_text_field($_POST["type"]), |
| 5543 |
"active" => sanitize_text_field($_POST["active"]), |
| 5544 |
"options" => $options, |
| 5545 |
"required" => sanitize_text_field($_POST["required"]), |
| 5546 |
"isName" => sanitize_text_field($_POST["isName"]), |
| 5547 |
"isEmail" => sanitize_text_field($_POST["isEmail"]), |
| 5548 |
"isSMS" => sanitize_text_field($_POST["isSMS"]), |
| 5549 |
"isAddress" => sanitize_text_field($_POST["isAddress"]), |
| 5550 |
"isTerms" => sanitize_text_field($_POST["isTerms"]), |
| 5551 |
"isAutocomplete" => sanitize_text_field($_POST["isAutocomplete"]), |
| 5552 |
"placeholder" => sanitize_text_field($_POST["placeholder"]), |
| 5553 |
); |
| 5554 |
|
| 5555 |
if (isset($_POST['targetCustomers'])) { |
| 5556 |
|
| 5557 |
$item['targetCustomers'] = sanitize_text_field($_POST["targetCustomers"]); |
| 5558 |
|
| 5559 |
} |
| 5560 |
|
| 5561 |
array_push($data, $item); |
| 5562 |
$json = json_encode($data); |
| 5563 |
if (defined('JSON_NUMERIC_CHECK')) { |
| 5564 |
|
| 5565 |
$json = json_encode($data, JSON_NUMERIC_CHECK); |
| 5566 |
|
| 5567 |
} |
| 5568 |
|
| 5569 |
try { |
| 5570 |
|
| 5571 |
$wpdb->query("START TRANSACTION"); |
| 5572 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 5573 |
$wpdb->update( |
| 5574 |
$table_name, |
| 5575 |
array('data' => $json), |
| 5576 |
array('key' => intval($row['key'])), |
| 5577 |
array('%s'), |
| 5578 |
array('%d') |
| 5579 |
); |
| 5580 |
|
| 5581 |
$wpdb->query('COMMIT'); |
| 5582 |
$wpdb->query('UNLOCK TABLES'); |
| 5583 |
|
| 5584 |
} catch (Exception $e) { |
| 5585 |
|
| 5586 |
$wpdb->query('ROLLBACK'); |
| 5587 |
$wpdb->query('UNLOCK TABLES'); |
| 5588 |
|
| 5589 |
}/** finally { |
| 5590 |
|
| 5591 |
$wpdb->query('UNLOCK TABLES'); |
| 5592 |
|
| 5593 |
}**/ |
| 5594 |
|
| 5595 |
|
| 5596 |
#return $data; |
| 5597 |
return $this->getForm($accountKey, false); |
| 5598 |
|
| 5599 |
} |
| 5600 |
|
| 5601 |
} |
| 5602 |
|
| 5603 |
public function updateForm(){ |
| 5604 |
|
| 5605 |
$accountKey = 1; |
| 5606 |
if (isset($_POST['accountKey'])) { |
| 5607 |
|
| 5608 |
$accountKey = $_POST['accountKey']; |
| 5609 |
|
| 5610 |
} |
| 5611 |
|
| 5612 |
if (isset($_POST['isSMS']) === false) { |
| 5613 |
|
| 5614 |
$_POST['isSMS'] = 'false'; |
| 5615 |
|
| 5616 |
} |
| 5617 |
|
| 5618 |
global $wpdb; |
| 5619 |
$table_name = $wpdb->prefix . "booking_package_form"; |
| 5620 |
$sql = $wpdb->prepare("SELECT * FROM " . $table_name . " WHERE `accountKey` = %d;", array(intval($accountKey))); |
| 5621 |
$row = $wpdb->get_row($sql, ARRAY_A); |
| 5622 |
if (is_null($row)) { |
| 5623 |
|
| 5624 |
return array('status' => 'error'); |
| 5625 |
|
| 5626 |
} else { |
| 5627 |
|
| 5628 |
$id = strtolower($_POST['id']); |
| 5629 |
$id = preg_replace('/[^0-9a-zA-Z_-]/', '', $id); |
| 5630 |
$id = preg_replace("/^( )|( )$/", "", $id ); |
| 5631 |
$input = array(); |
| 5632 |
#$options = str_replace("\\\"", "\"", sanitize_text_field($_POST['options'])); |
| 5633 |
#$options = str_replace("\'", "'", $options); |
| 5634 |
$options = stripslashes($_POST['options']); |
| 5635 |
$options = sanitize_text_field($options); |
| 5636 |
$options = json_decode($options, true); |
| 5637 |
if (is_null($options) || is_bool($options) === true) { |
| 5638 |
|
| 5639 |
$options = array(); |
| 5640 |
|
| 5641 |
} |
| 5642 |
|
| 5643 |
foreach ($options as $key => $value) { |
| 5644 |
|
| 5645 |
if (is_null($value) || empty($value) || $value == 'null') { |
| 5646 |
|
| 5647 |
unset($options[$key]); |
| 5648 |
|
| 5649 |
} |
| 5650 |
|
| 5651 |
} |
| 5652 |
|
| 5653 |
$options = array_values($options); |
| 5654 |
|
| 5655 |
$data = json_decode($row['data']); |
| 5656 |
#for($i = 0; $i < count($data); $i++){ |
| 5657 |
foreach ((array) $data as $i => $value) { |
| 5658 |
|
| 5659 |
if (intval($i) == intval($_POST['key']) && $value->id == $id) { |
| 5660 |
|
| 5661 |
$value->name = sanitize_text_field($_POST['name']); |
| 5662 |
$value->description = sanitize_textarea_field($_POST['description']); |
| 5663 |
$value->uri = sanitize_text_field($_POST['uri']); |
| 5664 |
$value->active = sanitize_text_field($_POST['active']); |
| 5665 |
$value->type = sanitize_text_field($_POST['type']); |
| 5666 |
$value->options = $options; |
| 5667 |
$value->required = sanitize_text_field($_POST['required']); |
| 5668 |
$value->isName = sanitize_text_field($_POST['isName']); |
| 5669 |
$value->isAddress = sanitize_text_field($_POST['isAddress']); |
| 5670 |
$value->isEmail = sanitize_text_field($_POST['isEmail']); |
| 5671 |
$value->isSMS = sanitize_text_field($_POST['isSMS']); |
| 5672 |
$value->isTerms = sanitize_text_field($_POST['isTerms']); |
| 5673 |
$value->isAutocomplete = sanitize_text_field($_POST['isAutocomplete']); |
| 5674 |
$value->placeholder = sanitize_text_field($_POST["placeholder"]); |
| 5675 |
if (isset($_POST['targetCustomers'])) { |
| 5676 |
|
| 5677 |
$value->targetCustomers = sanitize_text_field($_POST['targetCustomers']); |
| 5678 |
|
| 5679 |
} |
| 5680 |
#break; |
| 5681 |
|
| 5682 |
} |
| 5683 |
|
| 5684 |
array_push($input, $value); |
| 5685 |
|
| 5686 |
} |
| 5687 |
|
| 5688 |
$json = json_encode($input); |
| 5689 |
if (defined('JSON_NUMERIC_CHECK')) { |
| 5690 |
|
| 5691 |
$json = json_encode($input, JSON_NUMERIC_CHECK); |
| 5692 |
|
| 5693 |
} |
| 5694 |
|
| 5695 |
try { |
| 5696 |
|
| 5697 |
$wpdb->query("START TRANSACTION"); |
| 5698 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 5699 |
$wpdb->update( |
| 5700 |
$table_name, |
| 5701 |
array('data' => $json), |
| 5702 |
array('key' => intval($row['key'])), |
| 5703 |
array('%s'), |
| 5704 |
array('%d') |
| 5705 |
); |
| 5706 |
|
| 5707 |
$wpdb->query('COMMIT'); |
| 5708 |
$wpdb->query('UNLOCK TABLES'); |
| 5709 |
|
| 5710 |
} catch (Exception $e) { |
| 5711 |
|
| 5712 |
$wpdb->query('ROLLBACK'); |
| 5713 |
$wpdb->query('UNLOCK TABLES'); |
| 5714 |
|
| 5715 |
}/** finally { |
| 5716 |
|
| 5717 |
$wpdb->query('UNLOCK TABLES'); |
| 5718 |
|
| 5719 |
}**/ |
| 5720 |
|
| 5721 |
return $this->getForm($accountKey, false); |
| 5722 |
|
| 5723 |
} |
| 5724 |
|
| 5725 |
|
| 5726 |
} |
| 5727 |
|
| 5728 |
public function deleteFormItem(){ |
| 5729 |
|
| 5730 |
$accountKey = 1; |
| 5731 |
if (isset($_POST['accountKey'])) { |
| 5732 |
|
| 5733 |
$accountKey = $_POST['accountKey']; |
| 5734 |
|
| 5735 |
} |
| 5736 |
|
| 5737 |
global $wpdb; |
| 5738 |
$table_name = $wpdb->prefix."booking_package_form"; |
| 5739 |
$sql = $wpdb->prepare("SELECT * FROM ".$table_name." WHERE `accountKey` = %d;", array(intval($accountKey))); |
| 5740 |
$row = $wpdb->get_row($sql, ARRAY_A); |
| 5741 |
if (is_null($row)) { |
| 5742 |
|
| 5743 |
return array('status' => 'error'); |
| 5744 |
|
| 5745 |
} else { |
| 5746 |
|
| 5747 |
$data = json_decode($row['data']); |
| 5748 |
array_splice($data, intval($_POST['key']), 1); |
| 5749 |
$json = json_encode($data); |
| 5750 |
if (defined('JSON_NUMERIC_CHECK')) { |
| 5751 |
|
| 5752 |
$json = json_encode($data, JSON_NUMERIC_CHECK); |
| 5753 |
|
| 5754 |
} |
| 5755 |
|
| 5756 |
try { |
| 5757 |
|
| 5758 |
$wpdb->query("START TRANSACTION"); |
| 5759 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 5760 |
$wpdb->update( |
| 5761 |
$table_name, |
| 5762 |
array('data' => $json), |
| 5763 |
array('key' => intval($row['key'])), |
| 5764 |
array('%s'), |
| 5765 |
array('%d') |
| 5766 |
); |
| 5767 |
|
| 5768 |
$wpdb->query('COMMIT'); |
| 5769 |
$wpdb->query('UNLOCK TABLES'); |
| 5770 |
|
| 5771 |
} catch (Exception $e) { |
| 5772 |
|
| 5773 |
$wpdb->query('ROLLBACK'); |
| 5774 |
$wpdb->query('UNLOCK TABLES'); |
| 5775 |
|
| 5776 |
}/** finally { |
| 5777 |
|
| 5778 |
$wpdb->query('UNLOCK TABLES'); |
| 5779 |
|
| 5780 |
}**/ |
| 5781 |
|
| 5782 |
return $this->getForm($accountKey, false); |
| 5783 |
|
| 5784 |
} |
| 5785 |
|
| 5786 |
} |
| 5787 |
|
| 5788 |
public function changeFormRank(){ |
| 5789 |
|
| 5790 |
$accountKey = 1; |
| 5791 |
if (isset($_POST['accountKey'])) { |
| 5792 |
|
| 5793 |
$accountKey = $_POST['accountKey']; |
| 5794 |
|
| 5795 |
} |
| 5796 |
|
| 5797 |
$keyList = explode(",", $_POST['keyList']); |
| 5798 |
$indexList = explode(",", $_POST['indexList']); |
| 5799 |
|
| 5800 |
global $wpdb; |
| 5801 |
$table_name = $wpdb->prefix . "booking_package_form"; |
| 5802 |
$sql = $wpdb->prepare("SELECT * FROM " . $table_name . " WHERE `accountKey` = %d;", array(intval($accountKey))); |
| 5803 |
$row = $wpdb->get_row($sql, ARRAY_A); |
| 5804 |
if (is_null($row)) { |
| 5805 |
|
| 5806 |
return array('status' => 'error'); |
| 5807 |
|
| 5808 |
} else { |
| 5809 |
|
| 5810 |
$newData = array(); |
| 5811 |
$data = json_decode($row['data']); |
| 5812 |
foreach ((array) $data as $key => $value) { |
| 5813 |
|
| 5814 |
$search = array_search($value->name, $keyList); |
| 5815 |
$index = intval($indexList[$search]); |
| 5816 |
$newData[$index] = $value; |
| 5817 |
|
| 5818 |
} |
| 5819 |
|
| 5820 |
ksort($newData); |
| 5821 |
$json = json_encode($newData); |
| 5822 |
if (defined('JSON_NUMERIC_CHECK')) { |
| 5823 |
|
| 5824 |
$json = json_encode($newData, JSON_NUMERIC_CHECK); |
| 5825 |
|
| 5826 |
} |
| 5827 |
|
| 5828 |
try { |
| 5829 |
|
| 5830 |
$wpdb->query("START TRANSACTION"); |
| 5831 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 5832 |
$wpdb->update( |
| 5833 |
$table_name, |
| 5834 |
array('data' => $json), |
| 5835 |
array('key' => intval($row['key'])), |
| 5836 |
array('%s'), |
| 5837 |
array('%d') |
| 5838 |
); |
| 5839 |
|
| 5840 |
$wpdb->query('COMMIT'); |
| 5841 |
$wpdb->query('UNLOCK TABLES'); |
| 5842 |
|
| 5843 |
} catch (Exception $e) { |
| 5844 |
|
| 5845 |
$wpdb->query('ROLLBACK'); |
| 5846 |
$wpdb->query('UNLOCK TABLES'); |
| 5847 |
|
| 5848 |
}/** finally { |
| 5849 |
|
| 5850 |
$wpdb->query('UNLOCK TABLES'); |
| 5851 |
|
| 5852 |
}**/ |
| 5853 |
|
| 5854 |
|
| 5855 |
return $newData; |
| 5856 |
|
| 5857 |
} |
| 5858 |
|
| 5859 |
|
| 5860 |
} |
| 5861 |
|
| 5862 |
public function getCss($fileName, $plugin_dir_path) { |
| 5863 |
|
| 5864 |
if (get_option('_' . $this->pluginName . '_css_v') === false) { |
| 5865 |
|
| 5866 |
add_option('_' . $this->pluginName . '_css_v', date('U')); |
| 5867 |
|
| 5868 |
} |
| 5869 |
|
| 5870 |
$upload_dir = wp_upload_dir(); |
| 5871 |
$dirname = $upload_dir['basedir'] . '/' . $this->pluginName; |
| 5872 |
/** |
| 5873 |
if (function_exists('get_sites') && class_exists('WP_Site_Query')) { |
| 5874 |
|
| 5875 |
$id = get_current_blog_id(); |
| 5876 |
$dirname .= '/' . $id; |
| 5877 |
|
| 5878 |
} |
| 5879 |
**/ |
| 5880 |
$css = ""; |
| 5881 |
if (!file_exists($dirname)) { |
| 5882 |
|
| 5883 |
#wp_mkdir_p($dirname); |
| 5884 |
if (wp_mkdir_p($dirname) === true) { |
| 5885 |
|
| 5886 |
$css = file_get_contents($plugin_dir_path . 'css/front_end.css'); |
| 5887 |
file_put_contents($dirname . '/' . $fileName, $css); |
| 5888 |
|
| 5889 |
} else { |
| 5890 |
|
| 5891 |
$css = "There is a problem with directory permissions on wp-content or wp-content/uploads."; |
| 5892 |
|
| 5893 |
} |
| 5894 |
|
| 5895 |
} else { |
| 5896 |
|
| 5897 |
if (file_exists($dirname . '/' . $fileName)) { |
| 5898 |
|
| 5899 |
$css = file_get_contents($dirname . '/' . $fileName); |
| 5900 |
|
| 5901 |
} else { |
| 5902 |
|
| 5903 |
if (wp_mkdir_p($dirname) === true) { |
| 5904 |
|
| 5905 |
$css = file_get_contents($plugin_dir_path . 'css/front_end.css'); |
| 5906 |
file_put_contents($dirname . '/' . $fileName, $css); |
| 5907 |
|
| 5908 |
} else { |
| 5909 |
|
| 5910 |
$css = "There is a problem with directory permissions on wp-content or wp-content/uploads."; |
| 5911 |
|
| 5912 |
} |
| 5913 |
|
| 5914 |
} |
| 5915 |
|
| 5916 |
|
| 5917 |
} |
| 5918 |
|
| 5919 |
return $css; |
| 5920 |
|
| 5921 |
} |
| 5922 |
|
| 5923 |
public function getCssUrl($fileName) { |
| 5924 |
|
| 5925 |
$upload_dir = wp_upload_dir(); |
| 5926 |
$dirname = $upload_dir['baseurl'] . '/' . $this->pluginName; |
| 5927 |
$parseUrl = parse_url($dirname); |
| 5928 |
if ($parseUrl['scheme'] == 'https') { |
| 5929 |
|
| 5930 |
$dirname = str_replace('https://', '//', $dirname); |
| 5931 |
|
| 5932 |
} else if ($parseUrl['scheme'] == 'http') { |
| 5933 |
|
| 5934 |
$dirname = str_replace('http://', '//', $dirname); |
| 5935 |
|
| 5936 |
} |
| 5937 |
|
| 5938 |
/** |
| 5939 |
if (function_exists('get_sites') && class_exists('WP_Site_Query')) { |
| 5940 |
|
| 5941 |
$id = get_current_blog_id(); |
| 5942 |
$dirname .= '/' . $id . '/' . $fileName; |
| 5943 |
|
| 5944 |
} else { |
| 5945 |
|
| 5946 |
$dirname .= '/' . $fileName; |
| 5947 |
|
| 5948 |
} |
| 5949 |
**/ |
| 5950 |
$dirname .= '/' . $fileName; |
| 5951 |
return array('dirname' => $dirname, 'v' => get_option('_' . $this->pluginName . '_css_v')); |
| 5952 |
|
| 5953 |
} |
| 5954 |
|
| 5955 |
public function updateCss($fileName) { |
| 5956 |
|
| 5957 |
update_option('_' . $this->pluginName . '_css_v', date('U')); |
| 5958 |
$upload_dir = wp_upload_dir(); |
| 5959 |
$dirname = $upload_dir['basedir'] . '/' . $this->pluginName; |
| 5960 |
|
| 5961 |
/** |
| 5962 |
if (function_exists('get_sites') && class_exists('WP_Site_Query')) { |
| 5963 |
|
| 5964 |
$id = get_current_blog_id(); |
| 5965 |
$dirname .= '/' . $id; |
| 5966 |
|
| 5967 |
} |
| 5968 |
**/ |
| 5969 |
#$value = str_replace("\\\"", "\"", $_POST['value']); |
| 5970 |
#$value = str_replace("\'", "'", $value); |
| 5971 |
$value = stripslashes($_POST['value']); |
| 5972 |
file_put_contents($dirname . '/' . $fileName, $value); |
| 5973 |
return array("status" => "success"); |
| 5974 |
|
| 5975 |
} |
| 5976 |
|
| 5977 |
public function getJavaScript($fileName, $plugin_dir_path) { |
| 5978 |
|
| 5979 |
if (get_option('_' . $this->pluginName . '_javascript_v') === false) { |
| 5980 |
|
| 5981 |
add_option('_' . $this->pluginName . '_javascript_v', date('U')); |
| 5982 |
|
| 5983 |
} |
| 5984 |
|
| 5985 |
$upload_dir = wp_upload_dir(); |
| 5986 |
$dirname = $upload_dir['basedir'] . '/' . $this->pluginName; |
| 5987 |
$javascript = ""; |
| 5988 |
if (!file_exists($dirname)) { |
| 5989 |
|
| 5990 |
if (wp_mkdir_p($dirname) === true) { |
| 5991 |
|
| 5992 |
$javascript = file_get_contents($plugin_dir_path . 'js/front_end.js'); |
| 5993 |
file_put_contents($dirname . '/' . $fileName, $javascript); |
| 5994 |
|
| 5995 |
} else { |
| 5996 |
|
| 5997 |
$javascript = "//There is a problem with directory permissions on wp-content or wp-content/uploads."; |
| 5998 |
|
| 5999 |
} |
| 6000 |
|
| 6001 |
} else { |
| 6002 |
|
| 6003 |
if (file_exists($dirname . '/' . $fileName)) { |
| 6004 |
|
| 6005 |
$javascript = file_get_contents($dirname . '/' . $fileName); |
| 6006 |
|
| 6007 |
} else { |
| 6008 |
|
| 6009 |
if (wp_mkdir_p($dirname) === true) { |
| 6010 |
|
| 6011 |
$javascript = file_get_contents($plugin_dir_path . 'js/front_end.js'); |
| 6012 |
file_put_contents($dirname . '/' . $fileName, $javascript); |
| 6013 |
|
| 6014 |
} else { |
| 6015 |
|
| 6016 |
$javascript = "//There is a problem with directory permissions on wp-content or wp-content/uploads."; |
| 6017 |
|
| 6018 |
} |
| 6019 |
|
| 6020 |
} |
| 6021 |
|
| 6022 |
} |
| 6023 |
|
| 6024 |
return $javascript; |
| 6025 |
|
| 6026 |
} |
| 6027 |
|
| 6028 |
public function getJavaScriptUrl($fileName) { |
| 6029 |
|
| 6030 |
$upload_dir = wp_upload_dir(); |
| 6031 |
$dirname = $upload_dir['baseurl'] . '/' . $this->pluginName; |
| 6032 |
$parseUrl = parse_url($dirname); |
| 6033 |
if ($parseUrl['scheme'] == 'https') { |
| 6034 |
|
| 6035 |
$dirname = str_replace('https://', '//', $dirname); |
| 6036 |
|
| 6037 |
} else if ($parseUrl['scheme'] == 'http') { |
| 6038 |
|
| 6039 |
$dirname = str_replace('http://', '//', $dirname); |
| 6040 |
|
| 6041 |
} |
| 6042 |
$dirname .= '/' . $fileName; |
| 6043 |
return array('dirname' => $dirname, 'v' => get_option('_' . $this->pluginName . '_javascript_v')); |
| 6044 |
|
| 6045 |
} |
| 6046 |
|
| 6047 |
public function updateJavaScript($fileName) { |
| 6048 |
|
| 6049 |
update_option('_' . $this->pluginName . '_javascript_v', date('U')); |
| 6050 |
$upload_dir = wp_upload_dir(); |
| 6051 |
$dirname = $upload_dir['basedir'] . '/' . $this->pluginName; |
| 6052 |
$value = $_POST['value']; |
| 6053 |
#$value = str_replace("\\\\", "\\", $value); |
| 6054 |
#$value = str_replace("\\\"", "\"", $value); |
| 6055 |
#$value = str_replace("\'", "'", $value); |
| 6056 |
$value = stripslashes($value); |
| 6057 |
file_put_contents($dirname . '/' . $fileName, $value); |
| 6058 |
return array("status" => "success", 'value' => $value); |
| 6059 |
|
| 6060 |
} |
| 6061 |
|
| 6062 |
public function updataEmailMessageForUser() { |
| 6063 |
|
| 6064 |
$id = sanitize_text_field($_POST['id']); |
| 6065 |
$object = get_option($id, null); |
| 6066 |
if (is_null($object) === false) { |
| 6067 |
|
| 6068 |
$object = json_decode($object, true); |
| 6069 |
$object['subject'] = sanitize_text_field($_POST['subject']); |
| 6070 |
$object['content'] = sanitize_textarea_field(htmlspecialchars($_POST['content'], ENT_QUOTES|ENT_HTML5)); |
| 6071 |
$object['subjectForAdmin'] = sanitize_text_field($_POST['subjectForAdmin']); |
| 6072 |
$object['contentForAdmin'] = sanitize_textarea_field(htmlspecialchars($_POST['contentForAdmin'], ENT_QUOTES|ENT_HTML5)); |
| 6073 |
$object['enable'] = intval($_POST['enableEmail']); |
| 6074 |
$object['enableSMS'] = 0; |
| 6075 |
$object['format'] = sanitize_text_field($_POST['format']); |
| 6076 |
$object['notifyAdministrator'] = intval($_POST['notifyAdministrator']); |
| 6077 |
update_option($id, json_encode($object)); |
| 6078 |
|
| 6079 |
} |
| 6080 |
|
| 6081 |
return $this->getEmailForUser(); |
| 6082 |
|
| 6083 |
} |
| 6084 |
|
| 6085 |
public function updateEmailId() { |
| 6086 |
global $wpdb; |
| 6087 |
$table_name = $wpdb->prefix . "booking_package_email_settings"; |
| 6088 |
$update_completed = get_option('_' . $this->prefix . 'updated_email_id', 0); |
| 6089 |
if (intval($update_completed) === 0) { |
| 6090 |
|
| 6091 |
$ids = array( |
| 6092 |
'mail_new_admin' => 'new_booking_notification', |
| 6093 |
'mail_approved' => 'booking_approved_notification', |
| 6094 |
'mail_pending' => 'booking_pending_notification', |
| 6095 |
'mail_reminder' => 'booking_reminder_notification', |
| 6096 |
'mail_updated' => 'booking_updated_notification', |
| 6097 |
'mail_canceled_by_visitor_user' => 'booking_cancellation_notification', |
| 6098 |
'mail_deleted' => 'booking_deleted_notification', |
| 6099 |
); |
| 6100 |
|
| 6101 |
|
| 6102 |
$wpdb->query("START TRANSACTION"); |
| 6103 |
|
| 6104 |
try { |
| 6105 |
|
| 6106 |
$params = []; |
| 6107 |
|
| 6108 |
$case_sql = "UPDATE `{$table_name}` SET `mail_id` = CASE `mail_id` "; |
| 6109 |
foreach ($ids as $old_id => $new_id) { |
| 6110 |
$case_sql .= "WHEN %s THEN %s "; |
| 6111 |
$params[] = $old_id; |
| 6112 |
$params[] = $new_id; |
| 6113 |
} |
| 6114 |
$case_sql .= "END"; |
| 6115 |
|
| 6116 |
$where_in_placeholders = implode(', ', array_fill(0, count($ids), '%s')); |
| 6117 |
$sql_template = $case_sql . " WHERE `mail_id` IN (" . $where_in_placeholders . ")"; |
| 6118 |
|
| 6119 |
$final_params = array_merge($params, array_keys($ids)); |
| 6120 |
$final_sql = $wpdb->prepare($sql_template, $final_params); |
| 6121 |
#var_dump($final_sql); |
| 6122 |
$result = $wpdb->query($final_sql); |
| 6123 |
|
| 6124 |
if (false === $result) { |
| 6125 |
throw new Exception('Database update failed.'); |
| 6126 |
} |
| 6127 |
|
| 6128 |
$wpdb->query("COMMIT"); |
| 6129 |
update_option('_' . $this->prefix . 'updated_email_id', 1); |
| 6130 |
return true; |
| 6131 |
|
| 6132 |
} catch (Exception $e) { |
| 6133 |
|
| 6134 |
$wpdb->query("ROLLBACK"); |
| 6135 |
error_log($e->getMessage()); |
| 6136 |
|
| 6137 |
} /** finally { |
| 6138 |
|
| 6139 |
$wpdb->query('UNLOCK TABLES'); |
| 6140 |
|
| 6141 |
}**/ |
| 6142 |
|
| 6143 |
} else { |
| 6144 |
|
| 6145 |
$update_completed = get_option('_' . $this->prefix . 'updated_email_cancellation_id', 0); |
| 6146 |
if (intval($update_completed) === 0) { |
| 6147 |
|
| 6148 |
$sql = $wpdb->prepare( |
| 6149 |
"SELECT * FROM `" . $table_name . "` WHERE `mail_id` = %s AND `enable` = %d AND `enableSMS` = %d ORDER BY `accountKey` ASC;", |
| 6150 |
array('booking_cancellation_notification', 0, 0) |
| 6151 |
); |
| 6152 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 6153 |
$booking_cancellation_notifications = array(); |
| 6154 |
foreach ($rows as $key => $data) { |
| 6155 |
|
| 6156 |
$booking_cancellation_notifications[$data['accountKey']] = $data; |
| 6157 |
|
| 6158 |
} |
| 6159 |
|
| 6160 |
$sql = $wpdb->prepare( |
| 6161 |
"SELECT * FROM `" . $table_name . "` WHERE `mail_id` = %s AND (`enable` = %d OR `enableSMS` = %d) ORDER BY `accountKey` ASC;", |
| 6162 |
array('mail_canceled_by_visitor_user', 1, 1) |
| 6163 |
); |
| 6164 |
$rows = $wpdb->get_results($sql, ARRAY_A); |
| 6165 |
foreach ($rows as $key => $mail_canceled) { |
| 6166 |
|
| 6167 |
if (isset($booking_cancellation_notifications[ $mail_canceled['accountKey'] ])) { |
| 6168 |
|
| 6169 |
#$sql = $wpdb->prepare("DELETE FROM `" . $table_name . "` WHERE `key` = %d;", array( intval($booking_cancellation_notifications[ $mail_canceled['accountKey'] ]['key']) ) ); |
| 6170 |
#echo $sql . "<br>\n"; |
| 6171 |
#$wpdb->query($sql); |
| 6172 |
|
| 6173 |
$key_to_delete = intval($booking_cancellation_notifications[$mail_canceled['accountKey']]['key']); |
| 6174 |
$wpdb->delete($table_name, array('key' => $key_to_delete), array('%d')); |
| 6175 |
|
| 6176 |
} |
| 6177 |
|
| 6178 |
$sql = $wpdb->prepare("SELECT * FROM `" . $table_name . "` WHERE `mail_id` = %s AND `accountKey` = %d;", array('booking_cancellation_notification', intval($mail_canceled['accountKey']) ) ); |
| 6179 |
$row = $wpdb->get_var($sql); |
| 6180 |
if (empty($row)) { |
| 6181 |
|
| 6182 |
#$sql = $wpdb->prepare("UPDATE `" . $table_name . "` SET `mail_id` = 'booking_cancellation_notification' WHERE `key` = %d;", array(intval($mail_canceled['key']))); |
| 6183 |
#echo $sql . "<br>\n"; |
| 6184 |
#$wpdb->query($sql); |
| 6185 |
|
| 6186 |
$wpdb->update( |
| 6187 |
$table_name, |
| 6188 |
array('mail_id' => 'booking_cancellation_notification'), |
| 6189 |
array('key' => intval($mail_canceled['key'])), |
| 6190 |
array('%s'), |
| 6191 |
array('%d') |
| 6192 |
); |
| 6193 |
|
| 6194 |
} |
| 6195 |
|
| 6196 |
} |
| 6197 |
|
| 6198 |
update_option('_' . $this->prefix . 'updated_email_cancellation_id', 1); |
| 6199 |
return true; |
| 6200 |
|
| 6201 |
} |
| 6202 |
|
| 6203 |
} |
| 6204 |
|
| 6205 |
|
| 6206 |
} |
| 6207 |
|
| 6208 |
public function updataEmailMessageForCalendarAccount(){ |
| 6209 |
|
| 6210 |
$accountKey = intval($_POST['accountKey']); |
| 6211 |
$mail_id = sanitize_text_field($_POST['mail_id']); |
| 6212 |
|
| 6213 |
$subject = sanitize_text_field($_POST['subject']); |
| 6214 |
$content = sanitize_textarea_field(htmlspecialchars($_POST['content'], ENT_QUOTES|ENT_HTML5)); |
| 6215 |
|
| 6216 |
$subjectForAdmin = sanitize_text_field($_POST['subjectForAdmin']); |
| 6217 |
$contentForAdmin = sanitize_textarea_field(htmlspecialchars($_POST['contentForAdmin'], ENT_QUOTES|ENT_HTML5)); |
| 6218 |
|
| 6219 |
$subjectForIcalendar = sanitize_text_field($_POST['subjectForIcalendar']); |
| 6220 |
$locationForIcalendar = sanitize_text_field($_POST['locationForIcalendar']); |
| 6221 |
$contentForIcalendar = sanitize_textarea_field(htmlspecialchars($_POST['contentForIcalendar'], ENT_QUOTES|ENT_HTML5)); |
| 6222 |
|
| 6223 |
$enable = intval($_POST['enableEmail']); |
| 6224 |
$enableSMS = intval($_POST['enableSms']); |
| 6225 |
$format = sanitize_text_field($_POST['format']); |
| 6226 |
|
| 6227 |
global $wpdb; |
| 6228 |
$table_name = $wpdb->prefix . "booking_package_email_settings"; |
| 6229 |
try { |
| 6230 |
|
| 6231 |
$wpdb->query("START TRANSACTION"); |
| 6232 |
$wpdb->query("LOCK TABLES `" . $table_name . "` WRITE"); |
| 6233 |
$wpdb->update( |
| 6234 |
$table_name, |
| 6235 |
array( |
| 6236 |
'subject' => $subject, |
| 6237 |
'content' => $content, |
| 6238 |
'subjectForAdmin' => $subjectForAdmin, |
| 6239 |
'contentForAdmin' => $contentForAdmin, |
| 6240 |
'enable' => $enable, |
| 6241 |
'enableSMS' => $enableSMS, |
| 6242 |
'format' => $format, |
| 6243 |
'subjectForIcalendar' => $subjectForIcalendar, |
| 6244 |
'locationForIcalendar' => $locationForIcalendar, |
| 6245 |
'contentForIcalendar' => $contentForIcalendar, |
| 6246 |
'attachICalendar' => intval($_POST['attachICalendar']), |
| 6247 |
'notifyAdministrator' => intval($_POST['notifyAdministrator']), |
| 6248 |
), |
| 6249 |
array('accountKey' => $accountKey, 'mail_id' => $mail_id), |
| 6250 |
array('%s', '%s', '%s', '%s', '%d', '%d', '%s', '%s', '%s', '%s', '%d', '%d'), |
| 6251 |
array('%d', '%s') |
| 6252 |
); |
| 6253 |
|
| 6254 |
$wpdb->query('COMMIT'); |
| 6255 |
$wpdb->query('UNLOCK TABLES'); |
| 6256 |
|
| 6257 |
} catch (Exception $e) { |
| 6258 |
|
| 6259 |
$wpdb->query('ROLLBACK'); |
| 6260 |
$wpdb->query('UNLOCK TABLES'); |
| 6261 |
|
| 6262 |
}/** finally { |
| 6263 |
|
| 6264 |
$wpdb->query('UNLOCK TABLES'); |
| 6265 |
|
| 6266 |
}**/ |
| 6267 |
|
| 6268 |
return $this->getEmailMessageList($accountKey); |
| 6269 |
|
| 6270 |
} |
| 6271 |
|
| 6272 |
public function lookingForSubscription($customer_id, $subscription_id) { |
| 6273 |
|
| 6274 |
global $wpdb; |
| 6275 |
$url = BOOKING_PACKAGE_EXTENSION_URL; |
| 6276 |
|
| 6277 |
$license = array( |
| 6278 |
'status' => 0, |
| 6279 |
'subscription_status' => '', |
| 6280 |
'customer_id' => trim(esc_html($customer_id)), |
| 6281 |
'subscription_id' => trim(esc_html($subscription_id)), |
| 6282 |
'url' => get_site_url(), |
| 6283 |
'expiration_date' => 0, |
| 6284 |
); |
| 6285 |
|
| 6286 |
$args = array( |
| 6287 |
'method' => 'POST', |
| 6288 |
'timeout' => $this->request_timeout, |
| 6289 |
'body' => array( |
| 6290 |
'mode' => 'error', |
| 6291 |
'subscription_mode' => 'lookingForSubscription', |
| 6292 |
'customer_id_for_subscriptions' => $license['customer_id'], |
| 6293 |
'subscriptions_id_for_subscriptions' => $license['subscription_id'], |
| 6294 |
'url' => $license['url'], |
| 6295 |
) |
| 6296 |
); |
| 6297 |
$response = wp_remote_request($url . "lookingForSubscription/", $args); |
| 6298 |
$statusCode = wp_remote_retrieve_response_code($response); |
| 6299 |
$response = json_decode(wp_remote_retrieve_body($response), true); |
| 6300 |
$response['url'] = $url; |
| 6301 |
if (intval($statusCode) == 200 && intval($response['status']) == 1) { |
| 6302 |
|
| 6303 |
unset($response['status']); |
| 6304 |
$license['status'] = 1; |
| 6305 |
if (isset($response['subscription_status']) === true) { |
| 6306 |
|
| 6307 |
$license['subscription_status'] = $response['subscription_status']; |
| 6308 |
|
| 6309 |
} |
| 6310 |
|
| 6311 |
|
| 6312 |
$this->updateSubscribeSite(); |
| 6313 |
foreach ((array) $response as $key => $value) { |
| 6314 |
|
| 6315 |
$value = sanitize_text_field($value); |
| 6316 |
if ( $key === 'expiration_date_for_subscriptions' ) { |
| 6317 |
|
| 6318 |
$license['expiration_date'] = intval($value); |
| 6319 |
if ( is_numeric($value) === true ) { |
| 6320 |
|
| 6321 |
$value = $this->encryptValue($value); |
| 6322 |
|
| 6323 |
} |
| 6324 |
|
| 6325 |
} |
| 6326 |
|
| 6327 |
if (get_option('_' . $this->prefix . $key) !== false) { |
| 6328 |
|
| 6329 |
update_option('_' . $this->prefix . $key, $value); |
| 6330 |
|
| 6331 |
} else { |
| 6332 |
|
| 6333 |
$bool = add_option('_' . $this->prefix . $key, $value); |
| 6334 |
|
| 6335 |
} |
| 6336 |
|
| 6337 |
} |
| 6338 |
|
| 6339 |
if ($this->getSubscriptionStatus() !== 'Canceled') { |
| 6340 |
|
| 6341 |
$this->updateSubscriptionStatus('Active'); |
| 6342 |
|
| 6343 |
} |
| 6344 |
|
| 6345 |
if (strtolower( $license['subscription_status'] ) === 'canceled') { |
| 6346 |
|
| 6347 |
$this->updateSubscriptionStatus('Canceled'); |
| 6348 |
|
| 6349 |
} |
| 6350 |
|
| 6351 |
} else { |
| 6352 |
|
| 6353 |
$license['errorCode'] = esc_html($response['errorCode']); |
| 6354 |
$license['errorMessage'] = esc_html($response['errorMessage']); |
| 6355 |
update_option('_' . $this->prefix . 'expiration_date_for_subscriptions', 0); |
| 6356 |
|
| 6357 |
} |
| 6358 |
|
| 6359 |
return $license; |
| 6360 |
|
| 6361 |
} |
| 6362 |
|
| 6363 |
public function upgradePlan($type) { |
| 6364 |
|
| 6365 |
$response = array('status' => 'error'); |
| 6366 |
if ($type === 'get') { |
| 6367 |
|
| 6368 |
$values = array( |
| 6369 |
'customer_id_for_subscriptions', |
| 6370 |
'id_for_subscriptions', |
| 6371 |
'customer_email_for_subscriptions', |
| 6372 |
'invoice_id_for_subscriptions', |
| 6373 |
'expiration_date_for_subscriptions' |
| 6374 |
); |
| 6375 |
|
| 6376 |
for ($i = 0; $i < count($values); $i++) { |
| 6377 |
|
| 6378 |
$key = $values[$i]; |
| 6379 |
$value = get_option('_' . $this->prefix . $key, 0); |
| 6380 |
|
| 6381 |
if (get_option($this->prefix . $key) !== false) { |
| 6382 |
|
| 6383 |
$value = get_option($this->prefix . $key); |
| 6384 |
delete_option($this->prefix . $key); |
| 6385 |
add_option('_' . $this->prefix . $key, $value); |
| 6386 |
|
| 6387 |
} |
| 6388 |
|
| 6389 |
$response[$key] = $value; |
| 6390 |
|
| 6391 |
} |
| 6392 |
|
| 6393 |
$expiration = $response['expiration_date_for_subscriptions']; |
| 6394 |
if ( is_numeric($expiration) === false ) { |
| 6395 |
|
| 6396 |
$expiration = $this->decryptValue($expiration); |
| 6397 |
if ($expiration === false) { |
| 6398 |
|
| 6399 |
$expiration = 0; |
| 6400 |
|
| 6401 |
} |
| 6402 |
|
| 6403 |
if (intval($expiration) === 0) { |
| 6404 |
|
| 6405 |
$expiration = 0; |
| 6406 |
|
| 6407 |
} |
| 6408 |
|
| 6409 |
} else { |
| 6410 |
|
| 6411 |
if (intval($expiration) > 0) { |
| 6412 |
|
| 6413 |
$subscriptionDetails = $this->lookingForSubscription($response['customer_id_for_subscriptions'], $response['id_for_subscriptions']); |
| 6414 |
$expiration = $subscriptionDetails['expiration_date']; |
| 6415 |
if (intval($subscriptionDetails['status']) === 1) { |
| 6416 |
|
| 6417 |
update_option('_' . $this->prefix . 'expiration_date_for_subscriptions', $this->encryptValue($expiration)); |
| 6418 |
$this->updateSubscriptionStatus('Active'); |
| 6419 |
|
| 6420 |
} else { |
| 6421 |
|
| 6422 |
update_option('_' . $this->prefix . 'expiration_date_for_subscriptions', 0); |
| 6423 |
$this->updateSubscriptionStatus('Inactive'); |
| 6424 |
$this->notificationSubscriptionRenewalFailed(true); |
| 6425 |
|
| 6426 |
} |
| 6427 |
|
| 6428 |
} else { |
| 6429 |
|
| 6430 |
#$this->updateSubscriptionStatus('Inactive'); |
| 6431 |
|
| 6432 |
} |
| 6433 |
|
| 6434 |
} |
| 6435 |
|
| 6436 |
$response['expiration_date_for_subscriptions'] = intval($expiration); |
| 6437 |
$response['status'] = 'success'; |
| 6438 |
|
| 6439 |
} else if ($type === 'delete') { |
| 6440 |
|
| 6441 |
$params = array( |
| 6442 |
'mode' => 'error', |
| 6443 |
'subscription_mode' => 'cancelSubscription', |
| 6444 |
'customer_id' => $_POST['customer_id'], |
| 6445 |
'subscriptions_id' => trim($_POST['subscriptions_id']), |
| 6446 |
); |
| 6447 |
|
| 6448 |
$args = array( |
| 6449 |
'method' => 'POST', |
| 6450 |
'timeout' => $this->request_timeout, |
| 6451 |
'body' => $params |
| 6452 |
); |
| 6453 |
|
| 6454 |
$response = wp_remote_request(BOOKING_PACKAGE_EXTENSION_URL . "cancelSubscription/", $args); |
| 6455 |
$statusCode = wp_remote_retrieve_response_code($response); |
| 6456 |
$response = json_decode(wp_remote_retrieve_body($response), true); |
| 6457 |
$response['url'] = BOOKING_PACKAGE_EXTENSION_URL; |
| 6458 |
if ($statusCode == 200 && $response['status'] == 'success') { |
| 6459 |
|
| 6460 |
$this->updateSubscriptionStatus('Canceled'); |
| 6461 |
$response['status'] = 'success'; |
| 6462 |
|
| 6463 |
} |
| 6464 |
|
| 6465 |
|
| 6466 |
} |
| 6467 |
|
| 6468 |
return $response; |
| 6469 |
|
| 6470 |
} |
| 6471 |
|
| 6472 |
public function resetSubscription() { |
| 6473 |
|
| 6474 |
$this->deleteSubscriptionData(); |
| 6475 |
return array('status' => true); |
| 6476 |
|
| 6477 |
} |
| 6478 |
|
| 6479 |
private function deleteSubscriptionData() { |
| 6480 |
|
| 6481 |
$values = array('customer_id_for_subscriptions', 'id_for_subscriptions', 'customer_email_for_subscriptions', 'invoice_id_for_subscriptions', 'expiration_date_for_subscriptions'); |
| 6482 |
for ($i = 0; $i < count($values); $i++) { |
| 6483 |
|
| 6484 |
$key = $values[$i]; |
| 6485 |
if (get_option('_' . $this->prefix . $key) === false) { |
| 6486 |
|
| 6487 |
add_option('_' . $this->prefix . $key, 0); |
| 6488 |
|
| 6489 |
} else { |
| 6490 |
|
| 6491 |
update_option('_' . $this->prefix . $key, 0); |
| 6492 |
|
| 6493 |
} |
| 6494 |
|
| 6495 |
} |
| 6496 |
|
| 6497 |
} |
| 6498 |
|
| 6499 |
public function getSubscriptionStatus() { |
| 6500 |
|
| 6501 |
return get_option('_' . $this->prefix . 'subscription_status', 'Not subscribed'); |
| 6502 |
|
| 6503 |
} |
| 6504 |
|
| 6505 |
private function updateSubscriptionStatus($status) { |
| 6506 |
|
| 6507 |
if (get_option('_' . $this->prefix . 'subscription_status') === false) { |
| 6508 |
|
| 6509 |
add_option('_' . $this->prefix . 'subscription_status', sanitize_text_field($status)); |
| 6510 |
|
| 6511 |
} else { |
| 6512 |
|
| 6513 |
update_option('_' . $this->prefix . 'subscription_status', sanitize_text_field($status)); |
| 6514 |
|
| 6515 |
} |
| 6516 |
|
| 6517 |
} |
| 6518 |
|
| 6519 |
private function getExtensionsValid() { |
| 6520 |
|
| 6521 |
if (is_null($this->isExtensionsValid)) { |
| 6522 |
|
| 6523 |
$this->isExtensionsValid = $this->getSiteStatus(); |
| 6524 |
|
| 6525 |
} |
| 6526 |
|
| 6527 |
return $this->isExtensionsValid; |
| 6528 |
|
| 6529 |
} |
| 6530 |
|
| 6531 |
public function checkLatestInvoice() { |
| 6532 |
|
| 6533 |
$url = BOOKING_PACKAGE_EXTENSION_URL; |
| 6534 |
$latestInvoiceDate = get_option('_' . $this->prefix . 'latestInvoiceDate', null); |
| 6535 |
if ( is_null($latestInvoiceDate) ) { |
| 6536 |
|
| 6537 |
$current_timestamp = time(); |
| 6538 |
$last_month_timestamp = strtotime('last month', $current_timestamp); |
| 6539 |
$latestInvoiceDate = intval(date('Y', $last_month_timestamp) . date('m', $last_month_timestamp)); |
| 6540 |
add_option('_' . $this->prefix . 'latestInvoiceDate', $latestInvoiceDate); |
| 6541 |
|
| 6542 |
} |
| 6543 |
|
| 6544 |
$currentDate = intval(date('Y') . date('m')); |
| 6545 |
$subscriptions = $this->upgradePlan('get'); |
| 6546 |
$expiration_date = $subscriptions['expiration_date_for_subscriptions'] - (3 * 3600); |
| 6547 |
if ($this->getSubscriptionStatus() === 'Active' && $expiration_date < date('U') && $currentDate > intval($latestInvoiceDate)) { |
| 6548 |
|
| 6549 |
$params = array( |
| 6550 |
"subscription_mode" => "checkLatestInvoice", |
| 6551 |
"subscriptions_id" => $subscriptions['id_for_subscriptions'], |
| 6552 |
); |
| 6553 |
|
| 6554 |
$args = array( |
| 6555 |
'method' => 'POST', |
| 6556 |
'timeout' => $this->request_timeout, |
| 6557 |
'body' => $params |
| 6558 |
); |
| 6559 |
$response = wp_remote_request($url . "checkLatestInvoice/", $args); |
| 6560 |
$statusCode = wp_remote_retrieve_response_code($response); |
| 6561 |
$response = json_decode(wp_remote_retrieve_body($response)); |
| 6562 |
if ($response->subscription_status === 'active' && $response->invoice_status === 'open') { |
| 6563 |
|
| 6564 |
$this->notificationSubscriptionRenewalFailed(false, __('Your paid subscription payment failed.', 'booking-package')); |
| 6565 |
|
| 6566 |
} |
| 6567 |
update_option('_' . $this->prefix . 'latestInvoiceDate', $currentDate); |
| 6568 |
|
| 6569 |
} |
| 6570 |
|
| 6571 |
} |
| 6572 |
|
| 6573 |
public function notificationSubscriptionRenewalFailed($checkStatusText = true, $subject = null) { |
| 6574 |
|
| 6575 |
$to = get_option($this->prefix . "email_to", null); |
| 6576 |
if (empty($to)) { |
| 6577 |
|
| 6578 |
$to = get_bloginfo('admin_email'); |
| 6579 |
|
| 6580 |
} |
| 6581 |
|
| 6582 |
$sender = trim( get_option($this->prefix . "email_from", null) ); |
| 6583 |
$sender_name = trim( get_option($this->prefix . "email_title_from", null) ); |
| 6584 |
if (empty($sender)) { |
| 6585 |
|
| 6586 |
$sender = trim( get_bloginfo('admin_email') ); |
| 6587 |
$sender_name = trim( get_bloginfo('name') ); |
| 6588 |
|
| 6589 |
} |
| 6590 |
|
| 6591 |
$from = $sender; |
| 6592 |
if (!empty($sender_name) && strlen($sender_name) != 0) { |
| 6593 |
|
| 6594 |
$from = sprintf("%s <%s>", $sender_name, $sender); |
| 6595 |
|
| 6596 |
} |
| 6597 |
$headers = array("From: ".$from."\r\n", "Return-Path: ".$from."\r\n", "Reply-To: ".$from."\r\n"); |
| 6598 |
$text = $this->subscriptionRenewalFailed('text', $checkStatusText); |
| 6599 |
if (empty($text)) { |
| 6600 |
|
| 6601 |
return false; |
| 6602 |
|
| 6603 |
} |
| 6604 |
$text .= "\nURL: " . admin_url(); |
| 6605 |
if ( is_null($subject) ) { |
| 6606 |
|
| 6607 |
$subject = __('Paid Subscription Renewal Failed.', 'booking-package'); |
| 6608 |
|
| 6609 |
} |
| 6610 |
wp_mail(trim( $to ), '[Booking Packgae] ' . $subject, $text, $headers); |
| 6611 |
|
| 6612 |
} |
| 6613 |
|
| 6614 |
public function subscriptionRenewalFailed($type = 'html', $checkStatusText = true) { |
| 6615 |
|
| 6616 |
$status = $this->getSubscriptionStatus(); |
| 6617 |
$text = ''; |
| 6618 |
if ($status === 'Inactive' || $checkStatusText === false) { |
| 6619 |
|
| 6620 |
$text .= '<div id="booking_package_subscriptionRenewalFailed">'; |
| 6621 |
if ($checkStatusText === true) { |
| 6622 |
|
| 6623 |
$text .= '<p><b>' . __('Paid Subscription Renewal Failed.', 'booking-package') . '</b><br>' . "\n"; |
| 6624 |
|
| 6625 |
} else { |
| 6626 |
|
| 6627 |
$text .= '<p><b>' . __('Your paid subscription payment failed.', 'booking-package') . '</b><br>' . "\n"; |
| 6628 |
|
| 6629 |
} |
| 6630 |
$text .= '<div>' . sprintf(__('Please check the status in the WordPress dashboard under %s > %s > %s to find the reason and proceed with renewal.', 'booking-package'), 'Booking Package', __('General Settings', 'booking-package'), __('Paid Subscription', 'booking-package')) . "</div><br>\n"; |
| 6631 |
if ($checkStatusText === true) { |
| 6632 |
|
| 6633 |
$text .= '<div>' . __('If the status shows an issue, payment for your subscription may have failed. ', 'booking-package') . "<br>\n"; |
| 6634 |
|
| 6635 |
} |
| 6636 |
$text .= sprintf(__('Please check your payment status on the "%s" page and complete the payment if necessary. ', 'booking-package'), __('My billing', 'booking-package')) . "</div><br>\n"; |
| 6637 |
if ($checkStatusText === true) { |
| 6638 |
|
| 6639 |
$text .= '<div>' . sprintf(__('After completing the payment, or if the status is not updated even without a payment issue, click the "%s" button to manually update your subscription.', 'booking-package'), __('Update My Subscription', 'booking-package')) . "</div>\n"; |
| 6640 |
|
| 6641 |
} |
| 6642 |
$text .= '</p>'; |
| 6643 |
$text .= '</div>'; |
| 6644 |
|
| 6645 |
} |
| 6646 |
|
| 6647 |
if ($type === 'text') { |
| 6648 |
|
| 6649 |
$text = strip_tags($text); |
| 6650 |
|
| 6651 |
} |
| 6652 |
|
| 6653 |
return $text; |
| 6654 |
|
| 6655 |
} |
| 6656 |
|
| 6657 |
public function setSubscribeSite($scheme = false) { |
| 6658 |
|
| 6659 |
$unique = get_site_url(); |
| 6660 |
if ($scheme === true) { |
| 6661 |
|
| 6662 |
$unique = wp_hash( preg_replace('#^[^:]+://#', '', $unique) ); |
| 6663 |
if (get_option('_' . $this->prefix . 'unique_without_scheme') === false) { |
| 6664 |
|
| 6665 |
add_option('_' . $this->prefix . 'unique_without_scheme', sanitize_text_field($unique)); |
| 6666 |
|
| 6667 |
} else { |
| 6668 |
|
| 6669 |
#update_option('_' . $this->prefix . 'unique_without_scheme', sanitize_text_field($unique)); |
| 6670 |
|
| 6671 |
} |
| 6672 |
|
| 6673 |
} else { |
| 6674 |
|
| 6675 |
$unique = wp_hash($unique); |
| 6676 |
if (get_option('_' . $this->prefix . 'unique') === false) { |
| 6677 |
|
| 6678 |
add_option('_' . $this->prefix . 'unique', sanitize_text_field($unique)); |
| 6679 |
|
| 6680 |
} else { |
| 6681 |
|
| 6682 |
#update_option('_' . $this->prefix . 'unique', sanitize_text_field($unique)); |
| 6683 |
|
| 6684 |
} |
| 6685 |
|
| 6686 |
} |
| 6687 |
|
| 6688 |
|
| 6689 |
return $unique; |
| 6690 |
|
| 6691 |
} |
| 6692 |
|
| 6693 |
public function setOpensslAlgo($algo) { |
| 6694 |
|
| 6695 |
if (get_option('_' . $this->prefix . 'openssl_algo') === false) { |
| 6696 |
|
| 6697 |
add_option('_' . $this->prefix . 'openssl_algo', sanitize_text_field($algo)); |
| 6698 |
|
| 6699 |
} |
| 6700 |
|
| 6701 |
} |
| 6702 |
|
| 6703 |
public function updateSubscribeSite() { |
| 6704 |
|
| 6705 |
$site = get_site_url(); |
| 6706 |
$unique_without_scheme = wp_hash( preg_replace('#^[^:]+://#', '', $site) ); |
| 6707 |
update_option('_' . $this->prefix . 'unique_without_scheme', sanitize_text_field($unique_without_scheme) ); |
| 6708 |
$unique = wp_hash($site); |
| 6709 |
update_option('_' . $this->prefix . 'unique', sanitize_text_field($unique) ); |
| 6710 |
|
| 6711 |
} |
| 6712 |
|
| 6713 |
public function setPaidSubscription($mode) { |
| 6714 |
|
| 6715 |
$subscriptions = $this->upgradePlan("get"); |
| 6716 |
$isExtensionsValid = $this->getSiteStatus(); |
| 6717 |
if ($isExtensionsValid == true) { |
| 6718 |
|
| 6719 |
if ($mode == 'activation') { |
| 6720 |
|
| 6721 |
$this->lookingForSubscription($subscriptions['customer_id_for_subscriptions'], $subscriptions['id_for_subscriptions']); |
| 6722 |
|
| 6723 |
} else if ($mode == 'deactivation') { |
| 6724 |
|
| 6725 |
$statusCode = $this->cancelPaidSubscriptionAtPeriodEnd($subscriptions['customer_id_for_subscriptions'], $subscriptions['id_for_subscriptions']); |
| 6726 |
|
| 6727 |
} |
| 6728 |
|
| 6729 |
} |
| 6730 |
|
| 6731 |
return $isExtensionsValid; |
| 6732 |
|
| 6733 |
} |
| 6734 |
|
| 6735 |
public function updatePaidSubscription($unique) { |
| 6736 |
|
| 6737 |
$site = get_site_url(); |
| 6738 |
if ($unique !== false && wp_hash($site) === $unique) { |
| 6739 |
|
| 6740 |
$subscriptions = $this->upgradePlan('get'); |
| 6741 |
$response = $this->lookingForSubscription($subscriptions['customer_id_for_subscriptions'], $subscriptions['id_for_subscriptions']); |
| 6742 |
return $response; |
| 6743 |
|
| 6744 |
} |
| 6745 |
|
| 6746 |
return false; |
| 6747 |
|
| 6748 |
} |
| 6749 |
|
| 6750 |
public function validateWpSite($validate = true) { |
| 6751 |
|
| 6752 |
if ($validate === false) { |
| 6753 |
|
| 6754 |
return true; |
| 6755 |
|
| 6756 |
} |
| 6757 |
|
| 6758 |
$site = get_site_url(); |
| 6759 |
$unique = get_option('_' . $this->prefix . 'unique', false); |
| 6760 |
if (empty($unique)) { |
| 6761 |
|
| 6762 |
$unique = $this->setSubscribeSite(false); |
| 6763 |
|
| 6764 |
} |
| 6765 |
|
| 6766 |
$site_without_scheme = preg_replace('#^[^:]+://#', '', $site); |
| 6767 |
$unique_without_scheme = get_option('_' . $this->prefix . 'unique_without_scheme', false); |
| 6768 |
if (empty($unique_without_scheme)) { |
| 6769 |
|
| 6770 |
$unique_without_scheme = $this->setSubscribeSite(true); |
| 6771 |
|
| 6772 |
} |
| 6773 |
|
| 6774 |
if (wp_hash( $site_without_scheme ) !== $unique_without_scheme) { |
| 6775 |
|
| 6776 |
$this->updateSubscribeSite(); |
| 6777 |
$expiration = get_option('_' . $this->prefix . 'expiration_date_for_subscriptions', 0); |
| 6778 |
if ( is_numeric($expiration) === true ) { |
| 6779 |
|
| 6780 |
$value = $this->encryptValue($expiration); |
| 6781 |
if (get_option('_' . $this->prefix . 'expiration_date_for_subscriptions') === false) { |
| 6782 |
|
| 6783 |
add_option('_' . $this->prefix . 'expiration_date_for_subscriptions', $value); |
| 6784 |
|
| 6785 |
} else { |
| 6786 |
|
| 6787 |
update_option('_' . $this->prefix . 'expiration_date_for_subscriptions', $value); |
| 6788 |
|
| 6789 |
} |
| 6790 |
|
| 6791 |
} else { |
| 6792 |
|
| 6793 |
$expiration = $this->decryptValue($expiration); |
| 6794 |
|
| 6795 |
} |
| 6796 |
|
| 6797 |
if (intval($expiration) > 0) { |
| 6798 |
|
| 6799 |
/** |
| 6800 |
$subscriptions = $this->upgradePlan("get"); |
| 6801 |
$statusCode = $this->cancelPaidSubscriptionAtPeriodEnd($subscriptions['customer_id_for_subscriptions'], $subscriptions['id_for_subscriptions']); |
| 6802 |
|
| 6803 |
if (intval($statusCode) == 200) { |
| 6804 |
|
| 6805 |
update_option('_' . $this->prefix . "expiration_date_for_subscriptions", sanitize_text_field('0')); |
| 6806 |
|
| 6807 |
} |
| 6808 |
**/ |
| 6809 |
|
| 6810 |
update_option('_' . $this->prefix . "expiration_date_for_subscriptions", sanitize_text_field('0')); |
| 6811 |
return false; |
| 6812 |
|
| 6813 |
} |
| 6814 |
|
| 6815 |
} |
| 6816 |
|
| 6817 |
|
| 6818 |
return true; |
| 6819 |
|
| 6820 |
} |
| 6821 |
|
| 6822 |
|
| 6823 |
|
| 6824 |
public function getSiteStatus($countExpiration = false) { |
| 6825 |
|
| 6826 |
$url = BOOKING_PACKAGE_EXTENSION_URL; |
| 6827 |
$response = array('status' => 'error'); |
| 6828 |
$statusCode = 0; |
| 6829 |
$subscriptions = $this->upgradePlan('get'); |
| 6830 |
$expiration_date = intval($subscriptions['expiration_date_for_subscriptions']); |
| 6831 |
|
| 6832 |
if ( intval($subscriptions['expiration_date_for_subscriptions']) == 0 && $countExpiration === false ) { |
| 6833 |
|
| 6834 |
if ($this->getSubscriptionStatus() === 'Canceled') { |
| 6835 |
|
| 6836 |
$this->deleteSubscriptionData(); |
| 6837 |
$this->updateSubscriptionStatus('Not subscribed'); |
| 6838 |
|
| 6839 |
} |
| 6840 |
|
| 6841 |
return false; |
| 6842 |
|
| 6843 |
} |
| 6844 |
|
| 6845 |
if ($expiration_date < date('U')) { |
| 6846 |
|
| 6847 |
if ($this->getSubscriptionStatus() === 'Canceled') { |
| 6848 |
|
| 6849 |
$this->deleteSubscriptionData(); |
| 6850 |
$this->updateSubscriptionStatus('Not subscribed'); |
| 6851 |
return false; |
| 6852 |
|
| 6853 |
} |
| 6854 |
|
| 6855 |
$params = array( |
| 6856 |
"subscription_mode" => "updateLicense", |
| 6857 |
"customer_id" => $subscriptions['customer_id_for_subscriptions'], |
| 6858 |
"subscriptions_id" => $subscriptions['id_for_subscriptions'], |
| 6859 |
"site" => get_site_url(), |
| 6860 |
); |
| 6861 |
|
| 6862 |
$args = array( |
| 6863 |
'method' => 'POST', |
| 6864 |
'timeout' => $this->request_timeout, |
| 6865 |
'body' => $params |
| 6866 |
); |
| 6867 |
$response = wp_remote_request($url . "updateLicense/", $args); |
| 6868 |
$statusCode = wp_remote_retrieve_response_code($response); |
| 6869 |
$response = json_decode(wp_remote_retrieve_body($response)); |
| 6870 |
|
| 6871 |
$tmp_path = sys_get_temp_dir(); |
| 6872 |
if (intval($statusCode) == 200) { |
| 6873 |
|
| 6874 |
if (intval($response->status) == 1) { |
| 6875 |
|
| 6876 |
$expiration_date = $this->encryptValue( sanitize_text_field($response->expiration_date) ); |
| 6877 |
update_option('_' . $this->prefix . "invoice_id_for_subscriptions", sanitize_text_field($response->invoice_id)); |
| 6878 |
$bool = update_option('_' . $this->prefix . "expiration_date_for_subscriptions", $expiration_date); |
| 6879 |
$subscriptions = $this->upgradePlan('get'); |
| 6880 |
if ($countExpiration === true) { |
| 6881 |
|
| 6882 |
update_option('_' . $this->prefix . 'numberOfVerificationAttemptsForExpiration', 0); |
| 6883 |
|
| 6884 |
} |
| 6885 |
|
| 6886 |
return true; |
| 6887 |
|
| 6888 |
} else if (intval($response->status) == 0) { |
| 6889 |
|
| 6890 |
$bool = update_option('_' . $this->prefix . "expiration_date_for_subscriptions", sanitize_text_field('0')); |
| 6891 |
$this->updateSubscriptionStatus('Inactive'); |
| 6892 |
$this->notificationSubscriptionRenewalFailed(true); |
| 6893 |
return false; |
| 6894 |
|
| 6895 |
} |
| 6896 |
|
| 6897 |
} else { |
| 6898 |
|
| 6899 |
$bool = update_option('_' . $this->prefix . "expiration_date_for_subscriptions", sanitize_text_field('0')); |
| 6900 |
$this->updateSubscriptionStatus('Inactive'); |
| 6901 |
$this->notificationSubscriptionRenewalFailed(true); |
| 6902 |
return false; |
| 6903 |
|
| 6904 |
} |
| 6905 |
|
| 6906 |
} |
| 6907 |
|
| 6908 |
return true; |
| 6909 |
|
| 6910 |
} |
| 6911 |
|
| 6912 |
private function encryptValue($value) { |
| 6913 |
|
| 6914 |
$unique_without_scheme = get_option('_' . $this->prefix . 'unique_without_scheme', false); |
| 6915 |
if ( $unique_without_scheme === false ) { |
| 6916 |
|
| 6917 |
$unique_without_scheme = $this->setSubscribeSite(true); |
| 6918 |
|
| 6919 |
} |
| 6920 |
|
| 6921 |
if (function_exists('openssl_encrypt') === false) { |
| 6922 |
|
| 6923 |
return $value; |
| 6924 |
|
| 6925 |
} |
| 6926 |
$algo = get_option('_' . $this->prefix . 'openssl_algo', 'AES-128-ECB'); |
| 6927 |
$encryptedData = base64_encode(openssl_encrypt($value, $algo, $unique_without_scheme, OPENSSL_RAW_DATA)); |
| 6928 |
return $encryptedData; |
| 6929 |
|
| 6930 |
} |
| 6931 |
|
| 6932 |
private function decryptValue($value) { |
| 6933 |
|
| 6934 |
/** |
| 6935 |
$unique = get_option('_' . $this->prefix . 'unique', false); |
| 6936 |
if ( $unique === false ) { |
| 6937 |
|
| 6938 |
$unique = $this->setSubscribeSite(false); |
| 6939 |
|
| 6940 |
} |
| 6941 |
|
| 6942 |
$algo = get_option('_' . $this->prefix . 'openssl_algo', 'AES-128-ECB'); |
| 6943 |
$decryptedData = openssl_decrypt(base64_decode($value), $algo, $unique, OPENSSL_RAW_DATA); |
| 6944 |
if ( $decryptedData === false ) { |
| 6945 |
|
| 6946 |
$unique_without_scheme = get_option('_' . $this->prefix . 'unique_without_scheme', false); |
| 6947 |
if ( $unique_without_scheme === false || empty($unique_without_scheme)) { |
| 6948 |
|
| 6949 |
$unique_without_scheme = $this->setSubscribeSite(true); |
| 6950 |
|
| 6951 |
} |
| 6952 |
|
| 6953 |
$decryptedData = openssl_decrypt(base64_decode($value), $algo, $unique_without_scheme, OPENSSL_RAW_DATA); |
| 6954 |
if ($decryptedData === false) { |
| 6955 |
|
| 6956 |
return false; |
| 6957 |
|
| 6958 |
} |
| 6959 |
|
| 6960 |
} |
| 6961 |
**/ |
| 6962 |
|
| 6963 |
$algo = get_option('_' . $this->prefix . 'openssl_algo', 'AES-128-ECB'); |
| 6964 |
$unique_without_scheme = get_option('_' . $this->prefix . 'unique_without_scheme', false); |
| 6965 |
if ( $unique_without_scheme === false || empty($unique_without_scheme)) { |
| 6966 |
|
| 6967 |
$unique_without_scheme = $this->setSubscribeSite(true); |
| 6968 |
|
| 6969 |
} |
| 6970 |
|
| 6971 |
$decryptedData = openssl_decrypt(base64_decode($value), $algo, $unique_without_scheme, OPENSSL_RAW_DATA); |
| 6972 |
if ($decryptedData === false) { |
| 6973 |
|
| 6974 |
return false; |
| 6975 |
|
| 6976 |
} |
| 6977 |
|
| 6978 |
return $decryptedData; |
| 6979 |
|
| 6980 |
} |
| 6981 |
|
| 6982 |
public function cancelPaidSubscriptionAtPeriodEnd($customer_id, $subscription_id) { |
| 6983 |
|
| 6984 |
$params = array( |
| 6985 |
"subscription_mode" => "cancelAtPeriodEnd", |
| 6986 |
"customer_id" => trim($customer_id), |
| 6987 |
"subscriptions_id" => trim($subscription_id), |
| 6988 |
); |
| 6989 |
$args = array( |
| 6990 |
'method' => 'POST', |
| 6991 |
'timeout' => $this->request_timeout, |
| 6992 |
'body' => $params |
| 6993 |
); |
| 6994 |
$response = wp_remote_request(BOOKING_PACKAGE_EXTENSION_URL . "cancelAtPeriodEnd/", $args); |
| 6995 |
$statusCode = wp_remote_retrieve_response_code($response); |
| 6996 |
$response = json_decode(wp_remote_retrieve_body($response), true); |
| 6997 |
return $statusCode; |
| 6998 |
|
| 6999 |
} |
| 7000 |
|
| 7001 |
public function updateChannelGC($calendarAccountList){ |
| 7002 |
|
| 7003 |
$url_parce = parse_url(get_home_url()); |
| 7004 |
if($url_parce['scheme'] != 'https'){ |
| 7005 |
|
| 7006 |
return false; |
| 7007 |
|
| 7008 |
} |
| 7009 |
|
| 7010 |
$keyList = array(); |
| 7011 |
$calendarIdList = array(); |
| 7012 |
for($i = 0; $i < count($calendarAccountList); $i++){ |
| 7013 |
|
| 7014 |
if($calendarAccountList[$i]['expirationForGoogleWebhook'] < date('U')){ |
| 7015 |
|
| 7016 |
array_push($keyList, $calendarAccountList[$i]['key']); |
| 7017 |
array_push($calendarIdList, $calendarAccountList[$i]['googleCalendarID']); |
| 7018 |
|
| 7019 |
} |
| 7020 |
|
| 7021 |
} |
| 7022 |
|
| 7023 |
if(count($calendarIdList) == 0){ |
| 7024 |
|
| 7025 |
return null; |
| 7026 |
|
| 7027 |
} |
| 7028 |
|
| 7029 |
$calendarIdList = implode(",", $calendarIdList); |
| 7030 |
|
| 7031 |
$googleCalendar = array(); |
| 7032 |
$bookingSync = $this->getBookingSyncList(); |
| 7033 |
$bookingSync = $bookingSync['Google_Calendar']; |
| 7034 |
if(intval($bookingSync['booking_package_googleCalendar_active']['value']) == 1){ |
| 7035 |
|
| 7036 |
if($this->getExtensionsValid(false) === true){ |
| 7037 |
|
| 7038 |
$expiration_for_google_webhook = get_option($this->prefix."expiration_for_google_webhook", 0); |
| 7039 |
$expiration_for_google_webhook -= (1440 * 60) * 2; |
| 7040 |
#$timezone = get_option('timezone_string'); |
| 7041 |
date_default_timezone_set("UTC"); |
| 7042 |
if(date('U') < $expiration_for_google_webhook){ |
| 7043 |
|
| 7044 |
return false; |
| 7045 |
|
| 7046 |
} |
| 7047 |
|
| 7048 |
$host = $url_parce["host"]; |
| 7049 |
$address = get_home_url()."/?webhook=google"; |
| 7050 |
$id = hash('ripemd160', date('U')); |
| 7051 |
$timezone = get_option('timezone_string'); |
| 7052 |
$subscriptions = $this->upgradePlan('get'); |
| 7053 |
|
| 7054 |
$customer_id = $subscriptions['customer_id_for_subscriptions']; |
| 7055 |
$params = array( |
| 7056 |
'mode' => 'updateChannel', |
| 7057 |
'customer_id' => $customer_id, |
| 7058 |
'calendarIdList' => $calendarIdList, |
| 7059 |
/**'calendarId' => $bookingSync['booking_package_calendar_id']['value'], **/ |
| 7060 |
'service_account' => $bookingSync['booking_package_googleCalendar_json']['value'], |
| 7061 |
'id' => $id, |
| 7062 |
'token' => 'target='.hash('ripemd160', microtime()), |
| 7063 |
'address' => $address, |
| 7064 |
'timeZone' => get_option('timezone_string') |
| 7065 |
); |
| 7066 |
#var_dump($params); |
| 7067 |
if(isset($bookingSync['booking_package_googleCalendar_json'])){ |
| 7068 |
|
| 7069 |
$params['calendarId'] = $bookingSync['booking_package_calendar_id']['value']; |
| 7070 |
|
| 7071 |
} |
| 7072 |
|
| 7073 |
$tmp_path = sys_get_temp_dir(); |
| 7074 |
|
| 7075 |
$url = BOOKING_PACKAGE_EXTENSION_URL; |
| 7076 |
$ch = curl_init(); |
| 7077 |
curl_setopt($ch, CURLOPT_URL, $url."googleCalendar/"); |
| 7078 |
curl_setopt($ch, CURLOPT_COOKIEJAR, $tmp_path."/".$this->prefix."session.cookie"); |
| 7079 |
curl_setopt($ch, CURLOPT_COOKIEFILE, $tmp_path."/".$this->prefix."session.cookie"); |
| 7080 |
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); |
| 7081 |
curl_setopt($ch, CURLOPT_POST, 1); |
| 7082 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 7083 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
| 7084 |
|
| 7085 |
ob_start(); |
| 7086 |
$response = curl_exec($ch); |
| 7087 |
$response = ob_get_contents(); |
| 7088 |
ob_end_clean(); |
| 7089 |
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 7090 |
curl_close ($ch); |
| 7091 |
$response = json_decode($response, true); |
| 7092 |
#var_dump($response); |
| 7093 |
if($response['status'] != 'error'){ |
| 7094 |
|
| 7095 |
for($i = 0; $i < count($response); $i++){ |
| 7096 |
|
| 7097 |
$response[$i]['key'] = $keyList[$i]; |
| 7098 |
|
| 7099 |
} |
| 7100 |
|
| 7101 |
if(isset($response['expiration'])){ |
| 7102 |
|
| 7103 |
$response['expiration'] /= 1000; |
| 7104 |
$list = array('id' => 'id_for_google_webhook', 'token' => 'token_for_google_webhook', 'expiration' => 'expiration_for_google_webhook'); |
| 7105 |
foreach ((array) $list as $key => $value) { |
| 7106 |
|
| 7107 |
$optionKey = sanitize_text_field($this->prefix.$value); |
| 7108 |
$optionValue = sanitize_text_field($response[$key]); |
| 7109 |
if(get_option($optionKey) === false){ |
| 7110 |
|
| 7111 |
add_option($optionKey, $optionValue); |
| 7112 |
|
| 7113 |
}else{ |
| 7114 |
|
| 7115 |
update_option($optionKey, $optionValue); |
| 7116 |
|
| 7117 |
} |
| 7118 |
|
| 7119 |
} |
| 7120 |
|
| 7121 |
} |
| 7122 |
|
| 7123 |
}else{ |
| 7124 |
|
| 7125 |
$response = array(); |
| 7126 |
|
| 7127 |
} |
| 7128 |
|
| 7129 |
|
| 7130 |
|
| 7131 |
#var_dump($response); |
| 7132 |
|
| 7133 |
return $response; |
| 7134 |
|
| 7135 |
} |
| 7136 |
|
| 7137 |
} |
| 7138 |
|
| 7139 |
} |
| 7140 |
|
| 7141 |
public function listsGC($accountKey, $googleCalendarID, $timeMin){ |
| 7142 |
|
| 7143 |
if(strlen($googleCalendarID) == 0){ |
| 7144 |
|
| 7145 |
return array(); |
| 7146 |
|
| 7147 |
} |
| 7148 |
|
| 7149 |
|
| 7150 |
$eventList = array(); |
| 7151 |
$bookingSync = $this->getBookingSyncList($accountKey); |
| 7152 |
$bookingSync = $bookingSync['Google_Calendar']; |
| 7153 |
#var_dump($bookingSync); |
| 7154 |
if(intval($bookingSync['booking_package_googleCalendar_active']['value']) == 1){ |
| 7155 |
|
| 7156 |
if($this->getExtensionsValid(false) === true){ |
| 7157 |
|
| 7158 |
$subscriptions = $this->upgradePlan('get'); |
| 7159 |
$customer_id = $subscriptions['customer_id_for_subscriptions']; |
| 7160 |
$params = array( |
| 7161 |
'mode' => 'lists', |
| 7162 |
'timeMin' => $timeMin, |
| 7163 |
'customer_id' => $customer_id, |
| 7164 |
'calendarId' => $googleCalendarID, |
| 7165 |
'service_account' => $bookingSync['booking_package_googleCalendar_json']['value'], |
| 7166 |
'timeZone' => get_option('timezone_string') |
| 7167 |
); |
| 7168 |
|
| 7169 |
#var_dump($params); |
| 7170 |
$tmp_path = sys_get_temp_dir(); |
| 7171 |
|
| 7172 |
$url = BOOKING_PACKAGE_EXTENSION_URL; |
| 7173 |
$ch = curl_init(); |
| 7174 |
curl_setopt($ch, CURLOPT_URL, $url."googleCalendar/"); |
| 7175 |
#curl_setopt($ch, CURLOPT_USERPWD, $subscriptions['customer_id_for_subscriptions'].":"); |
| 7176 |
curl_setopt($ch, CURLOPT_COOKIEJAR, $tmp_path."/".$this->prefix."session.cookie"); |
| 7177 |
curl_setopt($ch, CURLOPT_COOKIEFILE, $tmp_path."/".$this->prefix."session.cookie"); |
| 7178 |
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); |
| 7179 |
curl_setopt($ch, CURLOPT_POST, 1); |
| 7180 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 7181 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
| 7182 |
|
| 7183 |
ob_start(); |
| 7184 |
$response = curl_exec($ch); |
| 7185 |
$response = ob_get_contents(); |
| 7186 |
ob_end_clean(); |
| 7187 |
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 7188 |
curl_close ($ch); |
| 7189 |
$eventList = json_decode($response); |
| 7190 |
if($eventList->status != 'error'){ |
| 7191 |
|
| 7192 |
} |
| 7193 |
|
| 7194 |
return $eventList; |
| 7195 |
|
| 7196 |
} |
| 7197 |
|
| 7198 |
} |
| 7199 |
|
| 7200 |
} |
| 7201 |
|
| 7202 |
public function pushGC($mode, $accountKey, $type, $id, $googleCalendarID, $sql_start_unixTime, $sql_end_unixTime, $form, $iCalID = false){ |
| 7203 |
|
| 7204 |
if(strlen($googleCalendarID) == 0){ |
| 7205 |
|
| 7206 |
return array(); |
| 7207 |
|
| 7208 |
} |
| 7209 |
|
| 7210 |
$id = intval($id); |
| 7211 |
$googleCalendar = array(); |
| 7212 |
$bookingSync = $this->getBookingSyncList($accountKey); |
| 7213 |
$bookingSync = $bookingSync['Google_Calendar']; |
| 7214 |
if(intval($bookingSync['booking_package_googleCalendar_active']['value']) == 1){ |
| 7215 |
|
| 7216 |
if($this->getExtensionsValid(false) === true){ |
| 7217 |
|
| 7218 |
if(is_null($sql_end_unixTime)){ |
| 7219 |
|
| 7220 |
$sql_end_unixTime = $sql_start_unixTime; |
| 7221 |
|
| 7222 |
} |
| 7223 |
$nameList = array(); |
| 7224 |
$addressList = array(); |
| 7225 |
for($i = 0; $i < count($form); $i++){ |
| 7226 |
|
| 7227 |
if($form[$i]->isName == 'true'){ |
| 7228 |
|
| 7229 |
array_push($nameList, $form[$i]->value); |
| 7230 |
|
| 7231 |
} |
| 7232 |
|
| 7233 |
if($form[$i]->isAddress == 'true'){ |
| 7234 |
|
| 7235 |
array_push($addressList, $form[$i]->value); |
| 7236 |
|
| 7237 |
} |
| 7238 |
|
| 7239 |
} |
| 7240 |
|
| 7241 |
$subscriptions = $this->upgradePlan('get'); |
| 7242 |
$customer_id = $subscriptions['customer_id_for_subscriptions']; |
| 7243 |
$params = array( |
| 7244 |
'mode' => $mode, |
| 7245 |
'customer_id' => $customer_id, |
| 7246 |
'calendarId' => $googleCalendarID, |
| 7247 |
'service_account' => $bookingSync['booking_package_googleCalendar_json']['value'], |
| 7248 |
'startTime' => intval($sql_start_unixTime), |
| 7249 |
'endTime' => intval($sql_end_unixTime), |
| 7250 |
'form' => json_encode($form), |
| 7251 |
'timeZone' => get_option('timezone_string'), |
| 7252 |
'type' => $type |
| 7253 |
); |
| 7254 |
|
| 7255 |
if($iCalID !== false){ |
| 7256 |
|
| 7257 |
$params['iCalID'] = $iCalID; |
| 7258 |
|
| 7259 |
} |
| 7260 |
|
| 7261 |
#var_dump($params); |
| 7262 |
|
| 7263 |
$tmp_path = sys_get_temp_dir(); |
| 7264 |
|
| 7265 |
$url = BOOKING_PACKAGE_EXTENSION_URL; |
| 7266 |
$ch = curl_init(); |
| 7267 |
curl_setopt($ch, CURLOPT_URL, $url."googleCalendar/"); |
| 7268 |
curl_setopt($ch, CURLOPT_COOKIEJAR, $tmp_path."/".$this->prefix."session.cookie"); |
| 7269 |
curl_setopt($ch, CURLOPT_COOKIEFILE, $tmp_path."/".$this->prefix."session.cookie"); |
| 7270 |
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); |
| 7271 |
curl_setopt($ch, CURLOPT_POST, 1); |
| 7272 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 7273 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
| 7274 |
|
| 7275 |
ob_start(); |
| 7276 |
$response = curl_exec($ch); |
| 7277 |
$response = ob_get_contents(); |
| 7278 |
ob_end_clean(); |
| 7279 |
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 7280 |
curl_close ($ch); |
| 7281 |
#var_dump($response); |
| 7282 |
$googleCalendar = json_decode($response); |
| 7283 |
if($googleCalendar->status != 'error'){ |
| 7284 |
|
| 7285 |
} |
| 7286 |
|
| 7287 |
#var_dump($httpCode); |
| 7288 |
$googleCalendar->responseMode = $mode; |
| 7289 |
if($httpCode >= 400){ |
| 7290 |
|
| 7291 |
$googleCalendar->responseCode = $httpCode; |
| 7292 |
$googleCalendar->responseStatus = 0; |
| 7293 |
|
| 7294 |
}else{ |
| 7295 |
|
| 7296 |
$googleCalendar->responseStatus = 1; |
| 7297 |
|
| 7298 |
} |
| 7299 |
|
| 7300 |
return $googleCalendar; |
| 7301 |
|
| 7302 |
} |
| 7303 |
|
| 7304 |
} |
| 7305 |
|
| 7306 |
} |
| 7307 |
|
| 7308 |
public function deleteGC($accountKey, $id, $googleCalendarID){ |
| 7309 |
|
| 7310 |
if(strlen($googleCalendarID) == 0){ |
| 7311 |
|
| 7312 |
return array(); |
| 7313 |
|
| 7314 |
} |
| 7315 |
|
| 7316 |
if(is_null($id)){ |
| 7317 |
|
| 7318 |
return array("id" => "No ID"); |
| 7319 |
|
| 7320 |
} |
| 7321 |
|
| 7322 |
$googleCalendar = array(); |
| 7323 |
$bookingSync = $this->getBookingSyncList($accountKey); |
| 7324 |
$bookingSync = $bookingSync['Google_Calendar']; |
| 7325 |
if(intval($bookingSync['booking_package_googleCalendar_active']['value']) == 1){ |
| 7326 |
|
| 7327 |
if($this->getExtensionsValid(false) === true){ |
| 7328 |
|
| 7329 |
$timezone = get_option('timezone_string'); |
| 7330 |
$subscriptions = $this->upgradePlan('get'); |
| 7331 |
$customer_id = $subscriptions['customer_id_for_subscriptions']; |
| 7332 |
$params = array( |
| 7333 |
'mode' => 'delete', |
| 7334 |
'customer_id' => $customer_id, |
| 7335 |
'calendarId' => $googleCalendarID, |
| 7336 |
'service_account' => $bookingSync['booking_package_googleCalendar_json']['value'], |
| 7337 |
'id' => $id, |
| 7338 |
'timeZone' => get_option('timezone_string') |
| 7339 |
); |
| 7340 |
#var_dump($params); |
| 7341 |
|
| 7342 |
$tmp_path = sys_get_temp_dir(); |
| 7343 |
|
| 7344 |
$url = BOOKING_PACKAGE_EXTENSION_URL; |
| 7345 |
$ch = curl_init(); |
| 7346 |
curl_setopt($ch, CURLOPT_URL, $url."googleCalendar/"); |
| 7347 |
#curl_setopt($ch, CURLOPT_USERPWD, $subscriptions['customer_id_for_subscriptions'].":"); |
| 7348 |
curl_setopt($ch, CURLOPT_COOKIEJAR, $tmp_path."/".$this->prefix."session.cookie"); |
| 7349 |
curl_setopt($ch, CURLOPT_COOKIEFILE, $tmp_path."/".$this->prefix."session.cookie"); |
| 7350 |
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); |
| 7351 |
curl_setopt($ch, CURLOPT_POST, 1); |
| 7352 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 7353 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
| 7354 |
|
| 7355 |
ob_start(); |
| 7356 |
$response = curl_exec($ch); |
| 7357 |
$response = ob_get_contents(); |
| 7358 |
ob_end_clean(); |
| 7359 |
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 7360 |
curl_close ($ch); |
| 7361 |
$response = json_decode($response, true); |
| 7362 |
|
| 7363 |
return $response; |
| 7364 |
|
| 7365 |
} |
| 7366 |
|
| 7367 |
} |
| 7368 |
|
| 7369 |
} |
| 7370 |
|
| 7371 |
public function activation($url, $mode, $version = null, $timezone = null, $site = null){ |
| 7372 |
|
| 7373 |
if (is_null($timezone)) { |
| 7374 |
|
| 7375 |
$timezone = get_option($this->prefix . 'timezone', null); |
| 7376 |
if (is_null($timezone)) { |
| 7377 |
|
| 7378 |
$timezone = get_option('timezone_string', ''); |
| 7379 |
if(is_null($timezone) || strlen($timezone) == 0){ |
| 7380 |
|
| 7381 |
$timezone = 'UTC'; |
| 7382 |
|
| 7383 |
} |
| 7384 |
|
| 7385 |
add_option($this->prefix."timezone", sanitize_text_field($timezone)); |
| 7386 |
|
| 7387 |
} |
| 7388 |
|
| 7389 |
} |
| 7390 |
|
| 7391 |
if (is_null($site)) { |
| 7392 |
|
| 7393 |
$site = get_site_url(); |
| 7394 |
|
| 7395 |
} |
| 7396 |
|
| 7397 |
$id = get_option($this->prefix."activation_id", null); |
| 7398 |
$params = array("mode" => $mode, "timeZone" => $timezone, "local" => get_locale(), "site" => $site); |
| 7399 |
|
| 7400 |
if (!is_null($id) || $id != 0) { |
| 7401 |
|
| 7402 |
$params['id'] = $id; |
| 7403 |
|
| 7404 |
} |
| 7405 |
|
| 7406 |
if (!is_null($version)) { |
| 7407 |
|
| 7408 |
$params['version'] = $version; |
| 7409 |
|
| 7410 |
} |
| 7411 |
|
| 7412 |
$args = array( |
| 7413 |
'method' => 'POST', |
| 7414 |
'timeout' => $this->request_timeout, |
| 7415 |
'body' => $params |
| 7416 |
); |
| 7417 |
$response = wp_remote_request($url . "activation/", $args); |
| 7418 |
$object = json_decode(wp_remote_retrieve_body($response)); |
| 7419 |
$statusCode = wp_remote_retrieve_response_code($response); |
| 7420 |
|
| 7421 |
if (intval($statusCode) == 200 && $mode == 'activation') { |
| 7422 |
|
| 7423 |
if (get_option($this->prefix."activation_id") === false) { |
| 7424 |
|
| 7425 |
add_option($this->prefix."activation_id", intval($object->key)); |
| 7426 |
|
| 7427 |
} else { |
| 7428 |
|
| 7429 |
update_option($this->prefix."activation_id", intval($object->key)); |
| 7430 |
|
| 7431 |
} |
| 7432 |
|
| 7433 |
} |
| 7434 |
|
| 7435 |
} |
| 7436 |
|
| 7437 |
public function updateRolesOfPlugin() { |
| 7438 |
|
| 7439 |
$manager = $this->prefix . 'manager'; |
| 7440 |
$editor = $this->prefix . 'editor'; |
| 7441 |
|
| 7442 |
if (is_null(get_role($manager))) { |
| 7443 |
|
| 7444 |
$roleArray = array('read' => true, 'level_0' => true, 'booking_package_manager' => true); |
| 7445 |
$object = add_role($manager, 'Booking Package Manager', $roleArray); |
| 7446 |
|
| 7447 |
} |
| 7448 |
|
| 7449 |
if (is_null(get_role($editor))) { |
| 7450 |
|
| 7451 |
$roleArray = array('read' => true, 'level_0' => true, 'booking_package_editor' => true); |
| 7452 |
$object = add_role($editor, 'Booking Package Editor', $roleArray); |
| 7453 |
|
| 7454 |
} |
| 7455 |
|
| 7456 |
} |
| 7457 |
|
| 7458 |
public function deleteRolesOfPlugin() { |
| 7459 |
|
| 7460 |
$roles = array($this->prefix . 'manager', $this->prefix . 'editor'); |
| 7461 |
for ($i = 0; $i < count($roles); $i++) { |
| 7462 |
|
| 7463 |
$role = $roles[$i]; |
| 7464 |
if (!is_null(get_role($role))) { |
| 7465 |
|
| 7466 |
$users = get_users(array('role' => $role)); |
| 7467 |
for ($a = 0; $a < count($users); $a++) { |
| 7468 |
|
| 7469 |
$user = $users[$a]; |
| 7470 |
$user->remove_role($role); |
| 7471 |
|
| 7472 |
} |
| 7473 |
remove_role($role); |
| 7474 |
|
| 7475 |
} |
| 7476 |
|
| 7477 |
} |
| 7478 |
|
| 7479 |
} |
| 7480 |
|
| 7481 |
public function updateRolesOfUser() { |
| 7482 |
|
| 7483 |
$oldRole = $this->prefix . 'member'; |
| 7484 |
$newRole = $this->prefix . 'user'; |
| 7485 |
if (!is_null(get_role($oldRole))) { |
| 7486 |
|
| 7487 |
$users = get_users(array('role' => $oldRole)); |
| 7488 |
for ($i = 0; $i < count($users); $i++) { |
| 7489 |
|
| 7490 |
$user = $users[$i]; |
| 7491 |
#$user->remove_role($oldRole); |
| 7492 |
#$user->add_role($newRole); |
| 7493 |
var_dump($user->get_role_caps()); |
| 7494 |
echo "<br>\n"; |
| 7495 |
#break; |
| 7496 |
|
| 7497 |
} |
| 7498 |
|
| 7499 |
#remove_role($userRole); |
| 7500 |
#$roleArray = array('read' => true, 'level_0' => true, 'booking_package' => true); |
| 7501 |
#$object = add_role($newRole, 'Booking Package User', $roleArray); |
| 7502 |
|
| 7503 |
} |
| 7504 |
|
| 7505 |
} |
| 7506 |
|
| 7507 |
public function getOnlyNumbers($value) { |
| 7508 |
|
| 7509 |
if (function_exists('mb_convert_kana')) { |
| 7510 |
|
| 7511 |
$value = mb_convert_kana($value, 'n'); |
| 7512 |
|
| 7513 |
} |
| 7514 |
$value = preg_replace('/[^\-0-9]/', '', $value); |
| 7515 |
|
| 7516 |
if (empty($value)) { |
| 7517 |
|
| 7518 |
$value = 0; |
| 7519 |
|
| 7520 |
} |
| 7521 |
|
| 7522 |
return $value; |
| 7523 |
|
| 7524 |
} |
| 7525 |
|
| 7526 |
} |
| 7527 |
|
| 7528 |
|
| 7529 |
?> |