Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/istore/
Upload File :
Current File : /var/www/html/mmishra/istore/z.php

<?php
include "functions.inc";
include "config.inc";

dbConnect("istore");

/*
$uid = 'mmishra';
$pwd = 'happy@2016';

 $ds = ldap_connect("ldaps://172.31.1.41:636");
 //$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);

echo $dn.' ['.$flag.']';


include "tenders.php";

$myTender = new iTender;

echo $myTender->title;

$myTender->
*/
?>
<h2 align='left'>Stock Alert</h2>

<?php

$rs = mysql_query("select i.*,e.emp_name,e.email from indents as i,employees as e where i.emp_no=e.emp_no and i.status='Approved' order by i.emp_no,i.indent_no");
while ($o = mysql_fetch_object($rs)) {
	$indentno = $o->indent_no;
	$empno = $o->emp_no;
        $email = $o->email;

	//send status mail for available items
	if ($email && availableAlert($indentno)) {
		$no++;
		//if ($email) automailer($email, "Indent Approval", $str);
        	//automailer('istore@iiita.ac.in', "Indent Approval", $str);
		echo "<h1>$no</h1>".$email."<div>".availableAlert($indentno)."</div>";
	}
}

function stockStatus($itemno) {
        $rs = mysql_query("select * from st_items where item=$itemno");
        if (mysql_num_rows($rs)) {
		$o = mysql_fetch_object($rs);
		return $o->qty_in - $o->qty_out;
	} else {
		return 0.00;
	}

}

function availableAlert($indentno) {
        //get available items list
        $rs = mysql_query("select i.*,e.emp_name from indents as i,employees as e where i.emp_no=e.emp_no and indent_no=$indentno");
        if (mysql_num_rows($rs)) {
                $o = mysql_fetch_object($rs);
		$str = "Dear Indentor
                <br><br>
                With reference to your indent (Ref. No. $indentno) some items marked with '<font size='+1' color='red'>*</font>' are available readily in the stock of Central Store.<br>
                Kindly collect them during 12 - 1 PM (Cleaning items) and 3 - 4 PM (Stationary & Crockery items) at your suitable convenience.<br>
                Remaining items, however, may take some time as they are subject to purchase processing.
                <br><br> 

		<table width='90%' border='1' style='border-collapse: collapse'>
		<tr><th>Indent No.: $o->indent_no ($o->status)</th><th>Account: $o->emp_name ($o->account)</th><th>Dated: $o->date_indent</th></tr>
		<tr><td>Location: $o->location</td><td>Purpose: $o->purpose</td><td>Recommendor: $o->recommendation</td></tr>
		</table>
                <table border='1' width='90%' style='border-collapse: collapse'>
                <tr><th>No.</th><th>Particulars</th><th>Qty Demand</th><th>Qty Approve</th><th>Qty Out</th><th>Approx Cost</th></tr>";
                $sr = mysql_query("select * from indent_items where indent_no=$indentno order by id");
                while ($q = mysql_fetch_object($sr)) {
                        $i++;
                        $star = '';
			if (mysql_num_rows(mysql_query("select * from st_items where id=$q->item and qty_in-qty_out>0"))) {
                                if ($q->qty_approve > $q->qty_out) {
					$star = "<font size='+1' color='red'>*</font>";
                        		$z++;
                        	}
			}
                        //list indented items
                        $str .= "<tr><td>$i $star</td><td>". item_detail($q->item). "</td><td>". number_format($q->qty_demand,2). " $q->unit</td>
                        <td>". number_format($q->qty_approve,2). " $q->unit</td><td>". number_format(issuedQty($indentno, $q->item),2). " $q->unit</td><td>$q->approx_cost</td></tr>";
                }
                $str .= "</table><br>Thanks,<br><br>";
        }
	if ($z) return $str;
	else return '';
}

function issuedQty($indentno, $itemno) {
        $rs = mysql_query("select * from st_stockout where indent_no=$indentno and item=$itemno");
        if (mysql_num_rows($rs)) {
		$o = mysql_fetch_object($rs);
		return $o->qty_out;
	} else {
		return 0;
	}
}

?>
</center>