<!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');
						$result222 = mysql_query("SELECT * FROM tapal_to_dpt_transaction, incoming_letters_transaction, desk_transaction WHERE desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND (desk_transaction.desk_ltr_rec_dt<'$id' and (desk_transaction.update_date>'$id' OR desk_transaction.dispatched_dt>'$id')) AND tapal_to_dpt_transaction.desk_id = (SELECT desk_id from login where login_id = '$username') order by incoming_letters_transaction.ltr_inword_no desc") or die("cccc".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'>आवक_क्रमांक</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 		= $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 class='gradeX'>
										<td class='center'>".$test['ltr_inword_no']."</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']=='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;'>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";

						echo'<br><br><p align="center"><font size="5" 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="5" color="#59c600">'.$from_date.'</font> ते <font size="5" color="#59c600">'.$to_date.'</font></font></p>';
						$date = date_create($from_date);
						date_modify($date, '-23 day');
						//echo $from_date1=date_format($date, 'd-m-Y');
						$from_date1=date_format($date, 'd-m-Y');
						$result222 = mysql_query("SELECT * FROM tapal_to_dpt_transaction, incoming_letters_transaction, desk_transaction WHERE desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND (desk_transaction.desk_ltr_rec_dt<'$id' and (desk_transaction.update_date>'$id' OR desk_transaction.dispatched_dt>'$id')) AND tapal_to_dpt_transaction.desk_id = (SELECT desk_id from login where login_id = '$username') order by incoming_letters_transaction.ltr_inword_no desc") or die("cccc".mysql_error());
						echo"<br><br>";
						echo "<tr>	
						<th>आवक_क्रमांक</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 		= $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']."</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;'><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;'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'>कार्यवाही करणे बाकी </font></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>";
								}
							
							echo "</tr>";
							}
						echo"</table>
						</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();
						$result222=mysql_query("SELECT * FROM tapal_to_dpt_transaction, incoming_letters_transaction, desk_transaction WHERE desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND (desk_transaction.desk_ltr_rec_dt BETWEEN '$id' AND '$id1') AND tapal_to_dpt_transaction.desk_id = (SELECT desk_id from login where login_id = '$username') ORDER BY incoming_letters_transaction.ltr_inword_no") or die("eeee".mysql_error());

						echo"<br><br><table id='dyntable' class='table table-bordered'>";
						echo"<thead>
								<tr>	
									<th class='head0 center'>आवक_क्रमांक</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 		= $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']."</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 style='text-align: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;'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'>कार्यवाही करणे बाकी </font></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>";
								}
							
							echo "</tr>";
								}
						echo"</table>";
						
						echo "<div id='divToPrint' style='display:none;'>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							
						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></p>';
						convert_marathi();
						$result222=mysql_query("SELECT * FROM tapal_to_dpt_transaction, incoming_letters_transaction, desk_transaction WHERE desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND (desk_transaction.desk_ltr_rec_dt BETWEEN '$id' AND '$id1') AND tapal_to_dpt_transaction.desk_id = (SELECT desk_id from login where login_id = '$username') ORDER BY incoming_letters_transaction.ltr_inword_no") or die("eeee".mysql_error());
						echo"<tr>	
						<th>आवक_क्रमांक</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 		= $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']."</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>";
												}
									echo "</tr>";
								}
						echo"</table></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();
					$result222=mysql_query("SELECT * FROM tapal_to_dpt_transaction, incoming_letters_transaction, desk_transaction WHERE desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND (desk_transaction.desk_ltr_rec_dt BETWEEN '$id' AND '$id1') AND tapal_to_dpt_transaction.desk_id = (SELECT desk_id from login where login_id = '$username') ORDER BY incoming_letters_transaction.ltr_inword_no");
					
					$result234 = mysql_query("SELECT * FROM tapal_to_dpt_transaction, incoming_letters_transaction, desk_transaction WHERE desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND (desk_transaction.desk_ltr_rec_dt<'$id' and (desk_transaction.update_date>'$id' OR desk_transaction.dispatched_dt>'$id')) AND tapal_to_dpt_transaction.desk_id = (SELECT desk_id from login where login_id = '$username') order by incoming_letters_transaction.ltr_inword_no desc");
					
					echo"<br><br><table id='dyntable' class='table table-bordered'>";
					echo"<thead>
						<tr>	
						<th class='head0 center'>आवक_क्रमांक</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']));
							
							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']."</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 style='text-align: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;'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'>कार्यवाही करणे बाकी </font></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>";
								}
							
							echo "</tr>";
						}
						
						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']));

							$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']."</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 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>";
								}
							
							echo "</tr>";
						}
					echo"</table>";
					#################################### Div to print ###################################3
					echo "<div id='divToPrint' style='display:none;'>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
					
					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></p>';
					convert_marathi();
					$result222= mysql_query("SELECT * FROM desk_transaction,tapal_to_dpt_transaction,incoming_letters_transaction WHERE (desk_transaction.desk_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 15 DAY)AND '$id')AND tapal_to_dpt_transaction.desk_id = (SELECT desk_id from login where login_id = '$username') AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id order by incoming_letters_transaction.ltr_inword_no desc")or die("Problem".mysql_error());
					
					$result234 = mysql_query("SELECT * FROM tapal_to_dpt_transaction, incoming_letters_transaction, desk_transaction WHERE desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND (desk_transaction.desk_ltr_rec_dt<'$id' and (desk_transaction.update_date>'$id' OR desk_transaction.dispatched_dt>'$id')) AND tapal_to_dpt_transaction.desk_id = (SELECT desk_id from login where login_id = '$username') order by incoming_letters_transaction.ltr_inword_no desc");
					
					echo"<tr>	
						<th>आवक_क्रमांक</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 		= $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']."</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;'><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;'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'>कार्यवाही करणे बाकी </font></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>";
								}
							
							echo "</tr>";
						}
						
						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']));

							$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>
							<td style='text-align:center;'>".$test1['ltr_inword_no']."</td>
							<td style='text-align:center;'>".$test1['dpt_inword_no']."<br>
							".$dept_rec_date."</td>
							<td style='text-align:center;'>".$test1['desk_ltr_inword_no']."<br>
							".$desk_ltr_rec_dt."</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>";
								}
							
						}	echo "</tr>";
					echo"</table></div>";
				}	
			########################################### Updated References ###############################
			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 * FROM incoming_letters_transaction, tapal_to_dpt_transaction, desk_transaction WHERE tapal_to_dpt_transaction.desk_id=(Select desk_id from login where login_id='$username') AND desk_transaction.update_date BETWEEN '$id' AND '$id1' AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id") or die("".mysql_error()); 
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
				<tr>	
						<th class='head0 center'>आवक_क्रमांक</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 		= $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']."</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 style='text-align: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;'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'>कार्यवाही करणे बाकी </font></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>";
								}
							
							echo "</tr>";
					}
				echo"</table>";
				
				echo "<div id='divToPrint' style='display:none;'>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
				
				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 * FROM incoming_letters_transaction, tapal_to_dpt_transaction, desk_transaction WHERE tapal_to_dpt_transaction.desk_id=(Select desk_id from login where login_id='$username') AND desk_transaction.update_date BETWEEN '$id' AND '$id1' AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id") or die("".mysql_error()); 
				echo"<tr>	
						<th>आवक_क्रमांक</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 		= $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']."</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>";
							}
						echo "</tr>";
					}
				echo"</table></div>";
			}
			########################################### Dispatched References ####################################
			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 * FROM incoming_letters_transaction, tapal_to_dpt_transaction, desk_transaction WHERE (desk_transaction.dispatched_dt BETWEEN '$id' AND '$id1') AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND tapal_to_dpt_transaction.desk_id=(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'>आवक_क्रमांक</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 		= $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']."</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>
					<td class='center'>".$test['action_taken']."</td>
					<td class='center'>".$test['ltr_status']."</td>";
						echo "<td class='center'>".$dispose_date."</td>";
					echo "</tr>";
				}
				echo"</table>";
				
				echo "<div id='divToPrint' style='display:none;'>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							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 * FROM incoming_letters_transaction, tapal_to_dpt_transaction, desk_transaction WHERE (desk_transaction.dispatched_dt BETWEEN '$id' AND '$id1') AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND tapal_to_dpt_transaction.desk_id=(Select desk_id from login where login_id='$username')") or die("".mysql_error()); 
				echo"<tr>	
						<th>आवक_क्रमांक</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 		= $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']."</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>";
						echo "<td style='text-align:center;'>".$dispose_date."</td>";
					echo "</tr>";
				}
				echo"</table></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>';
	
				$result222=mysql_query("SELECT * FROM tapal_to_dpt_transaction, incoming_letters_transaction, desk_transaction WHERE desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND (desk_transaction.desk_ltr_rec_dt BETWEEN '$id' AND '$id1' AND ( (desk_transaction.update_date NOT BETWEEN '$id' AND '$id1' AND desk_transaction.dispatched_dt NOT BETWEEN '$id' AND '$id1') OR desk_transaction.ltr_category='')) AND tapal_to_dpt_transaction.desk_id =(SELECT desk_id from login where login_id = '$username')")or die("abaaaaa".mysql_error()) ;
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
				<tr>	
						<th class='head0 center'>आवक_क्रमांक</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 		= $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']."</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 style='text-align: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;'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'>कार्यवाही करणे बाकी </font></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>";
								}
							
							echo "</tr>";
				}
				//mysql_close();
				echo"</table>";
				echo "<div id='divToPrint' style='display:none;'>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							echo'<br><br><p align="center"><font size="6" color="#00a0ee">एका आठवड्यातील शिल्लक संदर्भ - ';
				//	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><font size="6" color="#59c600">'.$to_date.'</font>';
					'</p>';
	
				$result222=mysql_query("SELECT * FROM tapal_to_dpt_transaction, incoming_letters_transaction, desk_transaction WHERE desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND (desk_transaction.desk_ltr_rec_dt BETWEEN '$id' AND '$id1' AND ( (desk_transaction.update_date NOT BETWEEN '$id' AND '$id1' AND desk_transaction.dispatched_dt NOT BETWEEN '$id' AND '$id1') OR desk_transaction.ltr_category='')) AND tapal_to_dpt_transaction.desk_id =(SELECT desk_id from login where login_id = '$username')")or die("abaaaaa".mysql_error()) ;
				echo"<tr>	
						<th>आवक_क्रमांक</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 		= $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']."</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>";
						}
					echo "</tr>";
				}
				//mysql_close();
				echo"</table></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');
			
				$result222=mysql_query("SELECT * FROM desk_transaction, tapal_to_dpt_transaction, incoming_letters_transaction WHERE (desk_transaction.desk_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 15 DAY)AND DATE_SUB('$id',INTERVAL 8 DAY)) AND (desk_transaction.ltr_category='' OR (desk_transaction.update_date NOT BETWEEN '$id' AND '$id1' AND desk_transaction.dispatched_dt NOT BETWEEN '$id' AND '$id1')) AND tapal_to_dpt_transaction.desk_id = (SELECT tapal_to_dpt_transaction.desk_id from login where login_id = '$username') AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id") or die("".mysql_error());
			
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
				<tr>	
						<th class='head0 center'>आवक_क्रमांक</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 		= $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 class='gradeX'>
						<td class='center'>".$test['ltr_inword_no']."</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 style='text-align: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;'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'>कार्यवाही करणे बाकी </font></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>";
								}
							
							echo "</tr>";
					}
					echo"</tbody></table>";
					echo "<div id='divToPrint' style='display:none;'>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							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');
			
				$result222=mysql_query("SELECT * FROM desk_transaction, tapal_to_dpt_transaction, incoming_letters_transaction WHERE (desk_transaction.desk_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 15 DAY)AND DATE_SUB('$id',INTERVAL 8 DAY)) AND (desk_transaction.ltr_category='' OR (desk_transaction.update_date NOT BETWEEN '$id' AND '$id1' AND desk_transaction.dispatched_dt NOT BETWEEN '$id' AND '$id1')) AND tapal_to_dpt_transaction.desk_id = (SELECT tapal_to_dpt_transaction.desk_id from login where login_id = '$username') AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id") or die("".mysql_error());	echo"<tr>	
						<th>आवक_क्रमांक</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 		= $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']."</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>";
				}
				echo "</tr>";
			}
			//mysql_close();
			echo "</table></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');	
				
				$result222=mysql_query("SELECT * FROM tapal_to_dpt_transaction, desk_transaction, incoming_letters_transaction WHERE (desk_transaction.desk_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 15 DAY)AND DATE_SUB('$id',INTERVAL 8 DAY)) AND desk_transaction.ltr_category='' AND tapal_to_dpt_transaction.desk_id = (SELECT desk_id from login where login_id = '$username') AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id ") or die("bbbb".mysql_error());
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
				<tr>	
						<th class='head0 center'>आवक_क्रमांक</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 		= $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']."</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 style='text-align: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;'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'>कार्यवाही करणे बाकी </font></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>";
								}
							
							echo "</tr>";
				}
				//mysql_close();
				echo"</table>";
				echo "<div id='divToPrint' style='display:none;'>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							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');	
				
				$result222=mysql_query("SELECT * FROM tapal_to_dpt_transaction, desk_transaction, incoming_letters_transaction WHERE (desk_transaction.desk_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 15 DAY)AND DATE_SUB('$id',INTERVAL 8 DAY)) AND desk_transaction.ltr_category='' AND tapal_to_dpt_transaction.desk_id = (SELECT desk_id from login where login_id = '$username') AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id ") or die("bbbb".mysql_error());
				echo"<tr>	
						<th>आवक_क्रमांक</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 		= $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']."</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>
					<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>";
						}
					echo "</tr>";
				}
				//mysql_close();
				echo"</table></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');	
					
				$result222 = mysql_query("SELECT * FROM tapal_to_dpt_transaction, desk_transaction, incoming_letters_transaction WHERE (desk_transaction.desk_ltr_rec_dt < DATE_SUB('$id',INTERVAL 23 DAY) AND '$id' AND desk_transaction.ltr_category='')AND tapal_to_dpt_transaction.desk_id = (SELECT desk_id from login where login_id = '$username') AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id") or die("bbbb".mysql_error());
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
					<tr>	
						<th class='head0 center'>आवक_क्रमांक</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 		= $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']."</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 style='text-align: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;'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'>कार्यवाही करणे बाकी </font></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>";
								}
							
							echo "</tr>";
					}
				//mysql_close();
				echo"</table>";
				echo "<div id='divToPrint' style='display:none;'>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							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');	
					
				$result222 = mysql_query("SELECT * FROM tapal_to_dpt_transaction, desk_transaction, incoming_letters_transaction WHERE (desk_transaction.desk_ltr_rec_dt < DATE_SUB('$id',INTERVAL 23 DAY) AND '$id' AND desk_transaction.ltr_category='')AND tapal_to_dpt_transaction.desk_id = (SELECT desk_id from login where login_id = '$username') AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id") or die("bbbb".mysql_error());
				echo"<tr>	
						<th>आवक_क्रमांक</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 		= $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 style='text-align:center;'>".$test['ltr_inword_no']."</td>
						<td style='text-align:center;'>".$test['dpt_inword_no']."<br>
						".$dept_rec_date."</td>
						<td style='text-align:center;'>".$test['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>";
							}
						echo "</tr>";
					}
				//mysql_close();
				echo"</table>";
			}
		########################################### 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 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');	
				$result222 = mysql_query("SELECT * FROM tapal_to_dpt_transaction, incoming_letters_transaction, desk_transaction WHERE tapal_to_dpt_transaction.desk_id=(select desk_id from login where login_id='$username') AND (desk_transaction.desk_ltr_rec_dt BETWEEN '$id' AND '$id1' AND (desk_transaction.update_date NOT BETWEEN '$id' AND '$id1' AND desk_transaction.dispatched_dt NOT BETWEEN '$id' AND '$id1') OR desk_transaction.ltr_category='') and desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id") or die("".mysql_error());
				echo"<br><br><table id='dyntable' class='table table-bordered'>";
				echo"<thead>
					<tr>	
						<th class='head0 center'>आवक_क्रमांक</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 		= $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']."</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 style='text-align: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;'><font color='red'>कार्यवाही करणे बाकी </font></td>";
							}
							else
							{
							 echo "<td style='text-align:center;'>".$test['ltr_status']."</td>";
							}
							 
							 if($test['ltr_status']=='')
							{
								echo "<td style='text-align:center;'><font color='red'>कार्यवाही करणे बाकी </font></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>";
								}
							
							echo "</tr>";
					}
				//mysql_close();
				echo"</table>";
				echo "<div id='divToPrint' style='display:none;'>
							<table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>". $desknm['desk_nm']. "गोषवारा </h4></center></td></tr>";
							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></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');	
				$result222 = mysql_query("SELECT * FROM tapal_to_dpt_transaction, incoming_letters_transaction, desk_transaction WHERE tapal_to_dpt_transaction.desk_id=(select desk_id from login where login_id='$username') AND (desk_transaction.desk_ltr_rec_dt BETWEEN '$id' AND '$id1' AND (desk_transaction.update_date NOT BETWEEN '$id' AND '$id1' AND desk_transaction.dispatched_dt NOT BETWEEN '$id' AND '$id1') OR desk_transaction.ltr_category='') and desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id") or die("".mysql_error());
				echo"<tr>	
						<th>आवक_क्रमांक</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 		= $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 style='text-align:center;'>".$test['ltr_inword_no']."</td>
						<td style='text-align:center;'>".$test['dpt_inword_no']."<br>
						".$dept_rec_date."</td>
						<td style='text-align:center;'>".$test['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>";
							}
						echo "</tr>";
					}
				//mysql_close();
				echo"</table><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>
