function displayEmergencyContact($username, $relationships, $status)
{
    $message = "";
    if ($status == "fail") {
        $message = "<div class='alert alert-dismissible alert-danger'>\r\n                    <button type='button' class='close' data-dismiss='alert'>&times;</button>\r\n                    A technical issue occurred during submission. Please try again.\r\n                </div>";
    } elseif ($status == "success") {
        $message = "<div class='alert alert-dismissible alert-success'>\r\n                    <button type='button' class='close' data-dismiss='alert'>&times;</button>\r\n                    Emergency contact information successfully saved.\r\n                </div>";
    }
    try {
        $connection = new PDO("mysql:host=" . DB_HOST_NAME . ";dbname=" . DB_NAME . ";charset=utf8", DB_USER_NAME, DB_PASSWORD);
        // Exceptions fire when occur
        $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $emergencyContactQuery = $connection->query('
                SELECT ME.FIRSTNAME, ME.LASTNAME, ME.PHONE, ME.RELATIONSHIP, ME.EMERGENCY_CONTACT_ID 
                FROM ' . USER_CREDENTIAL_TABLE . ' M INNER JOIN ' . EMERGENCY_CONTACTS_TABLE . ' ME ON ME.MEMBER_ID = M.MEMBER_ID
                WHERE M.MEMBER_EMAIL = ' . $connection->quote($username));
        $emergencyContact = $emergencyContactQuery->fetch();
        echo '<div class="row-fluid">
                <div class="well bs-component">
                <form method="post" action="./" id="emergency_contact_update">
                    <legend style="font-weight: bold; color:#ffffff">EMERGENCY CONTACT</legend>' . $message . '<div>
                        <div class="form-group row">
                            <label class="col-lg-2 control-label">First name</label>
                            <div class="col-lg-8">
                                <input type="text" name="firstName" value="' . htmlentities($emergencyContact[0], ENT_QUOTES) . '" class="form-control" required/>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 control-label">Last name</label>
                            <div class="col-lg-8">
                                <input type="text" name="lastName" value="' . htmlentities($emergencyContact[1], ENT_QUOTES) . '" class="form-control" required/>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 control-label">Phone number</label>
                            <div class="col-lg-8">
                                <input type="tel" name="phone" value="' . preg_replace("/^(\\d{3})(\\d{3})(\\d{4})\$/", "\$1-\$2-\$3", $emergencyContact[2]) . '" pattern="(?:\\(\\d{3}\\)|\\d{3})[- ]?\\d{3}[- ]?\\d{4}" maxlength="13" class="form-control" required/>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 control-label">Relationship</label>
                            <div class="col-lg-8">
                                <select name="relationship" class="form-control">' . createRelationshipsOptions($relationships, $emergencyContact[3]) . '</select>
                            </div>
                        </div>
                        <div>
                            <input type="hidden" name="emergencyContactID" value="' . $emergencyContact[4] . '" />   
                            <input type="hidden" name="submit" value="TRUE" />
                            <input type="submit" value="Save changes" class="btn btn-default" />
                        </div>
                    </div>
                </form>
                </div>
            </div>';
    } catch (PDOException $e) {
        echo "\r\n            <div>\r\n                Error: " . $e->getMessage() . "</div>";
        return FALSE;
    }
}
Ejemplo n.º 2
0
function displayAccountForm($status, $us_state_abbrevs, $relationships)
{
    $notice = "";
    if ($status == "success") {
        $notice = "<div class='alert alert-success alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                Account and emergency contact information updated.\n                                            </div>";
    } elseif ($status == "fail") {
        $notice = "<div class='alert alert-danger alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                Account information not updated. Please choose a different email address.\n                                            </div>";
    } elseif ($status == "tech_diff") {
        $notice = "<div class='alert alert-danger alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                There was a problem updating the account information. Please try again.\n                                            </div>";
    }
    try {
        $connection = new PDO("mysql:host=" . DB_HOST_NAME . ";dbname=" . DB_NAME . ";charset=utf8", DB_USER_NAME, DB_PASSWORD);
        // Exceptions fire when occur
        $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $accountInformationQuery = $connection->query('
                                            SELECT M.MEMBER_ID, M.MEMBER_EMAIL, M.FIRSTNAME, M.LASTNAME, M.ADDRESS, M.CITY, M.STATE, M.ZIP, M.PHONE, M.NOTES, M.ADMIN_NOTES, M.PASSWORD, M.DUEDATE, M.ACTIVESTATUS, ME.FIRSTNAME, ME.LASTNAME, ME.PHONE, ME.RELATIONSHIP, ME.EMERGENCY_CONTACT_ID 
                                            FROM ' . USER_CREDENTIAL_TABLE . ' M INNER JOIN ' . EMERGENCY_CONTACTS_TABLE . ' ME ON ME.MEMBER_ID = M.MEMBER_ID
                                            WHERE M.MEMBER_ID = ' . $connection->quote($_POST["buttonMemberID"]));
        $accountInformation = $accountInformationQuery->fetch(PDO::FETCH_NUM);
        echo "<form action='edit.php' method='post'>\n                                                <h3> Editing " . $accountInformation[2] . " " . $accountInformation[3] . "</h3></br>" . $notice . "<input type='text' name='buttonMemberID' value='" . $_POST["buttonMemberID"] . "' hidden>\n                                                <table style='width:75%'>\n                                                    <tr>\n                                                        <td>First Name: <input type='text' name='fname' value='" . htmlentities($accountInformation[2], ENT_QUOTES) . "' required /></td>\n                                                        <td>Last Name: <input type='text' name='lname' value='" . htmlentities($accountInformation[3], ENT_QUOTES) . "'  required /></td>\n                                                        <td>Dues Paid Until: <input type='date' name='duedate' value='" . $accountInformation[12] . "' placeholder='YYYY-MM-DD' required /></td>\n                                                        <td>Member Status: <select name='status' >\n                                                            <option value='active'>Active</option>\n                                                            <option value='inactive'";
        if ($accountInformation[13] == '0') {
            echo "selected>Inactive</option> </select> </td></tr>";
        } else {
            echo ">Inactive</option> </select> </td></tr>";
        }
        echo "<tr>\n                                                            <td> </br>Street Address: <input type='text' name='address' value='" . htmlentities($accountInformation[4], ENT_QUOTES) . "'  required></td>\n                                                            <td></br>City: <input type='text' name='city' value='" . htmlentities($accountInformation[5], ENT_QUOTES) . "' required></td>\n                                                            <td>\n                                                                </br>State: \n                                                                <select name='state' required>" . createStateAbbrevOptions($us_state_abbrevs, $accountInformation[6]) . "</select>\n                                                            </td>\n                                                            <td></br>Zip Code: <input type='text' name='zip' value='" . $accountInformation[7] . "' required /></td>\n                                                        </tr>\n                                                        <tr>\n                                                            <td> </br>Phone Number: <input type='text' name='phone' value='" . preg_replace('/^(\\d{3})(\\d{3})(\\d{4})$/', '$1-$2-$3', $accountInformation[8]) . "' pattern='(?:\\(\\d{3}\\)|\\d{3})[- ]?\\d{3}[- ]?\\d{4}' maxlength='14' required/></td>\n                                                            <td></br>Email Address: <input type='text' name='email' value='" . htmlentities($accountInformation[1], ENT_QUOTES) . "' required></td>\n                                                        </tr>\n                                                    </table>\n                                                    <br />\n                                                    <div style='width:50%'>\n                                                        Member Viewable Notes:</br> \n                                                        <textarea rows='4' cols='100' name='notes'>" . htmlentities($accountInformation[9], ENT_QUOTES) . "</textarea>\n                                                    </div>\n                                                    <div style='width:50%'>\n                                                        Administrator Notes:</br>\n                                                        <textarea rows='4' cols='100' name='adminnotes'>" . htmlentities($accountInformation[10], ENT_QUOTES) . "</textarea>\n                                                    </div>\n                                                    <hr />\n                                                    <h4>Emergency Contact</h4>\n                                                    <table style='width:50%'>\n                                                        <tr>\n                                                                <td>First Name: <input type='text' name='emergency_fname' value='" . htmlentities($accountInformation[14], ENT_QUOTES) . "' required /></td>\n                                                                <td>Last Name: <input type='text' name='emergency_lname' value='" . htmlentities($accountInformation[15], ENT_QUOTES) . "'  required /></td>\n                                                                <td>Phone Number: <input type='text' name='emergency_phone' value='" . preg_replace('/^(\\d{3})(\\d{3})(\\d{4})$/', '$1-$2-$3', $accountInformation[16]) . "' pattern='(?:\\(\\d{3}\\)|\\d{3})[- ]?\\d{3}[- ]?\\d{4}' maxlength='14' required/></td>\n                                                                <td>Relationship <select name='emergency_relationship'>" . createRelationshipsOptions($relationships, $accountInformation[17]) . "</select></td>\n                                                        </tr>\n                                                    </table>\n                                                    <hr />";
    } catch (PDOException $e) {
        echo "\n                                        <div>\n                                            Error: " . $e->getMessage() . "</div>";
    }
}
Ejemplo n.º 3
0
function displayForm($us_state_abbrevs, $relationships, $status, $submittedFirstName, $submittedLastName, $submittedDuesDate, $submittedStreet, $submittedCity, $submittedState, $submittedZip, $submittedPhone, $submittedEmail, $submittedAdminNotes, $submittedEmergencyFirstName, $submittedEmergencyLastName, $submittedEmergencyPhone, $submittedEmergencyRelationship)
{
    $notice = "";
    if ($status == "success_manual") {
        $notice = "<div class='alert alert-success alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                User successfully created.\n                                            </div>";
    } elseif ($status == "success_auto") {
        $notice = "<div class='alert alert-success alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                User successfully created. A welcome email with instructions to reset his/her password was sent.\n                                            </div>";
    } elseif ($status == "fail_email") {
        $notice = "<div class='alert alert-danger alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                There was a problem creating this user. Please choose a different email address and try again.\n                                            </div>";
    } elseif ($status == "fail_password") {
        $notice = "<div class='alert alert-danger alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                There was a problem creating this user. Please follow the password requirements and try again.\n                                            </div>";
    } elseif ($status == "tech_diff") {
        $notice = "<div class='alert alert-danger alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                There was a problem creating this user. Please try again.\n                                            </div>";
    }
    echo "<form action='add.php' method='post'>\n                                                <h3> Add a Member</h3></br>" . $notice . "<div>\n                                                    First Name: <input type='text' name='fname' value='" . htmlentities($submittedFirstName, ENT_QUOTES) . "' required />\n                                                    Last Name: <input type='text' name='lname' value='" . htmlentities($submittedLastName, ENT_QUOTES) . "' required />\n                                                    Dues End Date: <input type='date' name='duesdate' placeholder='YYYY-MM-DD' value='" . $submittedDuesDate . "' required />\n                                                </div><br />\n                                                <div>\n                                                    Street Address: <input type='text' name='street' value='" . htmlentities($submittedStreet, ENT_QUOTES) . "' required />\n                                                    City: <input type='text' name='city' value='" . htmlentities($submittedCity, ENT_QUOTES) . "' required />\n                                                    State:\n                                                    <select name='state'>" . createStateAbbrevOptions($us_state_abbrevs, $submittedState) . "</select>\n                                                    Zip Code: <input type='text' name='zip' value='" . htmlentities($submittedZip, ENT_QUOTES) . "' maxlength='5' required />\n                                                </div><br />\n                                                <div>\n                                                    Phone Number: <input type='text' name='phone' value='" . $submittedPhone . "' required />\n                                                    Email Address: <input type='text' name='email' value='" . htmlentities($submittedEmail, ENT_QUOTES) . "' required />\n                                                </div>\n                                                <br />\n                                                <div>\n                                                    Administrator Notes:\n                                                </div>\n                                                <div>\n                                                    <textarea rows='4' cols='100' name='notes'>" . htmlentities($submittedAdminNotes, ENT_QUOTES) . "</textarea>\n                                                </div>\n                                                <hr />\n                                                <h4> Emergency Contact:</h4>\n                                                <div>\n                                                    First Name: <input type='text' name='emergency_fname' value='" . htmlentities($submittedEmergencyFirstName, ENT_QUOTES) . "' required />\n                                                    Last Name: <input type='text' name='emergency_lname' value='" . htmlentities($submittedEmergencyLastName, ENT_QUOTES) . "' required />\n                                                    Phone Number: <input type='text' name='emergency_phone' value='" . htmlentities($submittedEmergencyPhone, ENT_QUOTES) . "' pattern='(?:\\(\\d{3}\\)|\\d{3})[- ]?\\d{3}[- ]?\\d{4}' maxlength='14' required />                                    \n                                                    Relationship:\n                                                    <select name='emergency_relationship'>" . createRelationshipsOptions($relationships, $submittedEmergencyRelationship) . "</select>\n                                            <hr />\n                                            <div>\n                                                <h4>Password</h4>\n                                                <script type='text/javascript'>\n                                                    function ShowHideDiv(generatePassword) {\n                                                        var passwordInformation = document.getElementById('passwordInformation');\n                                                        passwordInformation.style.display = generatePassword.checked ? 'none' : 'block';\n                                                    }\n                                                </script>\n\n                                                <div class='checkbox' for='generatePassword'>\n                                                    <label>\n                                                        <input type='checkbox' name='generatePassword' id='generatePassword' onclick = 'ShowHideDiv(this)' value='TRUE'> Generate password\n                                                    </label>\n                                                </div><br />\n                                                <div id='passwordInformation' style='display: hidden'>\n                                                The user's password must be eight or more characters and have at least one of each:\n                                                <ul>\n                                                    <li>Lower-case letter</li>\n                                                    <li>Upper-case letter</li>\n                                                    <li>Number</li>\n                                                    <li>Special characters</li>\n                                                </ul>\n\n                                                Enter the user's password: <input type='password' name='newPassword1'/><br /><br />\n                                                Re-enter the user's password: <input type='password' name='newPassword2'/><br /><br />\n                                            </div>\n                                            <hr />\n                                            <div>\n                                                <input type='text' name='submit' value='TRUE' hidden>\n                                                <input type='submit' class='btn btn-default' value='Submit' />\n                                            </div>\n                                        </form>";
}