Exemplo n.º 1
0
 public function update()
 {
     global $db;
     if ($db->AutoExecute("`logbook_entries`", $this->toArray(), "UPDATE", "`lentry_id` = " . $db->qstr($this->getID()))) {
         $existing_objectives = Models_Logbook_Entry_Objective::fetchAll($this->getID());
         foreach ($this->getObjectives() as $objective) {
             if (!isset($existing_objectives[$objective->getObjectiveID()])) {
                 $objective->insert();
             } elseif ($existing_objectives[$objective->getObjectiveID()]->getParticipationLevel() != $objective->getParticipationLevel()) {
                 $existing_objectives[$objective->getObjectiveID()]->setParticipationLevel($objective->getParticipationLevel());
                 $existing_objectives[$objective->getObjectiveID()]->update();
             }
         }
         foreach ($existing_objectives as $existing_objective) {
             if (!$this->attachedObjectiveIsDuplicate($existing_objective->getObjectiveID())) {
                 $existing_objective->delete();
             }
         }
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * Non-required field "objectives" / objectives
  */
 if (is_array($_POST["objectives"]) && count($_POST["objectives"]) && @count($_POST["objectives"]) == @count($_POST["obj_participation_level"])) {
     foreach ($_POST["objectives"] as $objective_id) {
         $objective = Models_Objective::fetchRow($objective_id);
         if ($objective) {
             $objective_array = array();
             $objective_array["objective"] = $objective;
             $objective_array["objective_id"] = $objective_id;
             $objective_array["lentry_id"] = isset($entry_id) && $entry_id ? $entry_id : NULL;
             $objective_array["participation_level"] = isset($_POST["obj_participation_level"][$objective_id]) && $_POST["obj_participation_level"][$objective_id] ? $_POST["obj_participation_level"][$objective_id] : 3;
             $objective_array["updated_date"] = time();
             $objective_array["updated_by"] = $ENTRADA_USER->getID();
             $objective_array["objective_active"] = 1;
             $entry_objective = new Models_Logbook_Entry_Objective();
             $PROCESSED["objectives"][$objective_id] = $entry_objective->fromArray($objective_array);
         }
     }
 }
 if (!$ERROR) {
     $PROCESSED["proxy_id"] = $ENTRADA_USER->getID();
     $PROCESSED["updated_by"] = $ENTRADA_USER->getID();
     $PROCESSED["updated_date"] = time();
     if (defined("EDIT_ENTRY") && EDIT_ENTRY) {
         if ($entry->fromArray($PROCESSED)->update()) {
             add_success("The entry has successfully been updated. You will be redirected to the logbook index in 5 seconds, or you can <a href=\"" . ENTRADA_URL . "/logbook\">click here</a> if you do not wish to wait.");
             add_statistic("encounter_tracking", "update", "lentry_id", $PROCESSED["lentry_id"], $ENTRADA_USER->getID());
         } else {
             add_error("An error occurred when attempting to update a logbook entry [" . $PROCESSED["lentry_id"] . "], an administrator has been informed, please try again later.");
             application_log("error", "Error occurred when updating logbook entry, DB said: " . $db->ErrorMsg());