<?php require "_header.php";?>
<script language="javascript" type="text/javascript">
document.getElementById("main-content").style.display = 'none';
</script>
<style type="text/css">
	.table-report{
		font-family:Verdana, Geneva, sans-serif;
		font-size:12px;
		text-align:left;
		border-right:0px none;
		border-bottom:0px none;
	}
	.table-report-inner{
		font-family:Verdana, Geneva, sans-serif;
		font-size:12px;
	}
	.table-report tr{
		padding:2px 2px 2px 2px;
	}
	.table-report td{
		padding:2px 2px 2px 2px;
		border-top:0px none;
		border-left:0px none;
	}
	.table-report th{
		padding:2px 2px 2px 2px;
		font-weight:bold;
		text-align:left;
		border-top:0px none;
		border-left:0px none;
	}	
</style>
<div id="main-report">
<?php
if($_REQUEST['startdate'] == "" || $_REQUEST['enddate'] == "")
{
?>
	<script language="javascript" type="text/javascript">
		location.href='report-send-sms.php';
	</script>
<?php
}
elseif($_SESSION['VedantnrCollegeId']!="" && isset($_SESSION['VedantnrCollegeId'])) 
{ 
	ob_start();
	$start_date 	= Escape($_REQUEST['startdate']);
	$end_date 	  = Escape($_REQUEST['enddate']);
	$order_by	  = Escape($_REQUEST['hid_orderby']);
	$SQL_CONDITION  = "";
//	dbQuery("SET SESSION group_concat_max_len = 1000000");
	$SQL_STUDENT = "
		SELECT tm.*,count(td.sms_mobileno)AS sms_mobileno,user_name
		FROM
			transactionmaster tm,
			transactiondetail td,
			cms_usermaster u
		WHERE 
			tm.trans_id  = td.trans_id 
			AND u.user_id=tm.user_id
			AND  tm.trans_date BETWEEN '".$start_date."' AND '".$end_date."' group by trans_id ORDER BY trans_date  ".$order_by;
	$RES_STUDENT = dbQuery($SQL_STUDENT);
	if(dbRows($RES_STUDENT)>0){?>
        <center><h4>Send SMS Report</h4></center><br />
		<table class="table-report" border="1" cellpadding="0" cellspacing="0" width="100%">
        <tr>
        	<th style="text-align:center;" width="5%">Sr</th>
            <th style="text-align:center;" width="10%">Send Date</th>
            <th style="text-align:center;" width="65%">Message</th>
            <th style="text-align:center;" width="10%">Total Nos</th>
            <th style="text-align:left;"   width="10%">send By</th>
        </tr>
		<?php
		$i = 1;
		$temp = "";
		$temp1="";
		while($REC_STUDENT = dbArray($RES_STUDENT)){
			 ?>
            <tr>
				<td style="text-align:center;">&nbsp;<?php echo $i++; ?></td>
                <td style="text-align:center;">&nbsp;<?php echo date("d-m-Y",strtotime($REC_STUDENT['trans_date'])); ?></td>
                <td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['user_message']; ?></td>
                <td style="text-align:center;">&nbsp;<?php echo str_replace(',','<br/>',$REC_STUDENT['sms_mobileno']); ?></td>
                <td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['user_name']; ?></td>
              </tr><?php
		}
		?>
		</table>
		<?php
	}
	else{
		echo "NO DATA FOUND!";	
	}
	
?>

<?php
	$HtmlCode = ob_get_contents();
	ob_end_flush();
	$header_row_string="Send SMS Report";
	$HtmlUrl = "studentlist-report.html";
	$HtmlPath =	"report/".$HtmlUrl;
	createHTMLReportPage($header_row_string,$HtmlUrl,$HtmlPath,$HtmlCode,false);
?>
<br/>
<form name="frm" id="frm" action="" method="post">		
    <input type="hidden"   name="txtFile" id="txtFile" value="<?php echo $HtmlUrl ;?>" />
    <input type="button"  name="btnPrint" id="btnPrint" value="Print" onClick="SetPageAction('PRINT');"/>
    <input type="button"  name="btnPdf" id="btnPdf" value="Create PDF" onClick="SetPageAction('PDF');"/>
    <input type="button" name="btnHtml" id="btnHtml" value="Create HTML" onClick="SetPageAction('HTML');"/>
    <input type="button" name="btnWord" id="btnWord" value="Create WORD" onClick="SetPageAction('WORD');"/>
    <input type="button" name="btnExcel" id="btnExcel" value="Create EXCEL" onClick="SetPageAction('Excel');"/>
</form>
<script language="javascript" type="text/javascript">
function SetPageAction(varAction) {
	if(varAction=="PRINT"){			
		document.frm.action="print/create-print.php";
		document.frm.target = "_blank";
		document.frm.submit();
	}
	else if(varAction=="PDF"){			
		document.frm.action="convertpdf/create-pdf.php";
		document.frm.target = "_blank";
		document.frm.submit();
	}
	else if(varAction=="HTML"){
		document.frm.action="<?php echo $HtmlPath ;?>";
		document.frm.target = "_blank";
		document.frm.submit();
	}
	else if(varAction=="WORD"){
		document.frm.action="convertword/create-word.php";
		document.frm.target="_blank";
		document.frm.submit();
	}
	else if(varAction=="Excel"){
		document.frm.action="convertword/create-excel.php";
		document.frm.target="_blank";
		document.frm.submit();
	}
}
</script>
<?php } ?>
</div>
<?php 
	require "_footer.php";
?>