Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/iws8/html/erp/
Upload File :
Current File : /var/www/html/mmishra/iws8/html/erp/automailing.php

<?php
include('config.inc');
include('functions.inc');
require('classes/PHPMailerAutoload.php');
require("classes/class.phpmailer.php");
date_default_timezone_set('Asia/Kolkata');


dbConnect("istore");

//******************tender meeting notice

$rs = mysql_query("select * from st_config");
if (mysql_num_rows($rs)) {
	$o = mysql_fetch_object($rs);
    $automailing = $o->auto_mailing;
    $tendernotice = $o->tender_notice;
	$tenderemails = explode(",",$o->tender_emails);
    $uploadnotice = $o->upload_notice;
	$uploademails = explode(",",$o->upload_emails);
    $meetingnotice = $o->meeting_notice;
	$meetingemails = explode(",",$o->meeting_emails);
}

$sql = "select tender_no,concat(title,' (',objective,')') as description,est_cost,user_dept,date_tender as dated,date_submission as submission,date_opening as opening,quotations,l1_quote,date_final as finalization from t_tenders where date_opening='".date("Y-m-d")."' order by id desc";

$sql = "select tender_no,concat(title,' (',objective,')') as description,est_cost,user_dept,date_tender as dated,date_submission as submission,date_opening as opening 
from t_tenders order by id desc";

$str = list_tabledata($sql);

if ($automailing && $str) {
	foreach ($meetingemails as $email) {
		automailer($email, "Tender Processing - Regarding meeting", $meetingnotice.$str);
	}
}

//*********************synchronize inventory quantity (in/out)

$rs = mysql_query("select item,sum(qty_in) as qi from st_stockin group by item");
while ($o = mysql_fetch_object($rs)) {
	$item = $o->item;
	$qi = $o->qi;
	$sr = mysql_query("select * from st_items where id=$item");
	$q = mysql_fetch_object($sr);
	$in = $q->qty_in;
	
	$sr = mysql_query("select item,sum(qty_out) as qo from st_stockout where item=$item");
	$q = mysql_fetch_object($sr);
	$qo = $q->qo;
	$sr = mysql_query("select * from st_items where id=$item");
	$q = mysql_fetch_object($sr);
	$out = $q->qty_out;
	//echo item_detail($o->item) ." [ $qi / $qo ][ $in / $out ]<br>";
	//if ($qi<$qo) $qi=$qo;
	mysql_query("update st_items set stock=$qi-$qo,qty_in=$qi,qty_out=$qo where id=$item");
}

//********************approved item availability notice

$rs = mysql_query("select * from indents where status='Approved' and date(date_indent)>'2017-10-01'");
while ($o = mysql_fetch_object($rs)) {
	$email = employee_email($o->emp_no);
	//$email = 'mmishra@iiita.ac.in';
	$mm = available_items($o->indent_no);
	
	if ($mm && $email && stock_available($o->indent_no)) {	
		$str = "Dear Indentor
		<br><br>	
		With reference to your indent No. $o->indent_no some items marked with <font size='+1' color='red'>*</font> are available readily in the stock. 
		Kindly collect them during 12 - 1 PM (Cleaning items) and 3 - 4 PM (Stationary & Crockery items) at your suitable convenience. 
		Remaining items, if any, may take some time as they are subject to purchase processing. <font size='+1' color='green'>*</font> marked items are already issued.
		<br><br>$mm<br><br>
		Thanks,<br><br>";

		automailer ($email, "Item Availability", $str);
		//automailer('istore@iiita.ac.in', "Item Availability", $str);
	}
}


//********************birthday wish

dbConnect("mm");

$today = date("m-d");
//$today = date("m-d", strtotime("15 Dec 1971"));//date("Y-m-d");
$msg = "<p align='center'>
<font size=+1 face='Time New Roman'>
Today should be a great day,
<br>
for you
<br>
Because it is your birthday!
<br>
<br>
Not because it calls for a celebration
<br>
but because it warrants introspection
<br>
<br>
<i>\"Wondering how could I be so immatured
<br>
in all these previous years
<br>
and pledging how I could be more
<br>
grown-up in the years to come\"
</i>
<br>
<br>
are the thoughts that echo,
<br>
today, on this day-the day of birthday.
<br>
<br>
The entire family of IIIT-Allahabad joins you and your family
<br>
to enjoy this special day.
<br><br>
All the best!
</font>
<p>
<p align='right'>
<font size='2px' face='Time New Roman'>
On behalf of IIIT-A
</font>
<br>
<br>
<font size=+1 face='Time New Roman'>
<b>P. Nagabhushan</b>
<br>
Director
<br>
IIIT-Allahabad
</font>
</p>
";
//echo $today;
$rs = mysql_query("select * from employees where dob like '%-$today'");
while ($o = mysql_fetch_object($rs)) {
       	$empno = $o->emp_no;
       	$empname = $o->emp_name;
	$designation = $o->designation;
       	$email = $o->email;
	$cellno = $o->cell_no;
	$dob = $o->dob;
	//$dobx = $o->dobx;
	//echo $empname .'--'.$dob;
	sendmail($email, "Happy Birthday!!", $msg);
	//sendmail('dir.wish@iiita.ac.in', "Happy Birthday!!", $msg);
	
	//echo date("d-m-Y", strtotime($dob))."\n";
	//mysql_query("update faculty set dob1='".date("Y-m-d", strtotime($dob))."' where emp_no='$empno'");
}

?>