<?php
session_start();
require_once('connection/db.php');
require_once('convert_marathi.php');
############################################# Display Letters To Perform Action ######################################

$username = $_SESSION['User_Name'];
$m1    = mysql_query("SELECT * FROM login WHERE login_id='$username'");
$rm1   = mysql_fetch_array($m1);
$logid = $rm1['id'];

	include_once('dashboard_bdo.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Tapal Admin System</title>
<script>
function func_show(var1)
{
	str = "r"+var1;
	var x = document.getElementById(str);
	if(x.checked)
	{
		var d = "div"+var1;
		document.getElementById(d).style.display = "inline";
	}
	else
	{
		var d = "div"+var1;
		document.getElementById(d).style.display="none";
	}
}

function valid_me()
{
	var x = document.getElementsByClassName('chk');
	var y = document.getElementsByClassName('txt');
	var c = x.length;
	var n = 0;
	for(i=0;i<c;i++)
	{
		if(x[i].checked)
		{
			if(y[i].value=="")
			{
				alert("कार्यवाही पूर्ण करा !!!");
				y[i].focus();
				return false;
			}
			n++;
		}
	}
	if(n==0)
	{
		return false;
	}
}
</script>
</head>
<body>
    <div class="rightpanel">
        <ul class="breadcrumbs">
            <li><a href="dashboard_desk.php"><i class="iconfa-home"></i></a> <span class="separator"></span></li>
            <li><a href="dashboard_desk.php">Tables</a> <span class="separator"></span></li>
             <li>Await Register</li>
        </ul>
        <div class="pageheader">
            <div class="pageicon"><span class="iconfa-table"></span></div>
            <div class="pagetitle">
               <h5>Forms</h5>
                <h1>Await Register</h1>
            </div>
        </div><!--pageheader-->
        <div class="maincontent">
            <div class="maincontentinner">
				<h4 class="widgettitle">Await Register</h4>             					 
                <form action="connection/db_await_register.php" method="post">          					 
                <table id="dyntable" class="table table-bordered">
                    <thead>
                        <tr>
                           <!--- <th class="head0 center">डेस्कचा <br>आवक क्र </th> -->
							<th class="head1 center">विभागाचे नाव <br>डेस्कचे नाव</th> 
                            <th class="head0 center">विभागीय आ. क्र.<br>विभागीय आ. दिं.</th>
							<th class="head1 center">कोणाकडून प्राप्त झाला<br>विषय </th>
                            <th class="head0 center">विभाग प्रकार</th>                 
							<th class="head1 center">विभागाचे नाव</th> 
  							<th class="head0 center">Await आ. दि.<br>एकूण दिवस</th>
							<!-- <th class="head1 center">कार्यवाही करा </th> -->
                        </tr>
					</thead>
					<tbody>	
					<?php	
						convert_marathi();
						$rs=mysql_query("SELECT * FROM wait_register WHERE kar_flag='N'") or die("".mysql_error());
						$c1= mysql_num_rows($rs);
						
							while($rws=mysql_fetch_array($rs))
							{	
								$login_id = $rws['login_id'];
								$tbnm = $rws['tbnm'];
								$iid  = $rws['iid'];

								$qq1 = mysql_query("SELECT * FROM login WHERE id='$login_id'");
								$rr1 = mysql_fetch_array($qq1);
								$dept_id1 = $rr1['dept_id'];
								$desk_id1 = $rr1['desk_id'];

								$dd2 = "";
								if($dept_id1<>0)
								{
									$qq2 = mysql_query("SELECT * FROM department_master WHERE dept_id='$dept_id1'");
									$rr2 = mysql_fetch_array($qq2);
									$dd2 = $rr2['dept_nm'];
								}
								$dd3 = "";
								if($desk_id1<>0)
								{
									$qq2 = mysql_query("SELECT * FROM desk_master WHERE desk_id='$desk_id1'");
									$rr2 = mysql_fetch_array($qq2);
									$dd3 = $rr2['desk_nm'];
								}
								else
								{
									$dd3 = "-";
								}

								if($tbnm == 'N')
								{
									// Tapal_to_department -------------------------------
									$q10 = mysql_query("SELECT * FROM tapal_to_dpt_transaction t,incoming_letters_transaction m WHERE dpt_ltr_id='$iid' AND t.ltr_id=m.ltr_id");
									$r10 = mysql_fetch_array($q10);
									$inwardno = $r10['dpt_inword_no'];
									$recivedt = date("d-m-Y",strtotime($r10['dpt_ltr_rec_dt']));
									$sendernm = $r10['sender_name'];
									$subject  = $r10['subject'];
								}
								else if($tbnm == 'Y')
								{
									// Desk_transaction -------------------------------
									$q10 = mysql_query("SELECT t.dpt_inword_no AS dpt_inword_no,t.dpt_ltr_rec_dt AS dpt_ltr_rec_dt,m.sender_name AS sender_name,m.subject AS subject FROM desk_transaction de, tapal_to_dpt_transaction t,incoming_letters_transaction m WHERE de.desk_ltr_id='$iid' AND de.dpt_ltr_id=t.dpt_ltr_id AND t.ltr_id=m.ltr_id");
									$r10 = mysql_fetch_array($q10);
									$inwardno = $r10['dpt_inword_no'];
									$recivedt = date("d-m-Y",strtotime($r10['dpt_ltr_rec_dt']));
									$sendernm = $r10['sender_name'];
									$subject  = $r10['subject'];
								}
								/***************************************************************
										fetching dates in dd-mm-yyyy format
									****************************************************************/
								
								?>
								<tr class="gradeX">	
								<?php 
									
									date_default_timezone_set('Asia/Kolkata');
									$cdt = date("Y-m-d");
									$d   = $rws['dt'];
									$days= round((strtotime($cdt) - strtotime($d))/86400) + 1;
									
									$rwait = $rws['rwait'];
									$ddnm  = $rws['ddnm'];
									if($rwait=="SD")
									{
										$r = "स्व विभागास";

										$q1 = mysql_query("SELECT * FROM department_master WHERE dept_id='$ddnm'");
										$r1 = mysql_fetch_array($q1);
										$nm = $r1['dept_nm'];
									}
									else if($rwait=="OD")
									{
										$r = "इतर विभागास";

										$q1 = mysql_query("SELECT * FROM other_department WHERE oid='$ddnm'");
										$r1 = mysql_fetch_array($q1);
										$nm = $r1['oname'];
									}


									echo "<td class='center'>".$dd2."<br>".$dd3."</td>
									<td class='center' >".$inwardno."<br>".$recivedt."</td>
									<td ><b>नाव : </b>".$sendernm."<br><b>विषय : </b>".$subject."</td>
									<td class='center' >".$r."</td>
									<td class='center' style='width:100px;'>".$nm."</td>
									<td class='center'>".date("d-m-Y",strtotime($d))."<br><font color='red'>".$days." दिवस</font></td>
									
									</tr>";

									?>
					<?php 	
						}

					
					 ?>
                    </tbody>
                </table>
                 <br />
                
            </form>
          
         <?php include_once('footer.php'); ?>
        </div><!--maincontentinner-->
    </div><!--maincontent-->  
</div><!--rightpanel-->
</div><!--mainwrapper-->
</body>
</html>

