1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636
<?php
class orddd_calendar_sync_settings {
public static function orddd_calendar_sync_general_settings_callback() {}
public static function orddd_calendar_event_location_callback( $args ) {
$google_calendar_location = get_option( "orddd_calendar_event_location" );
echo '<input type="text" name="orddd_calendar_event_location" id="orddd_calendar_event_location" value="' . $google_calendar_location . '" />';
$html = '<label for="orddd_calendar_event_location"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_calendar_event_summary_callback( $args ) {
$gcal_summary = get_option( 'orddd_calendar_event_summary' );
echo '<input id="orddd_calendar_event_summary" name="orddd_calendar_event_summary" value="' . $gcal_summary . '" size="90" name="gcal_summary" type="text"/>';
}
public static function orddd_calendar_event_description_callback( $args ) {
$gcal_description = get_option( 'orddd_calendar_event_description' );
echo '<textarea id="orddd_calendar_event_description" name="orddd_calendar_event_description" cols="90" rows="4" name="gcal_description">' . $gcal_description .'</textarea>';
$html = '<label for="orddd_calendar_event_description"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_calendar_sync_customer_settings_callback() { }
public static function orddd_add_to_calendar_order_received_page_callback( $args ) {
$add_to_calendar_order_received = "";
if ( get_option( 'orddd_add_to_calendar_order_received_page' ) == 'on' ) {
$add_to_calendar_order_received = "checked";
}
echo '<input type="checkbox" name="orddd_add_to_calendar_order_received_page" id="orddd_add_to_calendar_order_received_page" class="day-checkbox" value="on" ' . $add_to_calendar_order_received . ' />';
$html = '<label for="orddd_add_to_calendar_order_received_page"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_add_to_calendar_customer_email_callback( $args ) {
$add_to_calendar_customer_email = "";
if ( get_option( 'orddd_add_to_calendar_customer_email' ) == 'on' ) {
$add_to_calendar_customer_email = "checked";
}
echo '<input type="checkbox" name="orddd_add_to_calendar_customer_email" id="orddd_add_to_calendar_customer_email" class="day-checkbox" value="on" ' . $add_to_calendar_customer_email . ' />';
$html = '<label for="orddd_add_to_calendar_customer_email"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_add_to_calendar_my_account_page_callback( $args ) {
$orddd_add_to_calendar_my_account_page = "";
if ( get_option( 'orddd_add_to_calendar_my_account_page' ) == 'on' ) {
$orddd_add_to_calendar_my_account_page = "checked";
}
echo '<input type="checkbox" name="orddd_add_to_calendar_my_account_page" id="orddd_add_to_calendar_my_account_page" class="day-checkbox" value="on" ' . $orddd_add_to_calendar_my_account_page . ' />';
$html = '<label for="orddd_add_to_calendar_my_account_page"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_calendar_in_same_window_callback( $args ) {
$google_calendar_same_window = "";
if ( get_option( 'orddd_calendar_in_same_window' ) == 'on' ) {
$google_calendar_same_window = "checked";
}
echo '<input type="checkbox" name="orddd_calendar_in_same_window" id="orddd_calendar_in_same_window" class="day-checkbox" value="on" ' . $google_calendar_same_window . ' />';
$html = '<label for="orddd_calendar_in_same_window"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_calendar_sync_admin_settings_section_callback() { }
public static function orddd_calendar_sync_integration_mode_callback( $args ) {
$sync_directly = "";
$sync_manually = "";
$sync_disable = "checked";
if ( get_option( 'orddd_calendar_sync_integration_mode' ) == 'manually' ) {
$sync_manually = "checked";
$sync_disable = "";
} else if( get_option( 'orddd_calendar_sync_integration_mode' ) == 'directly' ) {
$sync_directly = "checked";
$sync_disable = "";
}
echo '<input type="radio" name="orddd_calendar_sync_integration_mode" id="orddd_calendar_sync_integration_mode" value="directly" ' . $sync_directly . '/>' . __( 'Sync Automatically', 'order-delivery-date' ) . '
<input type="radio" name="orddd_calendar_sync_integration_mode" id="orddd_calendar_sync_integration_mode" value="manually" ' . $sync_manually . '/>' . __( 'Sync Manually', 'order-delivery-date' ) . '
<input type="radio" name="orddd_calendar_sync_integration_mode" id="orddd_calendar_sync_integration_mode" value="disabled" ' . $sync_disable . '/>' . __( 'Disabled', 'order-delivery-date' );
$html = '<label for="orddd_calendar_sync_integration_mode"> ' . $args[0] . '</label>';
echo $html;
print( '<script type="text/javascript">
jQuery( document ).ready( function() {
var isChecked = jQuery( "#orddd_calendar_sync_integration_mode:checked" ).val();
if( isChecked == "directly" ) {
i = 0;
jQuery( ".form-table" ).each( function() {
if( i == 2 ) {
k = 0;
var row = jQuery( this ).find( "tr" );
jQuery.each( row , function() {
if( k == 7 ) {
jQuery( this ).fadeOut();
} else {
jQuery( this ).fadeIn();
}
k++;
});
} else {
jQuery( this ).fadeIn();
}
i++;
} );
} else if( isChecked == "manually" ) {
i = 0;
jQuery( ".form-table" ).each( function() {
if( i == 2 ) {
k = 0;
var row = jQuery( this ).find( "tr" );
jQuery.each( row , function() {
if( k != 7 && k != 0 ) {
jQuery( this ).fadeOut();
} else {
jQuery( this ).fadeIn();
}
k++;
});
} else {
jQuery( this ).fadeIn();
}
i++;
});
} else if( isChecked == "disabled" ) {
i = 0;
jQuery( ".form-table" ).each( function() {
if( i == 2 ) {
k = 0;
var row = jQuery( this ).find( "tr" );
jQuery.each( row , function() {
if( k != 0 ) {
jQuery( this ).fadeOut();
} else {
jQuery( this ).fadeIn();
}
k++;
});
} else {
jQuery( this ).fadeIn();
}
i++;
});
}
jQuery( "input[type=radio][id=orddd_calendar_sync_integration_mode]" ).change( function() {
var isChecked = jQuery( this ).val();
if( isChecked == "directly" ) {
i = 0;
jQuery( ".form-table" ).each( function() {
if( i == 2 ) {
k = 0;
var row = jQuery( this ).find( "tr" );
jQuery.each( row , function() {
if( k == 7 ) {
jQuery( this ).fadeOut();
} else {
jQuery( this ).fadeIn();
}
k++;
});
} else {
jQuery( this ).fadeIn();
}
i++;
} );
} else if( isChecked == "manually" ) {
i = 0;
jQuery( ".form-table" ).each( function() {
if( i == 2 ) {
k = 0;
var row = jQuery( this ).find( "tr" );
jQuery.each( row , function() {
if( k != 7 && k != 0 ) {
jQuery( this ).fadeOut();
} else {
jQuery( this ).fadeIn();
}
k++;
});
} else {
jQuery( this ).fadeIn();
}
i++;
});
} else if( isChecked == "disabled" ) {
i = 0;
jQuery( ".form-table" ).each( function() {
if( i == 2 ) {
k = 0;
var row = jQuery( this ).find( "tr" );
jQuery.each( row , function() {
if( k != 0 ) {
jQuery( this ).fadeOut();
} else {
jQuery( this ).fadeIn();
}
k++;
});
} else {
jQuery( this ).fadeIn();
}
i++;
});
}
})
});
</script>');
}
public static function orddd_sync_calendar_instructions_callback( ) {
echo '' . __( 'To set up Google Calendar API, please click on "Show me how" link and carefully follow these steps:', '' ) . '
<span class="description" ><a href="#orddd-instructions" id="show_instructions" data-target="api-instructions" class="orddd-info_trigger" title="' . __ ( 'Click to toggle instructions', 'order-delivery-date') . '">' . __( 'Show me how', 'order-delivery-date' ) . '</a></span>';
?> <div class="description orddd-info_target api-instructions" style="display: none;">
<ul style="list-style-type:decimal;">
<li><?php _e( 'Google Calendar API requires php V5.3+ and some php extensions.', 'order-delivery-date' ) ?> </li>
<li><?php printf( __( 'Go to Google APIs console by clicking %s. Login to your Google account if you are not already logged in.', 'order-delivery-date' ), '<a href="https://code.google.com/apis/console/" target="_blank">https://code.google.com/apis/console/</a>' ) ?></li>
<li><?php _e( 'Create a new project using the left side pane. Click on \'Home\' option. Name the project "Deliveries" (or use your chosen name instead).', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Click on API Manager from left side pane.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Click "Calendar API" under Google Apps APIs and Enable the API.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Go to "Credentials" menu in the left side pane and click on "New Credentials" dropdown.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Click on "OAuth client ID" option. Then click on Configure consent screen.', 'order-delivery-date' )?></li>
<li><?php _e( 'Enter a Product Name, e.g. Order Delivery Date, inside the opening pop-up. Click Save.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Select "Web Application" option, enter the Web client name and create the client ID.', 'order-delivery-date' )?></li>
<li><?php _e( 'Click on New Credentials dropdown and select "Service account key".', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Click "Service account" and select "New service account" and enter the name. Now select key type as "P12" and create the service account.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'A file with extension .p12 will be downloaded.', 'order-delivery-date' ) ?></li>
<li><?php printf( __( 'Using your FTP client program ( e.g.: %s, %s ), copy this key file to folder: %s . This file is required as you will grant access to your Google Calendar account even if you are not online. So this file serves as a proof of your consent to access to your Google calendar account. Note: This file cannot be uploaded in any other way. If you do not have FTP access, ask the website admin to do it for you.', 'order-delivery-date' ), '<a href="https://filezilla-project.org/" target="_blank">FileZilla</a>', '<a href="https://winscp.net/eng/index.php" target="_blank">WinSCP</a>', plugin_dir_path( __FILE__ ) .'gcal/key/' ) ?></li>
<li><?php _e( 'Enter the name of the key file to "Key file name" setting of Order Delivery Date. Exclude the extention .p12.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Copy "Email address" setting from Manage service account of Google apis console and paste it to "Service account email address" setting of Order Delivery Date.', 'order-delivery-date' ) ?></li>
<li><?php printf( __( 'Open your Google Calendar by clicking this link: %s', 'order-delivery-date' ), '<a href="https://www.google.com/calendar/render" target="_blank">https://www.google.com/calendar/render</a>' ) ?></li>
<li><?php _e( 'Create a new Calendar by selecting "my Calendars > Create new calendar" on left side pane. <b>Try NOT to use your primary calendar.</b>', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Give a name to the new calendar, e.g. Order Delivery Date calendar. <b>Check that Calendar Time Zone setting matches with time zone setting of your WordPress website.</b> Otherwise there will be a time shift.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Paste already copied "Email address" setting from Manage service account of Google apis console to "Person" field under "Share with specific person".', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Set "Permission Settings" of this person as "Make changes to events".', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Click "Add Person".', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Click "Create Calendar".', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Select the created calendar and click "Calendar settings".', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Copy "Calendar ID" value on Calendar Address row.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Paste this value to "Calendar to be used" field of Order Delivery Date settings.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Select the desired Integration mode: Sync Automatically or Sync Manually.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Click "Save Settings" on Order Delivery Date settings.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'After these stages, you have set up Google Calendar API. To test the connection, click the "Test Connection" link.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'If you get a success message, you should see a test event inserted to the Google Calendar and you are ready to go. If you get an error message, double check your settings.', 'order-delivery-date' ) ?></li>
</ul>
</div>
<script type="text/javascript">
function toggle_target (e) {
if ( e && e.preventDefault ) {
e.preventDefault();
}
if ( e && e.stopPropagation ) {
e.stopPropagation();
}
var target = jQuery(".orddd-info_target.api-instructions" );
if ( !target.length ) {
return false;
}
if ( target.is( ":visible" ) ) {
target.hide( "fast" );
} else {
target.show( "fast" );
}
return false;
}
jQuery(function () {
jQuery(document).on("click", ".orddd-info_trigger", toggle_target);
});
</script>
<?php
}
public static function orddd_calendar_key_file_name_callback( $args ) {
$gcal_key_file_arr = get_option( 'orddd_calendar_details_1' );
if( isset( $gcal_key_file_arr[ 'orddd_calendar_key_file_name' ] ) ) {
$gcal_key_file = $gcal_key_file_arr[ 'orddd_calendar_key_file_name' ];
} else {
$gcal_key_file = '';
}
echo '<input id="orddd_calendar_details_1[orddd_calendar_key_file_name]" name= "orddd_calendar_details_1[orddd_calendar_key_file_name]" value="' . $gcal_key_file .'" size="90" name="gcal_key_file" type="text" />';
$html = '<label for="orddd_calendar_key_file_name"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_calendar_service_acc_email_address_callback( $args ) {
$gcal_service_account_arr = get_option( 'orddd_calendar_details_1' );
if( isset( $gcal_service_account_arr[ 'orddd_calendar_service_acc_email_address' ] ) ) {
$gcal_service_account = $gcal_service_account_arr[ 'orddd_calendar_service_acc_email_address' ];
} else {
$gcal_service_account = '';
}
echo '<input id="orddd_calendar_details_1[orddd_calendar_service_acc_email_address]" name="orddd_calendar_details_1[orddd_calendar_service_acc_email_address]" value="' . $gcal_service_account . '" size="90" name="gcal_service_account" type="text"/>';
$html = '<label for="orddd_calendar_service_acc_email_address"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_calendar_id_callback( $args ) {
$gcal_selected_calendar_arr = get_option( 'orddd_calendar_details_1' );
if( isset( $gcal_selected_calendar_arr[ 'orddd_calendar_id' ] ) ) {
$gcal_selected_calendar = $gcal_selected_calendar_arr[ 'orddd_calendar_id' ];
} else {
$gcal_selected_calendar = '';
}
echo '<input id="orddd_calendar_details_1[orddd_calendar_id]" name="orddd_calendar_details_1[orddd_calendar_id]" value="' . $gcal_selected_calendar . '" size="90" name="gcal_selected_calendar" type="text" />';
$html = '<label for="orddd_calendar_id"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_calendar_test_connection_callback() {
echo "<script type='text/javascript'>
jQuery( document ).on( 'click', '#test_connection', function( e ) {
e.preventDefault();
var data = {
gcal_api_test_result: '',
gcal_api_pre_test: '',
gcal_api_test: 1,
action: 'display_nag'
};
jQuery( '#test_connection_ajax_loader' ).show();
jQuery.post( '" . get_admin_url() . "/admin-ajax.php', data, function( response ) {
jQuery( '#test_connection_message' ).html( response );
jQuery( '#test_connection_ajax_loader' ).hide();
});
});
</script>";
print "<a href='admin.php?page=order_delivery_date&action=calendar_sync_settings' id='test_connection'>" . __( 'Test Connection', 'order-delivery-date' ) . "</a>
<img src='" . plugins_url() . "/order-delivery-date/images/ajax-loader.gif' id='test_connection_ajax_loader'>";
print "<div id='test_connection_message'></div>";
}
public static function orddd_admin_add_to_calendar_email_notification_callback( $args ) {
$orddd_admin_add_to_calendar_email_notification = "";
if( get_option( 'orddd_admin_add_to_calendar_email_notification' ) == "on" ) {
$orddd_admin_add_to_calendar_email_notification = "checked";
}
echo '<input type="checkbox" name="orddd_admin_add_to_calendar_email_notification" id="orddd_admin_add_to_calendar_email_notification" value="on" ' . $orddd_admin_add_to_calendar_email_notification . ' />';
$html = '<label for="orddd_admin_add_to_calendar_email_notification"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_admin_add_to_calendar_delivery_calendar_callback( $args ) {
$orddd_admin_add_to_calendar_view_deliveries = "";
if( get_option( 'orddd_admin_add_to_calendar_delivery_calendar' ) == "on" ) {
$orddd_admin_add_to_calendar_view_deliveries = "checked";
}
echo '<input type="checkbox" name="orddd_admin_add_to_calendar_delivery_calendar" id="orddd_admin_add_to_calendar_delivery_calendar" value="on" ' . $orddd_admin_add_to_calendar_view_deliveries . ' />';
$html = '<label for="orddd_admin_add_to_calendar_delivery_calendar"> ' . $args[0] . '</label>';
echo $html;
}
public static function orddd_calendar_import_ics_feeds_section_callback() {
_e( 'Events will be imported using the ICS Feed url. Each event will create a new WooCommerce Order. The event\'s date & time will be set as that order\'s Delivery Date & Time. <br>Lockout will be updated for global settings for the set Delivery Date & Time.', 'order-delivery-date' );
}
public static function orddd_ics_feed_url_instructions_callback() {
echo '' . __( 'To set up Import events using ics feed urls, please click on "Show me how" link and carefully follow these steps:', 'order-delivery-date' ) . '
<span class="ics-feed-description" ><a href="#orddd-ics-feed-instructions" id="show_instructions" data-target="api-instructions" class="orddd_ics_feed-info_trigger" title="' . __ ( 'Click to toggle instructions', 'order-delivery-date') . '">' . __( 'Show me how', 'order-delivery-date' ) . '</a></span>';
?> <div class="ics-feed-description orddd_ics_feed-info_target api-instructions" style="display: none;">
<ul style="list-style-type:decimal;">
<li><?php printf( __( 'Open your Google Calendar by clicking this link: %s', 'order-delivery-date' ), '<a href="https://www.google.com/calendar/render" target="_blank">https://www.google.com/calendar/render</a>' ) ?></li>
<li><?php _e( 'Select the calendar to be imported and click "Calendar settings".', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Click on "ICAL" button in Calendar Address option.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Copy the basic.ics file URL. <i>If you are importing events from a private calendar please copy the basic.ics file URL for private calendar.</i>', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Paste this link in the text box under Google Calendar Sync tab -> Import Events section.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Save the URL.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'Click on "Import Events" button to import the events from the calendar.', 'order-delivery-date' ) ?></li>
<li><?php _e( 'You can import multiple calendars by using ics feeds. Add them using the Add New Ics Feed url button.', 'order-delivery-date' ) ?></li>
</ul>
</div>
<script type="text/javascript">
function orddd_ics_feed_toggle_target (e) {
if ( e && e.preventDefault ) {
e.preventDefault();
}
if ( e && e.stopPropagation ) {
e.stopPropagation();
}
var target = jQuery( ".orddd_ics_feed-info_target.api-instructions" );
if ( !target.length ) {
return false;
}
if ( target.is( ":visible" ) ) {
target.hide( "fast" );
} else {
target.show( "fast" );
}
return false;
}
jQuery( function () {
jQuery(document).on( "click", ".orddd_ics_feed-info_trigger", orddd_ics_feed_toggle_target );
});
</script>
<?php
}
public static function orddd_ics_feed_url_callback( $args ) {
echo '<table id="orddd_ics_url_list">';
$ics_feed_urls = get_option( 'orddd_ics_feed_urls' );
if( $ics_feed_urls == '' || $ics_feed_urls == '{}' || $ics_feed_urls == '[]' || $ics_feed_urls == 'null' ) {
$ics_feed_urls = array();
}
if( count( $ics_feed_urls ) > 0 ) {
foreach ( $ics_feed_urls as $key => $value ) {
echo "<tr id='$key'>
<td class='ics_feed_url'>
<input type='text' id='orddd_ics_fee_url_$key' size='60' value='" . $value. "'>
</td>
<td class='ics_feed_url'>
<input type='button' value='Save' id='save_ics_url' class='save_button' name='$key' disabled='disabled'>
</td>
<td class='ics_feed_url'>
<input type='button' class='save_button' id='$key' name='import_ics' value='Import Events'>
</td>
<td class='ics_feed_url'>
<input type='button' class='save_button' id='$key' value='Delete' name='delete_ics_feed'>
</td>
<td class='ics_feed_url'>
<div id='import_event_message'>
<img src='" . plugins_url() . "/order-delivery-date/images/ajax-loader.gif'>
</div>
<div id='success_message' ></div>
</td>
</tr>";
}
} else {
echo "<tr id='0' >
<td class='ics_feed_url'>
<input type='text' id='orddd_ics_fee_url_0' size='60' >
</td>
<td class='ics_feed_url'>
<input type='button' value='Save' id='save_ics_url' class='save_button' name='0' >
</td>
<td class='ics_feed_url'>
<input type='button' class='save_button' id='0' name='import_ics' value='Import Events' disabled='disabled'>
</td>
<td class='ics_feed_url'>
<input type='button' class='save_button' id='0' name='delete_ics_feed' value='Delete' disabled='disabled'>
</td>
<td class='ics_feed_url'>
<div id='import_event_message'>
<img src='" . plugins_url() . "/order-delivery-date/images/ajax-loader.gif'>
</div>
<div id='success_message' ></div>
</td>
</tr>";
}
echo'</table>';
echo "<input type='button' class='save_button' id='add_new_ics_feed' name='add_new_ics_feed' value='" . __( 'Add New Ics feed url', 'order-delivery-date' ) ."'>";
echo "<script type='text/javascript'>
jQuery( document ).ready( function() {
jQuery( '#add_new_ics_feed' ).on( 'click', function() {
var rowCount = jQuery( '#orddd_ics_url_list tr' ).length;
jQuery( '#orddd_ics_url_list' ).append( '<tr id=\'' + rowCount + '\'><td class=\'ics_feed_url\'><input type=\'text\' id=\'orddd_ics_fee_url_' + rowCount + '\' size=\'60\' ></td><td class=\'ics_feed_url\'><input type=\'button\' value=\'Save\' id=\'save_ics_url\' class=\'save_button\' name=\'' + rowCount + '\'></td><td class=\'ics_feed_url\'><input type=\'button\' class=\'save_button\' id=\'' + rowCount + '\' name=\'import_ics\' value=\'Import Events\' disabled=\'disabled\'></td><td class=\'ics_feed_url\'><input type=\'button\' class=\'save_button\' id=\'' + rowCount + '\' value=\'Delete\' disabled=\'disabled\' name=\'delete_ics_feed\' ></td><td class=\'ics_feed_url\'><div id=\'import_event_message\'><img src=\'" . plugins_url() . "/order-delivery-date/images/ajax-loader.gif\'></div><div id=\'success_message\' ></div></td></tr>' );
});
jQuery( document ).on( 'click', '#save_ics_url', function() {
var key = jQuery( this ).attr( 'name' );
var data = {
ics_url: jQuery( '#orddd_ics_fee_url_' + key ).val(),
action: 'save_ics_url_feed'
};
jQuery.post( '" . get_admin_url() . "/admin-ajax.php', data, function( response ) {
if( response == 'yes' ) {
jQuery( 'input[name=\'' + key + '\']' ).attr( 'disabled','disabled' );
jQuery( 'input[id=\'' + key + '\']' ).removeAttr( 'disabled' );
}
});
});
jQuery( document ).on( 'click', 'input[type=\'button\'][name=\'delete_ics_feed\']', function() {
var key = jQuery( this ).attr( 'id' );
var data = {
ics_feed_key: key,
action: 'delete_ics_url_feed'
};
jQuery.post( '" . get_admin_url() . "/admin-ajax.php', data, function( response ) {
if( response == 'yes' ) {
jQuery( 'table#orddd_ics_url_list tr#' + key ).remove();
}
});
});
jQuery( document ).on( 'click', 'input[type=\'button\'][name=\'import_ics\']', function() {
jQuery( '#import_event_message' ).show();
var key = jQuery( this ).attr( 'id' );
var data = {
ics_feed_key: key,
action: 'import_events'
};
jQuery.post( '" . get_admin_url() . "/admin-ajax.php', data, function( response ) {
jQuery( '#import_event_message' ).hide();
jQuery( '#success_message' ).html( response );
jQuery( '#success_message' ).fadeIn();
setTimeout( function() {
jQuery( '#success_message' ).fadeOut();
},3000 );
});
});
});
</script>";
}
}
?>