<?php
$flag=$_REQUEST['flag'];
$id=$_REQUEST['id'];

require_once('convert_marathi.php');
$no=$_GET['no'];
$ltrid=$_REQUEST['ltr_id'];
############################################### Jatan Prakar Wise Report For Tapal ########################################
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'];?>जतन प्रकारानुसार रिपोर्ट्स   ( <?php echo $id;?> ) </h4>
					<form method="post" action="">
						<?php 		
							$id=$_REQUEST['id'];
						
						############################ Display Counter ##############################
						if($id=="")
						{
					        convert_marathi();
							
							$rsut=mysql_query("SELECT jatanprakar_nm from jatanprakar_master ORDER BY jatanprakar_nm ASC") or die("".mysql_error());
							$x=0; 
							$y=0;
							$c=0;
							
							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>
								<tbody>";
									while($row=mysql_fetch_array($rsut))
									{
										$vargawari=$row['jatanprakar_nm'];
										
										//////////////dept without desk/////////
										$q1=mysql_query("SELECT COUNT(*) AS TOTAL 
										FROM tapal_to_dpt_transaction t, incoming_letters_transaction i
										WHERE t.desk_id='0' 
										AND (t.vargawari!='' AND t.ltr_status!='')
										AND i.ltr_id=t.ltr_id 
										AND t.vargawari='$vargawari'") or die("aaaa".mysql_error());
										$r1=mysql_fetch_array($q1);
										$count[$x]=$r1['TOTAL'];
										//echo $count[$x]."<br>";
										
										/////////////dept with desk///////////
										$q2=mysql_query("SELECT COUNT(*) AS TOTAL FROM desk_transaction d, tapal_to_dpt_transaction t, incoming_letters_transaction i
										WHERE (d.vargawari!='' AND d.ltr_status!='')
										AND (d.dpt_ltr_id=t.dpt_ltr_id) 
										AND i.ltr_id=t.ltr_id 
										AND d.vargawari='$vargawari'") or die("bbbb".mysql_error());
										$r2=mysql_fetch_array($q2);
										$count1[$y]=$r2['TOTAL'];
										//echo $count1[$y]."<br>";
										$count2[$c]=$count[$x]+$count1[$y];
										//echo $count2[$c]." ssssss";
										echo "<tr class='gradeX'>
												<td class='center'><a href='report_jatanprakar_tapal.php	?id=$vargawari&no=2'>".$vargawari."</a></td>
												<td class='center'>".$count2[$c]."</td> 
											</tr>"; 
										$x++;
										$y++;
										$c++;
										
									}
							echo "</tbody>
							</table>";
							
							
							echo "<div id='divToPrint' style='display:none;'>
							<center><h2>पोलीस अधिक्षक कार्यालय, <br> जि.रायगड <h2>
								<table id='export' border='1px' style='margin-left:50px;'>";
								
							echo "<tr><td colspan='9'><center><b>जतन प्रकारानुसार रिपोर्ट्स  </b></center></td></tr>";
							echo "<tr>
									<th>जतन प्रकार </th>
									<th>एकूण </th>
								</tr>";
							convert_marathi();
							
							$rsut=mysql_query("SELECT jatanprakar_nm from jatanprakar_master ORDER BY jatanprakar_nm ASC") or die("".mysql_error());
							$x=0; 
							$y=0;
							$c=0;
							
							while($row=mysql_fetch_array($rsut))
							{
								$vargawari=$row['jatanprakar_nm'];
									
								//////////////dept without desk/////////
								$q1=mysql_query("SELECT COUNT(*) AS TOTAL 
								FROM tapal_to_dpt_transaction t, incoming_letters_transaction i
								WHERE t.desk_id='0' 
								AND (t.vargawari!='' AND t.ltr_status!='')
								AND i.ltr_id=t.ltr_id 
								AND t.vargawari='$vargawari'") or die("aaaa".mysql_error());
								$r1=mysql_fetch_array($q1);
								$count[$x]=$r1['TOTAL'];
								//echo $count[$x]."<br>";
										
								/////////////dept with desk///////////
								$q2=mysql_query("SELECT COUNT(*) AS TOTAL FROM desk_transaction d, tapal_to_dpt_transaction t, incoming_letters_transaction i
								WHERE (d.vargawari!='' AND d.ltr_status!='')
								AND (d.dpt_ltr_id=t.dpt_ltr_id) 
								AND i.ltr_id=t.ltr_id 
								AND d.vargawari='$vargawari'") or die("bbbb".mysql_error());
								$r2=mysql_fetch_array($q2);
								$count1[$y]=$r2['TOTAL'];
								//echo $count1[$y]."<br>";
								$count2[$c]=$count[$x]+$count1[$y];
								//echo $count2[$c]." ssssss";
								echo "<tr class='gradeX'>
										<td class='center'>".$vargawari."</td>
										<td class='center'>".$count2[$c]."</td> 
									</tr>"; 
								$x++;
								$y++;
								$c++;
										
							}
							echo "</table></center></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 de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt,t.desk_approval,t.sent_to_desk_dt,  t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt,de.nasti_nashta_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no ,i.sent_dt
								FROM  incoming_letters_transaction  i  LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id
								LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id
								where (de.vargawari='$id' AND de.ltr_status!='') ") or die("sdfdfds".mysql_error());
								
								$result2221=mysql_query("SELECT  t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.dept_id_from,t.action_taken,i.priority_days,  i.subject, t.update_date, t.dispatched_date,t.nasti_nashta_dt, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no  ,i.sent_dt
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON (di.dpt_inword_no = t.dpt_inword_no AND t.desk_id = '0')
								WHERE  (t.vargawari != '' AND t.ltr_status!='')
								AND t.vargawari = '$id' ") or die("aaaa".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 de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt,t.desk_approval,t.sent_to_desk_dt,  t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt,de.nasti_nashta_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no  ,i.sent_dt
								FROM  incoming_letters_transaction  i  LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id
								LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id
								where (de.vargawari='$id' AND de.ltr_status!='')
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')") or die("bbb".mysql_error());
								
							
								$result2221=mysql_query("SELECT  t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.dept_id_from,t.action_taken,i.priority_days,  i.subject, t.update_date, t.dispatched_date,t.nasti_nashta_dt, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no  ,i.sent_dt
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON (di.dpt_inword_no = t.dpt_inword_no AND t.desk_id = '0')
								WHERE  (t.vargawari != '' AND t.ltr_status!='')
								AND t.vargawari = '$id'
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')") or die("ccccc".mysql_error());
							}
							echo "<table id='dyntable' class='table table-bordered'>						
									<thead>
										<tr>
										<th class=head0 center>पोलीस अधिक्षक <br> कार्यालय<br> आवक_क्रमांक<br>व_दिनांक</th>
										<th class=head1 center>संदर्भ क्रमांक <br> व_दिनांक</th>
										<th class=head1 center> विभाग आवक_क्रमांक <br>व_दिनांक</th>
										<th class=head1 center>विषय</th>
										<th class=head0 center>कोणाकडून प्राप्त झाला</th>
										<th class=head1 center>विभागाला पाठवले</th>";
									//	echo "<th class=head0 center>विभागाला_संदर्भ पाठवलेली_दिनांक </th>";
										echo "<th class=head1 center>डेस्कला  पाठवले</th>
										<th class=head0 center>डेस्कला पाठवलेली_दिनांक </th>
										<th class='head0 center'>केलेली कार्यवाही</th>
										<th class='head1 center'>नस्ती नष्ट दिनांक </th>
										</tr>
									</thead>
									<tbody>";
								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']));
										$deskrecdt=	date('d-m-Y',strtotime($test['sent_to_desk_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['ref_no']."<br>".$ref_dt."</td>
										<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
										
										<td class='center'>".$test['subject']."</td>
										<td class='center'>".$test['sender_name']."</td>";
										
										$q13=mysql_query("select dept_nm from department_master where dept_id=$test[dept_id_from]");
										$rs13=mysql_fetch_array($q13);
										
										echo "<td class='center'><a href=report_dptwise.php?deptid=$test[dept_id_from]&no=2>".$rs13['dept_nm']."</a></td>";
									
										//echo "<td>".$sent_dt."</font></td>";
										
										$q14=mysql_query("select desk_nm from desk_master where desk_id=$test[desk_id]");
										$rs14=mysql_fetch_array($q14);
										echo "<td class='center'><a href=report_dpt_deskwise.php?no=2&deskid=$test[desk_id]>".$rs14['desk_nm']."</a></td>
										<td class='center'>".$deskrecdt."</td>";
									
										echo "<td class='center'>".$test['action_taken']."</td>";
										
										///////////nasti nashta date////////////
											if($id=='अ')
											{
												echo "<td class='center'>LifeTime</td>";
											}
											else
											{
												echo "<td class='center'>".$test['nasti_nashta_dt']."</td>";
											}
										echo "</tr>";
									
									}
								while($test1 = mysql_fetch_array($result2221))
								{
									$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
									$ref_dt		= date('d-m-Y',strtotime($test1['ref_dt']));
									$sent_dt		= date('d-m-Y',strtotime($test1['sent_dt']));
									$rcv_dt		= date('d-m-Y',strtotime($test1['receive_dt']));
									echo "<tr class=gradeX>
										<td class='center'>".$test1['ltr_inword_no']."<br>".$rcv_dt."</td>
										<td class='center'>".$test1['dpt_inword_no']."<br>".$dept_rec_date."</td>
										<td class='center'>".$test1['ref_no']."<br>".$ref_dt."</td>
										<td class='center'>".$test1['subject']."</td>
										<td class='center'>".$test1['sender_name']."</td>";
										
										$q131=mysql_query("select dept_nm,desk_flag from department_master where dept_id=$test1[dept_id_from]");
										$rs131=mysql_fetch_array($q131);
										
										if($rs131['desk_flag']=='Y' || $rs131['desk_flag']=='y')
										{
											echo "<td class='center'><a href=report_dptwise.php?deptid=$test1[dept_id_from]&no=2>".$rs131['dept_nm']."</a></td>";
										}
										else
										{
											echo "<td class='center'><a href=report_dptwise.php?flag=n&deptid=$test1[dept_id_from]&no=2>".$rs131['dept_nm']."</a></td>";
										}
										//echo "<td>".$sent_dt."</font></td>";
										
										echo "<td class='center'>--</td>
										<td class='center'>--</td>
										<td class='center'>".$test1['action_taken']."</td>";
										///////////nasti nashta date////////////
											if($id=='अ')
											{
												echo "<td class='center'>LifeTime</td>";
											}
											else
											{
												echo "<td class='center'>".$test1['nasti_nashta_dt']."</td>";
											}
											
										echo "</tr>";
								//	echo "<td class='center'>".$test['action_taken']."</td>";
									
								}//mysql_close();
									
							echo" </tbody> </table>";
									
							echo "<div id='divToPrint' style='display:none;'>
							<center><h2>पोलीस अधिक्षक कार्यालय, <br> जि.रायगड <h2>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='10'><center><b>जतन प्रकारानुसार  रिपोर्ट्स ( ".$id." )</b><br>दिनांक ".$date123." पासून दिनांक ".$date223."</center></td></tr>";
							
							if($date123==''&& $date223=='') 
							{
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt,t.desk_approval,t.sent_to_desk_dt,  t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt,de.nasti_nashta_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no 
								FROM  incoming_letters_transaction  i  LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id
								LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id
								where (de.vargawari='$id' AND de.ltr_status!='') ") or die("sdfdfds".mysql_error());
								
								$result2221=mysql_query("SELECT  t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.dept_id_from,t.action_taken,i.priority_days,  i.subject, t.update_date, t.dispatched_date,t.nasti_nashta_dt, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON (di.dpt_inword_no = t.dpt_inword_no AND t.desk_id = '0')
								WHERE  (t.vargawari != '' AND t.ltr_status!='')
								AND t.vargawari = '$id' ") or die("aaaa".mysql_error());
							}
							else
							{
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt,t.desk_approval,t.sent_to_desk_dt,  t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt,de.nasti_nashta_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no 
								FROM  incoming_letters_transaction  i  LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id
								LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id
								where (de.vargawari='$id' AND de.ltr_status!='')
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')") or die("bbb".mysql_error());
								
								$result2221=mysql_query("SELECT  t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.dept_id_from,t.action_taken,i.priority_days,  i.subject, t.update_date, t.dispatched_date,t.nasti_nashta_dt, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON (di.dpt_inword_no = t.dpt_inword_no AND t.desk_id = '0')
								WHERE  (t.vargawari != '' AND t.ltr_status!='')
								AND t.vargawari = '$id'
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')") or die("ccccc".mysql_error());
							}
							echo "					
									
										<tr>
										<th class=head0 center>पोलीस अधिक्षक <br> कार्यालय <br> आवक_क्रमांक<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>";
										//echo "<th class=head0 center>विभागाला_संदर्भ पाठवलेली_दिनांक </th>";
										echo "<th class=head1 center>डेस्कला  पाठवले</th>
										<th class=head0 center>डेस्कला पाठवलेली_दिनांक </th>
										<th class='head0 center'>केलेली कार्यवाही</th>
										<th class='head1 center'>नस्ती नष्ट दिनांक </th>
										</tr>
									
									<tbody>";
								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']));
										$deskrecdt=	date('d-m-Y',strtotime($test['sent_to_desk_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>";
										$q13=mysql_query("select dept_nm from department_master where dept_id=$test[dept_id_from]");
										$rs13=mysql_fetch_array($q13);
										echo "<td class='center'>".$rs13['dept_nm']."</td>";
										
										//echo "<td>".$sent_dt."</font></td>";
										
										$q14=mysql_query("select desk_nm from desk_master where desk_id=$test[desk_id]");
										$rs14=mysql_fetch_array($q14);
										echo "<td class='center'>".$rs14['desk_nm']."</td>
										<td class='center'>".$deskrecdt."</td> 
										<td class='center'>".$test['action_taken']."</td>";
										
											///////////nasti nashta date////////////
										if($id=='अ')
										{
											echo "<td class='center'>LifeTime</td>";
										}
										else
										{
											echo "<td class='center'>".$test['nasti_nashta_dt']."</td>";
										}
										echo "</tr>";
										
								//	echo "<td class='center'>".$test['action_taken']."</td>";
									
								}
								while($test1 = mysql_fetch_array($result2221))
								{
									$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
									$ref_dt		= date('d-m-Y',strtotime($test1['ref_dt']));
									$sent_dt		= date('d-m-Y',strtotime($test1['sent_dt']));
									$rcv_dt		= date('d-m-Y',strtotime($test1['receive_dt']));
									echo "<tr class=gradeX>
										<td class='center'>".$test1['ltr_inword_no']."<br>".$rcv_dt."</td>
										<td class='center'>".$test1['dpt_inword_no']."<br>".$dept_rec_date."</td>
										<td class='center'>".$test1['ref_no']."<br>".$ref_dt."</td>
										<td class='center'>".$test1['subject']."</td>
										<td class='center'>".$test1['sender_name']."</td>";
										
										$q131=mysql_query("select dept_nm from department_master where dept_id=$test1[dept_id_from]");
										$rs131=mysql_fetch_array($q131);
										echo "<td class='center'>".$rs131['dept_nm']."</td>";
										
										//echo "<td>".$sent_dt."</font></td>";
										
										echo "<td class='center'>--</td>
										<td class='center'>--</td>
										
										<td class='center'>".$test1['action_taken']."</td>";
											///////////nasti nashta date////////////
										if($id=='अ')
										{
											echo "<td class='center'>LifeTime</td>";
										}
										else
										{
											echo "<td class='center'>".$test['nasti_nashta_dt']."</td>";
										}
										echo "</tr>";
										
								//	echo "<td class='center'>".$test['action_taken']."</td>";
								
								}//mysql_close();
								
							echo"</tbody>
							</table></center>
						</div></form>";	
					}
							########################## 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('sample_1', 'Sandarbha-Nusar Report')" 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
}
?>