function commit_letdown_line() { // Load letdown_line details into the form memory $_SESSION['form_memory']['letdown_line'][0] = mydb::cxn()->real_escape_string($_POST['id']); $_SESSION['form_memory']['letdown_line'][1] = mydb::cxn()->real_escape_string($_POST['letdown_line_num1']) . "-" . mydb::cxn()->real_escape_string($_POST['letdown_line_num2']); $_SESSION['form_memory']['letdown_line'][2] = mydb::cxn()->real_escape_string($_POST['crew_affiliation_id']); $_SESSION['form_memory']['letdown_line'][3] = mydb::cxn()->real_escape_string($_POST['crew_affiliation_name']); $_SESSION['form_memory']['letdown_line'][4] = mydb::cxn()->real_escape_string($_POST['in_service_date']); $_SESSION['form_memory']['letdown_line'][5] = mydb::cxn()->real_escape_string($_POST['retired_date']); $_SESSION['form_memory']['letdown_line'][6] = mydb::cxn()->real_escape_string($_POST['retired_reason']); $_SESSION['form_memory']['letdown_line'][7] = mydb::cxn()->real_escape_string($_POST['retired_category']); $_SESSION['form_memory']['letdown_line'][8] = mydb::cxn()->real_escape_string($_POST['status']); // This function is called within a try/catch block - let any exceptions thrown by the letdown_line class return to the caller $eq = new letdown_line(); $eq->load($_SESSION['form_memory']['letdown_line'][0]); $eq->set('serial_num', $_SESSION['form_memory']['letdown_line'][1]); $eq->set('crew_affiliation_id', $_SESSION['form_memory']['letdown_line'][2]); $eq->set('in_service_date', $_SESSION['form_memory']['letdown_line'][4]); $eq->set('retired_date', $_SESSION['form_memory']['letdown_line'][5]); $eq->set('retired_reason', $_SESSION['form_memory']['letdown_line'][6]); $eq->set('retired_category', $_SESSION['form_memory']['letdown_line'][7]); $eq->set('status', $_SESSION['form_memory']['letdown_line'][8]); $eq->save(); return true; // Success }
function add_letdown($letdown_line_id) { // This function will add a letdown line object to the local $letdowns array ($this->letdowns) try { $new_letdown = new letdown_line(); $new_letdown->load($letdown_line_id); //$this->letdowns[] = $temp_letdown; // Only add the new letdown line to this member array if no exceptions were thrown $duplicate_index = NULL; // If the new Letdown Line ID matches a letdown line ID already associated with this operation, overwrite the existing Letdown Line (as an update) for ($i = 0; $i < sizeof($this->letdowns); $i++) { if ($this->letdowns[$i]->get('id') == $new_letdown->get('id')) { $duplicate_index = $i; } } if ($duplicate_index !== NULL) { $this->letdowns[$duplicate_index] = $new_letdown; } elseif (sizeof($this->letdowns) >= 6) { throw new Exception('You cannot have more than 6 letdowns in one Operation'); } else { $this->letdowns[] = $new_letdown; } // Append the new rappel to the $rappels array } catch (Exception $e) { throw new Exception($e->getMessage()); // Re-Throw any exception that was thrown in the try block return 0; } return 1; }