</div> <div id="location_bar"><?php echo $_SESSION['location_bar']; ?> </div> <div id="content" style="text-align:center"> <?php /* ------------------------------------------------<< BEGIN CONTENT >>-------------------------------------------------------------*/ //Determine whether to show rappels for the whole REGION, the current CREW, the selected HRAP, or a specific OPERATION $zoom_level = false; try { $op = new operation(); isset($_GET['op']) ? $op->load($_GET['op']) : $op->load(false); } catch (Exception $e) { /* No OPERATION was specified - check for REGION or CREW_ID below */ } if ($op->get('id') !== NULL) { $zoom_level = 'operation'; } elseif (isset($_SESSION['current_view']['region']) && $_SESSION['current_view']['region'] !== NULL) { if (isset($_SESSION['current_view']['crew']) && $_SESSION['current_view']['crew'] !== NULL) { if ($_SESSION['current_view']['hrap'] !== NULL && $_SESSION['current_view']['hrap']->get('id') !== NULL) { $zoom_level = 'hrap'; } else { $zoom_level = 'crew'; } } else { $zoom_level = 'region'; }
function update_operation_in_db() { try { $success_message = ""; $date_array = explode('/', $_POST['date']); $year = $date_array[2]; $op = new operation(); $op->load($_GET['op']); $op->set('date', $_POST['date']); $op->set('type', $_POST['operation_type']); if ($_POST['operation_type'] == 'operational') { $op->set('incident_number', $_POST['inc_1'] . "-" . $_POST['inc_2'] . "-" . $_POST['inc_3']); } $op->set('height', $_POST['height']); $op->set('canopy_opening', $_POST['canopy_opening']); //$op->set('weather', $_POST['weather']); $op->set('location', $_POST['location']); //$op->set('comments', $_POST['comments']); $op->set('pilot_name', $_POST['pilot_name']); $op->set('aircraft_type', $_POST['aircraft_type']); $op->set('aircraft_configuration', $_POST['configuration']); $op->set('aircraft_tailnumber', $_POST['tailnumber']); $op->set('spotter', $_POST['name_spotter_id']); $op->save(); // Enter the info we have so far. This will also set the operation_id from the autoincrement database ID, which we need to bind each rappel below // Create a RAPPEL OBJECT for each rappel that was $_POST'ed. // We can use the NAME field ($_POST['name_stick1_left_text']) to tell if a rappel is populated or not // because we have already checked for partially-completed rappel boxes. So if the NAME field is filled out, we // know that the rest of the required information for that rappel is also present. $stick_options = array(1, 2, 3); $door_options = array('left', 'right'); foreach ($stick_options as $stick) { foreach ($door_options as $door) { $position = 'stick' . $stick . '_' . $door; $stick_name = 'name_' . $position . '_text'; if (isset($_POST[$stick_name]) && $_POST[$stick_name] != "") { $hrap = new hrap(); $hrap->load($_POST['name_' . $position . '_id']); if ($_SESSION['current_user']->get('account_type') == 'crew_admin' && $hrap->get_crew_by_year($year) == $_SESSION['current_user']->get('crew_affiliation_id') || $_SESSION['current_user']->get('account_type') == 'admin') { $new_rap = new rappel(); try { $new_rap->load($op->get_rappel($stick, $door)->get('id')); } catch (Exception $e) { /* If the requested rappel does not already exist, the rappel object will be CREATED instead of MODIFIED */ } $new_rap->set('operation_id', $op->get('id')); // Associate this rappel with the operation $new_rap->set('hrap_id', $_POST['name_' . $position . '_id']); $new_rap->set('genie', $_POST['genie_' . $position . '_id']); $new_rap->set('rope', $_POST['rope_' . $position . '_id']); $new_rap->set('rope_end', $_POST['rope_' . $position . '_end']); if (isset($_POST['knot_' . $position])) { $new_rap->set('knot', $_POST['knot_' . $position]); } if (isset($_POST['eto_' . $position])) { $new_rap->set('eto', $_POST['eto_' . $position]); } $new_rap->set('comments', $_POST['comments_' . $position]); $new_rap->set('stick', $stick); $new_rap->set('door', $door); $new_rap->save(); // Save this rappel to the database } } // End: if($_POST[$stick_name] != "") } // End: foreach($door_options) } // End: foreach($stick_options) // Add each $_POST'ed Letdown Line ID to the $new_op->letdowns array for ($ldid = 1; $ldid <= 6; $ldid++) { if ($_POST['letdown_' . $ldid . '_id'] != "") { $op->add_letdown($_POST['letdown_' . $ldid . '_id']); } } $op->save(); // Commit this entire OPERATION to the database $success_message = "All rappel information was successfully added to the database!"; return $success_message; } catch (Exception $e) { //throw new Exception($e->getMessage()); // Re-Throw any exceptions to the calling function if ($op->get('id') != NULL) { $op_id = $op->get('id'); } else { $op = false; } delete_partial_entry($op_id); // Cancel the transaction - delete partial entries throw new Exception($e->getMessage()); return 0; } }