 <!DOCTYPE html>
<?php 
$flag=$_REQUEST['flag'];

if($flag=='')
{
include('dashboard_department.php');
require_once('convert_marathi.php');
$username = $_SESSION['User_Name'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="text/javascript">     
       function PrintDiv() {    
           var divToPrint = document.getElementById('divToPrint');
           var popupWin = window.open('', '_blank', 'width=600,height=600');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
</script>
<script src="tableToExcel.js"></script>
</head>
<body>
<div class="mainwrapper">   
    <div class="rightpanel">
            <ul class="breadcrumbs">
				<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
				<li><a href="">Tables</a> <span class="separator"></span></li>
				<li>गोषवारा </li>
			</ul>
			<div class="pageheader">
				<div class="pageicon"><span class="iconfa-table"></span></div>
				<div class="pagetitle">
					<h5>Tables</h5>
					<?php
					$qp=mysql_query("Select dept_nm from department_master WHERE dept_id=(select dept_id from login where login_id='$username')");
					$rp=mysql_fetch_array($qp);
					?>
					<h1>गोषवारा  <?php echo $rp['dept_nm'];?></h1>
				</div>
			</div><!--pageheader-->
			<div class="maincontent">
				<div class="maincontentinner">
						<h4 class="widgettitle">गोषवारा <?php echo $rp['dept_nm'];?></h4>
						<?php
						$no = $_REQUEST['no'];
						########################### Pending References ####################################
						if($no == '01')
						{			
							echo'<br><br><p align="center"><font size="5" color="#00a0ee">मागील शिल्लक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							//echo $id;
							$id1 =$_REQUEST['end_date'];
							//echo $id1;
							$no = $_REQUEST['no'];
							//echo $no;
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5" color="#59c600">'.$from_date.'</font> ते <font size="5" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
							$date = date_create($from_date);
							date_modify($date, '-23 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
			
					// dept accepted,desk accepted////////////////////
					$result = 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.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 t.dpt_ltr_rec_dt < '$id' 
					AND d.ltr_status=''
					AND t.returned_choice=''
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')") or die("cccc".mysql_error());
							
					// dept accepted,desk not accepted///////////////////
					$result1 = 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.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 t.dpt_ltr_rec_dt < '$id' 
					AND t.desk_approval='pending' 
					AND t.returned_choice=''
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')") or die("cccc1".mysql_error());	
					
					//dept accepted, not assigned desk//////////////////////
					$result2 = 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.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 t.dpt_ltr_rec_dt < '$id' 
					AND t.desk_id='0' AND t.returned_choice=''
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')") or die("cccc1".mysql_error());
					
				/*	//dept not accepted///////////////////////////
					$result3 = 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.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 i.status='pending' AND i.sent_dt< '$id'
					AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
					
					echo"<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
									<tr>	
									<th class='head0 center'>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
									<th class='head0 center'>केलेली <br>कार्यवाही </th>
									<th class='head1 center'>पत्राची स्थिती </th>
									<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
						</tr>
								</thead>";
							while($rws = mysql_fetch_array($result))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result1))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result2))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							}
							//mysql_close();
						/*	while($rws = mysql_fetch_array($result3))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table>";
							
							
							################################ div to Print ###############################
						echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $rp['dept_nm']. "गोषवारा </h4></center></td></tr>";	
							echo ' <center><h2><font color="black">पोलीस अधीक्षक कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">मागील शिल्लक संदर्भ - ';
							
							
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							//echo $id;
							$id1 =$_REQUEST['end_date'];
							//echo $id1;
							$no = $_REQUEST['no'];
							//echo $no;
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="3">'.$from_date.'</font> ते <font size="3">'.$to_date.'</font></font></center></td></tr>';
							$date = date_create($from_date);
							date_modify($date, '-23 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
			
							// dept accepted,desk accepted////////////////////
					$result = 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.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 t.dpt_ltr_rec_dt < '$id' 
					AND d.ltr_status=''
					AND t.returned_choice=''
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')") or die("cccc".mysql_error());
							
					// dept accepted,desk not accepted///////////////////
					$result1 = 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.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 t.dpt_ltr_rec_dt < '$id' 
					AND t.desk_approval='pending' 
					AND t.returned_choice=''
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')") or die("cccc1".mysql_error());	
					
					//dept accepted, not assigned desk//////////////////////
					$result2 = 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.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 t.dpt_ltr_rec_dt < '$id' 
					AND t.desk_id='0'
					AND t.returned_choice=''
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')") or die("cccc1".mysql_error());
					
					/* //dept not accepted///////////////////////////
					$result3 = 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.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 i.status='pending' AND i.sent_dt< '$id'
					AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
					
								echo"<br><br>";
								echo "<tr>	
										<th>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                         
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>";	
							while($rws = mysql_fetch_array($result))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'>डेस्क लावणे बाकी </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी</td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी</td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result1))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'>डेस्कने स्वीकारणे बाकी </td>";
								
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
							
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								echo "</tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result2))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'>डेस्क लावणे बाकी </td>";
								
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
							
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								echo "</tr>";
							}
							//mysql_close();
							/* while($rws = mysql_fetch_array($result3))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'>डेस्क लावणे बाकी </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
							
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								echo "</tr>";
							} */
							//mysql_close();
						echo"</table></center>
						</div>";
						}
						
						
						#######################################################################################
						########################### Letters In Current Week ####################################
						else if($no == '02')
						{
							echo'<br><br><p align="center"><font size="5" color="#00a0ee">चालू आठवड्यातील आवक संदर्भ - ';
			
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							//echo $id;
							$id1 =$_REQUEST['end_date'];
							//echo $id1;
							$no = $_REQUEST['no'];
							//echo $no;
							//$result222=mysql_query("SELECT * FROM avak_nondvahi WHERE dept_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$id' AND type_of_doc=''");
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5" color="#59c600">'.$from_date.'</font> ते <font size="5" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
							
							////// accepted by dept but not assignd desk or desk apprval=pending
							$result222=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,di.dept_id_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, 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 (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1') 
							AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')
							AND (t.desk_id='0' OR t.desk_approval='pending')
							AND t.returned_choice=''
							ORDER BY i.ltr_inword_no") or die("eeee".mysql_error());
							
							//////desk accpted lttrs except returned lettrs
							$result2221=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,di.dept_id_to, di.dsk_id_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, 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 (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1') 
							AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')
							AND d.ltr_status!='closed' AND d.ltr_approval!='transferred_todesk'
							AND t.returned_choice=''
							ORDER BY i.ltr_inword_no") or die("eeee".mysql_error());
							
						/*	/////not accepted by dept//////
							$result22211 = mysql_query("SELECT i.subject,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
							WHERE i.status='pending' AND (i.sent_dt BETWEEN '$id' AND '$id1')
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
							echo"<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
									<tr>	
									<th class='head0 center'>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
									<th class='head0 center'>केलेली <br>कार्यवाही </th>
									<th class='head1 center'>पत्राची स्थिती </th>
									<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव <br> जावक_दिनांक</th>
						</tr>
								</thead>";
							while($rws = mysql_fetch_array($result222))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
								echo "</tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result2221))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$transfer=$rws['dept_id_to'];
								
								$updatedt=$rws['update_date'];
								$dispatcheddt=$rws['dispatched_dt'];
								if($transfer!='0')
								{
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$transfer' ");
									$r=mysql_fetch_array($q);
									$transfer_nm=$r['dept_nm'];
								}
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								$todsk=$rws['dsk_id_to'];
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']." to <br>".$transfer_nm."</td>";
								}
								else if($rws['ltr_approval']=='transferred_todesk')
								{
								
									echo "<td class='center'>transferred to <br>".$rr['desk_nm']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."अपडेट केले".$updatedt."</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to'].$transfer_nm.$rr['desk_nm']."<br>".$dispatcheddt."</td>";
								}
								echo "</tr>";
							}
							//mysql_close();
						/*	while($rws = mysql_fetch_array($result22211))
							{
								$ltrid=$rws['ltr_id'];
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								
								echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table>";
							
							######################################## Div To Print ########################
							
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $rp['dept_nm']. "गोषवारा </h4></center></td></tr>";	
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">चालू आठवड्यातील आवक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							//echo $id;
							$id1 =$_REQUEST['end_date'];
							//echo $id1;
							$no = $_REQUEST['no'];
							//echo $no;
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="3">'.$from_date.'</font> ते <font size="3">'.$to_date.'</font></font></center></td></tr>';
							$date = date_create($from_date);
							date_modify($date, '-23 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
	
							////// accepted by dept but not assignd desk or desk apprval=pending
							$result222=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,di.dept_id_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, 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 (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1') 
							AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')
							AND (t.desk_id='0' OR t.desk_approval='pending')
							AND t.returned_choice=''
							ORDER BY i.ltr_inword_no") or die("eeee".mysql_error());
							
							//////desk accpted lttrs except returned lettrs
							$result2221=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,di.dept_id_to, di.dsk_id_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, 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 (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1') 
							AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')
							AND d.ltr_status!='closed' AND d.ltr_approval!='transferred_todesk'
							AND t.returned_choice=''
							ORDER BY i.ltr_inword_no") or die("eeee".mysql_error());
							
						/*	/////not accepted by dept//////
							$result22211 = mysql_query("SELECT i.subject,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
							WHERE i.status='pending' AND (i.sent_dt BETWEEN '$id' AND '$id1')
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
								echo"<br><br>";
								echo "<tr>	
										<th>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
										<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
										<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th>कोणाकडून_प्राप्त<br>विषय </th>                          
										<th>केलेली <br>कार्यवाही </th>
										<th>पत्राची स्थिती </th>
										<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>";	
							while($rws = mysql_fetch_array($result222))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td style='text-align:center;'>डेस्क लावणे बाकी</td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td style='text-align:center;'>डेस्कने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td style='text-align:center;'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td style='text-align:center;'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td style='text-align:center;'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td style='text-align:center;'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td style='text-align:center;'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td style='text-align:center;'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td style='text-align:center;'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else
								{
									echo "<td style='text-align:center;'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td style='text-align:center;'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td style='text-align:center;'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td style='text-align:center;'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td style='text-align:center;'>"."कार्यवाही करणे बाकी"."</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td style='text-align:center;'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							while($rws = mysql_fetch_array($result2221))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$transfer=$rws['dept_id_to'];
								
								$updatedt=$rws['update_date'];
								$dispatcheddt=$rws['dispatched_dt'];
								if($transfer!='0')
								{
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$transfer' ");
									$r=mysql_fetch_array($q);
									$transfer_nm1=$r['dept_nm'];
								}
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'>डेस्क लावणे बाकी </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								$todsk=$rws['dsk_id_to'];
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']." to <br>".$transfer_nm1."</td>";
								}
								else if($rws['ltr_approval']=='transferred_todesk')
								{
								
									echo "<td class='center'>transferred to <br>".$rr['desk_nm']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."अपडेट केले".$updatedt."</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to'].$transfer_nm1.$rr['desk_nm']."<br>".$dispatcheddt."</td>";
								}
								echo "</tr>";
							}
							//mysql_close();
						/*	while($rws = mysql_fetch_array($result22211))
							{
								$ltrid=$rws['ltr_id'];
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								
								echo "<td class='center'> डेस्क लावणे बाकी </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table></center>
							</div>";
							
						}
						################################################################################
						########################### Total References ####################################
						else if($no == '03')
						{
							echo'<br><br><p align="center"><font size="5" color="#00a0ee">एकूण संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
							
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5" color="#59c600">'.$from_date.'</font> ते <font size="5" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
						///////////pending////////////////
							// dept accepted,desk accepted////////////////////
					$result = 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.desk_approval, 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.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 t.dpt_ltr_rec_dt < '$id' 
					AND d.ltr_status=''
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')") or die("cccc".mysql_error());
					
					// dept accepted,desk not accepted///////////////////
					$result1 = 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_approval, 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.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 t.dpt_ltr_rec_dt < '$id' 
					AND (t.desk_id='0' OR t.desk_approval='pending')
					AND t.returned_choice=''
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')") or die("cccc1".mysql_error());	
					
					/* //dept not accepted///////////////////////////
					$result3 = 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_approval, 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.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 i.status='pending' AND i.sent_dt < '$id'
					AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
						
					////////////////current/////////////////
						/////dept accpted but not assigned desk or desk not accepted
					$result222=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_approval, 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.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 (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1')
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username') 
					AND t.returned_choice=''
					AND (t.desk_id='0' OR t.desk_approval='pending' )
					ORDER BY i.ltr_inword_no") or die("eeee".mysql_error());
					
					///////////desk accpted lettrs except returned letters
					$result2221=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_approval, 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.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no,di.dsk_id_to, di.dispatched_to,di.dept_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 (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1')
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username') 
					AND d.ltr_status!='closed' AND d.ltr_approval!='transferred_todesk'
					ORDER BY i.ltr_inword_no") or die("eeee".mysql_error());
					
				/*	/////not accepted by dept//////
					$result22211 = mysql_query("SELECT i.subject,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
					WHERE i.status='pending' AND (i.sent_dt BETWEEN '$id' AND '$id1')
					AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
					
						echo "<br><br><table id='dyntable' class='table table-bordered'>";
							echo "<thead>
									<tr>	
									<th class='head0 center'>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
									<th class='head0 center'>केलेली <br>कार्यवाही </th>
									<th class='head1 center'>पत्राची स्थिती </th>
									<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>
								</thead>";
							while($rws = mysql_fetch_array($result))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result1))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$dskid=$rws['desk_id'];
								$dskapprval=$rws['desk_approval'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($dskid=='0')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($dskapprval=='pending')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							}
							//mysql_close();
						/*	while($rws = mysql_fetch_array($result3))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							} */
							//mysql_close();
							while($rws = mysql_fetch_array($result222))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
								echo "</tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result2221))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								$transferto=$rws['dept_id_to'];
								$q=mysql_query("SELECT dept_nm from department_master where dept_id='$transferto' ");
								$r=mysql_fetch_array($q);
								$transfer_nm=$r['dept_nm'];
								
								$todsk=$rws['dsk_id_to'];
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']." to <br>".$transfer_nm."
									</td>";
								}
								else if($rws['ltr_approval']=='transferred_todesk')
								{
									echo "<td class='center'>transferred to <br>".$rr['desk_nm']."
									</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to'].$transfer_nm.$rr['desk_nm']."</td>";
								}
								echo "</tr>";
							}
							//mysql_close();
						/*	while($rws = mysql_fetch_array($result22211))
							{
								$ltrid=$rws['ltr_id'];
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								
								echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table>";
							
							###################################### Div TO Print ###########################
							
							echo
							"<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $rp['dept_nm']. "गोषवारा </h4></center></td></tr>";	
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">एकूण संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];		
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5" >'.$from_date.'</font> ते <font size="5" >'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
					
						///////////pending////////////////
							// dept accepted,desk accepted////////////////////
					$result = 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.desk_approval, 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.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 t.dpt_ltr_rec_dt < '$id' 
					AND d.ltr_status=''
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')") or die("cccc".mysql_error());
					
					// dept accepted,desk not accepted///////////////////
					$result1 = 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_approval, 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.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 t.dpt_ltr_rec_dt < '$id' 
					AND (t.desk_id='0' OR t.desk_approval='pending')
					AND t.returned_choice=''
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')") or die("cccc1".mysql_error());	
					
				/*	//dept not accepted///////////////////////////
					$result3 = 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_approval, 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.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 i.status='pending' AND i.sent_dt < '$id'
					AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
						
					////////////////current/////////////////
						/////dept accpted but not assigned desk or desk not accepted
					$result222=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_approval, 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.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 (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1')
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username') 
					AND t.returned_choice=''
					AND (t.desk_id='0' OR t.desk_approval='pending' )
					ORDER BY i.ltr_inword_no") or die("eeee".mysql_error());
					
					///////////desk accpted lettrs except returned letters
					$result2221=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_approval, 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.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no,di.dsk_id_to, di.dispatched_to,di.dept_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 (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1')
					AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username') 
					AND d.ltr_status!='closed' AND d.ltr_approval!='transferred_todesk'
					ORDER BY i.ltr_inword_no") or die("eeee".mysql_error());
					
					/* /////not accepted by dept//////
					$result22211 = mysql_query("SELECT i.subject,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
					WHERE i.status='pending' AND (i.sent_dt BETWEEN '$id' AND '$id1')
					AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
					
							echo "<br><br>";
							echo "<tr>	
									<th>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                          
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>";
							while($rws = mysql_fetch_array($result))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'>डेस्क लावणे बाकी </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'> डेस्कने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result1))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$dskid=$rws['desk_id'];
								$dskapprval=$rws['desk_approval'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($dskid=='0')
								{
									echo "<td class='center'>डेस्क लावणे बाकी </td>";
								}
								else if($dskapprval=='pending')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी </td>";
								}
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
							
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								echo "</tr>";
							}
							//mysql_close();
						/*	while($rws = mysql_fetch_array($result3))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'> डेस्क लावणे बाकी </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
							
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								echo "</tr>";
							} */
							//mysql_close();
							while($rws = mysql_fetch_array($result222))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'> डेस्क लावणे बाकी </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'> डेस्कने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
								echo "</tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result2221))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'>डेस्क लावणे बाकी </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'> डेस्कने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								$transferto=$rws['dept_id_to'];
								$q=mysql_query("SELECT dept_nm from department_master where dept_id='$transferto' ");
								$r=mysql_fetch_array($q);
								$transfer_nm1=$r['dept_nm'];
								
								$todsk=$rws['dsk_id_to'];
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']." to <br>".$transfer_nm1."
									</td>";
								}
								else if($rws['ltr_approval']=='transferred_todesk')
								{
									echo "<td class='center'>transferred to <br>".$rr['desk_nm']."
									</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to'].$transfer_nm1.$rr['desk_nm']."</td>";
								}
								echo "</tr>";
							}
							//mysql_close();
						/*	while($rws = mysql_fetch_array($result22211))
							{
								$ltrid=$rws['ltr_id'];
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								
								echo "<td class='center'> डेस्क लावणे बाकी </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'> कार्यवाही करणे बाकी </font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								##############################################################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table></center></div>";
						}	
						
						
						########################### Updated References ####################################
						/*else if($no == '04')
						{
							echo'<br><br><p align="center"><font size="5" color="#00a0ee">Updated  - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5" color="#59c600">'.$from_date.'</font> ते <font size="5" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
							$result222 = 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.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 t.dept_id_from= (
													SELECT dept_id
													FROM login
													WHERE login_id = '$username' )
							AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1'
							AND  d.ltr_approval = 'approve'
							AND d.ltr_status = 'updated' ");
								
								
							echo "<br><br><table id='dyntable' class='table table-bordered'>";
							echo "<thead>
									<tr>	
									<th class='head0 center'>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
									<th class='head0 center'>केलेली <br>कार्यवाही </th>
									<th class='head1 center'>पत्राची स्थिती </th>
									<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
						</tr>
								</thead>";
								while($rws = mysql_fetch_array($result222))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
								echo "</tr>";
							}
							//mysql_close();
							echo"</table>";
							
							
							###############################DIV TO PRINT #####################################
							
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">Updated  - ';;
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							//echo $id;
							$id1 =$_REQUEST['end_date'];
							//echo $id1;
							$no = $_REQUEST['no'];
							//echo $no;
							//$result222=mysql_query("SELECT * FROM avak_nondvahi WHERE dept_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$id' AND type_of_doc=''");
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
							$result222 = 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.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 t.dept_id_from= (
													SELECT dept_id
													FROM login
													WHERE login_id = '$username' )
							AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1'
							AND  d.ltr_approval = 'approve'
							AND d.ltr_status = 'updated' ");
							echo "<tr>	
									<th>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>";
								while($rws = mysql_fetch_array($result222))
								{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td style='text-align:center;'>डेस्क लावणे बाकी</td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td style='text-align:center;'>डेस्कने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td style='text-align:center;'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td style='text-align:center;'>विभाग लावणे बाकी</td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td style='text-align:center;'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td style='text-align:center;'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td style='text-align:center;'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td style='text-align:center;'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td style='text-align:center;'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else
								{
									echo "<td style='text-align:center;'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td style='text-align:center;'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td style='text-align:center;'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td style='text-align:center;'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td style='text-align:center;'>"."कार्यवाही करणे बाकी"."</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$rws['outword_no']."अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td style='text-align:center;'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
								echo "</tr>";
							}
							//mysql_close();
							echo"</table></center></div>";
						} */
						#######################################################################################
						########################### Dispatched References ####################################
						else if($no == '05')
						{
							echo'<br><br><p align="center"><font size="5" color="#00a0ee">एकूण निर्गत संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							//echo $id;
							$id1 =$_REQUEST['end_date'];
							//echo $id1;
							$no = $_REQUEST['no'];
							//echo $no;
							//$result222=mysql_query("SELECT * FROM avak_nondvahi WHERE dept_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$id' AND type_of_doc=''");
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5" color="#59c600">'.$from_date.'</font> ते <font size="5" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
						$result222 = 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,di.dept_id_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.dsk_id_to, 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 t.dept_id_from = (
												SELECT dept_id
												FROM login
												WHERE login_id = '$username' 
												)
						AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1'
						AND ( d.`ltr_status` = 'dispatched' OR d.ltr_status = 'updated' )
						AND (
								t.`desk_approval` = 'approve'
								OR t.`desk_approval` = 'updated'
								OR t.`desk_approval` = 'dispatched'
							)
						AND d.ltr_approval!='transferred_todesk'
						AND d.action_taken != '' ") or die("".mysql_error());
						
							echo"<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
									<tr>	
							<th class='head0 center'>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
									<th class='head0 center'>केलेली <br>कार्यवाही </th>
									<th class='head1 center'>पत्राची स्थिती </th>
									<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
							</tr>
								</thead>";
							while($rws = mysql_fetch_array($result222))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								$transferto=$rws['dept_id_to'];
								$q=mysql_query("SELECT dept_nm from department_master where dept_id='$transferto' ");
								$r=mysql_fetch_array($q);
								$transfer_nm=$r['dept_nm'];
								
								$todsk=$rws['dsk_id_to'];
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								
								if($rws['ltr_status']=='')
								{
									echo "<td class=center><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class=center>".$rws['ltr_approval']." to <br>".$transfer_nm." </td>";
								}
								else if($rws['ltr_approval']=='transferred_todesk')
								{
									echo "<td class=center>transferred to <br>".$rr['desk_nm']." </td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class=center>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to'].$transfer_nm.$rr['desk_nm']."</td>";
								}
								echo "</tr>";
							}
							//mysql_close();
							echo"</table>";
							
							######################################### DIV TO PRINT ##############################

							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";

							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">एकूण निर्गत संदर्भ  - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
				
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
			
							$result222 = 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,di.dept_id_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.dsk_id_to, 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 t.dept_id_from = (
													SELECT dept_id
													FROM login
													WHERE login_id = '$username' 
													)
							AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1'
							AND (d.`ltr_status` = 'dispatched' OR d.ltr_status = 'updated')
							AND (
									t.`desk_approval` = 'approve'
									OR t.`desk_approval` = 'updated'
									OR t.`desk_approval` = 'dispatched'
								)
							AND d.ltr_approval!='transferred_todesk'
							AND d.action_taken != '' ") or die("".mysql_error());
				
							echo"<tr>	
									<th>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त <br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
							while($rws = mysql_fetch_array($result222))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'> डेस्क लावणे बाकी </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'> डेस्कने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी  </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								$transferto=$rws['dept_id_to'];
								$q=mysql_query("SELECT dept_nm from department_master where dept_id='$transferto' ");
								$r=mysql_fetch_array($q);
								$transfer_nm1=$r['dept_nm'];
								
								$todsk=$rws['dsk_id_to'];
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								
								if($rws['ltr_status']=='')
								{
									echo "<td class=center>"."कार्यवाही करणे बाकी "."</td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class=center>".$rws['ltr_approval']." to <br>".$transfer_nm1." </td>";
								}
								else if($rws['ltr_approval']=='transferred_todesk')
								{
									echo "<td class=center>transferred to <br>".$rr['desk_nm']." </td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class=center>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to'].$transfer_nm1.$rr['desk_nm']."</td>";
								}
								echo "</tr>";
							}
							//mysql_close();
							echo"</table></center></div>";
						
						}
							##############################################################################
						##############################    एका आठवड्यातील शिल्लक संदर्भ      ##############################
						if($no == '06')
						{
							echo'<br><br><p align="center"><font size="6" color="#00a0ee">एका आठवड्यातील शिल्लक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="6" color="#59c600">'.$from_date.'</font> ते </font><font size="6" color="#59c600">'.$to_date.'</font></p>';
							
							// dept accepted,desk accepted
								$result4 = 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.`desk_approval`, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' 
								AND t.`desk_approval` = 'approve'
								AND ( d.ltr_status='')");
										
								// dept accepted,desk not accepted
								$result41 = 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.`desk_approval`, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1'
								AND (t.desk_id='0' OR t.`desk_approval` = 'pending' )
								AND t.returned_choice=''");

							/*	//dept not accepted
								$result43 = 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.`desk_approval`, 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.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 i.status='pending' AND i.sent_dt BETWEEN '$id' AND '$id1' 
								AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
								
								
							echo "<br><br><table id='dyntable' class='table table-bordered'>";
							echo "<thead>
									<tr>	
										<th class='head0 center'>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br> आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
										<th class='head0 center'>केलेली <br>कार्यवाही </th>
										<th class='head1 center'>पत्राची स्थिती </th>
										<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>
								</thead>";
							while($rws = mysql_fetch_array($result4))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result41))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$dskapprval=$rws['desk_approval'];
								$dskid=$rws['desk_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($dskapprval=='pending')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else if($dskid=='0')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							}
							//mysql_close();
						
						/*	while($rws = mysql_fetch_array($result43))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table>";
							
							###################################################################################3
							
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";

							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">एका आठवड्यातील शिल्लक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
				
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
			
							// dept accepted,desk accepted
								$result4 = 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.`desk_approval`, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' 
								AND t.`desk_approval` = 'approve'
								AND ( d.ltr_status='')");
										
								// dept accepted,desk not accepted
								$result41 = 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.`desk_approval`, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1'
								AND (t.desk_id='0' OR t.`desk_approval` = 'pending' )
								AND t.returned_choice=''");

							/*	//dept not accepted
								$result43 = 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.`desk_approval`, 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.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 i.status='pending' AND i.sent_dt BETWEEN '$id' AND '$id1' 
								AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error());  */
				
							echo"<tr>	
									<th>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
							while($rws = mysql_fetch_array($result4))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'>डेस्क लावणे बाकी </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी</td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
							while($rws = mysql_fetch_array($result41))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$dskapprval=$rws['desk_approval'];
								$dskid=$rws['desk_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($dskapprval=='pending')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी </td>";
								}
								else if($dskid=='0')
								{
									echo "<td class='center'> डेस्क लावणे बाकी </td>";
								}
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
							
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								echo "</tr>";
							}
							//mysql_close();
						
						/*	while($rws = mysql_fetch_array($result43))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'> डेस्क लावणे बाकी </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								##############################################################################
							
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table></center></div>";
						}
						
						########################### Pending From 2 Weeks References ################################
						if($no == '07')
						{
							echo'<br><br><p align="center"><font size="6" color="#00a0ee">दोन आठवड्यातील शिल्लक संदर्भ - ';
							//	include("db.php");
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="6" color="#59c600">'.$from_date.'</font> ते <font size="6" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
			
							$date = date_create($from_date);
							date_modify($date, '-15 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
							
							$date = date_create($from_date);
							date_modify($date, '-8 day');
							//echo $to_date1=date_format($date, 'd-m-Y');
							$to_date1=date_format($date, 'd-m-Y');
			
							$prev_date = date("Y-m-d", strtotime('-1 days', strtotime($id)) );
							
								// dept accepted,desk accepted
								$result4 = 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,t.`desk_approval`, 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, 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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$prev_date'
								AND t.`desk_approval` = 'approve'
								AND ( d.ltr_status='')");
										
								// dept accepted,desk not accepted
								$result41 = 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.`desk_approval`, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$prev_date'
								AND (t.desk_id='0' OR t.desk_approval = 'pending')
								AND t.returned_choice='' ");

							/*	//dept not accepted
								$result43 = 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.`desk_approval`, 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.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 i.status='pending' AND i.sent_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$prev_date' 
								AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
						
							echo "<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
								<tr>	
									<th class='head0 center'>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
									<th class='head0 center'>केलेली <br>कार्यवाही </th>
									<th class='head1 center'>पत्राची स्थिती </th>
									<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>
							</thead>";
							
							while($rws = mysql_fetch_array($result4))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
							while($rws = mysql_fetch_array($result41))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$dskapprval=$rws['desk_approval'];
								$dskid=$rws['desk_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($dskapprval=='pending')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else if($dskid=='0')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							}
							//mysql_close();
						
						/*	while($rws = mysql_fetch_array($result43))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table>";
							
							
							################################## div to print ####################################
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">दोन आठवड्यातील शिल्लक संदर्भ- ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
				
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
								
								$prev_date = date("Y-m-d", strtotime('-1 days', strtotime($id)) );
								
								// dept accepted,desk accepted
								$result4 = 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,t.`desk_approval`, 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, 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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$prev_date'
								AND t.`desk_approval` = 'approve'
								AND ( d.ltr_status='')");
										
								// dept accepted,desk not accepted
								$result41 = 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.`desk_approval`, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$prev_date'
								AND (t.desk_id='0' OR t.desk_approval = 'pending')
								AND t.returned_choice='' ");

							/*	//dept not accepted
								$result43 = 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.`desk_approval`, 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.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 i.status='pending' AND i.sent_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$prev_date' 
								AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
				
							echo"<tr>	
									<th>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
							
							while($rws = mysql_fetch_array($result4))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'>डेस्क लावणे बाकी </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी</td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result41))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$dskapprval=$rws['desk_approval'];
								$dskid=$rws['desk_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($dskapprval=='pending')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी </td>";
								}
								else if($dskid=='0')
								{
									echo "<td class='center'> डेस्क लावणे बाकी </td>";
								}
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
							
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								echo "</tr>";
							}
							//mysql_close();	
						/*	while($rws = mysql_fetch_array($result43))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'> डेस्क लावणे बाकी </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								##############################################################################
							
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table></center></div>";
						}
						
						########################### Pending From 3 Weeks References #############################
						else if($no == '08')
						{
							echo'<br><br><p align="center"><font size="6" color="#00a0ee">तीन आठवड्यातील शिल्लक संदर्भ - ';
							//	include("db.php");
							$id =$_REQUEST['dpt_ltr_rec_dt'];
			
							$id1 =$_REQUEST['end_date'];
							
							$no = $_REQUEST['no'];
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="6" color="#59c600">'.$from_date.'</font> ते </font><font size="6" color="#59c600">'.$to_date.'</font></p>';
							$date = date_create($from_date);
							date_modify($date, '-15 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
			
							$date = date_create($from_date);
							date_modify($date, '-8 day');
							//echo $to_date1=date_format($date, 'd-m-Y');
							$to_date1=date_format($date, 'd-m-Y');	
							
							// dept accepted,desk accepted
							$result4 = 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.desk_approval, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
							AND t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)
							AND t.`desk_approval` = 'approve'
							AND ( d.ltr_status='')");
									
							// dept accepted,desk not accepted OR not assigned desk
							$result41 = 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.desk_approval, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
							AND t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)
							AND (t.desk_id='0' OR t.desk_approval = 'pending')
							AND t.returned_choice='' ");

						/*	//dept not accepted
							$result43 = 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.desk_approval, 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.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 i.status='pending' AND i.sent_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY) 
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
							echo"<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
									<tr>	
										<th class='head0 center'>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
										<th class='head0 center'>केलेली <br>कार्यवाही </th>
										<th class='head1 center'>पत्राची स्थिती </th>
										<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>
								</thead>";
							while($rws = mysql_fetch_array($result4))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result41))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$dskapprval=$rws['desk_approval'];
								$dskid=$rws['desk_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($dskapprval=='pending')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else if($dskid=='0')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							}
							//mysql_close();
						
						/*	while($rws = mysql_fetch_array($result43))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table>";
							
							################################ DIV TO PRINT ##################################
							
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">तीन आठवड्यातील शिल्लक संदर्भ- ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
				
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
			
							// dept accepted,desk accepted
							$result4 = 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.desk_approval, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
							AND t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)
							AND t.`desk_approval` = 'approve'
							AND ( d.ltr_status='')");
									
							// dept accepted,desk not accepted OR not assigned desk
							$result41 = 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.desk_approval, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
							AND t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)
							AND (t.desk_id='0' OR t.desk_approval = 'pending')
							AND t.returned_choice='' ");

						/*	//dept not accepted
							$result43 = 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.desk_approval, 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.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 i.status='pending' AND i.sent_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY) 
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
							echo"<tr>	
									<th>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
							
							while($rws = mysql_fetch_array($result4))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'>डेस्क लावणे बाकी </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी</td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result41))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$dskapprval=$rws['desk_approval'];
								$dskid=$rws['desk_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($dskapprval=='pending')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी </td>";
								}
								else if($dskid=='0')
								{
									echo "<td class='center'> डेस्क लावणे बाकी </td>";
								}
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
							
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								echo "</tr>";
							}
							//mysql_close();	
						/*	while($rws = mysql_fetch_array($result43))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'> डेस्क लावणे बाकी </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								##############################################################################
							
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table></center></div>";
						}
					
						########################### Pending From More Than 3 Weeks References ##################
						else if($no == '09')
						{
							echo'<br><br><p align="center"><font size="6" color="#00a0ee">तीन आठवड्यावरील शिल्लक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							
							$id1 =$_REQUEST['end_date'];
							
							$no = $_REQUEST['no'];
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="6" color="#59c600">'.$from_date.'</font> ते </font><font size="6" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
							
							$date = date_create($from_date);
							date_modify($date, '-15 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
							
							$date = date_create($from_date);
							date_modify($date, '-8 day');
							//echo $to_date1=date_format($date, 'd-m-Y');
							$to_date1=date_format($date, 'd-m-Y');	
							
							// dept accepted,desk accepted
							$result4 = 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.desk_approval, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
							AND t.dpt_ltr_rec_dt< DATE_SUB('$id',INTERVAL 14 DAY)
							AND t.`desk_approval` = 'approve'
							AND ( d.ltr_status='')");
									
							// dept accepted,desk not accepted or not assigned desk
							$result41 = 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.desk_approval, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
							AND t.dpt_ltr_rec_dt< DATE_SUB('$id',INTERVAL 14 DAY)
							AND (t.desk_id='0' OR t.`desk_approval` = 'pending')
							AND t.returned_choice='' ");
							
						/*	//dept not accepted
							$result43 = 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.desk_approval, 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.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 i.status='pending' AND i.sent_dt< DATE_SUB('$id',INTERVAL 14 DAY)
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
							echo"<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
									<tr>	
										<th class='head0 center'>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
										<th class='head0 center'>केलेली <br>कार्यवाही </th>
										<th class='head1 center'>पत्राची स्थिती </th>
										<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>
								</thead>";
							
							while($rws = mysql_fetch_array($result4))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result41))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$dskapprval=$rws['desk_approval'];
								$dskid=$rws['desk_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($dskapprval=='pending')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else if($dskid=='0')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							}
							//mysql_close();
						
						/*	while($rws = mysql_fetch_array($result43))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table>";
							
								################################ DIV TO PRINT ##################################
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">तीन आठवड्यावरील शिल्लक संदर्भ- ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
				
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
			
							// dept accepted,desk accepted
							$result4 = 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.desk_approval, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
							AND t.dpt_ltr_rec_dt< DATE_SUB('$id',INTERVAL 14 DAY)
							AND t.`desk_approval` = 'approve'
							AND ( d.ltr_status='')");
									
							// dept accepted,desk not accepted or not assigned desk
							$result41 = 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.desk_approval, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
							AND t.dpt_ltr_rec_dt< DATE_SUB('$id',INTERVAL 14 DAY)
							AND (t.desk_id='0' OR t.`desk_approval` = 'pending')
							AND t.returned_choice='' ");
							
						/*	//dept not accepted
							$result43 = 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.desk_approval, 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.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 i.status='pending' AND i.sent_dt< DATE_SUB('$id',INTERVAL 14 DAY)
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
							echo"<tr>	
									<th>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
						
							while($rws = mysql_fetch_array($result4))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'>डेस्क लावणे बाकी </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी</td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
							while($rws = mysql_fetch_array($result41))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$dskapprval=$rws['desk_approval'];
								$dskid=$rws['desk_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($dskapprval=='pending')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी </td>";
								}
								else if($dskid=='0')
								{
									echo "<td class='center'> डेस्क लावणे बाकी </td>";
								}
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
							
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								echo "</tr>";
							}
							//mysql_close();	
							
						/*	while($rws = mysql_fetch_array($result43))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'> डेस्क लावणे बाकी </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								##############################################################################
							
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table></center></div>";
						}
						
						########################### Total Pending References ####################################
						else if($no == '10')
						{
							echo'<br><br><p align="center"><font size="6" color="#00a0ee">एकूण शिल्लक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="6" color="#59c600">'.$from_date.'</font> ते </font><font size="6" color="#59c600">'.$to_date.'</font>';
							'</font></p>';
								
							$date = date_create($from_date);
							date_modify($date, '-15 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
								
							$date = date_create($from_date);
							date_modify($date, '-8 day');
							//echo $to_date1=date_format($date, 'd-m-Y');
							$to_date1=date_format($date, 'd-m-Y');	
				
							// dept accepted,desk accepted
								$result4 = 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.desk_approval, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt <= '$id1' 
								AND t.`desk_approval` = 'approve'
								AND ( d.ltr_status='')") or die("cccc2".mysql_error());
										
								// dept accepted,desk not accepted or not assigned desk
								$result41 = 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.desk_approval, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt <= '$id1' 
								AND (t.desk_id='0' OR t.`desk_approval` = 'pending')
								AND t.returned_choice='' ") or die("cccc2".mysql_error());

							/*	//dept not accepted
								$result43 = 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.desk_approval, 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.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 i.status='pending' AND i.sent_dt<= '$id1' 
								AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
								
							echo"<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
									<tr>	
										<th class='head0 center'>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
										<th class='head0 center'>केलेली <br>कार्यवाही </th>
										<th class='head1 center'>पत्राची स्थिती </th>
										<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>
								</thead>";
							while($rws = mysql_fetch_array($result4))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result41))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$dskapprval=$rws['desk_approval'];
								$dskid=$rws['desk_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($dskapprval=='pending')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else if($dskid=='0')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							}
							//mysql_close();
							
						/*	while($rws = mysql_fetch_array($result43))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'><font color='red'>डेस्क लावणे बाकी </font> </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
							
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								echo "</tr>";
							} */
							//mysql_close();
						echo"</table>";
						
								################################ DIV TO PRINT ##################################
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">एकूण शिल्लक संदर्भ- ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
				
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
			
								// dept accepted,desk accepted
								$result4 = 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.desk_approval, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt <= '$id1' 
								AND t.`desk_approval` = 'approve'
								AND ( d.ltr_status='')") or die("cccc2".mysql_error());
										
								// dept accepted,desk not accepted or not assigned desk
								$result41 = 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.desk_approval, 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.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 t.dept_id_from= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt <= '$id1' 
								AND (t.desk_id='0' OR t.`desk_approval` = 'pending')
								AND t.returned_choice='' ") or die("cccc2".mysql_error());

							/*	//dept not accepted
								$result43 = 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.desk_approval, 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.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 i.status='pending' AND i.sent_dt<= '$id1' 
								AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
				
							echo"<tr>	
									<th>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
							while($rws = mysql_fetch_array($result4))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'>डेस्क लावणे बाकी </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी</td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								
								else if($rws['ltr_approval']=='transferred')
								{
									echo "<td class='center'>".$rws['ltr_approval']."</td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
							
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result41))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								$dskapprval=$rws['desk_approval'];
								$dskid=$rws['desk_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								if($dskapprval=='pending')
								{
									echo "<td class='center'> डेस्कने स्वीकारणे बाकी </td>";
								}
								else if($dskid=='0')
								{
									echo "<td class='center'> डेस्क लावणे बाकी </td>";
								}
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
							
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								echo "</tr>";
							}
							//mysql_close();
							
						/*	while($rws = mysql_fetch_array($result43))
							{
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								$dskltrid=$rws['desk_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								################################### Desk ####################################
								echo "<td class='center'> डेस्क लावणे बाकी </td>";
								
								############################## dpt######################################
								
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								##############################################################################
							
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table></center></div>";
						}
						
						?>
						
						

						<br>
						<p>	
							<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"/>
							<input type="button" class="btn" onclick="tableToExcel('export', 'W3C Example Table')" value="Export to Excel"></center>
						</p>
						<script src="js/jquery-1.8.3.min.js"></script>
						<script type="text/javascript" src="js/jquery.dataTables.js"></script>
						<script type="text/javascript" src="js/DT_bootstrap.js"></script>
						<script src="js/dynamic-table.js"></script>
						<?php 
						if($_GET['rel']!='tab'){
							echo "</div>";
							include 'footer.php';
						}?>
					</div>
				</div><!--maincontentinner-->
			</div><!--maincontent-->
		</div><!--rightpanel-->
	</div>	
</body>
<?php 
} //if($flag=='')

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

else if($flag=='n')
{
include('new_dashboard_department.php');
require_once('convert_marathi.php');
$username = $_SESSION['User_Name'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="text/javascript">     
       function PrintDiv() {    
           var divToPrint = document.getElementById('divToPrint');
           var popupWin = window.open('', '_blank', 'width=600,height=600');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
</script>
<script src="tableToExcel.js"></script>
</head>
<body>
<div class="mainwrapper">   
    <div class="rightpanel">
            <ul class="breadcrumbs">
				<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
				<li><a href="">Tables</a> <span class="separator"></span></li>
				<li>गोषवारा </li>
			</ul>
			<div class="pageheader">
				<div class="pageicon"><span class="iconfa-table"></span></div>
				<div class="pagetitle">
					<h5>Tables</h5>
					<?php
					$qp=mysql_query("Select dept_nm from department_master WHERE dept_id=(select dept_id from login where login_id='$username')");
					$rp=mysql_fetch_array($qp);
					?>
					<h1>गोषवारा  <?php echo $rp['dept_nm'];?></h1>
				</div>
			</div><!--pageheader-->
			<div class="maincontent">
				<div class="maincontentinner">
						<h4 class="widgettitle">गोषवारा <?php echo $rp['dept_nm'];?></h4>
						<?php
						$no = $_REQUEST['no'];
						########################### Pending References ####################################
						if($no == '01')
						{			
							echo'<br><br><p align="center"><font size="5" color="#00a0ee">मागील शिल्लक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							//echo $id;
							$id1 =$_REQUEST['end_date'];
							//echo $id1;
							$no = $_REQUEST['no'];
							//echo $no;
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5" color="#59c600">'.$from_date.'</font> ते <font size="5" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
							$date = date_create($from_date);
							date_modify($date, '-23 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
			
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE (t.dpt_ltr_rec_dt < '$id' ) 
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username' )") or die("cccc".mysql_error());
									
						/*	//not accepted by dept
							$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE i.status='pending' AND i.sent_dt < '$id'
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */

							
							echo"<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
									<tr>	
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
										<th class='head0 center'>केलेली <br>कार्यवाही </th>
										<th class='head1 center'>पत्राची स्थिती </th>
										<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>
								</thead>";
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
					/*		while($rws = mysql_fetch_array($result1))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							echo"</table>";
							
							
							################################ div to Print ###############################
						echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $rp['dept_nm']. "गोषवारा </h4></center></td></tr>";	
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">मागील शिल्लक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							//echo $id;
							$id1 =$_REQUEST['end_date'];
							//echo $id1;
							$no = $_REQUEST['no'];
							//echo $no;
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="3">'.$from_date.'</font> ते <font size="3">'.$to_date.'</font></font></center></td></tr>';
							$date = date_create($from_date);
							date_modify($date, '-23 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
			
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.ltr_id = t.ltr_id 
							WHERE (t.dpt_ltr_rec_dt < '$id' ) 
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username' )") or die("cccc".mysql_error());
									
						/*	//not accepted by dept
							$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no  
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN desk_transaction d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE i.status='pending' AND i.sent_dt < '$id'
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
								echo"<br><br>";
								echo "<tr>	
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                         
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>";	
								while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
						/*	while($rws = mysql_fetch_array($result1))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
						echo"</table></center>
						</div>";
						}
						
						
						#######################################################################################
						########################### Letters In Current Week ####################################
						else if($no == '02')
						{
							echo'<br><br><p align="center"><font size="5" color="#00a0ee">चालू आठवड्यातील आवक संदर्भ - ';
			
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							//echo $id;
							$id1 =$_REQUEST['end_date'];
							//echo $id1;
							$no = $_REQUEST['no'];
							//echo $no;
							//$result222=mysql_query("SELECT * FROM avak_nondvahi WHERE dept_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$id' AND type_of_doc=''");
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5" color="#59c600">'.$from_date.'</font> ते <font size="5" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
							//accepted by dept
							$result222=mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dept_id_to,di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE (
									t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1'
								) 
								AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username') 
								AND t.returned_choice=''
								ORDER BY i.ltr_inword_no") or die("eeee".mysql_error());
							
						/*	/////not accepted by dept//////
							$result22211 = mysql_query("SELECT i.subject,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
							WHERE i.status='pending' AND (i.sent_dt BETWEEN '$id' AND '$id1')
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
							echo"<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
									<tr>
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
										<th class='head0 center'>केलेली <br>कार्यवाही </th>
										<th class='head1 center'>पत्राची स्थिती </th>
										<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव <br> जावक_दिनांक</th>
									</tr>
								</thead>";
								
							while($rws = mysql_fetch_array($result222))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									$dpt_to=$rws['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws['status']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
						/*	while($rws = mysql_fetch_array($result22211))
							{
								$ltrid=$rws['ltr_id'];
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								
								############################## dpt######################################
								
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table>";
							
							######################################## Div To Print ########################
							
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $rp['dept_nm']. "गोषवारा </h4></center></td></tr>";	
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">चालू आठवड्यातील आवक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							//echo $id;
							$id1 =$_REQUEST['end_date'];
							//echo $id1;
							$no = $_REQUEST['no'];
							//echo $no;
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="3">'.$from_date.'</font> ते <font size="3">'.$to_date.'</font></font></center></td></tr>';
							$date = date_create($from_date);
							date_modify($date, '-23 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
	
							$result222=mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no,di.dept_id_to, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE (
									t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1'
								) 
								AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username') 
								AND t.returned_choice=''
								ORDER BY i.ltr_inword_no") or die("eeee".mysql_error());
								
						/*	/////not accepted by dept//////
							$result22211 = mysql_query("SELECT i.subject,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
							WHERE i.status='pending' AND (i.sent_dt BETWEEN '$id' AND '$id1')
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
								echo"<br><br>";
								echo "<tr>
										<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
										<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th>कोणाकडून_प्राप्त<br>विषय </th>                          
										<th>केलेली <br>कार्यवाही </th>
										<th>पत्राची स्थिती </th>
										<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>";	
							while($rws = mysql_fetch_array($result222))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['status']=='transferred')
								{
									$dpt_to=$rws['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws['status']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
						/*	while($rws = mysql_fetch_array($result22211))
							{
								$ltrid=$rws['ltr_id'];
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'> कार्यवाही करणे बाकी </font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								##############################################################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table></center>
							</div>";
							
						}
						################################################################################
						########################### Total References ####################################
						else if($no == '03')
						{
							echo'<br><br><p align="center"><font size="5" color="#00a0ee">एकूण संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
							
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5" color="#59c600">'.$from_date.'</font> ते <font size="5" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
							////////////pending/////////
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no,di.dept_id_to,  di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE (t.dpt_ltr_rec_dt < '$id' ) 
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username' )") or die("cccc".mysql_error());
									
						/*	//not accepted by dept
							$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no,di.dept_id_to,  di.dispatched_to, t.ltr_category, t.assign_no  
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE i.status='pending' AND i.sent_dt < '$id'
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
								
							///////////current/////////////////
							
							$result11=mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no,di.dept_id_to,  di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON (di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1') 
							AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')
							AND t.returned_choice='' ") or die("eeee".mysql_error());
							
					/*		/////not accepted by dept//////
							$result22211 = mysql_query("SELECT i.subject,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
							WHERE i.status='pending' AND (i.sent_dt BETWEEN '$id' AND '$id1')
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
						echo "<br><br><table id='dyntable' class='table table-bordered'>";
							echo "<thead>
									<tr>
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br> आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
										<th class='head0 center'>केलेली <br>कार्यवाही </th>
										<th class='head1 center'>पत्राची स्थिती </th>
										<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>
								</thead>";
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									$dpt_to=$rws['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws['status']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
						/*	while($rws = mysql_fetch_array($result1))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									$dpt_to=$rws['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws['status']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							while($rws = mysql_fetch_array($result11))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									$dpt_to=$rws['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws['status']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
						
						/*	while($rws = mysql_fetch_array($result22211))
							{
								$ltrid=$rws['ltr_id'];
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table>";
							
							###################################### Div TO Print ###########################
							
							echo
							"<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $rp['dept_nm']. "गोषवारा </h4></center></td></tr>";	
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">एकूण संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];		
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5" >'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
						
							////////////pending/////////
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no,di.dept_id_to,  di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE (t.dpt_ltr_rec_dt < '$id' ) 
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username' )") or die("cccc".mysql_error());
									
						/*	//not accepted by dept
							$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no,di.dept_id_to,  di.dispatched_to, t.ltr_category, t.assign_no  
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN desk_transaction d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE i.status='pending' AND i.sent_dt < '$id'
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
								
							///////////current/////////////////
							//accepted by dept
							$result11=mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no,di.dept_id_to, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON (di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1') 
							AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')
							AND t.returned_choice='' ") or die("eeee".mysql_error());
							
					/*		/////not accepted by dept//////
							$result22211 = mysql_query("SELECT i.subject,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
							WHERE i.status='pending' AND (i.sent_dt BETWEEN '$id' AND '$id1')
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
							echo "<br><br>";
							echo "<tr>	
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br> आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                          
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['status']=='transferred')
								{
									$dpt_to=$rws['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws['status']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
						/*	while($rws = mysql_fetch_array($result1))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['status']=='transferred')
								{
									$dpt_to=$rws['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws['status']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							
							while($rws = mysql_fetch_array($result11))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['status']=='transferred')
								{
									$dpt_to=$rws['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws['status']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</tr>";
							}
						
						/*	while($rws = mysql_fetch_array($result22211))
							{
								$ltrid=$rws['ltr_id'];
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'> कार्यवाही करणे बाकी </font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								##############################################################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table></center></div>";
						}	
						
						
						########################### Updated References ####################################
						/*else if($no == '04')
						{
							echo'<br><br><p align="center"><font size="5" color="#00a0ee">Updated  - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5" color="#59c600">'.$from_date.'</font> ते <font size="5" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
							
							$result222 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no
							FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE t.dept_id_from = (
													SELECT dept_id
													FROM login
													WHERE login_id = '$username' )
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' AND t.returned_choice=''
								AND (t.status = 'approve' AND t.ltr_status = 'updated' ) ");
							
							echo "<br><br><table id='dyntable' class='table table-bordered'>";
							echo "<thead>
									<tr>	
									<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
									<th class='head0 center'>केलेली <br>कार्यवाही </th>
									<th class='head1 center'>पत्राची स्थिती </th>
									<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
						</tr>
								</thead>";
							while($rws = mysql_fetch_array($result222))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							echo"</table>";
							
							
							###############################DIV TO PRINT #####################################
							
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>".$rp['dept_nm']. "गोषवारा </h4></center></td></tr>";
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">Updated  - ';;
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							//echo $id;
							$id1 =$_REQUEST['end_date'];
							//echo $id1;
							$no = $_REQUEST['no'];
							//echo $no;
							//$result222=mysql_query("SELECT * FROM avak_nondvahi WHERE dept_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$id' AND type_of_doc=''");
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
							$result222 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no
							FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE t.dept_id_from = (
													SELECT dept_id
													FROM login
													WHERE login_id = '$username' )
							AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' AND t.returned_choice=''
							AND (t.status = 'approve' AND t.ltr_status = 'updated' ) ");
							echo "<tr>
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>";
								while($rws = mysql_fetch_array($result222))
								{
										$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							echo"</table></center></div>";
						} */
						
						#######################################################################################
						
						
						########################### Dispatched/updated References ###################################
						else if($no == '05')
						{
							echo'<br><br><p align="center"><font size="5" color="#00a0ee">एकूण निर्गत संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							//echo $id;
							$id1 =$_REQUEST['end_date'];
							//echo $id1;
							$no = $_REQUEST['no'];
							//echo $no;
							//$result222=mysql_query("SELECT * FROM avak_nondvahi WHERE dept_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$id' AND type_of_doc=''");
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5" color="#59c600">'.$from_date.'</font> ते <font size="5" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
							
							//dispatched
							$result222 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no,di.dept_id_to, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE t.dept_id_from = (SELECT dept_id from login where login_id = '$username') 
							AND (
									(t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' ) 
									AND (t.dispatched_date BETWEEN '$id' AND '$id1')
									AND t.returned_choice=''
								)") or die("".mysql_error());
						
							///updated
							$result22213 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no
							FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE t.dept_id_from = (
													SELECT dept_id
													FROM login
													WHERE login_id = '$username' )
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' AND t.returned_choice=''
								AND (t.status = 'approve' AND t.ltr_status = 'updated' ) ");
							echo"<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
									<tr>	
									<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
									<th class='head0 center'>केलेली <br>कार्यवाही </th>
									<th class='head1 center'>पत्राची स्थिती </th>
									<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
							</tr>
								</thead>";
							while($rws = mysql_fetch_array($result222))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									$dpt_to=$rws['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws['status']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result22213))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							echo"</table>";
							
							######################################### DIV TO PRINT ##############################

							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $rp['dept_nm']. "गोषवारा </h4></center></td></tr>";
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							
							echo'<tr><td colspan="8"><center><font size="3">एकूण निर्गत संदर्भ  - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
				
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
							//dispatched
							$result222 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no,di.dept_id_to, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE t.dept_id_from = (SELECT dept_id from login where login_id = '$username') 
							AND (
									(t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1') 
									AND (t.dispatched_date BETWEEN '$id' AND '$id1')
									AND t.returned_choice=''
								)") or die("".mysql_error()); 
							
							//updated
							$result22213 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no
							FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE t.dept_id_from = (
													SELECT dept_id
													FROM login
													WHERE login_id = '$username' )
							AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' AND t.returned_choice=''
							AND (t.status = 'approve' AND t.ltr_status = 'updated' ) ");
							
							echo"<tr>	
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त <br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
							while($rws = mysql_fetch_array($result222))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									$dpt_to=$rws['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws['status']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							while($rws = mysql_fetch_array($result22213))
							{
										$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							echo"</table></center></div>";
						
						}
							##############################################################################
							##############################    एका आठवड्यातील शिल्लक संदर्भ      ##############################
						if($no == '06')
						{
							echo'<br><br><p align="center"><font size="6" color="#00a0ee">एका आठवड्यातील शिल्लक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="6" color="#59c600">'.$from_date.'</font> ते </font><font size="6" color="#59c600">'.$to_date.'</font></p>';
								
								//////////////////pending///////////////
								//accepted by dept but nt taken ny action
								$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1') 
								AND t.ltr_status='' AND t.returned_choice=''
								AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username' )") or die("cccc".mysql_error());
							
								
							/*	//not accepted by dept
								$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE i.status='pending' AND i.sent_dt BETWEEN '$id' AND '$id1'
								AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
								
							echo "<br><br><table id='dyntable' class='table table-bordered'>";
							echo "<thead>
									<tr>	
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
										<th class='head0 center'>केलेली <br>कार्यवाही </th>
										<th class='head1 center'>पत्राची स्थिती </th>
										<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>
								</thead>";
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
					/*		while($rws1 = mysql_fetch_array($result1))
							{
								$ltrid=$rws1['ltr_id'];
								$dptltrid=$rws1['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id_from']!='' || $rws1['dept_id_from']!='0')
								{
									$depti1=$rws1['dept_id_from'];
									convert_marathi();
									$qdpt1=mysql_query("Select dept_nm from department_master Where dept_id='$depti1'") or die("".mysql_error());
									$dept1=mysql_fetch_array($qdpt1);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws1['dept_id']=='0' || $rws1['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws1['dpt_inword_no']=='' || $rws1['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept1['dept_nm']."<br>".$rws1['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws1['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws1['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws1['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws1['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws1['status']=='transferred')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='dispatched')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='approve' && $rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								##############################################################################
								if($rws1['dispatched_to']=='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws1['dispatched_to']!='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>".$rws1['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							
							echo"</table>";
							
							###################################################################################3
							
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>".$rp['dept_nm']. "गोषवारा </h4></center></td></tr>";
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							
							echo'<tr><td colspan="8"><center><font size="3">एका आठवड्यातील शिल्लक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
				
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
			
								//////////////////pending///////////////
								//accepted by dept but nt taken ny action
								$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1') 
								AND t.ltr_status='' AND t.returned_choice=''
								AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username' )") or die("cccc".mysql_error());
									
							/*	//not accepted by dept
								$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE i.status='pending' AND i.sent_dt BETWEEN '$id' AND '$id1'
								AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
								
							echo"<tr>	
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
							
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी</td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
						/*	while($rws1 = mysql_fetch_array($result1))
							{
								$ltrid=$rws1['ltr_id'];
								$dptltrid=$rws1['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id_from']!='' || $rws1['dept_id_from']!='0')
								{
									$depti1=$rws1['dept_id_from'];
									convert_marathi();
									$qdpt1=mysql_query("Select dept_nm from department_master Where dept_id='$depti1'") or die("".mysql_error());
									$dept1=mysql_fetch_array($qdpt1);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws1['dept_id']=='0' || $rws1['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws1['dpt_inword_no']=='' || $rws1['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept1['dept_nm']."<br>".$rws1['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws1['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws1['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws1['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['status']=='transferred')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='dispatched')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='approve' && $rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								##############################################################################
								if($rws1['dispatched_to']=='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws1['dispatched_to']!='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>".$rws1['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							echo"</table></center></div>";
						
						}
						
						########################### Pending From 2 Weeks References ################################
						if($no == '07')
						{
							echo'<br><br><p align="center"><font size="6" color="#00a0ee">दोन आठवड्यातील शिल्लक संदर्भ - ';
							//	include("db.php");
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="6" color="#59c600">'.$from_date.'</font> ते <font size="6" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
			
							$date = date_create($from_date);
							date_modify($date, '-15 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
							
							$date = date_create($from_date);
							date_modify($date, '-8 day');
							//echo $to_date1=date_format($date, 'd-m-Y');
							$to_date1=date_format($date, 'd-m-Y');
							
							$prev_date = date("Y-m-d", strtotime('-1 days', strtotime($id)) );
							
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE (t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY) AND '$prev_date')  
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username' )") or die("cccc".mysql_error());
										
						/*	//not accepted by dept
							$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE i.status='pending' AND i.sent_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY) AND '$prev_date'
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
						
							echo "<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
								<tr>	
									<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
									<th class='head0 center'>केलेली <br>कार्यवाही </th>
									<th class='head1 center'>पत्राची स्थिती </th>
									<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>
							</thead>";
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
						/*	while($rws1 = mysql_fetch_array($result1))
							{
								$ltrid=$rws1['ltr_id'];
								$dptltrid=$rws1['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id_from']!='' || $rws1['dept_id_from']!='0')
								{
									$depti1=$rws1['dept_id_from'];
									convert_marathi();
									$qdpt1=mysql_query("Select dept_nm from department_master Where dept_id='$depti1'") or die("".mysql_error());
									$dept1=mysql_fetch_array($qdpt1);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws1['dept_id']=='0' || $rws1['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws1['dpt_inword_no']=='' || $rws1['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept1['dept_nm']."<br>".$rws1['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws1['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws1['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws1['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws1['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws1['status']=='transferred')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='dispatched')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='approve' && $rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								##############################################################################
								if($rws1['dispatched_to']=='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws1['dispatched_to']!='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>".$rws1['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							echo"</table>";
							
							
							################################## div to print ####################################
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>".$rp['dept_nm']. "गोषवारा </h4></center></td></tr>";
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">दोन आठवड्यातील शिल्लक संदर्भ- ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
				
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
						//accepted by dept but nt taken ny action
						$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
						FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
						LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
						WHERE (t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY) AND '$prev_date')  
						AND t.ltr_status='' AND t.returned_choice=''
						AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username' )") or die("cccc".mysql_error());
									
					/*	//not accepted by dept
						$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
						FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
						LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
						WHERE i.status='pending' AND i.sent_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY) AND '$prev_date'
						AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
						
							echo"<tr>	
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी</td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
						/*	while($rws1 = mysql_fetch_array($result1))
							{
								$ltrid=$rws1['ltr_id'];
								$dptltrid=$rws1['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id_from']!='' || $rws1['dept_id_from']!='0')
								{
									$depti1=$rws1['dept_id_from'];
									convert_marathi();
									$qdpt1=mysql_query("Select dept_nm from department_master Where dept_id='$depti1'") or die("".mysql_error());
									$dept1=mysql_fetch_array($qdpt1);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws1['dept_id']=='0' || $rws1['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws1['dpt_inword_no']=='' || $rws1['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept1['dept_nm']."<br>".$rws1['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws1['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws1['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws1['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['status']=='transferred')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='dispatched')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='approve' && $rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								##############################################################################
								if($rws1['dispatched_to']=='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws1['dispatched_to']!='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>".$rws1['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							echo"</table></center></div>";
						}
						
						########################### Pending From 3 Weeks References #############################
						else if($no == '08')
						{
							echo'<br><br><p align="center"><font size="6" color="#00a0ee">तीन आठवड्यातील शिल्लक संदर्भ - ';
							//	include("db.php");
							$id =$_REQUEST['dpt_ltr_rec_dt'];
			
							$id1 =$_REQUEST['end_date'];
							
							$no = $_REQUEST['no'];
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="6" color="#59c600">'.$from_date.'</font> ते </font><font size="6" color="#59c600">'.$to_date.'</font></p>';
							$date = date_create($from_date);
							date_modify($date, '-15 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
			
							$date = date_create($from_date);
							date_modify($date, '-8 day');
							//echo $to_date1=date_format($date, 'd-m-Y');
							$to_date1=date_format($date, 'd-m-Y');	
							
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)  
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username')") or die("cccc".mysql_error());
									
					/*		//not accepted by dept
							$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE i.status='pending' AND i.sent_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error());  */
							
							echo"<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
									<tr>	
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
										<th class='head0 center'>केलेली <br>कार्यवाही </th>
										<th class='head1 center'>पत्राची स्थिती </th>
										<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>
								</thead>";
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
					/*		while($rws1 = mysql_fetch_array($result1))
							{
								$ltrid=$rws1['ltr_id'];
								$dptltrid=$rws1['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id_from']!='' || $rws1['dept_id_from']!='0')
								{
									$depti1=$rws1['dept_id_from'];
									convert_marathi();
									$qdpt1=mysql_query("Select dept_nm from department_master Where dept_id='$depti1'") or die("".mysql_error());
									$dept1=mysql_fetch_array($qdpt1);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws1['dept_id']=='0' || $rws1['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws1['dpt_inword_no']=='' || $rws1['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept1['dept_nm']."<br>".$rws1['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws1['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws1['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws1['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws1['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws1['status']=='transferred')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='dispatched')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='approve' && $rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								##############################################################################
								if($rws1['dispatched_to']=='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws1['dispatched_to']!='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>".$rws1['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							echo"</table>";
							
							################################ DIV TO PRINT ##################################
							
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>".$rp['dept_nm']. "गोषवारा </h4></center></td></tr>";
							
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">तीन आठवड्यातील शिल्लक संदर्भ- ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
				
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)  
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username')") or die("cccc".mysql_error());
									
						/*	//not accepted by dept
							$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE i.status='pending' AND i.sent_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
				
							echo"<tr>	
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी</td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
						/*	while($rws1 = mysql_fetch_array($result1))
							{
								$ltrid=$rws1['ltr_id'];
								$dptltrid=$rws1['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id_from']!='' || $rws1['dept_id_from']!='0')
								{
									$depti1=$rws1['dept_id_from'];
									convert_marathi();
									$qdpt1=mysql_query("Select dept_nm from department_master Where dept_id='$depti1'") or die("".mysql_error());
									$dept1=mysql_fetch_array($qdpt1);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws1['dept_id']=='0' || $rws1['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws1['dpt_inword_no']=='' || $rws1['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept1['dept_nm']."<br>".$rws1['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws1['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws1['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws1['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['status']=='transferred')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='dispatched')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='approve' && $rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								##############################################################################
								if($rws1['dispatched_to']=='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws1['dispatched_to']!='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>".$rws1['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							echo"</table></center></div>";
						}
					
						########################### Pending From More Than 3 Weeks References ##################
						else if($no == '09')
						{
							echo'<br><br><p align="center"><font size="6" color="#00a0ee">तीन आठवड्यावरील शिल्लक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							
							$id1 =$_REQUEST['end_date'];
							
							$no = $_REQUEST['no'];
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="6" color="#59c600">'.$from_date.'</font> ते </font><font size="6" color="#59c600">'.$to_date.'</font>';
								'</font></p>';
							
							$date = date_create($from_date);
							date_modify($date, '-15 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
							
							$date = date_create($from_date);
							date_modify($date, '-8 day');
							//echo $to_date1=date_format($date, 'd-m-Y');
							$to_date1=date_format($date, 'd-m-Y');	
							
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE t.dpt_ltr_rec_dt < DATE_SUB('$id',INTERVAL 14 DAY)
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username')") or die("cccc".mysql_error());
									
						/*	//not accepted by dept
							$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE i.status='pending' AND i.sent_dt < DATE_SUB('$id',INTERVAL 14 DAY)
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
							echo"<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
									<tr>	
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
										<th class='head0 center'>केलेली <br>कार्यवाही </th>
										<th class='head1 center'>पत्राची स्थिती </th>
										<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
									</tr>
								</thead>";
								
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
						/*	while($rws1 = mysql_fetch_array($result1))
							{
								$ltrid=$rws1['ltr_id'];
								$dptltrid=$rws1['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id_from']!='' || $rws1['dept_id_from']!='0')
								{
									$depti1=$rws1['dept_id_from'];
									convert_marathi();
									$qdpt1=mysql_query("Select dept_nm from department_master Where dept_id='$depti1'") or die("".mysql_error());
									$dept1=mysql_fetch_array($qdpt1);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws1['dept_id']=='0' || $rws1['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws1['dpt_inword_no']=='' || $rws1['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept1['dept_nm']."<br>".$rws1['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws1['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws1['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws1['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws1['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws1['status']=='transferred')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='dispatched')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='approve' && $rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								##############################################################################
								if($rws1['dispatched_to']=='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws1['dispatched_to']!='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>".$rws1['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							echo"</table>";
							
							################################ DIV TO PRINT ##################################
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>".$rp['dept_nm']. "गोषवारा </h4></center></td></tr>";
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							
							echo'<tr><td colspan="8"><center><font size="3">तीन आठवड्यावरील शिल्लक संदर्भ- ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
				
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE t.dpt_ltr_rec_dt < DATE_SUB('$id',INTERVAL 14 DAY)
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username')") or die("cccc".mysql_error());
									
						/*	//not accepted by dept
							$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE i.status='pending' AND i.sent_dt < DATE_SUB('$id',INTERVAL 14 DAY)
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							
							echo"<tr>	
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी</td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
						/*	while($rws1 = mysql_fetch_array($result1))
							{
								$ltrid=$rws1['ltr_id'];
								$dptltrid=$rws1['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id_from']!='' || $rws1['dept_id_from']!='0')
								{
									$depti1=$rws1['dept_id_from'];
									convert_marathi();
									$qdpt1=mysql_query("Select dept_nm from department_master Where dept_id='$depti1'") or die("".mysql_error());
									$dept1=mysql_fetch_array($qdpt1);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws1['dept_id']=='0' || $rws1['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws1['dpt_inword_no']=='' || $rws1['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept1['dept_nm']."<br>".$rws1['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws1['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws1['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws1['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['status']=='transferred')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='dispatched')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='approve' && $rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								##############################################################################
								if($rws1['dispatched_to']=='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws1['dispatched_to']!='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>".$rws1['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							echo"</table></center></div>";
						}
						
						########################### Total Pending References ####################################
						else if($no == '10')
						{
							echo'<br><br><p align="center"><font size="6" color="#00a0ee">एकूण शिल्लक संदर्भ - ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
							convert_marathi();
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="6" color="#59c600">'.$from_date.'</font> ते </font><font size="6" color="#59c600">'.$to_date.'</font>';
							'</font></p>';
								
							$date = date_create($from_date);
							date_modify($date, '-15 day');
							//echo $from_date1=date_format($date, 'd-m-Y');
							$from_date1=date_format($date, 'd-m-Y');
								
							$date = date_create($from_date);
							date_modify($date, '-8 day');
							//echo $to_date1=date_format($date, 'd-m-Y');
							$to_date1=date_format($date, 'd-m-Y');	
							
							//////////////////pending///////////////
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.ltr_id = t.ltr_id 
							WHERE (t.dpt_ltr_rec_dt < '$id' ) 
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username' )") or die("cccc".mysql_error());
									
						/*	//not accepted by dept
							$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN 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 i.status='pending' AND i.sent_dt < '$id'
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
								
							////////current pending////////////
							/////accepted by dept//////
							$result11=mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON (di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' AND t.returned_choice='') 
							AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')
							AND t.ltr_status='' ") or die("eeee".mysql_error());
							
						/*	/////not accepted by dept//////
							$result22211 = mysql_query("SELECT i.subject,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
							WHERE i.status='pending' AND (i.sent_dt BETWEEN '$id' AND '$id1')
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
						
							echo"<br><br><table id='dyntable' class='table table-bordered'>";
							echo"<thead>
									<tr>	
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
										<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
										<th class='head1 center'>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
										<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय </th>                      
										<th class='head0 center'>केलेली <br>कार्यवाही </th>
										<th class='head1 center'>पत्राची स्थिती </th>
										<th class='head0 center'>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>
								</thead>";
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
						/*	while($rws1 = mysql_fetch_array($result1))
							{
								$ltrid=$rws1['ltr_id'];
								$dptltrid=$rws1['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id_from']!='' || $rws1['dept_id_from']!='0')
								{
									$depti1=$rws1['dept_id_from'];
									convert_marathi();
									$qdpt1=mysql_query("Select dept_nm from department_master Where dept_id='$depti1'") or die("".mysql_error());
									$dept1=mysql_fetch_array($qdpt1);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws1['dept_id']=='0' || $rws1['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws1['dpt_inword_no']=='' || $rws1['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept1['dept_nm']."<br>".$rws1['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws1['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws1['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws1['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws1['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws1['status']=='transferred')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='dispatched')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='approve' && $rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								##############################################################################
								if($rws1['dispatched_to']=='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws1['dispatched_to']!='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>".$rws1['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							while($rws11 = mysql_fetch_array($result11))
							{
								$ltrid=$rws11['ltr_id'];
								$dptltrid=$rws11['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws11['dept_id_from']!='' || $rws11['dept_id_from']!='0')
								{
									$depti11=$rws11['dept_id_from'];
									convert_marathi();
									$qdpt11=mysql_query("Select dept_nm from department_master Where dept_id='$depti11'") or die("".mysql_error());
									$dept11=mysql_fetch_array($qdpt11);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws11['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws11['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws11['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws11['dept_id']=='0' || $rws11['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws11['dpt_inword_no']=='' || $rws11['dpt_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept11['dept_nm']."<br>".$rws11['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws11['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws11['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws11['sender_name']."<br><b>विषय : </b>".$rws11['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws11['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws11['ltr_status'])
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws11['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws11['ltr_status']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws11['status']=='transferred')
								{
									echo "<td class='center'>".$rws11['status']."</td>";
								}
								else if($rws11['status']=='dispatched')
								{
									echo "<td class='center'>".$rws11['status']."</td>";
								}
								else if($rws11['status']=='approve' && $rws11['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws11['ltr_status']."</td>";
								}
								else 
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								##############################################################################
								if($rws11['dispatched_to']=='' && $rws11['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws11['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws11['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws11['dispatched_to']!='' && $rws11['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws11['outword_no']."<br>".$rws11['addressed_to']."</td>";
								}
								
								echo "</td></tr>";
							}
							//mysql_close();
						
						/*	while($rws = mysql_fetch_array($result22211))
							{
								$ltrid=$rws['ltr_id'];
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								
								echo "</tr>";
							} */
							//mysql_close();
						echo"</table>";
						
						################################ DIV TO PRINT ##################################
							echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>".$rp['dept_nm']. "गोषवारा </h4></center></td></tr>";
							echo ' <center><h2><font color="black">पोलीस अधीक्षक <br> कार्यालय <br> जि.रायगड </font></h2></center>';
							echo'<tr><td colspan="8"><center><font size="3">एकूण शिल्लक संदर्भ- ';
							$id =$_REQUEST['dpt_ltr_rec_dt'];
							$id1 =$_REQUEST['end_date'];
							$no = $_REQUEST['no'];
				
							$from_date 	= date('d-m-Y',strtotime($id));
							$to_date 	= date('d-m-Y',strtotime($id1));
							echo '<font size="5">'.$from_date.'</font> ते <font size="5">'.$to_date.'</font>';
								'</font></p>';
							convert_marathi();
							
							//////////////////pending///////////////
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.ltr_id = t.ltr_id 
							WHERE (t.dpt_ltr_rec_dt < '$id' ) 
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from = ( SELECT dept_id from login where login_id = '$username' )") or die("cccc".mysql_error());
									
					/*		//not accepted by dept
							$result1 = mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN 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 i.status='pending' AND i.sent_dt < '$id'
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
								
							////////current pending////////////
							/////accepted by dept//////
							$result11=mysql_query("SELECT t.action_taken, 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, t.update_date, t.dispatched_date, t.status, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON (di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' AND t.returned_choice='') 
							AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username')
							AND t.ltr_status='' ") or die("eeee".mysql_error());
							
						/*	/////not accepted by dept//////
							$result22211 = mysql_query("SELECT i.subject,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
							WHERE i.status='pending' AND (i.sent_dt BETWEEN '$id' AND '$id1')
							AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error()); */
							echo"<tr>	
									<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
									<th>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्र.<br>आवक_दिनांक</th>
									<th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
									<th>कोणाकडून_प्राप्त<br>विषय </th>                      
									<th>केलेली <br>कार्यवाही </th>
									<th>पत्राची स्थिती </th>
									<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
								</tr>";
							while($rws = mysql_fetch_array($result))
							{
								$ltrid=$rws['ltr_id'];
								$dptltrid=$rws['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी</td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='')
								{
									echo "<td class='center'>कार्यवाही करणे बाकी </td>";
								}
								else if($rws['status']=='transferred')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='dispatched')
								{
									echo "<td class='center'>".$rws['status']."</td>";
								}
								else if($rws['status']=='approve' && $rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								
								##############################################################################
								if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
								}
						
								echo "</td></tr>";
							}
							//mysql_close();
							
						/*	while($rws1 = mysql_fetch_array($result1))
							{
								$ltrid=$rws1['ltr_id'];
								$dptltrid=$rws1['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id_from']!='' || $rws1['dept_id_from']!='0')
								{
									$depti1=$rws1['dept_id_from'];
									convert_marathi();
									$qdpt1=mysql_query("Select dept_nm from department_master Where dept_id='$depti1'") or die("".mysql_error());
									$dept1=mysql_fetch_array($qdpt1);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws1['dept_id']=='0' || $rws1['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws1['dpt_inword_no']=='' || $rws1['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept1['dept_nm']."<br>".$rws1['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws1['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws1['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws1['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['status']=='transferred')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='dispatched')
								{
									echo "<td class='center'>".$rws1['status']."</td>";
								}
								else if($rws1['status']=='approve' && $rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								}
								else
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								##############################################################################
								if($rws1['dispatched_to']=='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws1['dispatched_to']!='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."<br>".$rws1['addressed_to']."</td>";
								}
								else 
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								echo "</td></tr>";
							} */
							//mysql_close();
							while($rws11 = mysql_fetch_array($result11))
							{
								$ltrid=$rws11['ltr_id'];
								$dptltrid=$rws11['dpt_ltr_id'];
								########################### Fetch department name ##############################
								if($rws11['dept_id_from']!='' || $rws11['dept_id_from']!='0')
								{
									$depti11=$rws11['dept_id_from'];
									convert_marathi();
									$qdpt11=mysql_query("Select dept_nm from department_master Where dept_id='$depti11'") or die("".mysql_error());
									$dept11=mysql_fetch_array($qdpt11);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws11['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws11['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws11['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								if($rws11['dept_id']=='0' || $rws11['dept_id']=='')
								{
									echo "<td class='center'> विभाग लावणे बाकी </td>";
								}
								else if($rws11['dpt_inword_no']=='' || $rws11['dpt_inword_no']=='0')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$dept11['dept_nm']."<br>".$rws11['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								################################### common things #######################
								echo "<td class='center'>".$rws11['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws11['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws11['sender_name']."<br><b>विषय : </b>".$rws11['subject']."</td>";
								################## If Action Taken Pending ##########################				
								if($rws11['action_taken']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws11['ltr_status'])
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$rws11['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws11['ltr_status']=='')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws11['status']=='transferred')
								{
									echo "<td class='center'>".$rws11['status']."</td>";
								}
								else if($rws11['status']=='dispatched')
								{
									echo "<td class='center'>".$rws11['status']."</td>";
								}
								else if($rws11['status']=='approve' && $rws11['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws11['ltr_status']."</td>";
								}
								else 
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								##############################################################################
								if($rws11['dispatched_to']=='' && $rws11['ltr_status']!='updated')
								{
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								}
								else if($rws11['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws11['outword_no']."<br>अपडेट केले</td>";
								}
								else if($rws11['dispatched_to']!='' && $rws11['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws11['outword_no']."<br>".$rws11['addressed_to']."</td>";
								}
								
								echo "</td></tr>";
							}
							//mysql_close();
							
						/*	while($rws = mysql_fetch_array($result22211))
							{
								$ltrid=$rws['ltr_id'];
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class='gradeX'>";
								############################## dpt######################################
								
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								
								################################### common things #######################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								################## If Action Taken Pending ##########################				
								
									echo "<td class='center'> कार्यवाही करणे बाकी </font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								##############################################################################
								
									echo "<td class='center'> कार्यवाही करणे बाकी </td>";
								
								echo "</tr>";
							} */
							//mysql_close();
							echo"</table></center></div>";
						}
						
						?>
						
						

						<br>
						<p>	
							<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"/>
							<input type="button" class="btn" onclick="tableToExcel('export', 'W3C Example Table')" value="Export to Excel"></center>
						</p>
						<script src="js/jquery-1.8.3.min.js"></script>
						<script type="text/javascript" src="js/jquery.dataTables.js"></script>
						<script type="text/javascript" src="js/DT_bootstrap.js"></script>
						<script src="js/dynamic-table.js"></script>
						<?php 
						if($_GET['rel']!='tab'){
							echo "</div>";
							include 'footer.php';
						}?>
					</div>
				</div><!--maincontentinner-->
			</div><!--maincontent-->
		</div><!--rightpanel-->
	</div>	
</body>
<?php 
} //else if($flag=='n')

?>