<?php
require_once('./connection/db.php');
	 require_once('convert_marathi.php');
	 $padno=$_REQUEST['ltrpadno'];
########################################## View Current Status ########################################################
 
	 $no=$_GET['no'];
   ?>
<html>
<head>

<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="https://www.google.com/jsapi"></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 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>
<script type="text/javascript">     
	function PrintDiv() {    
	var divToPrint = document.getElementById('divToPrint');
	var popupWin = window.open('', '_blank', 'width=600,height=600');
	popupWin.document.open();
	popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
	 popupWin.document.close();
	}
	</script>
<script type="text/javascript" src="js/adduser.js"></script>
</head>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="js/excanvas.min.js"></script><![endif]-->
<body>
<div class="mainwrapper">
   <div class="header">
        <div class="logo">
            <img src="" alt="" /><font color="white" size="3px;" style="font-weight:bold">पोलीस अधिक्षक कार्यालय,<br> जि.रायगड</font>
        </div>
        <div class="headerinner">
            <ul class="headmenu">
                <li class="odd">
                    <ul class="dropdown-menu">
                    </ul>
                </li>
                <li class="right">
                    <div class="userloggedinfo">
                            <ul> 
                                <li><h5><?php echo "Welcome </h5><h4 style=font-weight:bold;>".User."</h4>";?></li>
                            </ul>
                        </div>
                    </div>
                </li>
            </ul><!--headmenu-->
        </div>
    </div>
</div><!--mainwrapper-->

<body style="background:white;">

    <div class="rightpanel" style="margin-Left:0px;width:100%;">
        <div class="maincontent">
            <div class="maincontentinner">
            <div class="widget" style="text-align:center;width:80%;margin-left: auto ;margin-right: auto ;">
            <h4 class="widgettitle">पत्राची सद्यस्थिती पडताळा </h4>
            <div class="widgetcontent" style="align:centre;">
			<form action="">
	<?php
					$q=mysql_query("SELECT desk_flag from department_master where dept_id=(SELECT dept_id from  incoming_letters_transaction where padtalni_no='$padno')");
					
					$r=mysql_fetch_array($q);
					
					if($r['desk_flag']=='Y' || $r['desk_flag']=='y')
					{
								echo "
									 <table class='table table-bordered' border=1px>	
										<thead>
											<tr>
												<th class='head0 center'>डेस्कचा आ_क्रमांक <br>आवक_दिनांक.</th>
												<th class='head1 center'>विभागीय आ_क्रमांक  <br>आवक_दिनांक</th>
												<th class='head0 center' style='width:90px;'>आवक_क्रमांक <br>आवक_दिनांक</th>
												<th class='head1 center' style='width:90px;'>संदर्भ_क्रमांक<br>प्राप्त_दिनांक</th>                          
												<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय</th>                     
												<th class='head1 center'>केलेली कार्यवाही </th>
												<th class='head1 center'>पत्राची स्थिती </th>
												<th class='head0 center' style='width:90px;'>जावक_दिनांक </th>
												<th class='head0 center'>जावक क्र. <br> व्यक्तीचे नाव </th>
											</tr>
										</thead>";
						
						convert_marathi();
						$result222=mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no,i.ltr_type, 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, de.update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt,t.sent_to_desk_dt, i.ref_no, i.dept_id, i.document, de.scan_doc,i.padtalni_no, di.outword_no, di.dispatched_to, t.returned_choice, t.desk_approval,di.dept_id_to, t.status,t.desk_approval, de.ltr_category, de.assign_no FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id  Where i.padtalni_no='$padno'") or die("".mysql_error());
						while($rws = mysql_fetch_array($result222))
						{	
							########################### Fetch department name ##############################
							if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
							{
							$dpt=$rws['dept_id_from'];
							$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$dpt'") or die("".mysql_error());
							$dept=mysql_fetch_array($qdpt);
							}
							########################### Fetch desk name ##############################
							if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
							{
							$dsk=$rws['desk_id_from'];
							$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
							$desk=mysql_fetch_array($qsk);
							}
								################# convert date in suitable format ##########################
													$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
													$dsrecdt1= date('d-m-Y', $dsrecdt);
													$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
													$dprecdt1= date('d-m-Y', $dprecdt);
													$dis_date 		= date('d-m-Y',strtotime($rws['dispatched_dt']));
													$up_date 		= date('d-m-Y',strtotime($rws['update_date']));
													$refdt = strtotime($rws['ref_dt']);
													$refdt1= date('d-m-Y', $refdt);
													$recdt = strtotime($rws['receive_dt']);
													$recdt1= date('d-m-Y', $recdt);	
													$dept_idto=$rws['dept_id_to'];
									echo "<tr class='gradeX'>";
									############################################### Desk ####################################
									if($rws['desk_id']=='0' || $rws['desk_id']=='')
									{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
									}
									else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
									{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
									}
									else
									{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
									}
									
									############################################## dpt######################################
									if($rws['dept_id']=='0' || $rws['dept_id']=='')
									{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
									}
									else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
									{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
									}
									else
									{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
									}
									######################################### common things ##################################
													echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
													<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
													<td>नाव : ".$rws['sender_name']." <br>विषय :".$rws['subject']."</td>";
										########################### If Action Taken Pending ##########################				
													if($rws['action_taken']=='')
													{
														echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
													}
													else
													{
														echo "<td class='center'>".$rws['action_taken']."</td>";
													}
										######################### For Letter Status #################################
													if($rws['action_taken']=='')
													{
													echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
													}
													else if($rws['ltr_approval']=='transferred')
													{
														$qey=mysql_query("SELECT dept_nm from department_master WHERE dept_id='$dept_idto'");
														$nmdpt=mysql_fetch_array($qey);
														echo "<td class='center'>".$rws['ltr_approval']." to<br>".$nmdpt['dept_nm']."</td>";
													}
													else if($rws['ltr_approval']=='Approve')
														{
															echo "<td class='center'>".$rws['ltr_status']."</td>";
														}
										##############################################################################
										
													if($rws['ltr_status']=='dispatched')
														{
															echo "<td class='center'>".$dis_date."</td>";
														}
													else if($rws['ltr_status']=='updated')
													{
															echo "<td class='center'>".$up_date."</td>";
													}
													else if($rws['ltr_approval']=='Approve')
													{
														echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
													}
										
										
										##############################################################################
													if($rws['addressed_to']=='')
													{
													echo "<td class='center'><font color='red'>"."-----"."</font></td>";
													}
													else
													{
														echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
													}
											echo" </select></tr>";
						}
						//mysql_close();
						echo"   </tbody>
							</table>";
					}
					
					else
					{
						echo "
									 <table class='table table-bordered'>	
										<thead>
											<tr>
												<th class='head1 center'>विभागीय आ_क्रमांक  <br>आवक_दिनांक</th>
												<th class='head0 center' style='width:90px;'>आवक_क्रमांक <br>आवक_दिनांक</th>
												<th class='head1 center' style='width:90px;'>संदर्भ_क्रमांक<br>प्राप्त_दिनांक</th>                          
												<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय</th>                     
												<th class='head1 center'>केलेली कार्यवाही </th>
												<th class='head1 center'>पत्राची स्थिती </th>
												<th class='head0 center' style='width:90px;'>जावक_दिनांक </th>
												<th class='head0 center'>जावक क्र. <br> व्यक्तीचे नाव </th>
											</tr>
										</thead>";
						
						convert_marathi();
						$result222=mysql_query("SELECT  t.action_taken, i.ltr_type, 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, t.update_date, t.dispatched_date, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, t.sent_to_desk_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, i.padtalni_no, di.outword_no, di.dispatched_to, t.returned_choice, t.desk_approval, di.dept_id_to, t.status, t.desk_approval, t.ltr_category, t.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 dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
						Where i.padtalni_no='$padno'") or die("".mysql_error());
						
						while($rws = mysql_fetch_array($result222))
						{	
							########################### Fetch department name ##############################
							if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
							{
							$dpt=$rws['dept_id_from'];
							$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$dpt'") or die("".mysql_error());
							$dept=mysql_fetch_array($qdpt);
							}
							########################### Fetch desk name ##############################
							if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
							{
							$dsk=$rws['desk_id_from'];
							$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
							$desk=mysql_fetch_array($qsk);
							}
								################# convert date in suitable format ##########################
													$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
													$dsrecdt1= date('d-m-Y', $dsrecdt);
													$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
													$dprecdt1= date('d-m-Y', $dprecdt);
													$dis_date = date('d-m-Y',strtotime($rws['dispatched_date']));
													$up_date = date('d-m-Y',strtotime($rws['update_date']));
													$refdt = strtotime($rws['ref_dt']);
													$refdt1= date('d-m-Y', $refdt);
													$recdt = strtotime($rws['receive_dt']);
													$recdt1= date('d-m-Y', $recdt);	
													$dept_idto=$rws['dept_id_to'];
									echo "<tr class='gradeX'>";
								
									############################## dpt ##################################
									if($rws['dept_id']=='0' || $rws['dept_id']=='')
									{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
									}
									else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
									{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
									}
									else
									{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
									}
									######################################### common things ##################################
													echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
													<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
													<td>नाव : ".$rws['sender_name']." <br>विषय :".$rws['subject']."</td>";
													
										#################### If Action Taken Pending #################				
													if($rws['action_taken']=='')
													{
														echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
													}
													else
													{
														echo "<td class='center'>".$rws['action_taken']."</td>";
													}
										######################### For Letter Status #################################
													if($rws['action_taken']=='')
													{
													echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
													}
													else if($rws['status']=='transferred')
													{
														$qey=mysql_query("SELECT dept_nm from department_master WHERE dept_id='$dept_idto'");
														$nmdpt=mysql_fetch_array($qey);
														echo "<td class='center'>".$rws['status']." to<br>".$nmdpt['dept_nm']."</td>";
													}
													else if($rws['status']=='approve' || $rws['status']=='dispatched')
													{
														echo "<td class='center'>".$rws['ltr_status']."</td>";
													}
										##############################################################################
										
													if($rws['ltr_status']=='dispatched')
													{
														echo "<td class='center'>".$dis_date."</td>";
													}
													else if($rws['ltr_status']=='updated')
													{
														echo "<td class='center'>".$up_date."</td>";
													}
													else if($rws['ltr_approval']=='Approve')
													{
														echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
													}
										
										
										##############################################################################
													if($rws['addressed_to']=='')
													{
													echo "<td class='center'><font color='red'>"."-----"."</font></td>";
													}
													else
													{
														echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
													}
											echo" </select></tr>";
						}
						//mysql_close();
						echo"   </tbody>
							</table>";
					}
					
					
			echo "<div id='divToPrint' align='center' style='display:none'>	
			<center><table style='width:70%;' border='1' class='table table-bordered' id='sample_1' cellpadding='2' cellspacing='2' >";
			
			$q=mysql_query("SELECT desk_flag from department_master where dept_id=(SELECT dept_id from  incoming_letters_transaction where padtalni_no='$padno')");
					
					$r=mysql_fetch_array($q);
					
					if($r['desk_flag']=='Y' || $r['desk_flag']=='y')
					{
								echo "<thead>
											<tr>
												<th class='head0 center'>डेस्कचा आ_क्रमांक <br>आवक_दिनांक.</th>
												<th class='head1 center'>विभागीय आ_क्रमांक  <br>आवक_दिनांक</th>
												<th class='head0 center' style='width:90px;'>आवक_क्रमांक <br>आवक_दिनांक</th>
												<th class='head1 center' style='width:90px;'>संदर्भ_क्रमांक<br>प्राप्त_दिनांक</th>                          
												<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय</th>                     
												<th class='head1 center'>केलेली कार्यवाही </th>
												<th class='head1 center'>पत्राची स्थिती </th>
												<th class='head0 center' style='width:90px;'>जावक_दिनांक </th>
												<th class='head0 center'>जावक क्र. <br> व्यक्तीचे नाव </th>
											</tr>
										</thead>";
						
						convert_marathi();
						$result222=mysql_query("SELECT de.desk_ltr_id, de.desk_id_from, de.action_taken, de.desk_ltr_rec_dt, de.desk_ltr_inword_no,i.ltr_type, 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, de.update_date, de.dispatched_dt, de.ltr_approval, di.addressed_to, de.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt,t.sent_to_desk_dt, i.ref_no, i.dept_id, i.document, de.scan_doc,i.padtalni_no, di.outword_no, di.dispatched_to, t.returned_choice, t.desk_approval,di.dept_id_to, t.status,t.desk_approval, de.ltr_category, de.assign_no FROM tapal_to_dpt_transaction t LEFT OUTER JOIN incoming_letters_transaction  i ON i.ltr_id = t.ltr_id LEFT OUTER JOIN desk_transaction de ON de.dpt_ltr_id = t.dpt_ltr_id LEFT OUTER JOIN dispatched_transaction di ON di.desk_ltr_id = de.desk_ltr_id  Where i.padtalni_no='$padno'") or die("".mysql_error());
						while($rws = mysql_fetch_array($result222))
						{	
							########################### Fetch department name ##############################
							if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
							{
							$dpt=$rws['dept_id_from'];
							$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$dpt'") or die("".mysql_error());
							$dept=mysql_fetch_array($qdpt);
							}
							########################### Fetch desk name ##############################
							if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
							{
							$dsk=$rws['desk_id_from'];
							$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
							$desk=mysql_fetch_array($qsk);
							}
								################# convert date in suitable format ##########################
													$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
													$dsrecdt1= date('d-m-Y', $dsrecdt);
													$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
													$dprecdt1= date('d-m-Y', $dprecdt);
													$dis_date 		= date('d-m-Y',strtotime($rws['dispatched_dt']));
													$up_date 		= date('d-m-Y',strtotime($rws['update_date']));
													$refdt = strtotime($rws['ref_dt']);
													$refdt1= date('d-m-Y', $refdt);
													$recdt = strtotime($rws['receive_dt']);
													$recdt1= date('d-m-Y', $recdt);	
													$dept_idto=$rws['dept_id_to'];
									echo "<tr class='gradeX'>";
									############################################### Desk ####################################
									if($rws['desk_id']=='0' || $rws['desk_id']=='')
									{
									echo "<td class='center'><font color='red'>डेस्क लावणे बाकी</font> </td>";
									}
									else if($rws['desk_ltr_inword_no']=='' || $rws['desk_ltr_inword_no']=='0')
									{
									echo "<td class='center'><font color='red'>डेस्कने स्वीकारणे बाकी</font> </td>";
									}
									else
									{
									echo "<td class='center'>".$desk['desk_nm']."<br>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>";
									}
									
									############################################## dpt######################################
									if($rws['dept_id']=='0' || $rws['dept_id']=='')
									{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
									}
									else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
									{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
									}
									else
									{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
									}
									######################################### common things ##################################
													echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
													<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
													<td>नाव : ".$rws['sender_name']." <br>विषय :".$rws['subject']."</td>";
										########################### If Action Taken Pending ##########################				
													if($rws['action_taken']=='')
													{
														echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
													}
													else
													{
														echo "<td class='center'>".$rws['action_taken']."</td>";
													}
										######################### For Letter Status #################################
													if($rws['action_taken']=='')
													{
													echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
													}
													else if($rws['ltr_approval']=='transferred')
													{
														$qey=mysql_query("SELECT dept_nm from department_master WHERE dept_id='$dept_idto'");
														$nmdpt=mysql_fetch_array($qey);
														echo "<td class='center'>".$rws['ltr_approval']." to<br>".$nmdpt['dept_nm']."</td>";
													}
													else if($rws['ltr_approval']=='Approve')
														{
															echo "<td class='center'>".$rws['ltr_status']."</td>";
														}
										##############################################################################
										
													if($rws['ltr_status']=='dispatched')
														{
															echo "<td class='center'>".$dis_date."</td>";
														}
													else if($rws['ltr_status']=='updated')
													{
															echo "<td class='center'>".$up_date."</td>";
													}
													else if($rws['ltr_approval']=='Approve')
													{
														echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
													}
										
										
										##############################################################################
													if($rws['addressed_to']=='')
													{
													echo "<td class='center'><font color='red'>"."-----"."</font></td>";
													}
													else
													{
														echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
													}
											echo" </select></tr>";
						}
						//mysql_close();
						echo"   </tbody>
							</table></center>";
					}
					
					else
					{
						echo "<thead>
								<tr>
									<th class='head1 center'>विभागीय आ_क्रमांक  <br>आवक_दिनांक</th>
									<th class='head0 center' style='width:90px;'>आवक_क्रमांक <br>आवक_दिनांक</th>
									<th class='head1 center' style='width:90px;'>संदर्भ_क्रमांक<br>प्राप्त_दिनांक </th>                          
									<th class='head0 center'>कोणाकडून प्राप्त झाला <br>विषय</th>                     
									<th class='head1 center'>केलेली कार्यवाही </th>
									<th class='head1 center'>पत्राची स्थिती </th>
									<th class='head0 center' style='width:90px;'>जावक_दिनांक </th>
									<th class='head0 center'>जावक क्र. <br> व्यक्तीचे नाव </th>
								</tr>
							</thead>";
						
						convert_marathi();
						$result222=mysql_query("SELECT  t.action_taken, i.ltr_type, 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, t.update_date, t.dispatched_date, di.addressed_to, t.ltr_status, i.sender_name, i.ltr_id, i.ltr_inword_no, i.receive_dt, i.ref_dt, t.sent_to_desk_dt, i.ref_no, i.dept_id, i.document, t.scan_doc, i.padtalni_no, di.outword_no, di.dispatched_to, t.returned_choice, t.desk_approval, di.dept_id_to, t.status, t.desk_approval, t.ltr_category, t.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 dispatched_transaction di ON ( di.ltr_id = t.ltr_id AND di.desk_ltr_id='0')
						Where i.padtalni_no='$padno'") or die("".mysql_error());
						
						while($rws = mysql_fetch_array($result222))
						{	
							########################### Fetch department name ##############################
							if($rws['dept_id_from']!='' || $rws['dept_id_from']!='0')
							{
							$dpt=$rws['dept_id_from'];
							$qdpt=mysql_query("Select dept_nm from department_master Where dept_id='$dpt'") or die("".mysql_error());
							$dept=mysql_fetch_array($qdpt);
							}
							########################### Fetch desk name ##############################
							if($rws['desk_id_from']!='' || $rws['desk_id_from']!='0')
							{
							$dsk=$rws['desk_id_from'];
							$qsk=mysql_query("Select desk_nm from desk_master Where desk_id='$dsk'") or die("".mysql_error());
							$desk=mysql_fetch_array($qsk);
							}
								################# convert date in suitable format ##########################
													$dsrecdt = strtotime($rws['desk_ltr_rec_dt']);
													$dsrecdt1= date('d-m-Y', $dsrecdt);
													$dprecdt = strtotime($rws['dpt_ltr_rec_dt']);
													$dprecdt1= date('d-m-Y', $dprecdt);
													$dis_date = date('d-m-Y',strtotime($rws['dispatched_date']));
													$up_date = date('d-m-Y',strtotime($rws['update_date']));
													$refdt = strtotime($rws['ref_dt']);
													$refdt1= date('d-m-Y', $refdt);
													$recdt = strtotime($rws['receive_dt']);
													$recdt1= date('d-m-Y', $recdt);	
													$dept_idto=$rws['dept_id_to'];
									echo "<tr class='gradeX'>";
								
									############################## dpt ##################################
									if($rws['dept_id']=='0' || $rws['dept_id']=='')
									{
									echo "<td class='center'><font color='red'>विभाग लावणे बाकी</font> </td>";
									}
									else if($rws['dpt_inword_no']=='' || $rws['dpt_inword_no']=='0')
									{
									echo "<td class='center'><font color='red'> विभागाने स्वीकारणे बाकी </font> </td>";
									}
									else
									{
									echo "<td class='center'>".$dept['dept_nm']."<br>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
									}
									######################################### common things ##################################
													echo "<td class='center'>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
													<td class='center'>".$rws['ref_no']."<br>".$refdt1."</td>
													<td>नाव : ".$rws['sender_name']." <br>विषय :".$rws['subject']."</td>";
													
										#################### If Action Taken Pending #################				
													if($rws['action_taken']=='')
													{
														echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
													}
													else
													{
														echo "<td class='center'>".$rws['action_taken']."</td>";
													}
										######################### For Letter Status #################################
													if($rws['action_taken']=='')
													{
													echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
													}
													else if($rws['status']=='transferred')
													{
														$qey=mysql_query("SELECT dept_nm from department_master WHERE dept_id='$dept_idto'");
														$nmdpt=mysql_fetch_array($qey);
														echo "<td class='center'>".$rws['status']." to<br>".$nmdpt['dept_nm']."</td>";
													}
													else if($rws['status']=='approve' || $rws['status']=='dispatched')
													{
														echo "<td class='center'>".$rws['ltr_status']."</td>";
													}
										##############################################################################
										
													if($rws['ltr_status']=='dispatched')
													{
														echo "<td class='center'>".$dis_date."</td>";
													}
													else if($rws['ltr_status']=='updated')
													{
														echo "<td class='center'>".$up_date."</td>";
													}
													else if($rws['ltr_approval']=='Approve')
													{
														echo "<td class='center'><font color='red'>"."कार्यवाही करणे बाकी "."</font></td>";
													}
										
										
										##############################################################################
													if($rws['addressed_to']=='')
													{
													echo "<td class='center'><font color='red'>"."-----"."</font></td>";
													}
													else
													{
														echo "<td class='center'>".$rws['outword_no']."<br>".$rws['addressed_to']."</td>";
													}
											echo" </select></tr>";
						}
						//mysql_close();
						echo"   </tbody>
							</table></center>";
					}
					
			echo "</div>";		
					
			
				
	?>
				<p>	
					<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"/>
					</center>
				</p>
				</form>
                </div><!--widgetcontent-->
            </div><!--widget-->
        	<center><a href="online_current_status.php">Back</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<a href="index.php">Home</a></center>
            <?php
            include_once('footer.php');?>
                    </div>
                </div><!--footer-->
                
            </div><!--maincontentinner-->
        </div><!--maincontent-->
        
    </div><!--rightpanel-->
    
</div><!--mainwrapper-->

</body>
</html>
