| Current Path : /var/www/html/mmishra/icure/public/ |
| Current File : /var/www/html/mmishra/icure/public/ihcSummary.inc |
<?php
$tbl = 'registrations';
$monthyear = $_REQUEST["monthyear"];
if (!$monthyear) $monthyear = date("Y-m");
$cal = explode("-", $monthyear);
$m = $cal[1];
$y = $cal[0];
$str = "<h3 align='left'>Health Center Summary</h3><center>
Select month <select name='monthyear' onchange=\"javascript: document.location.href='?pg=$pg&monthyear='+this.value\">";
//<option value=''></option>";
$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;
$str .= "<option value='$myear'". ($myear == $monthyear ? " selected" : ''). ">$myear</option>";
}
$str .= "</select>
<table style='font-size:x-small; border-collapse: collapse' border='1' width='90%'>
<tr valign='top'>";
$heads = array('Registration For','Registration By','Pathology Tests By','Patients','Batch','Course','Gender','Hostel','BG');
$sqls = array("select concat(dr_name,', ',specialization) as doctor,count(reg_no) as patients
from registrations as a, doctors as b
where a.dr_id=b.dr_id and reg_date like '$monthyear%' group by a.dr_id",
"select concat(ph_name,', ',specialization) as staff,count(reg_no) as patients
from registrations as a, staffs as b
where a.login_id=b.ph_id and reg_date like '$monthyear%' group by a.login_id",
"select concat(ph_name,', ',specialization) as staff,count(distinct reg_no) as patients
from phresults as a, staffs as b
where a.login_id=b.ph_id and test_date like '$monthyear%' group by a.login_id",
"select pat_group as Category,count(reg_no) as patients
from registrations
where reg_date like '$monthyear%' group by pat_group",
"select year as batch,count(reg_no) as patients
from students as a,registrations as b
where a.roll_no=b.pat_id and reg_date like '$monthyear%' group by year",
"select course_name,count(reg_no) as patients
from students as a,registrations as b
where a.roll_no=b.pat_id and reg_date like '$monthyear%' group by course_name",
"select gender,count(reg_no) as patients
from students as a,registrations as b
where a.roll_no=b.pat_id and reg_date like '$monthyear%' group by gender",
"select hostel_no,count(reg_no) as patients
from students as a,registrations as b
where a.roll_no=b.pat_id and reg_date like '$monthyear%' group by hostel_no",
"select bg as blood_group,count(reg_no) as patients
from students as a,registrations as b
where a.roll_no=b.pat_id and reg_date like '$monthyear%' group by bg");
$cols = 3;
$colw = 100/$cols;
$no = 0;
foreach ($sqls as $sql) {
$str .= "<td width='$colw%' align='center'><b>".$heads[$no]."</b><br>";
$no++;
$tno = 0;
$rs = mysql_query($sql);
if (mysql_num_rows($rs)) {
$colHeads = mysql_num_fields($rs);
$str .= "<table style='font-size:x-small; border-collapse: collapse' border='1' width='99%'>
<tr>";
for ($i=0; $i < $colHeads; $i++) { // Header
$str .= "<th>".ucwords(str_replace("_"," ",mysql_field_name($rs, $i)))."</th>";
}
$str .= "</tr>";
$j = 0;
while ($row = mysql_fetch_row($rs)) { //data
$j++;
$str .= "<tr><td>".implode($row,'</td><td>')."</td></tr>\n";
$tno = $tno + $row[1];
}
$str .= "<tr><th>Total</th><th>$tno</th></tr></table><br>";
} else {
$str .= "---";
}
$str .= "</td>";
$k++;
if ($k % $cols == 0) $str .= "</tr><tr valign='top'>";
}
$i = 0;
$str .= "</tr></table>";
echo $str;
?>