<!DOCTYPE html>
<?php
############################################ Display Reference Wise Report TO Department #########################################
include('dashboard_desk.php');
require_once('convert_marathi.php');
$username = $_SESSION['User_Name'];
$refno=$_GET['refno'];
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="text/javascript">     
function PrintDiv() {    
var divToPrint = document.getElementById('divToPrint');
var popupWin = window.open('', '_blank', 'width=600,height=600');
popupWin.document.open();
popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
popupWin.document.close();
}
</script>
<script src="tableToExcel.js"></script>
<style type="text/css">
.highlight{  
background:#fff;
font-weight:bold;
font-size:18px;
}
</style>
</head>
<body>
<div class="mainwrapper">   
    <div class="rightpanel">
            <ul class="breadcrumbs">
				<li><a href=""><i class="iconfa-home"></i></a> <span class="separator"></span></li>
				<li><a href="">Tables</a> <span class="separator"></span></li>
				<li>संदर्भानुसार रिपोर्ट्स</li>
			</ul>
			<div class="pageheader">
				<div class="pageicon"><span class="iconfa-table"></span></div>
				<div class="pagetitle">
					<h5>Tables</h5>
					<?php 
					$qryz=mysql_query("Select desk_nm from desk_master where desk_id=(select desk_id from login where login_id='$username')");
					$rsz=mysql_fetch_array($qryz);
					?>
					<h1><?php echo 	$rsz['desk_nm'];?> चे संदर्भानुसार रिपोर्ट्स</h1>
				</div>
			</div><!--pageheader-->
			<div class="maincontent">
				<div class="maincontentinner">	
						<h4 class="widgettitle"> <?php echo $rsz['desk_nm'];?> चे संदर्भानुसार रिपोर्ट्स</h4>
						<form method="post" action="">
							<?php
							convert_marathi();
							$result223=mysql_query("SELECT * FROM desk_transaction, incoming_letters_transaction, tapal_to_dpt_transaction WHERE desk_transaction.desk_id_from=(SELECT desk_id FROM login WHERE login_id='$username') AND incoming_letters_transaction.ltr_inword_no='$refno' AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND desk_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id AND incoming_letters_transaction.dpt_inword_no=tapal_to_dpt_transaction.dpt_inword_no") or die("".mysql_error());
							$rwst = mysql_fetch_array($result223);	
								############### Date Conversion #################
								$dsrecdt = strtotime($rwst['desk_ltr_rec_dt']);
								$dsrecdt1= date('d-m-Y', $dsrecdt);
								$dprecdt = strtotime($rwst['dpt_ltr_rec_dt']);
								$dprecdt1= date('d-m-Y', $dprecdt);
								$refdt = strtotime($rwst['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rwst['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);
								################# End Of Date Conversion ########
							?>	
							<table id="dyntable" class="table table-bordered">
							<thead>
							<tr>
								<th class="head1 center">डेस्कचा आवक क्र <br>आवक_दिनांक</th>
								<th class="head0 center">विभागीय आवक क्र. <br>आवक_दिनांक</th>
								<th class="head1 center">आवक क्रमांक<br>आवक_दिनांक</th>
								<th class="head0 center">संदर्भ क्र.<br>प्राप्त_दिनांक</th>                          
								<th class="head1 center">कोणाकडून प्राप्त झाला </th>
								<th class="head0 center">विषय</th>                         
								<th class="head1 center"> केलेली कार्यवाही </th>
							</tr>
							<tr class="highlight">	
							<?php 
									echo "<td class=center>".$rwst['desk_ltr_id']."<br>".$dsrecdt1." </td>
									<td class=center>".$rwst['dpt_ltr_id']."<br>".$dprecdt1." </td>";
									echo "<td class=center>".$rwst['ltr_id']."<br>".$recdt1." </td>
									<td class=center>".$rwst['ref_no']."<br>".$refdt1."</td>
									<td class=center id=wrapping>".$rwst['sender_name']."</td><td class=center id=wrapping>".$rwst['subject']."</td>";
									if($rwst['action_taken']=='')
									{
										echo "<td class=center><font color='red'>". "कार्यवाही करणे बाकी "."</font></td>";
									}
									else
									{
										echo "<td class=center>".$rwst['action_taken']."</td>";	
									}
							echo" </select></tr>";?>
							</thead>
							<tbody>
							<?php
							convert_marathi();
							$result222=mysql_query("SELECT * FROM desk_transaction, incoming_letters_transaction, tapal_to_dpt_transaction where desk_transaction.desk_id_from=(select desk_id from login where login_id='$username') AND (desk_transaction.assign_no='$refno' AND desk_transaction.ltr_category='current') AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id") or die("".mysql_error());
							while($rws = mysql_fetch_array($result222))
							{			
								############### Date Conversion #################
								$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);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);
								################# End Of Date Conversion ########
								if($rws['ltr_inword_no']==$refno && $rws['ltr_category']=='new')
								{?>
									<tr class="highlight">	
									<?php 
										echo "<td class=center>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>
										<td class=center>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
										echo "<td class=center>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
										<td class=center>".$rws['ref_no']."<br>".$refdt1."</td>
										<td class=center id=wrapping>".$rws['sender_name']."</td><td class=center id=wrapping>".$rws['subject']."</td>";
										if($rws['action_taken']=='')
										{
											echo "<td class=center><font color='red'>". "कार्यवाही करणे बाकी "."</font></td>";
										}
										else
										{
											echo "<td class=center>".$rws['action_taken']."</td>";	
										}
				  			 
										echo" </select></tr>";
								}
								else if($rws['assign_no']==$refno && $rws['ltr_category']=='current')
								{
									?>	
									<tr>
									<?php 
									echo "<td class=center>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>
									<td class=center>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
									echo "<td class=center>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
									<td class=center>".$rws['ref_no']."<br>".$refdt1."</td>
									<td class=center id=wrapping>".$rws['sender_name']."</td><td class=center id=wrapping>".$rws['subject']."</td>";
									if($rws['action_taken']=='')
									{
										echo "<td class=center><font color='red'>". "कार्यवाही करणे बाकी "."</font></td>";	
									}
									else
									{
										echo "<td class=center>".$rws['action_taken']."</td>";		
									}	
								}
							}
							//mysql_close();
							echo	"</tbody>
							</table>";
							?>
							<?php
							echo "<div id='divToPrint'><table>";
								convert_marathi();
								$result223=mysql_query("SELECT * FROM desk_transaction, incoming_letters_transaction, tapal_to_dpt_transaction WHERE desk_transaction.desk_id_from=(SELECT desk_id FROM login WHERE login_id='$username') AND incoming_letters_transaction.ltr_inword_no='$refno' AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id AND desk_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id AND incoming_letters_transaction.dpt_inword_no=tapal_to_dpt_transaction.dpt_inword_no") or die("".mysql_error());
								$rwst = mysql_fetch_array($result223);	
									############### Date Conversion #################
									$dsrecdt = strtotime($rwst['desk_ltr_rec_dt']);
									$dsrecdt1= date('d-m-Y', $dsrecdt);
									$dprecdt = strtotime($rwst['dpt_ltr_rec_dt']);
									$dprecdt1= date('d-m-Y', $dprecdt);
									$refdt = strtotime($rwst['ref_dt']);
									$refdt1= date('d-m-Y', $refdt);
									$recdt = strtotime($rwst['receive_dt']);
									$recdt1= date('d-m-Y', $recdt);
									################# End Of Date Conversion ########
									echo "<tr>
										<th>डेस्कचा आवक क्र <br>आवक_दिनांक</th>
										<th>विभागीय आवक क्र. <br>आवक_दिनांक</th>
										<th>आवक क्रमांक<br>आवक_दिनांक</th>
										<th>संदर्भ क्र.<br>प्राप्त_दिनांक</th>                          
										<th>कोणाकडून प्राप्त झाला </th>
										<th>विषय</th>                         
										<th> केलेली कार्यवाही </th>
									</tr>
									<tr class='highlight'>";
									echo "<td>".$rwst['desk_ltr_id']."<br>".$dsrecdt1." </td>
									<td>".$rwst['dpt_ltr_id']."<br>".$dprecdt1." </td>";
									echo "<td>".$rwst['ltr_id']."<br>".$recdt1." </td>
									<td>".$rwst['ref_no']."<br>".$refdt1."</td>
									<td>".$rwst['sender_name']."</td><td>".$rwst['subject']."</td>";
									if($rwst['action_taken']=='')
									{
										echo "<td>". "कार्यवाही करणे बाकी "."</td>";
									}
									else
									{
										echo "<td>".$rwst['action_taken']."</td>";	
									}
							echo "</tr>";
							convert_marathi();
							$result222=mysql_query("SELECT * FROM desk_transaction, incoming_letters_transaction, tapal_to_dpt_transaction where desk_transaction.desk_id_from=(select desk_id from login where login_id='$username') AND (desk_transaction.assign_no='$refno' AND desk_transaction.ltr_category='current') AND desk_transaction.dpt_ltr_id=tapal_to_dpt_transaction.dpt_ltr_id AND incoming_letters_transaction.ltr_id=tapal_to_dpt_transaction.ltr_id") or die("".mysql_error());
							while($rws = mysql_fetch_array($result222))
							{			
								############### Date Conversion #################
								$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);
								$refdt = strtotime($rws['ref_dt']);
								$refdt1= date('d-m-Y', $refdt);
								$recdt = strtotime($rws['receive_dt']);
								$recdt1= date('d-m-Y', $recdt);
								################# End Of Date Conversion ########
								if($rws['ltr_inword_no']==$refno && $rws['ltr_category']=='new')
								{
									echo "<tr class='highlight'>	
									<td>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>
									<td>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
									echo "<td>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
									<td>".$rws['ref_no']."<br>".$refdt1."</td>
									<td>".$rws['sender_name']."</td><td>".$rws['subject']."</td>";
									if($rws['action_taken']=='')
									{
										echo "<td>". "कार्यवाही करणे बाकी "."</font></td>";
									}
									else
									{
										echo "<td>".$rws['action_taken']."</td>";	
									}
									echo "</tr>";
								}
								else if($rws['assign_no']==$refno && $rws['ltr_category']=='current')
								{
									echo "<tr>
									<td>".$rws['desk_ltr_inword_no']."<br>".$dsrecdt1." </td>
									<td>".$rws['dpt_inword_no']."<br>".$dprecdt1." </td>";
									echo "<td>".$rws['ltr_inword_no']."<br>".$recdt1." </td>
									<td>".$rws['ref_no']."<br>".$refdt1."</td>
									<td>".$rws['sender_name']."</td><td>".$rws['subject']."</td>";
									if($rws['action_taken']=='')
									{
										echo "<td>". "कार्यवाही करणे बाकी "."</font></td>";	
									}
									else
									{
										echo "<td>".$rws['action_taken']."</td>";		
									}	
								}
							}
							//mysql_close();
							echo	"</table></div>";
							
							?>
							<br>
							<p>	
								<center><input type="submit" value=" Print Page " onclick="PrintDiv();" class="btn btn-primary"/>
								<input type="button" class="btn" onclick="tableToExcel('dyntable', 'W3C Example Table')" value="Export to Excel"></center>
							</p>
						</form>
						<br /><br />
                        <?php include_once('footer.php'); ?>
                    </div>
				</div><!--maincontentinner-->
			</div><!--maincontent-->
		</div><!--rightpanel-->
	</div><!--mainwrapper-->
</body>
</html>
