| Current Path : /var/www/html/mmishra/iws8/html/gian/ |
| Current File : /var/www/html/mmishra/iws8/html/gian/functions.inc |
<?php
function list_tabledata($sql) {
$rs = mysql_query($sql);
if (mysql_num_rows($rs)) {
$colHeads = mysql_num_fields($rs);
$str = "<table border='1' width='90%'><tr><th>Sr</th>";
for ($i=0; $i < $colHeads; $i++) { // Header
$str .= "<th>".ucwords(str_replace("_"," ",mysql_field_name($rs, $i)))."</th>";
}
$str .= "</tr>";
while ($row = mysql_fetch_row($rs)) { //data
$j++;
$str .= "<tr><td>$j</td><td>".implode($row,'</td><td>')."</td></tr>";
}
$str .= "</table>";
} else {
$str = "---";
}
return $str;
}
function get_email($patgroup, $patid) {
if ($patgroup == 'Student')
return $patid.'@iiita.ac.in';
else if ($patgroup == 'Employee') {
$rs = mysql_query("select email from employees where emp_no='$patid'");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
return $o->email;
} else
return 'icure@iiita.ac.in';
} else
return 'rdayal@iiita.ac.in';
}
function is_student($patid) {
$tbl = 'students';
$rs = mysql_query("select * from $tbl where roll_no='$patid'");
if (mysql_num_rows($rs)) return TRUE;
else return FALSE;
}
function student_detail($rollno) {
$tbl = 'students';
$str = "<div>";
$rs = mysql_query("select * from $tbl where roll_no='$rollno'");
while ($o = mysql_fetch_object($rs)) {
$str .= "$o->name_eng ($o->dob)";
}
$str .= "</div>";
return $str;
}
function is_employee($patid) {
$tbl = 'employees';
$rs = mysql_query("select * from $tbl where emp_no='$patid'");
if (mysql_num_rows($rs)) return TRUE;
else return FALSE;
}
function employee_detail($empno) {
$tbl = 'employees';
$str = "<div>";
$rs = mysql_query("select * from $tbl where emp_no='$empno'");
while ($o = mysql_fetch_object($rs)) {
$str .= "$o->emp_name ($o->designation)";
}
$str .= "</div>";
return $str;
}
function employee_list($empno) {
$tbl = 'employees';
$str = "<select name='patid' style='width:230'><option value=''>Select Name</option>";
$rs = mysql_query("select emp_no,emp_name,designation from $tbl order by emp_name");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->emp_no'".($empno == $o->emp_no ? ' selected' : '').">$o->emp_name</option>";
}
$str .= "</select>";
return $str;
}
function agencystaff_detail($staffnm) {
$tbl = 'agencystaffs';
$str = "<div>";
$rs = mysql_query("select * from $tbl where staff_name='$staffnm'");
while ($o = mysql_fetch_object($rs)) {
$str .= "$o->staff_name ($o->staff_post)";
}
$str .= "</div>";
return $str;
}
function staff_list($phid) {
$str = "<select name='phid'><option value=''></option>";
$rs = mysql_query("select * from staffs order by ph_name");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->ph_id'";
if ($phid == $o->ph_id) $str .= ' selected';
$str .= ">$o->ph_name</option>";
}
$str .= '</select>';
return $str;
}
function staffmulti_list($phid) {
$str = "<select name='phid[]' size='7' multiple><option value=''></option>";
$rs = mysql_query("select * from staffs order by ph_name");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->ph_id'";
if ($phid == $o->ph_id) $str .= ' selected';
$str .= ">$o->ph_name</option>";
}
$str .= '</select>';
return $str;
}
function staffcheck_list($phid) {
$rs = mysql_query("select * from staffs order by ph_name");
while ($o = mysql_fetch_object($rs)) {
$str .= "<input type='checkbox' name='phid[]' value='$o->ph_id'";
if ($phid == $o->ph_id) $str .= ' checked';
$str .= ">$o->ph_name";
}
return $str;
}
function staff_detail($phid) {
//$str = "<div>";
$rs = mysql_query("select * from staffs where ph_id='$phid'");
while ($o = mysql_fetch_object($rs)) {
$str .= "$o->ph_name ($o->specialization)";
}
//$str .= "</div>";
return $str;
}
function hospital_list($hosid) {
$tbl = 'hospitals';
$str = "<select name='hosid'><option value=''></option>";
$rs = mysql_query("select * from $tbl order by hos_name");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->hos_id'";
if ($testid == $o->hos_id) $str .= ' selected';
$str .= ">$o->hos_name</option>";
}
$str .= "</select>";
return $str;
}
function hospital_detail($hosid) {
$str = "";
$rs = mysql_query("select * from hospitals where hos_id=$hosid");
while ($o = mysql_fetch_object($rs)) {
$str .= "$o->hos_name, $o->address";
}
$str .= "";
return $str;
}
function previous_month() {
$pmonth = (int)(date("n"));
if ($pmonth == 0) {
$pmonth = 12;
$pyear = date("Y") - 1;
} else
$pyear = date("Y");
return date("Y-m", mktime(0, 0, 0, $pmonth, 0, $pyear));
}
function next_month() {
$nmonth = (int)(date("n"));
if ($nmonth == 12) {
$nmonth = 0;
$nyear = date("Y") + 1;
} else
$nyear = date("Y");
$nmonth = $nmonth + 1;
return date("Y-m", mktime(0, 0, 0, $nmonth, 25, $nyear));
}
function DateAdd($days) {
$curdate = getdate();
$cday = $curdate['mday'] + $days;
$cmonth = $curdate['mon'];
$cyear = $curdate['year'];
if ($cday > 31) {
$cmonth = $cmonth + 1;
$cday = $cday - 31;
if ($cmonth == 13) {
$cyear = $cyear + 1;
$cmonth = 1;
}
}
if ($cday < 10) $cday = "0$cday";
if ($cmonth < 10) $cmonth = "0$cmonth";
//$ourDate = array($cyear, $cmonth, $cday);
$ourDate = "$cyear-$cmonth-$cday";
return $ourDate;
}
function htmlsafe($str) {
return trim(htmlspecialchars(stripslashes($str), ENT_QUOTES));
}
function htmlunsafe($str) {
return trim(htmlspecialchars_decode($str, ENT_COMPAT));
}
?>