<!DOCTYPE html>
<?php
require_once('connection/db.php');
require_once('convert_marathi.php');
// like i said, we must never forget to start the session
session_start();
// is the one accessing this page logged in or not?
if (!isset($_SESSION['logged_in'])|| $_SESSION['logged_in'] !== true)
	{
		// not logged in, move to login page
		header('Location: index.php');
		exit;
	}
$username = $_SESSION['User_Name'];
?>
<html>
<head>
<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tapal Admin System</title>
<link rel="stylesheet" href="css/style.default.css" type="text/css" />
<link rel="stylesheet" href="css/bootstrap-fileupload.min.css" type="text/css" />
<link rel="stylesheet" href="css/bootstrap-timepicker.min.css" type="text/css" />
<link rel="stylesheet" href="css/responsive-tables.css">
<script type="text/javascript" src="js/jsapi.js"></script>
<script type="text/javascript" src="unicode.js"></script>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery-migrate-1.1.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.9.2.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-fileupload.min.js"></script>
<script type="text/javascript" src="js/bootstrap-timepicker.min.js"></script>
<script type="text/javascript" src="js/jquery.uniform.min.js"></script>
<script type="text/javascript" src="js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript" src="js/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="js/jquery.autogrow-textarea.js"></script>
<script type="text/javascript" src="js/charCount.js"></script>
<script type="text/javascript" src="js/colorpicker.js"></script>
<script type="text/javascript" src="js/ui.spinner.min.js"></script>
<script type="text/javascript" src="js/chosen.jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript" src="js/modernizr.min.js"></script>
<script type="text/javascript" src="js/responsive-tables.js"></script>
<script type="text/javascript" src="js/custom.js"></script>
<script type="text/javascript" src="js/forms.js"></script>
<!-- Script required of tab functioning -->	 
<script type="text/javascript" src="prettify/prettify.js"></script>
<script type="text/javascript" src="js/elements.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function(){
        // dynamic table
        jQuery('#dyntable').dataTable({
            "sPaginationType": "full_numbers",
            "aaSortingFixed": [[0,'asc']],
            "fnDrawCallback": function(oSettings) {
                jQuery.uniform.update();
            }
        });
        
        jQuery('#dyntable2').dataTable( {
            "bScrollInfinite": true,
            "bScrollCollapse": true,
            "sScrollY": "300px"
        });
        
    });
</script>
</head>
<body>
<div class="mainwrapper">
    <div class="header">
       <div class="logo">
            <div style="float:left;"><img src="images\t-soba.png" style="height:95px;width:95px;" alt="" /></div>
			<div style="float:right;margin-top:10px;margin-right:5px;"><font color="white" size="2px;">पोलीस अधिक्षक <br> कार्यालय,<br>जिल्हा रायगड</font></a></div>
        <!-- style="font-weight:bold"-->
        </div>



        <div class="headerinner">
			<ul class="headmenu">
				<!---------------------------------------------------------------------------------------------
										Notification Code
				----------------------------------------------------------------------------------------------->
				<li class="odd">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
					 <?php 
						convert_marathi();
						$qry1=mysql_query("Select * FROM  incoming_letters_transaction i 
						WHERE i.dept_id!='0' 
						AND i.status='pending' 
						AND i.dept_id=(select dept_id from login where login_id='$username')") OR die("".mysql_error());
						$cnt=mysql_num_rows($qry1);
						?>
						<span class="count"><?php echo $cnt;?></span>
                        <center><img src="images/silver-bell-md.png" style="height:40px;width:50px;" class="headmenu-label"></center>
                        <span class="headmenu-label">संदर्भ स्वीकारणे <br>बाकी</span>
                    </a>
                    <ul class="dropdown-menu">
						<table>
                        <?php
						echo "<li style=width:500px;><tr><td>&nbsp&nbsp&nbsp&nbsp <b>आवक_क्र. </b></td>
						<td>&nbsp&nbsp&nbsp&nbsp <b> विषय </b></td><tr><tr><td colspan=3>&nbsp;</td></tr>
						</li>";
						while($row=mysql_fetch_array($qry1))
						{ 
						echo "<li style=width:400px;><tr><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row['ltr_inword_no']."</td><td>&nbsp&nbsp&nbsp&nbsp".$row['subject']."</td></tr></li>";
						}
						?>
						</table>
                    </ul>
                </li>
				
				
				
				
				
				
				<li class="odd">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
					 <?php 
						
						$date123 = date('Y-m-d');
						
						//dept accepted, not assigned desk
						convert_marathi();
						$result421 = mysql_query("SELECT d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, i.priority_days, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d. update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.assign_no 
						FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
						LEFT OUTER JOIN desk_transaction 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.desk_id='0' 
						AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username') ");
						
						//$cnt=mysql_num_rows($result421);
						
						$cnt=0;
						while($row21=mysql_fetch_array($result421))
						{ 
							$priority_days=$row21['priority_days'];
							$receive_dt	=strtotime($row21['receive_dt']);

							$to_dt=strtotime("+".$priority_days." days",$receive_dt);
							//echo date("d-m-Y",$to_dt)."aa";
							
							$frm_dt=strtotime("-2 days",$to_dt);
															
							if(strtotime($date123)>$to_dt)
							{
								$cnt++;
							}
							
						//echo date("d-m-Y",$frm_dt)."<br>";
						
							
						}
						?>
						<span class="count"><?php echo $cnt;?></span>
                        <center><img src="images/silver-bell-md.png" style="height:40px;width:50px;" class="headmenu-label"></center>
                        <span class="headmenu-label"> प्राथमिकता प्रमाने  <br> &nbsp;&nbsp; </span>
                    </a>
                    <ul class="dropdown-menu">
						<table>
                        <?php
						echo "<li style=width:500px;><tr><td> &nbsp&nbsp&nbsp&nbsp <b> आवक_क्र. </b></td>
						<td>&nbsp&nbsp&nbsp&nbsp <b> संदर्भ_क्र. </b></td>
						<td>&nbsp&nbsp&nbsp&nbsp <b> विषय </b></td>
						<td>&nbsp&nbsp&nbsp&nbsp <b> पत्राची स्थिती </b></td>
						<td>&nbsp&nbsp&nbsp&nbsp <b> मुदत </b></td>
						</tr>
						<tr><td colspan=3>&nbsp;</td></tr>
						</li>";
						
						convert_marathi();
						$result421 = mysql_query("SELECT d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, i.priority_days, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d. update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.assign_no 
						FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
						LEFT OUTER JOIN desk_transaction 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.desk_id='0' 
						AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username') ");
						while($row2=mysql_fetch_array($result421))
						{ 
							$priority_days=$row2['priority_days'];
							$receive_dt	=strtotime($row2['receive_dt']);

							$to_dt=strtotime("+".$priority_days." days",$receive_dt);
							//echo date("d-m-Y",$to_dt)."aa";
							
							$frm_dt=strtotime("-2 days",$to_dt);
															
							if(strtotime($date123)>$to_dt)
							{
								//echo strtotime($date123).">=".$frm_dt;
								
								echo "<li style=width:500px;>
									<tr style=height:20px;>
										<td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row2['ltr_inword_no']."</td>
										<td> &nbsp&nbsp&nbsp&nbsp".$row2['ref_no']."</td>
										<td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row2['subject']."</td>
										<td> &nbsp&nbsp&nbsp&nbsp डेस्क लावणे बाकी </td>
										<td> &nbsp&nbsp&nbsp&nbsp ".date('d-m-Y',$to_dt)." </td>
									</tr>
								</li>";
							}
							
						//echo date("d-m-Y",$frm_dt)."<br>";
						
							
						}
						?>
						</table>
                    </ul>
                </li>
				
				
				
				
				
				
				
				
				
				
				
				<li class="odd">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
					<?php 
						convert_marathi();
						$date123 = date('Y-m-d');
					/*	$result5=mysql_query("SELECT * FROM  incoming_letters_transaction WHERE 
						(incoming_letters_transaction.sent_dt < DATE_SUB('$date123',INTERVAL 7 DAY) AND (incoming_letters_transaction.sent_dt > DATE_SUB('$date123',INTERVAL 15 DAY)) AND incoming_letters_transaction.dept_id!='0' AND incoming_letters_transaction.status='pending') AND incoming_letters_transaction.dept_id =(SELECT dept_id from login where login_id = '$username')") or die("".mysql_error());  */
					
								// dept accepted,desk accepted
								$result4 = mysql_query("SELECT d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d. update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.assign_no 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN desk_transaction 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= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt < DATE_SUB('$date123',INTERVAL 7 DAY)
								AND t.`desk_approval` = 'approve'
								AND ( d.ltr_status='')");
										
								// dept accepted,desk not accepted
								$result41 = mysql_query("SELECT d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d. update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.assign_no 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN desk_transaction 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= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
								AND t.dpt_ltr_rec_dt  < DATE_SUB('$date123',INTERVAL 7 DAY)
								AND t.`desk_approval` = 'pending' ");

																
								//dept accepted, not assigned desk
								$result42 = mysql_query("SELECT d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d. update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.assign_no 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN desk_transaction 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  < DATE_SUB('$date123',INTERVAL 7 DAY)
								AND t.desk_id='0' 
								AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username') ");	
																
								//dept not accepted
								$result43 = mysql_query("SELECT d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d. update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.assign_no 
								FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
								LEFT OUTER JOIN desk_transaction 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('$date123',INTERVAL 7 DAY)
								AND i.dept_id = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error());

						$cnt=mysql_num_rows($result4);
						$cnt1=mysql_num_rows($result41);
						$cnt2=mysql_num_rows($result42);
						$cnt3=mysql_num_rows($result43);
						$count=$cnt+$cnt1+$cnt2+$cnt3
						?>
						<span class="count"><?php echo $count;?></span>
                        <center><img src="images/silver-bell-md.png" style="height:40px;width:50px;" class="headmenu-label"></center>
                        <span class="headmenu-label"> एक आठवड्यापेक्षा <br>जास्त प्रलंबित संदर्भ  </span>
                    </a>
                    <ul class="dropdown-menu">
						<table>
                        <?php 
						echo "<li style=width:500px;><tr><td> &nbsp&nbsp&nbsp&nbsp <b> आवक_क्र. </b></td>
						<td>&nbsp&nbsp&nbsp&nbsp <b> संदर्भ_क्र. </b></td>
						<td>&nbsp&nbsp&nbsp&nbsp <b> विषय </b></td>
						<td>&nbsp&nbsp&nbsp&nbsp <b> पत्राची स्थिती </b></td></tr>
						<tr><td colspan=3>&nbsp;</td></tr>
						</li>";
						
						while($row=mysql_fetch_array($result4))
						{ 
							echo "<li style=width:500px;><tr style=height:20px;><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row['ltr_inword_no']."</td><td>&nbsp&nbsp&nbsp&nbsp".$row['ref_no']."</td><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row['subject']."</td>
							<td>&nbsp&nbsp&nbsp&nbsp डेस्क कार्यवाही करणे बाकी </td>
							</tr></li>";
						}
						
						while($row1=mysql_fetch_array($result41))
						{ 
							echo "<li style=width:500px;><tr style=height:20px;><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row1['ltr_inword_no']."</td><td>&nbsp&nbsp&nbsp&nbsp".$row1['ref_no']."</td><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row1['subject']."</td>
							<td>&nbsp&nbsp&nbsp&nbsp डेस्कने स्वीकारणे बाकी</td>
							</tr></li>";
						}
						
						while($row2=mysql_fetch_array($result42))
						{ 
							echo "<li style=width:500px;><tr style=height:20px;><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row2['ltr_inword_no']."</td><td>&nbsp&nbsp&nbsp&nbsp".$row2['ref_no']."</td><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row2['subject']."</td>
							<td>&nbsp&nbsp&nbsp&nbsp डेस्क लावणे बाकी </td>
							</tr></li>";
						}
						
						while($row3=mysql_fetch_array($result43))
						{ 
							echo "<li style=width:500px;><tr style=height:20px;><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row3['ltr_inword_no']."</td><td>&nbsp&nbsp&nbsp&nbsp".$row3['ref_no']."</td><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row3['subject']."</td>
							<td>&nbsp&nbsp&nbsp&nbsp विभागाने स्वीकारणे बाकी </td>
							</tr></li>";
						}
						?>
						</table>
                    </ul>
                </li>
				<li class="odd">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
					<?php 
						$dt=strtotime("today");
						$date=date("d-m-Y",$dt);
						
						$sun=strtotime("previous sunday");
						$datesun=date("d-m-Y",$sun);
						
						$sat=strtotime("next saturday");
						$datesat=date("d-m-Y",$sat);
					
						$date123	= $datesun;
						$date1	= date('Y-m-d',strtotime($date123));
								
						$date223	= $datesat;
						$date2	= date('Y-m-d',strtotime($date223));
							
						$id = $date1;
						$id1= $date2;
								
						//$date123 = date('Y-m-d');
						
						convert_marathi();
						/*	$result5=mysql_query("SELECT * FROM  incoming_letters_transaction WHERE 
						(incoming_letters_transaction.sent_dt < DATE_SUB('$date123',INTERVAL 30 DAY)  AND incoming_letters_transaction.dept_id!='0' AND incoming_letters_transaction.status='pending') AND incoming_letters_transaction.dept_id =(SELECT dept_id from login where login_id = '$username')") or die("".mysql_error()); */
						
							// dept accepted,desk accepted
							$result4 = mysql_query("SELECT d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt,t.desk_approval, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d. update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN desk_transaction 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= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
							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 d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt,t.desk_approval, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d. update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN desk_transaction 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= ( SELECT dept_id FROM login WHERE login_id = '$username' ) 
							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 accepted, not assigned desk
							$result42 = mysql_query("SELECT d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d. update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN desk_transaction 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  < DATE_SUB('$id',INTERVAL 14 DAY)
							AND t.desk_id='0' 
							AND t.dept_id_from = (SELECT dept_id from login where login_id = '$username') ");
							
							//dept not accepted
							$result43 = mysql_query("SELECT d.desk_ltr_id, d.desk_id_from, d.action_taken, d.desk_ltr_rec_dt, d.desk_ltr_inword_no, t.dpt_inword_no, t.dpt_ltr_id, t.dpt_ltr_rec_dt,t.desk_approval, t.dpt_inword_no, t.desk_id, t.dept_id_from, i.subject, d. update_date, d.dispatched_dt, d.ltr_approval, di.addressed_to, d.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, i.ref_no, i.dept_id, i.document, d.scan_doc, di.outword_no, di.dispatched_to, d.ltr_category, d.assign_no 
							FROM incoming_letters_transaction i LEFT OUTER JOIN tapal_to_dpt_transaction t ON i.ltr_id = t.ltr_id 
							LEFT OUTER JOIN desk_transaction 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 = (SELECT dept_id from login where login_id = '$username')") or die("cccc2".mysql_error());
								
						$cnt=mysql_num_rows($result4);
						$cnt1=mysql_num_rows($result41);
						$cnt2=mysql_num_rows($result42);
						$cnt3=mysql_num_rows($result43);
						$count=$cnt+$cnt1+$cnt2+$cnt3;
						?>
						<span class="count"><?php echo $count;?></span>
                        <center><img src="images/silver-bell-md.png" style="height:40px;width:50px;" class="headmenu-label"></center>
                        <span class="headmenu-label">तीन आठवड्यापेक्षा <br>जास्त प्रलंबित संदर्भ  </span>
                    </a>
                    <ul class="dropdown-menu">
						<table>
                        <?php
						echo "<li style=width:500px;>
							<tr><td>&nbsp&nbsp&nbsp&nbsp <b> आवक_क्र. </b></td>
							<td>&nbsp&nbsp&nbsp&nbsp <b> विषय </b></td>
							<td>&nbsp&nbsp&nbsp&nbsp <b> पत्राची स्थिती </b></td></tr>
							<tr><td colspan=3>&nbsp;</td></tr>
						</li>";
						while($row=mysql_fetch_array($result4))
						{ 
							echo "<li style=width:500px;><tr style=height:20px;><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row['ltr_inword_no']."</td><td>&nbsp&nbsp&nbsp&nbsp".$row['subject']."</td>
							<td>&nbsp&nbsp&nbsp&nbsp डेस्क कार्यवाही करणे बाकी </td>
							</tr></li>";
						}
						
						while($row1=mysql_fetch_array($result41))
						{ 
							echo "<li style=width:500px;><tr style=height:20px;><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row1['ltr_inword_no']."</td><td>&nbsp&nbsp&nbsp&nbsp".$row1['subject']."</td>
							<td>&nbsp&nbsp&nbsp&nbsp डेस्कने स्वीकारणे बाकी</td>
							</tr></li>";
						}
						while($row2=mysql_fetch_array($result42))
						{ 
							echo "<li style=width:500px;><tr style=height:20px;><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row2['ltr_inword_no']."</td><td>&nbsp&nbsp&nbsp&nbsp".$row2['ref_no']."</td><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row2['subject']."</td>
							<td>&nbsp&nbsp&nbsp&nbsp डेस्क लावणे बाकी </td>
							</tr></li>";
						}
						while($row3=mysql_fetch_array($result43))
						{ 
							echo "<li style=width:500px;><tr style=height:20px;><td style=height:18px;>&nbsp&nbsp&nbsp&nbsp".$row3['ltr_inword_no']."</td><td>&nbsp&nbsp&nbsp&nbsp".$row3['subject']."</td>
							<td>&nbsp&nbsp&nbsp&nbsp विभागाने स्वीकारणे बाकी </td>
							</tr></li>";
						}
						?>
						</table>
                    </ul>
                </li>
				<!---------------------------------------------------------------------------------------------
										End OF Notification Code
				----------------------------------------------------------------------------------------------->
                <li class="right">
                    <div class="userloggedinfo">
                        <img src="images/departments.jpg" alt="" />
						<div class="userinfo" style="width:150px;">
                            <ul> 
                                <li><h5><?php echo "Welcome </h5><h4 style=font-weight:bold;>".$_SESSION['User_Name']."</h4>";?></li>
                                <li><a href="logout.php">Sign Out</a></li>
                            </ul>
                        </div>
                    </div>
                </li>
            </ul><!--headmenu-->
        </div>
    </div>
    <div class="leftpanel">
        <div class="leftmenu">        
            <ul class="nav nav-tabs nav-stacked">
            	<li class="nav-header">Navigation</li>
				 <li class="active"><a href="dept_home.php"><span class="iconfa-laptop"></span>होम </a></li>
				 <li class="active"><a href="letterentry1.php"><span class="iconfa-envelope"></span>आवक बारनिशी</a></li>
				<li class="active"><a href="acceptletter.php"><span class="iconfa-laptop"></span>पत्र स्वीकृती</a></li>
                <li class="active"><a href="assign_desk.php"><span class="iconfa-laptop"></span>डेस्क लावा </a></li>
				<li class="active"><a href="sadyasthiti_department.php"><span class="iconfa-laptop"></span>कार्यविवरण नोंदवही / वर्कशिट </a></li>
				<li class="active"><a href="prakaran_nondwahi.php"><span class="iconfa-laptop"></span>प्रकरण नोंदवही </a></li>
                <li class="dropdown active"><a href=""><span class="iconfa-briefcase"></span>रिपोर्ट्स</a>
					<ul>
						<li><a href="report_dpt_sandharbha.php?no=1&username=<?php echo $username;?>">संदर्भप्रकारानुसार रिपोर्ट्स </a></li>
						<li><a href="report_dpt_jatanprakar.php?no=1">जतन प्रकारानुसार  रिपोर्ट्स</a></li>
					<!--	<li><a href="report_dpt_priority.php?no=1">प्राधान्यनुसार  रिपोर्ट्स</a></li> -->
						<li><a href="report_dpt_deskwise.php?no=1">डेस्क नुसार रिपोर्ट्स</a></li>
					<!--	<li><a href="report_dpt_refwise.php">संदर्भानुसार रिपोर्ट्स</a></li> -->
						<li><a href="report_dpt_ltr_transfer.php">पत्र फिर्तीनुसार रिपोर्ट्स </a></li>
						<li><a href="goshwara_dpt.php">गोषवारा </a></li>
						<li><a href="freq_dept1.php"> वारंवार येणारे पत्र  </a></li>
					</ul>
                </li>
				<li class="active"><a href="dept_accepted_rtn_table.php"><span class="iconfa-pencil"></span>स्वीकृत पत्र परत पाठवा </a></li>
				<?php 
				$q=mysql_query("Select user_type from login where login_id='$username'") or die("".mysql_error());
				$qs=mysql_fetch_array($q);
				$v=$qs['user_type'];
				?>
				<li class="active"><a href="changeseq.php?no=<?php echo $v; ?>"><span class="iconfa-pencil"></span>सेक्युरिटी प्रश्न बदला </a></li>
                <li class="active"><a href="changepw.php?no=<?php echo $v; ?>"><span class="iconfa-pencil"></span>पासवर्ड बदला </a></li>
            </ul>
        </div><!--leftmenu-->
    </div><!-- leftpanel -->
</script>
</body>
</html>