diff --git a/.gitignore b/.gitignore index 2d46485..907d805 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ data.json +database-config.txt diff --git a/database-config.txt b/database-config.txt new file mode 100644 index 0000000..8c2ee3d --- /dev/null +++ b/database-config.txt @@ -0,0 +1,10 @@ + +Your Nettl MySQL database details are as follows. + +Database Type: MySQL +Database Host: w3pcloud-ap-southeast-2-live.ca83oxrfowfr.ap-southeast-2.rds.amazonaws.com +Database Username: nettlau +Database Password: 0767a88ed2266022 +Database Name: nettlau + +Created on : Wed Mar 21 01:35:14 GMT 2018 diff --git a/date.php b/date.php index 88ac7c7..afbe3f5 100644 --- a/date.php +++ b/date.php @@ -1,7 +1,7 @@ get_results("SELECT * FROM `wp_amelia_appointments` WHERE `internalNotes` = 'freeBusy' AND `serviceId` = 4" , ARRAY_A); -// -// foreach($notCal as $row){ -// $itemsToCompare[] = $row['bookingStart']; -// } -// -// foreach ($apiArray as $startTime) { -// array_push($items,'time',$startTime['start']); -// } +$notCal = $wpdb->get_results("SELECT * FROM `wp_amelia_appointments` WHERE `internalNotes` = 'freeBusy' AND `serviceId` = 4" , ARRAY_A); + + + + + foreach($notCal as $row){ + $itemsToCompare[] = $row['bookingStart']; + } + foreach($apiArray as $rows){ + $bob[] = $rows['start']; + } +// $bob = str_replace(" ",'""',$items); +// $v = var_export($itemsToCompare, true); +// $c = var_export($items, true); + +// echo $v; +// // echo "

"; + +print_r($bob); +echo "

"; +print_r($itemsToCompare); +echo "

"; +$result = array_diff($itemsToCompare, $bob); +print_r ($result); + +// $bob = implode( '""', $items); +// // $bob = implode('""', $itemsToCompare); +// $great = '"'.$bob.'"'; +// print_r(gettype($great)); + +// echo "
2
"; +// $here = implode( '""', $itemsToCompare); +// // $here = implode('""', $itemsToCompare); +// // $realGood = '"'.$here.'"'; +// // print_r(gettype($realGood)); +// // echo "
3
"; +// print_r($items); +// echo "
break
"; +// print_r($itemsToCompare); +// echo "
break
"; +// $result = array_diff($items,$itemsToCompare); +// print_r($result); + + foreach ($apiArray as $key => $value) { //for each item in the array run the the following $start = $value['start']; //setting $start as the start date specified in the array $end = $value['end']; //setting $end as the start date specified in the array $count = 0; //set count as 0 to be used later - $start = date('Y-m-d H:i:s', strtotime( "$start - 10 hours")); //converting the time in NZ to GMT +2 as WP_Amelia uses Serbia timezones to read it - $end = date('Y-m-d H:i:s', strtotime( "$end - 10 hours"));//converting the time in NZ to GMT +2 as WP_Amelia uses Serbia timezones to read it + // $start = date('Y-m-d H:i:s', strtotime( "$start - 10 hours")); //converting the time in NZ to GMT +2 as WP_Amelia uses Serbia timezones to read it + // $end = date('Y-m-d H:i:s', strtotime( "$end - 10 hours"));//converting the time in NZ to GMT +2 as WP_Amelia uses Serbia timezones to read it $count = $wpdb->get_var("SELECT * FROM `wp_amelia_appointments` WHERE `bookingStart` = '$start' AND `bookingEnd` = '$end'"); //checking wether it already exists in the database if ($count < 1) { //if it doesnt exist run this $sql = $wpdb->insert('wp_amelia_appointments', array ('id' => NULL, 'status' => 'approved', 'bookingStart' => $start, 'bookingEnd' => $end, 'notifyParticipants' => '0', 'serviceId' => '4', 'providerId' => '1', 'internalNotes' => 'freeBusy'