| Current Path : /var/www/html/mmishra/irp/irp/pcstore/ |
| Current File : /var/www/html/mmishra/irp/irp/pcstore/mcell_library.inc |
<?php
function category_detail($row_id9, $linkid){
$sql9 = "select * from category_master where row_id=$row_id9";
$rs9 = mysql_query($sql9, $linkid);
$qd9 = mysql_fetch_array($rs9);
$code = $qd9["category_code"];
$description = $qd9["description"];
return $code . " (" . $description . ")";
}
function supplier_detail($row_id9, $linkid){
$sql9 = "select * from supplier_master where row_id=$row_id9";
$rs9 = mysql_query($sql9, $linkid);
$qd9 = mysql_fetch_array($rs9);
$code = $qd9["supplier_code"];
$description = $qd9["firm_name"];
//return $code . " (" . $description . ")";
return $description;
}
function user_detail($row_id9, $linkid){
$sql9 = "select * from user_master where row_id=$row_id9";
$rs9 = mysql_query($sql9, $linkid);
$qd9 = mysql_fetch_array($rs9);
$name = $qd9["name"];
$category = $qd9["category"];
return $name . " (" . $category . ")";
}
function pc_detail($row_id9, $linkid){
$sql9 = "select * from pc_master where row_id=$row_id9";
$rs9 = mysql_query($sql9, $linkid);
$qd9 = mysql_fetch_array($rs9);
$code = $qd9["pc_code"];
$description = $qd9["pc_series"];
return $code . " (" . $description . ")";
}
function item_detail($row_id9, $linkid){
$sql9 = "select * from item_master where row_id=$row_id9";
$rs9 = mysql_query($sql9, $linkid);
$qd9 = mysql_fetch_array($rs9);
$code = $qd9["description"];
$description = $qd9["model_make"];
return $code . " (" . $description . ")";
}
function parts_detail($row_id9, $linkid){
$sql9 = "select * from parts_master where row_id=$row_id9";
$rs9 = mysql_query($sql9, $linkid);
$qd9 = mysql_fetch_array($rs9);
$code = $qd9["parts_code"];
//$description = $qd9["remark"];
return $code;// . " (" . $description . ")";
}
function table_data($sql9, $linkid, $no, $db){
$result9 = mysql_query($sql9, $linkid);
if (!mysql_num_rows($result9)){
$sdata .= "<br>None...";
}else{
$sdata .= "<table width='99%'><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++){
switch ($qdata[$z]){
case "0000-00-00":
$fldvalue = " ";
break;
case "0":
$fldvalue = "Nil";
break;
default:
$fldvalue = $qdata[$z];
break;
}
$sdata .= "<td>$fldvalue</td>";
}
$sdata .= "</tr>";
//$no++;
}
mysql_free_result($result9);
$sdata .= "</table>";
}
return $sdata;
}
//mail
function overdue_mail($ucode, $linkid){
if ($ucode == ""){
//$sql9 = "select c.serial_no, c.issue_date, c.due_date, u.email from consumption_master c, user_master u where c.user_code=u.user_code and c.due_date < curdate() and c.return_date is null";
$sql9 = "select c.serial_no, c.issue_date, c.due_date, u.email from consumption_master c, user_master u where c.user_code=u.user_code and c.return_date is null";
}else{
//$sql9 = "select c.serial_no, c.issue_date, c.due_date, u.email from consumption_master c, user_master u where c.user_code=u.user_code and u.user_code='$ucode' and c.due_date < curdate() and c.return_date is null";
$sql9 = "select c.serial_no, c.issue_date, c.due_date, u.email from consumption_master c, user_master u where c.user_code=u.user_code and u.user_code='$ucode' and c.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 = "SerialNo.---issue_date---due_date---remark\n";
while ($qdata = mysql_fetch_array($result9)){
$mail_body .= $qdata["serial_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 = "mmishra@iiita.ac.in";
$mail->AddAddress("$email");
$mail->Subject = "Overdue Reminder from MCell";
$mail->Body = "$mail_body\n\nThese items are overdue to you. kindly return 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;
}
}
?>