<!DOCTYPE html>
<?php include('dashboard_desk.php');
require_once('convert_marathi.php');
$username = $_SESSION['User_Name'];
$desk=mysql_query("select desk_nm from desk_master where desk_id=(select desk_id from login where login_id='$username')");
$desknm=mysql_fetch_array($desk);
?>
<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>
                <h1> <?php echo $desknm['desk_nm'];?> गोषवारा </h1>
            </div>
        </div><!--pageheader-->
        <div class="maincontent">
            <div class="maincontentinner">
			    <h4 class="widgettitle">गोषवारा </h4>
				
				<?php
				$no = $_REQUEST['no'];
				###################################### Pending References ##################################
				if($no == '01')
					{
						
						$id =$_REQUEST['desk_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));
						
						$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 desk
						$result222 = mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no 
						FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
						LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id 
						LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id 
						WHERE de.desk_ltr_rec_dt < '$id' 
						and (t.desk_approval='approve' AND de.ltr_status='') 
						AND de.desk_id_from = (SELECT desk_id from login where login_id = '$username') 
						order by i.ltr_inword_no desc") or die("cccc".mysql_error());
						
					/*	//not accepted by desk
						$result2221 = mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no 
						FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
						LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id 
						LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id 
						WHERE (t.desk_approval='pending' AND t.sent_to_desk_dt< '$id')
						AND t.desk_id = (SELECT desk_id from login where login_id = '$username')
						order by i.ltr_inword_no desc ") or die("ccccddd".mysql_error()); */
						
						//echo'<center><font size="5" color="#00a0ee">मागील शिल्लक संदर्भ - ';
						//echo '<font size="5" color="#59c600">'.$from_date.'</font> ते <font size="5" color="#59c600">'.$to_date.'</font></font></center><br>';
						echo "<table id='dyntable' class='table table-bordered'>";
						echo"<thead>
						<tr>	
							<th class='head0 center'>पोलीस अधीक्षक <br>कार्यालय,<br>आवक_क्रमांक<br>आवक_दिनांक</th>
							<th class='head1 center'>विभागीय आवक_क्रमांक<br>दिनांक</th>
							<th class='head0 center'>डेस्क आवक_क्रमांक<br>दिनांक</th>
							<th class='head1 center'>विषय</th>
							<th class='head0 center'>कोणाकडून <br>प्राप्त_झाला</th>
							<th class='head1 center'>केलेली कार्यवाही</th>
							<th class='head0 center'>पत्राची_स्थिती </th>
							<th class='head1 center'>विभागीय <br>जावक_दिनांक</th>
						</tr>
							</thead>
							<tbody>";
						while($test = mysql_fetch_array($result222))
							{
								$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
								$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
								$update_date 		= date('d-m-Y',strtotime($test['update_date']));
								$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
								$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
								// code for split date and arrange according to our need
								//dispose_date is in following format "YYYY-MM-DD" 
								list($year, $month, $day ) =explode("-",$dispose_date);
								$dispose = $day.'-'.$month.'-'.$year;
								list($year, $month, $day ) =explode("-",$update_date);
								$update = $day.'-'.$month.'-'.$year;
								echo "<tr class='gradeX'>
										<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
										<td class='center'>".$test['dpt_inword_no']."<br>
											".$dept_rec_date."</td>
										<td class='center'>".$test['desk_ltr_inword_no']."<br>
											".$desk_ltr_rec_dt."</td>
										<td class='center'>".$test['subject']."</td>
										<td class='center'>".$test['sender_name']."</td>";
										if($test['action_taken']=='')
										{
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										}
										/*else
										{
										echo "<td class='center'>".$test['action_taken']."</td>";
										}*/
										else
										{
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										}
										
										if($test['ltr_status']=='')
										{
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										}
										else
										{
										echo "<td class='center'>".$test['ltr_status']."</td>";
										}
										
										
										if ($test['ltr_status']=='updated')
											{
												echo "<td class='center'>".$update_date."</td>";
											}
										else if($test['ltr_status']=='dispatched')
											{
												echo "<td class='center'>".$dispose_date."</td>";
											}
											else 
											{
												echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी</font> </td>";
											}
										echo "</tr>";
							}
							
						/*	while($test1 = mysql_fetch_array($result2221))
							{
								$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
								$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
								$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
								$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
								$rc_date 		= date('d-m-Y',strtotime($test1['receive_dt']));
								// code for split date and arrange according to our need
								//dispose_date is in following format "YYYY-MM-DD" 
								list($year, $month, $day ) =explode("-",$dispose_date);
								$dispose = $day.'-'.$month.'-'.$year;
								list($year, $month, $day ) =explode("-",$update_date);
								$update = $day.'-'.$month.'-'.$year;
								echo "<tr class='gradeX'>
										<td class='center'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
										<td class='center'>".$test1['dpt_inword_no']."<br>
											".$dept_rec_date."</td>
										<td class='center'><font color='red'> डेस्क ने स्वीकारणे बाकी </font></td>
										<td class='center'>".$test1['subject']."</td>
										<td class='center'>".$test1['sender_name']."</td>";
										
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										
										echo "</tr>";
							} */
						echo"</tbody>
						</table>";
						############################### Div To Print ####################################
						echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>";
							
							echo ' <center><h2>पोलीस अधीक्षक कार्यालय,<br> जि.रायगड </h2></center>';
							
							echo "<tr><td colspan='9'><center>". $desknm['desk_nm']. "गोषवारा </center></td></tr>";
					
						echo'<tr><td colspan="8"><center><font size="3">मागील शिल्लक संदर्भ - ';
						
					
						$id =$_REQUEST['desk_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="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 de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no 
						FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
						LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id 
						LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id 
						WHERE de.desk_ltr_rec_dt<'$id1' 
						and (t.desk_approval='approve' AND de.ltr_status='') 
						AND de.desk_id_from = (SELECT desk_id from login where login_id = '$username') 
						order by i.ltr_inword_no desc") or die("cccc".mysql_error());
						
				/*		$result2221 = mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no 
						FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
						LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id 
						LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id 
						WHERE (t.desk_approval='pending' AND t.sent_to_desk_dt< '$id')
						AND t.desk_id = (SELECT desk_id from login where login_id = '$username')
						order by i.ltr_inword_no desc ") or die("ccccddd".mysql_error()); */
						
						echo"<br><br>";
						echo "<tr>	
						<th>पोलीस अधीक्षक <br>कार्यालय <br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th>विषय</th>
						<th>कोणाकडून <br>प्राप्त_झाला</th>
						<th>केलेली कार्यवाही</th>
						<th>पत्राची स्थिती </th>
						<th>विभागीय <br>जावक_दिनांक</th>
					</tr>";
						while($test = mysql_fetch_array($result222))
							{
								$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
								$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
								$update_date 		= date('d-m-Y',strtotime($test['update_date']));
								$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
								$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
								// code for split date and arrange according to our need
								//dispose_date is in following format "YYYY-MM-DD" 
								list($year, $month, $day ) =explode("-",$dispose_date);
								$dispose = $day.'-'.$month.'-'.$year;
								list($year, $month, $day ) =explode("-",$update_date);
								$update = $day.'-'.$month.'-'.$year;
								echo "<tr class='gradeX'>
										<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
										<td class='center'>".$test['dpt_inword_no']."<br>
											".$dept_rec_date."</td>
										<td class='center'>".$test['desk_ltr_inword_no']."<br>
											".$desk_ltr_rec_dt."</td>
										<td class='center'>".$test['subject']."</td>
										<td class='center'>".$test['sender_name']."</td>";
										if($test['action_taken']=='')
										{
										echo "<td class='center'> कार्यवाही करणे बाकी </td>";
										}
										/*else
										{
										echo "<td class='center'>".$test['action_taken']."</td>";
										}*/
										else
										{
										echo "<td class='center'> कार्यवाही करणे बाकी </td>";
										}
										if($test['ltr_status']=='')
										{
										echo "<td class='center'> कार्यवाही करणे बाकी </td>";
										}
										else
										{
										echo "<td class='center'>".$test['ltr_status']."</td>";
										}
										if ($test['ltr_status']=='updated')
											{
												echo "<td class='center'>".$update_date."</td>";
											}
										else if($test['ltr_status']=='dispatched')
											{
												echo "<td class='center'>".$dispose_date."</td>";
											}
											else 
											{
												echo "<td class='center'> कार्यवाही करणे बाकी </td>";
											}
										echo "</tr>";
							}
							
						/*	while($test1 = mysql_fetch_array($result2221))
							{
								$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
								$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
								$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
								$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
								$rc_date 		= date('d-m-Y',strtotime($test1['receive_dt']));
								// code for split date and arrange according to our need
								//dispose_date is in following format "YYYY-MM-DD" 
								list($year, $month, $day ) =explode("-",$dispose_date);
								$dispose = $day.'-'.$month.'-'.$year;
								list($year, $month, $day ) =explode("-",$update_date);
								$update = $day.'-'.$month.'-'.$year;
								echo "<tr class='gradeX'>
										<td class='center'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
										<td class='center'>".$test1['dpt_inword_no']."<br>
											".$dept_rec_date."</td>
										<td class='center'> डेस्क ने स्वीकारणे बाकी </td>
										<td class='center'>".$test1['subject']."</td>
										<td class='center'>".$test1['sender_name']."</td>";
										
										echo "<td class='center'> कार्यवाही करणे बाकी </td>";
										echo "<td class='center'> कार्यवाही करणे बाकी </td>";
										echo "<td class='center'> कार्यवाही करणे बाकी </td>";
										
										echo "</tr>";
							} */
						echo"</table></center>
						</div>";
					}
					
					
						############################ References Of Current Week ###################################
					else if($no == '02')
					{
						echo'<br><br><p align="center"><font size="5" color="#00a0ee">चालू आठवड्यातील आवक संदर्भ - ';
						$id =$_REQUEST['desk_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><font size="5" color="#59c600">'.$to_date.'</font></p>';
						convert_marathi();
						// accepted by desk
						$result222=mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to,di.dsk_id_to,di.dept_id_to, de.ltr_category, de.assign_no FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id WHERE (de.desk_ltr_rec_dt BETWEEN '$id' AND '$id1') AND de.desk_id_from = (SELECT desk_id from login where login_id = '$username')
						AND de.ltr_status!='closed'
						ORDER BY i.ltr_inword_no") or die("eeee".mysql_error());

					/*	//not accepted by desk
						$result22212 = mysql_query("SELECT t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document
						FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
						WHERE (t.desk_approval='pending' AND t.sent_to_desk_dt BETWEEN '$id' AND '$id1')
						AND t.desk_id = (SELECT desk_id from login where login_id = '$username')
						order by i.ltr_inword_no desc ") or die("ccccddd".mysql_error()); */
							
						echo"<br><br><table id='dyntable' class='table table-bordered'>";
						echo"<thead>
								<tr>	
							<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय <br>आवक_क्रमांक<br>आवक_दिनांक</th>
							<th class='head1 center'>विभागीय आवक_क्रमांक<br>दिनांक</th>
							<th class='head0 center'>डेस्क आवक_क्रमांक<br>दिनांक</th>
							<th class='head1 center'>विषय</th>
							<th class='head0 center'>कोणाकडून <br>प्राप्त_झाला</th>
							<th class='head1 center'>केलेली कार्यवाही</th>
							<th class='head0 center'>पत्राची_स्थिती </th>
							<th class='head1 center'>विभागीय <br>जावक_दिनांक</th>
								</tr>
							</thead>";
							while($test = mysql_fetch_array($result222))
								{
									$desk_ltr_rec_dt 		= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
									$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
									$update_date 		= date('d-m-Y',strtotime($test['update_date']));
									$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
									$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
									// code for split date and arrange according to our need
									//dispose_date is in following format "YYYY-MM-DD" 
									list($year, $month, $day ) =explode("-",$dispose_date);
									$dispose = $day.'-'.$month.'-'.$year;
									list($year, $month, $day ) =explode("-",$update_date);
									$update = $day.'-'.$month.'-'.$year;
									echo "<tr>
											<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
											<td class='center'>".$test['dpt_inword_no']."<br>
												".$dept_rec_date."</td>
											<td class='center'>".$test['desk_ltr_inword_no']."<br>
												".$desk_ltr_rec_dt."</td>
											<td class='center'>".$test['subject']."</td>
											<td class='center'>".$test['sender_name']."</td>";
							////////////////////////////
							if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else if($test['ltr_status']=='closed')
							{
								echo "<td class='center'>--</td>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td>";
							}
							////////////////////////////////////
							if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else if($test['ltr_status']=='updated' || $test['ltr_status']=='closed')
							{
								echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='Approve')
							{
								echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred')
							{
								$todpt=$test['dept_id_to'];
								$qq=mysql_query("SELECT dept_nm from  department_master where dept_id='$todpt' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>".$test['ltr_approval']."to<br>".$rr['dept_nm']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred_todesk')
							{
								$todsk=$test['dsk_id_to'];
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>transferred to <br>".$rr['desk_nm']."</td>";
							}
							//////////////////////////////////// 
							 if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test['ltr_status']=='updated')
							{
								echo "<td class='center'>".$update_date."</td>";
							}
							else if($test['ltr_status']=='dispatched')
							{
								echo "<td class='center'>".$dispose_date."</td>";
							}
							else if($test['ltr_status']=='closed')
							{
								echo "<td class='center'>--</td>";
							}
							
							echo "</tr>";
						}
					/*	while($test1 = mysql_fetch_array($result22212))
						{
								$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
								$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
								$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
								$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
								$rc_date 		= date('d-m-Y',strtotime($test1['receive_dt']));
								// code for split date and arrange according to our need
								//dispose_date is in following format "YYYY-MM-DD" 
								list($year, $month, $day ) =explode("-",$dispose_date);
								$dispose = $day.'-'.$month.'-'.$year;
								list($year, $month, $day ) =explode("-",$update_date);
								$update = $day.'-'.$month.'-'.$year;
								echo "<tr class='gradeX'>
										<td class='center'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
										<td class='center'>".$test1['dpt_inword_no']."<br>
											".$dept_rec_date."</td>
										<td class='center'><font color='red'> डेस्क ने स्वीकारणे बाकी </font></td>
										<td class='center'>".$test1['subject']."</td>
										<td class='center'>".$test1['sender_name']."</td>";
										
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										
										echo "</tr>";
							} */
							//mysql_close();
						echo"</table>";
						################################### Print To Div ###################################
						echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='10'><center>". $desknm['desk_nm']. "गोषवारा </center></td></tr>";
						
						echo ' <center><h2>पोलीस अधीक्षक कार्यालय <br> जि.रायगड</h2></center>';	
						echo'<tr><td colspan="10"><center><font size="3">चालू आठवड्यातील आवक संदर्भ - ';
						$id =$_REQUEST['desk_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="3">'.$from_date.'</font> ते <font size="3">'.$to_date.'</font><//center></td></tr>';
						convert_marathi();
						//accepted by desk
						$result222=mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dsk_id_to,di.dept_id_to, di.dispatched_to, de.ltr_category, de.assign_no FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id WHERE (de.desk_ltr_rec_dt BETWEEN '$id' AND '$id1') AND de.desk_id_from = (SELECT desk_id from login where login_id = '$username')
						AND de.ltr_status!='closed'
						ORDER BY i.ltr_inword_no") or die("eeee".mysql_error());
						
					/*	//not accepted by desk
						$result22212 = mysql_query("SELECT t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document
						FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
						WHERE (t.desk_approval='pending' AND t.sent_to_desk_dt BETWEEN '$id' AND '$id1')
						AND t.desk_id = (SELECT desk_id from login where login_id = '$username')
						order by i.ltr_inword_no desc ") or die("ccccddd".mysql_error()); */
						
						echo"<tr>	
						<th>पोलीस अधीक्षक<br> कार्यालय <br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th>विषय</th>
						<th>कोणाकडून <br>प्राप्त_झाला</th>
						<th>केलेली कार्यवाही</th>
						<th>पत्राची स्थिती </th>
						<th>विभागीय <br>जावक_दिनांक</th>
					</tr>";
						while($test = mysql_fetch_array($result222))
						{
									$desk_ltr_rec_dt 		= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
									$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
									$update_date 		= date('d-m-Y',strtotime($test['update_date']));
									$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
									$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
									// code for split date and arrange according to our need
									//dispose_date is in following format "YYYY-MM-DD" 
									list($year, $month, $day ) =explode("-",$dispose_date);
									$dispose = $day.'-'.$month.'-'.$year;
									list($year, $month, $day ) =explode("-",$update_date);
									$update = $day.'-'.$month.'-'.$year;
									echo "<tr>
											<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
											<td class='center'>".$test['dpt_inword_no']."<br>
												".$dept_rec_date."</td>
											<td class='center'>".$test['desk_ltr_inword_no']."<br>
												".$desk_ltr_rec_dt."</td>
											<td class='center'>".$test['subject']."</td>
											<td class='center'>".$test['sender_name']."</td>";
							////////////////////////////
							if($test['ltr_status']=='')
							{
								echo "<td class='center'>कार्यवाही करणे बाकी </td>";
							}
							else if($test['ltr_status']=='closed')
							{
								echo "<td class='center'>--</td>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td>";
							}
							////////////////////////////////////
							if($test['ltr_status']=='')
							{
								echo "<td class='center'>कार्यवाही करणे बाकी </td>";
							}
							else if($test['ltr_status']=='updated' || $test['ltr_status']=='closed')
							{
								echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='Approve')
							{
								echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred')
							{
								$todpt=$test['dept_id_to'];
								$qq=mysql_query("SELECT dept_nm from  department_master where dept_id='$todpt' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>".$test['ltr_approval']."to<br>".$rr['dept_nm']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred_todesk')
							{
								$todsk=$test['dsk_id_to'];
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>transferred to <br>".$rr['desk_nm']."</td>";
							}
							//////////////////////////////////// 
							 if($test['ltr_status']=='')
							{
								echo "<td class='center'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test['ltr_status']=='updated')
							{
								echo "<td class='center'>".$update_date."</td>";
							}
							else if($test['ltr_status']=='dispatched')
							{
								echo "<td class='center'>".$dispose_date."</td>";
							}
							else if($test['ltr_status']=='closed')
							{
								echo "<td class='center'>--</td>";
							}
							
							echo "</tr>";
						}
						
					/*	while($test1 = mysql_fetch_array($result22212))
						{
								$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
								$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
								$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
								$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
								$rc_date 		= date('d-m-Y',strtotime($test1['receive_dt']));
								// code for split date and arrange according to our need
								//dispose_date is in following format "YYYY-MM-DD" 
								list($year, $month, $day ) =explode("-",$dispose_date);
								$dispose = $day.'-'.$month.'-'.$year;
								list($year, $month, $day ) =explode("-",$update_date);
								$update = $day.'-'.$month.'-'.$year;
								echo "<tr class='gradeX'>
										<td class='center'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
										<td class='center'>".$test1['dpt_inword_no']."<br>
											".$dept_rec_date."</td>
										<td class='center'> डेस्क ने स्वीकारणे बाकी </td>
										<td class='center'>".$test1['subject']."</td>
										<td class='center'>".$test1['sender_name']."</td>";
										
										echo "<td class='center'> कार्यवाही करणे बाकी </td>";
										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['desk_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> <font size="5" color="#59c600">'.$to_date.'</font></p>';
					convert_marathi();
						
					////////current/////////////////////////////////////
					
					//accepted by desk
					$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,di.dept_id_to,di.dsk_id_to
					FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction i ON i.ltr_id = t.ltr_id 
					LEFT OUTER JOIN desk_transaction d ON d.dpt_ltr_id = t.dpt_ltr_id 
					LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
					WHERE (d.desk_ltr_rec_dt BETWEEN '$id' AND '$id1') 
					AND d.desk_id_from = (SELECT desk_id from login where login_id = '$username')
					AND d.ltr_status!='closed'
					ORDER BY i.ltr_inword_no");
					
				/*	//not accepted by desk
					$result22212 = mysql_query("SELECT t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document
					FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
					WHERE (t.desk_approval='pending' AND t.sent_to_desk_dt BETWEEN '$id' AND '$id1')
					AND t.desk_id = (SELECT desk_id from login where login_id = '$username')
					order by i.ltr_inword_no desc ") or die("ccccddd".mysql_error()); */
							
					///////pending/////////////////////////////////////
				/*	//not accepted by desk
					$result234 = 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.desk_approval='pending' AND t.sent_to_desk_dt< '$id')
					AND t.desk_id = (SELECT desk_id from login where login_id = '$username') ORDER BY i.ltr_inword_no"); */
					
					////accepted by desk
					$result235 = 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 d.desk_ltr_rec_dt<'$id' 
					and (t.desk_approval='approve' AND d.ltr_status='')
					AND d.desk_id_from = (SELECT desk_id from login where login_id = '$username') ORDER BY i.ltr_inword_no");
					
					echo"<br><br><table id='dyntable' class='table table-bordered'>";
					echo"<thead>
						<tr>	
						<th class='head0 center'>पोलीस अधीक्षक<br> कार्यालय <br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th class='head1 center'>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th class='head0 center'>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th class='head1 center'>विषय</th>
						<th class='head0 center'>कोणाकडून <br>प्राप्त_झाला</th>
						<th class='head1 center'>केलेली कार्यवाही</th>
						<th class='head0 center'>पत्राची_स्थिती </th>
						<th class='head1 center'>विभागीय <br>जावक_दिनांक</th>
					</tr>
						</thead>";
					while($test = mysql_fetch_array($result222))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test['update_date']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
							$dpt_inward_no=$test['dpt_inword_no'];
							$dptidfrom=$test['dept_id_from'];
							//$dsk=$desknm['desk_nm'];
							if($test['ltr_status']=='closed')
							{
								$q=mysql_query("SELECT rtn_to_dsk from returned_from_desk where dpt_inword_no='$dpt_inward_no' 
								AND returned_from=(SELECT desk_id from login where login_id = '$username') ");
								$result=mysql_fetch_array($q);
								
								if($result['rtn_to_dsk']!='')
								{
									$return_to=$result['rtn_to_dsk'];
									$q1=mysql_query("SELECT desk_nm from desk_master where desk_id='$return_to' ");
									$r=mysql_fetch_array($q1);
									$return_nm=$r['desk_nm'];
								}
								else 
								{
									$q1=mysql_query("SELECT dept_nm from department_master where dept_id='$dptidfrom' ");
									$r=mysql_fetch_array($q1);
									$return_nm=$r['dept_nm'];
								}
							}
							
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr class='gradeX'>
							<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
							<td class='center'>".$test['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'>".$test['desk_ltr_inword_no']."<br>
							".$desk_ltr_rec_dt."</td>
							<td class='center'>".$test['subject']."</td>
							<td class='center'>".$test['sender_name']."</td>";
							
							/////////////////////////////////////////////////////////////
							if($test['ltr_status']=='closed')
							{
								echo "<td class='center'>Letter Return To<br>".$return_nm."</td>";
							}
							else if($test['action_taken']=='' )
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td>";
							}
							/////////////////////////////////////////////////////////
							if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else if($test['ltr_status']=='updated' || $test['ltr_status']=='closed')
							{
								echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='Approve')
							{
								echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred')
							{
								$todpt=$test['dept_id_to'];
								$qq=mysql_query("SELECT dept_nm from  department_master where dept_id='$todpt' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>".$test['ltr_approval']."to<br>".$rr['dept_nm']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred_todesk')
							{
								$todsk=$test['dsk_id_to'];
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>transferred to <br>".$rr['desk_nm']."</td>";
							}
							////////////////////////////////////////////////////////////
							 if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else if($test['ltr_status']=='closed')
							{
								echo "<td class='center'> -- </td>";
							}
							else if ($test['ltr_status']=='updated')
							{
								echo "<td class='center'>".$update_date."</td>";
							}
							else if($test['ltr_status']=='dispatched')
							{
								echo "<td class='center'>".$dispose_date."</td>";
							}
							else
							{
							 echo "<td class='center'>--</td>";
							}
							
							echo "</tr>";
						}
					/*	while($test1 = mysql_fetch_array($result22212))
							{
								$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
								$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
								$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
								$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
								$rc_date 		= date('d-m-Y',strtotime($test1['receive_dt']));
								// code for split date and arrange according to our need
								//dispose_date is in following format "YYYY-MM-DD" 
								list($year, $month, $day ) =explode("-",$dispose_date);
								$dispose = $day.'-'.$month.'-'.$year;
								list($year, $month, $day ) =explode("-",$update_date);
								$update = $day.'-'.$month.'-'.$year;
								echo "<tr class='gradeX'>
										<td class='center'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
										<td class='center'>".$test1['dpt_inword_no']."<br>
											".$dept_rec_date."</td>
										<td class='center'><font color='red'> डेस्क ने स्वीकारणे बाकी </font></td>
										<td class='center'>".$test1['subject']."</td>
										<td class='center'>".$test1['sender_name']."</td>";
										
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
										
										echo "</tr>";
							} */
							//mysql_close();
						
					/*	while($test1 = mysql_fetch_array($result234))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr class='gradeX'>
							<td class='center'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td class='center'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी </font></td>
							<td class='center'>".$test1['subject']."</td>
							<td class='center'>".$test1['sender_name']."</td>";
							if($test1['action_taken']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td class='center'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td class='center'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td class='center'>".$dispose_date."</td>";
								}
								else
							{
							 echo "<td class='center'>--</td>";
							}
							
							echo "</tr>";
						} */
						while($test1 = mysql_fetch_array($result235))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr class='gradeX'>
							<td class='center'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td class='center'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'>".$test1['desk_ltr_inword_no']."<br>".$desk_ltr_rec_dt ."</td>
							<td class='center'>".$test1['subject']."</td>
							<td class='center'>".$test1['sender_name']."</td>";
							if($test1['action_taken']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td class='center'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td class='center'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td class='center'>".$dispose_date."</td>";
								}
							else
							{
							 echo "<td class='center'>--</td>";
							}
							echo "</tr>";
						}
					echo"</table>";
					#################################### Div to print ###################################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>पोलीस अधीक्षक कार्यालय, <br> जि.रायगड</h2></center>';
					echo'<tr><td colspan="9"><center><font size="3">एकूण संदर्भ - ';
					$id =$_REQUEST['desk_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="3">'.$from_date.'</font> ते <font size="3">'.$to_date.'</font></center></td></tr>';
					convert_marathi();
					////////current/////////////////////////////////////
					//accepted by desk
					$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,di.dept_id_to,di.dsk_id_to
					FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction i ON i.ltr_id = t.ltr_id 
					LEFT OUTER JOIN desk_transaction d ON d.dpt_ltr_id = t.dpt_ltr_id 
					LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
					WHERE (d.desk_ltr_rec_dt BETWEEN '$id' AND '$id1') 
					AND d.desk_id_from = (SELECT desk_id from login where login_id = '$username')
					AND d.ltr_status!='closed'
					ORDER BY i.ltr_inword_no");
					
			/*		//not accepted by desk
					$result22212 = mysql_query("SELECT t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document
					FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
					WHERE (t.desk_approval='pending' AND t.sent_to_desk_dt BETWEEN '$id' AND '$id1')
					AND t.desk_id = (SELECT desk_id from login where login_id = '$username')
					order by i.ltr_inword_no desc ") or die("ccccddd".mysql_error()); */
					
					///////pending/////////////////////////////////////
					
				/*	//not accepted by desk
					$result234 = 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.desk_approval='pending' AND t.sent_to_desk_dt< '$id')
					AND t.desk_id = (SELECT desk_id from login where login_id = '$username') ORDER BY i.ltr_inword_no"); */
					
					////accepted by desk
					$result235 = 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 d.desk_ltr_rec_dt<'$id' 
					and (t.desk_approval='approve' AND d.ltr_status='')
					AND d.desk_id_from = (SELECT desk_id from login where login_id = '$username') ORDER BY i.ltr_inword_no");
					echo"<tr>	
						<th>पोलीस अधीक्षक <br>कार्यालय <br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th>विषय</th>
						<th>कोणाकडून <br>प्राप्त_झाला</th>
						<th>केलेली कार्यवाही</th>
						<th>पत्राची स्थिती </th>
						<th>विभागीय <br>जावक_दिनांक</th>
					</tr>";
						
					while($test = mysql_fetch_array($result222))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test['update_date']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
							$dpt_inward_no=$test['dpt_inword_no'];
							$dptidfrom=$test['dept_id_from'];
							//$dsk=$desknm['desk_nm'];
							if($test['ltr_status']=='closed')
							{
								$q=mysql_query("SELECT rtn_to_dsk from returned_from_desk where dpt_inword_no='$dpt_inward_no' 
								AND returned_from=(SELECT desk_id from login where login_id = '$username') ");
								$result=mysql_fetch_array($q);
								
								if($result['rtn_to_dsk']!='')
								{
									$return_to=$result['rtn_to_dsk'];
									$q1=mysql_query("SELECT desk_nm from desk_master where desk_id='$return_to' ");
									$r=mysql_fetch_array($q1);
									$return_nm=$r['desk_nm'];
								}
								else 
								{
									$q1=mysql_query("SELECT dept_nm from department_master where dept_id='$dptidfrom' ");
									$r=mysql_fetch_array($q1);
									$return_nm=$r['dept_nm'];
								}
							}
							
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr class='gradeX'>
							<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
							<td class='center'>".$test['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'>".$test['desk_ltr_inword_no']."<br>
							".$desk_ltr_rec_dt."</td>
							<td class='center'>".$test['subject']."</td>
							<td class='center'>".$test['sender_name']."</td>";
							
							/////////////////////////////////////////////////////////////
							if($test['ltr_status']=='closed')
							{
								echo "<td class='center'>Letter Return To<br>".$return_nm."</td>";
							}
							else if($test['action_taken']=='' )
							{
								echo "<td class='center'> कार्यवाही करणे बाकी </td>";
							}
							else if($test['ltr_status']=='')
							{
								echo "<td class='center'> कार्यवाही करणे बाकी </td>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td>";
							}
							/////////////////////////////////////////////////////////
							if($test['ltr_status']=='')
							{
								echo "<td class='center'>कार्यवाही करणे बाकी </td>";
							}
							else if($test['ltr_status']=='updated' || $test['ltr_status']=='closed')
							{
								echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='Approve')
							{
								echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred')
							{
								$todpt=$test['dept_id_to'];
								$qq=mysql_query("SELECT dept_nm from  department_master where dept_id='$todpt' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>".$test['ltr_approval']."to<br>".$rr['dept_nm']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred_todesk')
							{
								$todsk=$test['dsk_id_to'];
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>transferred to <br>".$rr['desk_nm']."</td>";
							}
							////////////////////////////////////////////////////////////
							 if($test['ltr_status']=='')
							{
								echo "<td class='center'>कार्यवाही करणे बाकी </td>";
							}
							else if($test['ltr_status']=='closed')
							{
								echo "<td class='center'> -- </td>";
							}
							else if ($test['ltr_status']=='updated')
							{
								echo "<td class='center'>".$update_date."</td>";
							}
							else if($test['ltr_status']=='dispatched')
							{
								echo "<td class='center'>".$dispose_date."</td>";
							}
							else
							{
								echo "<td class='center'>--</td>";
							}
							
							echo "</tr>";
						}
						
					/*	while($test1 = mysql_fetch_array($result22212))
							{
								$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
								$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
								$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
								$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
								$rc_date 		= date('d-m-Y',strtotime($test1['receive_dt']));
								// code for split date and arrange according to our need
								//dispose_date is in following format "YYYY-MM-DD" 
								list($year, $month, $day ) =explode("-",$dispose_date);
								$dispose = $day.'-'.$month.'-'.$year;
								list($year, $month, $day ) =explode("-",$update_date);
								$update = $day.'-'.$month.'-'.$year;
								echo "<tr class='gradeX'>
										<td class='center'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
										<td class='center'>".$test1['dpt_inword_no']."<br>
											".$dept_rec_date."</td>
										<td class='center'> डेस्क ने स्वीकारणे बाकी </td>
										<td class='center'>".$test1['subject']."</td>
										<td class='center'>".$test1['sender_name']."</td>";
										
										echo "<td class='center'> कार्यवाही करणे बाकी </td>";
										echo "<td class='center'> कार्यवाही करणे बाकी </td>";
										echo "<td class='center'> कार्यवाही करणे बाकी </td>";
										
										echo "</tr>";
							} */
							//mysql_close();
							
					/*	while($test1 = mysql_fetch_array($result234))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr class='gradeX'>
							<td class='center'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td class='center'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'> डेस्कने स्वीकारणे बाकी </td>
							<td class='center'>".$test1['subject']."</td>
							<td class='center'>".$test1['sender_name']."</td>";
							if($test1['action_taken']=='')
							{
								echo "<td class='center'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
								echo "<td class='center'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td class='center'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
							 echo "<td class='center'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td class='center'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td class='center'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td class='center'>--</td>";
							}
							
							echo "</tr>";
						} */
						
						while($test1 = mysql_fetch_array($result235))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr class='gradeX'>
							<td class='center'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td class='center'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'>".$test1['desk_ltr_inword_no']."<br>".$desk_ltr_rec_dt ."</td>
							<td class='center'>".$test1['subject']."</td>
							<td class='center'>".$test1['sender_name']."</td>";
							if($test1['action_taken']=='')
							{
								echo "<td class='center'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
								echo "<td class='center'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td class='center'> कार्यवाही करणे बाकी </td>";
							}
							else
							{
							 echo "<td class='center'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td class='center'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td class='center'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td class='center'>--</td>";
							}
							
							echo "</tr>";
						}
					echo"</table></center>
					</div>";
				}	
				
				################################################## Updated Letters ###########################
			/*else if($no == '04')
			{
				echo'<br><br><p align="center"><font size="5" color="#00a0ee">Updated  - ';
				$id =$_REQUEST['desk_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 de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id WHERE  de.desk_id_from=(Select desk_id from login where login_id='$username') AND de.update_date BETWEEN '$id' AND '$id1'") or die("".mysql_error()); 
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
				<tr>	
						<th class='head0 center'>पोलीस अधीक्षक कार्यालय,<br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th class='head1 center'>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th class='head0 center'>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th class='head1 center'>विषय</th>
						<th class='head0 center'>कोणाकडून <br>प्राप्त_झाला</th>
						<th class='head1 center'>केलेली कार्यवाही</th>
						<th class='head0 center'>पत्राची_स्थिती </th>
						<th class='head1 center'>विभागीय <br>जावक_दिनांक</th>
					</tr>
				</thead>";
				while($test = mysql_fetch_array($result222))
					{
						$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
						$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
						$update_date 		= date('d-m-Y',strtotime($test['update_date']));
						$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
						$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
						
						// code for split date and arrange according to our need
						//dispose_date is in following format "YYYY-MM-DD" 
						list($year, $month, $day ) =explode("-",$dispose_date);
						$dispose = $day.'-'.$month.'-'.$year;
						
						list($year, $month, $day ) =explode("-",$update_date);
						$update = $day.'-'.$month.'-'.$year;
						echo "<tr>
						<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
						<td class='center'>".$test['dpt_inword_no']."<br>
						".$dept_rec_date."</td>
						<td class='center'>".$test['desk_ltr_inword_no']."<br>
						".$desk_ltr_rec_dt."</td>
						<td class='center'>".$test['subject']."</td>
						<td class='center'>".$test['sender_name']."</td>";
							if($test['action_taken']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td>";
							}
							
							if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td class='center'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td class='center'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
					}
				echo"</table>";
				
				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> जि.रायगड </font></h2></center>';
				echo'<tr><td colspan="9"><center><font size="3">Updated  - ';
				$id =$_REQUEST['desk_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="3">'.$from_date.'</font> ते <font size="3">'.$to_date.'</font>';
				'</font></center></td></tr>';
				convert_marathi();
				$result222 = mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id WHERE  de.desk_id_from=(Select desk_id from login where login_id='$username') AND de.update_date BETWEEN '$id' AND '$id1'") or die("".mysql_error()); 
				echo"<tr>	
						<th>पोलीस अधीक्षक <br>कार्यालय <br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th>विषय</th>
						<th>कोणाकडून <br>प्राप्त_झाला</th>
						<th>केलेली कार्यवाही</th>
						<th>पत्राची स्थिती </th>
						<th>विभागीय <br>जावक_दिनांक</th>
					</tr>";
				while($test = mysql_fetch_array($result222))
					{
						$desk_ltr_rec_dt 		= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
						$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
						$update_date 		= date('d-m-Y',strtotime($test['update_date']));
						$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
						$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
						
						// code for split date and arrange according to our need
						//dispose_date is in following format "YYYY-MM-DD" 
						list($year, $month, $day ) =explode("-",$dispose_date);
						$dispose = $day.'-'.$month.'-'.$year;
						
						list($year, $month, $day ) =explode("-",$update_date);
						$update = $day.'-'.$month.'-'.$year;
						echo "<tr>
						<td style='text-align:center;'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
						<td style='text-align:center;'>".$test['dpt_inword_no']."<br>
						".$dept_rec_date."</td>
						<td style='text-align:center;'>".$test['desk_ltr_inword_no']."<br>
						".$desk_ltr_rec_dt."</td>
						<td style='text-align:center;'>".$test['subject']."</td>
						<td style='text-align:center;'>".$test['sender_name']."</td>
						<td style='text-align:center;'>".$test['action_taken']."</td>
						<td style='text-align:center;'>".$test['ltr_status']."</td>";
						if ($test['ltr_status']=='updated')
							{
								echo "<td style='text-align:center;'>".$update_date."</td>";
							}
						else if($test['ltr_status']=='dispatched')
							{
								echo "<td style='text-align:center;'>".$dispose_date."</td>";
							}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
						echo "</tr>";
					}
				echo"</table></center></div>";
			} */
			
			############################################  Dispatched/updated Letters ############################
			else if($no == '05')
			{
				echo'<br><br><p align="center"><font size="5" color="#00a0ee">एकूण निर्गत संदर्भ - ';
				$id =$_REQUEST['desk_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 de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no ,di.dept_id_to,di.dsk_id_to
				FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id 
				WHERE  (
							de.dispatched_dt BETWEEN '$id' AND '$id1'
							OR de.update_date BETWEEN '$id' AND '$id1'
						) 
				AND de.desk_id_from=(Select desk_id from login where login_id='$username')") or die("".mysql_error()); 
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
				<tr>	
						<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय<br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th class='head1 center'>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th class='head0 center'>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th class='head1 center'>विषय</th>
						<th class='head0 center'>कोणाकडून <br>प्राप्त_झाला</th>
						<th class='head1 center'>केलेली कार्यवाही</th>
						<th class='head0 center'>पत्राची_स्थिती </th>
						<th class='head1 center'>विभागीय <br>जावक_दिनांक</th>
					</tr>
				</thead>
				<tbody>";
				while($test = mysql_fetch_array($result222))
				{
					$desk_ltr_rec_dt 		= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
					$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
					$update_date 		= date('d-m-Y',strtotime($test['update_date']));
					$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
					$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
				
					// code for split date and arrange according to our need
					//dispose_date is in following format "YYYY-MM-DD" 
					list($year, $month, $day ) =explode("-",$dispose_date);
					$dispose = $day.'-'.$month.'-'.$year;
					
					list($year, $month, $day ) =explode("-",$update_date);
					$update = $day.'-'.$month.'-'.$year;
					echo "<tr class='gradeX'>
					<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
					<td class='center'>".$test['dpt_inword_no']."<br>
					".$dept_rec_date."</td>
					<td class='center'>".$test['desk_ltr_inword_no']."<br>
					".$desk_ltr_rec_dt."</td>
					<td class='center'>".$test['subject']."</td>
					<td class='center'>".$test['sender_name']."</td>";
					if($test['action_taken']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td>";
							}
							//////////////////////////////////////////////////////////////////////
							if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred')
							{
								$todpt=$test['dept_id_to'];
								$qq=mysql_query("SELECT dept_nm from  department_master where dept_id='$todpt' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>".$test['ltr_approval']."to<br>".$rr['dept_nm']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred_todesk')
							{
								$todsk=$test['dsk_id_to']; 
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>transferred to <br>".$rr['desk_nm']."</td>";
							}
							else 
							{
								echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							///////////////////////////////////////////////////////
							if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td class='center'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td class='center'>".$dispose_date."</td>";
								}
							echo "</tr>";
				}
				
				echo "</tbody></table>";
							################################## Div to print ##########################
				echo "<div id='divToPrint' style='display:none;'>";
				
				echo ' <center><h2><font color="black">पोलीस अधीक्षक  कार्यालय <br>जि.रायगड</font></h2></center>';
				echo "<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							echo'<tr><td colspan="8"><center><font size="3">एकूण निर्गत संदर्भ - ';
						$id =$_REQUEST['desk_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="3">'.$from_date.'</font> ते <font size="3">'.$to_date.'</font>';
							'</font></center></td></tr>';
						convert_marathi();
						$result222 = mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no ,di.dept_id_to,di.dsk_id_to
						FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id 
						WHERE  (
									de.dispatched_dt BETWEEN '$id' AND '$id1'
									OR de.update_date BETWEEN '$id' AND '$id1'
								) 
						AND de.desk_id_from=(Select desk_id from login where login_id='$username')") or die("".mysql_error()); 
						echo "<tr>	
							<th>पोलीस अधीक्षक <br> कार्यालय<br>आवक_क्रमांक<br>आवक_दिनांक</th>
							<th>विभागीय आवक_क्रमांक<br>दिनांक</th>
							<th>डेस्क आवक_क्रमांक<br>दिनांक</th>
							<th>विषय</th>
							<th>कोणाकडून <br>प्राप्त_झाला</th>
							<th>केलेली कार्यवाही</th>
							<th>पत्राची स्थिती </th>
							<th>विभागीय <br>जावक_दिनांक</th>
						</tr>";
				while($test = mysql_fetch_array($result222))
				{
					$desk_ltr_rec_dt 		= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
					$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
					$update_date 		= date('d-m-Y',strtotime($test['update_date']));
					$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
					$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
				
					// code for split date and arrange according to our need
					//dispose_date is in following format "YYYY-MM-DD" 
					list($year, $month, $day ) =explode("-",$dispose_date);
					$dispose = $day.'-'.$month.'-'.$year;
					
					list($year, $month, $day ) =explode("-",$update_date);
					$update = $day.'-'.$month.'-'.$year;
					echo "<tr class='gradeX'>
					<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
					<td class='center'>".$test['dpt_inword_no']."<br>
					".$dept_rec_date."</td>
					<td class='center'>".$test['desk_ltr_inword_no']."<br>
					".$desk_ltr_rec_dt."</td>
					<td class='center'>".$test['subject']."</td>
					<td class='center'>".$test['sender_name']."</td>";
					if($test['action_taken']=='')
							{
								echo "<td class='center'> कार्यवाही करणे बाकी </td>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td>";
							}
							//////////////////////////////////////////////////////////////////////
							if($test['ltr_status']=='')
							{
								echo "<td class='center'> कार्यवाही करणे बाकी </td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred')
							{
								$todpt=$test['dept_id_to'];
								$qq=mysql_query("SELECT dept_nm from  department_master where dept_id='$todpt' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>".$test['ltr_approval']."to<br>".$rr['dept_nm']."</td>";
							}
							else if($test['ltr_status']=='dispatched' && $test['ltr_approval']=='transferred_todesk')
							{
								$todsk=$test['dsk_id_to']; 
								$qq=mysql_query("SELECT desk_nm from  desk_master where desk_id='$todsk' ");
								$rr=mysql_fetch_array($qq);
								echo "<td class='center'>transferred to <br>".$rr['desk_nm']."</td>";
							}
							else 
							{
								echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							///////////////////////////////////////////////////////
							if($test['ltr_status']=='')
							{
								echo "<td class='center'> कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td class='center'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td class='center'>".$dispose_date."</td>";
								}
							echo "</tr>";
				}
					echo "</table></center>";
				echo "</div>";
			}
				

			####################################### Total Pending References ################################
			else if($no == '10')
			{
				echo'<br><br><p align="center"><font size="6" color="#00a0ee">एकूण शिल्लक संदर्भ - ';
				$id =$_REQUEST['desk_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 desk
				$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 d.desk_id_from=(select desk_id from login where login_id='$username') 
				AND d.desk_ltr_rec_dt <='$id1' 
				AND d.ltr_status = ''") or die("".mysql_error());
				
			/*	//not accepted by desk
				$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, 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.desk_approval='pending' AND t.sent_to_desk_dt<='$id1')
				AND t.desk_id = (SELECT desk_id from login where login_id = '$username')") or die("bb".mysql_error()); */
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
					<tr>	
						<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय<br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th class='head1 center'>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th class='head0 center'>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th class='head1 center'>विषय</th>
						<th class='head0 center'>कोणाकडून <br>प्राप्त_झाला</th>
						<th class='head1 center'>केलेली कार्यवाही</th>
						<th class='head0 center'>पत्राची_स्थिती </th>
						<th class='head1 center'>विभागीय <br>जावक_दिनांक</th>
					</tr>
				</thead>
				<tbody>";
				while($test = mysql_fetch_array($result222))
					{
						$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
						$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
						$update_date 		= date('d-m-Y',strtotime($test['update_date']));
						$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
						$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
						
						// code for split date and arrange according to our need
						//dispose_date is in following format "YYYY-MM-DD" 
						list($year, $month, $day ) =explode("-",$dispose_date);
						$dispose = $day.'-'.$month.'-'.$year;
						
						list($year, $month, $day ) =explode("-",$update_date);
						$update = $day.'-'.$month.'-'.$year;
						
						//echo $dispose;
						
						//$id1 = $test['inward_no'];	
						echo "<tr class='gradeX'>
						<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
						<td class='center'>".$test['dpt_inword_no']."<br>
						".$dept_rec_date."</td>
						<td class='center'>".$test['desk_ltr_inword_no']."<br>
						".$desk_ltr_rec_dt."</td>
						<td class='center'>".$test['subject']."</td>
						<td class='center'>".$test['sender_name']."</td>";
							if($test['action_taken']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else if($test['ltr_satus']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td>";
							}
							
							if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td class='center'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td class='center'd>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
					}
				//mysql_close();
					
				/*	while($test1 = mysql_fetch_array($result2221))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr>
							<td style='text-align:center;'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td style='text-align:center;'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'><font color='red'> डेस्कने स्वीकारणे बाकी </font></td>
							<td style='text-align:center;'>".$test1['subject']."</td>
							<td style='text-align:center;'>".$test1['sender_name']."</td>";
								if($test1['action_taken']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
						} */
				echo"</tbody></table>";
				
				
				echo "<div id='divToPrint' style='display:none;'>";
					echo ' <center><h2><font color="black">पोलीस अधीक्षक  कार्यालय <br> जि.रायगड </font></h2></center>';
					
					echo "	<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							echo'<tr><td colspan="9"><center><font size="3">एकूण शिल्लक संदर्भ - ';
				$id =$_REQUEST['desk_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="3">'.$from_date.'</font> ते <font size="3">'.$to_date.'</font></center></td></tr>';
				$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 desk
				$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 d.desk_id_from=(select desk_id from login where login_id='$username') 
				AND d.desk_ltr_rec_dt <='$id1' 
				AND d.ltr_status = ''") or die("".mysql_error());
				
			/*	//not accepted by desk
				$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, 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.desk_approval='pending' AND t.sent_to_desk_dt<='$id1')
				AND t.desk_id = (SELECT desk_id from login where login_id = '$username')") or die("bb".mysql_error()); */
				echo"<tr>	
						<th>पोलीस अधीक्षक <br> कार्यालय<br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th>विषय</th>
						<th>कोणाकडून <br>प्राप्त_झाला</th>
						<th>केलेली कार्यवाही</th>
						<th>पत्राची स्थिती </th>
						<th>विभागीय <br>जावक_दिनांक</th>
					</tr>";
				while($test = mysql_fetch_array($result222))
					{
						$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
						$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
						$update_date 		= date('d-m-Y',strtotime($test['update_date']));
						$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
						$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
						
						// code for split date and arrange according to our need
						//dispose_date is in following format "YYYY-MM-DD" 
						list($year, $month, $day ) =explode("-",$dispose_date);
						$dispose = $day.'-'.$month.'-'.$year;
						
						list($year, $month, $day ) =explode("-",$update_date);
						$update = $day.'-'.$month.'-'.$year;
							
						echo "<tr>
						<td style='text-align:center;'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
						<td style='text-align:center;'>".$test['dpt_inword_no']."<br>
						".$dept_rec_date."</td>
						<td style='text-align:center;'>".$test['desk_ltr_inword_no']."<br>
						".$desk_ltr_rec_dt."</td>
						<td style='text-align:center;'>".$test['subject']."</td>
						<td style='text-align:center;'>".$test['sender_name']."</td>";
						if($test['action_taken']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else if($test['ltr_satus']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test['action_taken']."</td>";
							}
							
							if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
					}
				//mysql_close();
				
				/*	while($test1 = mysql_fetch_array($result2221))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr>
							<td style='text-align:center;'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td style='text-align:center;'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'>डेस्कने स्वीकारणे बाकी</td>
							<td style='text-align:center;'>".$test1['subject']."</td>
							<td style='text-align:center;'>".$test1['sender_name']."</td>";
								if($test1['action_taken']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
						} */
				echo"</table></center></div>";
			}
			
			
			########################################### Pending References From 1 Week ##############################
			if($no == '06')
			{
				echo'<br><br><p align="center"><font size="6" color="#00a0ee">एका आठवड्यातील शिल्लक संदर्भ - '. '</font>';
				//	include("db.php");
				$id =$_REQUEST['desk_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="6" color="#59c600">'.$from_date.'</font> <font size="6" color="#00a0ee">ते </font><font size="6" color="#59c600">'.$to_date.'</font>';
					'</p>';
	
			//accepted by desk
			$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 (
					d.desk_ltr_rec_dt BETWEEN '$id' AND '$id1' 
					AND ( 
							(d.ltr_category='' AND d.ltr_status='')
							 OR (d.ltr_status='')
						)
				) AND d.desk_id_from=(SELECT desk_id from login where login_id = '$username') ")or die("abaaaaa".mysql_error()) ;
			
		/*	//not accepted by desk
			$result222x=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.desk_approval='pending' AND t.sent_to_desk_dt BETWEEN '$id' AND '$id1')
			AND t.desk_id = (SELECT desk_id from login where login_id = '$username')
			AND sent_to_desk_dt BETWEEN '$id' AND '$id1'  ")or die("abaaaaa".mysql_error()) ; */
			
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
				<tr>	
						<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय<br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th class='head1 center'>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th class='head0 center'>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th class='head1 center'>विषय</th>
						<th class='head0 center'>कोणाकडून <br>प्राप्त_झाला</th>
						<th class='head1 center'>केलेली कार्यवाही</th>
						<th class='head0 center'>पत्राची_स्थिती </th>
						<th class='head1 center'>विभागीय <br>जावक_दिनांक</th>
					</tr>
				</thead>";
				while($test = mysql_fetch_array($result222))
				{
					$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
					$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
					$update_date 		= date('d-m-Y',strtotime($test['update_date']));
					$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
					$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
					
					// code for split date and arrange according to our need
					//dispose_date is in following format "YYYY-MM-DD" 
					list($year, $month, $day ) =explode("-",$dispose_date);
					$dispose = $day.'-'.$month.'-'.$year;
					
					list($year, $month, $day ) =explode("-",$update_date);
					$update = $day.'-'.$month.'-'.$year;
					
					//echo $dispose;
					
					//$id1 = $test['inward_no'];	
					echo "<tr>
					<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
					<td class='center'>".$test['dpt_inword_no']."<br>
					".$dept_rec_date."</td>
					<td class='center'>".$test['desk_ltr_inword_no']."<br>
					".$desk_ltr_rec_dt."</td>
					<td class='center'>".$test['subject']."</td>
					<td class='center'>".$test['sender_name']."</td>";
						if($test['action_taken']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td>";
							}
							
							if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td class='center'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td class='center'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
				}
				//mysql_close();
				/*		while($test1 = mysql_fetch_array($result222x))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr>
							<td style='text-align:center;'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td style='text-align:center;'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'><font color='red'> डेस्कने स्वीकारणे बाकी </font></td>
							<td style='text-align:center;'>".$test1['subject']."</td>
							<td style='text-align:center;'>".$test1['sender_name']."</td>";
								if($test1['action_taken']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
						} */
				echo"</table>";
				echo "<div id='divToPrint' style='display:none;'>";
				
				echo ' <center><h2><font color="black">पोलीस अधीक्षक  कार्यालय <br> जि.रायगड </font></h2></center>';
				echo"	<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							echo'<tr><td colspan="8"><center><font size="3">एका आठवड्यातील शिल्लक संदर्भ - ';
				//	include("db.php");
				$id =$_REQUEST['desk_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><font size="3">'.$to_date.'</font>';
					'</center></td></tr>';
	
				//accepted by desk
			$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 (
					d.desk_ltr_rec_dt BETWEEN '$id' AND '$id1' 
					AND ( 
							(d.ltr_category='' AND d.ltr_status='')
							 OR (d.ltr_status='')
						)
				) AND d.desk_id_from=(SELECT desk_id from login where login_id = '$username') ")or die("abaaaaa".mysql_error()) ;
			
		/*	//not accepted by desk
			$result222x=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.desk_approval='pending' AND t.sent_to_desk_dt BETWEEN '$id' AND '$id1')
			AND t.desk_id = (SELECT desk_id from login where login_id = '$username')
			AND sent_to_desk_dt BETWEEN '$id' AND '$id1'  ")or die("abaaaaa".mysql_error()) ; */
				echo"<tr>	
						<th>पोलीस अधीक्षक <br> कार्यालय<br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th>विषय</th>
						<th>कोणाकडून <br>प्राप्त_झाला</th>
						<th>केलेली कार्यवाही</th>
						<th>पत्राची स्थिती </th>
						<th>विभागीय <br>जावक_दिनांक</th>
					</tr>";
				while($test = mysql_fetch_array($result222))
				{
					$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
					$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
					$update_date 		= date('d-m-Y',strtotime($test['update_date']));
					$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
					$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
					
					// code for split date and arrange according to our need
					//dispose_date is in following format "YYYY-MM-DD" 
					list($year, $month, $day ) =explode("-",$dispose_date);
					$dispose = $day.'-'.$month.'-'.$year;
					
					list($year, $month, $day ) =explode("-",$update_date);
					$update = $day.'-'.$month.'-'.$year;	
					echo "<tr>
					<td style='text-align:center;'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
					<td style='text-align:center;'>".$test['dpt_inword_no']."<br>
					".$dept_rec_date."</td>
					<td style='text-align:center;'>".$test['desk_ltr_inword_no']."<br>
					".$desk_ltr_rec_dt."</td>
					<td style='text-align:center;'>".$test['subject']."</td>
					<td style='text-align:center;'>".$test['sender_name']."</td>";
					if($test['action_taken']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test['action_taken']."</td>";
							}
							
							if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
				}
				//mysql_close();
				/*		while($test1 = mysql_fetch_array($result222x))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr>
							<td style='text-align:center;'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td style='text-align:center;'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'>डेस्कने स्वीकारणे बाकी</td>
							<td style='text-align:center;'>".$test1['subject']."</td>
							<td style='text-align:center;'>".$test1['sender_name']."</td>";
								if($test1['action_taken']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
						} */
				echo"</table></center></div>";
			}
			
			
			
			
			
			#################################### Pending References From 2 Weeks #################################
			if($no == '07')
			{
				echo'<br><br><p align="center"><font size="6" color="#00a0ee">दोन आठवड्यातील शिल्लक संदर्भ - ';
				//	include("db.php");
				$id =$_REQUEST['desk_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 desk
				$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 (	d.desk_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY) AND '$prev_date')  
				AND ( 
						(d.ltr_category='' AND d.ltr_status='')
						 OR (d.ltr_status='')
					)
				AND d.desk_id_from = (SELECT t.desk_id from login where login_id = '$username')") or die("".mysql_error());
			
			/*	//not accepted by desk
				$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, 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.desk_approval='pending'
				AND t.desk_id = ( SELECT desk_id from login where login_id = '$username' )
				AND t.sent_to_desk_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY) AND '$prev_date'") or die("".mysql_error()); */
				
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
				<tr>	
						<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय<br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th class='head1 center'>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th class='head0 center'>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th class='head1 center'>विषय</th>
						<th class='head0 center'>कोणाकडून <br>प्राप्त_झाला</th>
						<th class='head1 center'>केलेली कार्यवाही</th>
						<th class='head0 center'>पत्राची_स्थिती </th>
						<th class='head1 center'>विभागीय <br>जावक_दिनांक</th>
					</tr>
				</thead>
				<tbody>";
					while($test = mysql_fetch_array($result222))
					{
						$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
						$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
						$update_date 		= date('d-m-Y',strtotime($test['update_date']));
						$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
						$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
						
						// code for split date and arrange according to our need
						//dispose_date is in following format "YYYY-MM-DD" 
						list($year, $month, $day ) =explode("-",$dispose_date);
						$dispose = $day.'-'.$month.'-'.$year;
						
						list($year, $month, $day ) =explode("-",$update_date);
						$update = $day.'-'.$month.'-'.$year;
						echo "<tr class='gradeX'>
						<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
						<td class='center'>".$test['dpt_inword_no']."<br>
						".$dept_rec_date."</td>
						<td class='center'>".$test['desk_ltr_inword_no']."<br>
						".$desk_ltr_rec_dt."</td>
						<td class='center'>".$test['subject']."</td>
						<td class='center'>".$test['sender_name']."</td>";
							if($test['action_taken']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td>";
							}
							
							if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td class='center'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td class='center'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
					}
					
				/*		while($test1 = mysql_fetch_array($result2221))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr>
							<td style='text-align:center;'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td style='text-align:center;'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'><font color='red'> डेस्कने स्वीकारणे बाकी </font></td>
							<td style='text-align:center;'>".$test1['subject']."</td>
							<td style='text-align:center;'>".$test1['sender_name']."</td>";
								if($test1['action_taken']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
						} */
					echo"</tbody></table>";
					
					################################### Div TO Print #############################
					echo "<div id='divToPrint' style='display:none;'>";
					
					echo ' <center><h2><font color="black">पोलीस अधीक्षक कार्यालय <br>जि.रायगड </font></h2></center>';
					echo "	<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							echo'<tr><td colspan="8"><center><font size="3">दोन आठवड्यातील शिल्लक संदर्भ - ';
				//	include("db.php");
				$id =$_REQUEST['desk_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="3">'.$from_date.'</font> ते <font size="3">'.$to_date.'</font>';
					'</font></center></td></tr>';
				$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 desk
				$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 (	d.desk_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$prev_date')  
				AND ( 
						(d.ltr_category='' AND d.ltr_status='')
						 OR (d.ltr_status='')
					)
				AND d.desk_id_from = (SELECT t.desk_id from login where login_id = '$username')") or die("".mysql_error());
			
			/*	//not accepted by desk
				$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, 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.desk_approval='pending'
				AND t.desk_id = ( SELECT desk_id from login where login_id = '$username' )
				AND t.sent_to_desk_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY) AND '$prev_date'") or die("".mysql_error()); */
				
				echo"<tr>	
						<th>पोलीस अधीक्षक <br> कार्यालय<br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th>विषय</th>
						<th>कोणाकडून <br>प्राप्त_झाला</th>
						<th>केलेली कार्यवाही</th>
						<th>पत्राची स्थिती </th>
						<th>विभागीय <br>जावक_दिनांक</th>
					</tr>";
			while($test = mysql_fetch_array($result222))
			{
				$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
				$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
				$update_date 		= date('d-m-Y',strtotime($test['update_date']));
				$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
				$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
				
				// code for split date and arrange according to our need
				//dispose_date is in following format "YYYY-MM-DD" 
				list($year, $month, $day ) =explode("-",$dispose_date);
				$dispose = $day.'-'.$month.'-'.$year;
				
				list($year, $month, $day ) =explode("-",$update_date);
				$update = $day.'-'.$month.'-'.$year;
				echo "<tr>
				<td style='text-align:center;'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
				<td style='text-align:center;'>".$test['dpt_inword_no']."<br>
				".$dept_rec_date."</td>
				<td style='text-align:center;'>".$test['desk_ltr_inword_no']."<br>
				".$desk_ltr_rec_dt."</td>
				<td style='text-align:center;'>".$test['subject']."</td>
				<td style='text-align:center;'>".$test['sender_name']."</td>";
						
							if($test['action_taken']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test['action_taken']."</td>";
							}
							
							if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
			}
			//mysql_close();
						
					/*	while($test1 = mysql_fetch_array($result2221))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr>
							<td style='text-align:center;'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td style='text-align:center;'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'>डेस्कने स्वीकारणे बाकी</td>
							<td style='text-align:center;'>".$test1['subject']."</td>
							<td style='text-align:center;'>".$test1['sender_name']."</td>";
								if($test1['action_taken']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
						} */
			echo "</table></center></div>";
		}
		########################################### Pending References From 3 Weeks #################################
		else if($no == '08')
		{
				echo'<br><br><p align="center"><font size="6" color="#00a0ee">तीन आठवड्यातील शिल्लक संदर्भ - ';
				//	include("db.php");
				$id =$_REQUEST['desk_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');	
				
			
			//accepted by desk
			$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 (	d.desk_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY))  
			AND ( 
					(d.ltr_category='' AND d.ltr_status='')
					OR (d.ltr_status='')
				)
			AND d.desk_id_from = (SELECT desk_id from login where login_id = '$username')") or die("bbbb".mysql_error());
			
		/*	//not accepted by desk
			$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, 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.desk_approval='pending'
			AND t.desk_id = ( SELECT desk_id from login where login_id = '$username' )
			AND t.sent_to_desk_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)") or die("bbbb".mysql_error());  */
			
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
				<tr>	
						<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय<br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th class='head1 center'>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th class='head0 center'>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th class='head1 center'>विषय</th>
						<th class='head0 center'>कोणाकडून <br>प्राप्त_झाला</th>
						<th class='head1 center'>केलेली कार्यवाही</th>
						<th class='head0 center'>पत्राची_स्थिती </th>
						<th class='head1 center'>विभागीय <br>जावक_दिनांक</th>
					</tr>
				</thead>";
				while($test = mysql_fetch_array($result222))
				{
					$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
					$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
					$update_date 		= date('d-m-Y',strtotime($test['update_date']));
					$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
					$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
					
					// code for split date and arrange according to our need
					//dispose_date is in following format "YYYY-MM-DD" 
					list($year, $month, $day ) =explode("-",$dispose_date);
					$dispose = $day.'-'.$month.'-'.$year;
					
					list($year, $month, $day ) =explode("-",$update_date);
					$update = $day.'-'.$month.'-'.$year;

					echo "<tr>
					<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
					<td class='center'>".$test['dpt_inword_no']."<br>
					".$dept_rec_date."</td>
					<td class='center'>".$test['desk_ltr_inword_no']."<br>
					".$desk_ltr_rec_dt."</font></td>
					<td class='center'>".$test['subject']."</font></td>
					<td class='center'>".$test['sender_name']."</td>";
						if($test['action_taken']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td>";
							}
							
							if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td class='center'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td class='center'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
				}
				//mysql_close();
					
				/*		while($test1 = mysql_fetch_array($result2221))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr>
							<td style='text-align:center;'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td style='text-align:center;'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'><font color='red'> डेस्कने स्वीकारणे बाकी </font></td>
							<td style='text-align:center;'>".$test1['subject']."</td>
							<td style='text-align:center;'>".$test1['sender_name']."</td>";
								if($test1['action_taken']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							else if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
						}  */
				echo"</table>";
				
				############################### Print TO div ##########################
				echo "<div id='divToPrint' style='display:none;'>";
						
						echo ' <center><h2><font color="black">पोलीस अधीक्षक कार्यालय <br>जि.रायगड </font></h2></center>';
						echo	"<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							echo '<tr><td colspan="8"><center><font size="3">तीन आठवड्यातील शिल्लक संदर्भ - ';
				//	include("db.php");
				$id =$_REQUEST['desk_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="3">'.$from_date.'</font> ते <font size="3">'.$to_date.'</font>';
					'</font></center></td></tr>';
				
				$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 desk
			$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 (	d.desk_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY))  
			AND ( 
					(d.ltr_category='' AND d.ltr_status='')
					OR (d.ltr_status='')
				)
			AND d.desk_id_from = (SELECT desk_id from login where login_id = '$username')") or die("bbbb".mysql_error());
			
		/*	//not accepted by desk
			$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, 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.desk_approval='pending'
			AND t.desk_id = ( SELECT desk_id from login where login_id = '$username' )
			AND t.sent_to_desk_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)") or die("bbbb".mysql_error()); */
				echo"<tr>	
						<th>पोलीस अधीक्षक <br> कार्यालय<br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th>विषय</th>
						<th>कोणाकडून <br>प्राप्त_झाला</th>
						<th>केलेली कार्यवाही</th>
						<th>पत्राची स्थिती </th>
						<th>विभागीय <br>जावक_दिनांक</th>
					</tr>";
				while($test = mysql_fetch_array($result222))
				{
					$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
					$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
					$update_date 		= date('d-m-Y',strtotime($test['update_date']));
					$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
					$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
					
					// code for split date and arrange according to our need
					//dispose_date is in following format "YYYY-MM-DD" 
					list($year, $month, $day ) =explode("-",$dispose_date);
					$dispose = $day.'-'.$month.'-'.$year;
					
					list($year, $month, $day ) =explode("-",$update_date);
					$update = $day.'-'.$month.'-'.$year;

					echo "<tr>
					<td style='text-align:center;'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
					<td style='text-align:center;'>".$test['dpt_inword_no']."<br>
					".$dept_rec_date."</td>
					<td style='text-align:center;'>".$test['desk_ltr_inword_no']."<br>
					".$desk_ltr_rec_dt."</font></td>
					<td style='text-align:center;'>".$test['subject']."</font></td>
					<td style='text-align:center;'>".$test['sender_name']."</td>";
					if($test['action_taken']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
						else if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}	
							else
							{
								echo "<td style='text-align:center;'>".$test['action_taken']."</td>";
							}
							
							if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी</td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
				}
				//mysql_close();
					
					/*	while($test1 = mysql_fetch_array($result2221))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr>
							<td style='text-align:center;'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td style='text-align:center;'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'>डेस्कने स्वीकारणे बाकी</td>
							<td style='text-align:center;'>".$test1['subject']."</td>
							<td style='text-align:center;'>".$test1['sender_name']."</td>";
								if($test1['action_taken']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
						} */
				echo"</table></center></div>";
			}
	################################### Pending References From More Then 3 Weeks #############################
			else if($no == '09')
			{
				echo'<br><br><p align="center"><font size="6" color="#00a0ee">तीन आठवड्यावरील शिल्लक संदर्भ - ';
				$id =$_REQUEST['desk_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');	
					
				
			//accepted by desk
			$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 (	d.desk_ltr_rec_dt< DATE_SUB('$id',INTERVAL 14 DAY))  
			AND ( 
					(d.ltr_category='' AND d.ltr_status='')
					 OR (d.ltr_status='')
				)
			AND d.desk_id_from = (SELECT desk_id from login where login_id = '$username')") or die("bbbb".mysql_error()); 
			
		/*	//not accepted by desk
			$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, 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.desk_approval='pending'
			AND t.desk_id = ( SELECT desk_id from login where login_id = '$username' )
			AND t.sent_to_desk_dt< DATE_SUB('$id',INTERVAL 14 DAY)") or die("bbbb".mysql_error());  */
			
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
					<tr>	
						<th class='head0 center'>पोलीस अधीक्षक <br> कार्यालय<br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th class='head1 center'>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th class='head0 center'>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th class='head1 center'>विषय</th>
						<th class='head0 center'>कोणाकडून <br>प्राप्त_झाला</th>
						<th class='head1 center'>केलेली कार्यवाही</th>
						<th class='head0 center'>पत्राची_स्थिती </th>
						<th class='head1 center'>विभागीय <br>जावक_दिनांक</th>
					</tr>
				</thead>";
					
					while($test = mysql_fetch_array($result222))
					{
						$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
						$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
						$update_date 		= date('d-m-Y',strtotime($test['update_date']));
						$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
						$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
						
						// code for split date and arrange according to our need
						//dispose_date is in following format "YYYY-MM-DD" 
						list($year, $month, $day ) =explode("-",$dispose_date);
						$dispose = $day.'-'.$month.'-'.$year;
						
						list($year, $month, $day ) =explode("-",$update_date);
						$update = $day.'-'.$month.'-'.$year;
						
						//echo $dispose;
						
						//$id1 = $test['inward_no'];	
						echo "<tr>
						<td class='center'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
						<td class='center'>".$test['dpt_inword_no']."<br>
						".$dept_rec_date."</td>
						<td class='center'>".$test['desk_ltr_inword_no']."<br>
						".$desk_ltr_rec_dt."</td>
						<td class='center'>".$test['subject']."</td>
						<td class='center'>".$test['sender_name']."</td>";
							if($test['action_taken']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td class='center'>".$test['action_taken']."</td>";
							}
							
							if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td class='center'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td class='center'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td class='center'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td class='center'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
					}
				//mysql_close();
						
					/*	while($test1 = mysql_fetch_array($result2221))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr>
							<td style='text-align:center;'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td style='text-align:center;'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'><font color='red'> डेस्कने स्वीकारणे बाकी </font></td>
							<td style='text-align:center;'>".$test1['subject']."</td>
							<td style='text-align:center;'>".$test1['sender_name']."</td>";
								if($test1['action_taken']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'> कार्यवाही करणे बाकी </font></td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
						} */
				echo"</table>";
				
				########################## Div TO Print ###################################
				echo "<div id='divToPrint' style='display:none;'>";
				
				echo ' <center><h2><font color="black">पोलीस अधीक्षक  कार्यालय <br> जि.रायगड </font></h2></center>';
				echo"	<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							echo'<tr><td colspan="8"><center><font size="3">तीन आठवड्यावरील शिल्लक संदर्भ - ';
				$id =$_REQUEST['desk_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="3">'.$from_date.'</font> ते <font size="3">'.$to_date.'</font>';
					'</font></center></td></tr>';
				$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 desk
			$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 (	d.desk_ltr_rec_dt< DATE_SUB('$id',INTERVAL 14 DAY))  
			AND ( 
					(d.ltr_category='' AND d.ltr_status='')
					 OR (d.ltr_status='')
				)
			AND d.desk_id_from = (SELECT desk_id from login where login_id = '$username')") or die("bbbb".mysql_error()); 
			
		/*	//not accepted by desk
			$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, 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.desk_approval='pending'
			AND t.desk_id = ( SELECT desk_id from login where login_id = '$username' )
			AND t.sent_to_desk_dt< DATE_SUB('$id',INTERVAL 14 DAY)") or die("bbbb".mysql_error());  */
			
				echo"<tr>	
						<th>पोलीस अधीक्षक <br> कार्यालय<br>आवक_क्रमांक<br>आवक_दिनांक</th>
						<th>विभागीय आवक_क्रमांक<br>दिनांक</th>
						<th>डेस्क आवक_क्रमांक<br>दिनांक</th>
						<th>विषय</th>
						<th>कोणाकडून <br>प्राप्त_झाला</th>
						<th>केलेली कार्यवाही</th>
						<th>पत्राची स्थिती </th>
						<th>विभागीय <br>जावक_दिनांक</th>
					</tr>";
					while($test = mysql_fetch_array($result222))
					{
						$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
						$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
						$update_date 		= date('d-m-Y',strtotime($test['update_date']));
						$dispose_date 		= date('d-m-Y',strtotime($test['dispatched_dt']));
						$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
						// code for split date and arrange according to our need
						//dispose_date is in following format "YYYY-MM-DD" 
						list($year, $month, $day ) =explode("-",$dispose_date);
						$dispose = $day.'-'.$month.'-'.$year;
						
						list($year, $month, $day ) =explode("-",$update_date);
						$update = $day.'-'.$month.'-'.$year;
						
						//echo $dispose;
						
						//$id1 = $test['inward_no'];	
						echo "<tr>
						<td style='text-align:center;'>".$test['ltr_inword_no']."<br>".$rc_date."</td>
						<td style='text-align:center;'>".$test['dpt_inword_no']."<br>
						".$dept_rec_date."</td>
						<td style='text-align:center;'>".$test['desk_ltr_inword_no']."<br>
						".$desk_ltr_rec_dt."</td>
						<td style='text-align:center;'>".$test['subject']."</td>
						<td style='text-align:center;'>".$test['sender_name']."</td>
						";
						if($test['action_taken']=='')
						{
							echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
						}
						else if($test['ltr_status']=='')
						{
							echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
						}
						else
						{
							echo "<td style='text-align:center;'>".$test['action_taken']."</td>";
						}
						//////////////////////////////////////////////////////////////	
							if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
						//////////////////////////////////////////////////////////////////////	 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							
							echo "</tr>";
					}
				//mysql_close();
					
					/*	while($test1 = mysql_fetch_array($result2221))
						{
							$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test1['desk_ltr_rec_dt']));
							$dept_rec_date 		= date('d-m-Y',strtotime($test1['dpt_ltr_rec_dt']));
							$update_date 		= date('d-m-Y',strtotime($test1['update_date']));
							$dispose_date 		= date('d-m-Y',strtotime($test1['dispatched_dt']));
							$rc_date 		= date('d-m-Y',strtotime($test['receive_dt']));
							list($year, $month, $day ) =explode("-",$dispose_date);
							$dispose = $day.'-'.$month.'-'.$year;
							
							list($year, $month, $day ) =explode("-",$update_date);
							$update = $day.'-'.$month.'-'.$year;
			
							echo "<tr>
							<td style='text-align:center;'>".$test1['ltr_inword_no']."<br>".$rc_date."</td>
							<td style='text-align:center;'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td class='center'>डेस्कने स्वीकारणे बाकी</td>
							<td style='text-align:center;'>".$test1['subject']."</td>
							<td style='text-align:center;'>".$test1['sender_name']."</td>";
								if($test1['action_taken']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
								echo "<td style='text-align:center;'>".$test1['action_taken']."</td>";
							}
							
							if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test1['ltr_status']."</td>";
							}
							 
							 if($test1['ltr_status']=='')
							{
								echo "<td style='text-align:center;'>कार्यवाही करणे बाकी </td>";
							}
							
							else if ($test1['ltr_status']=='updated')
								{
									echo "<td style='text-align:center;'>".$update_date."</td>";
								}
							else if($test1['ltr_status']=='dispatched')
								{
									echo "<td style='text-align:center;'>".$dispose_date."</td>";
								}
							else
							{
								echo "<td style='text-align:center;'>--</td>";
							}
							echo "</tr>";
						} */
				echo"</table></center></div>";
			}
			
?>
			<form>
			<br>
			<p>	
				<center><input type="button" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"/>
				<input type="button" class="btn" onclick="tableToExcel('export', 'W3C Example Table')" value="Export to Excel"></center>
			</p>	
			</form>
			<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><!--mainwrapper-->
</body>
</html>
