| Current Path : /var/www/html/mmishra/mm/libsite/ |
| Current File : /var/www/html/mmishra/mm/libsite/libsite_library.inc |
<?php
function table_data($sql9, $linkid, $no, $db){
$result9 = mysql_query($sql9, $linkid);
if (!mysql_num_rows($result9)){
$sdata .= "<br>None...";
}else{
$sdata .= "<table width='100%'><tr valign='top'><th>No.</th>";
$num_fields = mysql_num_fields($result9);
for ($y = 0; $y < $num_fields; $y++){
$sdata .= "<th><a href='" . $_SERVER["SCRIPT_NAME"] . "?db=$db&sfield=" . mysql_field_name($result9, $y) . "'>" . ucfirst(strtr(mysql_field_name($result9, $y), "_", " ")) . "</a></th>";
}
$sdata .= "</tr>";
while ($qdata = mysql_fetch_row($result9)){
$no++;
$sdata .= "<tr id='";
if ($no % 2) $sdata .= "row1'>"; else $sdata .= "row2'>";
$sdata .= "<td>$no</td>";
for ($z = 0; $z < $num_fields; $z++){
$sdata .= "<td>" . $qdata[$z] . "</td>";
}
$sdata .= "</tr>";
}
mysql_free_result($result9);
$sdata .= "</table>";
}
return $sdata;
}
function list_data($sql9, $linkid, $ttl){
$result9 = mysql_query($sql9, $linkid);
if (!$result9) echo sql_error();
$ldata = "<b>$ttl</b>";
if (!mysql_num_rows($result9)){
$ldata .= "<br>None...";
}else{
$ldata .= "<table width='90%'>";
while ($qdata = mysql_fetch_row($result9)){
$y++;
$num_fields = mysql_num_fields($result9);
$ldata .= "<tr><th colspan='2'>$y</th></tr>";
for ($z = 0; $z < $num_fields; $z++){
$ldata .= "<tr id='";
if ($z % 2) $ldata .= "row1'>"; else $ldata .= "row2'>";
$ldata .= "<td>" . ucfirst(strtr(mysql_field_name($result9, $z), "_", " ")) . "</td>";
$ldata .= "<td nowrap>" . $qdata[$z] . "</td>";
}
$ldata .= "</tr>";
}
mysql_free_result($result9);
$ldata .= "</table>";
}
return $ldata;
}
function document_title($accno, $linkid){
$result9 = mysql_query("select document_type, document_code from accession_master where accession_no='$accno'", $linkid);
if (!$result9) echo sql_error();
if (!mysql_num_rows($result9)){
$dttl = "<br>Wrong accession no.";
}else{
$qdata = mysql_fetch_array($result9);
$doc_type = $qdata["document_type"];
$doc_code = $qdata["document_code"];
$result9 = mysql_query("select title from " . $doc_type . "_master where document_code='$doc_code'", $linkid);
$qdata = mysql_fetch_array($result9);
$dttl = $qdata["title"];
mysql_free_result($result9);
}
return $dttl;
}
//mail subroutine
function overdue_mail($mcode, $linkid){
if ($mcode == ""){
$sql9 = "select c.accession_no, c.issue_date, c.due_date, m.email from circulation_master c, member_master m where c.member_code=m.member_code and c.due_date < curdate() and return_date is null";
}else{
$sql9 = "select c.accession_no, c.issue_date, c.due_date, m.email from circulation_master c, member_master m where c.member_code=m.member_code and m.member_code='$mcode' and c.due_date < curdate() and return_date is null";
}
$result9 = mysql_query($sql9, $linkid);
if(!$result9) echo sql_error();
if (!mysql_num_rows($result9)){
return "None overdue...";
}else{
$mail_body = "AccessionNo.---issue_date---due_date---remark\n";
while ($qdata = mysql_fetch_array($result9)){
$mail_body .= $qdata["accession_no"] . "---" . $qdata["issue_date"] . "---" . $qdata["due_date"] . "\n";
}
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.local"; // SMTP server
$mail->From = "library@iiita.ac.in";
$mail->AddAddress("$email");
$mail->Subject = "Overdue Reminder from Library";
$mail->Body = "$mail_body\n\nThese documents are pending to you. kindly return/re-issue them.";
$mail->WordWrap = 50;
if(!$mail->Send()){
//echo "Message was not sent";
return "Mailer Error: " . $mail->ErrorInfo;
}else{
return "Message has been sent";
}
return $mail_body;
}
}
function table_info($tbl, $linkid, $fkey, $val){
$sql8 = "select * from $tbl";
$result8 = mysql_query($sql8, $linkid);
$result9 = mysql_list_fields("mmishra", $tbl, $linkid);
$sdata = "<table>";
for ($i=0; $i < mysql_num_fields($result9); $i++){
$field_info_object = mysql_fetch_field($result9, $i);
$fname = $field_info_object->name;
$fsize = mysql_field_len($result9, $i);
$sdata .= "<tr><th>" . ucfirst(strtr($fname,"_", " ")) . "</th><td>";
if ($fsize > 100) $sdata .= "<textarea name='$fname' rows='2' cols='40'></textarea>";
else if ($fsize > 50) $sdata .= "<input type='text' name='$fname' value='' size='50'>";
else $sdata .= "<input type='text' name='$fname' value='' size='$fsize'>";
// $sdata .= " (" . $field_info_object->max_length . ") ";
$sdata .= " " . $field_info_object->type . ",";
if ($field_info_object->not_null) $sdata .= " null value not allowed"; else $sdata .= " null allowed";
if ($field_info_object->primary_key) $sdata .= " (primary key)";
else if ($field_info_object->multiple_key) $sdata .= " (key)";
else if ($field_info_object->unique_key) $sdata .= " (should be unique)";
if ($field_info_object->unsigned) $sdata .= " unsigned";
if ($field_info_object->zerofill) $sdata .= " zero-filled";
$sdata .= "</td></tr>";
}
$sdata .= "</table>";
return $sdata;
}
?>