<!DOCTYPE html>
<?php
$flag=$_REQUEST['flag'];
//$id=$_REQUEST['id'];
if($flag=='')
{
 require_once('convert_marathi.php');
$no=$_GET['no'];
$ltrid=$_REQUEST['ltr_id'];


############################################### Jatan Prakar Wise Report For Department ########################################
if($no==1)
{
include('dashboard_department.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_id,dept_nm from department_master where dept_id=(select dept_id from login where login_id='$username')");
				$rsz=mysql_fetch_array($qryz);
				$deptid=$rsz['dept_id'];
				
				$id=$_REQUEST['id'];
				?>
                <h1><?php echo 	$rsz['dept_nm'];?>जतन प्रकारानुसार रिपोर्ट्स </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 		
							$id=$_REQUEST['id'];
							############################ Display Counter ##############################
							if($id=="" && $no==1)
							{
								convert_marathi();
								$qre=("SELECT desk_transaction.vargawari, COUNT(*) AS TOTAL FROM desk_transaction, tapal_to_dpt_transaction, incoming_letters_transaction WHERE (desk_transaction.vargawari!='' AND desk_transaction.ltr_status!='')
								AND tapal_to_dpt_transaction.dept_id_from=(select dept_id from login where login_id='$username') and incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND tapal_to_dpt_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id GROUP BY vargawari");
							
								$rsut=mysql_query($qre) or die("".mysql_error());
								echo "<table id='dyntable' class='table table-bordered'>
								<thead>
								<tr>
								<th class='head0 center' style=width:160px;>जतन प्रकार</th>
								<th class='head1 center'> एकूण </th>
								</tr>
								</thead>";
								while($rws = mysql_fetch_array($rsut))
								{
									$id=$rws['vargawari'];
									?>
									<tbody>
									<tr class="gradeX">
									<?php 
									echo "<td class='center'><a href='report_dpt_jatanprakar.php?id=$id&no=1'>".$rws['vargawari']."</a></td><td class='center'>". $rws['TOTAL']."</td> </tr>";
								}?>
								</tbody>
								</table>
								<div id="divToPrint" style='display:none;'> 
									<?php	convert_marathi();
									$qre=("SELECT desk_transaction.vargawari, COUNT(*) AS TOTAL FROM desk_transaction, tapal_to_dpt_transaction, incoming_letters_transaction WHERE desk_transaction.vargawari!='' AND tapal_to_dpt_transaction.dept_id_from=(select dept_id from login where login_id='$username') and incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND tapal_to_dpt_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id GROUP BY vargawari");
								 
								 
									$rsut=mysql_query($qre) or die("".mysql_error());
									echo ' <center><h2>पोलीस अधिक्षक कार्यालय, <br> जि.रायगड <h2></center>';
									echo "<center><table id='export' border='1px' style='margin-left:50px;'>
									
									<thead>
									<tr><td colspan='2'><center>".$rsz['dept_nm']."जतन प्रकारानुसार रिपोर्ट्स </center> </td></tr>
									<tr>
									<th class='head0 center' style=width:160px;>जतन प्रकार</th>
									<th class='head1 center'> एकूण </th>
									</tr>
									</thead>";
									while($rws = mysql_fetch_array($rsut))
									{
										$id=$rws['vargawari'];
										?>
										<tbody>
										<tr class="gradeX">
										<?php 
										echo "<td class='center'>".$rws['vargawari']."</td><td class='center'>". $rws['TOTAL']."</td> </tr>";
									}?>
									</tbody>
									</table></center>
								</div><!--print div-->
			<?php 			} 
							############################ End Of Display Counter ##############################	

							########################## Display Details ##################################
							else if( $id != "" && $no==1)
							{
								convert_marathi();
								echo "<form name='dept_sandarbh' action='' method='post'>
								<div align='center'><br><table align='center' cellpadding='2' cellspacing='0' class='myClass'>
								<table>
									<tr>											  
										<td align='center'><label style='width:110px;'>Start date</label></td>
										<td align='center'><input type='text' name='start_date' class='input-small'/></td>
										<td align='center'><label style='width:110px;'>End Date</label></td>
										<td align='center'><input type='text' name='end_date' class='input-small'/></td>
									</tr>
									<tr>
										<td colspan='6'>
										<div align='center'>
											<input type='submit' onClick='return sadyasthitiDates()' name='ok' value='GO'/>
											<input type='reset' value='CLEAR' name='clear'/>
										</div>
										</td>
									</tr>
								</table>
							</div>				
							</form>
							<form method='post' action=''>";
							$date123	= $_POST['start_date'];
							$date1	= date('Y-m-d',strtotime($date123));
							$date223	= $_POST['end_date'];
							$date2	= date('Y-m-d',strtotime($date223));
							//$date22	= date('d-m-Y',strtotime($date2));
							
							if($date123==''&& $date223=='')
							{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt,t.desk_approval,t.sent_to_desk_dt,  t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt,de.nasti_nashta_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no 
								FROM  incoming_letters_transaction  i  LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id
								LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id
								where t.dept_id_from=(
														select dept_id from login 
														where login_id='$username')
								AND (de.vargawari='$id' AND de.ltr_status!='')") or die("sdfdfds".mysql_error());
							}
							else{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt,t.desk_approval,t.sent_to_desk_dt,  t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no,de.nasti_nashta_dt
								FROM  incoming_letters_transaction  i  LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id
								LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id
								where t.dept_id_from=(
														select dept_id from login 
														where login_id='$username')
								AND (de.vargawari='$id' AND de.ltr_status!='') AND (i.receive_dt BETWEEN '$date1' AND '$date2') ") or die("xxxdfds".mysql_error());
							}
								echo " <table id='dyntable' class='table table-bordered'>	
								<thead>
								<tr>
								<th class='head0 center'>पोलीस अधिक्षक कार्यालय <br> आवक_क्रमांक <br>व_दिनांक</th>
								<th class=''head1 center'>संदर्भ क्रमांक<br>व_दिनांक</th>
								<th class='head1 center'>विषय</th>
								<th class='head0 center'>कोणाकडून प्राप्त झाला</th>";
								//echo "<th class='head1 center'>प्राधान्य दिवस </th>";
								
								echo "<th class='head0 center'>डेस्कला  पाठवले </th>
								<th class='head1 center'>डेस्कला_संदर्भ पाठवलेली_दिनांक </th>
								<th class='head0 center'>केलेली कार्यवाही</th>
								<th class='head0 center'>नस्ती नष्ट दिनांक</th>
								</tr>
								</thead>";
								while($test = mysql_fetch_array($result222))
								{
									$ref_date 		= date('d-m-Y',strtotime($test['ref_dt']));
									$rec_date 		= date('d-m-Y',strtotime($test['receive_dt']));
									
									if($test['sent_to_desk_dt']=='')
									{
										$dis_date="डेस्कला पाठविणे बाकी" ;	
									}
									else
									{
										$dis_date = date('d-m-Y',strtotime($test['sent_to_desk_dt']));
									}
					
									$id1 = $test['ltr_inword_no'];
									$id2 = $test['assign_dpt'];
									$id3 = $test['sandarbh_prakar'];
									$deskid=$test['desk_id'];
									echo "<tr class='gradeX'>
									<td class='center'>".$test['ltr_inword_no']."<br>".$rec_date ."</td>
									<td class='center'>".$test['ref_no']."</font><br>".$ref_date."</td>
									<td class='center'>".$test['subject']."</td>
									<td class='center'>".$test['sender_name']."</td>";
								/*	if($test['priority_days']=='0')
									{
										echo "<td class='center'>"."--"."</td>";
									}
									else if($test['priority_days']>'0')
									{
										echo "<td class='center'><a href=report_dpt_priority.php?id=$test[priority_days]&no=1>".$test['priority_days']."</a></td>";		
									} */
									$qry09="Select desk_nm from desk_master where desk_id='$deskid'";
									$rs09=mysql_query($qry09) or die("assssss".mysql_error());
									while($rw09=mysql_fetch_array($rs09))
									{
										$desknm=$rw09['desk_nm'];
									}
									
									if($test['desk_id']=='' || $test['desk_id']=='0')
									{
										echo "<td class='center'><font color='red'> डेस्क लावणे बाकी </font></td>";
									}
									else if($test['desk_approval']=='pending')
									{
										echo "<td class='center'><a href=report_dpt_deskwise.php?deskid=$test[desk_id]&no=1>".$desknm."</a><br> <font color='red'>डेस्कने स्वीकारणे बाकी </font></td>";
									}
									else 
									{
										echo "<td class='center'><a href=report_dpt_deskwise.php?deskid=$test[desk_id]&no=1>".$desknm."</a></td>";
									}
									
									if($test['desk_id']=='' || $test['desk_id']=='0')
									{
										echo "<td class='center'><font color='red'> डेस्क लावणे बाकी </font></td>";
									}
									else
									{
										echo "<td class='center'>".$dis_date."</font></td>";
									}
									if($test['ltr_status']=='')
									{
										echo "<td class='center'><font color='red'> कार्यवाही करणे बाकी </font></td>";
									}
									else
									{
										echo "<td class='center'>".$test['action_taken']."</td>";
									}
										///////////nasti nashta date////////////
									if($id=='अ')
									{
										echo "<td class='center'>LifeTime</td>";
									}
									else
									{
										echo "<td class='center'>".$test['nasti_nashta_dt']."</td>";
									}
									echo "</tr>";
								}
							//mysql_close();
								echo"   </tbody>
								</table>";
								
								echo "<div id='divToPrint' style='display:none;'>
								 <center><table id='export' border='1px' style='margin-left:50px;'>
										<tr><td colspan='9'><center>".$rsz['dept_nm']." जतन प्रकारानुसार रिपोर्ट्स ( ".$id." ) <br>दिनांक ".$date123." पासून दिनांक ".$date223."</center></td></tr>";	
									echo ' <center><h2>पोलीस अधिक्षक कार्यालय, <br> जि.रायगड <h2></center>';
							if($date123==''&& $date223=='')
							{
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt,t.desk_approval,t.sent_to_desk_dt,  t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to,de.nasti_nashta_dt,  de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no 
								FROM  incoming_letters_transaction  i  LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id
								LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id
								where t.dept_id_from=(
														select dept_id from login 
														where login_id='$username')
								AND (de.vargawari='$id' AND de.ltr_status!='') ") or die("sdfdfds".mysql_error());
							}
							else{
								$id1 = $date1;
								$id2= $date2;
								$result222=mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt,t.desk_approval,t.sent_to_desk_dt,  t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, de.nasti_nashta_dt, de. 	update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, de.scan_doc, di.outword_no, di.dispatched_to, de.ltr_category, de.assign_no 
								FROM  incoming_letters_transaction  i  LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id
								LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id
								where t.dept_id_from=(
														select dept_id from login 
														where login_id='$username')
								AND (de.vargawari='$id' AND de.ltr_status!='') AND (i.receive_dt BETWEEN '$date1' AND '$date2') ") or die("xxxdfds".mysql_error());
							}
								
								echo "
									<tr>
								<th class='head0 center'>पोलीस अधिक्षक कार्यालय <br> आवक_क्रमांक <br>व_दिनांक</th>
								<th class=''head1 center'>संदर्भ क्रमांक<br>व_दिनांक</th>
								<th class='head1 center'>विषय</th>
								<th class='head0 center'>कोणाकडून प्राप्त झाला</th>";
								//echo "<th class='head1 center'>प्राधान्य दिवस </th>";
								
								echo "<th class='head0 center'>डेस्कला  पाठवले </th>
								<th class='head1 center'>डेस्कला_संदर्भ पाठवलेली_दिनांक </th>
								<th class='head0 center'>केलेली कार्यवाही</th>
								<th class='head1 center'>नस्ती नष्ट दिनांक</th>
								</tr>
								</thead>";
								while($test = mysql_fetch_array($result222))
								{
									$ref_date 		= date('d-m-Y',strtotime($test['ref_dt']));
									$rec_date 		= date('d-m-Y',strtotime($test['receive_dt']));
									
									if($test['sent_to_desk_dt']=='')
									{
										$dis_date="डेस्कला पाठविणे बाकी" ;	
									}
									else
									{
										$dis_date = date('d-m-Y',strtotime($test['sent_to_desk_dt']));
									}
					
									$id1 = $test['ltr_inword_no'];
									$id2 = $test['assign_dpt'];
									$id3 = $test['sandarbh_prakar'];
									$deskid=$test['desk_id'];
									echo "<tr class='gradeX'>
									<td class='center'>".$test['ltr_inword_no']."<br>".$rec_date ."</td>
									<td class='center'>".$test['ref_no']."</font><br>".$ref_date."</td>
									<td class='center'>".$test['subject']."</td>
									<td class='center'>".$test['sender_name']."</td>";
								/*	if($test['priority_days']=='0')
									{
										echo "<td class='center'>"."--"."</td>";
									}
									else if($test['priority_days']>'0')
									{
										echo "<td class='center'><a href=report_dpt_priority.php?id=$test[priority_days]&no=1>".$test['priority_days']."</a></td>";		
									} */
									$qry09="Select desk_nm from desk_master where desk_id='$deskid'";
									$rs09=mysql_query($qry09) or die("assssss".mysql_error());
									while($rw09=mysql_fetch_array($rs09))
									{
										$desknm=$rw09['desk_nm'];
									}
									
									if($test['desk_id']=='' || $test['desk_id']=='0')
									{
										echo "<td class='center'> डेस्क लावणे बाकी </td>";
									}
									else if($test['desk_approval']=='pending')
									{
										echo "<td class='center'>".$desknm."<br>डेस्कने स्वीकारणे बाकी </td>";
									}
									else 
									{
										echo "<td class='center'>".$desknm."</td>";
									}
									
									if($test['desk_id']=='' || $test['desk_id']=='0')
									{
										echo "<td class='center'> डेस्क लावणे बाकी </td>";
									}
									else
									{
										echo "<td class='center'>".$dis_date."</font></td>";
									}
									if($test['ltr_status']=='')
									{
										echo "<td class='center'> कार्यवाही करणे बाकी </td>";
									}
									else
									{
										echo "<td class='center'>".$test['action_taken']."</td>";
									}
										///////////nasti nashta date////////////
									if($id=='अ')
									{
										echo "<td class='center'>LifeTime</td>";
									}
									else
									{
										echo "<td class='center'>".$test['nasti_nashta_dt']."</td>";
									}
									echo "</tr>";
								}
							//mysql_close();
								
								echo "</table></center></div>";
								
							}
							########################## End Of Display Details ##################################
							?>
							<br>
							<p>	
								<center><input type="submit" 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>
					</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 ########################
						?>
						<br>
						<p>	
							<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"/>
							<input type="button" class="btn" onclick="tableToExcel('dyntable', 'W3C Example Table')" value="Export to Excel"></center>
						</p>
					</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 ########################################
if($no==1)
{
include('new_dashboard_department.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>
            </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 		
							
							############################ Display Counter ##############################
							if($id=="" && $no==1)
							{
								convert_marathi();
								/*$qre=("SELECT desk_transaction.vargawari, COUNT(*) AS TOTAL FROM desk_transaction, tapal_to_dpt_transaction, incoming_letters_transaction WHERE desk_transaction.vargawari!='' AND tapal_to_dpt_transaction.dept_id_from=(select dept_id from login where login_id='$username') and incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND tapal_to_dpt_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id GROUP BY vargawari");*/
								$qre=("SELECT  t.vargawari, COUNT(*) AS TOTAL 
									FROM tapal_to_dpt_transaction t, incoming_letters_transaction i 
									WHERE  (t.vargawari!='' AND t.ltr_status!='')
									AND t.dept_id_from=(select dept_id from login where login_id='$username') 
									AND i.ltr_id=t.ltr_id 
									GROUP BY vargawari");
																 
								$rsut=mysql_query($qre) or die("".mysql_error());
								echo "<table id='dyntable' class='table table-bordered'>
								<thead>
									<tr>
										<th class='head0 center' style=width:160px;>जतन प्रकार</th>
										<th class='head1 center'> एकूण </th>
									</tr>
								</thead>";
								while($rws = mysql_fetch_array($rsut))
								{
									$id=$rws['vargawari'];
									?>
									<tbody>
									<tr class="gradeX">
									<?php 
									echo "<td class='center'><a href='report_dpt_jatanprakar.php?flag=n&id=$id&no=1'>".$rws['vargawari']."</a></td><td class='center'>". $rws['TOTAL']."</td> </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>जतन प्रकार </th>
									<th>एकूण </th>
								</tr>";
							convert_marathi();
							$qre=("SELECT  t.vargawari, COUNT(*) AS TOTAL 
									FROM tapal_to_dpt_transaction t, incoming_letters_transaction i 
									WHERE  (t.vargawari!='' AND t.ltr_status!='')
									AND t.dept_id_from=(select dept_id from login where login_id='$username') 
									AND i.ltr_id=t.ltr_id 
									GROUP BY vargawari");
																 
							$rsut=mysql_query($qre) or die("".mysql_error());	
							while($rws = mysql_fetch_array($rsut))
							{
								$id=$rws['vargawari'];
								?>
								<tbody>
								<tr class="gradeX">
								<?php 
								echo "<td class='center'><center>".$rws['vargawari']."</center></td><td class='center'><center>". $rws['TOTAL']."</center></td> </tr>";
							}	
							echo "</table></div>";	
						
						} 

						############################ End Of Display Counter ##############################	

						########################## Display Details ##################################
							else if( $id != "" && $no==1)
							{
								convert_marathi();
								echo "<form name='dept_sandarbh' action='' method='post'>
								<div align='center'><br><table align='center' cellpadding='2' cellspacing='0' class='myClass'>
								<table>
									<tr>											  
										<td align='center'><label style='width:110px;'>Start date</label></td>
										<td align='center'><input type='text' name='start_date' class='input-small'/></td>
										<td align='center'><label style='width:110px;'>End Date</label></td>
										<td align='center'><input type='text' name='end_date' class='input-small'/></td>
									</tr>
									<tr>
										<td colspan='6'>
										<div align='center'>
											<input type='submit' onClick='return sadyasthitiDates()' name='ok' value='GO'/>
											<input type='reset' value='CLEAR' name='clear'/>
										</div>
										</td>
									</tr>
								</table>
							</div>				
							</form>
							<form action='' method='post'>";
							$date123	= $_POST['start_date'];
							$date1	= date('Y-m-d',strtotime($date123));
							$date223	= $_POST['end_date'];
							$date2	= date('Y-m-d',strtotime($date223));
							//$date22	= date('d-m-Y',strtotime($date2));
							if($date123==''&& $date223=='')
							{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id1 = $date1;
								$id2= $date2;
								/*$result222=mysql_query("SELECT * FROM desk_transaction, incoming_letters_transaction, tapal_to_dpt_transaction where tapal_to_dpt_transaction.dept_id_from=(select dept_id from login where login_id='$username') AND desk_transaction.vargawari='$id' AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND tapal_to_dpt_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id") or die("sdfdfds".mysql_error());*/
								$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") or die("sdfdfds".mysql_error());
								
							}
							else{
								echo '<br><br><center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></center></h4><br>';
								$id1 = $date1;
								$id2= $date2;
								$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 (i.receive_dt BETWEEN '$date1' AND '$date2')") or die("xxxdfds".mysql_error());
							}
								/*echo " <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'>संदर्भ प्राप्त दिनांक</th>
										<th class='head1 center'>विषय</th>
										<th class='head0 center'>कोणाकडून प्राप्त झाला</th>
										<th class='head1 center'>डेस्कला  पाठवले</th>
										<th class='head0 center'>डेस्कला पाठवलेली_दिनांक </th>
									</tr>
								</thead>";*/
								echo " <table id='dyntable' class='table table-bordered'>	
								<thead>
									<tr>
										<th class='head0 center'>पोलीस अधिक्षक कार्यालय<br> आवक_क्रमांक<br>व_दिनांक</th>
										<th class='head0 center'>संदर्भ क्रमांक <br>व_दिनांक</th>
										<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक </th>
										<th class='head1 center'>विषय</th>
										<th class='head0 center'>कोणाकडून प्राप्त झाला</th>
										<th class='head1 center'>केलेली कार्यवाही</th>
										<th class='head1 center'>नस्ती नष्ट दिनांक </th>
									</tr>
								</thead>";
			
								while($test = mysql_fetch_array($result222))
								{
									$desk_ltr_rec_dt 	= date('d-m-Y',strtotime($test['desk_ltr_rec_dt']));
									$dept_rec_date 		= date('d-m-Y',strtotime($test['dpt_ltr_rec_dt']));
									$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']));
									echo "<tr class=gradeX>			
									<td class='center'>".$test['ltr_inword_no']."<br>".$rcv_dt."</td>
									<td class='center'>".$test['ref_no']."<br>".$ref_dt."</td>
									<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
									<td class='center'>".$test['subject']."</td>
									<td class='center'>".$test['sender_name']."</td>
									<td class='center'>".$test['action_taken']."</td>";
									
									///////////nasti nashta date////////////
									if($id=='अ')
									{
										echo "<td class='center'>LifeTime</td>";
									}
									else
									{
										echo "<td class='center'>".$test['nasti_nashta_dt']."</td>";
									}
									
									/*$q14=mysql_query("select desk_nm from desk_master where desk_id=$test[desk_id]");
									$rs14=mysql_fetch_array($q14);
									echo "<td class='center'><a href=report_dpt_deskwise.php?deskid=$test[desk_id]&no=1>".$rs14['desk_nm']."</a></td>
									<td class='center'>".$deskrecdt."</td></tr>";*/
								}
								//mysql_close();
								echo"   </tbody>
								</table>";
							
							echo "<div id='divToPrint' style='display:none;'>
									<center><table id='export' border='1px' style='margin-left:50px;'>
									<tr><td colspan='8'><center>".$rsz['dept_nm']. "चे जतन प्रकारानुसार रिपोर्ट्स  ( ".$id." )  <br>दिनांक ".$date123." पासून दिनांक ".$date223."</center></td></tr>";
									
								echo ' <center><h2>पोलीस अधिक्षक कार्यालय, <br> जि.रायगड <h2></center>';
								convert_marathi();
							if($date123==''&& $date223=='')
							{
								$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") or die("sdfdfds".mysql_error());
							}
							else
							{
								$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 (i.receive_dt BETWEEN '$date1' AND '$date2')") or die("xxxdfds".mysql_error());
							}
								$count10=mysql_num_rows($result222);
								echo "
								<tr>
									<th class='head0 center'>पोलीस अधिक्षक कार्यालय<br> आवक_क्रमांक<br>व_दिनांक</th>
									<th class='head0 center'>संदर्भ क्रमांक <br>व_दिनांक</th>
									<th class='head1 center'>विभागीय आवक_क्र. <br>आवक_दिनांक </th>
									<th class='head1 center'>विषय</th>
									<th class='head0 center'>कोणाकडून प्राप्त झाला</th>
									<th class='head1 center'>केलेली कार्यवाही </th>
									<th class='head1 center'>नस्ती नष्ट दिनांक </th>
								</tr>";
								while($test = mysql_fetch_array($result222))
								{
									
									echo "<tr class=gradeX>			
									<td class='center'>".$test['ltr_inword_no']."<br>".$rcv_dt."</td>
									<td class='center'>".$test['ref_no']."<br>".$ref_dt."</td>
									<td class='center'>".$test['dpt_inword_no']."<br>".$dept_rec_date."</td>
									<td class='center'>".$test['subject']."</td>
									<td class='center'>".$test['sender_name']."</td>
									<td class='center'>".$test['action_taken']."</td>";
								
									///////////nasti nashta date////////////
									if($id=='अ')
									{
										echo "<td class='center'>LifeTime</td>";
									}
									else
									{
										echo "<td class='center'>".$test['nasti_nashta_dt']."</td>";
									}
									/*$q14=mysql_query("select desk_nm from desk_master where desk_id=$test[desk_id]");
									$rs14=mysql_fetch_array($q14);
									echo "<td class='center'><a href=report_dpt_deskwise.php?deskid=$test[desk_id]&no=1>".$rs14['desk_nm']."</a></td>
									<td class='center'>".$deskrecdt."</td></tr>";*/
									echo "</tr>";
								}
							//mysql_close();
							echo "</table></center></div>";
						}
							########################## End Of Display Details ##################################
							?>
							<br>
							<p>	
								<center><input type="submit" 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>
					</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')
?>