I have a php script (someone else wrote it, I have to fix it) that populates a series of dropdowns for 'date', 'hour', 'min', 'am/pm' and initially selects the time stored in a MySQL record. If and only if the hour selected is '12' then the stored time on a status screen shows 12am (pm was selected) but when I retrieve the full record the time selected always shows 7pm even though that's not what's stored. Any hour other than '12' works normally.
I have another page using the same dropdown layout but that uses a similar script to select the 'hour' dropdown 4 hours ahead. On this one whenever the hour is '12' it gets am and pm backwards. I would greatly appreciate any help or insight.
Here is the code snippet for the first problem page:
CODE
<tr>
<td>Disposition</td>
<td valign="middle">
<input type="radio" name="disposition" value="SCHEDULED_NQ" <?php echo (($this->lead[0]['Status'] == 'SCHEDULED' And $this->lead[0]['Verified'] == 0) ? ' CHECKED ' : '') ?> class="input-text" value="0" style="width:20px;" onclick="java script:changeQualification(this)">Not Qualified
</td>
<td colspan="2">
<?php displayCalendarDate('schedule_nq_Date', "calImg_nq", strtotime($this->lead[0]['StatusDate']), (($this->lead[0]['Status'] == 'SCHEDULED' And $this->lead[0]['Verified'] == 0) ? true : false)) ?>
Time
<?php displayTime('schedule_nq_TimeHour', 'schedule_nq_TimeMin', 'schedule_nq_TimeAMPM', strtotime($this->lead[0]['StatusDateTime']), (($this->lead[0]['Status'] == 'SCHEDULED' And $this->lead[0]['Verified'] == 0) ? true : false)); ?>
</td>
</tr>
<tr>
<td> </td>
<td valign="middle">
<input type="radio" name="disposition" value="SCHEDULED_Q" <?php echo (($this->lead[0]['Status'] == 'SCHEDULED' And $this->lead[0]['Verified'] == 1) ? ' CHECKED ' : '') ?> class="input-text" value="1" style="width:20px;" onclick="java script:changeQualification(this)">Qualified
</td>
<td colspan="2">
<?php displayCalendarDate('schedule_q_Date', "calImg_q", strtotime($this->lead[0]['StatusDate']), ($this->lead[0]['Status'] == 'SCHEDULED' And $this->lead[0]['Verified'] == 1) ? true : false) ?>
Time
<?php displayTime('schedule_q_TimeHour', 'schedule_q_TimeMin', 'schedule_q_TimeAMPM', strtotime($this->lead[0]['StatusDateTime']), ($this->lead[0]['Status'] == 'SCHEDULED' And $this->lead[0]['Verified'] == 1) ? true : false); ?>
</td>
</tr>
Here is the code for the second problem script:
CODE
function displayTime($nameHour, $nameMin, $nameAmPm, $time, $enabled) {
echo '<select name="' . $nameHour . '" ' . ($enabled ? '' : ' disabled ') . ' class="input-text" style="width:45px">';
$strHour = '';
for ($i = 1; $i <= 12; $i++) {
if ($i < 10)
$strHour = '0' . $i;
else
$strHour = $i;
echo '<option ' . ($i == (intval(date('g', $time))) ? ' SELECTED ' : '') . ' value="' . $strHour . '">' . $strHour . '</option>';
}
echo '</select> ';
echo '<select name="' . $nameMin . '" ' . ($enabled ? '' : ' disabled ') . ' class="input-text" style="width:45px">';
$strMin = '';
for ($i = 0; $i <= 59; $i++) {
if ($i < 10)
$strMin = '0' . $i;
else
$strMin = $i;
echo '<option ' . ($i == intval(date('i', $time)) ? ' SELECTED ' : '') . ' value="' . $strMin . '">' . $strMin . '</option>';
}
echo '</select>';
echo '<select name="' . $nameAmPm . '" ' . ($enabled ? '' : ' disabled ') . ' class="input-text" style="width:45px">';
echo '<option ' . (date('A', $time) == 'AM' ? ' SELECTED ' : '') . ' value="AM">am</option>';
echo '<option ' . (date('A', $time) == 'PM' ? ' SELECTED ' : '') . ' value="PM">pm</option>';
echo '</select> ';
}
function displayCalendarDate($nameCalendar, $imgId, $date, $enabled) {
echo '<input type="text" readOnly ' . ($enabled ? '' : ' disabled ') . ' name="' . $nameCalendar . '" class="input-text" style="width:75px" value="' . date('m-d-Y', $date) . '"> ';
echo '<img id="' . $imgId . '" style="display:' . ($enabled ? '' : ' none ') . '" src="/sentry/images/dhtmlgoodies_calendar/cal.gif" border="0" onclick="displayCalendar(document.submitForm.' . $nameCalendar. ', \'mm-dd-yyyy\',this)">';
}
function displayNextDays($nameDate, $numberOfDays, $enabled) {
echo '<select name="' . $nameDate . '" ' . ($enabled ? '' : ' disabled ') . '" class="input-text" style="width:85px">';
$count = 0;
$day = 0;
while ($count < 7) {
$nextDate = time() + ($day * 60 * 60 * 24);
if (date('N', $nextDate) < 6) {
echo '<option value="' . date('m-d-Y', $nextDate) . '">' . date('m-d-Y', $nextDate) . '</option>';
$count++;
}
$day++;
}
echo '</select>';
}
Thanks!