$MAPPED_PROCESSED["fk_instructional_method_id"] = $medbiq_instructional_method->getID(); $MAPPED_PROCESSED["updated_date"] = time(); $MAPPED_PROCESSED["updated_by"] = $ENTRADA_USER->getID(); foreach ($PROCESSED["event_types"] as $event_type_id) { $mapped_event_types = Models_Event_MapEventsEventType::fetchAllByEventTypeID($event_type_id); if ($mapped_event_types) { foreach ($mapped_event_types as $event_type) { if (!$event_type->delete()) { //add_error("There was a problem mapping event types. The system administrator was informed of this error; please try again later."); application_log("error", "There was an error editing event mapping within medbiquitous instructional resources. Database said: " . $db->ErrorMsg()); } } } $MAPPED_PROCESSED["fk_eventtype_id"] = (int) $event_type_id; $mapped_event_type = new Models_Event_MapEventsEventType($MAPPED_PROCESSED); if (!$mapped_event_type->insert()) { add_error("There was a problem inserting this instructional method into the system. The system administrator was informed of this error; please try again later. " . $db->ErrorMsg()); application_log("error", "There was an error inserting an instructional method. Database said: " . $db->ErrorMsg()); } } } if (!$ERROR) { $url = ENTRADA_URL . "/admin/settings/manage/medbiqinstructional?org=" . $ORGANISATION_ID; $SUCCESS++; $SUCCESSSTR[] = "You have successfully added <strong>" . html_encode($PROCESSED["instructional_method"]) . "</strong> to the system.<br /><br />You will now be redirected to the Event Types index; this will happen <strong>automatically</strong> in 5 seconds or <a href=\"" . $url . "\" style=\"font-weight: bold\">click here</a> to continue."; $ONLOAD[] = "setTimeout('window.location=\\'" . $url . "\\'', 5000)"; application_log("success", "New Medbiquitous Instructional Method [" . $PROCESSED["instructional_method"] . "] added to the system."); } } else { $ERROR++; $ERRORSTR[] = "There was a problem inserting this instructional method into the system. The system administrator was informed of this error; please try again later.";
application_log("error", "An error occured while attempting to delete the organisation eventtype " . $eto->getEventTypeID() . " DB said: " . $db->ErrorMsg()); add_error("An error while attempting to delete the organisation event type"); } else { $eto->setEventTypeID($eventtype_id); if (!$eto->insert()) { application_log("error", "An error occured while attempting to insert the organisation eventtype " . $eto->getEventTypeID() . " DB said: " . $db->ErrorMsg()); add_error("An error while attempting to insert the organisation event type"); } } $mapped_instructional_method = Models_Event_MapEventsEventType::fetchRowByEventTypeID($PROCESSED["eventtype_id"]); if ($mapped_instructional_method) { $mapped_instructional_method->delete(); } if (isset($PROCESSED["medbiq_instructional_method_id"])) { $mapped_method = new Models_Event_MapEventsEventType(array("fk_instructional_method_id" => $PROCESSED["medbiq_instructional_method_id"], "fk_eventtype_id" => $eventtype_id, "updated_date" => time(), "updated_by" => $ENTRADA_USER->getID())); if (!$mapped_method->insert()) { application_log("error", "An error occured while attempting to insert the medbiq instructional method " . $mapped_method->getID() . " DB said: " . $db->ErrorMsg()); add_error("An error occured while attempting to save the selected medbiq instructional method " . $db->ErrorMsg()); } } // we need a list of event_ids that are associated with this eventtype_id $query = "\tSELECT b.`event_id`, c.*\n FROM `courses` AS a\n LEFT JOIN `events` AS b\n ON a.`course_id` = b.`course_id`\n LEFT JOIN `event_eventtypes` AS c\n ON b.`event_id` = c.`event_id`\n WHERE a.`organisation_id` = " . $db->qstr($ORGANISATION_ID) . "\n AND c.`eventtype_id` = " . $db->qstr($PROCESSED["eventtype_id"]); $events_list = $db->GetAssoc($query); if ($events_list) { foreach ($events_list as $event_id => $event) { $event_eventtype = new Models_Event_EventType(array("eeventtype_id" => $event["eeventtype_id"], "event_id" => $event_id, "eventtype_id" => $eventtype_id, "duration" => $event["duration"])); $event_eventtype->update(); } } } else { application_log("error", "An error occured while attempting to insert the eventtype " . $PROCESSED["eventtype_id"] . " DB said: " . $db->ErrorMsg());