 <?php 
$user=$_GET['user'];
if($user=='bdo')
	{
			?>
			<!DOCTYPE html>
			<?php 
			include_once('dashboard_bdo.php');
			require_once('convert_marathi.php');
			######################################### Desk Wise Sadyasthiti Report #################################################
			$username = $_SESSION['User_Name'];
			?>

			<html>
			<head>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
			<meta name="viewport" content="width=device-width, initial-scale=1.0" />
			<title>Tapal Admin System</title>
			<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>
				<div class="rightpanel">
					<ul class="breadcrumbs">
						<li><a href="dashboard_bdo.php"><i class="iconfa-home"></i></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>सद्यस्थिती </h1>
						</div>
					</div><!--pageheader-->
	<?php } 
	else if($user=='tapal')
	{
		include_once('dashboard_tapal.php');
		require_once('convert_marathi.php');
		######################################### Desk Wise Sadyasthiti Report ######################################
		$username = $_SESSION['User_Name'];

		?>
		<html>
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Tapal Admin System</title>
		<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="rightpanel">
				<ul class="breadcrumbs">
					<li><a href="dashboard_tapal.php"><i class="iconfa-home"></i></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>सद्यस्थिती </h1>
					</div>
				</div><!--pageheader-->
<?php }?>
	
        <div class="maincontent">
            <div class="maincontentinner">
				<h4 class="widgettitle">सद्यस्थिती </h4>	  
					<?php 
						echo "<form name='dept_sandarbh' action='' method='post'>
								<div align='center'><br><table align='center' cellpadding='2' cellspacing='0' class='myClass'>
								<table>
									<tr>											  
										<td align='center'><label style='width:110px;'>Start date</label></td>
										<td align='center'><input type='text' name='start_date' class='input-small'/></td>
										<td align='center'><label style='width:110px;'>End Date</label></td>
										<td align='center'><input type='text' name='end_date' class='input-small'/></td>
									</tr>
									<tr>
										<td colspan='6'>
										<div align='center'>
											<input type='submit' onClick='return sadyasthitiDates()' name='ok' value='GO'/>
											<input type='reset' value='CLEAR' name='clear'/>
										</div>
										</td>
									</tr>
								</table>
							</div>				
							</form>
							<form action='' method='post'>";
					?>
					<table id='dyntable' class='table table-bordered'>
						<thead>
							<tr>
                            <th class="head0 center">डेस्क आवक_क्र.<br>आवक_दिनांक</th>
                            <th class="head1 center">विभागीय आवक_क्र. <br>आवक_दिनांक</th>
							<th class="head0 center">पोलीस अधिक्षक <br> कार्यालय<br> आवक_क्र.<br>आवक_दिनांक</th>
                            <th class="head1 center">संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
                            <th class="head0 center">कोणाकडून प्राप्त झाला <br>विषय </th>                      
							<th class="head0 center"> केलेली <br>कार्यवाही </th>
							<th class="head1 center">पत्राची स्थिती </th>
							<th class="head0 center">जावक_क्रमांक<br> व्यक्तीचे नाव </th>
							<th class="head1 center">View</th>
							</tr>
						</thead>
						<?php
							
							$date123	= $_POST['start_date'];
							$date1	= date('Y-m-d',strtotime($date123));
							$date223	= $_POST['end_date'];
							$date2	= date('Y-m-d',strtotime($date223));
							//$date22	= date('d-m-Y',strtotime($date2));
								
							echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
							$id1 = $date1;
							$id2= $date2;
					
					$y=date("Y");	
					$query1=mysql_query("SELECT * FROM incoming_letters_transaction i, tapal_to_dpt_transaction t,department_master dm
					WHERE t.ltr_id=i.ltr_id
					AND t.dept_id_from=dm.dept_id ") OR die("aaaaaa".mysql_error());
					
				while($result1=mysql_fetch_array($query1))
					{
						$dept_ltr_id=$result1['dpt_ltr_id'];
						
						if($result1['desk_flag']=='Y' || $result1['desk_flag']=='y')
						{
						
							if($date123==''&& $date223=='')
							{
								
								convert_marathi();
								$result222=mysql_query("SELECT de.waitflag,de.wait_kar_flag,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.dept_id_to,di.dsk_id_to,di.dsk_id_from, 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 t.dpt_ltr_id='$dept_ltr_id'
								") or die("xyzxyz".mysql_error());
								
							}
							else{
								
								$result222=mysql_query("SELECT de.waitflag,de.wait_kar_flag,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.dept_id_to, di.outword_no,di.dsk_id_to,di.dsk_id_from, 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 (i.receive_dt BETWEEN '$date1' AND '$date2') AND t.dpt_ltr_id='$dept_ltr_id'") or die("".mysql_error());
							}
							
							while($rws = mysql_fetch_array($result222))
							{	
								$dptltrid=$rws['dpt_ltr_id'];
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								convert_marathi();
								//closed lettr
								$ltrinward=$rws['ltr_inword_no'];
								$deskidfrom=$rws['desk_id_from'];
								if($rws['ltr_status']=='closed')
								{
									$query=mysql_query("select rtn_to_dsk from  returned_from_desk 
														where ltr_inword_no='$ltrinward'
														AND returned_from='$deskidfrom' ");		
									$result=mysql_fetch_array($query);
									//echo $result['rtn_to_dsk']."<br>";
								}
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class=gradeX>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0' || $rws['dpt_inword_no']=='NULL')
								{
									echo "<td class='center'><font color='red'>".$dept['dept_nm']."<br> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								######################################### common things ####################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								########################### If Action Taken Pending ###################				
								if($result['rtn_to_dsk']=='')
								{
									$returnto=$dept['dept_nm'];
										
								}
								else
								{
									$dsk_nm=$result['rtn_to_dsk'];
									$qw=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk_nm'") or die("".mysql_error());
									$de=mysql_fetch_array($qw);
									$returnto=$de['desk_nm'];
								}
									
								if($rws['ltr_status']=='' && $rws['waitflag']!='W')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_status']=='closed' )
								{
									echo"<td class='center'>Letter Returned To <br>".$returnto."</td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='' && $rws['waitflag']=='W' && $rws['wait_kar_flag']=='N')
								{
									echo "<td class=center><font color='red'>"."Await Register"."</font></td>";
								}
								else if($rws['ltr_status']=='' && $rws['waitflag']=='W' && $rws['wait_kar_flag']=='A')
								{	
									echo "<td class=center>"."Await Register Complete"."</td>";
								}
								else if($rws['ltr_status']=='' && $rws['waitflag']=='' && $rws['wait_kar_flag']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									$dpt_to=$rws['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws['ltr_approval']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws['ltr_approval']=='transferred_todesk')
								{
									$dsk_to=$rws['dsk_id_to'];
									$q=mysql_query("SELECT desk_nm from desk_master where desk_id='$dsk_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>transferred to<br>".$r['desk_nm']." </td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
																
								if($rws['waitflag']=='W' && $rws['wait_kar_flag']=='A')
								{
									echo "<td class='center'>"."कार्यवाही पूर्ण झाली."."</td>";
								}
								else if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated' && $rws['ltr_status']!='closed' )
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."अपडेट केले</td>";
								}
								else if($rws['ltr_status']=='closed')
								{
									echo "<td class='center'>--</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									$dept_to=$rws['dept_id_to'];
									$qdpto=mysql_query("Select dept_nm from department_master Where dept_id='$dept_to'") or die("".mysql_error());
									$depto=mysql_fetch_array($qdpto);
									
									$dsk_to=$rws['dsk_id_to'];
									$q=mysql_query("SELECT desk_nm from desk_master where desk_id='$dsk_to' ");
									$r=mysql_fetch_array($q);
									
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."".$depto['dept_nm']."".$r['desk_nm']."</td>";
								}
								
								//////////////////////////////////////////////////////////////////////////////
								if($user=='tapal')
								{
									//echo" <td class=center><a href='view_document.php?deskltrid=$deskltrid&no=4'> View </a>";
									echo" <td class='center'><a href='view_avak_javak_bdo_tapal.php?user=2&dptltrid=$dept_ltr_id&dskltrid=$deskltrid'> View </a>";
									
									if($rws['ltr_approval']=='transferred' || $rws['ltr_approval']=='transferred_todesk')
									{
										echo "<br><a href='report_dpt_ltr_transfer_op.php?ltrid=$ltrid&user=tapal'>DispatchDetails</a><br>";
									}
								}
								else
								{
									//	echo" <td class='center'><a href='view_document.php?deskltrid=$deskltrid&no=1'> View </a>";
									echo" <td class='center'><a href='view_avak_javak_bdo_tapal.php?user=1&dptltrid=$dept_ltr_id&dskltrid=$deskltrid'> View </a>";
									
									if($rws['ltr_approval']=='transferred' || $rws['ltr_approval']=='transferred_todesk')
									{
										echo"<br><a href='report_dpt_ltr_transfer_op.php?ltrid=$ltrid&user=bdo'>DispatchDetails</a><br>";
									}
								}
								//////////////////////////////////////////////////////////////////////////////////
								if($rws['ltr_category']=='current')
								{
									if($user='tapal')
									{
										echo "<a href='bdo_tapal_sandharbhawise.php?refno=$rws[assign_no]&user=tapal'>".$rws['assign_no']."</a></td></tr>";
									}
									else
									{
										echo "<a href='bdo_tapal_sandharbhawise.php?refno=$rws[assign_no]&user=bdo'>".$rws['assign_no']."</a></td></tr>";
									}
								}
								else
								{
									echo "</td></tr>";
								}
							}//mysql_close();
							
							
						}//if($result1['desk_flag']=='y')
							
						else if($result1['desk_flag']=='N' || $result1['desk_flag']=='n')
						{
							
							if($date123==''&& $date223=='')
							{
								convert_marathi();
								$result2221=mysql_query("SELECT t.waitflag,t.wait_kar_flag,t.action_taken, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, t.update_date, t.dispatched_date, t.status, di.addressed_to,di.dept_id_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc,  di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
								FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON (di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								where t.dpt_ltr_id='$dept_ltr_id' ") or die("".mysql_error());
								
							}
							else{
								
								$result2221=mysql_query("SELECT t.waitflag,t.wait_kar_flag,t.action_taken, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, t.update_date, t.dispatched_date, t.status, di.addressed_to,di.dept_id_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
								FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON (di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								where  (i.receive_dt BETWEEN '$date1' AND '$date2') AND t.dpt_ltr_id='$dept_ltr_id'") or die("".mysql_error());
							}
							
							while($rws1 = mysql_fetch_array($result2221))
							{	
								
								//$deskltrid=$rws['desk_ltr_id'];
								
								$ltrid=$rws1['ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id_from']!='' || $rws1['dept_id_from']!='0')
								{
									$depti=$rws1['dept_id_from'];
									convert_marathi();
									$qdpt1=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept1=mysql_fetch_array($qdpt1);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class=gradeX>";
								################################### Desk ####################################
								if($rws1['desk_id']=='0' || $rws1['desk_id']=='')
								{
									//echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
									echo "<td class='center'> -- </td>";
								}
								else if($rws1['desk_ltr_inword_no']=='' || $rws1['desk_ltr_inword_no']=='0')
								{
									//echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
									echo "<td class='center'> -- </td>";
								}
								else
								{
									//echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
									echo "<td class='center'> -- </td>";
								}
							
								############################## dpt######################################
								if($rws1['dept_id']=='0' || $rws1['dept_id']=='')
								{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
								}
								else if($rws1['dpt_inword_no']=='' || $rws1['dpt_inword_no']=='0' || $rws1['dpt_inword_no']=='NULL')
								{
									echo "<td class='center'><font color='red'>".$dept1['dept_nm']."<br> विभागाने स्वीकारणे बाकी </font> </td>";
								}
								else
								{
									echo "<td class='center'>".$dept1['dept_nm']."<br>".$rws1['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								######################################### common things ####################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								########################### If Action Taken Pending ###################				
								if($rws1['action_taken']=='')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else
								{
									echo "<td class='center'>".$rws1['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws1['ltr_status']=='' && $rws1['waitflag']=='W' && $rws1['wait_kar_flag']=='N')
								{
									echo "<td class=center><font color='red'>"."Await Register"."</font></td>";
								}
								else if($rws1['ltr_status']=='' && $rws1['waitflag']=='W' && $rws1['wait_kar_flag']=='A')
								{	
									echo "<td class=center>"."Await Register Complete"."</td>";
								}
								else if($rws1['ltr_status']=='' && $rws1['waitflag']=='' && $rws1['wait_kar_flag']=='')
								{
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								}
								else if($rws1['status']=='transferred')
								{
									$dpt_to=$rws1['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws1['status']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws1['status']=='dispatched')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								} 
								##############################################################################
								
								if($rws1['waitflag']=='W' && $rws1['wait_kar_flag']=='A')
								{
									echo "<td class='center'>"."कार्यवाही पूर्ण झाली."."</td>";
								}
								else if($rws1['dispatched_to']=='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."अपडेट केले</td>";
								}
								else if($rws1['dispatched_to']!='' && $rws1['ltr_status']!='updated')
								{
									$dept_to=$rws1['dept_id_to'];
									$qdpto=mysql_query("Select dept_nm from department_master Where dept_id='$dept_to'") or die("".mysql_error());
									$depto=mysql_fetch_array($qdpto);
									
									echo "<td class='center'>".$rws1['outword_no']."<br>".$rws1['addressed_to']."".$depto['dept_nm']."</td>";
								}
								
								///////////////////////////////////////////////////////////////
								if($user=='tapal')
								{
									///echo" <td class=center><a href='view_document.php?deskltrid=$deskltrid&no=4'> View </a>";
									echo" <td class='center'><a href='view_avak_javak_bdo_tapal.php?flag=n&user=2&dptltrid=$dept_ltr_id&dskltrid='a'> View </a>";
									if($rws1['status']=='transferred') 	
									{
										echo "<br><a href='report_dpt_ltr_transfer_op.php?ltrid=$ltrid&user=tapal'>DispatchDetails</a><br>";
									}
								}
								else
								{
									//echo" <td class='center'><a href='view_document.php?deskltrid=$deskltrid&no=1'> View </a>";
									echo" <td class='center'><a href='view_avak_javak_bdo_tapal.php?flag=n&user=1&dptltrid=$dept_ltr_id&dskltrid='a'> View </a>";
									if($rws1['status']) 	
									{
										echo "<br><a href='report_dpt_ltr_transfer_op.php?ltrid=$ltrid&user=bdo'>DispatchDetails</a><br>";
									}
								}
								//////////////////////////////////////////////////////////////////////////
								if($rws1['ltr_category']=='current')
								{
									if($user='tapal')
									{
										echo "<a href='bdo_tapal_sandharbhawise.php?refno=$rws[assign_no]&user=tapal'>".$rws1['assign_no']."</a></td></tr>";
									}
									else
									{
										echo "<a href='bdo_tapal_sandharbhawise.php?refno=$rws[assign_no]&user=bdo'>".$rws1['assign_no']."</a></td></tr>";
									}
								}
								else
								{
									echo "</td></tr>";
								}
							}//mysql_close();
							
						} // else if($result1['desk_flag']=='n')
						
			} //while
			
				/////////////dept pending ltrs/////////////////
				if($date123==''&& $date223=='')
				{
					convert_marathi();
					$result2223=mysql_query("SELECT * 
					from incoming_letters_transaction i
					where i.status='pending' AND i.dept_id!='0' ") or die("xyzxyz".mysql_error());
				}
				else{
					convert_marathi();
					$result2223=mysql_query("SELECT * 
					from incoming_letters_transaction i
					where i.status='pending' AND i.dept_id!='0'
					AND (i.receive_dt BETWEEN '$date1' AND '$date2')") or die("xyzxyz".mysql_error());
				}
				while($rws1 = mysql_fetch_array($result2223))
				{			
					$dptid=$rws1['dept_id'];
					$qry=mysql_query("SELECT desk_flag from department_master where dept_id='$dptid'");
					$rws2 = mysql_fetch_array($qry);
					if($rws2['desk_flag']=='y' || $rws2['desk_flag']=='Y')
					{
								
								$ltrid=$rws['ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id']!='' || $rws1['dept_id']!='0')
								{
									$depti=$rws1['dept_id'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								
								################# convert date in suitable format ##########################
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class=gradeX>";
								################################### Desk ####################################
								echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
								
							
								############################## dpt######################################
								echo "<td class='center'><font color='red'>".$dept['dept_nm']."<br> विभागाने स्वीकारणे बाकी </font> </td>";
								
								######################################### common things ####################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								########################### If Action Taken Pending ###################				
								
								echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								
								
								echo" <td class=center> View ";
								
					}
					else if($rws2['desk_flag']=='n' || $rws2['desk_flag']=='N')
					{
								$ltrid=$rws['ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id']!='' || $rws1['dept_id']!='0')
								{
									$depti=$rws1['dept_id'];
									//echo $depti."sss<br>";
									
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
									//echo $dept['dept_nm']."aaaaaaaaaaaassssssssss";
								}
								
								################# convert date in suitable format ##########################
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class=gradeX>";
								################################### Desk ####################################
								echo "<td class='center'>-- </td>";
								
							
								############################## dpt######################################
								echo "<td class='center'><font color='red'>".$dept['dept_nm']."<br> विभागाने स्वीकारणे बाकी </font> </td>";
								
								######################################### common things ####################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								########################### If Action Taken Pending ###################				
								
								echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
								
								##############################################################################
								
									echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी"."</font></td>";
								
								
								echo" <td class=center> View <br>";
					}
				}
			echo "</tbody>
			</table>";
			

			echo "<div id='divToPrint' style='display:none;'>
							<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center> सद्यस्थिती <br>दिनांक ".$date123." पासून दिनांक ".$date223."</center></td></tr>";
							
							echo ' <center><h2>पोलीस अधिक्षक कार्यालय, <br> जि.रायगड <h2></center>';
							$id1 = $date1;
							$id2= $date2;
							
							
							
						echo "<tr>
							<th>डेस्क आवक_क्र.<br>आवक_दिनांक</th>
							<th>विभागीय आवक_क्र. <br>आवक_दिनांक</th>
							<th>पोलीस अधिक्षक <br> कार्यालय <br> आवक_क्र.<br>आवक_दिनांक</th>
                            <th>संदर्भ_क्र.<br>प्राप्त_दिनांक</th>                          
                            <th>कोणाकडून प्राप्त झाला <br>विषय </th>                      
							<th>केलेली <br>कार्यवाही </th>
							<th>पत्राची स्थिती </th>
							<th>जावक_क्रमांक<br> व्यक्तीचे नाव </th>
							
						</tr>";
					
							
							
							
					$query1=mysql_query("SELECT * FROM incoming_letters_transaction i, tapal_to_dpt_transaction t,department_master dm
					WHERE t.ltr_id=i.ltr_id
					AND t.dept_id_from=dm.dept_id ") OR die("aaaaaa".mysql_error());
							
					while($result1=mysql_fetch_array($query1))
					{
						$dept_ltr_id=$result1['dpt_ltr_id'];
						
						if($result1['desk_flag']=='Y' || $result1['desk_flag']=='y')
						{
						
							if($date123==''&& $date223=='')
							{
								
								convert_marathi();
								$result222=mysql_query("SELECT de.waitflag,de.wait_kar_flag,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,di.dept_id_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.dsk_id_to,di.dsk_id_from, 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 t.dpt_ltr_id='$dept_ltr_id'") or die("xyzxyz".mysql_error());
							}
							else{
								
								$result222=mysql_query("SELECT de.waitflag,de.wait_kar_flag,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,di.dept_id_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.dsk_id_to,di.dsk_id_from, 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 (i.receive_dt BETWEEN '$date1' AND '$date2') AND t.dpt_ltr_id='$dept_ltr_id'") or die("".mysql_error());
							}
							
							while($rws = mysql_fetch_array($result222))
							{	
								
								$deskltrid=$rws['desk_ltr_id'];
								$ltrid=$rws['ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								########################### Fetch desk name ##############################
								if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
								{
									$dsk=$rws['desk_id_from'];
									convert_marathi();
									$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
									$desk=mysql_fetch_array($qsk);
								}
								################# convert date in suitable format ##########################
								$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class=gradeX>";
								################################### Desk ####################################
								if($rws['desk_id']=='0' || $rws['desk_id']=='')
								{
									echo "<td class='center'>ेस्क लावणे बाकी </td>";
								}
								else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
								{
									echo "<td class='center'>डेस्कने स्वीकारणे बाकी </td>";
								}
								else
								{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
								}
							
								############################## dpt######################################
								if($rws['dept_id']=='0' || $rws['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी </td>";
								}
								else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0' || $rws['dpt_inword_no']=='NULL')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								######################################### common things ####################
								echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws['sender_name']."<br><b>विषय : </b>".$rws['subject']."</td>";
								########################### If Action Taken Pending ###################				
								if($rws['action_taken']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else
								{
									echo "<td class='center'>".$rws['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws['ltr_status']=='' && $rws['waitflag']=='W' && $rws['wait_kar_flag']=='N')
								{
									echo "<td class=center>"."Await Register"."</td>";
								}
								else if($rws['ltr_status']=='' && $rws['waitflag']=='W' && $rws['wait_kar_flag']=='A')
								{	
									echo "<td class=center>"."Await Register Complete"."</td>";
								}
								else if($rws['ltr_status']=='' && $rws['waitflag']=='' && $rws['wait_kar_flag']=='')
								{
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else if($rws['ltr_approval']=='transferred')
								{
									$dpt_to=$rws['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws['ltr_approval']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws['ltr_approval']=='transferred_todesk')
								{
									$dsk_to=$rws['dsk_id_to'];
									$q=mysql_query("SELECT desk_nm from desk_master where desk_id='$dsk_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>transferred to<br>".$r['desk_nm']." </td>";
								}
								else if($rws['ltr_approval']=='Approve')
								{
									echo "<td class='center'>".$rws['ltr_status']."</td>";
								}
								##############################################################################
								if($rws['waitflag']=='W' && $rws['wait_kar_flag']=='A')
								{
									echo "<td class='center'>"."कार्यवाही पूर्ण झाली."."</td>";
								}
								else if($rws['dispatched_to']=='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								}
								else if($rws['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."अपडेट केले</td>";
								}
								else if($rws['dispatched_to']!='' && $rws['ltr_status']!='updated')
								{
									echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."".$depto['dept_nm']."".$r['desk_nm']."</td>";
								}
								////////////////////////////////////////////////////////////////////////////////
								
								echo "</tr>";
								
							}//mysql_close();
							
							
						}//if($result1['desk_flag']=='y')
							
						else if($result1['desk_flag']=='N' || $result1['desk_flag']=='n')
						{
							
							if($date123==''&& $date223=='')
							{
								convert_marathi();
								$result2221=mysql_query("SELECT t.waitflag,t.wait_kar_flag,t.action_taken, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, t.update_date, t.dispatched_date, t.status, di.addressed_to,di.dept_id_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
								FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON (di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								where t.dpt_ltr_id='$dept_ltr_id' ") or die("".mysql_error());
								
							}
							else{
								
								$result2221=mysql_query("SELECT t.waitflag,t.wait_kar_flag,t.action_taken, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, t.update_date, t.dispatched_date, t.status, di.addressed_to,di.dept_id_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, di.outword_no, di.dispatched_to, t.ltr_category, t.assign_no 
								FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON (di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								where (i.receive_dt BETWEEN '$date1' AND '$date2') AND t.dpt_ltr_id='$dept_ltr_id'") or die("".mysql_error());
							}
							
							while($rws1 = mysql_fetch_array($result2221))
							{	
								
								//$deskltrid=$rws['desk_ltr_id'];
								
								$ltrid=$rws1['ltr_id'];
								########################### Fetch department name ##############################
								if($rws1['dept_id_from']!='' || $rws1['dept_id_from']!='0')
								{
									$depti=$rws1['dept_id_from'];
									convert_marathi();
									$qdpt1=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept1=mysql_fetch_array($qdpt1);
								}
								################# convert date in suitable format ##########################
								
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class=gradeX>";
								################################### Desk ####################################
								if($rws1['desk_id']=='0' || $rws1['desk_id']=='')
								{
									//echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
									echo "<td class='center'> -- </td>";
								}
								else if($rws1['desk_ltr_inword_no']=='' || $rws1['desk_ltr_inword_no']=='0')
								{
									//echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
									echo "<td class='center'> -- </td>";
								}
								else
								{
									//echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
									echo "<td class='center'> -- </td>";
								}
							
								############################## dpt######################################
								if($rws1['dept_id']=='0' || $rws1['dept_id']=='')
								{
									echo "<td class='center'>विभाग लावणे बाकी</td>";
								}
								else if($rws1['dpt_inword_no']=='' || $rws1['dpt_inword_no']=='0' || $rws1['dpt_inword_no']=='NULL')
								{
									echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								}
								else
								{
									echo "<td class='center'>".$dept1['dept_nm']."<br>".$rws1['dpt_inword_no']."<br>".$dprecdt1." </td>";
								}
								######################################### common things ####################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								########################### If Action Taken Pending ###################				
								if($rws1['action_taken']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else
								{
									echo "<td class='center'>".$rws1['action_taken']."</td>";
								}
								######################### For Letter Status #################################
								if($rws1['ltr_status']=='' && $rws1['waitflag']=='W' && $rws1['wait_kar_flag']=='N')
								{
									echo "<td class=center>"."Await Register"."</td>";
								}
								else if($rws1['ltr_status']=='' && $rws1['waitflag']=='W' && $rws1['wait_kar_flag']=='A')
								{	
									echo "<td class=center>"."Await Register Complete"."</td>";
								}
								else if($rws1['ltr_status']=='' && $rws1['waitflag']=='' && $rws1['wait_kar_flag']=='')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								}
								else if($rws1['status']=='transferred')
								{
									$dpt_to=$rws1['dept_id_to'];
									$q=mysql_query("SELECT dept_nm from department_master where dept_id='$dpt_to' ");
									$r=mysql_fetch_array($q);
									echo "<td class='center'>".$rws1['status']." to <br>".$r['dept_nm']."</td>";
								}
								else if($rws1['status']=='dispatched')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['ltr_status']."</td>";
								} 
								##############################################################################
								if($rws1['waitflag']=='W' && $rws1['wait_kar_flag']=='A')
								{
									echo "<td class='center'>"."कार्यवाही पूर्ण झाली."."</td>";
								}
								else if($rws1['dispatched_to']=='' && $rws1['ltr_status']!='updated')
								{
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								}
								else if($rws1['ltr_status']=='updated')
								{
									echo "<td class='center'>".$rws1['outword_no']."अपडेट केले</td>";
								}
								else if($rws1['dispatched_to']!='' && $rws1['ltr_status']!='updated')
								{
									$dept_to=$rws1['dept_id_to'];
									$qdpto=mysql_query("Select dept_nm from department_master Where dept_id='$dept_to'") or die("".mysql_error());
									$depto=mysql_fetch_array($qdpto);
									echo "<td class='center'>".$rws1['outword_no']."<br>".$rws1['addressed_to']."<br>".$depto['dept_nm']."</td>";
								}
								////////////////////////////////////////////////////////////////////////
								
								echo "</tr>";
							}//mysql_close();
						}// else if($result1['desk_flag']=='n')
							
					} //while
						
			/////////////dept pending ltrs/////////////////
				if($date123==''&& $date223=='')
				{
					convert_marathi();
					$result2223=mysql_query("SELECT * 
					from incoming_letters_transaction i
					where i.status='pending' ") or die("xyzxyz".mysql_error());
				}
				else{
					convert_marathi();
					$result2223=mysql_query("SELECT * 
					from incoming_letters_transaction i
					where i.status='pending'
					AND (i.receive_dt BETWEEN '$date1' AND '$date2')") or die("xyzxyz".mysql_error());
				}
				while($rws1 = mysql_fetch_array($result2223))
				{			
					$dptid=$rws1['dept_id'];
					$qry=mysql_query("SELECT desk_flag from department_master where dept_id='$dptid'");
					$rws2 = mysql_fetch_array($qry);
					if($rws2['desk_flag']=='y' || $rws2['desk_flag']=='Y')
					{
								
								$ltrid=$rws['ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								
								################# convert date in suitable format ##########################
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class=gradeX>";
								################################### Desk ####################################
								echo "<td class='center'>डेस्क लावणे बाकी </td>";
								
							
								############################## dpt######################################
								echo "<td class='center'> विभागाने स्वीकारणे बाकी </td>";
								
								######################################### common things ####################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								########################### If Action Taken Pending ###################				
								
								echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								
								
								echo" </tr>";
								
					}
					else if($rws2['desk_flag']=='n' || $rws2['desk_flag']=='N')
					{
								$ltrid=$rws['ltr_id'];
								########################### Fetch department name ##############################
								if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
								{
									$depti=$rws['dept_id_from'];
									convert_marathi();
									$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$depti'") or die("".mysql_error());
									$dept=mysql_fetch_array($qdpt);
								}
								
								################# convert date in suitable format ##########################
								$dprecdt = strtotime($rws1['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rws1['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws1['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);		
								echo "<tr class=gradeX>";
								################################### Desk ####################################
								echo "<td class='center'>-- </td>";
								
							
								############################## dpt######################################
								echo "<td class='center'> विभागाने स्वीकारणे बाकी  </td>";
								
								######################################### common things ####################
								echo "<td class='center'>".$rws1['ltr_inword_no']."<br>".$recdt1." </td>
								<td class='center'>".$rws1['ref_no']."<br>".$refdt1."</td>
								<td><b>नाव : </b>".$rws1['sender_name']."<br><b>विषय : </b>".$rws1['subject']."</td>";
								########################### If Action Taken Pending ###################				
								
								echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								######################### For Letter Status #################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी "."</td>";
								
								##############################################################################
								
									echo "<td class='center'>"."कार्यवाही करणे बाकी"."</td>";
								
								
								echo " </tr>";
					}
				} //mysql_close()
			echo "</tbody>
			</table></center></div>";
			
					?>
							<br>
							<p>	
								<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"/>
								<input type="button" class="btn" onclick="tableToExcel('export', 'W3C Example Table')" value="Export to Excel"></center>
							</p>
						</form>
							<br /><br />
						
					
                    <?php include_once('footer.php'); ?>
				</div><!--maincontentinner-->
			</div><!--maincontent-->
		</div><!--rightpanel-->
</div><!--mainwrapper-->
</body>
</html>