<!DOCTYPE html>

<?php
$flag=$_REQUEST['flag'];
$username = $_SESSION['User_Name'];
//$id=$_REQUEST['id'];
if($flag=='')
{
	/*require_once('convert_marathi.php');
	$no=$_GET['no'];
	$ltrid=$_REQUEST['ltr_id'];*/
	$no=$_REQUEST['no'];

	if($no=='2') 
	{
		require_once('convert_marathi.php');
		//$no=$_GET['no'];
		$ltrid=$_REQUEST['ltr_id'];
		$no=$_REQUEST['no'];
		include('rec_sort_desk_dashboard.php');
		
		?>
		
		<html>
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<script type="text/javascript">     
			   function PrintDiv() {    
				   var divToPrint = document.getElementById('divToPrint');
				   var popupWin = window.open('', '_blank', 'width=600,height=600');
				   popupWin.document.open();
				   popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
					popupWin.document.close();
			   }
		</script> 
		<script src="tableToExcel.js"></script>
		</head>

		<body>
		<div class="mainwrapper">   
			<div class="rightpanel">
				<ul class="breadcrumbs">
					<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
					<li><a href="">Tables</a> <span class="separator"></span></li>
					<li>बारकोड जोडणे </li>
				</ul>
				<div class="pageheader">
					<div class="pageicon"><span class="iconfa-table"></span></div>
					<div class="pagetitle">
						<h5>Tables</h5>
						<?php 
							$qx= mysql_query("SELECT * FROM desk_master dm,department_master d WHERE dm.desk_id = (select desk_id from login where login_id='$username')
							AND d.dept_id=dm.dept_id") or die("".mysql_error());
							$rwx=mysql_fetch_array($qx) or die("".mysql_error());
							
							$id=$_REQUEST['id'];
							
							$rack_no=$_POST['rack_no'];
							$row_no=$_POST['row_no'];
							$g_no=$_POST['g_no'];
						?>
					   <!-- <h1><?php echo 	$rsz['dept_nm'];?> रेकॉर्ड सॉर्टिंग </h1>-->
						<h1>बारकोड जोडणे </h1>
					</div>
				</div><!--pageheader-->
				<div class="maincontent">
					<div class="maincontentinner">
					<?php 
						echo "<h4 class=widgettitle>".$rwx['dept_nm']." -> ".$rwx['desk_nm']."  बारकोड जोडणे ( ".$id." )   </h4>"; 
					?>
						<form method="post" action="rec_sort_barcode_gen.php?no=2&id=<?php echo $id; ?>&uname=<?php echo $username; ?>">
							
							<?php 		
							if( $id != "")
							{
								echo "<br>
								<center>
								<table>
									 <col width='50'> <col width='20'> <col width='60'>
									 <col width='20'> <col width='60'> <col width='20'>
									<tr>
										<td class='center'><b>गठ्ठा क्र. = </b></td>
										<td>".$g_no."</td>
										<td class='center'> <b>Rack No. =</b> </td>
										<td>".$rack_no."</td>
										<td class='center'> <b>Row No. =</b> </td>
										<td>".$row_no."</td>
									</tr>
								</table>
								</center>
								<br>";
								
								convert_marathi();
								$result222=mysql_query("SELECT t.dpt_inword_no, t.dpt_ltr_rec_dt, i.subject,i.ltr_inword_no, d.desk_ltr_id, d.desk_ltr_inword_no, d.desk_ltr_rec_dt, d.nasti_nashta_dt, d.final_nashta_dt FROM desk_transaction d, tapal_to_dpt_transaction t, incoming_letters_transaction i
								WHERE ( d.vargawari!='' AND d.ltr_status !='')
								AND t.dept_id_from=(select dept_id from login where login_id='$username') 
								AND d.dpt_ltr_id=t.dpt_ltr_id 
								AND i.ltr_id=t.ltr_id 
								AND d.final_nashta_dt IS NOT NULL 
								AND d.desk_id_from=(select desk_id from login where login_id='$username') ") or die("sdfdfds".mysql_error());
							
							echo " <table id='dyntable' class='table table-bordered'>	
								<thead>
									<tr>
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक </th>
										<th class='head1 center'>देस्क आवक_क्र. <br>आवक_दिनांक </th>
										<th class='head1 center'>विषय</th>
										<th class='head1 center'>नस्‍ती	 सुरु कालावधी़ (महिना/वर्ष) </th>
										<th class='head1 center'>नसती नष्‍ट करावयाचा कालावधी (महिना/वर्ष) </th>
										<th class='head1 center'>नस्‍ती  नष्‍ट केल्‍याचा  दिनांक </th>
									</tr>
								</thead>";
								$i=1;
								
								if($id !='अ')
								{	
									while($test = mysql_fetch_array($result222))
									{
										if(isset($_POST[$i]))
										{
											$dsk_ltr_id=$test['desk_ltr_id'];
											
											$qw=mysql_query("UPDATE desk_transaction SET barcode_flag='y' where desk_ltr_id='$dsk_ltr_id' ");
											
											$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
											$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
											
											$d=$test['nasti_nashta_dt'];
											$exp=explode("-",$d);
											$nasti_dt=$exp[2]."-".$exp[1]."-".$exp[0];
											//$nasti_dt = date('d-m-Y',strtotime($test['nasti_nashta_dt']));
											
											$mnth1=  date('F',strtotime($test['desk_ltr_rec_dt']));
											$yr1= date('Y',strtotime($test['desk_ltr_rec_dt']));
											//echo $mnth;
											
											$mnth2=  date('F',strtotime($test['nasti_nashta_dt']));
											$yr2=$exp[0];
											
											$d1=$test['final_nashta_dt'];
											$exp1=explode("-",$d1);
											$final_nasti_dt=$exp1[2]."-".$exp1[1]."-".$exp1[0];
											
											echo "<tr class=gradeX>			
											<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
											<td class='center'>".$test['desk_ltr_inword_no']."<br>".$desk_ltr_rec_dt."</td>
											<td class='center'>".$test['subject']."</td>
											<td class='center'>".$mnth1." / ".$yr1."</td>
											<td class='center'>".$mnth2." / ".$yr2."</td>
											<td class='center'>".$final_nasti_dt."</td>
											";
											
											echo "</tr>";
											$inwardID=$test['ltr_inword_no'].",".$inwardID;
										}
										$i++;
									}
									mysql_query("INSERT into rec_sort_barcode(gattha_no,rack_no,row_no,inward_no,dept_desk_flag) 
									values ('$g_no','$rack_no','$row_no','$inwardID','desk') ");
							}
							else if($id =='अ')
							{	
									while($test = mysql_fetch_array($result222))
									{
										if(isset($_POST[$i]))
										{
											$dsk_ltr_id=$test['desk_ltr_id'];
											
											$qw=mysql_query("UPDATE desk_transaction SET barcode_flag='y' where desk_ltr_id='$dsk_ltr_id' ");
											
											$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
											$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
											
											$d=$test['nasti_nashta_dt'];
											$exp=explode("-",$d);
											$nasti_dt=$exp[2]."-".$exp[1]."-".$exp[0];
											//$nasti_dt = date('d-m-Y',strtotime($test['nasti_nashta_dt']));
											
											$mnth1=  date('F',strtotime($test['desk_ltr_rec_dt']));
											$yr1= date('Y',strtotime($test['desk_ltr_rec_dt']));
											//echo $mnth;
											
											$mnth2=  date('F',strtotime($test['nasti_nashta_dt']));
											$yr2=$exp[0];
											
											echo "<tr class=gradeX>			
											<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
											<td class='center'>".$test['desk_ltr_inword_no']."<br>".$desk_ltr_rec_dt."</td>
											<td class='center'>".$test['subject']."</td>
											<td class='center'>".$mnth1." / ".$yr1."</td>
											<td class='center'> कायम </td>
											<td class='center'> कायम </td>
											";
											
											echo "</tr>";
											$inwardID=$test['ltr_inword_no'].",".$inwardID;
										}
										$i++;
									}
									mysql_query("INSERT into rec_sort_barcode(gattha_no,rack_no,row_no,inward_no,dept_desk_flag) 
									values ('$g_no','$rack_no','$row_no','$inwardID','desk') ");
							}
								//mysql_close();
								echo"   </tbody>
								</table>";
								
							echo "<div id='divToPrint' style='display:none;'>
								<center><h2>पोलीस अधिक्षक कार्यालय, <br> जि.रायगड <h2>
							echo "<br>
								<b>गठ्ठा क्र. = </b>".$g_no."&nbsp;&nbsp;&nbsp; <b>Rack No. =</b>".$rack_no."
								&nbsp;&nbsp;&nbsp; <b>Row No. =</b> ".$row_no."
								</center>
								<br>";
							echo "<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>".$rwx['desk_nm'] ." बारकोड जोडणे ( ".$id.") </h4></center></td></tr>";
							
							convert_marathi();
							$result222=mysql_query("SELECT t.dpt_inword_no, t.dpt_ltr_rec_dt, i.subject,i.ltr_inword_no, d.desk_ltr_id, d.desk_ltr_inword_no, d.desk_ltr_rec_dt, d.nasti_nashta_dt, d.final_nashta_dt FROM desk_transaction d, tapal_to_dpt_transaction t, incoming_letters_transaction i
							WHERE ( d.vargawari!='' AND d.ltr_status !='')
							AND t.dept_id_from=(select dept_id from login where login_id='$username') 
							AND d.dpt_ltr_id=t.dpt_ltr_id 
							AND i.ltr_id=t.ltr_id 
							AND d.final_nashta_dt IS NOT NULL 
							AND d.desk_id_from=(select desk_id from login where login_id='$username') ") or die("sdfdfds".mysql_error());
							
							echo "<tr>
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक </th>
										<th class='head1 center'>देस्क आवक_क्र. <br>आवक_दिनांक </th>
										<th class='head1 center'>विषय</th>
										<th class='head1 center'>नस्‍ती	 सुरु कालावधी़ (महिना/वर्ष) </th>
										<th class='head1 center'>नसती नष्‍ट करावयाचा कालावधी (महिना/वर्ष) </th>
										<th class='head1 center'>नस्‍ती  नष्‍ट केल्‍याचा  दिनांक </th>
								</tr>";
							
								$i=1;
								
								if($id !='अ')
								{	
									while($test = mysql_fetch_array($result222))
									{
										if(isset($_POST[$i]))
										{
											$dsk_ltr_id=$test['desk_ltr_id'];
											
											$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
											$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
											
											$d=$test['nasti_nashta_dt'];
											$exp=explode("-",$d);
											$nasti_dt=$exp[2]."-".$exp[1]."-".$exp[0];
											//$nasti_dt = date('d-m-Y',strtotime($test['nasti_nashta_dt']));
											
											$mnth1=  date('F',strtotime($test['desk_ltr_rec_dt']));
											$yr1= date('Y',strtotime($test['desk_ltr_rec_dt']));
											//echo $mnth;
											
											$mnth2=  date('F',strtotime($test['nasti_nashta_dt']));
											$yr2=$exp[0];
											
											$d1=$test['final_nashta_dt'];
											$exp1=explode("-",$d1);
											$final_nasti_dt=$exp1[2]."-".$exp1[1]."-".$exp1[0];
											
											echo "<tr class=gradeX>			
											<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
											<td class='center'>".$test['desk_ltr_inword_no']."<br>".$desk_ltr_rec_dt."</td>
											<td class='center'>".$test['subject']."</td>
											<td class='center'>".$mnth1." / ".$yr1."</td>
											<td class='center'>".$mnth2." / ".$yr2."</td>
											<td class='center'>".$final_nasti_dt."</td>
											";
											
											echo "</tr>";
											$inwardID=$test['ltr_inword_no'].",".$inwardID;
										}
										$i++;
									}
							}
							else if($id =='अ')
							{	
									while($test = mysql_fetch_array($result222))
									{
										if(isset($_POST[$i]))
										{
											$dsk_ltr_id=$test['desk_ltr_id'];
											
											$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
											$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
											
											$d=$test['nasti_nashta_dt'];
											$exp=explode("-",$d);
											$nasti_dt=$exp[2]."-".$exp[1]."-".$exp[0];
											//$nasti_dt = date('d-m-Y',strtotime($test['nasti_nashta_dt']));
											
											$mnth1=  date('F',strtotime($test['desk_ltr_rec_dt']));
											$yr1= date('Y',strtotime($test['desk_ltr_rec_dt']));
											//echo $mnth;
											
											$mnth2=  date('F',strtotime($test['nasti_nashta_dt']));
											$yr2=$exp[0];
											
											echo "<tr class=gradeX>			
											<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
											<td class='center'>".$test['desk_ltr_inword_no']."<br>".$desk_ltr_rec_dt."</td>
											<td class='center'>".$test['subject']."</td>
											<td class='center'>".$mnth1." / ".$yr1."</td>
											<td class='center'> कायम </td>
											<td class='center'> कायम </td>
											";
											
											echo "</tr>";
											$inwardID=$test['ltr_inword_no'].",".$inwardID;
										}
										$i++;
									}
							}
							
						echo "</table></center></div>";	
								
							
							echo "<br>
							<p>	
								<center>
								<input type='button' value='Print Page' onclick='PrintDiv();' class='btn btn-primary'/>
								<input type='button' class='btn' onclick='tableToExcel('sample_1', 'Sandarbha-Nusar Report')' value='Export to Excel'></center>
							</p>";
						}
						########################## End Of Display Details ##################################
							?>
							
							
					</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')
{
	require_once('convert_marathi.php');
	include('rec_sort_dpt_dashboard.php');
	
	$no=$_GET['no'];
	$ltrid=$_REQUEST['ltr_id'];
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="text/javascript">     
       function PrintDiv() {    
           var divToPrint = document.getElementById('divToPrint');
           var popupWin = window.open('', '_blank', 'width=600,height=600');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
       }
</script> 
<script src="tableToExcel.js"></script>
</head>

<body>
<div class="mainwrapper">   
    <div class="rightpanel">
        <ul class="breadcrumbs">
            <li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
            <li><a href="">Tables</a> <span class="separator"></span></li>
            <li>बारकोड जोडणे </li>
        </ul>
        <div class="pageheader">
            <div class="pageicon"><span class="iconfa-table"></span></div>
            <div class="pagetitle">
                <h5>Tables</h5>
                <?php 
				$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);
				$id=$_REQUEST['id'];
				
				$rack_no=$_POST['rack_no'];
				$row_no=$_POST['row_no'];
				$g_no=$_POST['g_no'];
				
				?>
               <!-- <h1><?php echo 	$rsz['dept_nm'];?> रेकॉर्ड सॉर्टिंग </h1>-->
				<h1>बारकोड जोडणे </h1>
            </div>
        </div><!--pageheader-->
        <div class="maincontent">
            <div class="maincontentinner">
				<h4 class="widgettitle"><?php echo 	$rsz['dept_nm'];?> बारकोड जोडणे ( <?php echo $id;?> ) </h4>
				
					<form method="post" action="">
						<?php 		
							if( $id != "")
							{
								echo "<br>
								<center>
								<table>
									 <col width='50'> <col width='20'> <col width='60'>
									 <col width='20'> <col width='60'> <col width='20'>
									<tr>
										<td class='center'><b>गठ्ठा क्र. = </b></td>
										<td>".$g_no."</td>
										<td class='center'> <b>Rack No. =</b> </td>
										<td>".$rack_no."</td>
										<td class='center'> <b>Row No. =</b> </td>
										<td>".$row_no."</td>
									</tr>
								</table>
								</center>
								<br>";
								
								
								convert_marathi();
								$result222=mysql_query("SELECT * FROM incoming_letters_transaction i, 				tapal_to_dpt_transaction t
								where t.dept_id_from=(select dept_id from login where login_id='$username') 
								AND ( t.vargawari='$id' AND t.ltr_status!='')
								AND i.ltr_id=t.ltr_id
								AND t.final_nashta_dt IS NOT NULL 
								AND t.dept_id_from=(select dept_id from login where login_id='$username') ") or die("sdfdfds".mysql_error());
							
							echo " <table id='dyntable' class='table table-bordered'>	
								<thead>
									<tr>
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक </th>
										<th class='head1 center'>विषय</th>
										<th class='head1 center'>नस्‍ती	 सुरु कालावधी़ (महिना/वर्ष) </th>
										<th class='head1 center'>नसती नष्‍ट करावयाचा कालावधी (महिना/वर्ष) </th>
										<th class='head1 center'>नस्‍ती  नष्‍ट केल्‍याचा  दिनांक </th>
									</tr>
								</thead>";
								$i=1;
								
								if($id !='अ')
								{	
									while($test = mysql_fetch_array($result222))
									{
										if(isset($_POST[$i]))
										{
											$dpt_ltr_id=$test['dpt_ltr_id'];
											
											$qw=mysql_query("UPDATE tapal_to_dpt_transaction SET barcode_flag='y' where dpt_ltr_id='$dpt_ltr_id' ");
											
											$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
											$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
											$ref_dt		= date('d-m-Y',strtotime($test['ref_dt']));
											$deskrecdt=	date('d-m-Y',strtotime($test['sent_to_desk_dt']));
											$sent_dt		= date('d-m-Y',strtotime($test['sent_dt']));
											$rcv_dt		= date('d-m-Y',strtotime($test['receive_dt']));
											
											$d=$test['nasti_nashta_dt'];
											$exp=explode("-",$d);
											$nasti_dt=$exp[2]."-".$exp[1]."-".$exp[0];
											//$nasti_dt = date('d-m-Y',strtotime($test['nasti_nashta_dt']));
											
											$mnth1=  date('F',strtotime($test['dpt_ltr_rec_dt']));
											$yr1= date('Y',strtotime($test['dpt_ltr_rec_dt']));
											//echo $mnth;
											
											$mnth2=  date('F',strtotime($test['nasti_nashta_dt']));
											$yr2=$exp[0];
											
											$d1=$test['final_nashta_dt'];
											$exp1=explode("-",$d1);
											$final_nasti_dt=$exp1[2]."-".$exp1[1]."-".$exp1[0];
											
											echo "<tr class=gradeX>			
											<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
											<td class='center'>".$test['subject']."</td>
											<td class='center'>".$mnth1." / ".$yr1."</td>
											<td class='center'>".$mnth2." / ".$yr2."</td>
											<td class='center'>".$final_nasti_dt."</td>
											";
											
											echo "</tr>";
											$inwardID=$test['ltr_inword_no'].",".$inwardID;
										}
										$i++;
									}
									mysql_query("INSERT into rec_sort_barcode(gattha_no,rack_no,row_no,inward_no,dept_desk_flag)
									values ('$g_no','$rack_no','$row_no','$inwardID','dept') ");
							}
							else if($id =='अ')
							{	
									while($test = mysql_fetch_array($result222))
									{
										if(isset($_POST[$i]))
										{
											$dpt_ltr_id=$test['dpt_ltr_id'];
											
											$qw=mysql_query("UPDATE tapal_to_dpt_transaction SET barcode_flag='y' where dpt_ltr_id='$dpt_ltr_id' ");
											
											$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
											$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
											$ref_dt		= date('d-m-Y',strtotime($test['ref_dt']));
											$deskrecdt=	date('d-m-Y',strtotime($test['sent_to_desk_dt']));
											$sent_dt		= date('d-m-Y',strtotime($test['sent_dt']));
											$rcv_dt		= date('d-m-Y',strtotime($test['receive_dt']));
											
											$d=$test['nasti_nashta_dt'];
											$exp=explode("-",$d);
											$nasti_dt=$exp[2]."-".$exp[1]."-".$exp[0];
											//$nasti_dt = date('d-m-Y',strtotime($test['nasti_nashta_dt']));
											
											$mnth1=  date('F',strtotime($test['dpt_ltr_rec_dt']));
											$yr1= date('Y',strtotime($test['dpt_ltr_rec_dt']));
											//echo $mnth;
											
											$mnth2=  date('F',strtotime($test['nasti_nashta_dt']));
											$yr2=$exp[0];
											
											echo "<tr class=gradeX>			
											<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
											<td class='center'>".$test['subject']."</td>
											<td class='center'>".$mnth1." / ".$yr1."</td>
											<td class='center'> कायम </td>
											<td> कायम </td>
											";
											
											echo "</tr>";
											$inwardID=$test['ltr_inword_no'].",".$inwardID;
										}
										$i++;
									}
									mysql_query("INSERT into rec_sort_barcode(gattha_no,rack_no,row_no,inward_no,dept_desk_flag)
									values ('$g_no','$rack_no','$row_no','$inwardID','dept') ");
							}
								//mysql_close();
								echo"   </tbody>
								</table>";
							
							echo "<br>
							<p>	
								<center>
								<input type='button' value='Print Page' onclick='PrintDiv();' class='btn btn-primary'/>
								<input type='button' class='btn' onclick='tableToExcel('sample_1', 'Sandarbha-Nusar Report')' value='Export to Excel'></center>
							</p>";
							
							
						echo "<div id='divToPrint' style='display:none;'>
								<center><h2>पोलीस अधिक्षक कार्यालय, <br> जि.रायगड <h2>
							echo "<br>
								<b>गठ्ठा क्र. = </b>".$g_no."&nbsp;&nbsp;&nbsp; <b>Rack No. =</b>".$rack_no."
								&nbsp;&nbsp;&nbsp; <b>Row No. =</b> ".$row_no."
								</center>
								<br>";
							echo "<center><table id='export' border='1px' style='margin-left:50px;'>
							<tr><td colspan='9'><center><h4>".$rsz['dept_nm'] ." बारकोड जोडणे ( ".$id.") </h4></center></td></tr>";
							
							convert_marathi();
							$result222=mysql_query("SELECT * FROM incoming_letters_transaction i, 				tapal_to_dpt_transaction t
							where t.dept_id_from=(select dept_id from login where login_id='$username') 
							AND ( t.vargawari='$id' AND t.ltr_status!='')
							AND i.ltr_id=t.ltr_id
							AND t.final_nashta_dt IS NOT NULL 
							AND t.dept_id_from=(select dept_id from login where login_id='$username') ") or die("sdfdfds".mysql_error());
							
							echo "<tr>
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक </th>
										<th class='head1 center'>विषय</th>
										<th class='head1 center'>नस्‍ती	 सुरु कालावधी़ (महिना/वर्ष) </th>
										<th class='head1 center'>नसती नष्‍ट करावयाचा कालावधी (महिना/वर्ष) </th>
										<th class='head1 center'>नस्‍ती  नष्‍ट केल्‍याचा  दिनांक </th>
									</tr>";
							
								$i=1;
								
								if($id !='अ')
								{	
									while($test = mysql_fetch_array($result222))
									{
										if(isset($_POST[$i]))
										{
											$dpt_ltr_id=$test['dpt_ltr_id'];
											
											
											$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
											$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
											$ref_dt		= date('d-m-Y',strtotime($test['ref_dt']));
											$deskrecdt=	date('d-m-Y',strtotime($test['sent_to_desk_dt']));
											$sent_dt		= date('d-m-Y',strtotime($test['sent_dt']));
											$rcv_dt		= date('d-m-Y',strtotime($test['receive_dt']));
											
											$d=$test['nasti_nashta_dt'];
											$exp=explode("-",$d);
											$nasti_dt=$exp[2]."-".$exp[1]."-".$exp[0];
											//$nasti_dt = date('d-m-Y',strtotime($test['nasti_nashta_dt']));
											
											$mnth1=  date('F',strtotime($test['dpt_ltr_rec_dt']));
											$yr1= date('Y',strtotime($test['dpt_ltr_rec_dt']));
											//echo $mnth;
											
											$mnth2=  date('F',strtotime($test['nasti_nashta_dt']));
											$yr2=$exp[0];
											
											$d1=$test['final_nashta_dt'];
											$exp1=explode("-",$d1);
											$final_nasti_dt=$exp1[2]."-".$exp1[1]."-".$exp1[0];
											
											echo "<tr class=gradeX>			
											<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
											<td class='center'>".$test['subject']."</td>
											<td class='center'>".$mnth1." / ".$yr1."</td>
											<td class='center'>".$mnth2." / ".$yr2."</td>
											<td class='center'>".$final_nasti_dt."</td>
											";
											
											echo "</tr>";
											$inwardID=$test['ltr_inword_no'].",".$inwardID;
										}
										$i++;
									}
									
							}
							else if($id =='अ')
							{	
									while($test = mysql_fetch_array($result222))
									{
										if(isset($_POST[$i]))
										{
											$dpt_ltr_id=$test['dpt_ltr_id'];
											
											$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
											$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
											$ref_dt		= date('d-m-Y',strtotime($test['ref_dt']));
											$deskrecdt=	date('d-m-Y',strtotime($test['sent_to_desk_dt']));
											$sent_dt		= date('d-m-Y',strtotime($test['sent_dt']));
											$rcv_dt		= date('d-m-Y',strtotime($test['receive_dt']));
											
											$d=$test['nasti_nashta_dt'];
											$exp=explode("-",$d);
											$nasti_dt=$exp[2]."-".$exp[1]."-".$exp[0];
											//$nasti_dt = date('d-m-Y',strtotime($test['nasti_nashta_dt']));
											
											$mnth1=  date('F',strtotime($test['dpt_ltr_rec_dt']));
											$yr1= date('Y',strtotime($test['dpt_ltr_rec_dt']));
											//echo $mnth;
											
											$mnth2=  date('F',strtotime($test['nasti_nashta_dt']));
											$yr2=$exp[0];
											
											echo "<tr class=gradeX>			
											<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
											<td class='center'>".$test['subject']."</td>
											<td class='center'>".$mnth1." / ".$yr1."</td>
											<td class='center'> कायम </td>
											<td> कायम </td>
											";
											
											echo "</tr>";
											$inwardID=$test['ltr_inword_no'].",".$inwardID;
										}
										$i++;
									}
									
							}
							
						echo "</table></center></div>";
							
						} 
							########################## End Of Display Details ##################################
							?>
							
							
					</form>
					<br /><br />
                    <?php include_once('footer.php'); ?>
				</div><!--maincontentinner-->
			</div><!--maincontent-->
		</div><!--rightpanel-->
</div><!--mainwrapper-->
</body>
</html>
<?php 

######################################### End OF Jatan Prakar Wise Report For Department ########################

} //else if($flag=='n')
?>
