function scheduler_save_slotform(scheduler_instance $scheduler, $course, $slotid, $data) { global $DB; if ($slotid) { $slot = scheduler_slot::load_by_id($slotid, $scheduler); } else { $slot = new scheduler_slot($scheduler); } // Set data fields from input form. $slot->starttime = $data->starttime; $slot->duration = $data->duration; $slot->exclusivity = $data->exclusivityenable ? $data->exclusivity : 0; $slot->teacherid = $data->teacherid; $slot->notes = $data->notes['text']; $slot->notesformat = $data->notes['format']; $slot->appointmentlocation = $data->appointmentlocation; $slot->hideuntil = $data->hideuntil; $slot->emaildate = $data->emaildate; $slot->timemodified = time(); $currentapps = $slot->get_appointments(); $processedstuds = array(); for ($i = 0; $i < $data->appointment_repeats; $i++) { if ($data->studentid[$i] > 0) { $app = null; foreach ($currentapps as $currentapp) { if ($currentapp->studentid == $data->studentid[$i]) { $app = $currentapp; $processedstuds[] = $currentapp->studentid; } } if ($app == null) { $app = $slot->create_appointment(); $app->studentid = $data->studentid[$i]; } $app->attended = isset($data->attended[$i]); $app->appointmentnote = $data->appointmentnote[$i]['text']; $app->appointmentnoteformat = $data->appointmentnote[$i]['format']; if (isset($data->grade)) { $selgrade = $data->grade[$i]; $app->grade = $selgrade >= 0 ? $selgrade : null; } } } foreach ($currentapps as $currentapp) { if (!in_array($currentapp->studentid, $processedstuds)) { $slot->remove_appointment($currentapp); } } $slot->save(); }
function scheduler_save_slotform(scheduler_instance $scheduler, $course, $slotid, $data) { global $DB, $COURSE; $courseid = $COURSE->id; //echo "Course ID: ".$courseid."<br>"; if ($slotid) { $slot = scheduler_slot::load_by_id($slotid, $scheduler); $slot->slotid = $slotid; } else { $slot = new scheduler_slot($scheduler); } //echo "<pre>"; //print_r($data); //echo "</pre>"; //die(); // Set new data from input form. $slot->starttime = $data->starttime; $slot->duration = $data->duration; $slot->teacherid = $data->teacherid; $slot->notes = $data->notes['text']; $slot->exclusivity = $data->exclusivity; $slot->emaildate = $data->emaildate; $slot->notesformat = $data->notes['format']; $slot->appointmentlocation = $data->appointmentlocation; $slot->hideuntil = $data->hideuntil; $slot->emaildate = $data->emaildate; $slot->timemodified = time(); $currentapps = $slot->get_appointments(); $processedstuds = array(); for ($i = 0; $i < $data->appointment_repeats; $i++) { if ($data->studentid[$i] > 0) { $app = null; foreach ($currentapps as $currentapp) { if ($currentapp->studentid == $data->studentid[$i]) { $app = $currentapp; $processedstuds[] = $currentapp->studentid; } } if ($app == null) { $app = $slot->create_appointment(); $app->studentid = $data->studentid[$i]; } $app->attended = isset($data->attended[$i]); $app->appointmentnote = $data->appointmentnote[$i]['text']; $app->appointmentnoteformat = $data->appointmentnote[$i]['format']; if (isset($data->grade)) { $selgrade = $data->grade[$i]; $app->grade = $selgrade >= 0 ? $selgrade : null; } } } foreach ($currentapps as $currentapp) { if (!in_array($currentapp->studentid, $processedstuds)) { $slot->remove_appointment($currentapp); } } // Add additional slot for other course if ($courseid == 44 || $courseid == 45) { $ds = new Schedule(); if ($courseid == 44) { // Add same slot for Phlebotomy with EKG Workshop course $schedulerid = 5; } // end if $courseid==44 if ($courseid == 45) { // Add same slot for Phlebotomy Workshop course $schedulerid = 6; } $slot->schedulerid = $schedulerid; $ds->save_additional_slot($slot); //die('Stopped'); } // end if $courseid == 44 || $courseid == 45 // Saves original slot $slot->save(); // Notify non Phleb workshop users // other users notified inside save_additional_slot() if ($courseid != 44 && $courseid != 45) { if (property_exists($slot, 'slotid')) { $slots_array = array($slot->slotid); $ds->notify_students($slots_array); } } }