| Current Path : /var/www/html/mmishra/icure/admin/ |
| Current File : /var/www/html/mmishra/icure/admin/dschedules.inc |
<h3 align='left'>Doctor Schedule</h3>
<center>
<?php
$tbl = 'dschedules';
$schid = $_REQUEST["schid"];
$monthyear = $_REQUEST["monthyear"];
if (!$monthyear) $monthyear = date("Y-m");
if ($_POST["submit"] == 'SAVE') {
$drid = $_POST["drid"];
$dayweek = $_POST["dayweek"];
$timing = $_POST["timing"];
if (!$timing) {
$ftime = $_POST["ftime"];
$ttime = $_POST["ttime"];
//if ($ftime < $ttime)
$timing = "$ftime - $ttime";
//else echo "Wrong timing";
}
if (mysql_num_rows(mysql_query("select * from $tbl where sch_id=$schid"))) {
mysql_query("update $tbl set dr_id='$drid',period='$monthyear',day_week='$dayweek',timing='$timing',
login_id='$user' where sch_id=$schid");
} else {
mysql_query("insert into $tbl(dr_id,period,day_week,timing,login_id)
values('$drid','$monthyear','$dayweek','$timing','$user')");
}
} else if ($_POST["submit"] == 'DELETE') {
mysql_query("update $tbl set dr_id='' where sch_id=$schid");
}
if ($_GET["repeat"] == 1) {
$pmonthyear = previous_month();
$rs = mysql_query("select * from $tbl where period='$pmonthyear' order by sch_id");
while ($o = mysql_fetch_object($rs)) {
$i++;
mysql_query("insert into $tbl(dr_id,period,day_week,timing,date_creation,date_updation,login_id)
values('$o->dr_id','$monthyear','$o->day_week','$o->timing',now(),now(),'$user')");
}
} else if ($_GET["clear"] == 1) {
mysql_query("delete from $tbl where period='$monthyear'");
}
?>
Select month <select name='monthyear'>
<?php
$cal = explode("-", $monthyear);
$m = $cal[1];
$y = $cal[0];
$rs = mysql_query("select distinct concat(year(reg_date),'-',month(reg_date)) as monthyear from registrations order by reg_date desc");
while ($o = mysql_fetch_object($rs)) {
if (strlen($o->monthyear) == 6) $myear = str_replace("-","-0",$o->monthyear);
else $myear = $o->monthyear;
echo "<option value='$myear'";
if ($myear == $monthyear) echo " selected";
echo ">$myear</option>";
}
?>
</select> <input type='submit' name='submit' value='OK'>
<table border='1' width='80%'>
<tr><th nowrap>Time Slots \ Day of Week</th>
<?php
$dayweeks = array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
foreach ($dayweeks as $dw) {
echo "<th>$dw</th>";
}
echo "</tr>";
$i = 0; $j = 0; $k = 0;
$rs = mysql_query("select distinct timing from $tbl where period='$monthyear' order by sch_id");
while ($o = mysql_fetch_object($rs)) {
$i++;
$timing = $o->timing;
echo "<tr><th>$timing</th>";
$j = 0;
$sr = mysql_query("select * from $tbl where period='$monthyear' and timing='$timing' order by sch_id");
while ($q = mysql_fetch_object($sr)) {
$j++;
echo "<td align='center'>";
if ($schid == $q->sch_id) {
echo doctor_list($q->dr_id) . "<input type='hidden' name='dayweek' value='$q->day_week'>
<input type='hidden' name='timing' value='$q->timing'><input type='hidden' name='schid' value='$q->sch_id'>";
} else if ($monthyear == $q->period) {
echo "<a href='?pg=$pg&edit=1&schid=$q->sch_id'>".($q->dr_id ? $q->dr_id : 'x') ."</a>";
} else {
echo ($q->dr_id ? $q->dr_id : 'x');
}
echo "</td>";
$did = $q->dr_id;
}
if ($j < 7 || ($j < 7 && $did == '')) {
echo "<td>" . doctor_list($drid) . "<input type='hidden' name='dayweek' value='".$dayweeks[$j] . "'>
<input type='hidden' name='timing' value='$timing'><input type='hidden' name='schid' value='$q->sch_id'></td>";
} else $j = 0;
echo "</tr>";
}
$edit = $_GET["edit"];
$timings = explode(" - ", $timing);
echo "<tr>";
if ((!$i || !$j) && ($edit == 0)) {
echo "<th>";
if ($timings[1]) {
echo $timings[1] . "<input type='hidden' name='ftime' value='" . $timings[1] . "'>";
} else {
echo "<select name='ftime'>";
for ($j = 0; $j < 24; $j++) {
echo "<option value='$j'>$j</option>";
}
echo "</select>";
}
echo " - <select name='ttime'>";
for ($j = 1; $j < 24; $j++) {
echo "<option value='$j'>$j</option>";
}
echo "</select></th>
<td>" . doctor_list($drid) . "<input type='hidden' name='dayweek' value='" . $dayweeks[0] . "'></td>";
} else {
echo "<th><a href='?pg=$pg&schid='>Next</a></th>";
}
echo "</tr>";
if (!mysql_num_rows($rs)) {
echo "<tr><td colspan='8'>[ <a href='?pg=$pg&repeat=1'>Repeat Last Schedules</a> ]</td></tr>";
}
?>
<tr><th colspan='8'>
<input type='submit' name='submit' value='SAVE'>
[ <a href='?pg=<?php echo $pg; ?>&clear=1&monthyear=<?php echo $monthyear; ?>'>Clear Above Schedules</a> ]
<input type='submit' name='submit' value='DELETE'>
</th></tr></table>
</center>