  <?php ######################################### Desk Wise Sadyasthiti Report #################################################
include_once('dashboard_desk.php');
require_once('convert_marathi.php');
$username = $_SESSION['User_Name'];
$qry=mysql_query("select desk_nm from desk_master,login where login.desk_id=desk_master.desk_id");
$rwq=mysql_fetch_array($qry);
?>
<!DOCTYPE html>

<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>
<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> 
<script src="tableToExcel.js"></script>
</head>
    <div class="rightpanel"> 
        <ul class="breadcrumbs">
            <li><a href="dashboard_desk.php"><i class="iconfa-home"></i></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>
                <h1>सद्यस्थिती </h1>
            </div>
        </div><!--pageheader-->
        <div class="maincontent">
            <div class="maincontentinner">
			<h4 class="widgettitle"><?php echo $rwq['desk_nm']; ?>च्या पत्रांची सद्यस्थिती </h4>	
			<!-- Code For Start Date End Date Input -->
				<form name="sadyasthiti" action="sadhyasthiti_desk.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>
			    <div id="divToPrint">       
						<p align="center"><font size="4" color='#0866c6' style="font-family:verdana;"><br>
						<?php
						$date123	= $_POST['start_date'];
						$date1	= date('Y-m-d',strtotime($date123));
						$date223	= $_POST['end_date'];
						$date2	= date('Y-m-d',strtotime($date223));
						//$date22	= date('d-m-Y',strtotime($date2));
						echo 'दिनांक <font color="#59c600">'.$date123.'</font>'.' पासून दिनांक '.'<font color="#59c600">'.$date223.'</font>';$id = $date1;
						$id1= $date2;
						?></font>
						</p>
						<br>			
						<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'>केलेली<br> कार्यवाही</th>
									<th class='head1 center'>View</th>
								</tr>
							</thead>
							<tbody>		
							<?php	
							convert_marathi();
							if($date123==''&& $date223=='')
							{	
								$qry=("SELECT tapal_to_dpt_transaction.dpt_ltr_id,incoming_letters_transaction.ref_dt, incoming_letters_transaction.sender_name, incoming_letters_transaction.ltr_inword_no,desk_transaction.desk_ltr_id, incoming_letters_transaction.ref_no,incoming_letters_transaction.ltr_id, incoming_letters_transaction.subject, tapal_to_dpt_transaction.dpt_inword_no,desk_transaction.desk_apprv_dt, desk_transaction.desk_ltr_rec_dt, desk_transaction.assign_no, desk_transaction.ltr_category, desk_transaction.desk_ltr_inword_no,tapal_to_dpt_transaction.dpt_ltr_rec_dt, tapal_to_dpt_transaction.desk_id, incoming_letters_transaction.dept_id, tapal_to_dpt_transaction.dept_id_from, desk_transaction.desk_id_from, incoming_letters_transaction.receive_dt, desk_transaction.desk_apprv_dt FROM incoming_letters_transaction LEFT OUTER JOIN tapal_to_dpt_transaction ON incoming_letters_transaction.ltr_id = tapal_to_dpt_transaction.ltr_id LEFT OUTER JOIN desk_transaction ON tapal_to_dpt_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id WHERE desk_transaction.desk_id_from=(select desk_id from login where login_id='$username')");
							}
							else
							{	
								$qry=("SELECT tapal_to_dpt_transaction.dpt_ltr_id,incoming_letters_transaction.ref_dt, incoming_letters_transaction.sender_name, incoming_letters_transaction.ltr_inword_no,desk_transaction.desk_ltr_id, incoming_letters_transaction.ref_no,incoming_letters_transaction.ltr_id, incoming_letters_transaction.subject, tapal_to_dpt_transaction.dpt_inword_no,desk_transaction.desk_apprv_dt, desk_transaction.desk_ltr_rec_dt, desk_transaction.assign_no, desk_transaction.ltr_category, desk_transaction.desk_ltr_inword_no,tapal_to_dpt_transaction.dpt_ltr_rec_dt, tapal_to_dpt_transaction.desk_id, incoming_letters_transaction.dept_id, tapal_to_dpt_transaction.dept_id_from, desk_transaction.desk_id_from, incoming_letters_transaction.receive_dt, desk_transaction.desk_apprv_dt FROM incoming_letters_transaction LEFT OUTER JOIN tapal_to_dpt_transaction ON incoming_letters_transaction.ltr_id = tapal_to_dpt_transaction.ltr_id LEFT OUTER JOIN desk_transaction ON tapal_to_dpt_transaction.dpt_ltr_id=desk_transaction.dpt_ltr_id WHERE desk_transaction.desk_id_from=(select desk_id from login where login_id='$username') AND desk_transaction.desk_ltr_rec_dt BETWEEN '$date1' AND '$date2'");
							}
							$rs=mysql_query($qry) or die("".mysql_error());
							while($rws=mysql_fetch_array($rs))
							{	
								/***************************************************************
											fetching dates in dd-mm-yyyy format
								****************************************************************/
								$refdt= strtotime($rws['ref_dt']);
								$refdte = date('d-m-Y', $refdt);

								$deskrecdt= strtotime($rws['desk_ltr_rec_dt']);
								$deskrecdte = date('d-m-Y', $deskrecdt);
										 
								$deskappdt= strtotime($rws['desk_apprv_dt']);
								$deskappdte = date('d-m-Y', $deskappdt);
										 
								$dptrecdt= strtotime($rws['dpt_ltr_rec_dt']);
								$dptrecdte = date('d-m-Y', $dptrecdt);
										 
								$recdt=strtotime($rws['receive_dt']);
								$recdte=date('d-m-Y', $recdt);
								//$tapalrecdt=
								?>
								<tr class="gradeX">
								<?php 
								$vr=$rws['desk_ltr_id'];
								echo "<td class='center' >".$rws['ltr_inword_no']."<br>".$recdte."</td>
									<td class='center' >".$rws['dpt_inword_no']."<br>".$dptrecdte."</td>	
									<td class='center'>".$rws['desk_ltr_inword_no']."<br>".$deskrecdte."</td>
									<td class='center' >".$rws['ref_no']."<br>".$refdte."</td>
									<td class='center'>".$rws['subject']."</td>
									<td class='center'>".$rws['sender_name']."</td>";
									if($rws['action_taken']=='')
									{
										echo "<td class='center'><font color=red>"."कार्यवाही करणे  बाकी "."</font></td>";
									}
									else
									{
										echo "<td class='center'>".$rws['action_taken']."</td>";
									}
								echo "<td class='center'><a href=view_avak_javak.php?user=2&dskltrid=$vr>View</a>";
								echo" <br><a href='report_dpt_ltr_transfer_op.php?ltrid=$ltrid&user=bdo'>DispatchDetails</a><br>";
						if($rws['ltr_category']=='current')
							{
								echo "<a href='report_desk_refwise.php?refno=$rws[assign_no]'>".$rws['assign_no']."</a></td></tr>";
							}
						else
							{
								echo "</td></tr>";
							}			
							}?>
							</tbody>
						</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>
					  <br /><br />
					<?php include_once('footer.php'); ?>
					</div><!--maincontentinner-->
				</div><!--maincontent-->
			</div><!--rightpanel-->
		</div><!--mainwrapper-->
		</body>
		</html>
