<?php
 require_once('convert_marathi.php');
$user=$_GET['user'];
$no=$_GET['no'];
$username = $_SESSION['User_Name'];
$flag=$_REQUEST['flag'];
########################################################### if user is tapal ################################################  
if($user==2)
{
include_once('dashboard_department.php');
convert_marathi();
$desk_id=$_GET['deskid'];
$name=mysql_query("Select desk_nm from desk_master where desk_id='$desk_id'");
$desknm=mysql_fetch_array($name);
?>

<!DOCTYPE html>
<html>
<head>
<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>
<script type="text/javascript" src="js/adduser.js"></script> 
</head>

    <div class="rightpanel">
        
        <ul class="breadcrumbs">
            <li><a href="dashboard_tapal.php"><i class="iconfa-home"></i></a> <span class="separator"></span></li>
            <li><a href="dashboard_tapal.php">Tables</a> <span class="separator"></span></li>
            <li>Table Dynamic</li>
        </ul>
        
        <div class="pageheader">
           
            <div class="pageicon"><span class="iconfa-table"></span></div>
            <div class="pagetitle">
                <h5>Tables</h5>
                <h1>Welcome <?php echo $username?> User</h1>
            </div>
        </div><!--pageheader-->
<?php 
	}  
	
 ?>     
        <div class="maincontent">
            <div class="maincontentinner">
				
				<?php 
				
				if ($no==1)
				{	
				?>			
						<h4 class="widgettitle"><?php echo $desknm['desk_nm'];?> चे अस्वीकृत पत्राचे रिपोर्ट्स <h4>
						<form name="sadyasthiti" 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="4">
								<div align="center">
									<input type="submit" onClick="return sadyasthitiDate()" name="ok" value="GO"/>
									<input type="reset" value="CLEAR" name="clear"/>
								</div>
								</td>
							</tr>
						</table>
					</div>
				</form>
				<form>
						

						<?php
						convert_marathi();
						$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));
						echo '<br><br><center>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center><br>';$id = $date1;
						$id1= $date2;

							#########################		Pending report dept user     #######################
						if($date123==''&& $date223=='')
							{	
						
								$qry1=mysql_query("Select * FROM incoming_letters_transaction i LEFT OUTER JOIN  	tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id' ") OR die("aaaa".mysql_error());
								$cnt=mysql_num_rows($qry1);
								//echo "aaaaaaaaa".$cnt;
							}
						else
							{
								$qry1=mysql_query("Select * FROM incoming_letters_transaction i LEFT OUTER JOIN  tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id'
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error());
							}
							echo	"<table id='dyntable' class='table table-bordered'>
									<thead>
									<tr>
										<th class='head1 center'>पोलीस अधिक्षक <br> कार्यालय <br> आवक क्रमांक <br>आवक दिनांक</th>
										<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'>कोणाकडून <br>प्राप्त झाला</th>
										<th class='head1 center'> केलेली <br>कार्यवाही </th>
									</tr></thead><tbody>";
						
							
						while($test = mysql_fetch_array($qry1))
						{
								$desk_ltr_rec_dt = date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
								$dept_rec_date 	= date('d-m-Y',strtotime($test['sent_dt']));
								$dptid=$test['dept_id_from'];
								$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dptid' ");
								$dptnm=mysql_fetch_array($q);
								
								if($test['status']=='pending' && $test['desk_id']=='0')
								{
									$avno='स्वीकारणे बाकी ';
								}
								else
								{
									$avno=$test['dpt_inword_no'];
									//$avno=$test['desk_ltr_inword_no'];
								}
								
							/*	if($test['action_taken']=='')
								{
									$action="कार्यवाही केलेली नाही ";
								}
								else
								{
									$action=$test['action_taken'];
								}
								*/
								$receive_dt	= date('d-m-Y',strtotime($test['receive_dt']));
								$refdt	= date('d-m-Y',strtotime($test['ref_dt']));
								$m=$test['ltr_type'];
			
							echo "
							<tr class='gradeX'>
							<td class='center'>".$test['ltr_inword_no']."<br>".$receive_dt."</td>
							<td class='center'>".$dptnm['dept_nm']."<br>".$avno."<br></td>
							<td class='center'>".$test['ref_no']."<br>".$refdt."</td>";
							
							$ltrtype=mysql_query("select sandharbh_nm FROM sandharbh_master WHERE sandhrbh_id='$m'");
							$s=mysql_fetch_array($ltrtype);
							echo "<td class='center'>".$s['sandharbh_nm']."</td>
							<td class='center'>".$test['subject']."</td>
							<td class='center'>".$test['sender_name']."</td>
							<td class='center'><font color='red'>कार्यवाही केलेली नाही.</font></td>
							</tr>";
						}
						echo "</tbody></table>";
			
						################################ print table ##################################
						echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='7'><center>".$desknm['desk_nm']." चे अस्वीकृत पत्राचे रिपोर्ट्स <br>दिनांक ".$date123." पासून दिनांक ".$date223."</center></td></tr>";
							
							echo ' <center><h2>पोलीस अधिक्षक <br> कार्यालय कार्यालय <br> तालुका राहुरी जिल्हा अहमदनगर <h2></center>'; 
							#########################		Pending report tapal user     ##################
							
							if($date123==''&& $date223=='')
							{	
								$qry1=mysql_query("Select * FROM incoming_letters_transaction i LEFT OUTER JOIN  	tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id' ") OR die("aaaa".mysql_error());
								$cnt=mysql_num_rows($qry1);
								//echo "aaaaaaaaa".$cnt;
							}
						else
							{
								$qry1=mysql_query("Select * FROM incoming_letters_transaction i LEFT OUTER JOIN  tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id'
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error());
							}
							echo	"<tr>
										<th class='head1 center'>पोलीस अधिक्षक <br> कार्यालय <br> आवक क्रमांक <br>आवक दिनांक</th>
										<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'>कोणाकडून <br>प्राप्त झाला</th>
										<th class='head1 center'> केलेली <br>कार्यवाही </th>
									</tr>";
							while($test = mysql_fetch_array($qry1))
						{
								$desk_ltr_rec_dt = date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
								$dept_rec_date 	= date('d-m-Y',strtotime($test['sent_dt']));
								$dptid=$test['dept_id_from'];
								$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dptid' ");
								$dptnm=mysql_fetch_array($q);
								
								if($test['status']=='pending' && $test['desk_id']=='0')
								{
									$avno='स्वीकारणे बाकी ';
								}
								else
								{
									$avno=$test['dpt_inword_no'];
									//$avno=$test['desk_ltr_inword_no'];
								}
								
							/*	if($test['action_taken']=='')
								{
									$action="कार्यवाही केलेली नाही ";
								}
								else
								{
									$action=$test['action_taken'];
								}
								*/
								$receive_dt	= date('d-m-Y',strtotime($test['receive_dt']));
								$refdt	= date('d-m-Y',strtotime($test['ref_dt']));
								$m=$test['ltr_type'];
			
							echo "
							<tr class='gradeX'>
							<td class='center'>".$test['ltr_inword_no']."<br>".$receive_dt."</td>
							<td class='center'>".$dptnm['dept_nm']."<br>".$avno."<br></td>
							<td class='center'>".$test['ref_no']."<br>".$refdt."</td>";
							
							$ltrtype=mysql_query("select sandharbh_nm FROM sandharbh_master WHERE sandhrbh_id='$m'");
							$s=mysql_fetch_array($ltrtype);
							echo "<td class='center'>".$s['sandharbh_nm']."</td>
							<td class='center'>".$test['subject']."</td>
							<td class='center'>".$test['sender_name']."</td>
							<td class='center'>कार्यवाही केलेली नाही.</td>
							</tr>";
						}
						echo"</table></center></div>";
				}//if no=1
				#########################	End Of Pending report tapal user     #############################
				
				#########################	Accepted Letter report tapal user     #############################
				else if($no==2)
				{
						?>	
			
					<h4 class="widgettitle"><?php echo $desknm['desk_nm']; ?> चे स्वीकृत पत्राचे रिपोर्ट्स <h4>
					<form method='post'>
						<form name="sadyasthiti" action="" method="post">
						<div align="center"><br><table align="center" cellpadding="2" cellspacing="0" class='myClass'>
						<table>
							<tr>
								<td><label>तारखेचा प्रकार निवडा  : </label></td>
								<td><span class="field unicode" lang="mr">
										<select name="datetype">
											<option value="">तारखेचा प्रकार निवडा</option>  
											<option value="1">आवक दिनांक</option>
											<option value="2">विभागीय आवक दिनांक</option>
											<option value="3">डेस्क आवक दिनांक</option>
										</select>
									</span>
								</td>
									  
								<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="4">
								<div align="center">
									<input type="submit" onClick="return sadyasthitiDate()" name="ok" value="GO"/>
									<input type="reset" value="CLEAR" name="clear"/>
								</div>
								</td>
							</tr>
						</table>
					</div>
				</form>
				<form action="" method="post">

						<?php
						convert_marathi();
						$dt_type=$_POST['datetype'];
						//echo "date".$dt_type;
						$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=='' && $dt_type=='')
							{	
								echo '<br><br><center>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center><br>';$id = $date1;
								$id1= $date2;
						
								$qry1=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.ltr_type, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'") OR die("aaaa".mysql_error());
							}
							else if($date123!=''&& $date223!='' && $dt_type==1)
							{
								echo '<br><center><h4> <font color="red">आवक दिनांकनुसार संदर्भ </font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
								
								$qry1=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.ltr_type, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')");
							}
							else if($date123!=''&& $date223!='' && $dt_type==2)
							{
								echo '<br><center><h4> <font color="red">आवक दिनांकनुसार संदर्भ </font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
								
								$qry1=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.ltr_type, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND (t.dpt_ltr_rec_dt BETWEEN '$date1' AND '$date2')");
							}
							else if($date123!=''&& $date223!='' && $dt_type==3)
							{
								echo '<br><center><h4> <font color="red">आवक दिनांकनुसार संदर्भ </font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
								
								$qry1=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.ltr_type, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND (d.desk_ltr_rec_dt BETWEEN '$date1' AND '$date2')");
							}
							
							//$cnt=mysql_num_rows($qry1);
							echo"  <br><br><table id='dyntable' class='table table-bordered'><thead>
									<tr>
									<th class='head1 center'>पोलीस अधिक्षक <br> कार्यालय <br>आवक क्रमांक <br>आवक_दिनांक</th>
									<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'>कोणाकडून <br>प्राप्त_झाला</th>
									<th class='head1 center'>केलेली <br>कार्यवाही </th>";
									
									 echo "</tr> </thead><tbody>";
									while($test = mysql_fetch_array($qry1))
									{
										$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']));
										$receive_dt	= date('d-m-Y',strtotime($test['receive_dt']));
										$refdt	= date('d-m-Y',strtotime($test['ref_dt']));
										$deskrec_dt	= date('d-m-Y',strtotime($test['sent_to_desk_dt']));
										$m=$test['ltr_type'];
										echo "
										<tr class='gradeX'>
										<td class='center'>".$test['ltr_inword_no']."<br>".$receive_dt."</td>
										<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date ."</td>";
										if($test['desk_id']=='' || $test['desk_id']=='0')
										{
											echo "<td class='center'><font color='red'>"."डेस्क लावणे बाकी  "."</font></td>";
										}
										else if($test['desk_ltr_inword_no']=='' || $test['desk_ltr_inword_no']=='0')
										{
											echo "<td class='center'><font color='red'>"."डेस्कने स्वीकारणे बाकी "."</font></td>";
										}
										else  if($test['desk_ltr_inword_no']!='0' || $test['desk_ltr_inword_no']!='')
										{
											echo "<td class='center'>".$test['desk_ltr_inword_no']."<br>".$deskrec_dt."</td>";
										}
										echo "<td class='center'>".$test['ref_no']."<br>".$refdt."</td>";
										$ltrtype=mysql_query("select sandharbh_nm FROM sandharbh_master WHERE sandhrbh_id='$m'");
										$s=mysql_fetch_array($ltrtype);
										echo "<td class='center'>".$s['sandharbh_nm']."</td>
										<td class='center'>".$test['subject']."</td>
										<td class='center'>".$test['sender_name']."</td>";
										
										if($test['action_taken']=='')
										{
											echo "<td class='center'><font color='red'>कार्यवाही केलेली नाही  </font></td>";
										}
										else if($test['ltr_status']=='')
										{
											echo "<td class='center'><font color='red'>कार्यवाही केलेली नाही  </font></td>";
										}
										else
										{
											echo "<td class='center'>".$test['action_taken']."</td>";
										}
										echo "</tr>";
									}
								echo"</tbody></table>";	
								################################## div to print ############################
								
								echo "<div id='divToPrint' style='display:none;'>
								<center><table id='export' border='1px' style='margin-left:50px;'>
								<tr><td colspan='8'><center>".$desknm['desk_nm']." चे स्वीकृत पत्राचे रिपोर्ट्स  <br>दिनांक ".$date123." पासून दिनांक ".$date223."</center></td></tr>";
								
								echo ' <center><h2>पोलीस अधिक्षक <br> कार्यालय कार्यालय <br> तालुका राहुरी जिल्हा अहमदनगर <h2></center>';
						if($date123==''&& $date223=='' && $dt_type=='')
							{	
								//echo '<br><br><center>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center><br>';$id = $date1;
								$id1= $date2;
						
								$qry1=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.ltr_type, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'") OR die("aaaa".mysql_error());
							}
							else if($date123!=''&& $date223!='' && $dt_type==1)
							{
								//echo '<br><center><h4> <font color="red">आवक दिनांकनुसार संदर्भ </font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
								
								$qry1=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.ltr_type, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')");
							}
							else if($date123!=''&& $date223!='' && $dt_type==2)
							{
								//echo '<br><center><h4> <font color="red">आवक दिनांकनुसार संदर्भ </font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
								
								$qry1=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.ltr_type, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND (t.dpt_ltr_rec_dt BETWEEN '$date1' AND '$date2')");
							}
							else if($date123!=''&& $date223!='' && $dt_type==3)
							{
								//echo '<br><center><h4> <font color="red">आवक दिनांकनुसार संदर्भ </font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
								
								$qry1=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.ltr_type, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND (d.desk_ltr_rec_dt BETWEEN '$date1' AND '$date2')");
							}
							$cnt=mysql_num_rows($qry1);
								echo	"<tr>
									<th>पोलीस अधिक्षक <br> कार्यालय <br>आवक क्रमांक <br>आवक_दिनांक</th>
									<th>विभागीय आवक क्र.<br>आवक_दिनांक</th>
									<th>डेस्कचा आवक क्र. <br>आवक_दिनांक</th>
									<th>संदर्भ_क्रमांक <br>संदर्भ दि. </th>
									<th>संदर्भाचा प्रकार</th>
									<th>विषय</th>
									<th>कोणाकडून <br>प्राप्त_झाला</th>
									<th>केलेली <br>कार्यवाही </th>";
									echo "</tr>";
									while($test = mysql_fetch_array($qry1))
									{
										$desk_ltr_rec_dt = date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
										$dept_rec_date 	= date('d-m-Y',strtotime($test['sent_dt']));
										$receive_dt	= date('d-m-Y',strtotime($test['receive_dt']));
										$refdt	= date('d-m-Y',strtotime($test['ref_dt']));
										$deskrec_dt	= date('d-m-Y',strtotime($test['sent_to_desk_dt']));
										$m=$test['ltr_type'];
			
										echo "
										<tr>
										<td style='text-align:center;'>".$test['ltr_inword_no']."<br>".$receive_dt."</td>
										<td style='text-align:center;'>".$test['dpt_inword_no']."<br>".$dept_rec_date ."</td>";
										if($test['desk_id']=='' || $test['desk_id']=='0')
										{
											echo "<td style='text-align:center;'>डेस्क लावणे बाकी </td>";
										}
										else if($test['desk_ltr_inword_no']=='' || $test['desk_ltr_inword_no']=='0')
										{
											echo "<td style='text-align:center;'>डेस्कने स्वीकारणे बाकी </td>";
										}
										else  if($test['desk_ltr_inword_no']!='0' || $test['desk_ltr_inword_no']!='')
										{
											echo "<td style='text-align:center;'>".$test['desk_ltr_inword_no']."<br>".$deskrec_dt."</td>";
										}
										echo "<td style='text-align:center;'>".$test['ref_no']."<br>".$refdt."</td>";
										$ltrtype=mysql_query("select sandharbh_nm FROM sandharbh_master WHERE sandhrbh_id='$m'");
										$s=mysql_fetch_array($ltrtype);
										echo "<td style='text-align:center;'>".$s['sandharbh_nm']."</td>
										<td style='text-align:center;'>".$test['subject']."</td>
										<td style='text-align:center;'>".$test['sender_name']."</td>";
										
										if($test['action_taken']=='')
										{
											echo "<td style='text-align:center;'>कार्यवाही केलेली नाही  </td>";
										}
										else if($test['ltr_status']=='')
										{
											echo "<td style='text-align:center;'>कार्यवाही केलेली नाही  </td>";
										}
										else
										{
											echo "<td style='text-align:center;'>".$test['action_taken']."</td>";
										}
										echo "</tr>";

									}
					echo"</table></center></div>";				
			}//if=2	
			
		#########################	End Of Accepted Letter report tapal user     #############################
		
		#########################	Dispatched,Updated Letter report tapal user     #############################
				else if($no==3)
				{
			?>		
			
			 <h4 class="widgettitle"><?php echo $desknm['desk_nm']; ?> चे पाठवलेल्या पत्राचे रिपोर्ट्स <h4>
						<form action="" method="post">
						<form name="sadyasthiti" 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="4">
								<div align="center">
									<input type="submit" onClick="return sadyasthitiDate()" name="ok" value="GO"/>
									<input type="reset" value="CLEAR" name="clear"/>
								</div>
								</td>
							</tr>
						</table>
					</div>
				</form>
				<form action="" method="post">
						

						<?php
						$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));
						echo '<br><br><center>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center><br>';$id = $date1;
						$id1= $date2;
					
						if($date123==''&& $date223=='')
						{
							$qry13=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from,i.ltr_type, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.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, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to,di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
							WHERE d.desk_id_from='$desk_id'
							AND (d.ltr_status='updated' OR d.ltr_status='dispatched')") OR die("aaaa".mysql_error());
							
							$cnt=mysql_num_rows($qry13);
						}
						else
						{
							$qry13=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from,i.ltr_type, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.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, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to,di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
							WHERE d.desk_id_from='$desk_id'
							AND (d.ltr_status='updated' OR d.ltr_status='dispatched')
							AND (i.receive_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error());
							$cnt=mysql_num_rows($qry13);
						
						}
						
						//echo "aaaaaaaaa".$cnt;
							echo"  <br><br><table id='dyntable' class='table table-bordered'><thead>
									<tr>
									<th class='head1 center'>पोलीस अधिक्षक <br> कार्यालय <br>आवक क्रमांक <br>आवक_दिनांक</th>
									<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'>कोणाकडून <br>प्राप्त_झाला</th>
									<th class='head0 center'>केलेली कार्यवाही</th>
									<th class='head0 center'>पत्राची_स्थिती </th>
									<th class='head1 center'>विभागीय <br>जावक_दिनांक</th>";
									echo "</tr>
									</thead>
									<tbody>";			
									while($test = mysql_fetch_array($qry13))
									{
										$dept_rec_date 	= date('d-m-Y',strtotime($test['sent_dt']));
										$receive_dt	= date('d-m-Y',strtotime($test['receive_dt']));
										$refdt	= date('d-m-Y',strtotime($test['ref_dt']));
										$deskrec_dt	= date('d-m-Y',strtotime($test['sent_to_desk_dt']));
										$update_date 		= date('d-m-Y',strtotime($test['update_date']));
										$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
										$dptto=$test['dept_id_to'];
										$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dptto' ");
										$dept_to=mysql_fetch_array($q);
										$m=$test['ltr_type'];
						
										echo "<tr class='gradeX'>
										<td class='center'>".$test['ltr_inword_no']."<br>".$receive_dt."</td>
										<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date ."</td>";
										if($test['desk_id']=='' || $test['desk_id']==0)
										{
											echo "<td class='center'><font color='red'>"."डेस्क लावणे बाकी "."</font></td>";
										}
										else if($test['desk_ltr_inword_no']=='' || $test['desk_ltr_inword_no']=='0')
										{
											echo "<td class='center'><font color='red'>"."डेस्कने स्वीकारणे बाकी "."</font></td>";
										}
										else
										{
											echo "<td class='center'>".$test['desk_ltr_inword_no']."<br>".$deskrec_dt."</td>";
										}
										echo "<td class='center'>".$test['ref_no']."<br>".$refdt."</td>";
										$ltrtype=mysql_query("select sandharbh_nm FROM sandharbh_master WHERE sandhrbh_id='$m'");
										$s=mysql_fetch_array($ltrtype);
										echo "<td class='center'>".$s['sandharbh_nm']."</td>
										<td class='center'>".$test['subject']."</td>
										<td class='center'>".$test['sender_name']."</td>";
										echo "<td class='center'>".$test['action_taken']."</td>";
										//////////////////////////////////////////////////////////////
										if($test['ltr_status']=='')
										{
											echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										}
										else if($test['ltr_status']=='updated' )
										{
											echo "<td class='center'>".$test['ltr_status']."</td>";
										}
										else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='Approve')
										{
											echo "<td class='center'>".$test['ltr_status']."</td>";
										}
										else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred')
										{
											echo "<td class='center'>".$test['ltr_approval']." to<br>".$dept_to['dept_nm']."</td>";
										}
										else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred_todesk')
										{	
											$todsk=$test['dsk_id_to'];
											$qq=mysql_query("SELECT desk_nm from desk_master where desk_id ='$todsk' ");
											$rr=mysql_fetch_array($qq);
											echo "<td class='center'>transferred to<br>".$rr['desk_nm']."</td>";
										}
										///////////////////////////////////////////////////////////////////////
										if ($test['ltr_status']=='updated')
										{
											echo "<td class='center'>".$update_date."</td>";
										}
										else if($test['ltr_status']=='dispatched' )
										{
											echo "<td class='center'>".$dispose_date."</td>";
										}
										
										echo "</tr>";

									}
					echo"</tbody></table>";

						
						echo "<div id='divToPrint' style='display:none;'>
								<center><table id='export' border='1px' style='margin-left:50px;'>
								<tr><td colspan='10'><center>".$desknm['desk_nm']." चे पाठवलेल्या पत्राचे रिपोर्ट्स  <br>दिनांक ".$date123." पासून दिनांक ".$date223."</center></td></tr>";
								echo ' <center><h2>पोलीस अधिक्षक <br> कार्यालय कार्यालय <br> तालुका राहुरी जिल्हा अहमदनगर <h2></center>';
						if($date123==''&& $date223=='')
						{
							$qry13=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from,i.ltr_type, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.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, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to,di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
							WHERE d.desk_id_from='$desk_id'
							AND (d.ltr_status='updated' OR d.ltr_status='dispatched')") OR die("aaaa".mysql_error());
							
							$cnt=mysql_num_rows($qry13);
						}
						else
						{
							$qry13=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from,i.ltr_type, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.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, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to,di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
							WHERE d.desk_id_from='$desk_id'
							AND (d.ltr_status='updated' OR d.ltr_status='dispatched')
							AND (i.receive_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error());
							$cnt=mysql_num_rows($qry13);
						
						}
						$cnt=mysql_num_rows($qry13);
						//echo "aaaaaaaaa".$cnt;
						echo" <tr>
								<th>पोलीस अधिक्षक <br> कार्यालय <br>आवक क्रमांक <br>आवक_दिनांक</th>
								<th>विभागीय आवक क्र.<br>आवक_दिनांक</th>
								<th>डेस्कचा आवक क्र. <br>आवक_दिनांक</th>
								<th>संदर्भ_क्रमांक <br>संदर्भ दि. </th>
								<th>संदर्भाचा प्रकार</th>
								<th>विषय</th>
								<th>कोणाकडून <br>प्राप्त_झाला</th>
								<th>केलेली कार्यवाही</th>
								<th>पत्राची_स्थिती </th>
								<th>विभागीय <br>जावक_दिनांक</th>";
						echo "</tr>";			
							
							while($test = mysql_fetch_array($qry13))
									{
										$dept_rec_date 	= date('d-m-Y',strtotime($test['sent_dt']));
										$receive_dt	= date('d-m-Y',strtotime($test['receive_dt']));
										$refdt	= date('d-m-Y',strtotime($test['ref_dt']));
										$deskrec_dt	= date('d-m-Y',strtotime($test['sent_to_desk_dt']));
										$update_date 		= date('d-m-Y',strtotime($test['update_date']));
										$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
										$dptto=$test['dept_id_to'];
										$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dptto' ");
										$dept_to=mysql_fetch_array($q);
										$m=$test['ltr_type'];
						
										echo "<tr class='gradeX'>
										<td class='center'>".$test['ltr_inword_no']."<br>".$receive_dt."</td>
										<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date ."</td>";
										if($test['desk_id']=='' || $test['desk_id']==0)
										{
											echo "<td class='center'>"."डेस्क लावणे बाकी "."</td>";
										}
										else if($test['desk_ltr_inword_no']=='' || $test['desk_ltr_inword_no']=='0')
										{
											echo "<td class='center'>"."डेस्कने स्वीकारणे बाकी "."</td>";
										}
										else
										{
											echo "<td class='center'>".$test['desk_ltr_inword_no']."<br>".$deskrec_dt."</td>";
										}
										echo "<td class='center'>".$test['ref_no']."<br>".$refdt."</td>";
										$ltrtype=mysql_query("select sandharbh_nm FROM sandharbh_master WHERE sandhrbh_id='$m'");
										$s=mysql_fetch_array($ltrtype);
										echo "<td class='center'>".$s['sandharbh_nm']."</td>
										<td class='center'>".$test['subject']."</td>
										<td class='center'>".$test['sender_name']."</td>";
										echo "<td class='center'>".$test['action_taken']."</td>";
										////////////////////////////////////////////
										if($test['ltr_status']=='')
										{
											echo "<td class='center'> कार्यवाही करणे बाकी </td>";
										}
										else if($test['ltr_status']=='updated' )
										{
											echo "<td class='center'>".$test['ltr_status']."</td>";
										}
										else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='Approve')
										{
											echo "<td class='center'>".$test['ltr_status']."</td>";
										}
										else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred')
										{
											echo "<td class='center'>".$test['ltr_approval']." to<br>".$dept_to['dept_nm']."</td>";
										}
										else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred_todesk')
										{	
											$todsk=$test['dsk_id_to'];
											$qq=mysql_query("SELECT desk_nm from desk_master where desk_id ='$todsk' ");
											$rr=mysql_fetch_array($qq);
											echo "<td class='center'>transferred to<br>".$rr['desk_nm']."</td>";
										}
										//////////////////////////////////////////
										if ($test['ltr_status']=='updated')
										{
											echo "<td class='center'>".$update_date."</td>";
										}
										else if($test['ltr_status']=='dispatched' )
										{
											echo "<td class='center'>".$dispose_date."</td>";
										}
										echo "</tr>";

									}
					echo"</table></center></div>";	
					
										
				}//if=3					
							
		#########################	End Of Dispatched,Updated Letter report tapal user     #####################
		
		#########################	Approved But Not Worked Letter report tapal user     #############################
			else if($no==4)
			{
	?>		
			
			 <h4 class="widgettitle"><?php echo $desknm['desk_nm']; ?> ने स्वीकृत परंतु कार्यवाही न केलेल्या पत्राचे रिपोर्ट  <h4>
			 
						<form name="sadyasthiti" action="" method="post">
						<div align="center"><br><table align="center" cellpadding="2" cellspacing="0" class='myClass'>
						<table>
							<tr>
							<td><label>तारखेचा प्रकार निवडा  : </label></td>
								<td><span class="field unicode" lang="mr">
										<select name="datetype">
											<option value="">तारखेचा प्रकार निवडा</option>  
											<option value="1">आवक दिनांक</option>
											<option value="2">विभागीय आवक दिनांक</option>
											<option value="3">डेस्क आवक दिनांक</option>
											<option value="4">अपडेट/जावक दिनांक </option>
										</select>
									</span>
								</td>
								<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>
						

						<?php
						convert_marathi();
						$dt_type=$_POST['datetype'];
						//echo "date".$dt_type;
						$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=='' && $dt_type=='')
							{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id = $date1;
								$id1= $date2; 
								
								//not assigned to desk OR assigned to desk but approval is pending
								/*$qry3=mysql_query("SELECT DISTINCT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, i.ltr_type, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de.update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, t.sent_to_desk_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, i.sent_dt, 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 t.dept_id_from='$deptid' 
								AND t.returned_choice='' 
								AND t.dept_id_from='$deptid' 
								AND (t.status='approve' OR t.status='closed') 
								AND (
										(t.desk_id='' OR t.desk_id='0') 
										OR (t.desk_id!='0' AND t.desk_approval='pending')
									)") OR die("aaaa".mysql_error()); */
								
							//desk accepted but not taken any action
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND d.ltr_approval='Approve' 
								AND  d.ltr_status='' ") OR die("abxxba".mysql_error());
							}
						else if($date123!=''&& $date223!='' && $dt_type==1)
							{
								echo '<br><center><h4> <font color="red">आवक दिनांकनुसार संदर्भ </font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
								/*$qry3=mysql_query("SELECT DISTINCT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, i.ltr_type, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de.update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, t.sent_to_desk_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, i.sent_dt, di.dispatched_to, de.ltr_category, de.assign_no FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i 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 t.dept_id_from='$deptid' AND t.returned_choice='' AND t.dept_id_from='$deptid' AND (t.status='approve' OR t.status='closed') AND ((t.desk_id='' OR t.desk_id='0') OR (t.desk_id!='0' AND t.desk_approval='pending')) AND (i.receive_dt BETWEEN '$date1' AND '$date2')") OR die("xaaaa".mysql_error()); */
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND d.ltr_approval='Approve' 
								AND  d.ltr_status=''
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')") OR die("yaaaa".mysql_error());
							}
							
							else if($date123!=''&& $date223!='' && $dt_type==2)
							{
								echo '<br><center><h4> <font color="red">विभागीय आवक दिनांकनुसार संदर्भ</font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
							/*	$qry3=mysql_query("SELECT DISTINCT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, i.ltr_type, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de.update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, t.sent_to_desk_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, i.sent_dt, di.dispatched_to, de.ltr_category, de.assign_no FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i 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 t.dept_id_from='$deptid' AND t.returned_choice='' AND t.dept_id_from='$deptid' AND (t.status='approve' OR t.status='closed') AND ((t.desk_id='' OR t.desk_id='0') OR (t.desk_id!='0' AND t.desk_approval='pending')) AND (t.dpt_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error()); */
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND d.ltr_approval='Approve' 
								AND  d.ltr_status=''
								AND (t.dpt_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("aaxx".mysql_error());
							}
							
							else if($date123!=''&& $date223!='' && $dt_type==3)
							{
								echo '<br><center><h4> <font color="red">डेस्क आवक दिनांकनुसार संदर्भ</font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
							/*	$qry3=mysql_query("SELECT DISTINCT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, i.ltr_type, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de.update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, t.sent_to_desk_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, i.sent_dt, di.dispatched_to, de.ltr_category, de.assign_no FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i 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 t.dept_id_from='$deptid' AND t.returned_choice='' AND t.dept_id_from='$deptid' AND (t.status='approve' OR t.status='closed') AND ((t.desk_id='' OR t.desk_id='0') OR (t.desk_id!='0' AND t.desk_approval='pending')) AND (de.desk_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error()); */
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND d.ltr_approval='Approve' 
								AND  d.ltr_status=''
								AND (d.desk_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error());
							}
						echo"  <br><br><table id='dyntable' class='table table-bordered'>
								<thead>
								<tr>
									<th class='head1 center'>पोलीस अधिक्षक <br> कार्यालय <br>आवक क्रमांक <br>आवक_दिनांक</th>
									<th class='head0 center'>विभागीय आवक क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>डेस्कचा आवक क्र. <br>आवक_दिनांक</th>
									<th class='head0 center'>संदर्भ_क्रमांक <br>संदर्भ दि. </th>
									<th class='head0 center'>विषय</th>
									<th class='head1 center'>कोणाकडून <br>प्राप्त_झाला</th>
									<th class='head0 center'>केलेली कार्यवाही</th>	
								</tr>
								</thead>
							<tbody>";
						/*while($test = mysql_fetch_array($qry3))
						{
								$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['sent_to_desk_dt']));
								$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
								$receive_dt		= date('d-m-Y',strtotime($test['receive_dt']));
								$refdt		= date('d-m-Y',strtotime($test['ref_dt']));
								$update_date 		= date('d-m-Y',strtotime($test['update_date']));
								$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
								$deskid=$test['desk_id'];
			
								echo "<tr class='gradeX'>
									<td class='center'>".$test['ltr_inword_no']."<br>".$receive_dt."</td>
									<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>";
									if($test['desk_id']=='' || $test['desk_id']=='0')
									{
										echo "<td class='center'><font color='red'>डेस्क लावणे बाकी </font></td>";
									}
									else if($test['desk_ltr_inword_no']=='' || $test['desk_ltr_inword_no']=='0')
									{
										echo "<td class='center'><font color='red'>"."डेस्कने स्वीकारणे बाकी "."</font></td>";
									}
									else
									{
										echo "<td class='center'>".$test['desk_ltr_inword_no']."<br>".$desk_ltr_rec_dt."</td>";
									}
									echo "<td class='center'>".$test['ref_no']."<br>".$refdt."</td>
									<td class='center'>".$test['subject']."</font></td>
									<td class='center'>".$test['sender_name']."</font></td>";
									if($test['action_taken']=='' ||$test['action_taken']==0)
									{
										echo"<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
									}
									else if($test['ltr_status']=='' ||$test['ltr_status']==0)
									{
										echo"<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
									}
									else
									{
										echo"<td class='center'>".$test['action_taken']."</td>";
									}
										echo "</tr>";

						} */
						while($test = mysql_fetch_array($qry4))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['sent_to_desk_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
							$receive_dt		= date('d-m-Y',strtotime($test['receive_dt']));
							$refdt		= date('d-m-Y',strtotime($test['ref_dt']));
							$update_date 		= date('d-m-Y',strtotime($test['update_date']));
							$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
							$deskid=$test['desk_id'];
		
							echo "<tr class='gradeX'>
								<td class='center'>".$test['ltr_inword_no']."<br>".$receive_dt."</td>
								<td class='center'>".$test['desk_ltr_inword_no']."<br>".$dept_rec_date."</td>";
								if($test['desk_id']=='' || $test['desk_id']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी </font></td>";
								}
								else if($test['desk_ltr_inword_no']=='' || $test['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>"."डेस्कने स्वीकारणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$test['desk_ltr_inword_no']."<br>".$desk_ltr_rec_dt."</td>";
								}
								echo "<td class='center'>".$test['ref_no']."<br>".$refdt."</td>
								<td class='center'>".$test['subject']."</font></td>
								<td class='center'>".$test['sender_name']."</font></td>";
								if($test['action_taken']=='' ||$test['action_taken']==0)
								{
									echo"<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($test['ltr_status']=='' ||$test['ltr_status']==0)
								{
									echo"<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo"<td class='center'>".$test['action_taken']."</td>";
								}
							
											
										echo "</tr>";
						}
						echo"</tbody></table>";
				
				
				
				echo "<div id='divToPrint' style='display:none;'>
								<center><table id='export' border='1px' style='margin-left:50px;'>
								<tr><td colspan='7'><center>".$desknm['desk_nm']." ने स्वीकृत परंतु कार्यवाही न केलेल्या पत्राचे रिपोर्ट   <br>दिनांक ".$date123." पासून दिनांक ".$date223."</center></td></tr>";
								echo ' <center><h2>पोलीस अधिक्षक <br> कार्यालय कार्यालय <br> तालुका राहुरी जिल्हा अहमदनगर <h2></center>';
						if($date123==''&& $date223=='' && $dt_type=='')
							{
								//echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id = $date1;
								$id1= $date2; 
								
								//not assigned to desk OR assigned to desk but approval is pending
								/*$qry3=mysql_query("SELECT DISTINCT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, i.ltr_type, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de.update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, t.sent_to_desk_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, i.sent_dt, 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 t.dept_id_from='$deptid' 
								AND t.returned_choice='' 
								AND t.dept_id_from='$deptid' 
								AND (t.status='approve' OR t.status='closed') 
								AND (
										(t.desk_id='' OR t.desk_id='0') 
										OR (t.desk_id!='0' AND t.desk_approval='pending')
									)") OR die("aaaa".mysql_error()); */
								
							//desk accepted but not taken any action
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND d.ltr_approval='Approve' 
								AND  d.ltr_status='' ") OR die("abxxba".mysql_error());
							}
						else if($date123!=''&& $date223!='' && $dt_type==1)
							{
								echo "<tr><td colspan='7'><center>आवक दिनांकनुसार संदर्भ </center></td></tr>";
								$id = $date1;
								$id1= $date2; 
								/*$qry3=mysql_query("SELECT DISTINCT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, i.ltr_type, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de.update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, t.sent_to_desk_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, i.sent_dt, di.dispatched_to, de.ltr_category, de.assign_no FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i 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 t.dept_id_from='$deptid' AND t.returned_choice='' AND t.dept_id_from='$deptid' AND (t.status='approve' OR t.status='closed') AND ((t.desk_id='' OR t.desk_id='0') OR (t.desk_id!='0' AND t.desk_approval='pending')) AND (i.receive_dt BETWEEN '$date1' AND '$date2')") OR die("xaaaa".mysql_error()); */
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND d.ltr_approval='Approve' 
								AND  d.ltr_status=''
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')") OR die("yaaaa".mysql_error());
							}
							
							else if($date123!=''&& $date223!='' && $dt_type==2)
							{
								echo "<tr><td colspan='7'><center>विभागीय आवक दिनांकनुसार </center></td></tr>";
								$id = $date1;
								$id1= $date2; 
							/*	$qry3=mysql_query("SELECT DISTINCT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, i.ltr_type, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de.update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, t.sent_to_desk_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, i.sent_dt, di.dispatched_to, de.ltr_category, de.assign_no FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i 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 t.dept_id_from='$deptid' AND t.returned_choice='' AND t.dept_id_from='$deptid' AND (t.status='approve' OR t.status='closed') AND ((t.desk_id='' OR t.desk_id='0') OR (t.desk_id!='0' AND t.desk_approval='pending')) AND (t.dpt_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error()); */
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND d.ltr_approval='Approve' 
								AND  d.ltr_status=''
								AND (t.dpt_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("aaxx".mysql_error());
							}
							
							else if($date123!=''&& $date223!='' && $dt_type==3)
							{
								echo "<tr><td colspan='7'><center>डेस्क आवक दिनांकनुसार </center></td></tr>";
								$id = $date1;
								$id1= $date2; 
							/*	$qry3=mysql_query("SELECT DISTINCT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, i.ltr_type, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de.update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, t.sent_to_desk_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, i.sent_dt, di.dispatched_to, de.ltr_category, de.assign_no FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i 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 t.dept_id_from='$deptid' AND t.returned_choice='' AND t.dept_id_from='$deptid' AND (t.status='approve' OR t.status='closed') AND ((t.desk_id='' OR t.desk_id='0') OR (t.desk_id!='0' AND t.desk_approval='pending')) AND (de.desk_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error()); */
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND d.ltr_approval='Approve' 
								AND  d.ltr_status=''
								AND (d.desk_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error());
							}
						echo "<tr>
								<th>पोलीस अधिक्षक <br> कार्यालय <br>आवक क्रमांक <br>आवक_दिनांक</th>
								<th>विभागीय आवक क्र.<br>आवक_दिनांक</th>
								<th>डेस्क आवक क्र. <br>आवक_दिनांक</th>
								<th>संदर्भ_क्रमांक <br>संदर्भ दि. </th>
								<th>विषय</th>
								<th>कोणाकडून <br>प्राप्त_झाला</th>
								<th>केलेली कार्यवाही</th>
								</tr>";
						/*while($test = mysql_fetch_array($qry3))
						{
								$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['sent_to_desk_dt']));
								$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
								$receive_dt		= date('d-m-Y',strtotime($test['receive_dt']));
								$refdt		= date('d-m-Y',strtotime($test['ref_dt']));
								$update_date 		= date('d-m-Y',strtotime($test['update_date']));
								$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
								$deskid=$test['desk_id'];
			
								echo "<tr>
									<td style='text-align:center;'>".$test['ltr_inword_no']."<br>".$receive_dt."</td>
									<td style='text-align:center;'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>";
									if($test['desk_id']=='' || $test['desk_id']=='0')
									{
										echo "<td style='text-align:center;'>डेस्क लावणे बाकी </font></td>";
									}
									else if($test['desk_ltr_inword_no']=='' || $test['desk_ltr_inword_no']=='0')
									{
										echo "<td style='text-align:center;'><font color='red'>"."डेस्कने स्वीकारणे बाकी "."</font></td>";
									}
									else
									{
										echo "<td style='text-align:center;'>".$test['desk_ltr_inword_no']."<br>".$deskrec_dt."</td>";
									}
									echo "<td style='text-align:center;'>".$test['ref_no']."<br>".$refdt."</td>
									<td style='text-align:center;'>".$test['subject']."</font></td>
									<td style='text-align:center;'>".$test['sender_name']."</font></td>";
									if($test['action_taken']=='' ||$test['action_taken']==0)
									{
										echo"<td style='text-align:center;'>"."कार्यवाही करणे बाकी "."</td>";
									}
									else if($test['ltr_status']=='' ||$test['ltr_status']==0)
									{
										echo"<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
									}
									else
									{
										echo"<td style='text-align:center;'>".$test['action_taken']."</td>";
									}
									
									echo "</tr>";

						} */
						while($test = mysql_fetch_array($qry4))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['sent_to_desk_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
							$receive_dt		= date('d-m-Y',strtotime($test['receive_dt']));
							$refdt		= date('d-m-Y',strtotime($test['ref_dt']));
							$deskid=$test['desk_id'];
		
							echo "<tr>
								<td style='text-align:center;'>".$test['ltr_inword_no']."<br>".$receive_dt."</td>
								<td style='text-align:center;'>".$test['desk_ltr_inword_no']."<br>".$dept_rec_date."</td>";
								if($test['desk_id']=='' || $test['desk_id']=='0')
								{
									echo "<td style='text-align:center;'>डेस्क लावणे बाकी </td>";
								}
								else if($test['desk_ltr_inword_no']=='' || $test['desk_ltr_inword_no']=='0')
								{
									echo "<td style='text-align:center;'>"."डेस्कने स्वीकारणे बाकी "."</td>";
								}
								else
								{
									echo "<td style='text-align:center;'>".$test['desk_ltr_inword_no']."<br>".$deskrec_dt."</td>";
								}
								echo "<td style='text-align:center;'>".$test['ref_no']."<br>".$refdt."</td>
								<td style='text-align:center;'>".$test['subject']."</td>
								<td style='text-align:center;'>".$test['sender_name']."</td>";
								if($test['action_taken']=='' ||$test['action_taken']==0)
								{
									echo"<td style='text-align:center;'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else if($test['ltr_status']=='' ||$test['ltr_status']==0)
								{
									echo"<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo"<td style='text-align:center;'>".$test['action_taken']."</td>";
								}
							echo "</tr>";
						}
				echo"</table></center></div>";
					
		} // else if($no==4)
	###################	End Of Accepted But Not Worked Letter report DEPT user    #############################


	#################################### Total Letter report DEPT user ############################				
				else if($no==5)
				{
					?>		
			
			 <h4 class="widgettitle"><?php echo $desknm['desk_nm']; ?>ला पाठवलेले पत्राचे रिपोर्ट्स  <h4>
			 
						<form name="sadyasthiti" action="" method="post">
						<div align="center"><br><table align="center" cellpadding="2" cellspacing="0" class='myClass'>
						<table>
							<tr>
							<td><label>तारखेचा प्रकार निवडा  : </label></td>
								<td><span class="field unicode" lang="mr">
										<select name="datetype">
											<option value="">तारखेचा प्रकार निवडा</option>  
											<option value="1">आवक दिनांक</option>
											<option value="2">विभागीय आवक दिनांक</option>
											<option value="3">डेस्क आवक दिनांक</option>
											<option value="4">अपडेट/जावक दिनांक </option>
										</select>
									</span>
								</td>
								<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>
						

						<?php
						convert_marathi();
						$dt_type=$_POST['datetype'];
						//echo "".$dt_type;
						$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));
						$id = $date1;
						$id1= $date2;
						
						if($date123==''&& $date223=='' && $dt_type=='')
							{	

								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
								
								//desk not accepted
								$qry3=mysql_query("Select t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document 
								FROM incoming_letters_transaction i LEFT OUTER JOIN  tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id' ") OR die("aaaa".mysql_error());
								
								//desk accepted
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to, di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'") OR die("aabbhhaa".mysql_error());
								
							}
						else if($date123!=''&& $date223!='' && $dt_type==1)
							{
								echo '<br><center><h4> <font color="red">आवक दिनांकनुसार संदर्भ </font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
								$qry3=mysql_query("Select t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document 
								FROM incoming_letters_transaction i LEFT OUTER JOIN  tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id'
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error());
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to, di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')")OR die("agg".mysql_error());
							}
							
							else if($date123!=''&& $date223!='' && $dt_type==2)
							{
								echo '<br><center><h4> <font color="red">विभागीय आवक दिनांकनुसार संदर्भ</font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
								$qry3=mysql_query("Select t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document 
								FROM incoming_letters_transaction i LEFT OUTER JOIN  tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id'  AND (t.dpt_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error());
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to, di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id' AND (t.dpt_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("aaxx".mysql_error());
							}
							
							else if($date123!=''&& $date223!='' && $dt_type==3)
							{
								echo '<br><center><h4> <font color="red">डेस्क आवक दिनांकनुसार संदर्भ</font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
								$qry3=mysql_query("Select t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document 
								FROM incoming_letters_transaction i LEFT OUTER JOIN  tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id' 
								") OR die("aaaa".mysql_error());
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, di.dept_id_to, di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id' AND (d.desk_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("mmm".mysql_error());
							}
							
							else if($date123!=''&& $date223!='' && $dt_type==4)
							{
								echo '<br><center><h4> <font color="red">अपडेट/जावक दिनांकनुसार संदर्भ</font></h4></center><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';$id = $date1;
								$id1= $date2; 
								
								$qry3=mysql_query("Select t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document 
								FROM incoming_letters_transaction i LEFT OUTER JOIN  tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id' ") OR die("aaaa".mysql_error());
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to, di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id' AND ((d.update_date BETWEEN '$date1' AND '$date2') OR (d.dispatched_dt BETWEEN '$date1' AND '$date2')) ") OR die("avc".mysql_error());
							}
						echo"  <br><br><table id='dyntable' class='table table-bordered'>
								<thead>
								<tr>
									<th class='head1 center'>पोलीस अधिक्षक <br> कार्यालय <br>आवक क्रमांक <br>आवक_दिनांक</th>
									<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'>कोणाकडून <br>प्राप्त_झाला</th>
									<th class='head0 center'>केलेली_कार्यवाही</th>
									<th class='head0 center'>पत्राची_स्थिती </th>
									<th class='head1 center'>डेस्क <br>जावक_दिनांक</th>	
								</tr>
								</thead>
							<tbody>";
						
						while($test = mysql_fetch_array($qry3))
						{		
								$ltrinward=$test['ltr_inword_no'];	
								$dept_rec_date 	= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
								$receive_dt	= date('d-m-Y',strtotime($test['receive_dt']));
								$refdt	= date('d-m-Y',strtotime($test['ref_dt']));
								$m=$test['ltr_type'];
								$update_date 		= date('d-m-Y',strtotime($test['update_date']));
								//$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
								$deskid=$test['desk_id'];
							echo "
							<tr class='gradeX'>
							<td class='center'>".$ltrinward."<br>".$receive_dt."</td>";
							if($test['dpt_inword_no']=='')
							{
								echo "<td class='center'><font color='red'>"." विभागाने स्वीकारणे बाकी" ."</font></td>";
							
							}
							else
							{
								echo "<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date ."</td>";
							}
							
							if($test['desk_id']=='' || $test['desk_id']==0)
							{
								echo "<td class='center'><font color='red'>"."डेस्क लावणे बाकी "."</font></td>";
							}
							else if($test['desk_ltr_inword_no']=='' || $test['desk_ltr_inword_no']=='0')
							{
								echo "<td class='center'><font color='red'>"."डेस्कने स्वीकारणे बाकी "."</font></td>";
							}
							else
							{
								echo "<td class='center'>".$test['desk_ltr_inword_no']."<br>".$deskrec_dt."</td>";
							}
							
							echo "<td class='center'>".$test['ref_no']."<br>".$refdt."</td>";
							$ltrtype=mysql_query("select sandharbh_nm FROM sandharbh_master WHERE sandhrbh_id='$m'");
							$s=mysql_fetch_array($ltrtype);
							echo "<td class='center'>".$s['sandharbh_nm']."</td>
							<td class='center'>".$test['subject']."</td>
							<td class='center'>".$test['sender_name']."</td>";
							
							if($test['ltr_status']=='' ||$test['ltr_status']=='NULL')
							{
								echo"<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
							}
							else
							{
								echo"<td class='center'>".$test['action_taken']."</td>";
							}
							
							if($test['ltr_status']=='' || $test['ltr_status']=='NULL')
							{
								echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";	
							}
							else
							{
								echo "<td class='center'>". $test['ltr_status'] ."</td>";
							}
							
							
								echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							
							echo "</tr>";
						}
						
						while($test1 = mysql_fetch_array($qry4))
						{		
								$ltrinward=$test1['ltr_inword_no'];
								$desk_ltr_rec_dt = date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
								$dept_rec_date 	= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
								$receive_dt	= date('d-m-Y',strtotime($test1['receive_dt']));
								$refdt	= date('d-m-Y',strtotime($test1['ref_dt']));
								$deskrec_dt	= date('d-m-Y',strtotime($test1['sent_to_desk_dt']));
								$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
								$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
								$m=$test1['ltr_type'];
								$deskid=$test1['desk_id'];
							echo "
							<tr class='gradeX'>
							<td class='center'>".$ltrinward."<br>".$receive_dt."</td>";
							if($test1['dpt_inword_no']=='')
							{
								echo "<td class='center'><font color='red'>"." विभागाने स्वीकारणे बाकी" ."</font></td>";
							
							}
							else
							{
								echo "<td class='center'>".$test1['dpt_inword_no']."<br>".$dept_rec_date ."</td>";
							}
							if($test1['desk_id']=='' || $test1['desk_id']==0)
							{
								echo "<td class='center'><font color='red'>"."डेस्क लावणे बाकी "."</font></td>";
							}
							else if($test1['desk_ltr_inword_no']=='' || $test1['desk_ltr_inword_no']=='0')
							{
								echo "<td class='center'><font color='red'>"."डेस्कने स्वीकारणे बाकी "."</font></td>";
							}
							else
							{
								echo "<td class='center'>".$test1['desk_ltr_inword_no']."<br>".$deskrec_dt."</td>";
							}
							echo "<td class='center'>".$test1['ref_no']."<br>".$refdt."</td>";
							$ltrtype=mysql_query("select sandharbh_nm FROM sandharbh_master WHERE sandhrbh_id='$m'");
							$s=mysql_fetch_array($ltrtype);
							echo "<td class='center'>".$s['sandharbh_nm']."</td>
							<td class='center'>".$test1['subject']."</td>
							<td class='center'>".$test1['sender_name']."</td>";
							////////////////////////////////////////////////////////////////////
							if($test1['ltr_status']=='' ||$test1['ltr_status']=='NULL')
							{
								echo"<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
							}
							else if($test1['ltr_status']=='closed'  )
							{
								echo "<td class='center'> -- </td>";	
							}
							else
							{
								echo"<td class='center'>".$test1['action_taken']."</td>";
							}
							///////////////////////////////////////////////////////////////////////
							if($test1['ltr_status']=='' || $test1['ltr_status']=='NULL')
							{
								echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";	
							}
							else if($test1['ltr_status']=='dispatched' && $test1['ltr_approval']=='transferred')
							{
								$todpt=$test1['dept_id_to'];
								$qq=mysql_query("SELECT dept_nm from department_master where dept_id='$todpt' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>transferred to<br>".$rr['dept_nm']."</td>";
							}
							else if($test1['ltr_status']=='dispatched' && $test1['ltr_approval']=='transferred_todesk')
							{
								$todsk=$test1['dsk_id_to'];
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								
								echo "<td class='center'>transferred to<br>".$rr['desk_nm']."</td>";
							}
							else if($test1['ltr_status']=='dispatched' && $test1['ltr_approval']=='Approve')
							{
								echo "<td class='center'>". $test1['ltr_status'] ."</td>";
							}
							else
							{
								echo "<td class='center'>". $test1['ltr_status'] ."</td>";
							}
							///////////////////////////////////////////////////////////////
							if ($test1['ltr_status']=='updated')
							{
								echo "<td class='center'>".$update_date."</td>";
							}
							else if($test1['ltr_status']=='dispatched')
							{
								echo "<td class='center'>".$dispose_date."</td>";
							}
							else if($test1['ltr_status']=='closed'  )
							{
								echo "<td class='center'> -- </td>";	
							}
							else 
							{
								echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
											
										echo "</tr>";
						}	
							   
					echo "</tbody></table>";	
						
							
					
						echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='10'><center>". $desknm['desk_nm']."ला पाठवलेले पत्राचे रिपोर्ट्स  <br>दिनांक ".$date123." पासून दिनांक ".$date223."</center></td></tr>";
							echo ' <center><h2>पोलीस अधिक्षक <br> कार्यालय कार्यालय <br> तालुका राहुरी जिल्हा अहमदनगर <h2></center>';
						$id1= $date2;
						
					if($date123==''&& $date223=='' && $dt_type=='')
							{	
								$id = $date1;
								$id1= $date2; 
								
								//desk not accepted
								$qry3=mysql_query("Select t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document 
								FROM incoming_letters_transaction i LEFT OUTER JOIN  tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id' ") OR die("aaaa".mysql_error());
								
								//desk accepted
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to, di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'") OR die("aabbhhaa".mysql_error());
							}
						else if($date123!=''&& $date223!='' && $dt_type==1)
							{
								echo "<tr><td colspan='10'><center>आवक दिनांकनुसार संदर्भ </center></td></tr>";
								
								$id = $date1;
								$id1= $date2; 
								$qry3=mysql_query("Select t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document 
								FROM incoming_letters_transaction i LEFT OUTER JOIN  tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id'
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error());
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to, di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id'
								AND (i.receive_dt BETWEEN '$date1' AND '$date2')")OR die("agg".mysql_error());
							}
							
							else if($date123!=''&& $date223!='' && $dt_type==2)
							{
								echo "<tr><td colspan='10'><center>विभागीय आवक दिनांकनुसार  </center></td></tr>";
								
								$id = $date1;
								$id1= $date2; 
								$qry3=mysql_query("Select t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document 
								FROM incoming_letters_transaction i LEFT OUTER JOIN  tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id'  AND (t.dpt_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("aaaa".mysql_error());
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to, di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id' AND (t.dpt_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("aaxx".mysql_error());
							}
							
							else if($date123!=''&& $date223!='' && $dt_type==3)
							{
								echo "<tr><td colspan='10'><center>डेस्क आवक दिनांकनुसार  </center></td></tr>";
								$id = $date1;
								$id1= $date2; 
								$qry3=mysql_query("Select t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document 
								FROM incoming_letters_transaction i LEFT OUTER JOIN  tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id' 
								") OR die("aaaa".mysql_error());
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to,di.dept_id_to, di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id' AND (d.desk_ltr_rec_dt BETWEEN '$date1' AND '$date2')") OR die("mmm".mysql_error());
							}
							
							else if($date123!=''&& $date223!='' && $dt_type==4)
							{
								echo "<tr><td colspan='10'><center>अपडेट/जावक दिनांकनुसार </center></td></tr>";
								$id = $date1;
								$id1= $date2; 
								
								$qry3=mysql_query("Select t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document 
								FROM incoming_letters_transaction i LEFT OUTER JOIN  tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE t.desk_approval='pending'
								AND t.desk_id='$desk_id' ") OR die("aaaa".mysql_error());
							
								$qry4=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, di.dept_id_to, di.dsk_id_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE d.desk_id_from='$desk_id' AND ((d.update_date BETWEEN '$date1' AND '$date2') OR (d.dispatched_dt BETWEEN '$date1' AND '$date2')) ") OR die("avc".mysql_error());
							}
						
						echo"<tr>
									<th class='head1 center'>पोलीस अधिक्षक <br> कार्यालय <br>आवक क्रमांक <br>आवक_दिनांक</th>
									<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'>कोणाकडून <br>प्राप्त_झाला</th>
									<th class='head0 center'>केलेली_कार्यवाही</th>
									<th class='head0 center'>पत्राची_स्थिती </th>
									<th class='head1 center'>डेस्क <br>जावक_दिनांक</th>	
								</tr>";
						echo "</tr>";
						while($test = mysql_fetch_array($qry3))
						{		
								$ltrinward=$test['ltr_inword_no'];	
								$dept_rec_date 	= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
								$receive_dt	= date('d-m-Y',strtotime($test['receive_dt']));
								$refdt	= date('d-m-Y',strtotime($test['ref_dt']));
								$m=$test['ltr_type'];
								$update_date 		= date('d-m-Y',strtotime($test['update_date']));
								//$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
								$deskid=$test['desk_id'];
							echo "
							<tr class='gradeX'>
							<td class='center'>".$ltrinward."<br>".$receive_dt."</td>";
							if($test['dpt_inword_no']=='')
							{
								echo "<td class='center'>"." विभागाने स्वीकारणे बाकी" ."</td>";
							
							}
							else
							{
								echo "<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date ."</td>";
							}
							
							if($test['desk_id']=='' || $test['desk_id']==0)
							{
								echo "<td class='center'>"."डेस्क लावणे बाकी "."</td>";
							}
							else if($test['desk_ltr_inword_no']=='' || $test['desk_ltr_inword_no']=='0')
							{
								echo "<td class='center'>"."डेस्कने स्वीकारणे बाकी "."</td>";
							}
							else
							{
								echo "<td class='center'>".$test['desk_ltr_inword_no']."<br>".$deskrec_dt."</td>";
							}
							
							echo "<td class='center'>".$test['ref_no']."<br>".$refdt."</td>";
							$ltrtype=mysql_query("select sandharbh_nm FROM sandharbh_master WHERE sandhrbh_id='$m'");
							$s=mysql_fetch_array($ltrtype);
							echo "<td class='center'>".$s['sandharbh_nm']."</td>
							<td class='center'>".$test['subject']."</td>
							<td class='center'>".$test['sender_name']."</td>";
							
							if($test['ltr_status']=='' ||$test['ltr_status']=='NULL')
							{
								echo"<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
							}
							else
							{
								echo"<td class='center'>".$test['action_taken']."</td>";
							}
							
							if($test['ltr_status']=='' || $test['ltr_status']=='NULL')
							{
								echo "<td class='center'> कार्यवाही करणे बाकी </td>";	
							}
							else
							{
								echo "<td class='center'>". $test['ltr_status'] ."</td>";
							}
							
							
								echo "<td class='center'> कार्यवाही करणे बाकी </td>";
							
							echo "</tr>";
						}
						
						while($test1 = mysql_fetch_array($qry4))
						{		
								$ltrinward=$test1['ltr_inword_no'];
								$desk_ltr_rec_dt = date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
								$dept_rec_date 	= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
								$receive_dt	= date('d-m-Y',strtotime($test1['receive_dt']));
								$refdt	= date('d-m-Y',strtotime($test1['ref_dt']));
								$deskrec_dt	= date('d-m-Y',strtotime($test1['sent_to_desk_dt']));
								$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
								$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
								$m=$test1['ltr_type'];
								$deskid=$test1['desk_id'];
							echo "
							<tr class='gradeX'>
							<td class='center'>".$ltrinward."<br>".$receive_dt."</td>";
							if($test1['dpt_inword_no']=='')
							{
								echo "<td class='center'>"." विभागाने स्वीकारणे बाकी" ."</td>";
							
							}
							else
							{
								echo "<td class='center'>".$test1['dpt_inword_no']."<br>".$dept_rec_date ."</td>";
							}
							if($test1['desk_id']=='' || $test1['desk_id']==0)
							{
								echo "<td class='center'>"."डेस्क लावणे बाकी "."</td>";
							}
							else if($test1['desk_ltr_inword_no']=='' || $test1['desk_ltr_inword_no']=='0')
							{
								echo "<td class='center'>"."डेस्कने स्वीकारणे बाकी "."</td>";
							}
							else
							{
								echo "<td class='center'>".$test1['desk_ltr_inword_no']."<br>".$deskrec_dt."</td>";
							}
							echo "<td class='center'>".$test1['ref_no']."<br>".$refdt."</td>";
							$ltrtype=mysql_query("select sandharbh_nm FROM sandharbh_master WHERE sandhrbh_id='$m'");
							$s=mysql_fetch_array($ltrtype);
							echo "<td class='center'>".$s['sandharbh_nm']."</td>
							<td class='center'>".$test1['subject']."</td>
							<td class='center'>".$test1['sender_name']."</td>";
							////////////////////////////////////////////////////////////////////
							if($test1['ltr_status']=='' ||$test1['ltr_status']=='NULL')
							{
								echo"<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
							}
							else if($test1['ltr_status']=='closed'  )
							{
								echo "<td class='center'> -- </td>";	
							}
							else
							{
								echo"<td class='center'>".$test1['action_taken']."</td>";
							}
							///////////////////////////////////////////////////////////////////////
							if($test1['ltr_status']=='' || $test1['ltr_status']=='NULL')
							{
								echo "<td class='center'> कार्यवाही करणे बाकी </td>";	
							}
							else
							{
								echo "<td class='center'>". $test1['ltr_status'] ."</td>";
							}
							///////////////////////////////////////////////////////////////
							if ($test1['ltr_status']=='updated')
							{
								echo "<td class='center'>".$update_date."</td>";
							}
							else if($test1['ltr_status']=='dispatched')
							{
								echo "<td class='center'>".$dispose_date."</td>";
							}
							else if($test1['ltr_status']=='closed'  )
							{
								echo "<td class='center'> -- </td>";	
							}
							else 
							{
								echo "<td class='center'> कार्यवाही करणे बाकी </td>";
							}
											
										echo "</tr>";
						}	
						
					echo"</table></center></div>";							
					
				}//if=5	
			######################### End OF Total Letter report tapal user #######################	
			
			############################## Returned Letter Report ##############################
				else if($no==6)
				{
						?>		
			
					<h4 class="widgettitle"><?php echo $desknm['desk_nm']; ?>रिटर्न केलेले पत्र रिपोर्ट्स  <h4>
					
				<form>
					

						<?php
						
						/*******************************************************************************
										Returned Letter
						****************************************************************************/		
						 
							$qry1=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
									LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
							WHERE d.desk_id_from='$desk_id'
							AND (
									(d.ltr_status='closed') OR ( t.desk_approval='returned')
								) ") OR die("aaaa".mysql_error());
							
						$cnt=mysql_num_rows($qry1);
							echo" <br><br><table id='dyntable' class='table table-bordered'>
									<thead>
										<tr>
											<th class='head1 center'>पोलीस अधिक्षक <br> कार्यालय <br>आवक क्रमांक <br>आवक_दिनांक</th>
											<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'>कोणाकडून <br>प्राप्त_झाला</th>";
											//echo "<th class='head0 center'>केलेली कार्यवाही</th>";
								echo "</tr></thead>";
						
							
						while($test = mysql_fetch_array($qry1))
						{		
								$ltrinward=$test['ltr_inword_no'];
								$desk_ltr_rec_dt = date('d-m-Y',strtotime($test['desk_approval']));
								$dept_rec_date 	= date('d-m-Y',strtotime($test['sent_dt']));
								$receive_dt	= date('d-m-Y',strtotime($test['receive_dt']));
								$refdt	= date('d-m-Y',strtotime($test['ref_dt']));
								$deskrec_dt	= date('d-m-Y',strtotime($test['sent_to_desk_dt']));
								$m=$test['ltr_type'];
								$deskid=$test['desk_id'];
			
							echo "<tbody>
							<tr class='gradeX'>
							<td class='center'>".$ltrinward."<br>".$receive_dt."</td>";
							if($test['dpt_inword_no']=='')
							{
								echo "<td class='center'><font color=red>"." विभागाने स्वीकारणे बाकी" ."</font></td>";	
							}
							else
							{
								echo "<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date ."</td>";
							}
							if($test['desk_ltr_inword_no']=='' || $test['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>"."डेस्कने स्वीकारणे बाकी "."</font></td>";
								}
							else
								{
									echo "<td class='center'>".$test['desk_ltr_inword_no']."<br>".$deskrec_dt."</td>";
								}
							echo "<td class='center'>".$test['ref_no']."<br>".$refdt."</td>";
							$ltrtype=mysql_query("select sandharbh_nm FROM sandharbh_master WHERE sandhrbh_id='$m'");
							$s=mysql_fetch_array($ltrtype);
							echo "<td class='center'>".$s['sandharbh_nm']."</td>
							<td class='center'>".$test['subject']."</td>
							<td class='center'>".$test['sender_name']."</td>";
						/*	if($test['action_taken']=='')
							{
								echo "<td class='center'><font color='red'>". "कार्यवाही करणे बाकी "."</font></td></tr>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td></tr>";	
							} */

						}
						
					echo"</table>";		
						echo "<div id='divToPrint' style='display:none;'>
								<center><table id='export' border='1px' style='margin-left:50px;'>
								<tr><td colspan='8'><center>".$desknm['desk_nm']." रिटर्न केलेले पत्र रिपोर्ट्स</h4></center></td></tr>";
							//	echo '<tr><td colspan="8"><center>दिनांक '.$date123.''.' पासून दिनांक '.''.$date223.' </center></tr>';
							echo ' <center><h2>पोलीस अधिक्षक <br> कार्यालय कार्यालय <br> तालुका राहुरी जिल्हा अहमदनगर <h2></center>';
								$id = $date1;
								
						/*******************************************************************************
										Returned Letter
						****************************************************************************/
						$qry1=mysql_query("Select d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d.update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status,i.ltr_type, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
									LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
							WHERE d.desk_id_from='$desk_id'
							AND (
									(d.ltr_status='closed') OR ( t.desk_approval='returned')
								) ") OR die("aaaa".mysql_error());
						
						$cnt=mysql_num_rows($qry1);
							echo " 	<tr>
									<th>पोलीस अधिक्षक <br> कार्यालय <br>आवक_क्रमांक <br>आवक_दिनांक</th>
									<th>विभागीय आवक_क्र.<br>आवक_दिनांक</th>
									<th>डेस्क आवक_क्र. <br>आवक_दिनांक</th>
									<th>संदर्भ_क्रमांक <br>संदर्भ दि. </th>
									<th>संदर्भाचा प्रकार</th>
									<th>विषय</th>
									<th>कोणाकडून <br>प्राप्त_झाला</th>";
									//echo "<th>केलेली कार्यवाही</th>";
									 echo "</tr>";
							while($test = mysql_fetch_array($qry1))
							{		
								$ltrinward=$test['ltr_inword_no'];
								$desk_ltr_rec_dt = date('d-m-Y',strtotime($test['desk_approval']));
								$dept_rec_date 	= date('d-m-Y',strtotime($test['sent_dt']));
								$receive_dt	= date('d-m-Y',strtotime($test['receive_dt']));
								$refdt	= date('d-m-Y',strtotime($test['ref_dt']));
								$deskrec_dt	= date('d-m-Y',strtotime($test['sent_to_desk_dt']));
								$m=$test['ltr_type'];
								$deskid=$test['desk_id'];
			
							echo "<tr>
							<td style='text-align:center;'>".$ltrinward."<br>".$receive_dt."</td>";
							if($test['dpt_inword_no']=='')
							{
								echo "<td style='text-align:center;'>"." विभागाने स्वीकारणे बाकी" ."</font></td>";
							}
							else
							{
							echo "<td style='text-align:center;'>".$test['dpt_inword_no']."<br>".$dept_rec_date ."</td>";
							}
							if($test['desk_ltr_inword_no']=='' || $test['desk_ltr_inword_no']=='0')
								{
								echo "<td style='text-align:center;'><font>"."डेस्कने स्वीकारणे बाकी "."</font></td>";
								}
								else
								{
								echo "<td style='text-align:center;'>".$test['desk_ltr_inword_no']."<br>".$deskrec_dt."</td>";
								}
							echo "<td style='text-align:center;'>".$test['ref_no']."<br>".$refdt."</td>";
							$ltrtype=mysql_query("select sandharbh_nm FROM sandharbh_master WHERE sandhrbh_id='$m'");
							$s=mysql_fetch_array($ltrtype);
							echo "<td style='text-align:center;'>".$s['sandharbh_nm']."</td>
							<td style='text-align:center;'>".$test['subject']."</td>
							<td style='text-align:center;'>".$test['sender_name']."</td>";
						/*	if($test['action_taken']=='')
							{
								echo "<td style='text-align:center;'>". "कार्यवाही करणे बाकी "."</td></tr>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test['action_taken']."</td></tr>";	
							} */
						}
						
					echo"</table></center></div>";								
					
				}//if=2									
						    		
            //if user tapal
######################## End Of Returned Letter Report ##############################   
		   ?>
                <br /><br />
                
               <p>	
				<center><input type="button" 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></div>
			</form>
                
                <?php include_once('footer.php');
				?>
            
            </div><!--maincontentinner-->
        </div><!--maincontent-->
        
    </div><!--rightpanel-->
    
</div><!--mainwrapper-->
</body>
</html>