<!DOCTYPE html>

<?php
$flag=$_REQUEST['flag'];
//$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');
		$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" />
		<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>
		function dt_check(str)
		{
			var dt  = document.getElementById(str);
			var dt1 = dt.value;
			if(dt1!="")
			{
			//alert("date chk"+dt1);
			
			var arr = dt1.split("-");
			var cnt = arr.length;
			//alert("cnt:"+cnt);
			
			if(cnt==3)
			{
				if(isNaN(arr[0]))
				{
					alert("Please Enter Date in Proper Format!!!");
					//dt.focus();
					dt.value="";
					return false;
				}
				else if(arr[0].length!=2)
				{
					alert("Please Enter Date in Proper Format!!!");
					//dt.focus();
					dt.value="";
					return false;
				}
				else if(parseInt(arr[0]) < 1 || parseInt(arr[0]) > 31)
				{
					alert("Please Enter Date in Proper Format!!!");
					//dt.focus();
					dt.value="";
					return false;
				}
				else if(isNaN(arr[1]))
				{
					alert("Please Enter Date in Proper Format!!!");
					//dt.focus();
					dt.value="";
					return false;
				}
				else if(arr[1].length!=2)
				{
					alert("Please Enter Date in Proper Format!!!");
					//dt.focus();
					dt.value="";
					return false;
				}
				else if(parseInt(arr[1]) < 1 || parseInt(arr[1]) > 12)
				{
					alert("Please Enter Date in Proper Format!!!");
					//dt.focus();
					dt.value="";
					return false;
				}
				else if(isNaN(arr[2]))
				{
					alert("Please Enter Date in Proper Format!!!");
					//dt.focus();
					dt.value="";
					return false;
				}
				else if(arr[2].length!=4)
				{
					alert("Please Enter Date in Proper Format!!!");
					//dt.focus();
					dt.value="";
					return false;
				}
				else if(parseInt(arr[2]) < 1970 || parseInt(arr[2]) > 2100)
				{
					alert("Please Enter Date in Proper Format!!!");
					//dt.focus();
					dt.value="";
					return false;
				}
			}
			else
			{
				alert("Please Enter Date in Proper Format!!!");
				dt.focus();
				dt.value="";
				return false;
			}
			
			}
		}
		</script>
		<script src="tableToExcel.js"></script>
		</head>
		<body>
		<div class="mainwrapper">   
			<div class="rightpanel">
					<ul class="breadcrumbs">
						<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
						<li><a href="">Tables</a> <span class="separator"></span></li>
						<li>रेकॉर्ड सॉर्टिंग </li>
					</ul>
					<div class="pageheader">
						<div class="pageicon"><span class="iconfa-table"></span></div>
						<div class="pagetitle">
							<h5>Tables</h5>
							<h1>रेकॉर्ड सॉर्टिंग </h1>
						</div>
					</div><!--pageheader-->
					<div class="maincontent">
						<div class="maincontentinner">
							<?php
							$qx= mysql_query("SELECT * FROM desk_master WHERE desk_id = (select desk_id from login where login_id='$username')") or die("".mysql_error());
							$rwx=mysql_fetch_array($qx) or die("".mysql_error());
							
							$id=$_REQUEST['id'];
							
							echo "<h4 class=widgettitle>".$rwx['desk_nm']." रेकॉर्ड सॉर्टिंग </h4>";
							?>
							
							<form >
							
							<?php
							$id=$_REQUEST['id'];
								
								
								convert_marathi();
								$result222=mysql_query("SELECT * FROM  rec_sort_barcode where dept_desk_flag='desk' ") or die("sdfdfds".mysql_error());
							
							echo "<br><br> <table id='dyntable' class='table table-bordered'>	
								<thead>
									<tr>
										<th class='head1 center'>गठ्ठा क्रमांक</th>
										<th class='head1 center'>Rack No.</th>
										<th class='head1 center'>Row No.</th> 
										<th class='head1 center'>पोलीस अधिक्षक <br> कार्यालय <br>आवक_क्र.</th>
									</tr>
								</thead>";
								
								while($test = mysql_fetch_array($result222))
								{
									$inwardString=$test['inward_no'];
									$string=explode(",",$inwardString);
									$cnt=count($string);
									echo "<tr class=gradeX>			
											<td class='center'>".$test['gattha_no']."</td>
											<td class='center'>".$test['rack_no']."</td>
											<td class='center'>".$test['row_no']."</td>";
											
											echo "<td >";
											for($i=0;$i<=($cnt-2); $i++)
											{
												echo $string[$i]."&nbsp;&nbsp;&nbsp; ";
												$qr=mysql_query("SELECT subject from incoming_letters_transaction where ltr_inword_no='$string[$i]' ");
												$rr=mysql_fetch_array($qr);
												
												echo $rr['subject']."<br>";
											}
											echo "</td>";
											
										echo "</tr>";
								}
								
								echo"   </tbody>
								</table>";
							
							echo "<div id='divToPrint' style='display:none;'>
							<center><h2>पोलीस अधिक्षक कार्यालय, <br> जि.रायगड <h2>
								<table id='export' border='1px' style='margin-left:50px;'>";
								
							echo "<tr><td colspan='9'><center><b>".$rwx['desk_nm']."  रेकॉर्ड सॉर्टिंग </b></center></td></tr>";
							echo "<tr>
									<th class='head1 center'>गठ्ठा क्रमांक</th>
									<th class='head1 center'>Rack No.</th>
									<th class='head1 center'>Row No.</th> 
									<th class='head1 center'>पोलीस अधिक्षक <br> कार्यालय<br>आवक_क्र.</th>
								</tr>";
							
								convert_marathi();
								$result222=mysql_query("SELECT * FROM  rec_sort_barcode where dept_desk_flag='desk' ") or die("sdfdfds".mysql_error());
								
								while($test = mysql_fetch_array($result222))
								{
									$inwardString=$test['inward_no'];
									$string=explode(",",$inwardString);
									$cnt=count($string);
									echo "<tr class=gradeX>			
											<td class='center'><center>".$test['gattha_no']."</center></td>
											<td class='center'><center>".$test['rack_no']."</center></td>
											<td class='center'><center>".$test['row_no']."</center></td>";
											
											echo "<td >";
											for($i=0;$i<=($cnt-2); $i++)
											{
												echo $string[$i]."&nbsp;&nbsp;&nbsp; ";
												$qr=mysql_query("SELECT subject from incoming_letters_transaction where ltr_inword_no='$string[$i]' ");
												$rr=mysql_fetch_array($qr);
												
												echo $rr['subject']."<br>";
											}
											echo "</td>";
											
										echo "</tr>";
								} //mysql_close();
								echo" </table> </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>
					<?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');
	$no=$_GET['no'];
	$ltrid=$_REQUEST['ltr_id'];

	######################################### Jatan Prakar Wise Report For Department ###############################

	include('rec_sort_dpt_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 
				$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'];
				
				?>
               <!-- <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'];?> रेकॉर्ड सॉर्टिंग </h4>
					<form method="post" action="rec_sort_reportJatan.php?flag=n&id=<?php echo $id; ?>&uname=<?php echo $username; ?>">
						<?php 
						
								convert_marathi();
								$result222=mysql_query("SELECT * FROM  rec_sort_barcode where dept_desk_flag='dept' ") or die("sdfdfds".mysql_error());
							
							echo "<br><br> <table id='dyntable' class='table table-bordered'>	
								<thead>
									<tr>
										<th class='head1 center'>गठ्ठा क्रमांक</th>
										<th class='head1 center'>Rack No.</th>
										<th class='head1 center'>Row No.</th> 
										<th class='head1 center'>पोलीस अधिक्षक <br> कार्यालय<br>आवक_क्र.</th>
									</tr>
								</thead>";
								
								while($test = mysql_fetch_array($result222))
								{
									$inwardString=$test['inward_no'];
									$string=explode(",",$inwardString);
									$cnt=count($string);
									echo "<tr class=gradeX>			
											<td class='center'>".$test['gattha_no']."</td>
											<td class='center'>".$test['rack_no']."</td>
											<td class='center'>".$test['row_no']."</td>";
											
											echo "<td>";
											for($i=0;$i<=($cnt-2); $i++)
											{
												echo $string[$i]."&nbsp;&nbsp;&nbsp; ";
												$qr=mysql_query("SELECT subject from incoming_letters_transaction where ltr_inword_no='$string[$i]' ");
												$rr=mysql_fetch_array($qr);
												
												echo $rr['subject']."<br>";
											}
											echo "</td>";
											
										echo "</tr>";
								}
								
								echo"   </tbody>
								</table>";
							
							echo "<div id='divToPrint' style='display:none;'>
							<center><h2>पोलीस अधिक्षक कार्यालय, <br> जि.रायगड <h2>
								<table id='export' border='1px' style='margin-left:50px;'>";
								
							echo "<tr><td colspan='9'><center><b>".$rsz['dept_nm']."  रेकॉर्ड सॉर्टिंग </b></center></td></tr>";
							echo "<tr>
									<th class='head1 center'>गठ्ठा क्रमांक</th>
									<th class='head1 center'>Rack No.</th>
									<th class='head1 center'>Row No.</th> 
									<th class='head1 center'>पोलीस अधिक्षक <br> कार्यालय<br>आवक_क्र.</th>
								</tr>";
							
								convert_marathi();
								$result222=mysql_query("SELECT * FROM  rec_sort_barcode where dept_desk_flag='dept' ") or die("sdfdfds".mysql_error());
								
								while($test = mysql_fetch_array($result222))
								{
									$inwardString=$test['inward_no'];
									$string=explode(",",$inwardString);
									$cnt=count($string);
									echo "<tr class=gradeX>			
											<td class='center'><center>".$test['gattha_no']."</center></td>
											<td class='center'><center>".$test['rack_no']."</center></td>
											<td class='center'><center>".$test['row_no']."</center></td>";
											
											echo "<td>";
											for($i=0;$i<=($cnt-2); $i++)
											{
												echo $string[$i]."&nbsp;&nbsp;&nbsp; ";
												$qr=mysql_query("SELECT subject from incoming_letters_transaction where ltr_inword_no='$string[$i]' ");
												$rr=mysql_fetch_array($qr);
												
												echo $rr['subject']."<br>";
											}
											echo "</td>";
											
										echo "</tr>";
								} //mysql_close();
								echo" </table> </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 

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

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