Last active
December 24, 2015 21:38
-
-
Save npardington/6866623 to your computer and use it in GitHub Desktop.
Bad example of how things were done. Used in a blog post about using a framework.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting (E_ALL ^ E_NOTICE); | |
session_start(); | |
include "./includes/class.pageClass.php"; | |
require "./includes/class.requiredField.php"; | |
require "./includes/inc.functions.php"; | |
require "./includes/inc.dbConnection.php"; | |
$page = new Page; | |
$page->Debug(); | |
$page->RequireLogin(); //redirects if your not logged in | |
Connect(); | |
UpdateWorkersResponse($_GET['id'],$_GET['record'],$_GET['response']); | |
$page->SetTitle("Administration"); | |
$page->SetScript(" | |
function HideAll(){ | |
if (document.getElementById('adminAll').style.display == 'none') | |
{ | |
document.getElementById('adminAll').style.display = 'block' | |
document.getElementById('adminAllToggle').innerHTML = 'Hide' | |
} else { | |
document.getElementById('adminAll').style.display = 'none' | |
document.getElementById('adminAllToggle').innerHTML = 'Show' | |
} | |
} | |
"); | |
if ($_COOKIE['whoAmI'] == "| Logged in as Naomi") { | |
$content = " | |
<div id='divGeneralContainer'> <h2 id='mainAdminLinks'><a href='javascript:doClick(1)'>Add Worker</a> | <a href='javascript:doClick(2)'>Remove Worker</a> | <a href='javascript:doClick(3)'>Assign Worker</a> | <a href='javascript:doClick(4)'>Requests</a></h2> | |
<div id='divAddWorker'> | |
<form id='myvalid' action='' method='post' > | |
<p> | |
<label for='txtFirstName' class='label-left'>First Name:</label><input class='required' id='txtFirstName' name='fname' /> | |
</p> | |
<p> | |
<label for='txtLastName' class='label-left'>Last Name:</label><input class='required' id='txtLastName' name='lname' /> | |
</p> | |
<p> | |
<label for='txtEmail' class='label-left'>Email:</label><input class='required email' id='txtEmail' name='email' /> | |
</p> | |
<p> <label for='leader' class='label-left' >Leader:</label>". AdminSelect("leader", "leader") ."</p> | |
<p> | |
<label for='isLeader' class='label-left'>Is Leader:<input type='checkbox' name='isLeader' name='isleader' id='isLeader' value='yes'></label> | |
<input id='addSubmit' type='submit' value='Add' id='btnSubmit' /> | |
</p> | |
</form> | |
</div> | |
<div id='divRemoveWorker' style='display:none;'> | |
<table> | |
<tr> | |
<td id='tdRemoveWorkers'>" . WorkersSelect("selRemoveWorker", "selRemoveWorker") . "</td> | |
<td> | |
<span class='messages' id='removeWorkerMessage'>Worker Removed</span> | |
</td> | |
</tr> | |
<tr> | |
<td align='right'> | |
<input style='display:none;' id='confirmRemove' type='submit' value='Confirm' onClick='RemoveWorker(this);' /> | |
<input type='submit' value='Remove' onClick='ConfirmRemoveWorker();' /> | |
</td> | |
</tr> | |
</table> | |
</div> | |
<div id='divAssignWorkerLeader' style='display:none;'> | |
<table> | |
<tr><td>Assign:</td><td>". WorkersSelect("selAssignWorker", "selAssignWorker") ."<span id='assignVerify'>Worker Assigned</span></td></tr> | |
<tr><td>Leader:</td><td>" . AdminSelect("selAsignToAdmin", "selAsignToAdmin") . "</td></tr> | |
<tr><td><input type='submit' value='Assign' onClick='AssignWorker();'></td><td align='right'></td></tr> | |
</table> | |
</div> | |
<div id='divPrayerRequests' style='display:none'> | |
<div class='requests'> | |
<div class='requestText'> | |
". GetPrayerRequests() ." | |
<br /> | |
<br /> | |
Request: <span id='requestnotify'>Request Updated</span> <br /> | |
<textarea id='txtRequest' name='request' rows='5' cols='15' ></textarea> | |
<input type='submit' id='submitRequest' value='Update' onClick='SubmitRequest()'> | |
</div> | |
<img id='requestImg' class='requestImg' src='' width='150' /> | |
<input type='hidden' id='nope' /> | |
</div> | |
<div style='clear: both'></div> | |
</div> | |
</div> | |
"; | |
} //end of tylers content | |
$content .=" | |
<script language='JavaScript'> | |
". | |
$sReqiredDeclarations | |
." | |
var btnSubmit = document.getElementById('btnSubmit'); | |
var divErrorMSG = document.getElementById('divErrorMSG'); | |
var divContent = [0, | |
document.getElementById('divAddWorker'), | |
document.getElementById('divRemoveWorker'), | |
document.getElementById('divAssignWorkerLeader'), | |
document.getElementById('divPrayerRequests') | |
]; | |
var currentDiv = 1; | |
". | |
$sRequiredDef | |
." | |
function ControlMayNotBeBlank(_ctl,_msg){ | |
this.control = _ctl; | |
if ('' == _msg){ | |
this.message = _ctl.name + ' may not be blank.'; | |
} else { | |
this.message = _msg; | |
} | |
return this; | |
} | |
function doClick(num){ | |
if(currentDiv != 0) | |
{ | |
divContent[currentDiv].style.display = 'none'; | |
} | |
currentDiv = num; | |
divContent[currentDiv].style.display = 'block'; | |
} | |
ControlMayNotBeBlank.prototype.isValid = function () { | |
return this.control.value != ''; | |
} | |
function CheckRequiredTextFields(listOfFields, divErrorMessage) | |
{ | |
var k; | |
divErrorMessage.innerHTML = ''; | |
var returnValue = true; | |
for (k=0;k < listOfFields.length; ++k) | |
{ | |
if(!listOfFields[k].isValid()) | |
{ | |
divErrorMessage.innerHTML = divErrorMessage.innerHTML | |
+ '<br />' + listOfFields[k].message; | |
returnValue = false; | |
} | |
} | |
return returnValue; | |
} | |
function CheckFields() { | |
var okToSubmit = true; | |
divErrorMSG.innerHTML = ''//reset the error block | |
okToSubmit = CheckRequiredTextFields(requiredTextFields, divErrorMSG); | |
btnSubmit.disabled = !okToSubmit; | |
} | |
</script> | |
"; | |
$page->SetContent($content . | |
"<h2>If you need to change a worker you do it here. <a href='javascript:HideAll()'><span id='adminAllToggle'>Hide</span></a></h2>" . AdminListAll()); | |
$page->RenderPage(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment