/** * Function to create the appointment, scrub the database, and send out an email confirmation * * User interaction is complete * **/ public function anyConfirmed() { // When this boolean is set to True, instead of deleting all appointment times for the package duration // It will instead remove all times up to the end of the day, and continue to the next day until the package // time is done. $overlapDays = FALSE; $info = Session::get('appointmentInfo'); $startTime = new DateTime($info['datetime']); $endTime = new DateTime($info['datetime']); date_add($endTime, date_interval_create_from_date_string($info['package_time'] . ' hours')); $newCustomer = Customer::addCustomer(); $startTime = $startTime->format('Y-m-d H:i'); $endTime = $endTime->format('Y-m-d H:i'); // Create the appointment with this new customer id Appointment::addAppointment($newCustomer); if ($overlapDays) { // Remove hours up to the last hour of the day, then continue to the next day // If necessary // PSEUDO CODE // We will get the last appointment of the day and see if it's smaller than the package time // If the last appointment occurs beyond the package duration, we delete like normal // If the last appointment occurs before the package duration // We subtract the hours we remove from the package duration to get remaining time // Then we go to the next day with appointment times and remove enough appointments // To make clearance for the package duration. } else { // Remove all dates conflicting with the appointment duration BookingDateTime::timeBetween($startTime, $endTime)->delete(); } return View::make('success'); }