"; echo "
"; if ($usernameunique_err) format_message(1,"User name already exists."); if ($fnamesuppld_err) format_message(1,"First name cannot be blank."); if ($lnamesuppld_err) format_message(1,"Last name cannot be blank."); if ($loginsuppld_err) format_message(1,"Login cannot be blank."); if ($loginunique_err) format_message(1,"Login already exists."); if ($passcomplex_err) format_message(1,"Password doesn't meet complexity requirements."); if ($passmatch_err) format_message(1,"The supplied passwords don't match."); if ($userhaswriteups_err) format_message(1,"User has actions in the database and cannot be deleted."); if ($edit_user && !$delete_user) { // set form options for editing $sectiontitle="Modify User        Click here to add a new user

"; $formtag="
"; $buttontags="          
"; // pull current values from database $currentvalues=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from users where id=$user_id")); $user_fname=$currentvalues["firstname"]; $user_lname=$currentvalues["lastname"]; $user_login=$currentvalues["login"]; $user_pass=$user_passconf="password_is_unchanged"; if ($currentvalues["role"]==ADMIN) { $roletag=""; } else { $roletag=""; } if ($currentvalues["active"]==1) { $activetag=""; } else { $activetag=""; } } else { // set form options for add if (!$user_add_fail) unset($user_id,$user_fname,$user_lname,$user_login,$user_pass,$user_passconf,$user_role,$user_active); $sectiontitle="Add New User

"; $formtag=""; $buttontags=" "; // set default values $roletag=""; $activetag=""; } $password_help="Password must be at least 8 characters in length and contain at least one upper case letter, one lower case letter, one number, and one special character."; echo " $sectiontitle $formtag
First Name:  

Last Name:  

Login:  

Password:  

Repeat Password:  

Need a random password?   "; $rpwok=false; while (!$rpwok) { $rpw=substr(str_shuffle(password_hash(microtime(),PASSWORD_DEFAULT)), 10, 12); $rpwtst=validate_password($rpw,$rpw); if ($rpwtst['complex']) $rpwok=true; } echo "  $rpw



Admin:  $roletag     Active:   $activetag

$buttontags


"; // show the table of entities $existingdata=mysqli_query($drs_db,"select id,firstname,lastname,login,role,active from users order by id asc"); echo " Existing Users   Click on the User ID to edit.

"; while ($tablerow=mysqli_fetch_assoc($existingdata)) { if ($tablerow["role"]==ADMIN) { $roledef="Admin"; } elseif ($tablerow["role"]==USER) { $roledef="User"; } if ($tablerow["active"]) { $activedef="\"active\""; } else { $activedef="\"inactive\""; } printf(" ", $tablerow["id"],$tablerow["id"], $tablerow["firstname"], $tablerow["lastname"], $tablerow["login"], $roledef, $activedef); } echo "
User IDFirst NameLast NameLoginRoleActive
%s %s %s %s %s %s
"; echo "
"; if ($devicenameunique_err) format_message(1,"Device name already exists."); if ($devicenamesuppld_err) format_message(1,"Device name cannot be blank."); if ($devicehaswriteups_err) format_message(1,"Device has writeups in the database and cannot be deleted."); if ($edit_device && !$delete_device) { // set form options for editing $sectiontitle="Modify Device        Click here to add a new device

"; $formtag="
"; $buttontags="          
"; // pull current values from database $currentvalues=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from devices where id=$device_id")); $device_name=$currentvalues["name"]; if ($currentvalues["active"]==1) { $activetag=""; } else { $activetag=""; } } else { // set form options for add if (!$device_add_fail) unset($device_id,$device_name,$device_active); $sectiontitle="Add New Device

"; $formtag=""; $buttontags=" "; // set default values $activetag=""; } echo " $sectiontitle $formtag
Device Name:  

Active:   $activetag

$buttontags


"; // show the table of entities $existingdata=mysqli_query($drs_db,"select * from devices order by id asc"); echo " Existing Devices   Click on the Device ID to edit.

"; while ($tablerow=mysqli_fetch_assoc($existingdata)) { if ($tablerow["active"]) { $activedef="\"active\""; } else { $activedef="\"inactive\""; } printf(" ", $tablerow["id"],$tablerow["id"], $tablerow["name"], $activedef); } echo "
Device IDDevice NameActive
%s %s %s
"; echo "
"; if ($ssnameunique_err) format_message(1,"Subsystem name already exists."); if ($ssnamesuppld_err) format_message(1,"Subsystem name cannot be blank."); if ($sshaswriteups_err) format_message(1,"Subsystem has writeups in the database and cannot be deleted."); if ($edit_subsystem && !$delete_subsystem) { // set form options for editing $sectiontitle="Modify Subsystem        Click here to add a new subsystem

"; $formtag="
"; $buttontags="          
"; // pull current values from database $currentvalues=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from subsystems where id=$subsystem_id")); $subsystem_name=$currentvalues["name"]; $subsystem_desc=$currentvalues["description"]; if ($currentvalues["active"]==1) { $activetag=""; } else { $activetag=""; } } else { // set form options for add if (!$subsystem_add_fail) unset($subsystem_id,$subsystem_name,$subsystem_desc,$subsystem_active); $sectiontitle="Add New Subsystem

"; $formtag=""; $buttontags=" "; // set default values $activetag=""; } echo " $sectiontitle $formtag
Subsystem Name:  

Description:


Active:   $activetag

$buttontags


"; // show the table of entities $existingdata=mysqli_query($drs_db,"select * from subsystems order by id asc"); echo " Existing Subsystems   Click on the Subsystem ID to edit.

"; while ($tablerow=mysqli_fetch_assoc($existingdata)) { if ($tablerow["active"]) { $activedef="\"active\""; } else { $activedef="\"inactive\""; } printf(" ", $tablerow["id"],$tablerow["id"], $tablerow["name"], $tablerow["description"], $activedef); } echo "
Subsystem IDSubsystem NameDescriptionActive
%s %s %s %s
"; echo "
"; if ($reastextunique_err) format_message(1,"Reason already exists."); if ($reastextsuppld_err) format_message(1,"Reason cannot be blank."); if ($reashaswriteups_err) format_message(1,"Reason has writeups in the database and cannot be deleted."); if ($edit_reason && !$delete_reason) { // set form options for editing $sectiontitle="Modify Reason        Click here to add a new reason

"; $formtag="
"; $buttontags="          
"; // pull current values from database $currentvalues=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from reasons where id=$reason_id")); $reason_text=$currentvalues["text"]; if ($currentvalues["active"]==1) { $activetag=""; } else { $activetag=""; } } else { // set form options for add if (!$reason_add_fail) unset($reason_id,$reason_text,$reason_active); $sectiontitle="Add New Reason

"; $formtag=""; $buttontags=" "; // set default values $activetag=""; } echo " $sectiontitle $formtag
Reason Text:  

Active:   $activetag

$buttontags


"; // show the table of entities $existingdata=mysqli_query($drs_db,"select * from reasons order by id asc"); echo " Existing Reasons   Click on the Reason ID to edit.

"; while ($tablerow=mysqli_fetch_assoc($existingdata)) { if ($tablerow["active"]) { $activedef="\"active\""; } else { $activedef="\"inactive\""; } printf(" ", $tablerow["id"],$tablerow["id"], $tablerow["text"], $activedef); } echo "
Reason IDReason TextActive
%s %s %s
"; echo "
"; if ($peridisint_err) format_message(1,"Period number must be an integer."); if ($peridsuppld_err) format_message(1,"Period number cannot be blank."); if ($peridunique_err) format_message(1,"Period number already exists."); if ($pertimesunique_err) format_message(1,"Period already exists."); if ($pertimessuppld_err) format_message(1,"Period times cannot be blank."); if ($perhaswriteups_err) format_message(1,"Period has writeups in the database and cannot be deleted."); if ($edit_period && !$delete_period) { // set form options for editing $sectiontitle="Modify Period        Click here to add a new period

"; $formtag="
"; $buttontags="          
"; // pull current values from database $currentvalues=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from periods where id=$period_id")); $period_times=$currentvalues["times"]; if ($currentvalues["active"]==1) { $activetag=""; } else { $activetag=""; } $idtag="$period_id"; } else { // set form options for add if (!$period_add_fail) unset($period_id,$period_times,$period_active); $sectiontitle="Add New Period

"; $formtag=""; $buttontags=" "; $idtag=""; // set default values $activetag=""; } echo " $sectiontitle $formtag
Period Number:  $idtag

Period Times:  

Active:   $activetag

$buttontags


"; // show the table of entities $existingdata=mysqli_query($drs_db,"select * from periods order by id asc"); echo " Existing Periods   Click on the Period ID to edit.

"; while ($tablerow=mysqli_fetch_assoc($existingdata)) { if ($tablerow["active"]) { $activedef="\"active\""; } else { $activedef="\"inactive\""; } printf(" ", $tablerow["id"],$tablerow["id"], $tablerow["times"], $activedef); } echo "
Period IDPeriod TimesActive
%s %s %s
"; echo "
"; echo "
"; banner($print); pageblock("right","end"); pagetable("end"); framework("end","","",$print); ?>