<!DOCTYPE html>
<?php
$flag=$_REQUEST['flag'];
if($flag=='')
{
 require_once('convert_marathi.php');
############################################ Display Reference Wise Report TO Department #########################################
$no=$_GET['no'];
$ltrid=$_REQUEST['ltr_id'];
if($no==2)
{
	$username = $_SESSION['User_Name'];
	include('dashboard_tapal.php');	
	?>
	<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<script type="text/javascript">     
	function PrintDiv() {    
		var divToPrint = document.getElementById('divToPrint');
		var popupWin = window.open('', '_blank', 'width=600,height=600');
		popupWin.document.open();
		popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
		popupWin.document.close();
	 }
	</script>
	<script src="tableToExcel.js"></script>
	</head>
	<body>
	<div class="mainwrapper">   
		<div class="rightpanel">
            <ul class="breadcrumbs">
				<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
				<li><a href="">Tables</a> <span class="separator"></span></li>
				<li>प्राधान्यानुसार रिपोर्ट्स </li> 
			</ul>
			<div class="pageheader">
				<div class="pageicon"><span class="iconfa-table"></span></div>
				<div class="pagetitle">
					<h5>Tables</h5>
					<?php 
					$qryz=mysql_query("Select dept_nm from department_master where dept_id=(select dept_id from login where login_id='$username')");
					$rsz=mysql_fetch_array($qryz);
					?>
					<h1><?php echo 	$rsz['dept_nm'];?>प्राधान्यानुसार रिपोर्ट्स </h1>
				</div>
			</div><!--pageheader-->
			<div class="maincontent">
				<div class="maincontentinner">
					<h4 class="widgettitle"><?php echo $rsz['dept_nm'];?> प्राधान्यानुसार रिपोर्ट्स </h4>
						<form method="post" action="">
							<?php 		
							$id=$_REQUEST['id'];
							#################### Display Counter #########################
							if($id=="")
							{ 
								convert_marathi();
								$qre=("SELECT incoming_letters_transaction.priority_days, COUNT(*) AS TOTAL FROM incoming_letters_transaction,tapal_to_dpt_transaction WHERE incoming_letters_transaction.priority_days!='' AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id GROUP BY incoming_letters_transaction.priority_days");
								$rsut=mysql_query($qre) or die("".mysql_error());
								echo " <table id='dyntable' class='table table-bordered'>
								<thead>
								<tr>
								<th class='head0 center' style='width:160px;'>प्राधान्य दिवस </th>
								<th class='head1 center'>एकूण </th>
								</tr>
								</thead>";
								while($rws = mysql_fetch_array($rsut))
								{
									$id=$rws['priority_days'];
									?>
									<tbody>
									<tr class="gradeX">
									<?php 
										echo "<td class='center'><a href='report_dpt_priority.php?id=$id&no=2'>".$rws['priority_days']."</a></td>	<td class='center'>". $rws['TOTAL']."</td> </tr>";           
								}?>
								</tbody>
								</table>
								<?php 
								echo "<div id='divToPrint' style='display:none;'>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4> प्राधान्यानुसार रिपोर्ट्स </h4></center></td></tr>";
								convert_marathi();
								$qre=("SELECT incoming_letters_transaction.priority_days, COUNT(*) AS TOTAL FROM incoming_letters_transaction,tapal_to_dpt_transaction WHERE incoming_letters_transaction.priority_days!='' AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id GROUP BY incoming_letters_transaction.priority_days");
								$rsut=mysql_query($qre) or die("".mysql_error());
								echo "<tr>
								<th>प्राधान्य दिवस </th>
								<th>एकूण </th>
								</tr>";
								while($rws = mysql_fetch_array($rsut))
								{
									$id=$rws['priority_days'];
									echo "<tr>";
										echo "<td style='text-align:center;'>".$rws['priority_days']."</td><td style='text-align:center;'>". $rws['TOTAL']."</td> </tr>";           
								}
								echo "</table>
								</div>";
							} 
							#################### End Of Display Counter #########################
					
							#################### Display Details #########################
							else if( $id != "")
							{ 
								convert_marathi();
								echo "<form name='dept_sandarbh' action='' method='post'>
								<div align='center'><br><table align='center' cellpadding='2' cellspacing='0' class='myClass'>
								<table>
									<tr>											  
										<td align='center'><label style='width:110px;'>Start date</label></td>
										<td align='center'><input type='text' name='start_date' class='input-small'/></td>
										<td align='center'><label style='width:110px;'>End Date</label></td>
										<td align='center'><input type='text' name='end_date' class='input-small'/></td>
									</tr>
									<tr>
										<td colspan='6'>
										<div align='center'>
											<input type='submit' onClick='return sadyasthitiDates()' name='ok' value='GO'/>
											<input type='reset' value='CLEAR' name='clear'/>
										</div>
										</td>
									</tr>
								</table>
							</div>				
							</form>
							<form>";
							$date123	= $_POST['start_date'];
							$date1	= date('Y-m-d',strtotime($date123));
							$date223	= $_POST['end_date'];
							$date2	= date('Y-m-d',strtotime($date223));
							//$date22	= date('d-m-Y',strtotime($date2));
							if($date123==''&& $date223=='')
							{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction, tapal_to_dpt_transaction where incoming_letters_transaction.priority_days='$id' AND tapal_to_dpt_transaction.ltr_id=incoming_letters_transaction.ltr_id") or die("sdfdfds".mysql_error());
							}
							else{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction, tapal_to_dpt_transaction where incoming_letters_transaction.priority_days='$id' AND tapal_to_dpt_transaction.ltr_id=incoming_letters_transaction.ltr_id AND (incoming_letters_transaction.receive_dt BETWEEN '$date1' AND '$date2')") or die("sds".mysql_error());
							}
								echo "<table  id='dyntable' class='table table-bordered'>
								<thead>
								<tr>
								<th class='head0 center'>आवक_क्रमांक<br>व_दिनांक</th>
								<th class='head1 center'>संदर्भ पाठवलेली<br>क्रमांक_व_दिनांक</th>
								<th class='head0 center'>संदर्भ प्राप्त दिनांक</th>
								<th class='head1 center'>विषय</th>
								<th class='head0 center'>कोणाकडून प्राप्त झाला</th>
								<th class='head1 center'>विभागाला पाठवले</th>
								<th class='head0 center'>विभागाला_संदर्भ पाठवलेली_दिनांक </th>
								</tr>
								</thead>";
			
								while($test = mysql_fetch_array($result222))
								{
									$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
									$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
									$ref_dt		= date('d-m-Y',strtotime($test['ref_dt']));

									$sent_dt		= date('d-m-Y',strtotime($test['sent_dt']));
									$recv_dt=date('d-m-Y',strtotime($test['receive_dt']));
									echo "<tr class='gradeX'>
									<td class='center'>".$test['ltr_inword_no']."<br>".$recv_dt."</td>
									<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
									<td class='center'>".$test['ref_no']."<br>".$ref_dt."</td>
									<td class='center'>".$test['subject']."</td>
									<td class='center'>".$test['sender_name']."</td>";
									$q12=mysql_query("Select dept_nm from department_master where dept_id=$test[dept_id]");
									$rs12=mysql_fetch_array($q12);
									echo "<td class='center'>".$rs12['dept_nm']."</td>
									<td class='center'>".$sent_dt."</td>
									</tr>";
								}
								//mysql_close();
								echo"   </tbody>
									</table>";

								echo "<div id='divToPrint' style='display:none;'>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>  प्राधान्यानुसार रिपोर्ट्स</h4></center></td></tr>";
								convert_marathi();
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction, tapal_to_dpt_transaction where incoming_letters_transaction.priority_days='$id' AND tapal_to_dpt_transaction.ltr_id=incoming_letters_transaction.ltr_id") or die("sdfdfds".mysql_error());
								echo "<tr>
								<th>आवक_क्रमांक</th>
								<th>संदर्भ पाठवलेली<br>क्रमांक_व_दिनांक</th>
								<th>संदर्भ प्राप्त_दिनांक</th>
								<th>विषय</th>
								<th>कोणाकडून प्राप्त_झाला</th>
								<th>विभागाला_पाठवले</th>
								<th>विभागाला_संदर्भ पाठवलेली_दिनांक </th>
								</tr>";
								while($test = mysql_fetch_array($result222))
								{
									$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
									$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
									$ref_dt		= date('d-m-Y',strtotime($test['ref_dt']));
									$sent_dt		= date('d-m-Y',strtotime($test['sent_dt']));
									
									echo "<tr>
									<td style='text-align:center;'>".$test['ltr_inword_no']."</td>
									<td style='text-align:center;'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
									<td style='text-align:center;'>".$test['ref_no']."<br>".$ref_dt."</td>
									<td style='text-align:center;'>".$test['subject']."</td>
									<td style='text-align:center;'>".$test['sender_name']."</td>";
									$q12=mysql_query("Select dept_nm from department_master where dept_id=$test[dept_id]");
									$rs12=mysql_fetch_array($q12);
									echo "<td style='text-align:center;'>".$rs12['dept_nm']."</td>
									<td style='text-align:center;'>".$sent_dt."</td>
									</tr>";
								}
								//mysql_close();
								echo " </table></div>";
							}		
							#################### End Of Display Details #########################
						?><br>
						<p>	
							<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"/>
							<input type="button" class="btn" onclick="tableToExcel('export', 'Sandarbha-Nusar Report')" value="Export to Excel"></center>
						</p>
					</form>
                    <?php include_once('footer.php'); ?>
				</div><!--maincontentinner-->
			</div><!--maincontent-->
		</div><!--rightpanel--> 
	</div><!--mainwrapper-->
</body>
</html>
<?php
}
############################### End Of Display Priority Wise Report TO Tapal #########################################


############################# Display Priority Wise Report TO Department #########################################
else if($no==1)
{
		include('dashboard_department.php');
		?>
		<html>
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<script type="text/javascript">     
			function PrintDiv() {    
			var divToPrint = document.getElementById('divToPrint');
			var popupWin = window.open('', '_blank', 'width=600,height=600');
			popupWin.document.open();
			popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
			popupWin.document.close();
			}
		</script>
		<script src="tableToExcel.js"></script>
		</head>
		<body>
		<div class="mainwrapper">   
			<div class="rightpanel">
				<ul class="breadcrumbs">
					<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
					<li><a href="">Tables</a> <span class="separator"></span></li>
					<li>प्राधान्यानुसार रिपोर्ट्स </li>
				</ul>
				<div class="pageheader">
					<div class="pageicon"><span class="iconfa-table"></span></div>
					<div class="pagetitle">
						<h5>Tables</h5>
						<?php 
						$qryz=mysql_query("Select dept_nm from department_master where dept_id=(select dept_id from login where login_id='$username')");
						$rsz=mysql_fetch_array($qryz);
						?>
						<h1><?php echo 	$rsz['dept_nm'];?>चे प्राधान्यानुसार रिपोर्ट्स </h1>
					</div>
				</div><!--pageheader-->
			<div class="maincontent">
				<div class="maincontentinner">
						<h4 class="widgettitle"><?php echo 	$rsz['dept_nm'];?>चे प्राधान्यानुसार रिपोर्ट्स </h4>
						<form method="post" action="">
						<?php 		
						$id=$_REQUEST['id'];
						#################### Display Counter #########################
						if($id=="")
							{
								convert_marathi();
								/*$qre=("SELECT dept_id, priority_days, COUNT(*) AS TOTAL FROM  incoming_letters_transaction WHERE incoming_letters_transaction.dept_id=(select dept_id from login where login_id='$username') AND incoming_letters_transaction.status='approve' AND priority_days!='0' GROUP BY priority_days");*/
								$qre=("SELECT dept_id, priority_days, COUNT(*) AS TOTAL FROM  incoming_letters_transaction i,  tapal_to_dpt_transaction t 
								WHERE t.ltr_id=i.ltr_id
								AND t.dept_id_from=(select dept_id from login where login_id='$username')
								AND i.priority_days!='0' GROUP BY priority_days");
							 
								$rsut=mysql_query($qre) or die("".mysql_error());
								echo "<table  id='dyntable' class='table table-bordered'>
								<thead>
								<tr>
								<th class='head0 center' style='width:160px;'>प्राधान्य दिवस </th>
								<th class='head1 center'>एकूण </th>
								</tr>
								</thead>";
								while($rws = mysql_fetch_array($rsut))
								{
									$id=$rws['priority_days'];
									?>
									<tbody>
									<tr class="gradeX">
									<?php 
										echo "<td class='center'><a href='report_dpt_priority.php?id=$id&no=1'>".$rws['priority_days']."</a></td>	<td class='center'>". $rws['TOTAL']."</td> </tr>";           
								}?>
								</tbody>
								</table>
								
								<?php
								echo "
								<div id='divToPrint' style='display:none;'>
								<table id='export' border='1px' style='margin-left:50px;'>
								<tr><td colspan='9'><center><h4> प्राधान्यानुसार रिपोर्ट्स </h4></center></td></tr>";
									convert_marathi();
									/*$qre=("SELECT dept_id, priority_days, COUNT(*) AS TOTAL FROM  incoming_letters_transaction WHERE incoming_letters_transaction.dept_id=(select dept_id from login where login_id='$username') AND incoming_letters_transaction.status='approve' AND priority_days!='0' GROUP BY priority_days");*/
									$qre=("SELECT dept_id, priority_days, COUNT(*) AS TOTAL FROM  incoming_letters_transaction i,  tapal_to_dpt_transaction t 
									WHERE t.ltr_id=i.ltr_id
									AND t.dept_id_from=(select dept_id from login where login_id='$username')
									AND i.priority_days!='0' GROUP BY priority_days");
							 
									$rsut=mysql_query($qre) or die("".mysql_error());
									echo "
									<tr>
									<th>प्राधान्य दिवस </th>
									<th>एकूण </th>
									</tr>";
								while($rws = mysql_fetch_array($rsut))
								{
									$id=$rws['priority_days'];
									echo "<tr><td style='text-align:center;'>".$rws['priority_days']."</td>	<td style='text-align:center;'>".$rws['TOTAL']."</td> </tr>";           
								}
								
							echo	"</table></div>";
						} 
							#################### End Of Display Counter #########################
					
							#################### Display Details #########################
							else if( $id != "")
							{
								convert_marathi();
								echo "<form name='dept_sandarbh' action='' method='post'>
								<div align='center'><br><table align='center' cellpadding='2' cellspacing='0' class='myClass'>
								<table>
									<tr>											  
										<td align='center'><label style='width:110px;'>Start date</label></td>
										<td align='center'><input type='text' name='start_date' class='input-small'/></td>
										<td align='center'><label style='width:110px;'>End Date</label></td>
										<td align='center'><input type='text' name='end_date' class='input-small'/></td>
									</tr>
									<tr>
										<td colspan='6'>
										<div align='center'>
											<input type='submit' onClick='return sadyasthitiDates()' name='ok' value='GO'/>
											<input type='reset' value='CLEAR' name='clear'/>
										</div>
										</td>
									</tr>
								</table>
							</div>				
							</form>
							<form action='' method='post'>";
							$date123	= $_POST['start_date'];
							$date1	= date('Y-m-d',strtotime($date123));
							$date223	= $_POST['end_date'];
							$date2	= date('Y-m-d',strtotime($date223));
							//$date22	= date('d-m-Y',strtotime($date2));
							if($date123==''&& $date223=='')
							{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id1 = $date1;
								$id2= $date2;
								/*$result222=mysql_query("SELECT * FROM incoming_letters_transaction, tapal_to_dpt_transaction where tapal_to_dpt_transaction.dept_id_from=(select dept_id from login where login_id='$username') AND priority_days='$id' AND incoming_letters_transaction.status='approve' AND tapal_to_dpt_transaction.ltr_id= incoming_letters_transaction.ltr_id") or die("sdfdfds".mysql_error());*/
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction, tapal_to_dpt_transaction where tapal_to_dpt_transaction.dept_id_from=(select dept_id from login where login_id='$username') AND priority_days='$id' AND incoming_letters_transaction.status='approve' AND tapal_to_dpt_transaction.ltr_id= incoming_letters_transaction.ltr_id") or die("sdfdfds".mysql_error());
								
							}
							else
							{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction, tapal_to_dpt_transaction where tapal_to_dpt_transaction.dept_id_from=(select dept_id from login where login_id='$username') AND priority_days='$id' AND incoming_letters_transaction.status='approve' AND tapal_to_dpt_transaction.ltr_id= incoming_letters_transaction.ltr_id AND (incoming_letters_transaction.receive_dt BETWEEN '$date1' AND '$date2')") or die("sdfdfds".mysql_error());
							}
								?> 
								<table id="dyntable" class="table table-bordered">
								<thead>
								<tr>
									<th class="head0 center">आवक_क्रमांक <br>आवक दि. </th>
									<th class="head1 center">विभागीय आवक_क्रमांक <br>विभागीय प्राप्त दि. </th>
									<th class="head0 center">संदर्भ_क्रमांक <br>संदर्भ दिं.</th>                          
									<th class="head1 center">कोणाकडून प्राप्त झाले  </th>
									<th class="head0 center">थोडक्यात विषय </th>                         
									<th class="head1 center">संदर्भाचा प्रकार </th>
									<th class="head0 center">डेस्कचे नाव</th>  
									<th class="head1 center">डेस्क ला पाठवलेली दि.  </th>
								</tr>
								</thead>
								<?php
									while($rws = mysql_fetch_array($result222))
									{ 
										$dsrecdt = strtotime($rws['sent_to_desk_dt']);
										$dsrecdt1= date('d-m-Y', $dsrecdt);
										$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
										$dprecdt1= date('d-m-Y', $dprecdt);
										$refdt = strtotime($rws['ref_dt']);
										$refdt1= date('d-m-Y', $refdt);
										$recdt = strtotime($rws['receive_dt']);
										$recdt1= date('d-m-Y', $recdt);
										?>
										<tr class="gradeX">
										<?php 
										echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
										<td class='center'>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
										
										echo "<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
										<td class='center'>".$rws['sender_name']."</td><td class='center'>".$rws['subject']."</td>";
										$l=$rws['ltr_type'];
										$l1=mysql_query("Select sandharbh_nm from sandharbh_master where sandhrbh_id='$l'");
										$lr1=mysql_fetch_array($l1);
										echo "<td class='center'><a href=report_dpt_sandharbha.php?ltr_id=$l&no=1>".$lr1['sandharbh_nm']."</a></td>";
										$l2=$rws['desk_id'];
										$l3=mysql_query("Select desk_nm from desk_master where desk_id='$l2'");
										$lr3=mysql_fetch_array($l3);
										if($dsrecdt1==="01-01-1970")
										{
										echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font></td>";
										}
										else
										{
										echo "<td class='center'>".$lr3['desk_nm']."</td>";
										}
										if($dsrecdt1==="01-01-1970")
										{	
											echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font></td>";
										}
										else if ($dsrecdt1!="01-01-1970"){
											echo "<td class='center'>".$dsrecdt1."</td>";
										}
										echo" </select></tr>";
									}
								//mysql_close();
								echo"   </tbody></table>";
								
								
								echo "<div id='divToPrint' style='display:none;'>
								<table id='export' border='1px' style='margin-left:50px;'>
								<tr><td colspan='9'><center><h4>  प्राधान्यानुसार रिपोर्ट्स </h4></center></td></tr>";
								
								if($date123==''&& $date223=='')
							{
								
								/*$result222=mysql_query("SELECT * FROM incoming_letters_transaction, tapal_to_dpt_transaction where tapal_to_dpt_transaction.dept_id_from=(select dept_id from login where login_id='$username') AND priority_days='$id' AND incoming_letters_transaction.status='approve' AND tapal_to_dpt_transaction.ltr_id= incoming_letters_transaction.ltr_id") or die("sdfdfds".mysql_error());*/
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction, tapal_to_dpt_transaction where tapal_to_dpt_transaction.dept_id_from=(select dept_id from login where login_id='$username') AND priority_days='$id' AND incoming_letters_transaction.status='approve' AND tapal_to_dpt_transaction.ltr_id= incoming_letters_transaction.ltr_id") or die("sdfdfds".mysql_error());
								
							}
							else
							{
								
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction, tapal_to_dpt_transaction where tapal_to_dpt_transaction.dept_id_from=(select dept_id from login where login_id='$username') AND priority_days='$id' AND incoming_letters_transaction.status='approve' AND tapal_to_dpt_transaction.ltr_id= incoming_letters_transaction.ltr_id AND (incoming_letters_transaction.receive_dt BETWEEN '$date1' AND '$date2')") or die("sdfdfds".mysql_error());
							}
			 
								echo "<tr>
									<th>आवक_क्रमांक <br>आवक_दि. </th>
									<th>विभागीय आवक_क्रमांक <br>प्राप्त_दि. </th>
									<th>संदर्भ_क्रमांक <br>संदर्भ_दिं.</th>                          
									<th>कोणाकडून प्राप्त_झाले  </th>
									<th>थोडक्यात विषय </th>                         
									<th>संदर्भाचा प्रकार </th>
									<th>डेस्कचे नाव</th>  
									<th>डेस्कला पाठवलेली दि.  </th>
								</tr>";
									while($rws = mysql_fetch_array($result222))
									{ 
										$dsrecdt = strtotime($rws['sent_to_desk_dt']);
										$dsrecdt1= date('d-m-Y', $dsrecdt);
										$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
										$dprecdt1= date('d-m-Y', $dprecdt);
										$refdt = strtotime($rws['ref_dt']);
										$refdt1= date('d-m-Y', $refdt);
										$recdt = strtotime($rws['receive_dt']);
										$recdt1= date('d-m-Y', $recdt);
										
										echo "<tr>";
										echo "<td style='text-align:center;'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
										<td style='text-align:center;'>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
										
										echo "<td style='text-align:center;'>".$rws['ref_no']."<br>".$refdt1."</td>
										<td style='text-align:center;'>".$rws['sender_name']."</td><td class='center'>".$rws['subject']."</td>";
										$l=$rws['ltr_type'];
										$l1=mysql_query("Select sandharbh_nm from sandharbh_master where sandhrbh_id='$l'");
										$lr1=mysql_fetch_array($l1);
										echo "<td cstyle='text-align:center;'>".$lr1['sandharbh_nm']."</td>";
										$l2=$rws['desk_id'];
										$l3=mysql_query("Select desk_nm from desk_master where desk_id='$l2'");
										$lr3=mysql_fetch_array($l3);
										if($dsrecdt1==="01-01-1970")
										{
										echo "<td style='text-align:center;'>डेस्क लावणे बाकी</td>";
										}
										else
										{
										echo "<td style='text-align:center;'>".$lr3['desk_nm']."</td>";
										}
										if($dsrecdt1==="01-01-1970")
										{	
											echo "<td style='text-align:center;'><font color='red'>डेस्क लावणे बाकी</font></td>";
										}
										else if ($dsrecdt1!="01-01-1970"){
											echo "<td style='text-align:center;'>".$dsrecdt1."</td>";
										}
										echo" </tr>";
									}
								//mysql_close();
								echo "</table></div>";
							}
							################################ End Of Display Details ###############################################
							?><br>
							<p>	
								<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"/>
								<input type="button" class="btn" onclick="tableToExcel('export', 'W3C Example Table')" value="Export to Excel"></center>
							</p>
						</form>
						<br /><br />
						<?php include_once('footer.php'); ?>
					</div><!--maincontentinner-->
			</div><!--maincontent--> 
		</div><!--rightpanel-->
	</div><!--mainwrapper-->
</body>
</html>
<?php }
############################## End Of Display Priority Wise Report TO Department ###################


############################# Display Priority Wise Report TO BDO #########################################

else if($no==3) 
{include('dashboard_bdo.php'); 
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="text/javascript">     
       function PrintDiv() {    
           var divToPrint = document.getElementById('divToPrint');
           var popupWin = window.open('', '_blank', 'width=600,height=600');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
</script>
<script src="tableToExcel.js"></script>
</head>
<body>
<div class="mainwrapper">   
    <div class="rightpanel">
            <ul class="breadcrumbs">
				<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
				<li><a href="">Tables</a> <span class="separator"></span></li>
				<li>प्राधान्यानुसार रिपोर्ट्स </li>
			</ul>
			<div class="pageheader">
				<div class="pageicon"><span class="iconfa-table"></span></div>
				<div class="pagetitle">
					<h5>Tables</h5>
					<?php 
					$qryz=mysql_query("Select dept_nm from department_master where dept_id=(select dept_id from login where login_id='$username')");
					$rsz=mysql_fetch_array($qryz);
					?>
					<h1><?php echo 	$rsz['dept_nm'];?> प्राधान्यानुसार रिपोर्ट्स </h1>
				</div>
			</div><!--pageheader-->
			<div class="maincontent">
				<div class="maincontentinner">
					<h4 class="widgettitle">
					<?php echo $rsz['dept_nm'];?> प्राधान्यानुसार रिपोर्ट्स </h4>
						<form method="post" action="">
							
							<?php 		
							$id=$_REQUEST['id'];
							########################## Display Counter #############################
							if($id=="")
							{
								convert_marathi();
									/*$qre=("SELECT incoming_letters_transaction.priority_days, COUNT(*) AS TOTAL FROM incoming_letters_transaction,tapal_to_dpt_transaction WHERE incoming_letters_transaction.priority_days!='' AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id GROUP BY incoming_letters_transaction.priority_days");*/
								$qre=("SELECT i.priority_days, COUNT(*) AS TOTAL 
								FROM incoming_letters_transaction i
								WHERE i.priority_days!='' 
								GROUP BY i.priority_days");	
								
								$rsut=mysql_query($qre) or die("".mysql_error());
								echo "<table id='dyntable' class='table table-bordered'>
								<thead>
								<tr>
									<th class='head0 center' style=width:160px;>प्राधान्य दिवस </th>
									<th class='head1 center'>एकूण </th>
								</tr>
								</thead>";
								while($rws = mysql_fetch_array($rsut))
								{
									$id=$rws['priority_days'];
									?>
									<tbody>
									<tr class="gradeX">
									<?php echo "<td class='center'><a href='report_dpt_priority.php?id=$id&no=3'>".$rws['priority_days']."</a></td>	<td class='center'>". $rws['TOTAL']."</td> </tr>";                
								}?>
								</tbody>
								</table>
								
							<?php 
								echo "<div id='divToPrint' style='display:none;'>
								<table id='export' border='1px' style='margin-left:50px;'>
								<tr><td colspan='9'><center><h4> प्राधान्यानुसार रिपोर्ट्स</h4></center></td></tr>";
								convert_marathi();
								$qre=("SELECT i.priority_days, COUNT(*) AS TOTAL 
								FROM incoming_letters_transaction i
								WHERE i.priority_days!='' 
								GROUP BY i.priority_days");
							 
								$rsut=mysql_query($qre) or die("".mysql_error());
								echo "
								<tr>
									<th>प्राधान्य दिवस </th>
									<th>एकूण </th>
								</tr>";
								while($rws = mysql_fetch_array($rsut))
								{
									$id=$rws['priority_days'];
									echo "<tr>
									<td style='text-align:center;'>".$rws['priority_days']."</td><td style='text-align:center;'>". $rws['TOTAL']."</td> </tr>";                
								}
								echo "
								</table></div>";
						} 
							########################## End Of Display Counter ##################################
					
							########################## Display Details ###################################
							else if( $id != "")
							{					
								convert_marathi();
								echo "<form name='dept_sandarbh' action='' method='post'>
								<div align='center'><br><table align='center' cellpadding='2' cellspacing='0' class='myClass'>
								<table>
									<tr>											  
										<td align='center'><label style='width:110px;'>Start date</label></td>
										<td align='center'><input type='text' name='start_date' class='input-small'/></td>
										<td align='center'><label style='width:110px;'>End Date</label></td>
										<td align='center'><input type='text' name='end_date' class='input-small'/></td>
									</tr>
									<tr>
										<td colspan='6'>
										<div align='center'>
											<input type='submit' onClick='return sadyasthitiDates()' name='ok' value='GO'/>
											<input type='reset' value='CLEAR' name='clear'/>
										</div>
										</td>
									</tr>
								</table>
							</div>				
							</form>
							<form action='' method='post'>";
							$date123	= $_POST['start_date'];
							$date1	= date('Y-m-d',strtotime($date123));
							$date223	= $_POST['end_date'];
							$date2	= date('Y-m-d',strtotime($date223));
							//$date22	= date('d-m-Y',strtotime($date2));
							if($date123==''&& $date223=='')
							{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction, tapal_to_dpt_transaction where incoming_letters_transaction.priority_days='$id' AND tapal_to_dpt_transaction.ltr_id=incoming_letters_transaction.ltr_id") or die("sdfdfds".mysql_error());
							}
							else{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction, tapal_to_dpt_transaction where incoming_letters_transaction.priority_days='$id' AND tapal_to_dpt_transaction.ltr_id=incoming_letters_transaction.ltr_id AND (incoming_letters_transaction.receive_dt BETWEEN '$date1' AND '$date2')") or die("sdfdfds".mysql_error());
							}
								echo "<table  id='dyntable' class='table table-bordered'>	
								<thead>
								<tr>
									<th class='head0 center'>आवक_क्रमांक<br>व_दिनांक</th>
									<th class='head1 center'>संदर्भ पाठवलेली<br>क्रमांक_व_दिनांक</th>
									<th class='head0 center'>संदर्भ प्राप्त दिनांक</th>
									<th class='head1 center'>विषय</th>
									<th class='head0 center'>कोणाकडून प्राप्त झाला</th>
									<th class='head1 center'>विभागाला पाठवले</th>
									<th class='head0 center'>विभागाला_संदर्भ पाठवलेली_दिनांक </th>
								</tr>
								</thead>";
			
								while($test = mysql_fetch_array($result222))
								{
									$desk_ltr_rec_dt= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
									$dept_rec_date = date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
									$ref_dt	= date('d-m-Y',strtotime($test['ref_dt']));
									$sent_dt= date('d-m-Y',strtotime($test['sent_dt']));
									$rcv_dt		= date('d-m-Y',strtotime($test['receive_dt']));
									
									echo "<tr class='gradeX'>
										<td class='center'>".$test['ltr_inword_no']."<br>".$rcv_dt."</td>
										<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
										<td class='center'>".$test['ref_no']."<br>".$ref_dt."</td>
										<td class='center'>".$test['subject']."</td>
										<td class='center'>".$test['sender_name']."</td>";
										$q12=mysql_query("Select dept_nm from department_master where dept_id=$test[dept_id]");
										$rs12=mysql_fetch_array($q12);
										echo "<td class='center'>".$rs12['dept_nm']."</td>
										<td class='center'>".$sent_dt."</td>
										</tr>";
								}
								//mysql_close();
								echo "</tbody>
								</table>";
								
							echo "<div id='divToPrint' style='display:none;'>
								<table id='export' border='1px' style='margin-left:50px;'>
								<tr><td colspan='9'><center><h4> प्राधान्यानुसार रिपोर्ट्स</h4></center></td></tr>";	
								convert_marathi();
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction, tapal_to_dpt_transaction where incoming_letters_transaction.priority_days='$id' AND tapal_to_dpt_transaction.ltr_id=incoming_letters_transaction.ltr_id") or die("sdfdfds".mysql_error());
								echo "<tr>
									<th>आवक_क्रमांक</th>
									<th>संदर्भ पाठवलेली<br>क्रमांक_व_दिनांक</th>
									<th>संदर्भ प्राप्त दिनांक</th>
									<th>विषय</th>
									<th>कोणाकडून प्राप्त झाला</th>
									<th>विभागाला पाठवले</th>
									<th>विभागाला_संदर्भ पाठवलेली_दिनांक </th>
								</tr>";
			
								while($test = mysql_fetch_array($result222))
								{
									$desk_ltr_rec_dt= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
									$dept_rec_date = date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
									$ref_dt	= date('d-m-Y',strtotime($test['ref_dt']));
									$sent_dt= date('d-m-Y',strtotime($test['sent_dt']));
									
									echo "<tr>
										<td style='text-align:center;'>".$test['ltr_inword_no']."</td>
										<td style='text-align:center;'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
										<td style='text-align:center;'>".$test['ref_no']."<br>".$ref_dt."</td>
										<td style='text-align:center;'>".$test['subject']."</td>
										<td style='text-align:center;'>".$test['sender_name']."</td>";
										$q12=mysql_query("Select dept_nm from department_master where dept_id=$test[dept_id]");
										$rs12=mysql_fetch_array($q12);
										echo "<td style='text-align:center;'>".$rs12['dept_nm']."</td>
										<td style='text-align:center;'>".$sent_dt."</td>
										</tr>";
								}
								//mysql_close();
								echo "</tbody>
								</table></div>";
							}
							################ End Of Display Priority Wise Report TO Department ################
							?>
							<br>
							<p>	
								<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"/>
								<input type="button" class="btn" onclick="tableToExcel('export', 'W3C Example Table')" value="Export to Excel"></center>
							</p>
						</form>
						<br /><br />
                        <?php include_once('footer.php'); ?>
					</div><!--maincontentinner-->
				</div><!--maincontent-->
			</div><!--rightpanel-->
		</div><!--mainwrapper-->
</body>
</html>
<?php }
} // if($flag=='')

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

else if($flag=='n')
{
	require_once('convert_marathi.php');
	$no=$_GET['no'];
	$ltrid=$_REQUEST['ltr_id'];


############################# Display Priority Wise Report TO Department #########################################
if($no==1)
{
		include('new_dashboard_department.php');
		?>
		<html>
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<script type="text/javascript">     
			function PrintDiv() {    
			var divToPrint = document.getElementById('divToPrint');
			var popupWin = window.open('', '_blank', 'width=600,height=600');
			popupWin.document.open();
			popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
			popupWin.document.close();
			}
		</script>
		<script src="tableToExcel.js"></script>
		</head>
		<body>
		<div class="mainwrapper">   
			<div class="rightpanel">
				<ul class="breadcrumbs">
					<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
					<li><a href="">Tables</a> <span class="separator"></span></li>
					<li>प्राधान्यानुसार रिपोर्ट्स </li>
				</ul>
				<div class="pageheader">
					<div class="pageicon"><span class="iconfa-table"></span></div>
					<div class="pagetitle">
						<h5>Tables</h5>
						<?php 
						$qryz=mysql_query("Select dept_nm from department_master where dept_id=(select dept_id from login where login_id='$username')");
						$rsz=mysql_fetch_array($qryz);
						?>
						<h1><?php echo 	$rsz['dept_nm'];?>चे प्राधान्यानुसार रिपोर्ट्स </h1>
					</div>
				</div><!--pageheader-->
			<div class="maincontent">
				<div class="maincontentinner">
						<h4 class="widgettitle"><?php echo 	$rsz['dept_nm'];?>चे प्राधान्यानुसार रिपोर्ट्स </h4>
						<form method="post" action="">
						<?php 		
						$id=$_REQUEST['id'];
						#################### Display Counter #########################
						if($id=="")
							{
								convert_marathi();
								$qre=("SELECT  priority_days, COUNT(*) AS TOTAL FROM  incoming_letters_transaction i,  tapal_to_dpt_transaction t 
								WHERE t.ltr_id=i.ltr_id
								AND t.dept_id_from=(select dept_id from login where login_id='$username')
								AND i.priority_days!='0' GROUP BY priority_days");
							
								$rsut=mysql_query($qre) or die("".mysql_error());
								echo "<table  id='dyntable' class='table table-bordered'>
								<thead>
									<tr>
										<th class='head0 center' style='width:160px;'>प्राधान्य दिवस </th>
										<th class='head1 center'>एकूण </th>
									</tr>
								</thead>";
								while($rws = mysql_fetch_array($rsut))
								{
									$id=$rws['priority_days'];
									?>
									<tbody>
									<tr class="gradeX">
									<?php 
										echo "<td class='center'><a href='report_dpt_priority.php?flag=n&id=$id&no=1'>".$rws['priority_days']."</a></td>	
										<td class='center'>". $rws['TOTAL']."</td> </tr>";           
								}?>
								</tbody>
								</table>
								
								<?php
								echo "
								<div id='divToPrint' style='display:none;'>
								<table id='export' border='1px' style='margin-left:50px;'>
								<tr><td colspan='9'><center><h4>".$rsz['dept_nm']. "चे प्राधान्यानुसार रिपोर्ट्स </h4></center></td></tr>";
									convert_marathi();
									$qre=("SELECT  priority_days, COUNT(*) AS TOTAL FROM  incoming_letters_transaction i,  tapal_to_dpt_transaction t 
								WHERE t.ltr_id=i.ltr_id
								AND t.dept_id_from=(select dept_id from login where login_id='$username')
								AND i.priority_days!='0' GROUP BY priority_days");
							 
									$rsut=mysql_query($qre) or die("".mysql_error());
									echo "
									<tr>
									<th>प्राधान्य दिवस </th>
									<th>एकूण </th>
									</tr>";
								while($rws = mysql_fetch_array($rsut))
								{
									$id=$rws['priority_days'];
									echo "<tr><td style='text-align:center;'>".$rws['priority_days']."</td>	<td style='text-align:center;'>".$rws['TOTAL']."</td> </tr>";           
								}
								
							echo	"</table></div>";
						} 
							#################### End Of Display Counter #########################
					
							#################### Display Details #########################
							else if( $id != "")
							{
								convert_marathi();
								echo "<form name='dept_sandarbh' action='' method='post'>
								<div align='center'><br><table align='center' cellpadding='2' cellspacing='0' class='myClass'>
								<table>
									<tr>										  
										<td align='center'><label style='width:110px;'>Start date</label></td>
										<td align='center'><input type='text' name='start_date' 					class='input-small'/></td>
										<td align='center'><label style='width:110px;'>End Date</label></td>
										<td align='center'><input type='text' name='end_date' class='input-small'/></td>
									</tr>
									<tr>
										<td colspan='6'>
										<div align='center'>
											<input type='submit' onClick='return sadyasthitiDates()' name='ok' value='GO'/>
											<input type='reset' value='CLEAR' name='clear'/>
										</div>
										</td>
									</tr>
								</table>
							</div>				
							</form>
							<form action='' method='post'>";
							$date123	= $_POST['start_date'];
							$date1	= date('Y-m-d',strtotime($date123));
							$date223	= $_POST['end_date'];
							$date2	= date('Y-m-d',strtotime($date223));
							//$date22	= date('d-m-Y',strtotime($date2));
							if($date123==''&& $date223=='')
							{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction i, tapal_to_dpt_transaction t 
								where t.dept_id_from=(select dept_id from login where login_id='$username') 
								AND i.priority_days='$id' 
								AND t.ltr_id= i.ltr_id") or die("sdfdfds".mysql_error());
								
								
							}
							else
							{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction i, tapal_to_dpt_transaction t 
								where t.dept_id_from=(select dept_id from login where login_id='$username') 
								AND i.priority_days='$id' 
								AND t.ltr_id= i.ltr_id AND (i.receive_dt BETWEEN '$date1' AND '$date2')") or die("sdfdfds".mysql_error());
							}
								?> 
								<table id="dyntable" class="table table-bordered">
								<thead>
								<!--<tr>
									<th class="head0 center">आवक_क्रमांक <br>आवक दि. </th>
									<th class="head1 center">विभागीय आवक_क्रमांक <br>विभागीय प्राप्त दि. </th>
									<th class="head0 center">संदर्भ_क्रमांक <br>संदर्भ दिं.</th>                          
									<th class="head1 center">कोणाकडून प्राप्त झाले  </th>
									<th class="head0 center">थोडक्यात विषय </th>                         
									<th class="head1 center">संदर्भाचा प्रकार </th>
									<th class="head0 center">डेस्कचे नाव</th>  
									<th class="head1 center">डेस्क ला पाठवलेली दि.  </th>
								</tr>-->
								<tr>
									<th class="head0 center">आवक_क्रमांक <br>आवक दि. </th>
									<th class="head1 center">विभागीय आवक_क्रमांक <br>विभागीय प्राप्त दि. </th>
									<th class="head0 center">संदर्भ_क्रमांक <br>संदर्भ दिं.</th>                          
									<th class="head1 center">कोणाकडून प्राप्त झाले  </th>
									<th class="head0 center">थोडक्यात विषय </th>                         
									<th class="head1 center">संदर्भाचा प्रकार </th>
									<th class='head0 center'>केलेली कार्यवाही</th>
								</tr>
								</thead>
								<?php
									while($rws = mysql_fetch_array($result222))
									{ 
										$dsrecdt = strtotime($rws['sent_to_desk_dt']);
										$dsrecdt1= date('d-m-Y', $dsrecdt);
										$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
										$dprecdt1= date('d-m-Y', $dprecdt);
										$refdt = strtotime($rws['ref_dt']);
										$refdt1= date('d-m-Y', $refdt);
										$recdt = strtotime($rws['receive_dt']);
										$recdt1= date('d-m-Y', $recdt);
										?>
										<tr class="gradeX">
										<?php 
										echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
										<td class='center'>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
										
										echo "<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
										<td class='center'>".$rws['sender_name']."</td><td class='center'>".$rws['subject']."</td>";
										$l=$rws['ltr_type'];
										$l1=mysql_query("Select sandharbh_nm from sandharbh_master where sandhrbh_id='$l'");
										$lr1=mysql_fetch_array($l1);
										echo "<td class='center'><a href=report_dpt_sandharbha.php?flag=n&ltr_id=$l&no=1>".$lr1['sandharbh_nm']."</a></td>";
										/*$l2=$rws['desk_id'];
										$l3=mysql_query("Select desk_nm from desk_master where desk_id='$l2'");
										$lr3=mysql_fetch_array($l3);
										if($dsrecdt1==="01-01-1970")
										{
										echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font></td>";
										}
										else
										{
										echo "<td class='center'>".$lr3['desk_nm']."</td>";
										}
										if($dsrecdt1==="01-01-1970")
										{	
											echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font></td>";
										}
										else if ($dsrecdt1!="01-01-1970"){
											echo "<td class='center'>".$dsrecdt1."</td>";
										}*/
										if($rws['action_taken']=='')
										{
											echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी</font> </td>";
										}
										else
										{
											echo "<td class='center'>".$rws['action_taken']."</td>";		
										}
											echo" </select></tr>";
										}
								//mysql_close();
								echo"   </tbody></table>";
								
								
								echo "<div id='divToPrint' style='display:none;'>
								<table id='export' border='1px' style='margin-left:50px;'>
								<tr><td colspan='9'><center><h4>  प्राधान्यानुसार रिपोर्ट्स </h4></center></td></tr>";
								convert_marathi();
							if($date123==''&& $date223=='')
							{
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction i, tapal_to_dpt_transaction t 
								where t.dept_id_from=(select dept_id from login where login_id='$username') 
								AND i.priority_days='$id' 
								AND t.ltr_id= i.ltr_id") or die("sdfdfds".mysql_error());
							}
							else
							{
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction i, tapal_to_dpt_transaction t 
								where t.dept_id_from=(select dept_id from login where login_id='$username') 
								AND i.priority_days='$id' 
								AND t.ltr_id= i.ltr_id AND (i.receive_dt BETWEEN '$date1' AND '$date2')") or die("sdfdfds".mysql_error());
							}
								echo "<tr>
									
									<th class='head0 center'>आवक_क्रमांक <br>आवक दि. </th>
									<th class='head1 center'>विभागीय आवक_क्रमांक <br>विभागीय प्राप्त दि. </th>
									<th class='head0 center'>संदर्भ_क्रमांक <br>संदर्भ दिं.</th>                          
									<th class='head1 center'>कोणाकडून प्राप्त झाले  </th>
									<th class='head0 center'>थोडक्यात विषय </th>                         
									<th class='head1 center'>संदर्भाचा प्रकार </th>
									<th class='head0 center'>केलेली कार्यवाही</th>
								
								</tr>";
									while($rws = mysql_fetch_array($result222))
									{ 
										$dsrecdt = strtotime($rws['sent_to_desk_dt']);
										$dsrecdt1= date('d-m-Y', $dsrecdt);
										$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
										$dprecdt1= date('d-m-Y', $dprecdt);
										$refdt = strtotime($rws['ref_dt']);
										$refdt1= date('d-m-Y', $refdt);
										$recdt = strtotime($rws['receive_dt']);
										$recdt1= date('d-m-Y', $recdt);
										
										echo "<tr>";
										echo "<td style='text-align:center;'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
										<td style='text-align:center;'>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
										
										echo "<td style='text-align:center;'>".$rws['ref_no']."<br>".$refdt1."</td>
										<td style='text-align:center;'>".$rws['sender_name']."</td><td class='center'>".$rws['subject']."</td>";
										$l=$rws['ltr_type'];
										$l1=mysql_query("Select sandharbh_nm from sandharbh_master where sandhrbh_id='$l'");
										$lr1=mysql_fetch_array($l1);
										echo "<td cstyle='text-align:center;'>".$lr1['sandharbh_nm']."</td>";
										/*$l2=$rws['desk_id'];
										$l3=mysql_query("Select desk_nm from desk_master where desk_id='$l2'");
										$lr3=mysql_fetch_array($l3);
										if($dsrecdt1==="01-01-1970")
										{
										echo "<td style='text-align:center;'>डेस्क लावणे बाकी</td>";
										}
										else
										{
										echo "<td style='text-align:center;'>".$lr3['desk_nm']."</td>";
										}
										if($dsrecdt1==="01-01-1970")
										{	
											echo "<td style='text-align:center;'><font color='red'>डेस्क लावणे बाकी</font></td>";
										}
										else if ($dsrecdt1!="01-01-1970"){
											echo "<td style='text-align:center;'>".$dsrecdt1."</td>";
										}*/
										if($rws['action_taken']=='')
										{
											echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी</font> </td>";
										}
										else
										{
											echo "<td class='center'>".$rws['action_taken']."</td>";		
										}
									
										echo" </tr>";
									}
								//mysql_close();
								echo "</table></div>";
							}
							################################ End Of Display Details ###############################################
							?><br>
							<p>	
								<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"/>
								<input type="button" class="btn" onclick="tableToExcel('export', 'W3C Example Table')" value="Export to Excel"></center>
							</p>
						</form>
						<br /><br />
						<?php include_once('footer.php'); ?>
					</div><!--maincontentinner-->
			</div><!--maincontent--> 
		</div><!--rightpanel-->
	</div><!--mainwrapper-->
</body>
</html>
<?php }
############################## End Of Display Priority Wise Report TO Department ###################
} // else if($flag=='n')
?>