Skip to content

Commit

Permalink
removing code for delete as need plugin to be live for now - on hold.…
Browse files Browse the repository at this point in the history
… Also adding the script to remove the busy serivce from the customer front end.
  • Loading branch information
sturzael committed Aug 20, 2018
1 parent 1900e71 commit fdb575b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 36 deletions.
47 changes: 11 additions & 36 deletions date.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
$items = array();
$itemsToCompare = array();
$i = 0;
// $items = array();
// $itemsToCompare = array();
// $i = 0;

define( 'SHORTINIT', true );
require_once($_SERVER['DOCUMENT_ROOT'].'/wp-config.php'); //Calling everything needed to make the querys.
Expand All @@ -10,32 +10,17 @@
$myArray = $_REQUEST['jsonString']; //setting myarray variable as the dates specified in script.js

$apiArray = json_decode($myArray, true); //decode the json into a php array
$notCal = $wpdb->get_results("SELECT * FROM `wp_amelia_appointments` WHERE `internalNotes` = 'freeBusy' AND `serviceId` = 4" , ARRAY_A);

$i == 0;
$j == 0;
foreach($notCal as $row){
$itemsToCompare[] = $row['bookingStart'];
$i++;
}

//pushing start times inside an array
foreach ($apiArray as $startTime) {
$items[] = $startTime['start'];
$j++;
}

// if ($i > $j) {
// // i is bigger
// print_r($itemsToCompare);
// }else {
// print_r($items);
// $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 $startTime) {
// array_push($items,'time',$startTime['start']);
// }

// $diff = array_values($items);
// print_r($diff);



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
Expand All @@ -44,16 +29,6 @@
$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


// $notCal = $wpdb->get_col("SELECT * FROM `wp_amelia_appointments` WHERE `bookingStart` <> '$start' AND `bookingEnd` <> '$end' AND `internalNotes` = 'freeBusy' AND `serviceId` = 4"); //query broken

// foreach ($notCal as $key => $value) {
// echo "- $value -";
// // $sql = $wpdb->delete('wp_amelia_appointments', array ('id' => $value));
// }


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'
));//insert the appointment
Expand Down
2 changes: 2 additions & 0 deletions js/removeCSs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$("span:contains('Busy')");
console.log($("span:contains('Busy')");

0 comments on commit fdb575b

Please sign in to comment.