<!DOCTYPE html>

<?php 
include('dashboard_tapal.php');	
require_once('convert_marathi.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" />
	<link href="printcss.css" rel="stylesheet" />
	
	<script src="tableToExcel.js"></script>
	<script type="text/javascript" src="js/adduser.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
					$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>";
					
					?>
					<h1>टपालचा गोषवारा </h1>
				</div>
			</div><!--pageheader-->
			<div class="maincontent">
				<div class="maincontentinner">
					<h4 class="widgettitle">टपालचा गोषवारा </h4>
						<form name="sadyasthiti" action="goshwara_tapal.php" 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="4">
									<div align="center">
										<input type="submit" onClick="return sadyasthitiDate()" name="ok" value="GO"/>
										<input type="reset" value="CLEAR" name="clear"/>
									</div></td>
								</tr>
								</table>
							</div>
						</form>
						<br><br>
						
						
						
							<p align="center"><font size="4" color='#0866c6' style="font-family:verdana;"><br>
							<?php
								if(isset($_POST['ok']))
								{
									$date123	= $_REQUEST['start_date'];
									$date1	= date('Y-m-d',strtotime($date123));
									//$date12	= date('d-m-Y',strtotime($date1));
									$date223	= $_REQUEST['end_date'];
									$date2	= date('Y-m-d',strtotime($date223));
									//$date22	= date('d-m-Y',strtotime($date2));
									
									$id = $date1;
									//echo $id;
									
									$id1= $date2;
									//echo $id1;
								}
								else
								{
									$date123	= $datesun;
									$date1	= date('Y-m-d',strtotime($date123));
									//$date12	= date('d-m-Y',strtotime($date1));
									$date223	= $datesat;
									$date2	= date('Y-m-d',strtotime($date223));
									//$date22	= date('d-m-Y',strtotime($date2));
									
									
									$id = $date1;
									//echo $id;
									
									$id1= $date2;
									//echo $id1;
								}
							?></font></p>
							
							<p>	
								<center>
								
								<a href='goshwara_print.php?id=<?php echo $id; ?>&id1=<?php echo $id1; ?>' target='blank' title='Click to View'><input type="button" class="btn"  value="Print Page"></a>
								<input type="button" class="btn" onclick="tableToExcel('sample_1', 'W3C Example Table')" value="Export to Excel">
								</center>
							</p>

<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">
				<p align="center"><font size="5" color='#0866c6' style="font-family:verdana;">&nbsp;&nbsp;&nbsp;विभाग - 
			<?php
				echo $row['dept_nm']."<br></font>";
				$dptid=$row['dept_id'];
				
				echo "<font size='3' color='#0866c6' style='font-family:verdana;'><br><br> गोषवारा ";
				echo '<br><br> <center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></h4><br><br><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());
								
							/*	/////not accepted by dept//////
								$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 BETWEEN '$id' AND '$id1')
								AND i.dept_id = '$dptid'") or die("cccc2".mysql_error()); */

								while($row = mysql_fetch_array($result1))
								{
									$sum2122	=	$row['total'];
								}
							/*	while($row = mysql_fetch_array($result3))
								{
									$sum211222	=	$row['total'];
								}  */
								$sum2134172=$sum2122+$sum211222;
								echo "<td align='center'>".$sum2134172."</td></tr>";
								
								$sum42 = $sum4 + $sum2134172 ;
			
								########################### 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))
								{
									$sum44 = $row['total'];
								} 
								while($row1 = mysql_fetch_array($result1))
								{
									$sum144 = $row1['total'];
								}
								
							/*	while($row3 = mysql_fetch_array($result3))
								{
									$sum344 = $row3['total'];
									
								} */
								$sum4=$sum44+$sum144+$sum344;
								
								////////////current/////////////////
								///// 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 
								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//////
								$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 BETWEEN '$id' AND '$id1')
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */

								while($row = mysql_fetch_array($result1))
								{
									$sum216	=	$row['total'];
								}
							/*	while($row = mysql_fetch_array($result3))
								{
									$sum21109026	=	$row['total'];
								} */
								
								$sum42 = $sum4 + $sum216+$sum21109026 ;
								
								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))
								{
									$sum99=$row['total'];
								}
								while($row1 = mysql_fetch_array($result41))
								{
									$sum199=$row1['total'];
								}
							/*	while($row3 = mysql_fetch_array($result43))
								{
									$sum399=$row3['total'];
								} */
								$sum4 = $sum99+$sum199+$sum399;								
								
								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))
								{
									$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 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))
								{
									$sum34=$row['total'];
								}
								while($row1 = mysql_fetch_array($result41))
								{
									$sum134=$row1['total'];
								}
								
							/*	while($row3 = mysql_fetch_array($result43))
								{
									$sum334=$row3['total'];
								} */
								$sum4 = $sum34+$sum134+$sum334;								
								
								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>
								<br><br><br>
							<p align="left"><b> Note: </b></p> <br>   
							<p align="left">1) वरिल प्रमाणे प्रलंबीत संदर्भ तात्काळ निर्गमीत करुन अनुपालन अहवाल सादर करावा.</p><br>
							<p align="left">2) दोन आठवडयांपेक्षा अधिक प्रलंबीत संदर्भाचा समक्ष खुलासा सादर करावा.</p><br>
							<p align="left">3) एका आठवडयापेक्षा अधिक संदर्भ प्रलंबीत राहणार नाही याची दक्षता घ्यावी.</p><br>
							
							<br><br><br><br><br><br>
							<p align="right">पोलीस अधिक्षक,</p><br>
                            <p align="right"> जि.रायगड </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">
				<p align="center"><font size="5" color='#0866c6' style="font-family:verdana;">&nbsp;&nbsp;&nbsp;विभाग - 
			<?php
				echo $row['dept_nm']."<br></font>";
				$dptid=$row['dept_id'];
				
				echo "<font size='3' color='#0866c6' style='font-family:verdana;'><br><br> गोषवारा ";
				echo '<br><br> <center><h4>दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font></h4><br><br><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))
									{
										$sum15 = $row['total'];
									}
								/*	while($row1 = mysql_fetch_array($result1))
									{
										$sum25 = $row1['total'];
									} */
									$sum=$sum15+$sum25;
									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//////
								$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 BETWEEN '$id' AND '$id1')
								AND i.dept_id = '$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result1))
								{
									$sum278	=	$row['total'];
								}
							/*	while($row = mysql_fetch_array($result3))
								{
									$sum21129878	=	$row['total'];
								} */
								$sum2112565=$sum278+$sum21129878;
								echo "<td align='center'>".$sum2112565."</td></tr>";
								//echo $sum2;
								$sum3 = $sum1 + $sum2112565 ;
			
								########################### 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//////
								$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 BETWEEN '$id' AND '$id1')
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								 
								while($row = mysql_fetch_array($result))
								{
									$sum177 = $row['total'];
								}
							/*	while($row1 = mysql_fetch_array($result1))
								{
									$sum277 = $row1['total'];
								} */
								while($row2 = mysql_fetch_array($result11))
								{
									$sum377	=	$row2['total'];
								}
							/*	while($row = mysql_fetch_array($result3))
								{
									$sum24511277	=	$row['total'];
								} */
									$sum=$sum177+$sum277+$sum377+$sum24511277;
								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.returned_choice=''
								AND t.dpt_ltr_rec_dt BETWEEN '$id' AND '$id1' 
								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` = 'dispatched'
										OR t.status = 'approve'
								)
								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////////////
								/////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//////
								$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 BETWEEN '$id' AND '$id1')
								AND i.dept_id ='$dptid' ") or die("cccc2".mysql_error()); */
								
								while($row = mysql_fetch_array($result))
								{
									$sum100 = $row['total'];
								}
							/*	while($row1 = mysql_fetch_array($result1))
								{
									$sum200 = $row1['total'];
								} */
								while($row2 = mysql_fetch_array($result11))
								{
									$sum300 = $row2['total'];
								}
							/*	while($row = mysql_fetch_array($result3))
								{
									$sum21791200	=	$row['total'];
								} */
								$sum=$sum100+$sum200+$sum300+$sum21791200;
								
								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))
								{
									$sum01 = $row['total'];
								}
							/*	while($row1 = mysql_fetch_array($result1))
								{
									$sum02 = $row1['total'];
								} */
					
								$sum=$sum01+$sum02;
								
								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))
								{
									$sum166 = $row['total'];
								}
							/*	while($row1 = mysql_fetch_array($result1))
								{
									$sum266 = $row1['total'];
								} */
								
								$sum=$sum166+$sum266;
								
								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))
								{
									$sum133 = $row['total'];
								}
							/*	while($row1 = mysql_fetch_array($result1))
								{
									$sum233 = $row1['total'];
								} */
								
								$sum=$sum133+$sum233;
								
								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))
								{
									$sum188 = $row['total'];
								}
							/*	while($row1 = mysql_fetch_array($result1))
								{
									$sum288 = $row1['total'];
								} */
								
								$sum=$sum188+$sum288;
								
								echo "<td align='center'>".$sum."</td></tr>";
								
								?>
								</table>
								</center>
								<br><br><br>
							<p align="left"><b> Note: </b></p> <br>   
							<p align="left">1) वरिल प्रमाणे प्रलंबीत संदर्भ तात्काळ निर्गमीत करुन अनुपालन अहवाल सादर करावा.</p><br>
							<p align="left">2) दोन आठवडयांपेक्षा अधिक प्रलंबीत संदर्भाचा समक्ष्‍ खुलासा सादर करावा.</p><br>
							<p align="left">3) एका आठवडयापेक्षा अधिक संदर्भ्‍ प्रलंबीत राहणार नाही याची दक्षता घ्यावी.</p><br>
							
							<br><br><br><br><br><br>
							<p align="right">पोलीस अधिक्षक,</p><br>
                            <p align="right"> जि.रायगड </p>
			</div>    
			
				<p align="center"><font size="2" style="font-family:verdana;">
				Pg. No.<?php echo $p; $p++; ?></font></p>
		</div>
	<?php
		}
		
		
	?>
	
	
</div>

							
						
						<br /><br />
						<?php include 'footer.php'; ?>
					</div>
				</div><!--maincontentinner-->
			</div><!--maincontent-->
		</div><!--rightpanel-->
	</div><!--mainwrapper-->
</body>
</html><!DOCTYPE html>