Skip to content

Instantly share code, notes, and snippets.

@JeremyMorgan
Created August 23, 2020 19:38
Show Gist options
  • Save JeremyMorgan/e0c541acb7f47371014585b1dc40222b to your computer and use it in GitHub Desktop.
Save JeremyMorgan/e0c541acb7f47371014585b1dc40222b to your computer and use it in GitHub Desktop.
Ancient Code3
<?php
/**
* Call Monitor Class
*
* This class builds the call monitor object, and is the first class that others are based off of.
* It stores info
*
*
* @package SSVS Call Monitor App
* @author Jeremy Morgan
* @version .5
* @copyright 2005 Hollywood Entertainment
*
*
* @var string contains class1 information
*
*/
class callmon {
/**
* @var int department number, from database
*/
var $dept;
/**
* @var string mode, for future expansion
*/
var $mode;
/**
* @var string title of the page being displayed
*/
var $title;
/**
* callmon constructor
*
* this function serves as a constructor to create the object with its variables.
*/
function callmon($dept=NULL,$mode=NULL){
$this->thispage = $_SERVER['PHP_SELF'];
$this->dept = $dept;
$this->mode = $mode;
$this->title = $title;
// create question
if ($mode == "start"){
$inputbox = new inputbox($dept);
$this->do_questionbox();
$this->getquestions($dept);
$this->do_questionboxclose($dept);
}
if ($mode == "insert"){
}
} // end function callmon()
/**
* setmode method
*
* this function sets the mode variable. Although the mode is set in the constructor and is generally static, modes may change. This function will serve
* to change the object variable if you want in the future.
*/
function setmode($mode){
$this->mode = $mode;
} // end function setmode()
function do_insert(){
}
/**
* drawindex method
*
* function that draws the first menu you see at the beginning of the page. Takes departments from the database to create.
*/
function do_index(){
?><table border="0" align="center" class="indextable">
<tr>
<td><div align="center">
<h2>Choose Department</h2>
</div></td>
</tr><?php
$sql = "SELECT depid id, depname name, abb, valid
FROM `callmon_departments`
WHERE valid = 'Y'";
$result = mysql_query($sql) or die(mysql_error());
while($ary = mysql_fetch_array($result)){
$id = $ary['id'];
$name = $ary['name'];
$abb = $ary['abb'];
?><tr>
<td class="indexbutton"><div align="center"><h3><a href="index.php?mode=start&amp;dept=<?=$id?>" class="indextext"><?=$name?></a></h3></div></td>
</tr><?php
} // end while loop
?></table><?php
} // end function drawindex()
/**
* questionbox method
*
* this function creates the box that all questions are generated in. Drawquestions runs inside the box.
* This opens the table, you must use questionboxclose() to close the table properly.
*/
function do_questionbox(){
?>
<form action="index.php" method="POST">
<table width="400" border="0">
<tr>
<td width="20">&nbsp;</td>
<td width="236">Question</td>
<td width="130">Value</td>
</tr>
<?php
} // end function do_questionbox()
/**
* questionboxclose method
*
* this simply prints a table tag (closing) at this time. There may be more added later.
*/
function do_questionboxclose($dept){
?>
</table>
<input type="hidden" name="dept" value="<?=$dept?>">
<input type="hidden" name="mode" value="insert">
<input type="submit" value="submit now">
</form>
<?php
} // end function questionboxclose()
/**
* getquestions method
*
* This method creates a question based on type and maximum value, and is reiterated until there are no more questions. This runs to generate
* the questions for each survey
*/
function getquestions($dept){
$qnum = "1";
$q = 'Q';
$sql = "select * from questions where qdept = '$dept'";
//$sql = "select * from questions where qdept = '1'";
$result = mysql_query($sql) or die(mysql_error());
while($ary = mysql_fetch_array($result)){
$text = $ary['questiontext'];
$max = $ary['maxvalue'];
$qtype = $ary['qtype'];
$dname = $q.$qnum;
echo "
<tr>
<td>$qnum .</td>
<td>$text</td>";
$resp = $this->makeresp($dname,drop,$max);
echo "$resp";
echo "</tr>";
$qnum++;
} // end while loop
} // end function drawquestion()
/**
* makeresp method
*
* this function makes a "responder". Right now the common one is a dropdown, however, the reason for this method's existence is so that later
* we can use a text box or some other type of field if so desired.
*
*/
function makeresp($dname,$rtype,$max){
$dval = 1; // this is to prevent zero from being a value
$max = $max + 1; // this compensates for that
$responder = "<td>";
if($rtype = 'drop'){ // if type is dropdown
$responder .= "
<select name=\"$dname\">
";
while ($dval < $max){
$responder .= "
<option value=\"$dval\">$dval</option>
";
$dval++;
}
$responder .="</select>";
} // end if
$responder .= "</td>";
return $responder;
} // end function makeresp()
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment