Exemplo n.º 1
0
 function set($var, $value)
 {
     $value = mydb::cxn()->real_escape_string($value);
     switch ($var) {
         case 'serial_num':
             // The Serial Number of an item is not restricted to any subset of characters. Any string is allowed, provided that it fits into the allowed VARCHAR space in the database
             if ($this->is_duplicate($value)) {
                 throw new Exception('That serial number (' . strtoupper($value) . ') is already being used for an item of type \'' . $this->item_type . '\'');
             } else {
                 $this->serial_num = $value;
             }
             break;
         case 'item_type':
             $this->item_type = $value;
             break;
         case 'color':
             $this->color = $value;
             break;
         case 'size':
             $this->size = $value;
             break;
         case 'description':
             $this->description = $value;
             break;
         case 'condition':
             $this->condition = $value;
             break;
         case 'note':
             $this->note = $value;
             break;
         case 'crew_affiliation_id':
             if (!is_numeric($value) || !(intval($value) == floatval($value))) {
                 throw new Exception('A non-integer Crew ID was passed to item->set().');
             } else {
                 if (!crew::exists($value)) {
                     throw new Exception('The Item cannot be affiliated with Crew #' . $value . ' because that Crew does not exist.');
                 } else {
                     $this->crew_affiliation_id = $value;
                     $this->crew_affiliation_name = crew::get_name($value);
                 }
             }
             break;
         case 'status':
             if (in_array(strtolower($value), $this->valid_status)) {
                 $this->status = strtolower($value);
             } else {
                 throw new Exception('The item->set() function attempted to set an invalid \'status\' (' . $value . ')');
             }
             break;
         default:
             throw new Exception('The item->set() function attempted to modify an invalid variable (' . $var . ')');
             break;
     }
     // End: switch($var)
 }
Exemplo n.º 2
0
require_once "classes/crew_class.php";
session_name('raprec');
session_start();
require_once "includes/constants.php";
// Force 'constants.php' to load, even if it has been previously included by one of the classes above.  Must set SESSION vars AFTER the session_start() declaration.
require_once "includes/auth_functions.php";
require_once "includes/check_get_vars.php";
require_once "includes/make_menu.php";
require_once "includes/photo_upload_functions.php";
// Make sure this user is allowed to access this page
if ($_SESSION['logged_in'] == 1 && check_access("crew_admin", $_GET['crew'])) {
    // ACCESS GRANTED!
    // Attempt to load the specified crew
    try {
        global $crew;
        $crew = new crew();
        $crew->load($_GET['crew']);
    } catch (Exception $e) {
        if ($_SESSION['current_user']->get('account_type') == 'admin') {
            //echo "admin";
            if ($_GET['function'] != 'no_crew_specified') {
                header('location: ' . $_SERVER['PHP_SELF'] . '?function=no_crew_specified');
            }
        } else {
            header('location: index.php');
        }
    }
} else {
    // ACCESS DENIED!
    store_intended_location();
    //Redirect user back to their intended location after they log in
Exemplo n.º 3
0
// The amount of equipment to display ('crew', 'region')
// Determine whether to show ROPE, GENIE or LETDOWN_LINE records
if (isset($_GET['eq_type']) && in_array(strtolower($_GET['eq_type']), array('rope', 'genie', 'letdown_line'))) {
    $eq_type = strtolower($_GET['eq_type']);
    try {
        $eq = new $eq_type();
        if (isset($_GET['eq_id']) && $_GET['eq_id'] != "") {
            $eq->load($_GET['eq_id']);
        } else {
            $eq->load(false);
        }
    } catch (Exception $e) {
        /* An equipment type was specified, but not a specific equipment ID - show cumulatives for this eq_type */
        // Determine whether to show equipment records for a particular CREW or an entire REGION
        try {
            $zoom_obj = new crew();
            // $zoom_obj will become either a CREW OBJECT or a REGION ID, depending on $zoom_level
            isset($_GET['crew']) ? $zoom_obj->load($_GET['crew']) : $zoom_obj->load(false);
            $zoom_level = 'crew';
        } catch (Exception $e) {
            /* No CREW was specified - check for a preselected CREW in the 'current_view' SESSION var */
            try {
                if ($_SESSION['current_view']['crew'] != NULL) {
                    $zoom_obj->load($_SESSION['current_view']['crew']->get('id'));
                } else {
                    throw new Exception('This exception is meant solely to trigger the following catch block');
                }
                $zoom_level = 'crew';
            } catch (Exception $e) {
                /* No CREW selection was stored in the SESSION - check for a REGION selection*/
                if (isset($_SESSION['current_view']['region']) && $_SESSION['current_view']['region'] !== NULL) {
Exemplo n.º 4
0
function make_menu()
{
    /******* PROCESS LOGIN ATTEMPT ***************************/
    /*
    		if(isset($_POST['username']) && isset($_POST['passwd'])) $login_result = login($_POST['username'], $_POST['passwd']);
    		elseif(!isset($_SESSION['logged_in']) && !isset($login_result)) $login_result = array(-1,"No login attempt made yet");
    		else $login_result = array(-1,"No login attempt made yet");
    */
    /******* MAKE LOCATION BAR ***************************/
    if (isset($_GET['year']) && check_year($_GET['year'])) {
        $_SESSION['current_view']['year'] = $_GET['year'];
    } elseif (!isset($_SESSION['current_view']['year'])) {
        $_SESSION['current_view']['year'] = date('Y');
    }
    if (!isset($_SESSION['mobile'])) {
        $_SESSION['mobile'] = false;
    }
    $current_file = explode('/', $_SERVER['PHP_SELF']);
    $current_file = strtolower($current_file[sizeof($current_file) - 1]);
    // Get the filename of the script that called this function (no path info, just the filename)
    $region = NULL;
    $crew = new crew();
    $hrap = new hrap();
    $op = NULL;
    try {
        //This exception below is meant solely to trigger the 'catch' block.  The message is never displayed to the user.
        if ($current_file == "index.php" || $current_file == "proficiency_report.php") {
            throw new Exception('You cannot specify an individual HRAP on the index or proficiency page.');
        }
        isset($_GET['hrap']) ? $hrap->load($_GET['hrap']) : $hrap->load(false);
        $crew->load($hrap->get_crew_by_year($_SESSION['current_view']['year']));
        $_SESSION['current_view']['hrap'] = $hrap;
        if (isset($crew->id)) {
            $_SESSION['current_view']['region'] = $crew->region;
            $_SESSION['current_view']['crew'] = $crew;
            $_SESSION['location_bar'] = "Location: <a href=\"./index.php\">Home</a>";
            $_SESSION['location_bar'] .= " / <a href=\"./" . $current_file . "?region=" . $crew->region . "\">R" . $crew->region . "</a>";
            $_SESSION['location_bar'] .= " / <a href=\"./" . $current_file . "?region=" . $crew->region . "&crew=" . $crew->id . "\">" . $crew->name . "</a>";
            $_SESSION['location_bar'] .= " / <a href=\"./" . $current_file . "?region=" . $crew->region . "&crew=" . $crew->id . "&hrap=" . $hrap->id . "\">" . $hrap->name . "</a>";
        } else {
            /* The requested HRAP is not assigned to a crew for the requested year, maintain the previous 'current_view' (do nothing)*/
        }
    } catch (Exception $e) {
        if (isset($_GET['eq_type'])) {
            // The current view is on a piece of equipment, retain CREW and REGION but reset all other 'current_view' parameter
            $_SESSION['location_bar'] = "Location: <a href=\"./index.php\">Home</a>";
            if (isset($_GET['eq_id'])) {
                try {
                    $eq = new $_GET['eq_type']();
                    $eq->load($_GET['eq_id']);
                    $_SESSION['current_view']['crew'] = new crew();
                    $_SESSION['current_view']['crew']->load($eq->get('crew_affiliation_id'));
                    $result = mydb::cxn()->query("SELECT region FROM crews WHERE id = " . $eq->get('crew_affiliation_id'));
                    $row = $result->fetch_assoc();
                    $_SESSION['current_view']['region'] = $row['region'];
                    $_SESSION['location_bar'] .= " / <a href=\"view_equipment.php?eq_type=" . $_GET['eq_type'] . "&region=" . $_SESSION['current_view']['region'] . "\">R" . $_SESSION['current_view']['region'] . "</a>" . " / <a href=\"view_equipment.php?eq_type=" . $_GET['eq_type'] . "&crew=" . $_SESSION['current_view']['crew']->get('id') . "\">" . $_SESSION['current_view']['crew']->get('name') . "</a>" . " / <a href=\"view_equipment.php?crew=" . $_SESSION['current_view']['crew']->get('id') . "\">Equipment</a>";
                } catch (Exception $e) {
                }
            } elseif (isset($_GET['crew']) && check_crew($_GET['crew'])) {
                $crew->load($_GET['crew']);
                $_SESSION['current_view']['region'] = $crew->get('region');
                $_SESSION['current_view']['crew'] = $crew;
                $_SESSION['location_bar'] .= " / <a href=\"view_equipment.php?eq_type=" . $_GET['eq_type'] . "&region=" . $_SESSION['current_view']['region'] . "\">R" . $_SESSION['current_view']['region'] . "</a>" . " / <a href=\"view_equipment.php?eq_type=" . $_GET['eq_type'] . "&crew=" . $_SESSION['current_view']['crew']->get('id') . "\">" . $_SESSION['current_view']['crew']->get('name') . "</a>" . " / <a href=\"view_equipment.php?crew=" . $_SESSION['current_view']['crew']->get('id') . "\">Equipment</a>";
            } elseif (isset($_GET['region']) && is_valid_region($_GET['region'])) {
                $_SESSION['current_view']['region'] = $_GET['region'];
                $_SESSION['location_bar'] .= " / <a href=\"view_equipment.php?eq_type=" . $_GET['eq_type'] . "&region=" . $_SESSION['current_view']['region'] . "\">R" . $_SESSION['current_view']['region'] . "</a>" . " / <a href=\"view_equipment.php?region=" . $_SESSION['current_view']['region'] . "\">Equipment</a>";
                $_SESSION['current_view']['crew'] = NULL;
            }
            $_SESSION['current_view']['hrap'] = NULL;
            $_SESSION['current_view']['op'] = NULL;
        } elseif (isset($_GET['crew']) && check_crew($_GET['crew'])) {
            try {
                $crew->load($_GET['crew']);
            } catch (Exception $e) {
            }
            $_SESSION['current_view']['region'] = $crew->get('region');
            $_SESSION['current_view']['crew'] = $crew;
            $_SESSION['location_bar'] = "Location: <a href=\"./index.php\">Home</a>";
            if ($current_file != "modify_roster.php") {
                $_SESSION['location_bar'] .= " / <a href=\"./" . $current_file . "?region=" . $crew->get('region') . "\">R" . $crew->get('region') . "</a>";
            } else {
                $_SESSION['location_bar'] .= " / <a href=\"./index.php?region=" . $crew->get('region') . "\">R" . $crew->get('region') . "</a>";
            }
            $_SESSION['location_bar'] .= " / <a href=\"./" . $current_file . "?region=" . $crew->get('region') . "&crew=" . $crew->get('id') . "\">" . $crew->get('name') . "</a>";
            if ($current_file == "proficiency_report.php") {
                $_SESSION['location_bar'] .= " / Proficiency Report";
            }
            // Clear the unknown 'current_view' elements
            $_SESSION['current_view']['hrap'] = NULL;
            $_SESSION['current_view']['op'] = NULL;
        } elseif (isset($_GET['region']) && is_valid_region($_GET['region'])) {
            $region = $_GET['region'];
            $_SESSION['current_view']['region'] = $region;
            $_SESSION['location_bar'] = "Location: <a href=\"./index.php\">Home</a>";
            $_SESSION['location_bar'] .= " / <a href=\"./" . $current_file . "?region=" . $region . "\">R" . $region . "</a>";
            if ($current_file == "proficiency_report.php") {
                $_SESSION['location_bar'] .= " / Proficiency Report";
            }
            // Clear the unknown 'current_view' elements
            $_SESSION['current_view']['crew'] = NULL;
            $_SESSION['current_view']['hrap'] = NULL;
            $_SESSION['current_view']['op'] = NULL;
        } elseif (isset($_GET['op']) && operation::exists($_GET['op'])) {
            // If a specific OPERATION is being viewed (and none of the above criteria were met), there is a mix of different CREWS, HRAPS, and possibly REGIONS...
            // So just maintain the same location bar that was shown before the user accessed this page
            $op = $_GET['op'];
            // DO NOTHING
        } elseif ($current_file == "proficiency_report.php") {
            // Viewing the proficiency report, but no Crew or Region has been specified.
            // 1st - Look for pre-existing crew or region in the $_SESSION['current_view'] array
            // 2nd - Try to determine the current user's crew and use that
            // 3rd - Display the page with no parameters - the page will show an error and offer a link to the Home page
            if (isset($_SESSION['current_view']['crew'])) {
                $crew = $_SESSION['current_view']['crew'];
                $region = $crew->get('region');
                $_SESSION['current_view']['region'] = $region;
                $_SESSION['location_bar'] = "Location: <a href=\"./index.php\">Home</a>";
                $_SESSION['location_bar'] .= " / <a href=\"" . $current_file . "?region=" . $region . "\">R" . $region . "</a>";
                $_SESSION['location_bar'] .= " / <a href=\"./" . $current_file . "?region=" . $crew->get('region') . "&crew=" . $crew->get('id') . "\">" . $crew->get('name') . "</a>";
                $_SESSION['location_bar'] .= " / Proficiency Report";
                // Clear the unknown 'current_view' elements
                $_SESSION['current_view']['hrap'] = NULL;
                $_SESSION['current_view']['op'] = NULL;
            } elseif (isset($_SESSION['current_view']['region'])) {
                $region = $_SESSION['current_view']['region'];
                $_SESSION['location_bar'] = "Location: <a href=\"./index.php\">Home</a>";
                $_SESSION['location_bar'] .= " / <a href=\"" . $current_file . "?region=" . $region . "\">R" . $region . "</a>";
                $_SESSION['location_bar'] .= " / Proficiency Report";
                // Clear the unknown 'current_view' elements
                $_SESSION['current_view']['crew'] = NULL;
                $_SESSION['current_view']['hrap'] = NULL;
                $_SESSION['current_view']['op'] = NULL;
            } elseif (isset($_SESSION['current_user']) && $_SESSION['current_user']->get('crew_affiliation_id') != false) {
                $crew = new crew();
                $crew->load($_SESSION['current_user']->get('crew_affiliation_id'));
                $region = $crew->get('region');
                $_SESSION['current_view']['crew'] = $crew;
                $_SESSION['current_view']['region'] = $region;
                $_SESSION['location_bar'] = "Location: <a href=\"./index.php\">Home</a>";
                $_SESSION['location_bar'] .= " / <a href=\"" . $current_file . "?region=" . $region . "\">R" . $region . "</a>";
                $_SESSION['location_bar'] .= " / <a href=\"./" . $current_file . "?region=" . $crew->get('region') . "&crew=" . $crew->get('id') . "\">" . $crew->get('name') . "</a>";
                $_SESSION['location_bar'] .= " / Proficiency Report";
                // Clear the unknown 'current_view' elements
                $_SESSION['current_view']['hrap'] = NULL;
                $_SESSION['current_view']['op'] = NULL;
            }
        } else {
            // Clear the unknown 'current_view' elements
            $_SESSION['location_bar'] = "Location: <a href=\"./index.php\">Home</a>";
            $_SESSION['current_view']['region'] = NULL;
            $_SESSION['current_view']['crew'] = NULL;
            $_SESSION['current_view']['hrap'] = NULL;
            $_SESSION['current_view']['op'] = NULL;
        }
    }
    // End: try/catch block
    /********************************************************************************************************************************/
    /*******************<< USER is not logged in (yet) >>****************************************************************************/
    if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] != 1) {
        //Initialize the current_user as a GUEST
        $_SESSION['current_user'] = new user('guest');
        /******* PROCESS LOGIN ATTEMPT ***************************/
        try {
            if (!isset($_POST['username']) || !isset($_POST['passwd'])) {
                throw new Exception('');
            }
            //No login attempt was made
            login($_POST['username'], $_POST['passwd']);
        } catch (Exception $e) {
            // If this block is reached, either no login attempt was made, or a login attempt failed with an exception.
            echo "<div id=\"left_sidebar_title\">Login</div>\n";
            echo "<form action=\"" . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] . "\" method=\"post\" style=\"margin:0; padding:0;\">\n" . "\t<table style=\"margin:0; padding:0;\">\n" . "\t\t<tr><td colspan=\"2\"><div id=\"login_result\">" . $e->getMessage() . "</div></td></tr>\n" . "\t\t<tr><td>Username:</td><td><input name=\"username\" type=\"text\" class=\"loginfield\" value=\"" . (isset($_POST['username']) ? $_POST['username'] : "") . "\" /></td></tr>\n" . "\t\t<tr><td>Password:</td><td><input name=\"passwd\" type=\"password\" class=\"loginfield\" /></td></tr>\n" . "\t\t<tr><td>&nbsp;</td><td style=\"text-align:right;\"><input type=\"submit\" value=\"Login\" class=\"form_button\" style=\"margin-right:0;\" /></td></tr>\n" . "\t</table>\n" . "</form>";
            echo "<hr><br>\n" . "<table>\n" . "\t<tr><td>You are viewing information for the following year:</td></tr>\n" . "\t<tr><td style=\"text-align:center;vertical-align:center;padding:0;\">\n" . "\t\t<form action=\"" . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] . "\" method=\"GET\" id=\"sidebar_year_form\" name=\"sidebar_year_form\">\n" . "\t\t<input name=\"year\" type=\"text\" value=\"" . $_SESSION['current_view']['year'] . "\" style=\"width:40px; height:1.3em; font-size:1.2em; font-weight:bold; margin:1px;\">\n";
            if ($region != NULL) {
                echo "<input type=\"hidden\" name=\"region\" value=\"" . $_GET['region'] . "\">\n";
            }
            if ($crew != NULL) {
                echo "<input type=\"hidden\" name=\"crew\" value=\"" . $crew->get('id') . "\">\n";
            }
            if ($hrap != NULL) {
                echo "<input type=\"hidden\" name=\"hrap\" value=\"" . $hrap->get('id') . "\">\n";
            }
            if ($op != NULL) {
                echo "<input type=\"hidden\" name=\"op\" value=\"" . $op . "\">\n";
            }
            if (isset($_GET['function']) && $_GET['function'] != '') {
                echo "<input type=\"hidden\" name=\"function\" value=\"" . $_GET['function'] . "\">\n";
            }
            echo "\t\t<input type=\"button\" value=\"Update\" class=\"form_button\" onClick=' document.forms.sidebar_year_form.submit();'>\n" . "\t\t</form>\n" . "\t\t</td>\n" . "\t</tr>\n" . "</table>\n" . "<br><hr>\n\n";
        }
    }
    /******* USER IS LOGGED IN*******************************************************************************************************/
    if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == 1) {
        echo "<div id=\"left_sidebar_title\">RapRec Menu</div>\n";
        echo "You are logged in as:<br />" . $_SESSION['current_user']->get('firstname') . " " . $_SESSION['current_user']->get('lastname') . "<br /><i>" . $_SESSION['current_user']->get('username') . "</i><br><br>\n";
        echo "<a href=\"index.php?logout=1" . (isset($_SESSION['mobile']) ? "&mobile=" . $_SESSION['mobile'] : "") . "\">Logout</a><br>";
        echo "<hr><br>\n" . "<table>\n" . "\t<tr><td>You are viewing information for the following year:</td></tr>\n" . "\t<tr><td>\n" . "\t\t<form action=\"" . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] . "\" method=\"GET\" id=\"sidebar_year_form\" name=\"sidebar_year_form\">\n" . "\t\t<input name=\"year\" id=\"sidebar_year\" type=\"text\" size=\"4\" value=\"" . $_SESSION['current_view']['year'] . "\" style=\"width:40px\">\n";
        if ($region != NULL) {
            echo "<input type=\"hidden\" name=\"region\" value=\"" . $_GET['region'] . "\">\n";
        }
        if ($crew != NULL) {
            echo "<input type=\"hidden\" name=\"crew\" value=\"" . $crew->get('id') . "\">\n";
        }
        if ($hrap != NULL) {
            echo "<input type=\"hidden\" name=\"hrap\" value=\"" . $hrap->get('id') . "\">\n";
        }
        if ($op != NULL) {
            echo "<input type=\"hidden\" name=\"op\" value=\"" . $op . "\">\n";
        }
        if (isset($_GET['function']) && $_GET['function'] != '') {
            echo "<input type=\"hidden\" name=\"function\" value=\"" . $_GET['function'] . "\">\n";
        }
        echo "<input type=\"button\" value=\"Update\" class=\"form_button\" onClick='document.forms.sidebar_year_form.submit();'></form></td></tr></table><br><hr>\n\n";
        /*
        		//Decide what to show in the 'Location Bar' when navigating to the 'update_rappels.php' page, since updating rappels is not a crew-dependent operation
        		if(isset($_SESSION['current_view']['crew']) && ($_SESSION['current_view']['crew']->get('id') != NULL)) $update_rappels_crew_id = $_SESSION['current_view']['crew']->get('id');
        		else $update_rappels_crew_id = $_SESSION['current_user']->get('crew_affiliation_id');
        */
        $crew_id = "";
        $crew_name = "None Selected";
        $region = "";
        if (isset($_SESSION['current_view']['crew'])) {
            $crew_id = $_SESSION['current_view']['crew']->get('id');
            $crew_name = $_SESSION['current_view']['crew']->get('name');
        }
        if (isset($_SESSION['current_view']['region'])) {
            $region = $_SESSION['current_view']['region'];
        }
        $academy_id = get_academy_id($region);
        echo "<h3>" . ucwords(str_replace("_", " ", $_SESSION['current_user']->get('account_type'))) . "</h3><br><br>\n" . "<ul class=\"sidebar_menu\">\n";
        echo "<li>Home\n" . "<ul>\n" . "\t<li><a href=\"index.php\">National Map</a></li>\n";
        if ($_SESSION['current_user']->get('crew_affiliation_id')) {
            echo "\t<li><a href=\"index.php?crew=" . $_SESSION['current_user']->get('crew_affiliation_id') . "\">My Crew</a></li>\n";
        }
        echo "<li><a href=\"weekly_report.php\">Weekly Report</a></li>\n";
        echo "</ul></li>\n";
        /*
        			if($crew_id != "") {
        				echo "<li><a href=\"modify_roster.php?crew=".$crew_id."\">Current Crew<br><small>(".$crew_name.")</small></a>\n"
        					."<ul>\n"
        					."	<li><a href=\"modify_roster.php?crew=".$crew_id."\">View / Edit Crewmembers</a></li>\n"
        					."	<li><a href=\"modify_roster.php?crew=".$crew_id."&function=add_hrap_menu\">Add Crewmembers</a></li>\n"
        					."</ul></li>\n\n";
        			}
        */
        if ($region != "" || $crew_id != "" || $_SESSION['current_user']->get('account_type') == 'crew_admin') {
            echo "<li>Rosters\n<ul>\n";
        }
        if ($region != "") {
            echo "\t<li><a href=\"index.php?region=" . $region . "\">Regional Crew List</a></li>\n";
        }
        if ($crew_id != "") {
            echo "\t<li><a href=\"index.php?region=" . $region . "&crew=" . $crew_id . "\">Crew Roster</a></li>\n";
        }
        if ($_SESSION['current_user']->get('account_type') == 'crew_admin') {
            echo "\t<li><a href=\"modify_roster.php?&crew=" . $_SESSION['current_user']->get('crew_affiliation_id') . "\">Modify My Roster</a></li>\n";
        }
        if ($crew_id != "" && $_SESSION['current_user']->get('account_type') == 'admin') {
            echo "\t<li><a href=\"modify_roster.php?&crew=" . $crew_id . "\">Modify This Roster</a></li>\n";
        }
        if ($region != "" || $crew_id != "" || $_SESSION['current_user']->get('account_type') == 'crew_admin') {
            echo "</ul></li>\n";
        }
        if (in_array($_SESSION['current_user']->get('account_type'), array('admin', 'crew_admin'))) {
            echo "\t<li>Rappel Records\n" . "\t<ul>\n" . "\t<li><a href=\"update_rappels.php?function=add_rappel\">Add a New Rappel</a></li>\n";
        } elseif ($crew_id != "" || $region != "") {
            echo "\t<li>Rappel Records\n" . "\t<ul>\n";
        }
        if ($crew_id != "" || $region != "") {
            echo "\t<li><a href=\"proficiency_report.php?region=" . $region . "\">Regional Proficiency Report</a></li>\n" . "\t<li><a href=\"view_rappels.php?region=" . $region . "\">Regional Rappels</a></li>\n";
        }
        if ($crew_id != "") {
            echo "\t<li><a href=\"proficiency_report.php?crew=" . $crew_id . "\">Crew Proficiency Report</a></li>\n" . "\t<li><a href=\"view_rappels.php?crew=" . $crew_id . "\">Crew Rappels</a></li>\n";
        }
        if ($crew_id != "" || $region != "" || in_array($_SESSION['current_user']->get('account_type'), array('admin', 'crew_admin'))) {
            echo "</ul></li>\n\n";
        }
        if ($crew_id != "" || $region != "") {
            echo "<li>Equipment\n" . "<ul>\n";
            if (in_array($_SESSION['current_user']->get('account_type'), array('admin', 'crew_admin'))) {
                echo "\t<li><a href=\"add_new_equipment.php?crew=" . $crew->get('id') . "\">Add New Equipment</a></li>\n";
            }
            echo "\t<li><a href=\"view_equipment.php?region=" . $region . "\">Regional Equipment</a></li>\n";
            if ($academy_id != false) {
                echo "\t<li><a href=\"view_equipment.php?crew=" . $academy_id . "&region=" . $region . "\">Academy Equipment</a></li>\n";
            }
            if ($crew_id != "") {
                echo "\t<li><a href=\"view_equipment.php?crew=" . $crew_id . "\">Crew Equipment</a></li>\n";
            }
            echo "</ul></li>\n\n";
        }
        echo "\t<li>Account Management\n" . "\t\t<ul><li><a href=\"account_management.php?function=edit_account&user_id=" . $_SESSION['current_user']->get('id') . "\">Edit My Account</a></li>\n";
        if (in_array($_SESSION['current_user']->get('account_type'), array('admin', 'crew_admin'))) {
            echo "\t\t<li><a href=\"account_management.php\">All Accounts</a></li>\n";
        }
        if (in_array($_SESSION['current_user']->get('account_type'), array('admin', 'crew_admin'))) {
            echo "\t\t<li><a href=\"account_management.php?function=create_account\">Create an Account</a></li></ul>\n";
        }
        echo "\t</li>\n";
        echo "</ul>\n\n";
    }
}
function show_proficiency_report($view_type = 'region', $id = false)
{
    // INPUTS:
    //	$view_type is either 'crew' or 'region', specifying the scope of the report
    //	$obj is either an integer region ID or a crew ID
    //
    // OUTPUT:
    //	This function prints the appropriate HTML page content to the screen.
    //	There is no return value.
    $rappel_platform = isset($_GET['rappel_platform']) ? $_GET['rappel_platform'] : 'bell_medium';
    if ($rappel_platform == 'bell_medium') {
        $aircraft_criteria = "(aircraft_types.type = '2' OR isNull(aircraft_types.type))";
    } else {
        $aircraft_criteria = "(aircraft_types.shortname = '" . $rappel_platform . "' OR isNull(aircraft_types.type))";
    }
    switch ($view_type) {
        case 'crew':
            $crew = new crew();
            $crew->load($id);
            $_SESSION['current_view']['crew'] = $crew;
            $roster_criteria = "rosters.crew_id = " . $id;
            $text = "<br /><div style=\"width:100%; text-align:left;\">\n" . "<h1>Proficiency Status</h1><br />\n" . "<h2>" . $crew->get('name') . " -- " . $_SESSION['current_view']['year'] . "</h2>\n" . "</div>\n";
            break;
        case 'region':
        default:
            if (!$id) {
                $id = 6;
            }
            //This shouldn't happen, but default to region 6 if inputs were incomplete
            $roster_criteria = "rosters.crew_id IN (SELECT id FROM crews WHERE region = " . $id . ")";
            $text = "<br /><div style=\"width:100%; text-align:left;\">\n" . "<h1>Proficiency Status</h1><br />\n" . "<h2>Region " . $id . " -- " . $_SESSION['current_view']['year'] . "</h2>\n" . "<hr style=\"width:100%\">" . "</div>\n";
            break;
    }
    // End: switch($view_type)
    $text .= build_rappel_platform_dropdown();
    $query = "\nSELECT \nhraps.id AS hrap_id, \nCONCAT( hraps.firstname,' ', hraps.lastname ) AS name, \nvr1.date, \nvr1.operation_id, \nvr1.aircraft_fullname, \nvr1.aircraft_type, \naircraft_types.shortname AS aircraft_shortname, \nDATEDIFF( NOW( ) , STR_TO_DATE( vr1.date,  '%m/%d/%Y') ) AS days_ago\n\nFROM \nhraps INNER JOIN rosters ON ((rosters.year = '" . $_SESSION['current_view']['year'] . "') AND (" . $roster_criteria . ") AND (hraps.id = rosters.hrap_id))\nLEFT OUTER JOIN view_rappels as vr1 ON hraps.id = vr1.hrap_id\nLEFT OUTER JOIN view_rappels as vr2 ON ((vr1.hrap_id = vr2.hrap_id) AND (STR_TO_DATE( vr1.date,  '%m/%d/%Y' ) < STR_TO_DATE( vr2.date,  '%m/%d/%Y' )))\nLEFT OUTER JOIN aircraft_types ON (\n\t\t(vr1.aircraft_type_id = aircraft_types.id) AND (" . $aircraft_criteria . ")\n\t\t)\nWHERE vr2.hrap_id IS NULL\nGROUP BY hraps.id\nORDER BY name";
    $result = mydb::cxn()->query($query);
    if (mydb::cxn()->affected_rows < 1) {
        $text .= "<br /><span class=\"error_msg\">This " . $view_type . " has no roster information for " . $_SESSION['current_view']['year'] . "</span>";
    } else {
        $text .= "<br>\n" . "<table class=\"alternating_rows\" style=\"width:100%; border:2px solid #555555;\">\n" . "<th>+</th>" . "<th>HRAP</th>" . "<th>Aircraft</th>" . "<th>Days Since Last Rap</th>" . "<th>Days Until Lapse</th>" . "<th>Status</th></tr>\n";
        $current_row = 0;
        while ($row = $result->fetch_assoc()) {
            $current_row++;
            //if($current_row % 2 == 0) $class = "class=\"evn\"";
            //else $class = "class=\"odd\"";
            $class = "class=\"odd\"";
            // Determine whether the current HRAP is proficient or not and HIGHLIGHT this row accordingly
            $highlight = "";
            $p_status = "Proficient";
            if ($row['days_ago'] > $_SESSION['proficiency_duration'] || $row['days_ago'] == "") {
                $highlight = "background-color:#ff6666;";
                // Highlight RED if HRAP is past proficiency date
                $p_status = "Not Proficient";
            } elseif ($row['days_ago'] > $_SESSION['proficiency_duration'] - 3) {
                $highlight = "background-color:#ffff66;";
            }
            // Highlight YELLOW if HRAP is within 3 days of proficiency date
            $text .= "<tr " . $class . " style=\"height:1.8em;" . $highlight . "\">\n" . "<td style=\"text-align:center;\">";
            if ($row['operation_id'] != "") {
                $text .= "<a href=\"view_rappels.php?&op=" . $row['operation_id'] . "&hrap=" . $row['hrap_id'] . "\"><img src=\"images/magnifying_glass.png\" style=\"margin:0;\"></a>";
            }
            $text .= "</td>" . "<td>" . $row['name'] . "</td>" . "<td>" . $row['aircraft_fullname'] . "</td>" . "<td style=\"text-align:center;\">" . $row['days_ago'] . "</td>" . "<td style=\"text-align:center;\">" . ($row['days_ago'] == "" ? "0" : max((int) $_SESSION['proficiency_duration'] - (int) $row['days_ago'], 0)) . "</td>" . "<td>" . $p_status . "</td>" . "</tr>\n\n";
        }
        $text .= "</table><br>\n\n";
        $text .= color_coding_legend();
    }
    // End: else [if(mydb::cxn()->affected_rows < 1)]
    echo $text;
}
Exemplo n.º 6
0
function show_crew_cumulatives()
{
    $crew = new crew();
    $crew->load($_SESSION['current_view']['crew']->get('id'));
    // Display Crew Cumulatives
    echo "<div style=\"text-align:center;\">\n";
    echo "<table style=\"margin:0 auto 0 auto;\">\n" . "<tr><td><img src=\"" . $crew->logo_filename . "\"></td>\n" . "<td><h1>" . $crew->name . "</h1>" . "<table style=\"margin:0 auto 0 auto;\">\n" . "<tr><td style=\"text-align:right\">Crew Size in " . $_SESSION['current_view']['year'] . ":</td><td style=\"text-align:right\">" . $crew->crewmember_count . "</td></tr>\n" . "<tr><td style=\"text-align:right\">Total Rappels in " . $_SESSION['current_view']['year'] . ":</td><td style=\"text-align:right\">" . $crew->raps_this_year_total . "</td></tr>\n" . "<tr><td style=\"text-align:right\">Operationals in " . $_SESSION['current_view']['year'] . ":</td><td style=\"text-align:right\">" . $crew->raps_this_year_operational . "</td></tr>\n" . "<tr><td style=\"text-align:right\">Operationals-per-Person in " . $_SESSION['current_view']['year'] . ":</td><td style=\"text-align:right; padding-left:10px;\">" . $crew->raps_this_year_per_person_operational . "</td></tr>\n" . "<tr><th colspan=\"2\" style=\"padding-top:10px;border-bottom:1px solid #555555;\">Demographics</th></tr>\n" . "<tr><td style=\"text-align:right\">Average Age:</td><td style=\"text-align:right\">" . $crew->avg_age . "</td></tr>\n" . "<tr><td style=\"text-align:right\">Crewmembers Who Are Male:</td><td style=\"text-align:right\">" . $crew->gender_ratio . "%</td></tr>\n" . "<tr><td style=\"text-align:right\">Rappels by Men / Women in " . $_SESSION['current_view']['year'] . ":</td><td style=\"text-align:right\">" . $crew->male_rappels . " / " . $crew->female_rappels . "</td></tr>\n" . "</table>\n" . "</td></tr>\n\n" . "</table></div>\n\n";
    echo "<hr style=\"width:75%; height:3px; \">\n\n";
    echo "This crew has roster information for the following years:<br>\n";
    $year_str = "";
    if ($year_array = $crew->get_roster_years()) {
        foreach ($year_array as $year) {
            $year_str .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?region=" . $_SESSION['current_view']['region'] . "&crew=" . $_SESSION['current_view']['crew']->get('id') . "&year=" . $year . "\">" . $year . "</a> | ";
        }
        $year_str = substr($year_str, 0, strlen($year_str) - 3);
        // Strip the last pipe divider off the string
    }
    echo $year_str . "\n<br><br>\n";
    // Display crew roster - if user is logged in, each crewmember image will be a link to their rappel history. If NOT logged in, images are not links.
    try {
        if ($crew->get_crewmembers($_SESSION['current_view']['year'])) {
            $col_count = 1;
            echo "<table style=\"margin:0 auto 0 auto;\">\n";
            foreach ($crew->crewmembers as $hrap) {
                if (($col_count - 1) % 5 == 0) {
                    echo "<tr>\n";
                }
                echo "<td class=\"roster_thumbnail\">";
                if (isset($_SESSION['logged_in']) && $_SESSION['logged_in']) {
                    echo "<a href=\"view_rappels.php?hrap=" . $hrap->get('id') . "\">";
                }
                echo "<img src=\"" . $hrap->headshot_filename . "\">";
                if (isset($_SESSION['logged_in']) && $_SESSION['logged_in']) {
                    echo "</a>";
                }
                /*				echo "<br>\n"
                					."<table><tr><td colspan=\"2\" style=\"text-align:center;font-weight:bold;\">".$hrap->name."</td></tr>\n"
                					."<tr><td style=\"text-align:right;\">Operationals:</td><td style=\"text-align:left;\">".$hrap->raps_all_time_operational."</td></tr></table>\n</td>";
                */
                echo "<br>\n" . "<span style=\"font-weight:bold;\">" . $hrap->name . "</span><br>\n" . $hrap->raps_all_time_operational . " Ops / " . $hrap->raps_all_time_live . " Total</td>\n";
                if ($col_count % 5 == 0) {
                    echo "\n</tr>\n";
                }
                $col_count++;
            }
            // End: foreach
            echo "</table></div><br>\n";
        }
    } catch (Exception $e) {
        echo $e->getMessage() . "<br>\n";
        //Display message if there is no data for the selected year
    }
}