Your IP : 216.73.216.40


Current Path : /var/www/html/venkat/ary/
Upload File :
Current File : /var/www/html/venkat/ary/table.php

<?php
include("view.php");
//$checkdate =  date("Y/m/d");
//echo $checkdate;
$checkdate =  addslashes($_POST['date']);
/*
if($inouttype == "Out") {
	$a = "0";
	$stmt = $conn->prepare("INSERT INTO armyleave(army_id, intype, outtype, type, outdate) VALUES (:armyid, :intype, :outtype, :type, :outdate)");
	$stmt->bindParam(':armyid', addslashes($_POST['armyid']));
	$stmt->bindParam(':outtype', addslashes($_POST['inout']));
	$stmt->bindParam(':type', addslashes($_POST['type']));
	$stmt->bindParam(':outdate', addslashes($_POST['date']));
	$stmt->bindParam(':intype', $a);
}
else {*/
	$a = 0;
	$aa = "0";
	$i = 0;
	$j = 0;
	$p = 0;
	$count = "<td>Auth Str </td>";
	$pcount = "<td>Posted Str </td>";
	$tab = "<td> </td>";
	$sql = $conn->prepare("SELECT type FROM armyleavetype");
	$sql->execute();
	$row = $sql->rowCount();
        while ($row = $sql->fetch()) {
                $type[$i] = $row['type'];
		$i = $i + 1;
	}
	$auth = 0;
	$sql = $conn->prepare("SELECT designation, count(designation), sum(posted) FROM armymember group by designation");
	$sql->execute();
	$row = $sql->rowCount();
        while ($row = $sql->fetch()) {
                $desi = $row['designation'];
		$tab = $tab."<td>".$desi."</td>";
                $countdesi = $row['count(designation)'];
		$count = $count."<td>".$countdesi."</td>";
		$auth = $auth + 1;
		$countauth[$auth] = $countdesi;
                $countpost = $row['sum(posted)'];
		$pcount = $pcount."<td>".$countpost."</td>";
		$a = $a + $countdesi;
		$b = $b + $countpost; 
		$p = $p + 1;
		for($j = 0; $j<$i; $j++) {
			$sql1 = $conn->prepare("SELECT count(type) FROM armyleave where designation = :designation and type = :type and outdate < :outdate and intype = :intype");
			$sql1->bindValue(':type',$type[$j]);
			$sql1->bindValue(':designation',$desi);
			//echo $type[$j];
			$sql1->bindValue(':outdate',$checkdate);
			//echo $checkdate;
			$sql1->bindValue(':intype',$aa);
			//echo $aa;
			$sql1->execute();
			$row = $sql1->rowCount();
        		while ($row = $sql1->fetch()) {
                		$leave[$p][$j] = $row['count(type)'];
			}
			//echo $leave[$p][$j];
		}
        }

	$tab = $tab."<td>Total</td>";
	$count = $count."<td>".$a."</td>";
	$pcount = $pcount."<td>".$b."</td>";
	for($j = 0; $j< $i; $j++) {
		$leavetype[$j] = "<td>".$type[$j]."</td>";
		$leavetotal[$j] = 0;
		for($k = 1; $k <= $p; $k++) {
			$leavetype[$j] = $leavetype[$j]."<td>".$leave[$k][$j]."</td>";
			$leavetotal[$j] = $leavetotal[$j] + $leave[$k][$j]; 
			$leavebasetotal[$k] = $leavebasetotal[$k] + $leave[$k][$j];
		}	
		$leavetype[$j] = $leavetype[$j]."<td>".$leavetotal[$j]."</td>";
	}
	$basetotal = "<td> T/Out </td>";
	$basebalancetotal = "<td> P/Str </td>";
	$touttotal = 0;
	$pstrtotal = 0;
	for($k = 1; $k <= $p; $k++) {
		$basetotal = $basetotal."<td>".$leavebasetotal[$k]."</td>";
		$touttotal = $touttotal + $leavebasetotal[$k];
		$balancetotal = $countauth[$k] - $leavebasetotal[$k];
		$basebalancetotal = $basebalancetotal."<td>".$balancetotal."</td>";
		$pstrtotal = $pstrtotal + $balancetotal;

	}
		$basetotal = $basetotal."<td>".$touttotal."</td>";
		$basebalancetotal = $basebalancetotal."<td>".$pstrtotal."</td>";
	/*$armyid =  addslashes($_POST['armyid']);
	if($stmt->execute()) {
        	echo "<b> <center> <font color = 'blue'> <br>Sucessfully Submitted. Check your submission </font>  </center> </b> <br> <br>";
	}
	$sql = $conn->prepare("SELECT * FROM armyleave where army_id = :armyid  order by army_id = :armyid DESC LIMIT 1");
	$sql->bindValue(':armyid',$armyid);
	$sql->execute();
	$row = $sql->rowCount();
        while ($row = $sql->fetch()) {
                $armyid = $row['army_id'];
                $out = $row['outtype'];
                $type = $row['type'];
                $outdate = $row['outdate'];
                $indate = $row['indate'];
                $in = $row['intype'];
        }*/
?>


	
	<div align = "center">
	Sheet as on <b><?php echo $checkdate; ?> </b><br>
	         <table border = "1"> 
	                <tr> <?php echo $tab ?>  </tr>
	                <tr> <?php echo $count ?>  </tr>
	                <tr> <?php echo $pcount ?>  </tr>
			<?php 
				for($j = 0; $j < $i; $j++) {
					echo "<tr>".$leavetype[$j]."</tr>";
				} 

			?>
			<tr> <?php echo $basetotal ?></tr>
			<tr> <?php echo $basebalancetotal ?></tr>
	        </table>
	</div>
<?php
?>

<div align = "center">
  <table style="float: left" border = "1">
    <tr> <td colspan = 2><center> In Detail</center> </td> </tr>
    <tr><td>Name </td> <td> Designation </td> </tr>
      <?php 
	$sql1 = $conn->prepare("SELECT name, designation FROM armyleave where indate = :indate");
			$sql1->bindValue(':indate',$checkdate);
			$sql1->execute();
			$row = $sql1->rowCount();
        		while ($row = $sql1->fetch()) {
                		$name = $row['name'];
                		$designation = $row['designation'];
				echo "<tr> <td>".$name."</td><td>".$designation."</td></tr>";
			}
     ?>
    </tr>
  </table>
  <table style="float: left" border = "1">
    <tr> <td colspan = 2><center>Out Detail</center> </td> </tr>
    <tr><td>Name </td> <td> Designation </td> </tr>
      <?php 
	$sql1 = $conn->prepare("SELECT name, designation FROM armyleave where outdate = :outdate");
			$sql1->bindValue(':outdate',$checkdate);
			$sql1->execute();
			$row = $sql1->rowCount();
        		while ($row = $sql1->fetch()) {
                		$name = $row['name'];
                		$designation = $row['designation'];
				echo "<tr> <td>".$name."</td><td>".$designation."</td></tr>";
			}
     ?>
    </tr>
  </table>
</div>