<?php
// HotelWakeUp put into module format by tshif 2/17/2009
//PHP Programming by Swordsteel 2/17/2009
// including Wakeup scripts last modified by Jcoulter (credits included within)
//
if(count($_POST)){
	hotelwakeup_saveconfig();
}
$date = hotelwakeup_getconfig();
?>
<h1><b>Wake Up Calls</b></h1>
<hr><br>
Wake Up calls produces hotel-style wakeup calls to any extension.<br>
To use the Wake-Up feature, dial the feature code assigned in FreePBX Feature Codes.<br><br>

<form method="POST" action="">
<h3><u>Operator Mode</u></h3>
By default, Wake Up calls are made only to the extension which requests them. <br>When the Operator Mode is enabled, certain extensions are identified to be able to request a Wake Up call for any extension on the system.<br><br>
<table border="0" width="430" id="table1">
  <tr>
    <td width="153">Operator Mode: </td>
    <td width="129">
<?php 
echo "<input type=\"radio\" value=\"0\" name=\"operator_mode\"".(($date[5]==0)?' checked':'').">\n";
?> 
Disabled&nbsp;</td>
    <td>
<?php
echo "<input type=\"radio\" value=\"1\" name=\"operator_mode\"".(($date[5]==1)?' checked':'').">\n";
?>
&nbsp; Enabled</td>
  </tr>
  <tr>
    <td width="153">Extension Length</td>
    <td width="129">&nbsp;
<select size="1" name="extensionlength">
<?php
echo "<option".(($date[3]==2)?' selected':'').">2</option>\n";
echo "<option".(($date[3]==3)?' selected':'').">3</option>\n";
echo "<option".(($date[3]==4)?' selected':'').">4</option>\n";
echo "<option".(($date[3]==5)?' selected':'').">5</option>\n";
echo "<option".(($date[3]==6)?' selected':'').">6</option>\n";
echo "<option".(($date[3]==7)?' selected':'').">7</option>\n";
echo "<option".(($date[3]==8)?' selected':'').">8</option>\n";
echo "<option".(($date[3]==9)?' selected':'').">9</option>\n";
echo "<option".(($date[3]==10)?' selected':'').">10</option>\n";
echo "<option".(($date[3]==11)?' selected':'').">11</option>\n";

?>
</select></td>
    <td> &nbsp;</td>
  </tr>
  <tr>
    <td width="153">Operator Extensions:</td>
    <td colspan="2">
<?php
echo "<input type=\"text\" name=\"operator_extensions\" size=\"37\" value=\"{$date[6]}\">\n";
?>
    </td>
  </tr>
  <tr>
    <td width="153">&nbsp;</td>
    <td colspan="2">(Use a comma separated list)</td>
  </tr>
</table>
<p><h3><u>General Configuration</u></h3></p>
<table border="0" width="428" id="table2">
  <tr>
    <td width="155">Ring Time:</td>
    <td>
<select size="1" name="waittime">
<?php
echo "<option".(($date[1]==20)?' selected':'').">20</option>\n";
echo "<option".(($date[1]==30)?' selected':'').">30</option>\n";
echo "<option".(($date[1]==40)?' selected':'').">40</option>\n";
echo "<option".(($date[1]==50)?' selected':'').">50</option>\n";
?>
</select> Seconds
    </td>
  </tr>
  <tr>
    <td width="155">Retry Time:</td>
    <td>
<select size="1" name="retrytime">
<?php
echo "<option".(($date[2]==20)?' selected':'').">20</option>\n";
echo "<option".(($date[2]==30)?' selected':'').">30</option>\n";
echo "<option".(($date[2]==40)?' selected':'').">40</option>\n";
echo "<option".(($date[2]==50)?' selected':'').">50</option>\n";
echo "<option".(($date[2]==60)?' selected':'').">60</option>\n";
echo "<option".(($date[2]==70)?' selected':'').">70</option>\n";
?>
</select> Seconds
    </td>
  </tr>
  <tr>
    <td width="155">Max Retries:</td>
    <td>
<select size="1" name="maxretries">
<?php
echo "<option".(($date[0]==2)?' selected':'').">2</option>\n";
echo "<option".(($date[0]==3)?' selected':'').">3</option>\n";
echo "<option".(($date[0]==4)?' selected':'').">4</option>\n";
echo "<option".(($date[0]==5)?' selected':'').">5</option>\n";
echo "<option".(($date[0]==6)?' selected':'').">6</option>\n";
echo "<option".(($date[0]==7)?' selected':'').">7</option>\n";
echo "<option".(($date[0]==8)?' selected':'').">8</option>\n";
echo "<option".(($date[0]==9)?' selected':'').">9</option>\n";
echo "<option".(($date[0]==10)?' selected':'').">10</option>\n";
?>
</select>
    </td>
  </tr>
  <tr>
    <td width="155">Wake Up Caller ID:</td>
    <td>
<?php
echo "&quot;<input type=\"text\" name=\"calleridtext\" size=\"10\" value=\"{$date[8]}\" style=\"text-align: center\">&quot;\n";
echo "&lt;<input type=\"text\" name=\"calleridnumber\" size=\"5\" value=\"{$date[7]}\" style=\"text-align: center\">&gt;\n";
?>
    </td>
  </tr>
</table>
<p align="center">

<?php
//	$sql="SELECT `operator_mode`FROM `hotelwakeup`";
//	  $parm_operator_mode = $db->query($sql);
//	
//	$sql="SELECT `operator_extensions`FROM `hotelwakeup`";
//	  $parm_operator_extensions = $db->query($sql);
//
//	$sql="SELECT `wakeupcallerid`FROM `hotelwakeup`";
//	  $parm_wakeupcallerid = $db->query($sql);
//
//	$sql="SELECT `retrytime`FROM `hotelwakeup`";
//	  $parm_retrytime = $db->query($sql);
//
//	$sql="SELECT `waittime`FROM `hotelwakeup`";
//	  $parm_waittime = $db->query($sql);
//
//	$sql="SELECT `maxretries`FROM `hotelwakeup`";
//	  $parm_maxretries = $db->query($sql);
//
// The goalis to collect the current db entries and then have the UI reflect those setting below
//
?>
<input type="submit" value="Submit" name="B1">