| Current Path : /var/www/html/mmishra/ilight/ |
| Current File : /var/www/html/mmishra/ilight/functions.inc |
<?php
function dbConnect() {
$link = mysql_connect("localhost", "erp", "erpa2018");
mysql_select_db("ilight");
return $link;
}
function uniq_sid($uid, $pwd) {
//$epwd = @mcrypt_ecb(MCRYPT_DES, "gravity", $pwd, MCRYPT_ENCRYPT);
$epwd = base64_encode($pwd);
//clear entry for ppl who havent done anything for past 20 minutes
//$result = mysql_query("delete from auth where last_activity < now()-1200");
srand((double)microtime()*100000000);
//generate a unique s_id
do {
$ch = "";
for($i=0; $i<20; $i++) $ch = $ch . chr(rand(65, 90));
//loop until a uniq string is generated
} while (!mysql_query("insert into auth values('$ch', '$uid','$epwd', NULL)"));
return $ch;
}
function sendmail($email, $subject, $body) {
$mail = new PHPMailer();
$mail->IsHTML(true); // telling the class to use HML format
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;//465;
$mail->SMTPSecure = 'tls';//'ssl';
$mail->SMTPAuth = true;
$mail->FromName = "iLight@IIITA";
$mail->From = "ilight@iiita.ac.in";
$mail->addReplyTo('a.engr@iiita.ac.in', 'Asstt. Engineer');
$mail->AddAddress($email, $email);
$mail->AddCC("ilight@iiita.ac.in","iLight@IIITA");
$mail->Username = "ilight@iiita.ac.in";
$mail->Password = "irp@2015";
$mail->Subject = $subject;
$mail->Body = $body . "<br>\niLight@IIITA\n\n<br><br>
Login at https://ilight.iiita.ac.in using LDAP credentials for updated information on electrical billing.<br><br>
(Automailer)";
$mail->WordWrap = 75;
if (!$mail->Send()) {
return $mail->ErrorInfo;
} else {
return TRUE;
}
}
function automailer($email, $subject, $body) {
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Tell PHPMailer to use SMTP
$mail->isHTML(true);
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 465;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'ssl';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "ilight@iiita.ac.in";
//Password to use for SMTP authentication
$mail->Password = "irp@2015";
//Set who the message is to be sent from
$mail->setFrom('ilight@iiita.ac.in', 'iLight@IIITA');
//Set an alternative reply-to address
$mail->addReplyTo('a.engr@iiita.ac.in', 'Asstt. Engineer');
//Set who the message is to be sent to
$mail->addAddress($email, $email);
//$mail->addBCC('mmishra@iiita.ac.in', 'Mmishra');
//Set the subject line
$mail->Subject = $subject;
$mail->Body = $body . "<br>\niLight@IIITA\n\n<br><br>
Login at https://ilight.iiita.ac.in using LDAP credentials for updated information on electrical billing.<br><br>
(Automailer)";
$mail->WordWrap = 75;
//send the message, check for errors
if (!$mail->send()) {
echo "<i>XX</i>";
} else {
echo "<i>OK</i>";
}
}
function localAuth($uid, $pwd) {
$role = 'licensee';
if ($uid) {
$rs = mysql_query("select * from webusers where userid='$uid'");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$role = $o->role;
}
}
return $role;
}
function ldapAuth($uid, $pwd) {
if ($uid && $pwd) {
//$ds = ldap_connect("ldaps://172.31.1.41:636");
if (!$ds) $ds = ldap_connect("ldap://172.31.1.41:389");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$a = ldap_search($ds, "dc=iiita,dc=ac,dc=in", "uid=$uid");
$b = ldap_get_entries($ds, $a);
$dn = $b[0]["dn"];
//******************************************************
$flag = (ldap_bind($ds, $dn, $pwd) ? TRUE : FALSE);
ldap_close($ds);
} else $flag = FALSE;
return $flag;
}
function accessLog($user, $referer, $url, $remoteip) {
$tbl = 'weblogs';
if (!$user) $user = 'guest';
if (!$referer) $referer = 'direct';
if ($url == '/') $url = 'index.php';
mysql_query("insert into $tbl(userid,referer,weburl,remoteip,dateaccess)
values('$user', '$referer', '$url','$remoteip',now())");
}
function user_group($uid) {
$ds = ldap_connect("172.31.1.42");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$z = ldap_bind($ds);
$a = ldap_search($ds,"dc=iiita,dc=ac,dc=in","(&(uid=$uid)(objectclass=posixAccount))");
$b = ldap_get_entries($ds,$a);
$dn = $b[0]["dn"];
$ou = explode(",", $dn);
if (strpos($dn,"Employee") || strpos($dn,"PhD"))
$grp = strtoupper(str_replace("ou=","",$ou[1]));
else
$grp = strtoupper(str_replace("ou=","",$ou[3] . $ou[2] . $ou[1]));
ldap_close($ds);
return $grp;
}
function user_name($uid) {
$ds = ldap_connect("172.31.1.42");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$z = ldap_bind($ds);
$a = ldap_search($ds,"dc=iiita,dc=ac,dc=in","(&(uid=$uid)(objectclass=posixAccount))");
$b = ldap_get_entries($ds,$a);
$cn = $b[0]["gecos"][0];
ldap_close($ds);
return strtoupper($cn);
}
function get_enum_values($table, $field) {
$rs = mysql_query("show columns from {$table} where field='{$field}'");
$r = mysql_fetch_object($rs);
$type = $r->Type;
preg_match("/^enum\(\'(.*)\'\)$/", $type, $matches);
$enum = explode("','", $matches[1]);
return $enum;
}
function getIP() {
//Just get the headers if we can or else use the SERVER global
if ( function_exists( 'apache_request_headers' ) ) {
$headers = apache_request_headers();
} else {
$headers = $_SERVER;
}
//Get the forwarded IP if it exists
if ( array_key_exists( 'X-Forwarded-For', $headers ) && filter_var( $headers['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {
$the_ip = $headers['X-Forwarded-For'];
} elseif ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ) && filter_var( $headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 )) {
$the_ip = $headers['HTTP_X_FORWARDED_FOR'];
} else {
$the_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 );
}
return $the_ip;
}
function htmlsafe($str) {
return trim(htmlspecialchars(stripslashes($str), ENT_QUOTES));
}
function unhtmlentities ($string) {
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
return strtr ($string, $trans_tbl);
}
function previous_month() {
$pmonth = (int)(date("n"));
if ($pmonth == 0) {
$pmonth = 12;
$pyear = date("Y") - 1;
} else
$pyear = date("Y");
return date("M-Y",mktime(0,0,0,$pmonth,0,$pyear));
}
function previous_month1($cmonth) {
$pmonth = (int)(date("n"));
if ($pmonth == 0) {
$pmonth = 12;
$pyear = date("Y",strtotime($cmonth)) - 1;
} else
$pyear = date("Y",strtotime($cmonth));
return date("M-Y",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-d",mktime(0,0,0,$nmonth,25,$nyear));
}
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 '';
} else
return '';
}
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($id) {
$rs = mysql_query("select * from employees where emp_no='$id'");
while ($o = mysql_fetch_object($rs)) {
$str = "$o->emp_name ($o->designation)";
}
return $str;
}
function employee_list($id) {
$str = "<select name='employee' style='width:230'>
<option value=''></option>";
$rs = mysql_query("select * from employees order by emp_name");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->emp_no'";
if ($id == $o->emp_no) $str .= ' selected';
$str .= ">$o->emp_name</option>";
}
$str .= "</select>";
return $str;
}
function technician_detail($id) {
$rs = mysql_query("select * from st_technicians where id=$id");
while ($o = mysql_fetch_object($rs)) {
$str = "$o->staff_name ($o->staff_post)";
}
return $str;
}
function technician_list($id) {
$str = "<select name='technician' style='width:230'><option value=''></option>";
$rs = mysql_query("select id,staff_name,staff_post from st_technicians order by staff_name");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->id'".($id == $o->id ? ' selected' : '').">$o->staff_name ($o->staff_post)</option>";
}
$str .= "</select>";
return $str;
}
function supplier_detail($id) {
$rs = mysql_query("select * from st_suppliers where id=$id");
while ($o = mysql_fetch_object($rs)) {
$str = "$o->firm_name ($o->address)";
}
return $str;
}
function supplier_list($id) {
$str = "<select name='supplier' style='width:230'><option value=''></option>";
$rs = mysql_query("select id,firm_name,address from st_suppliers order by firm_name");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->id'".($id == $o->id ? ' selected' : '').">$o->firm_name</option>";
}
$str .= "</select>";
return $str;
}
function bill_detail($id) {
$rs = mysql_query("select * from st_bills where id=$id");
while ($o = mysql_fetch_object($rs)) {
$str = "$o->bill_no dated $o->bill_date";
}
return $str;
}
function bill_list($id) {
$str = "<select name='bill_no' style='width:230'><option value=''></option>";
$rs = mysql_query("select * from st_bills order by id");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->id'".($id == $o->id ? ' selected' : '').">$o->bill_no</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 user_name1($regno) {
$rs = mysql_query("select pat_group,pat_id,dependent from registrations where reg_no=$regno");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$patgroup = $o->pat_group;
$patid = $o->pat_id;
$dependent = $o->dependent;
if ($patgroup == 'Student') $sql = "select name_eng as pname,gender as spec from students where roll_no='$patid'";
else if ($patgroup == 'Employee') $sql = "select emp_name as pname,designation as spec from employees where emp_no='$patid'";
else $sql = "select staff_name as pname,staff_post as spec from agencystaffs where staff_name='$patid'";
$rs = mysql_query($sql);
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$str .= "[ $patgroup: ".strtoupper($patid)." ]<br>$o->pname ($o->spec)";
} else {
$str .= "[ $patgroup: ".strtoupper($patid)." ]";
}
$str .= ($dependent ? "<br>Dependent: $dependent" : '<br>Self');
}
return $str;
}
function department_list($dept_no) {
$str = "<select name='dept_no'><option value=''></option>";
$rs = mysql_query("select * from departments order by dept_code");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->dept_no'";
if ($dept_no == $o->dept_no) $str .= ' selected';
$str .= ">$o->dept_code ($o->dept_name)</option>";
}
$str .= '</select>';
return $str;
}
function department_detail($dept_no) {
$rs = mysql_query("select * from departments where dept_no=$dept_no");
while ($o = mysql_fetch_object($rs)) {
$str = "$o->dept_code ($o->dept_name)";
}
return $str;
}
function project_list($project_no) {
$str = "<select name='project_no'><option value=''></option>";
$rs = mysql_query("select * from projects order by project_code");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->project_no'";
if ($project_no == $o->project_no) $str .= ' selected';
$str .= ">$o->project_code ($o->project_name)</option>";
}
$str .= '</select>';
return $str;
}
function project_detail($project_no) {
$rs = mysql_query("select * from projects where project_no=$project_no");
while ($o = mysql_fetch_object($rs)) {
$str = "$o->project_code ($o->project_name)";
}
return $str;
}
function category_list($code) {
$str = "<select name='category'>
<option value=''></option>";
$rs = mysql_query("select * from st_category order by code");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->id'";
if ($code == $o->id) $str .= ' selected';
$str .= ">$o->code ($o->description)</option>";
}
$str .= '</select>';
return $str;
}
function category_detail($code) {
$rs = mysql_query("select * from st_category where id=$code");
while ($o = mysql_fetch_object($rs)) {
$str = "$o->code ($o->description)";
}
return $str;
}
function subcategory_list($code) {
$str = "<select name='category'>
<option value=''></option>";
$rs = mysql_query("select * from st_subcategory order by code");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->id'";
if ($code == $o->id) $str .= ' selected';
$str .= ">$o->code ($o->description)</option>";
}
$str .= '</select>';
return $str;
}
function subcategory_detail($code) {
$rs = mysql_query("select * from st_subcategory where id=$code");
while ($o = mysql_fetch_object($rs)) {
$str = "$o->code ($o->description)";
}
return $str;
}
function item_list($code) {
$str = "<select name='item'>
<option value=''></option>";
$rs = mysql_query("select * from st_items order by code");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->id'";
if ($code == $o->id) $str .= ' selected';
$str .= ">$o->code ($o->description)</option>";
}
$str .= '</select>';
return $str;
}
function item_multilist($code) {
$str = "<select name='item[]'>
<option value=''></option>";
$rs = mysql_query("select * from st_items order by code");
while ($o = mysql_fetch_object($rs)) {
$str .= "<option value='$o->id'";
if ($code == $o->id) $str .= ' selected';
$str .= ">$o->code ($o->description)</option>";
}
$str .= '</select>';
return $str;
}
/*
function item_category($item) {
$rs = mysql_query("select * from st_category where id=(select category from st_items where id=$item)");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$str = $o->code;
}
return $str;
}
*/
function item_category($item) {
$rs = mysql_query("select * from st_category where id=$item");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$str = $o->code;
}
return $str;
}
/*
function item_subcategory($item) {
$rs = mysql_query("select * from st_subcategory where id=(select subcategory from st_items where id=$item)");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$str = $o->code;
}
return $str;
}
*/
function item_subcategory($item) {
$rs = mysql_query("select * from st_subcategory where id=$item");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$str = $o->code;
}
return $str;
}
function item_detail($code) {
$rs = mysql_query("select a.*,b.item_type from st_items a, st_subcategory b where a.subcategory=b.id and a.id=$code");
while ($o = mysql_fetch_object($rs)) {
$str = "$o->code; $o->description ($o->item_type)";
}
return $str;
}
function indent_approved($code) {
$rs = mysql_query("select * from indents where indent_no=$code");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$str = "<table border='1' width='99%' style='border-collapse: collapse'>
<tr><th>Indent No.: $code</th><th>Dated: $o->indent_date</th></tr>
<tr><td width='50%'>Purpose: $o->purpose</td><td>Recommendation: $o->recommendation</td></tr>
</table>";
$str .= "<table border='1' width='99%' style='border-collapse: collapse'>
<tr><th>No.</th><th>Particulars</th><th>Indent Qty</th><th>Approved Qty</th></tr>";
$sr = mysql_query("select * from indent_items where indent_no=$code order by id");
while ($q = mysql_fetch_object($sr)) {
$i++;
$str .= "<tr><td>$i</td><td>".item_detail($q->item)."</td><td>$q->qty_demand</td><td>$q->qty_approve</td></tr>";
}
$str .= "</table><br>";
}
return $str;
}
function indent_issued($code) {
$rs = mysql_query("select * from indents where indent_no=$code");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$str = "<table border='1' width='99%' style='border-collapse: collapse'>
<tr><th>Indent No.: $code</th><th>Dated: $o->indent_date</th></tr>
<tr><td width='50%'>Purpose: $o->purpose</td><td>Recommendation: $o->recommendation</td></tr>
</table>";
$str .= "<table border='1' width='99%' style='border-collapse: collapse'>
<tr><th>No.</th><th>Particulars</th><th>Indent Qty</th><th>Approved Qty</th><th>Issued Qty</th></tr>";
$sr = mysql_query("select * from indent_items where indent_no=$code order by id");
while ($q = mysql_fetch_object($sr)) {
$i++;
$str .= "<tr><td>$i</td><td>".item_detail($q->item)."</td><td>$q->qty_demand</td><td>$q->qty_approve</td></td>";
$ss = mysql_query("select * from st_stockout where indent_no=$code and item=$q->item");
if (mysql_num_rows($ss)) {
$r = mysql_fetch_object($ss);
$str .= $r->qty_out;
}
$str .= "</td></tr>";
}
$str .= "</table><br>";
}
return $str;
}
function staff_list($phid) {
$tbl = 'staffs';
$str = "<select name='phid'><option value=''></option>";
$rs = mysql_query("select * from $tbl 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) {
$tbl = 'staffs';
$str = "<select name='phid[]' size='7' multiple><option value=''></option>";
$rs = mysql_query("select * from $tbl 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) {
$tbl = 'staffs';
$rs = mysql_query("select * from $tbl 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) {
$tbl = 'staffs';
//$str = "<div>";
$rs = mysql_query("select * from $tbl where ph_id='$phid'");
while ($o = mysql_fetch_object($rs)) {
$str .= "$o->ph_name ($o->specialization)";
}
//$str .= "</div>";
return $str;
}
function medicine_list($medid,$plusminus) {
$tbl = 'medicines';
$str = "<select name='medid'>";
if ($plusminus == '+')
$rs = mysql_query("select * from $tbl order by med_name");
else {
//$rs = mysql_query("select med_id,med_name from $tbl where qty_inhand>qty_critical order by med_name");
$rs = mysql_query("select * from $tbl where qty_inhand>0 order by med_name");
}
while ($o = mysql_fetch_object($rs)) {
$str .= "<option style='color:".($o->qty_inhand <= $o->qty_critical ? 'red' : '')."' value='$o->med_id'";
if ($medid == $o->med_id) $str .= ' selected';
$str .= ">$o->med_name ($o->qty_inhand/$o->qty_critical/$o->qty_used)</option>";
}
$str .= '</select>';
return $str;
}
function medicine_detail($medid) {
$tbl = 'medicines';
$str = "<div>";
$rs = mysql_query("select med_name from $tbl where med_id=$medid");
while ($o = mysql_fetch_object($rs)) {
$str .= "$o->med_name";
}
$str .= "</div>";
return $str;
}
function material_list($medid,$plusminus) {
$tbl = 'materials';
$str = "<select name='medid'>";
if ($plusminus == '+')
$rs = mysql_query("select * from $tbl order by med_name");
else {
//$rs = mysql_query("select med_id,med_name from $tbl where qty_inhand>qty_critical order by med_name");
$rs = mysql_query("select * from $tbl where qty_inhand>0 order by med_name");
}
while ($o = mysql_fetch_object($rs)) {
$str .= "<option style='color:".($o->qty_inhand <= $o->qty_critical ? 'red' : '')."' value='$o->med_id'";
if ($medid == $o->med_id) $str .= ' selected';
$str .= ">$o->med_name ($o->qty_inhand/$o->qty_critical/$o->qty_used)</option>";
}
$str .= '</select>';
return $str;
}
function material_detail($medid) {
$tbl = 'materials';
$str = "<div>";
$rs = mysql_query("select med_name from $tbl where med_id=$medid");
while ($o = mysql_fetch_object($rs)) {
$str .= "$o->med_name";
}
$str .= "</div>";
return $str;
}
function registration_detail($regno) {
$rs = mysql_query("select * from registrations where reg_no=$regno");
while ($o = mysql_fetch_object($rs)) {
$str = "<table border='1' width='80%'>
<tr><th>RegNo</th><th>Registration Date</th><th>Patient Detail</th><th>Doctor Detail</th></tr>
<tr><td align='center'>$regno</td><td align='center'>$o->reg_date $o->reg_time</td>
<td>".patient_detail($o->pat_id)."</td>
<td align='center'>".doctor_detail($o->dr_id)."</td>
</tr></table><br>";
}
return $str;
}
//multiple registrations
function list_registrations($patid) {
$str = "[ $patid]".patient_detail($patid);
$rs = mysql_query("select * from registrations where pat_id='$patid' order by reg_no desc");
while ($o = mysql_fetch_object($rs)) {
$i++;
$str .= "$i) ".($o->dependent ? "Dependent: ".strtoupper($o->dependent) : "Self");
$str .= "<table border='1' width='95%'>
<tr><th>RegNo</th><th>Registration Date</th><th>Doctor</th><th>Staff</th></tr>
<tr><td align='center'>$o->reg_no</td><td align='center'> $o->reg_date $o->reg_time</td>
<td align='center'>".doctor_detail($o->dr_id)."</td>
<td align='center'>".staff_detail($o->login_id)."</td>
</tr></table><br>";
}
return $str;
}
?>