<div class="cc_hubadm_content">
    <div class="cc_hubadm_box cc_hubadm_full">
    <div class="cc_hubadm_boxtitle">Staff Member Permissions</div>
        <div class="cc_hubadm_missingdata"><?php echo $missingdata; ?></div>
       <form method="post" action="<?php echo SITE_URL ?>/<?php echo $mloc ?>.php/HubOps/setpermissions">
           <table class="cc_hubadm_formtable">
               <tr><td>Pilot</td><td>
                   <?php if(!$lockpilot) { ?>
                   <select name="pilotid">
                    <?php if(!$fpilots) { echo '<option value="">No Pilots Found</option>'; } else { foreach($fpilots as $fpilot) { if($permissions->pilotid == $fpilot->pilotid) { $sel1 = "selected"; } else { $sel1 = ""; } ?>
                       <option value="<?php echo $fpilot->pilotid ?>" <?php echo $sel1; ?>><?php echo PilotData::GetPilotCode($fpilot->code, $fpilot->pilotid); ?> <?php echo $fpilot->firstname.' '.$fpilot->lastname; ?></option>
                   <?php } ?>
                   <?php } ?>
                   </select>
                   <?php } else { ?>
                   <input type="text" name="pname" value="<?php echo PilotData::GetPilotCode($permissions->code, $permissions->pilotid); ?> <?php echo $permissions->firstname.' '.$permissions->lastname; ?>" readonly />
                   <input type="hidden" name="pilotid" value="<?php echo $permissions->pilotid ?>" readonly />
                   <?php } ?>
                   </td></tr>
               <tr><td>Hub(s)</td><td>
                   <?php $found = 0; if(!$formhubs) { echo "No Hubs available!"; } else { foreach($formhubs as $fhub) { ?>
                   <input id="l<?php echo $fhub->icao ?>" type="checkbox" name="hub_list[]" value="<?php echo $fhub->icao ?>" <?php 
                 if($permissions->hubarray) foreach (unserialize($permissions->hubarray) as $perm) {
                       if($perm && ($perm->icao == $fhub->icao)) {
                            $found = 1;
                            break;
                        }
                    }
    if($found == 1) { echo "checked"; } $found = 0; ?>><label for="l<?php echo $fhub->icao ?>"><?php echo $fhub->icao ?> <?php echo $fhub->name ?></label><br/>
                   <?php } ?>
                   <?php } ?>
                   </td></tr>
               <tr><td>Permissions</td><td>
                   <input type="checkbox" name="edithubinfo" id="edithubinfo" value="1" <?php if($permissions->edithubinfo == '1') { echo "checked"; } ?>><label for="edithubinfo">Add/Edit Hub Details</label><br/>
                   <input type="checkbox" name="editstaff" id="editstaff" value="1" <?php if($permissions->editstaff == '1') { echo "checked"; } ?>><label for="editstaff">Add/Edit Staff</label><br/>
                   <input type="checkbox" name="editdocs" id="editdocs" value="1" <?php if($permissions->editdocs== '1') { echo "checked"; } ?>><label for="editdocs">Write/Upload Documents</label><br/>
                   <input type="checkbox" name="editpages" id="editpages" value="1" <?php if($permissions->editpages == '1') { echo "checked"; } ?>><label for="editpages">Edit Public Hub Page</label><br/>
                   <input type="checkbox" name="editpilots" id="editpilots" value="1" <?php if($permissions->editpilots == '1') { echo "checked"; } ?>><label for="editpilots">Manage Pilots</label><br/>
                   <input type="checkbox" name="editpireps" id="editpireps" value="1" <?php if($permissions->editpireps == '1') { echo "checked"; } ?>><label for="editpireps">Manage PIREPs</label><br/>
                   <input type="checkbox" name="editschedules" id="editschedules" value="1" <?php if($permissions->editschedules == '1') { echo "checked"; } ?>><label for="editschedules">Add/Edit Schedules</label><br/>
                   <input type="checkbox" name="emailpilots" id="emailpilots" value="1" <?php if($permissions->emailpilots == '1') { echo "checked"; } ?>><label for="emailpilots">Email Hub Pilots</label><br/>
                   </td></tr>
               <tr><td></td><td><input type="submit" value="Set Permissions" /></td></tr>
           </table>
    </form>
    </div>
</div>