Esempio n. 1
0
         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());
     add_error("An error while attempting to insert the event type");