<!DOCTYPE html>

<?php 
require_once('connection/db.php');
require_once('convert_marathi.php');
$username = $_SESSION['User_Name'];
?>

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	
	<link href="printcss.css" rel="stylesheet" />
	
	<script type="text/javascript">
	function pg_print()
	{
		window.print();
	}
	</script>
	
</head>

<body onload="pg_print()">
<div class="mainwrapper">   
    <div class="rightpanel">
           <div class="pageheader">
				<div class="pageicon"><span class="iconfa-table"></span></div>
				<div class="pagetitle">
					
					<?php
					$dt=strtotime("today");
					//echo $dt;
					$date=date("d-m-Y",$dt);
					//echo "today :".$date."<br>";

					$sun=strtotime("previous sunday");
					$datesun=date("d-m-Y",$sun);
					//echo "prev sunday :".$datesun."<br>";

					$sat=strtotime("next saturday");
					$datesat=date("d-m-Y",$sat);
					//echo "next saturday :".$datesat."<br>";
					
					?>
					
				</div>
			</div><!--pageheader-->
			<div class="maincontent">
				<div class="maincontentinner">
					
					<?php
									$date123	= $_REQUEST['id'];
									$date1	= date('Y-m-d',strtotime($date123));
									//$date12	= date('d-m-Y',strtotime($date1));
									$date223	= $_REQUEST['id1'];
									$date2	= date('Y-m-d',strtotime($date223));
									//$date22	= date('d-m-Y',strtotime($date2));
									
									$id = $date1;
									$id56 =date("d-m-Y",strtotime($id));
									//echo $id;
									
									$id1= $date2;
									$id57 =date("d-m-Y",strtotime($id1));
									//echo $id1;
								
							?>
							

<div class="book">
	<?php
		
		$p=1;
	
		convert_marathi();
		$sql = mysql_query("SELECT * FROM department_master where desk_flag='Y' ");
		while($row = mysql_fetch_array($sql))
		{
	?>
   
		<div class="page">
			<div class="subpage">
				<div style="float:left; margin-left:25px;"><img src="images\t-soba.png" style="height:60px;width:95px;" alt="" ></div>
				<div style="float:left;margin-left:25px;"><font color="black" size="5" style="font-weight:bold"> पोलीस अधिक्षक कार्यालय, <br><center> जि.रायगड </center></font></div><br>
			
			
				<p align="center"><font size="5" color='#0866c6' style="font-family:verdana;"><br><br>विभाग - 
			<?php
				echo $row['dept_nm']."</font>";
				$dptid=$row['dept_id'];
				
				echo "<center><font size='3' color='#0866c6' style='font-family:verdana;'><br> गोषवारा ";
				echo '<br> दिनांक <font color="#59c600">'.$id56.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$id57.'</font><br></font></p>';	
								
								########################### Pending References ####################################
								echo"<center><table style='width:70%;' border='1' class='table table-bordered' id='sample_1' cellpadding='2' cellspacing='2' >
								<tbody role=alert aria-live=polite aria-relevant=all><tr>
							
								<tr>
									<td id='ff'>संदर्भाचा प्रकार</td>
									<td id='ff'>एकूण संदर्भ</td>
								</tr>
								<tr>
									<td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&dpt_ltr_rec_dt=$id&end_date=$id1&no=01' target='blank' title='Click to View'>मागील शिल्लक संदर्भ</a></td>";
					
								// dept accepted,desk accepted
								$result = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE t.dpt_ltr_rec_dt < '$id' 
								AND d.ltr_status=''
								AND t.dept_id_from ='$dptid' ") or die("cccc".mysql_error());	
									
								// dept accepted,desk not accepted
								$result1 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE t.dpt_ltr_rec_dt < '$id' 
								AND t.desk_approval='pending' 
								AND t.returned_choice=''
								AND t.dept_id_from ='$dptid' ") or die("cccc1".mysql_error());	
								
								//dept accepted, not assigned desk
								$result2 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE t.dpt_ltr_rec_dt < '$id' 
								AND t.desk_id='0' 
								AND t.returned_choice=''
								AND t.dept_id_from ='$dptid' ") or die("cccc1".mysql_error());	
								
							/*	//dept not accepted
								$result3 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE i.status='pending' AND i.sent_dt< '$id'
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result))
								{
									$sum11 = $row['total'];
								} 
								while($row1 = mysql_fetch_array($result1))
								{
									$sum111 = $row1['total'];
								}
								while($row2 = mysql_fetch_array($result2))
								{
									$sum211 = $row2['total'];
								}
							/*	while($row3 = mysql_fetch_array($result3))
								{
									$sum311 = $row3['total'];
									
								} */
								$sum4=$sum11+$sum111+$sum211+$sum311;
								
								echo"<td align='center'>".$sum4."</td></tr>";
								
								########################### Letters In Current Week ############################
			
								echo"<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&dpt_ltr_rec_dt=$id&end_date=$id1&no=02' target='blank' title='Click to View'>चालू आठवड्यातील आवक संदर्भ</a></td>";
								
								//dept accepted
								$result1=mysql_query("SELECT count(*)as total 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1')
								AND t.dept_id_from = '$dptid'
								AND t.returned_choice='' ") or die("eeee".mysql_error());
								
							/*	//dept not accepted
								$result321 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE i.status='pending' AND i.sent_dt BETWEEN '$id' AND '$id1'
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result1))
								{
									$sum2144	=	$row['total'];
								}
							/*	while($row = mysql_fetch_array($result321))
								{
									$sum452144	=	$row['total'];
								} */
								$sum114521=$sum2144+$sum452144;
								echo "<td align='center'>".$sum114521."</td></tr>";
									
								//echo $sum2;
								$sum42 = $sum4 + $sum114521 ;
			
								########################### Total References ####################################
								echo"<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&dpt_ltr_rec_dt=$id&end_date=$id1&no=03' target='blank' title='Click to View'>एकूण संदर्भ</a></td>";
							
								////////////pending////////////
									// dept accepted,desk accepted
								$result = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE t.dpt_ltr_rec_dt < '$id' 
								AND d.ltr_status=''
								AND t.dept_id_from ='$dptid' ") or die("cccc".mysql_error());	
									
								// dept accepted,desk not acceptedor not assigned desk
								$result1 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE t.dpt_ltr_rec_dt < '$id' 
								AND (t.desk_id='0' OR t.desk_approval='pending' )
								AND t.returned_choice=''
								AND t.dept_id_from ='$dptid' ") or die("cccc1".mysql_error());	
								
							/*	//dept not accepted
								$result3 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE i.status='pending' AND i.sent_dt< '$id'
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result))
								{
									$sum22 = $row['total'];
								} 
								while($row1 = mysql_fetch_array($result1))
								{
									$sum122 = $row1['total'];
								}
								
							/*	while($row3 = mysql_fetch_array($result3))
								{
									$sum322 = $row3['total'];
								} */
								$sum4=$sum22+$sum122+$sum322;
								
								////////////current/////////////////
								//dept accepted
								$result1=mysql_query("SELECT count(*)as total 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								WHERE (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1')
								AND t.dept_id_from = '$dptid'
								AND t.returned_choice='' ") or die("eeee".mysql_error());
								
							/*	//dept not accepted
								$result3215 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE i.status='pending' AND i.sent_dt BETWEEN '$id' AND '$id1'
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result1))
								{
									$sum2166	=	$row['total'];
								}
							/*	while($row = mysql_fetch_array($result3215))
								{
									$sum2926166	=	$row['total'];
								} */
								$sum42 = $sum4 + $sum2166 + $sum2926166 ;
								
								echo "<td align='center'>".$sum42."</td></tr>";
								
								########################### Updated References ####################################
								/*echo "<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&dpt_ltr_rec_dt=$id&end_date=$id1&no=04' target='blank' title='Click to View'>अद्यावत केलेले </a></td>";
									
								$result3 = mysql_query("SELECT COUNT( * ) AS TOTAL
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE t.dept_id_from='$dptid'
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1'
								AND  d.ltr_approval = 'approve'
								AND d.ltr_status = 'updated' ");
							
								while($row = mysql_fetch_array($result3))
								{
									echo "<td align='center'>".$row['TOTAL']."</td></tr>";
									$sum13 = $row['TOTAL'];
								}
								//$sum5 = $sum3 - $sum13;*/
								
								########################### Dispatched/updated References ############################
								echo"<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&dpt_ltr_rec_dt=$id&end_date=$id1&no=05' target='blank' title='Click to View'>एकूण निर्गत संदर्भ</a></td>";
								
								$result21 = mysql_query("SELECT COUNT( * ) AS TOTAL
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id 
								WHERE t.dept_id_from ='$dptid'
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1'
								AND (d.`ltr_status` = 'dispatched' OR d.ltr_status = 'updated')
								AND (
										t.`desk_approval` = 'approve'
										OR t.`desk_approval` = 'updated'
										OR t.`desk_approval` = 'dispatched'
									)
								AND d.ltr_approval!='transferred_todesk'
								AND d.action_taken != '' ");
								
								while($row = mysql_fetch_array($result21))
								{
									echo "<td align='center'>".$row['TOTAL']."</td></tr>";
									$sum4 = $row['total'];
								}
								//$sum5 = $sum3 - $sum4;
								$sum5=$sum3-($sum13+$sum4);
								
								########################### Total Pending References ##############################
								echo"<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&dpt_ltr_rec_dt=$id&end_date=$id1&no=10' target='blank' title='Click to View'>एकूण शिल्लक संदर्भ</a></td>";
								
								// dept accepted,desk accepted
								$result4 = mysql_query("SELECT COUNT(*) AS total
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE t.dept_id_from='$dptid'
								AND t.dpt_ltr_rec_dt <= '$id1' 
								AND t.`desk_approval` = 'approve'
								AND ( d.ltr_status='')");
										
								// dept accepted,desk not accepted
								$result41 = mysql_query("SELECT COUNT(*) AS total
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE t.dept_id_from='$dptid'
								AND t.dpt_ltr_rec_dt <= '$id1' 
								AND (t.desk_id='0' OR t.`desk_approval` = 'pending')
								AND t.returned_choice='' ");

							/*	//dept not accepted
								$result43 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE i.status='pending' AND i.sent_dt<= '$id1' 
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result4))
								{
									$sum00=$row['total'];
								}
								while($row1 = mysql_fetch_array($result41))
								{
									$sum100=$row1['total'];
								}
							/*	while($row3 = mysql_fetch_array($result43))
								{
									$sum300=$row3['total'];
								} */
								$sum4 = $sum00+$sum100+$sum300;								
								
								echo "<td align='center'>".$sum4."</td></tr>";
								
								########################### Pending From 1 Week References ##########################
								echo"<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&dpt_ltr_rec_dt=$id&end_date=$id1&no=06' target='blank' title='Click to View'>एका आठवड्यातील शिल्लक संदर्भ</a></td>";
								
								// dept accepted,desk accepted
								$result4 = mysql_query("SELECT COUNT(*) AS total
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE t.dept_id_from='$dptid' 
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' 
								AND t.`desk_approval` = 'approve'
								AND ( d.ltr_status='')");
										
								// dept accepted,desk not accepted or not assigned desk
								$result41 = mysql_query("SELECT COUNT(*) AS total
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE t.dept_id_from='$dptid' 
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1'
								AND ( t.desk_id='0' OR t.`desk_approval` = 'pending')
								AND t.returned_choice='' ");

							/*	//dept not accepted
								$result43 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE i.status='pending' AND i.sent_dt BETWEEN '$id' AND '$id1' 
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result4))
								{
									$sum98=$row['total'];
								}
								while($row1 = mysql_fetch_array($result41))
								{
									$sum198=$row1['total'];
								}
								
							/*	while($row3 = mysql_fetch_array($result43))
								{
									$sum398=$row3['total'];
								} */
								$sum4 = $sum98+$sum198+$sum398;								
								
								echo "<td align='center'>".$sum4."</td></tr>";
									
								########################### Pending From 2 Weeks References ##########################
								echo "<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&dpt_ltr_rec_dt=$id&end_date=$id1&no=07' target='blank' title='Click to View'>दोन आठवड्यातील शिल्लक संदर्भ</a></td>";			
								
								$prev_date = date("Y-m-d", strtotime('-1 days', strtotime($id)) );
								
								// dept accepted,desk accepted
								$result4 = mysql_query("SELECT COUNT(*) AS total
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE t.dept_id_from='$dptid'
								AND t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$prev_date'
								AND t.`desk_approval` = 'approve'
								AND ( d.ltr_status='')");
										
								// dept accepted,desk not accepted
								$result41 = mysql_query("SELECT COUNT(*) AS total
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE t.dept_id_from='$dptid' 
								AND t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$prev_date'
								AND (t.desk_id='0' OR t.`desk_approval` = 'pending')
								AND t.returned_choice='' ");

							/*	//dept not accepted
								$result43 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
								WHERE i.status='pending' AND i.sent_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY)AND '$prev_date' 
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
							
								while($row = mysql_fetch_array($result4))
								{
									$sum56=$row['total'];
								}
								while($row1 = mysql_fetch_array($result41))
								{
									$sum156=$row1['total'];
								}
								
							/*	while($row3 = mysql_fetch_array($result43))
								{
									$sum356=$row3['total'];
								} */
								$sum4 = $sum56+$sum156+$sum356;								
								
								echo "<td align='center'>".$sum4."</td></tr>";
								
								########################### Pending From 3 Weeks References ##########################
								echo "<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&dpt_ltr_rec_dt=$id&end_date=$id1&no=08' target='blank' title='Click to View'>तीन आठवड्यातील शिल्लक संदर्भ</a></td>";	
							
							// dept accepted,desk accepted
							$result4 = mysql_query("SELECT COUNT(*) AS total
							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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
							WHERE t.dept_id_from='$dptid'
							AND t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)
							AND t.`desk_approval` = 'approve'
							AND ( d.ltr_status='')");
									
							// dept accepted,desk not accepted
							$result41 = mysql_query("SELECT COUNT(*) AS total
							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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
							WHERE t.dept_id_from='$dptid'
							AND t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)
							AND (t.desk_id='0' OR t.`desk_approval` = 'pending')
							AND t.returned_choice='' ");

															
						/*	//dept not accepted
							$result43 = mysql_query("SELECT count(*)as total 
							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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
							WHERE i.status='pending' AND i.sent_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY) 
							AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result4))
								{
									$sum45=$row['total'];
								}
								while($row1 = mysql_fetch_array($result41))
								{
									$sum145=$row1['total'];
								}
								
							/*	while($row3 = mysql_fetch_array($result43))
								{
									$sum345=$row3['total'];
								} */
								$sum4 = $sum45+$sum145+$sum345;								
								
								echo "<td align='center'>".$sum4."</td></tr>";
								
								#################### Pending From More Than 3 Weeks References #######################
								echo "<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&dpt_ltr_rec_dt=$id&end_date=$id1&no=09' target='blank' title='Click to View'>तीन आठवड्यावरील शिल्लक संदर्भ</a></td>";			
								
							// dept accepted,desk accepted
							$result4 = mysql_query("SELECT COUNT(*) AS total
							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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
							WHERE t.dept_id_from='$dptid'
							AND t.dpt_ltr_rec_dt< DATE_SUB('$id',INTERVAL 14 DAY)
							AND t.`desk_approval` = 'approve'
							AND ( d.ltr_status='')");
									
							// dept accepted,desk not accepted
							$result41 = mysql_query("SELECT COUNT(*) AS total
							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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
							WHERE t.dept_id_from='$dptid'
							AND t.dpt_ltr_rec_dt< DATE_SUB('$id',INTERVAL 14 DAY)
							AND (t.desk_id='0' OR t.`desk_approval` = 'pending')
							AND t.returned_choice='' ");
								
						/*	//dept not accepted
							$result43 = mysql_query("SELECT count(*)as total 
							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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = d.desk_ltr_id
							WHERE i.status='pending' AND i.sent_dt< DATE_SUB('$id',INTERVAL 14 DAY)
							AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
							
								while($row = mysql_fetch_array($result4))
								{
									$sum32=$row['total'];
								}
								while($row1 = mysql_fetch_array($result41))
								{
									$sum132=$row1['total'];
								}
								
							/*	while($row3 = mysql_fetch_array($result43))
								{
									$sum332=$row3['total'];
								} */
								$sum4 = $sum32+$sum132+$sum332;								
								
								echo "<td align='center'>".$sum4."</td></tr>";
								
								?>
								</table>
								</center>
							
							<p align="left"><b> Note: </b><br>
							1) वरिल प्रमाणे प्रलंबीत संदर्भ तात्काळ निर्गमीत करुन अनुपालन अहवाल सादर करावा.<br>
							2) दोन आठवडयांपेक्षा अधिक प्रलंबीत संदर्भाचा समक्ष्‍ खुलासा सादर करावा.<br>
							3) एका आठवडयापेक्षा अधिक संदर्भ्‍ प्रलंबीत राहणार नाही याची दक्षता घ्यावी.</p>
							
							<br><br><br>
							<p align="right">पोलीस अधिक्षक,<br>
								जि.रायगड </p>
			
			</div>    
			<p align="center"><font size="2" style="font-family:verdana;">
				Pg. No.<?php echo $p; $p++; ?></font></p>
		</div>
	<?php
		}
		
		
		
		convert_marathi();
		$sql = mysql_query("SELECT * FROM department_master where desk_flag='N' ");
		while($row = mysql_fetch_array($sql))
		{
	?>
   
		<div class="page">
			<div class="subpage">
			
				<div style="float:left; margin-left:25px;"><img src="images\t-soba.png" style="height:60px;width:95px;" alt="" ></div>
				<div style="float:left;margin-left:25px;"><font color="black" size="5" style="font-weight:bold">पोलीस अधिक्षक कार्यालय,<br><center> जि.रायगड </center></font></div><br>
			
			
				<p align="center"><font size="5" color='#0866c6' style="font-family:verdana;"><br><br>विभाग - 
			<?php
				echo $row['dept_nm']."</font>";
				$dptid=$row['dept_id'];
				
				echo "<center><font size='3' color='#0866c6' style='font-family:verdana;'><br> गोषवारा ";
				echo '<br> दिनांक <font color="#59c600">'.$id56.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$id57.'</font><br></font></p>';
			
			
					########################### Pending References ####################################
								echo"<center><table style='width:70%;' border='1' class='table table-bordered' id='sample_1' cellpadding='2' cellspacing='2' >
								<tbody role=alert aria-live=polite aria-relevant=all><tr>
								
								<tr>
									<td id='ff'>संदर्भाचा प्रकार</td>
									<td id='ff'>एकूण संदर्भ</td>
								</tr>
								<tr>
									<td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&flag=n&dpt_ltr_rec_dt=$id&end_date=$id1&no=01' target='blank' title='Click to View'>मागील शिल्लक संदर्भ</a></td>";
					
									
									//accepted by dept but nt taken ny action
									$result = mysql_query("SELECT count(*)as total 
									FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
									LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
									WHERE (t.dpt_ltr_rec_dt < '$id' ) 
									AND t.ltr_status='' AND t.returned_choice=''
									AND t.dept_id_from ='$dptid' ") or die("cccc".mysql_error());
									
								/*	//not accepted by dept
									$result1 = mysql_query("SELECT count(*)as total 
									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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
									LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
									WHERE i.status='pending' AND i.sent_dt < '$id'
									AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
									
									while($row = mysql_fetch_array($result))
									{
										$sum231 = $row['total'];
									}
								/*	while($row1 = mysql_fetch_array($result1))
									{
										$sum232 = $row1['total'];
									} */
									$sum=$sum231+$sum232;
									echo"<td align='center'>".$sum."</td></tr>";
											
								########################### Letters In Current Week ############################
			
								echo"<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&flag=n&dpt_ltr_rec_dt=$id&end_date=$id1&no=02' target='blank' title='Click to View'>चालू आठवड्यातील आवक संदर्भ</a></td>";
								//accepted by dept
								$result1=mysql_query("SELECT count(*)as total 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON (di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1') 
								AND t.dept_id_from ='$dptid'
								AND t.returned_choice='' ") or die("eeee".mysql_error());
								
							/*	//not accepted by dept
								$result16 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE i.status='pending' AND i.sent_dt BETWEEN '$id' AND '$id1'
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result1))
								{
									$sum442	=	$row['total'];
								}
							/*	while($row = mysql_fetch_array($result16))
								{
									$sum44216	=	$row['total'];
								} */
								$sum21639=$sum442+$sum44216;
								echo "<td align='center'>".$sum21639."</td></tr>";
									
								//echo $sum2;
								$sum3 = $sum1 + $sum21639 ;
			
								########################### Total References ####################################
								echo"<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&flag=n&dpt_ltr_rec_dt=$id&end_date=$id1&no=03' target='blank' title='Click to View'>एकूण संदर्भ</a></td>";
								
								////////////pending/////////
								//accepted by dept but nt taken ny action
								$result = mysql_query("SELECT count(*)as total 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE (t.dpt_ltr_rec_dt < '$id' ) 
								AND t.ltr_status='' AND t.returned_choice=''
								AND t.dept_id_from ='$dptid' ") or die("cccc".mysql_error());
									
						/*		//not accepted by dept
								$result1 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE i.status='pending' AND i.sent_dt < '$id' 
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error());  */
								
								///////////current/////////////////
								// accepted by dept
								$result11=mysql_query("SELECT count(*)as total 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON (di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1') 
								AND t.dept_id_from ='$dptid'
								AND t.returned_choice='' ") or die("eeee".mysql_error());
								
							/*	//not accepted by dept
								$result145 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE i.status='pending' AND i.sent_dt BETWEEN '$id' AND '$id1'
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result))
								{
									$sum17 = $row['total'];
								}
							/*	while($row1 = mysql_fetch_array($result1))
								{
									$sum27 = $row1['total'];
								} */
								while($row2 = mysql_fetch_array($result11))
								{
									$sum37	=	$row2['total'];
								}
							/*	while($row2 = mysql_fetch_array($result145))
								{
									$sum3457	=	$row2['total'];
								} */
									$sum=$sum17+$sum27+$sum37+$sum3457;
								echo "<td align='center'>".$sum."</td></tr>";
							
								########################### Updated References ####################################
							/*	echo "<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&flag=n&dpt_ltr_rec_dt=$id&end_date=$id1&no=04' target='blank' title='Click to View'>अद्यावत केलेले </a></td>";
								
								$result3 = mysql_query("SELECT COUNT( * ) AS TOTAL
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE t.dept_id_from ='$dptid'
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' AND t.returned_choice=''
								AND (t.status = 'approve' AND t.ltr_status = 'updated' )");
								
								while($row = mysql_fetch_array($result3))
								{
									echo "<td align='center'>".$row['TOTAL']."</td></tr>";
									$sum13 = $row['TOTAL'];
								}
								//$sum5 = $sum3 - $sum13; */
								########################### Dispatched References ####################################
								echo"<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&flag=n&dpt_ltr_rec_dt=$id&end_date=$id1&no=05' target='blank' title='Click to View'>एकूण निर्गत संदर्भ</a></td>";
							
								$result21 = mysql_query("SELECT COUNT( * ) AS TOTAL
								FROM `tapal_to_dpt_transaction` t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE t.dept_id_from ='$dptid'
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1'
								AND t.returned_choice=''
								AND (t.`ltr_status` = 'dispatched' OR t.ltr_status = 'updated')
								AND (
										t.`status` = 'transferred'
										OR t.status = 'approve'
										OR t.`status` = 'dispatched'
								)
								AND t.action_taken != '' ");
								
								while($row = mysql_fetch_array($result21))
								{
									echo "<td align='center'>".$row['TOTAL']."</td></tr>";
									$sum4 = $row['total'];
								}
								//$sum5 = $sum3 - $sum4;
								$sum5=$sum3-($sum13+$sum4);
								########################### Total Pending References ##############################
								echo"<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&flag=n&dpt_ltr_rec_dt=$id&end_date=$id1&no=10' target='blank' title='Click to View'>एकूण शिल्लक संदर्भ</a></td>";
							
								//////////////////pending///////////////
								//accepted by dept but nt taken ny action
								$result = mysql_query("SELECT count(*)as total 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE (t.dpt_ltr_rec_dt < '$id' ) 
								AND t.ltr_status='' AND t.returned_choice=''
								AND t.dept_id_from ='$dptid' ") or die("cccc".mysql_error());
									
							/*	//not accepted by dept
								$result1 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE i.status='pending' AND i.sent_dt < '$id'
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								////////current pending////////////
								//not accepted by dept
								$result11=mysql_query("SELECT count(*)as total 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON (di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1') 
								AND t.dept_id_from ='$dptid'
								AND t.ltr_status='' AND t.returned_choice='' ") or die("eeee".mysql_error());
								
							/*	//not accepted by dept
								$result12 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE i.status='pending' AND i.sent_dt BETWEEN '$id' AND '$id1'
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result))
								{
									$sum155 = $row['total'];
								}
							/*	while($row1 = mysql_fetch_array($result1))
								{
									$sum255 = $row1['total'];
								} */
								while($row2 = mysql_fetch_array($result11))
								{
									$sum355 = $row2['total'];
								}
							/*	while($row2 = mysql_fetch_array($result12))
								{
									$sum3455 = $row2['total'];
								} */
								$sum=$sum155+$sum255+$sum355+$sum3455;
								
								echo "<td align='center'>".$sum."</td></tr>";
								
								########################### Pending From 1 Week References ##########################
								echo"<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&flag=n&dpt_ltr_rec_dt=$id&end_date=$id1&no=06' target='blank' title='Click to View'>एका आठवड्यातील शिल्लक संदर्भ</a></td>";
							
								//accepted by dept but nt taken ny action
								$result = mysql_query("SELECT count(*)as total 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE (t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' ) 
								AND t.ltr_status='' AND t.returned_choice=''
								AND t.dept_id_from ='$dptid' ") or die("cccc".mysql_error());
									
							/*	//not accepted by dept
								$result1 = mysql_query("SELECT count(*)as total 
								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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
								LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
								WHERE i.status='pending' AND i.sent_dt BETWEEN '$id' AND '$id1'
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
																
								while($row = mysql_fetch_array($result))
								{
									$sum771 = $row['total'];
								}
							/*	while($row1 = mysql_fetch_array($result1))
								{
									$sum772 = $row1['total'];
								} */
					
								$sum=$sum771+$sum772;
								
								echo "<td align='center'>".$sum."</td></tr>";
									
								########################### Pending From 2 Weeks References ##########################
								echo "<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&flag=n&dpt_ltr_rec_dt=$id&end_date=$id1&no=07' target='blank' title='Click to View'>दोन आठवड्यातील शिल्लक संदर्भ</a></td>";			
							
							$prev_date = date("Y-m-d", strtotime('-1 days', strtotime($id)) );
							
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT count(*)as total 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE (t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY) AND '$prev_date')  
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from ='$dptid' ") or die("cccc".mysql_error());
									
						/*	//not accepted by dept
							$result1 = mysql_query("SELECT count(*)as total 
							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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE i.status='pending' AND i.sent_dt BETWEEN DATE_SUB('$id',INTERVAL 7 DAY) AND '$prev_date'
							AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result))
								{
									$sum091 = $row['total'];
								}
							/*	while($row1 = mysql_fetch_array($result1))
								{
									$sum092 = $row1['total'];
								} */
								
								$sum=$sum091+$sum092;
								
								echo "<td align='center'>".$sum."</td></tr>";
							
								
						########################### Pending From 3 Weeks References ##########################
							echo "<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&flag=n&dpt_ltr_rec_dt=$id&end_date=$id1&no=08' target='blank' title='Click to View'>तीन आठवड्यातील शिल्लक संदर्भ</a></td>";	
							
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT count(*)as total 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE t.dpt_ltr_rec_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)  
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from ='$dptid' ") or die("cccc".mysql_error());
									
						/*	//not accepted by dept
							$result1 = mysql_query("SELECT count(*)as total 
							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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE i.status='pending' AND i.sent_dt BETWEEN DATE_SUB('$id',INTERVAL 14 DAY) AND DATE_SUB('$id',INTERVAL 8 DAY)
							AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result))
								{
									$sum531 = $row['total'];
								}
							/*	while($row1 = mysql_fetch_array($result1))
								{
									$sum532 = $row1['total'];
								} */
								
								$sum=$sum531+$sum532;
								
								echo "<td align='center'>".$sum."</td></tr>";
							
						#################### Pending From More Than 3 Weeks References #######################
								echo "<tr><td align='center'><a href='goshwara_tapal_view.php?deptid=$dptid&flag=n&dpt_ltr_rec_dt=$id&end_date=$id1&no=09' target='blank' title='Click to View'>तीन आठवड्यावरील शिल्लक संदर्भ</a></td>";			
							
							//accepted by dept but nt taken ny action
							$result = mysql_query("SELECT count(*)as total 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE t.dpt_ltr_rec_dt < DATE_SUB('$id',INTERVAL 14 DAY)
							AND t.ltr_status='' AND t.returned_choice=''
							AND t.dept_id_from ='$dptid' ") or die("cccc".mysql_error());
									
						/*	//not accepted by dept
							$result1 = mysql_query("SELECT count(*)as total 
							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 d ON d.dpt_ltr_id = t.dpt_ltr_id 
							LEFT OUTER JOIN dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
							WHERE i.status='pending' AND i.sent_dt < DATE_SUB('$id',INTERVAL 14 DAY)
							AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result))
								{
									$sum131 = $row['total'];
								}
							/*	while($row1 = mysql_fetch_array($result1))
								{
									$sum2631 = $row1['total'];
								} */
								
								$sum=$sum131+$sum2631;
								
								echo "<td align='center'>".$sum."</td></tr>";
								
								?>
								</table>
								</center>
							
							<p align="left"><b> Note: </b><br>
							1) वरिल प्रमाणे प्रलंबीत संदर्भ तात्काळ निर्गमीत करुन अनुपालन अहवाल सादर करावा.<br>
							2) दोन आठवडयांपेक्षा अधिक प्रलंबीत संदर्भाचा समक्ष्‍ खुलासा सादर करावा.<br>
							3) एका आठवडयापेक्षा अधिक संदर्भ्‍ प्रलंबीत राहणार नाही याची दक्षता घ्यावी.</p>
							
							<br><br><br>
							<p align="right">पोलीस अधिक्षक<br>
								जि.रायगड</p>
			
			</div>    
			<p align="center"><font size="2" style="font-family:verdana;">
				Pg. No.<?php echo $p; $p++; ?></font></p>
		</div>
	<?php
		}
		
		
	?>
	
	
</div>

							
					</div>
				</div><!--maincontentinner-->
			</div><!--maincontent-->
		</div><!--rightpanel-->
	</div><!--mainwrapper-->
</body>
</html><!DOCTYPE html>