<!DOCTYPE html>
<?php 
$flag=$_REQUEST['flag'];
if($flag=='')
{
$user=$_GET['user'];
if($user=='tapal')
{
	require_once('dashboard_tapal.php');
	include_once('convert_marathi.php');
	$username = $_SESSION['User_Name'];
	$ltrid=$_GET['ltrid'];
	?>

	<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>
	<style type="text/css">
	.highlight{
	background:#eee;
	}
	</style>
	</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>पत्र फिर्तीनुसार रिपोर्ट्स</h1>
				</div>
			</div>
<?php } 

if($user=='bdo')
{
	require_once('dashboard_bdo.php');
	include_once('convert_marathi.php');
	$username = $_SESSION['User_Name'];
	$ltrid=$_GET['ltrid'];
	?>
	<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>
	<style type="text/css">
	.highlight{
	background:#eee;
	}
	</style>
	</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>पत्र फिर्तीनुसार रिपोर्ट्स</h1>
				</div>
			</div>
<?php } 
else if($user=='dept')
{
		require_once('dashboard_department.php');
		include_once('convert_marathi.php');
		$username = $_SESSION['User_Name'];
		$ltrid=$_GET['ltrid'];
		?>

		<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>
		<style type="text/css">
		.highlight{
		background:#eee;
		}
		</style>
		</head>
		<body>
		<div class="mainwrapper">   
			<div class="rightpanel">
				<ul class="breadcrumbs">
					<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
					<li><a href="">Tables</a> <span class="separator"></span></li>
					<li>पत्र फिर्तीनुसार रिपोर्ट्स</li>
				</ul>
				<div class="pageheader">
					<div class="pageicon"><span class="iconfa-table"></span></div>
					<div class="pagetitle">
						<h5>Tables</h5>
						<?php 
						$qryz=mysql_query("Select dept_nm from department_master where dept_id=(select dept_id from login where login_id='$username')");
						$rsz=mysql_fetch_array($qryz);
						?>	
						<h1><?php echo 	$rsz['dept_nm'];?>  चे पत्र फिर्तीनुसार रिपोर्ट्स</h1>
					</div>
				</div><!--pageheader-->
<?php }
else if($user=='deptn')
{
		require_once('new_dashboard_department.php');
		include_once('convert_marathi.php');
		$username = $_SESSION['User_Name'];
		$ltrid=$_GET['ltrid'];
		?>

		<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>
		<style type="text/css">
		.highlight{
		background:#eee;
		}
		</style>
		</head>
		<body>
		<div class="mainwrapper">   
			<div class="rightpanel">
				<ul class="breadcrumbs">
					<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
					<li><a href="">Tables</a> <span class="separator"></span></li>
					<li>पत्र फिर्तीनुसार रिपोर्ट्स</li>
				</ul>
				<div class="pageheader">
					<div class="pageicon"><span class="iconfa-table"></span></div>
					<div class="pagetitle">
						<h5>Tables</h5>
						<?php 
						$qryz=mysql_query("Select dept_nm from department_master where dept_id=(select dept_id from login where login_id='$username')");
						$rsz=mysql_fetch_array($qryz);
						?>	
						<h1><?php echo 	$rsz['dept_nm'];?>  चे पत्र फिर्तीनुसार रिपोर्ट्स</h1>
					</div>
				</div><!--pageheader-->
<?php }
else if($user=='desk')
{
		include_once('dashboard_desk.php');
		include_once('convert_marathi.php');
		$username = $_SESSION['User_Name'];
		$ltrid=$_GET['ltrid'];
		?>

		<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>
		<style type="text/css">
		.highlight{
		background:#eee;
		}
		</style>
		</head>
		<body>
		<div class="mainwrapper">   
			<div class="rightpanel">
				<ul class="breadcrumbs">
					<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
					<li><a href="">Tables</a> <span class="separator"></span></li>
					<li>पत्र फिर्तीनुसार रिपोर्ट्स</li>
				</ul>
				<div class="pageheader">
					<div class="pageicon"><span class="iconfa-table"></span></div>
					<div class="pagetitle">
						<h5>Tables</h5>
						<?php 
						$qryz=mysql_query("Select dept_nm from department_master where dept_id=(select dept_id from login where login_id='$username')");
						$rsz=mysql_fetch_array($qryz);
						?>	
						<h1><?php echo 	$rsz['dept_nm'];?>  चे पत्र फिर्तीनुसार रिपोर्ट्स</h1>
					</div>
				</div><!--pageheader-->
<?php }
?>
        <div class="maincontent">
            <div class="maincontentinner">
					<h4 class="widgettitle"></h4>
					<form method="post" action="">
							<!-- ############################# Display Main Reference With Common Information ################ -->
							<table id="dyntable" class="table table-bordered">									
								<tr>
									<th class="head1 center">पोलीस अधिक्षक कार्यालय <br> आवक क्र.<br>प्राप्त दि.</th>
									<th class="head1 center">संदर्भ_क्रमांक<br>संदर्भ दि.</th>
									<th class="head0 center">कोणाकडून प्राप्त झाले </th>
									<th class="head1 center">विषय </th>                     
								</tr>
							<tbody>
							<?php
							//convert_marathi();
							$result221=mysql_query("SELECT * from incoming_letters_transaction where ltr_id='$ltrid'");
							while($rwq = mysql_fetch_array($result221))
							{	
								$recdt = strtotime($rwq['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);
								$refdt = strtotime($rwq['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
										
								echo "<tr><td class='center' style='font-weight:bold;font-size:15px;'>".$rwq['ltr_inword_no']."<br>".$recdt1."</td>
								<td class='center' style='font-weight:bold;font-size:15px;'>".$rwq['ref_no']."<br>".$refdt1."</td>
								<td class='center' style='font-weight:bold;font-size:15px;'>".$rwq['sender_name']."<br>".$dprecdt1."</td>";
								echo "<td class='center' style='font-weight:bold;font-size:15px;' >".$rwq['subject']."</td>";
								echo"</tr>";
							}
							######################### End Of Display Main Reference With Common Information ################ 
							//mysql_close();
							echo	"</tbody></table>";
							?>
					</form>
					<!-- ################################### Display Other Reference Information ################ -->
					<br>	
							<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>संदर्भ दि.</th>
										<th class="head1 center">विभागाकडून प्राप्त </th>
										<th class="head0 center">विभागाला पाठवले</th>
										<th class="head1 center">डेस्क आवक_क्रमांक<br>प्राप्त दि.</th>
										<th class="head0 center">डेस्कचे_नाव </th>
										<th class="head1 center">केलेली_कार्यवाही </th>   -->
										
										<th class="head1 center">विभागीय आ_क्र. <br>प्राप्त दि.  </th>
										<th class="head1 center">विभागाकडून / डेस्ककडून प्राप्त </th>
										<th class="head0 center">विभागाला / डेस्कला पाठवले</th>
										<th class="head1 center">डेस्क आवक_क्रमांक<br>प्राप्त दि.</th>
										<th class="head0 center">कार्यवाही केलेल्या <br> डेस्कचे_नाव </th>
										<th class="head1 center">केलेली_कार्यवाही </th> 
									</tr>
								</thead>
								<tbody>
								<?php
									convert_marathi();
								
								$result00=mysql_query("SELECT * FROM incoming_letters_transaction i, tapal_to_dpt_transaction t,department_master dm
								WHERE t.ltr_id='$ltrid'
								AND t.ltr_id=i.ltr_id
								AND t.dept_id_from=dm.dept_id ") or die("xyzxyz".mysql_error());
								$c=mysql_num_rows($result00);
									
						while($row = mysql_fetch_array($result00))
						{
								$deptidfrm=$row['dept_id_from']	;
								if($row['desk_flag']=='Y' || $row['desk_flag']=='y')
								{		
									/*$result222=mysql_query("SELECT * FROM dispatched_transaction, incoming_letters_transaction, tapal_to_dpt_transaction, desk_transaction WHERE dispatched_transaction.ltr_id='$ltrid' AND incoming_letters_transaction.ltr_id=dispatched_transaction.ltr_id AND tapal_to_dpt_transaction.ltr_id=incoming_letters_transaction.ltr_id AND tapal_to_dpt_transaction.desk_ltr_inword_no=desk_transaction.desk_ltr_inword_no AND tapal_to_dpt_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id AND dispatched_transaction.desk_ltr_id=desk_transaction.desk_ltr_id ") or die("".mysql_error());*/
									$result222=mysql_query("SELECT i.receive_dt, i.ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_rec_dt, i.ref_no, i.ref_dt, di.dept_id_from, di.dept_id_to, d.action_taken, di.dispatched_to, di.dsk_id_from, di.dsk_id_to, di.desk_ltr_id, d.desk_ltr_inword_no, d.desk_ltr_rec_dt, d.desk_id_from, t.desk_id
									FROM dispatched_transaction di, incoming_letters_transaction i, tapal_to_dpt_transaction t, desk_transaction d 
									WHERE di.ltr_id='$ltrid' 
									AND i.ltr_id=di.ltr_id 
									AND t.ltr_id=i.ltr_id 
									AND t.dpt_ltr_id=d.dpt_ltr_id 
									AND di.desk_ltr_id=d.desk_ltr_id
									And t.dept_id_from='$deptidfrm'") or die("".mysql_error());
									
									$cnt=mysql_num_rows($result222);
									
									while($rws = mysql_fetch_array($result222))
									{
										$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);
										$desk=$rws['desk_id'];
										$deskid=$rws['desk_id_from'];
										
										$dptfrom=$rws['dept_id_from'];
										$dptto=$rws['dept_id_to'];
										$dskfrom=$rws['dsk_id_from'];
										$dskto=$rws['dsk_id_to'];
										
										echo "<tr class='highlight'>"; 
										echo "
										<td style='text-align:center;'>".$rws['dpt_inword_no']."<br>".$dprecdt1."</td>";
										
										//////////////////////////////////////////////////////////////////
									/*	$rt1="select dept_nm from department_master where dept_id='$dptfrom'";
										$rw3=mysql_query($rt1);	
										$x1=mysql_fetch_array($rw3);
										echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										
										if($rws['dept_id_to']=='0')
										{
											echo "<td style='text-align:center;'>"."अर्जदाराला पाठविले"."</td>";
										}
										else
										{
											$rt2="select dept_nm from department_master where dept_id='$dptto'";
											$rw4=mysql_query($rt2);	
											$x2=mysql_fetch_array($rw4);
											echo "<td style='text-align:center;'>".$x2['dept_nm']."</td>";
										}	*/
										
										if($rws['dispatched_to']=='department')
										{
											$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										}
										else if($rws['dispatched_to']=='desk')
										{
											$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskfrom' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
										}
										else
										{
											if($rws['desk_ltr_id']=='0')
											{
												$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
												$x1=mysql_fetch_array($rw3);
												echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
											}
											else
											{
												$rw3=mysql_query("select desk_nm from desk_master where desk_id='$deskid' ");	
												$x1=mysql_fetch_array($rw3);
												echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
											}
										}
										//////////////////////////////////////////////////////////////////
										if($rws['dispatched_to']=='department')
										{
											$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptto' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										}
										else if($rws['dispatched_to']=='desk')
										{
											$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskto' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
										}
										else
										{
											echo "<td style='text-align:center;'>"."अर्जदाराला पाठविले"."</td>";
										}
										
										//////////////////////////////////////////////////////////////////
										
										echo "<td style='text-align:center;'>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1."</td>";
										$rt="select desk_nm from desk_master where desk_id='$deskid'";
										$rw2=mysql_query($rt);	
										$x=mysql_fetch_array($rw2);
										echo "<td style='text-align:center;'>".$x['desk_nm']."</td>
										<td style='text-align:center;'>".$rws['action_taken']."</td>";
										
										echo"</tr>";
									}
										//mysql_close();
							//echo	"</tbody> 
							//</table>";
					}
					else if($row['desk_flag']=='n' || $row['desk_flag']=='N')
					{
						$result2221=mysql_query("SELECT i.receive_dt,i.ltr_inword_no,t.dpt_inword_no,t.dpt_ltr_rec_dt,i.ref_no,i.ref_dt, di.desk_ltr_id, di.dispatched_to, di.dept_id_from,di.dept_id_to, di.dsk_id_from, di.dsk_id_to, t.action_taken FROM dispatched_transaction di, incoming_letters_transaction i, tapal_to_dpt_transaction t 
						WHERE di.ltr_id='$ltrid' 
						AND (i.ltr_id=di.ltr_id AND di.desk_ltr_id=0)
						AND t.ltr_id=i.ltr_id 
						
						AND (t.desk_id='0' OR t.desk_id='')
						And t.dept_id_from='$deptidfrm' ") or die("".mysql_error());
						
						$cnt=mysql_num_rows($result2221);
									//echo "xxxxxxxxxx".$cnt;
									
						while($rws = mysql_fetch_array($result2221))
						{
										
							$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);
						
							$dptfrom=$rws['dept_id_from'];
							$dptto=$rws['dept_id_to'];
							$dskfrom=$rws['dsk_id_from'];
							$dskto=$rws['dsk_id_to'];
							?>
							<tr class="highlight">
							<?php 
								echo "
								<td class='center'>".$rws['dpt_inword_no']."<br>".$dprecdt1."</td>";
								
								//////////////////////////////////////////////////////////////////
								/*$rt1="select dept_nm from department_master where dept_id='$dptfrom'";
								$rw3=mysql_query($rt1);	
								$x1=mysql_fetch_array($rw3);
								echo "<td class='center'>".$x1['dept_nm']."</td>";
										
								if($rws['dept_id_to']=='0')
								{
									echo "<td class='center'>"."अर्जदाराला पाठविले"."</td>";
								}
								else
								{
									$rt2="select dept_nm from department_master where dept_id='$dptto'";
									$rw4=mysql_query($rt2);	
									$x2=mysql_fetch_array($rw4);
									echo "<td class=center>".$x2['dept_nm']."</td>";
								}*/
								
								if($rws['dispatched_to']=='department')
								{
									$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom'");	
									$x1=mysql_fetch_array($rw3);
									echo "<td class='center'>".$x1['dept_nm']."</td>";
								}
								else if($rws['dispatched_to']=='desk')
								{
									$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskto' ");	
									$x1=mysql_fetch_array($rw3);
									echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
								}
								else
								{
									if($rws['desk_ltr_id']=='0')
									{
										$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
										$x1=mysql_fetch_array($rw3);
										echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
									}
									else
									{
										$rw3=mysql_query("select desk_nm from desk_master where desk_id='$deskid' ");	
										$x1=mysql_fetch_array($rw3);
										echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
									}
								}
								
								
								///////////////////////////////////////////////////////////
								if($rws['dispatched_to']=='department')
								{
									$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptto'");	
									$x1=mysql_fetch_array($rw3);
									echo "<td class='center'>".$x1['dept_nm']."</td>";
								}
								else
								{
									echo "<td class='center'>"."अर्जदाराला पाठविले"."</td>";
								}
								///////////////////////////////////////////////////////////
								echo "<td class='center'> -- </td>";
								//////////////////////////////////////////////////////////
								$rt="select desk_nm from desk_master where desk_id='$desk'";
								$rw2=mysql_query($rt);	
								$x=mysql_fetch_array($rw2);
								
								echo "<td class='center'> -- </td>
								<td class='center'>".$rws['action_taken']."</td>";
								
								echo"</tr>";
						}
						//mysql_close();
							
					}  //else if($row['desk_flag']=='N' || $row['desk_flag']=='n')
						
			}
			//mysql_close();
			echo	"</tbody> 
			</table>";
							
						echo "<div id='divToPrint' style='display:none;'>
								<center><table id='export' border='1px' style='margin-left:50px;'>";
								echo ' <center><h2>पोलीस अधिक्षक कार्यालय, <br> जि.रायगड <h2></center>';
								convert_marathi();
								$result221=mysql_query("SELECT * from incoming_letters_transaction where ltr_id=$ltrid");
								$rwq = mysql_fetch_array($result221);
								
							################# End Of Display Main Reference With Common Information ################ 
							//mysql_close();
							$recdt = strtotime($rwq['receive_dt']);
							$recdt1= date('d-m-Y', $recdt);
							$refdt = strtotime($rwq['ref_dt']);
							$refdt1= date('d-m-Y', $refdt);
							echo "<tr><td colspan='8'><center><h4>".$rsz['dept_nm']."चे पत्र फिरतीची माहिती </h4></center></td></tr>
								<tr>
									<td colspan='2'><center><strong>पोलीस अधिक्षक कार्यालय<br> आवक क्र. <br>प्राप्त दि. : </strong><br>".$rwq['ltr_inword_no']."<br>".$recdt1."</center></td>
									<td colspan='2'><center><strong>संदर्भ_क्रमांक<br>संदर्भ दि. : </strong><br>".$rwq['ref_no']."<br>".$refdt1."</center></td>";
									/*echo "<td colspan='2'><bold>कोणाकडून प्राप्त झाले :</bold><br>".$rwq['sender_name']."<br>".$dprecdt1."</td>";
									echo "<td colspan='4'><bold>विषय  :</bold><br>".$rwq['subject']."<br>".$refdt1."</td>  */
									echo "<td colspan='1'><center><strong>कोणाकडून प्राप्त झाले :</strong><br>".$rwq['sender_name']."</center></td>";
									echo "<td colspan='2'><center><strong>विषय  :</strong><br>".$rwq['subject']."</center></td>
								</tr>
								
								<tr>
									<th>विभागीय_आ_क्रमांक<br>प्राप्त_दिनांक </th>
									<th>विभागाकडून प्राप्त </th>
									<th>विभागाला पाठवले </th>
									<th>डेस्कचा_आवक_क्रमांक<br>प्राप्त_दिनांक</th>
									<th>कार्यवाही केलेल्या <br> डेस्कचे_नाव </th>
									<th>केलेली कार्यवाही </th>                          
								</tr>";
									convert_marathi();
									$result00=mysql_query("SELECT * FROM incoming_letters_transaction i, tapal_to_dpt_transaction t,department_master dm
									WHERE t.ltr_id='$ltrid'
									AND t.ltr_id=i.ltr_id
									AND t.dept_id_from=dm.dept_id ") or die("xyzxyz".mysql_error());
									
						$c=mysql_num_rows($result00);
									
						while($row = mysql_fetch_array($result00))
						{
								$deptidfrm=$row['dept_id_from']	;
								if($row['desk_flag']=='Y' || $row['desk_flag']=='y')
								{		
									/*$result222=mysql_query("SELECT * FROM dispatched_transaction, incoming_letters_transaction, tapal_to_dpt_transaction, desk_transaction WHERE dispatched_transaction.ltr_id='$ltrid' AND incoming_letters_transaction.ltr_id=dispatched_transaction.ltr_id AND tapal_to_dpt_transaction.ltr_id=incoming_letters_transaction.ltr_id AND tapal_to_dpt_transaction.desk_ltr_inword_no=desk_transaction.desk_ltr_inword_no AND tapal_to_dpt_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id AND dispatched_transaction.desk_ltr_id=desk_transaction.desk_ltr_id ") or die("".mysql_error());*/
									$result222=mysql_query("SELECT i.receive_dt, i.ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_rec_dt, i.ref_no, i.ref_dt, di.dept_id_from, di.dept_id_to, d.action_taken, di.dispatched_to, di.dsk_id_from, di.dsk_id_to, di.desk_ltr_id, d.desk_ltr_inword_no, d.desk_ltr_rec_dt, d.desk_id_from, t.desk_id
									FROM dispatched_transaction di, incoming_letters_transaction i, tapal_to_dpt_transaction t, desk_transaction d 
									WHERE di.ltr_id='$ltrid' 
									AND i.ltr_id=di.ltr_id 
									AND t.ltr_id=i.ltr_id 
									AND t.dpt_ltr_id=d.dpt_ltr_id 
									AND di.desk_ltr_id=d.desk_ltr_id
									And t.dept_id_from='$deptidfrm'") or die("".mysql_error());
									
									$cnt=mysql_num_rows($result222);
									while($rws = mysql_fetch_array($result222))
									{
										$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);
										$desk=$rws['desk_id'];
										$deskid=$rws['desk_id_from'];
										
										$dptfrom=$rws['dept_id_from'];
										$dptto=$rws['dept_id_to'];
										$dskfrom=$rws['dsk_id_from'];
										$dskto=$rws['dsk_id_to'];
										
										echo "<tr class='highlight'>"; 
										echo "
										<td style='text-align:center;'>".$rws['dpt_inword_no']."<br>".$dprecdt1."</td>";
										
										//////////////////////////////////////////////////////////////////
									/*	$rt1="select dept_nm from department_master where dept_id='$dptfrom'";
										$rw3=mysql_query($rt1);	
										$x1=mysql_fetch_array($rw3);
										echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										
										if($rws['dept_id_to']=='0')
										{
											echo "<td style='text-align:center;'>"."अर्जदाराला पाठविले"."</td>";
										}
										else
										{
											$rt2="select dept_nm from department_master where dept_id='$dptto'";
											$rw4=mysql_query($rt2);	
											$x2=mysql_fetch_array($rw4);
											echo "<td style='text-align:center;'>".$x2['dept_nm']."</td>";
										}	*/
										
										if($rws['dispatched_to']=='department')
										{
											$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										}
										else if($rws['dispatched_to']=='desk')
										{
											$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskfrom' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
										}
										else
										{
											if($rws['desk_ltr_id']=='0')
											{
												$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
												$x1=mysql_fetch_array($rw3);
												echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
											}
											else
											{
												$rw3=mysql_query("select desk_nm from desk_master where desk_id='$deskid' ");	
												$x1=mysql_fetch_array($rw3);
												echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
											}
										}
										//////////////////////////////////////////////////////////////////
										if($rws['dispatched_to']=='department')
										{
											$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptto' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										}
										else if($rws['dispatched_to']=='desk')
										{
											$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskto' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
										}
										else
										{
											echo "<td style='text-align:center;'>"."अर्जदाराला पाठविले"."</td>";
										}
										
										//////////////////////////////////////////////////////////////////
										
										echo "<td style='text-align:center;'>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1."</td>";
										$rt="select desk_nm from desk_master where desk_id='$deskid'";
										$rw2=mysql_query($rt);	
										$x=mysql_fetch_array($rw2);
										echo "<td style='text-align:center;'>".$x['desk_nm']."</td>
										<td style='text-align:center;'>".$rws['action_taken']."</td>";
										
										echo"</tr>";
									}
									//mysql_close();
							//echo	"</tbody> 
							//</table>";
					}
					else if($row['desk_flag']=='n' || $row['desk_flag']=='N')
					{
						$result2221=mysql_query("SELECT i.receive_dt,i.ltr_inword_no,t.dpt_inword_no,t.dpt_ltr_rec_dt,i.ref_no,i.ref_dt, di.desk_ltr_id, di.dispatched_to, di.dept_id_from,di.dept_id_to, di.dsk_id_from, di.dsk_id_to, t.action_taken FROM dispatched_transaction di, incoming_letters_transaction i, tapal_to_dpt_transaction t 
						WHERE di.ltr_id='$ltrid' 
						AND (i.ltr_id=di.ltr_id AND di.desk_ltr_id=0)
						AND t.ltr_id=i.ltr_id 
						AND (t.desk_id='0' OR t.desk_id='')
						And t.dept_id_from='$deptidfrm' ") or die("".mysql_error());
							
						$cnt=mysql_num_rows($result2221);
									//echo "xxxxxxxxxx".$cnt;
									
						while($rws = mysql_fetch_array($result2221))
						{
										
							$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);
						
							$dptfrom=$rws['dept_id_from'];
							$dptto=$rws['dept_id_to'];
							$dskfrom=$rws['dsk_id_from'];
							$dskto=$rws['dsk_id_to'];
							?>
							<tr class="highlight">
							<?php 
								echo "
								<td class='center'>".$rws['dpt_inword_no']."<br>".$dprecdt1."</td>";
								
								//////////////////////////////////////////////////////////////////
								/*$rt1="select dept_nm from department_master where dept_id='$dptfrom'";
								$rw3=mysql_query($rt1);	
								$x1=mysql_fetch_array($rw3);
								echo "<td class='center'>".$x1['dept_nm']."</td>";
										
								if($rws['dept_id_to']=='0')
								{
									echo "<td class='center'>"."अर्जदाराला पाठविले"."</td>";
								}
								else
								{
									$rt2="select dept_nm from department_master where dept_id='$dptto'";
									$rw4=mysql_query($rt2);	
									$x2=mysql_fetch_array($rw4);
									echo "<td class=center>".$x2['dept_nm']."</td>";
								}*/
								
								if($rws['dispatched_to']=='department')
								{
									$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom'");	
									$x1=mysql_fetch_array($rw3);
									echo "<td class='center'>".$x1['dept_nm']."</td>";
								}
								else if($rws['dispatched_to']=='desk')
								{
									$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskto' ");	
									$x1=mysql_fetch_array($rw3);
									echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
								}
								else
								{
									if($rws['desk_ltr_id']=='0')
									{
										$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
										$x1=mysql_fetch_array($rw3);
										echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
									}
									else
									{
										$rw3=mysql_query("select desk_nm from desk_master where desk_id='$deskid' ");	
										$x1=mysql_fetch_array($rw3);
										echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
									}
								}
								
								
								///////////////////////////////////////////////////////////
								if($rws['dispatched_to']=='department')
								{
									$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptto'");	
									$x1=mysql_fetch_array($rw3);
									echo "<td class='center'>".$x1['dept_nm']."</td>";
								}
								else
								{
									echo "<td class='center'>"."अर्जदाराला पाठविले"."</td>";
								}
								///////////////////////////////////////////////////////////
								echo "<td class='center'> -- </td>";
								//////////////////////////////////////////////////////////
								$rt="select desk_nm from desk_master where desk_id='$desk'";
								$rw2=mysql_query($rt);	
								$x=mysql_fetch_array($rw2);
								
								echo "<td class='center'> -- </td>
								<td class='center'>".$rws['action_taken']."</td>";
								
								echo"</tr>";
						}
						//mysql_close();
							
					}  //else if($row['desk_flag']=='n' || $row['desk_flag']=='N')
						
				}//while
					
					
						//mysql_close();
							echo	"</table></center>
						</div>";
						?>
						<!-- ##################### Display Main Reference With Common Information ################ -->
						<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>
<?php
} //if($flag=='')

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

else if($flag=='n')
{
$user=$_GET['user'];

if($user=='dept')
{
		require_once('new_dashboard_department.php');
		include_once('convert_marathi.php');
		$username = $_SESSION['User_Name'];
		$ltrid=$_GET['ltrid'];
		?>

		<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>
		<style type="text/css">
		.highlight{
		background:#eee;
		}
		</style>
		</head>
		<body>
		<div class="mainwrapper">   
			<div class="rightpanel">
				<ul class="breadcrumbs">
					<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
					<li><a href="">Tables</a> <span class="separator"></span></li>
					<li>पत्र फिर्तीनुसार रिपोर्ट्स </li>
				</ul>
				<div class="pageheader">
					<div class="pageicon"><span class="iconfa-table"></span></div>
					<div class="pagetitle">
						<h5>Tables</h5>
						<?php 
						$qryz=mysql_query("Select dept_nm from department_master where dept_id=(select dept_id from login where login_id='$username')");
						$rsz=mysql_fetch_array($qryz);
						?>	
						<h1><?php echo 	$rsz['dept_nm'];?>चे पत्र फिर्तीनुसार रिपोर्ट्स</h1>
					</div>
				</div><!--pageheader-->
<?php }?>
        <div class="maincontent">
            <div class="maincontentinner">
					<h4 class="widgettitle"></h4>
					<form method="post" action="">
							<!-- ############################# Display Main Reference With Common Information ################ -->
							<table id="dyntable" class="table table-bordered">									
								<tr>
									<th class="head1 center">आवक क्र.<br>प्राप्त दि.</th>
									<th class="head0 center">संदर्भ_क्रमांक<br>संदर्भ दि.</th>
									<th class="head1 center">कोणाकडून प्राप्त झाले  </th>
									<th class="head0 center">विषय</th>                     
								</tr>
							<tbody>
							<?php
							//convert_marathi();
							$result221=mysql_query("SELECT * from incoming_letters_transaction where ltr_id='$ltrid'");
							while($rwq = mysql_fetch_array($result221))
							{	
								$recdt = strtotime($rwq['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);
								$refdt = strtotime($rwq['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								echo "<tr><td class='center' style='font-weight:bold;font-size:15px;'>".$rwq['ltr_inword_no']."<br>".$recdt1."</td>
								<td class='center' style='font-weight:bold;font-size:15px;'>".$rwq['ref_no']."<br>".$refdt1."</td>
								<td class='center' style='font-weight:bold;font-size:15px;'>".$rwq['sender_name']."</td>";
								echo "<td class='center' style='font-weight:bold;font-size:15px;' >".$rwq['subject']."</td>";
								echo"</tr>";
							}
							######################### End Of Display Main Reference With Common Information ################ 
							//mysql_close();
							echo	"</tbody></table>";
							?>
					</form>
					<!-- ################################### Display Other Reference Information ################ -->
					<br>	
							<table id="dyntable" class="table table-bordered">
								<thead>
									<tr>
										<th class="head1 center">विभागीय आ_क्र.  <br>प्राप्त दि.  </th>
										<th class="head1 center">विभागाकडून प्राप्त </th>
										<th class="head0 center">विभागाला पाठवले </th>
										<th class="head1 center">डेस्क आवक_क्रमांक<br>प्राप्त दि.</th>
										<th class="head0 center">कार्यवाही केलेल्या <br> डेस्कचे_नाव </th>
										<th class="head1 center">केलेली_कार्यवाही </th>                          
									</tr>
								</thead>
								<tbody>
								<?php
								convert_marathi();
								/*$result00=mysql_query("SELECT * FROM incoming_letters_transaction i, tapal_to_dpt_transaction t,department_master dm,
								WHERE t.ltr_id='$ltrid'
								AND t.ltr_id=i.ltr_id
								AND t.dept_id_from=dm.dept_id") or die("xyzxyz".mysql_error());
									$c=mysql_num_rows($result00);
									echo $c."sssssssssssssss";*/
								$result00=mysql_query("SELECT * FROM incoming_letters_transaction i, tapal_to_dpt_transaction t,department_master dm
								WHERE t.ltr_id='$ltrid'
								AND t.ltr_id=i.ltr_id
								AND t.dept_id_from=dm.dept_id ") or die("xyzxyz".mysql_error());
								$c=mysql_num_rows($result00);
									
						while($row = mysql_fetch_array($result00))
						{
								$deptidfrm=$row['dept_id_from']	;
								if($row['desk_flag']=='Y' || $row['desk_flag']=='y')
								{		
									/*$result222=mysql_query("SELECT * FROM dispatched_transaction, incoming_letters_transaction, tapal_to_dpt_transaction, desk_transaction WHERE dispatched_transaction.ltr_id='$ltrid' AND incoming_letters_transaction.ltr_id=dispatched_transaction.ltr_id AND tapal_to_dpt_transaction.ltr_id=incoming_letters_transaction.ltr_id AND tapal_to_dpt_transaction.desk_ltr_inword_no=desk_transaction.desk_ltr_inword_no AND tapal_to_dpt_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id AND dispatched_transaction.desk_ltr_id=desk_transaction.desk_ltr_id ") or die("".mysql_error());*/
									$result222=mysql_query("SELECT i.receive_dt,i.ltr_inword_no,t.dpt_inword_no,t.dpt_ltr_rec_dt,i.ref_no,i.ref_dt,
									di.dispatched_to, di.dept_id_from, di.dept_id_to, di.dsk_id_from, di.dsk_id_to,d.desk_id_from,  d.action_taken,d.desk_ltr_inword_no,d.desk_ltr_rec_dt,t.desk_id FROM dispatched_transaction di, incoming_letters_transaction i, tapal_to_dpt_transaction t, desk_transaction d 
									WHERE di.ltr_id='$ltrid' 
									AND i.ltr_id=di.ltr_id 
									AND t.ltr_id=i.ltr_id 
									AND t.dpt_ltr_id=d.dpt_ltr_id 
									AND di.desk_ltr_id=d.desk_ltr_id
									And t.dept_id_from='$deptidfrm'") or die("".mysql_error());
								
									$cnt=mysql_num_rows($result222);
									while($rws = mysql_fetch_array($result222))
									{
										$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);
										$desk=$rws['desk_id'];
										$deskidfrom=$rws['desk_id_from'];
										
										$dptfrom=$rws['dept_id_from'];
										$dptto=$rws['dept_id_to'];
										$dskfrom=$rws['dsk_id_from'];
										$dskto=$rws['dsk_id_to'];
										
										echo "<tr class='highlight'>"; 
										echo "<td style='text-align:center;'>".$rws['dpt_inword_no']."<br>".$dprecdt1."</td>";
										////////////////////////////////////////////////////////////////////////
										/*$rt1="select dept_nm from department_master where dept_id='$dptfrom'";
										$rw3=mysql_query($rt1);	
										$x1=mysql_fetch_array($rw3);
										echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										
										if($rws['dept_id_to']=='0')
										{
											echo "<td style='text-align:center;'>"."अर्जदाराला पाठविले"."</td>";
										}
										else
										{
											$rt2="select dept_nm from department_master where dept_id='$dptto'";
											$rw4=mysql_query($rt2);	
											$x2=mysql_fetch_array($rw4);
											echo "<td style='text-align:center;'>".$x2['dept_nm']."</td>";
										} */

										if($rws['dispatched_to']=='department')
										{
											$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										}
										else if($rws['dispatched_to']=='desk')
										{
											$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskfrom' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
										}
										else
										{
											if($rws['desk_ltr_id']=='0')
											{
												$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
												$x1=mysql_fetch_array($rw3);
												echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
											}
											else
											{
												$rw3=mysql_query("select desk_nm from desk_master where desk_id='$deskid' ");	
												$x1=mysql_fetch_array($rw3);
												echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
											}
										}
										//////////////////////////////////////////////////////////////////
										if($rws['dispatched_to']=='department')
										{
											$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptto' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										}
										else if($rws['dispatched_to']=='desk')
										{
											$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskto' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
										}
										else
										{
											echo "<td style='text-align:center;'>"."अर्जदाराला पाठविले"."</td>";
										}
										
										//////////////////////////////////////////////////////////////////
										echo "<td style='text-align:center;'>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1."</td>";
										$rt="select desk_nm from desk_master where desk_id='$deskidfrom'";
										$rw2=mysql_query($rt);	
										$x=mysql_fetch_array($rw2);
										echo "<td style='text-align:center;'>".$x['desk_nm']."</td><td style='text-align:center;'>".$rws['action_taken']."</td>";
										echo"</tr>";
									}
										//mysql_close();
							//echo	"</tbody> 
							//</table>";
					}
					else if($row['desk_flag']=='n' || $row['desk_flag']=='N')
					{
						$result2221=mysql_query("SELECT i.receive_dt,i.ltr_inword_no,t.dpt_inword_no,t.dpt_ltr_rec_dt,i.ref_no,i.ref_dt,
						di.dispatched_to, di.dept_id_from, di.dept_id_to, di.dsk_id_from, di.dsk_id_to, t.action_taken FROM dispatched_transaction di, incoming_letters_transaction i, tapal_to_dpt_transaction t 
						WHERE di.ltr_id='$ltrid' 
						AND (i.ltr_id=di.ltr_id AND di.desk_ltr_id=0)
						AND t.ltr_id=i.ltr_id 
						AND (t.desk_id='0' OR t.desk_id='')
						And t.dept_id_from='$deptidfrm'  ") or die("".mysql_error());
									
						$cnt=mysql_num_rows($result2221);
									//echo "xxxxxxxxxx".$cnt;
									
									while($rws = mysql_fetch_array($result2221))
									{
										
										$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);
										
										$dptfrom=$rws['dept_id_from'];
										$dptto=$rws['dept_id_to'];
										$dskfrom=$rws['dsk_id_from'];
										$dskto=$rws['dsk_id_to'];
										
										?>
										<tr class="highlight">
										<?php 
										echo "<td class='center'>".$rws['dpt_inword_no']."<br>".$dprecdt1."</td>";
										
										//////////////////////////////////////////////////////////////////////
										/*$rt1="select dept_nm from department_master where dept_id='$dptfrom'";
										$rw3=mysql_query($rt1);	
										$x1=mysql_fetch_array($rw3);
										echo "<td class='center'>".$x1['dept_nm']."</td>";
										
										if($rws['dept_id_to']=='0')
										{
											echo "<td class='center'>"."अर्जदाराला पाठविले "."</td>";
										}
										else
										{
											$rt2="select dept_nm from department_master where dept_id='$dptto'";
											$rw4=mysql_query($rt2);	
											$x2=mysql_fetch_array($rw4);
											echo "<td class=center>".$x2['dept_nm']."</td>";
										}	*/
										
										if($rws['dispatched_to']=='department')
										{
											$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										}
										else if($rws['dispatched_to']=='desk')
										{
											$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskfrom' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
										}
										else
										{
											if($rws['desk_ltr_id']=='0')
											{
												$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
												$x1=mysql_fetch_array($rw3);
												echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
											}
											else
											{
												$rw3=mysql_query("select desk_nm from desk_master where desk_id='$deskid' ");	
												$x1=mysql_fetch_array($rw3);
												echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
											}
										}
										//////////////////////////////////////////////////////////////////
										if($rws['dispatched_to']=='department')
										{
											$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptto' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										}
										else if($rws['dispatched_to']=='desk')
										{
											$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskto' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
										}
										else
										{
											echo "<td style='text-align:center;'>"."अर्जदाराला पाठविले"."</td>";
										}
										
										//////////////////////////////////////////////////////////////
										
										echo "<td class=center> -- </td>";
										echo "<td class=center> -- </td>";
										echo "<td class=center>".$rws['action_taken']."</td>";
										
										//////////////////////////////////////////////////////////////////
									
									echo"</tr>";
								}
										//mysql_close();
							
						}  //else if($row['desk_flag']=='n' || $row['desk_flag']=='N')
						
					}//while
					echo	"</tbody> 
							</table>";
							
							echo "<div id='divToPrint' style='display:none;'>
								<center><table id='export' border='1px' style='margin-left:50px;'>";
								
								echo ' <center><h2>पोलीस अधिक्षक कार्यालय, <br> जि.रायगड <h2></center>';
								
								convert_marathi();
								$result221=mysql_query("SELECT * from incoming_letters_transaction where ltr_id=$ltrid");
								$rwq = mysql_fetch_array($result221);
								
							################# End Of Display Main Reference With Common Information ################ 
							//mysql_close();
							$recdt = strtotime($rwq['receive_dt']);
							$recdt1= date('d-m-Y', $recdt);
							$refdt = strtotime($rwq['ref_dt']);
							$refdt1= date('d-m-Y', $refdt);
							echo "<tr><td colspan='8'><center><h4>".$rsz['dept_nm']."चे पत्र फिरतीची माहिती </h4></center></td></tr>
								<tr>
									<td colspan='2'><center><strong>पोलीस अधिक्षक कार्यालय<br>आवक_क्रमांक<br>प्राप्त_दिनांक: </strong><br>".$rwq['ltr_inword_no']."<br>".$recdt1."</center></td>
									<td colspan='2'><center><strong>संदर्भ_क्रमांक<br>संदर्भ_दिनांक  : </strong><br>".$rwq['ref_no']."<br>".$refdt1."</center></td>
									<td colspan='1'><center><strong>कोणाकडून प्राप्त झाले :</strong><br>".$rwq['sender_name']."</center></td>
									<td colspan='4'><center><strong>विषय  :</strong><br>".$rwq['subject']."</center></td>                  
								</tr>
								
									<tr>
										<th>विभागीय_आ_क्रमांक<br>प्राप्त_दिनांक </th>
										<th>विभागाकडून प्राप्त </th>
										<th>विभागाला पाठवले </th>
										<th>डेस्कचा_आवक_क्रमांक<br>प्राप्त_दिनांक</th>
										<th>कार्यवाही केलेल्या <br> डेस्कचे_नाव </th>
										<th>केलेली कार्यवाही </th>                          
									</tr>";
									convert_marathi();
									$result00=mysql_query("SELECT * FROM incoming_letters_transaction i, tapal_to_dpt_transaction t,department_master dm
									WHERE t.ltr_id='$ltrid'
									AND t.ltr_id=i.ltr_id
									AND t.dept_id_from=dm.dept_id ") or die("xyzxyz".mysql_error());
									
						$c=mysql_num_rows($result00);
									
						while($row = mysql_fetch_array($result00))
						{
								$deptidfrm=$row['dept_id_from']	;
								if($row['desk_flag']=='Y' || $row['desk_flag']=='y')
								{		
									/*$result222=mysql_query("SELECT * FROM dispatched_transaction, incoming_letters_transaction, tapal_to_dpt_transaction, desk_transaction WHERE dispatched_transaction.ltr_id='$ltrid' AND incoming_letters_transaction.ltr_id=dispatched_transaction.ltr_id AND tapal_to_dpt_transaction.ltr_id=incoming_letters_transaction.ltr_id AND tapal_to_dpt_transaction.desk_ltr_inword_no=desk_transaction.desk_ltr_inword_no AND tapal_to_dpt_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id AND dispatched_transaction.desk_ltr_id=desk_transaction.desk_ltr_id ") or die("".mysql_error());*/
									$result222=mysql_query("SELECT i.receive_dt,i.ltr_inword_no,t.dpt_inword_no,t.dpt_ltr_rec_dt,i.ref_no,i.ref_dt,
									di.dispatched_to, di.dept_id_from, di.dept_id_to, di.dsk_id_from, di.dsk_id_to,d.desk_id_from,  d.action_taken,d.desk_ltr_inword_no,d.desk_ltr_rec_dt,t.desk_id FROM dispatched_transaction di, incoming_letters_transaction i, tapal_to_dpt_transaction t, desk_transaction d 
									WHERE di.ltr_id='$ltrid' 
									AND i.ltr_id=di.ltr_id 
									AND t.ltr_id=i.ltr_id 
									AND t.dpt_ltr_id=d.dpt_ltr_id 
									AND di.desk_ltr_id=d.desk_ltr_id
									And t.dept_id_from='$deptidfrm'") or die("".mysql_error());
									
									$cnt=mysql_num_rows($result222);
									while($rws = mysql_fetch_array($result222))
									{
										$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);
										$desk=$rws['desk_id'];
										$deskidfrom=$rws['desk_id_from'];
										
										$dptfrom=$rws['dept_id_from'];
										$dptto=$rws['dept_id_to'];
										$dskfrom=$rws['dsk_id_from'];
										$dskto=$rws['dsk_id_to'];
										
										echo "<tr class='highlight'>"; 
										echo "<td style='text-align:center;'>".$rws['dpt_inword_no']."<br>".$dprecdt1."</td>";
										////////////////////////////////////////////////////////////////////////
										/*$rt1="select dept_nm from department_master where dept_id='$dptfrom'";
										$rw3=mysql_query($rt1);	
										$x1=mysql_fetch_array($rw3);
										echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										
										if($rws['dept_id_to']=='0')
										{
											echo "<td style='text-align:center;'>"."अर्जदाराला पाठविले"."</td>";
										}
										else
										{
											$rt2="select dept_nm from department_master where dept_id='$dptto'";
											$rw4=mysql_query($rt2);	
											$x2=mysql_fetch_array($rw4);
											echo "<td style='text-align:center;'>".$x2['dept_nm']."</td>";
										} */

										if($rws['dispatched_to']=='department')
										{
											$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										}
										else if($rws['dispatched_to']=='desk')
										{
											$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskfrom' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
										}
										else
										{
											if($rws['desk_ltr_id']=='0')
											{
												$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
												$x1=mysql_fetch_array($rw3);
												echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
											}
											else
											{
												$rw3=mysql_query("select desk_nm from desk_master where desk_id='$deskid' ");	
												$x1=mysql_fetch_array($rw3);
												echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
											}
										}
										//////////////////////////////////////////////////////////////////
										if($rws['dispatched_to']=='department')
										{
											$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptto' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										}
										else if($rws['dispatched_to']=='desk')
										{
											$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskto' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
										}
										else
										{
											echo "<td style='text-align:center;'>"."अर्जदाराला पाठविले"."</td>";
										}
										
										//////////////////////////////////////////////////////////////////
										echo "<td style='text-align:center;'>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1."</td>";
										$rt="select desk_nm from desk_master where desk_id='$deskidfrom'";
										$rw2=mysql_query($rt);	
										$x=mysql_fetch_array($rw2);
										echo "<td style='text-align:center;'>".$x['desk_nm']."</td><td style='text-align:center;'>".$rws['action_taken']."</td>";
										echo"</tr>";
									}
									//mysql_close();
									
							//echo	"</tbody> 
							//</table>";
					}
					else if($row['desk_flag']=='n' || $row['desk_flag']=='N')
					{
						$result2221=mysql_query("SELECT i.receive_dt,i.ltr_inword_no,t.dpt_inword_no,t.dpt_ltr_rec_dt,i.ref_no,i.ref_dt,
						di.dispatched_to, di.dept_id_from, di.dept_id_to, di.dsk_id_from, di.dsk_id_to, t.action_taken FROM dispatched_transaction di, incoming_letters_transaction i, tapal_to_dpt_transaction t 
						WHERE di.ltr_id='$ltrid' 
						AND (i.ltr_id=di.ltr_id AND di.desk_ltr_id=0)
						AND t.ltr_id=i.ltr_id 
						AND (t.desk_id='0' OR t.desk_id='')
						And t.dept_id_from='$deptidfrm'  ") or die("".mysql_error());
							
						$cnt=mysql_num_rows($result2221);
									//echo "xxxxxxxxxx".$cnt;
									
						while($rws = mysql_fetch_array($result2221))
									{
										
										$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);
										
										$dptfrom=$rws['dept_id_from'];
										$dptto=$rws['dept_id_to'];
										$dskfrom=$rws['dsk_id_from'];
										$dskto=$rws['dsk_id_to'];
										
										?>
										<tr class="highlight">
										<?php 
										echo "<td class='center'>".$rws['dpt_inword_no']."<br>".$dprecdt1."</td>";
										
										//////////////////////////////////////////////////////////////////////
										/*$rt1="select dept_nm from department_master where dept_id='$dptfrom'";
										$rw3=mysql_query($rt1);	
										$x1=mysql_fetch_array($rw3);
										echo "<td class='center'>".$x1['dept_nm']."</td>";
										
										if($rws['dept_id_to']=='0')
										{
											echo "<td class='center'>"."अर्जदाराला पाठविले "."</td>";
										}
										else
										{
											$rt2="select dept_nm from department_master where dept_id='$dptto'";
											$rw4=mysql_query($rt2);	
											$x2=mysql_fetch_array($rw4);
											echo "<td class=center>".$x2['dept_nm']."</td>";
										}	*/
										
										if($rws['dispatched_to']=='department')
										{
											$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										}
										else if($rws['dispatched_to']=='desk')
										{
											$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskfrom' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
										}
										else
										{
											if($rws['desk_ltr_id']=='0')
											{
												$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptfrom' ");	
												$x1=mysql_fetch_array($rw3);
												echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
											}
											else
											{
												$rw3=mysql_query("select desk_nm from desk_master where desk_id='$deskid' ");	
												$x1=mysql_fetch_array($rw3);
												echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
											}
										}
										//////////////////////////////////////////////////////////////////
										if($rws['dispatched_to']=='department')
										{
											$rw3=mysql_query("select dept_nm from department_master where dept_id='$dptto' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['dept_nm']."</td>";
										}
										else if($rws['dispatched_to']=='desk')
										{
											$rw3=mysql_query("select desk_nm from desk_master where desk_id='$dskto' ");	
											$x1=mysql_fetch_array($rw3);
											echo "<td style='text-align:center;'>".$x1['desk_nm']."</td>";
										}
										else
										{
											echo "<td style='text-align:center;'>"."अर्जदाराला पाठविले"."</td>";
										}
										
										//////////////////////////////////////////////////////////////
										
										echo "<td class=center> -- </td>";
										echo "<td class=center> -- </td>";
										echo "<td class=center>".$rws['action_taken']."</td>";
										
										//////////////////////////////////////////////////////////////////
									
									echo"</tr>";
								}
										//mysql_close();
							
						}  //else if($row['desk_flag']=='N' || $row['desk_flag']=='n')
						
					}//while
					//mysql_close();
					
					echo	"</table></center>
				</div>";
						?>
						<!-- ##################### Display Main Reference With Common Information ################ -->
						<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>
<?php
} //else if($flag=='n')
?>