| Current Path : /var/www/html/venkat/army1/ |
| Current File : /var/www/html/venkat/army1/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;
$aca = 0;
$ccount = "<td>Auth Str </td>";
$pcount = "<td>Posted Str </td>";
$mcount = "<td>Misc. </td>";
$tab = "<td> </td>";
$sql = $conn->prepare("SELECT type FROM armyleavetype order by leaveorder");
$sql->execute();
$row = $sql->rowCount();
while ($row = $sql->fetch()) {
$type[$i] = $row['type'];
$i = $i + 1;
}
$sql = $conn->prepare("SELECT auth FROM armypost order by desiorder");
$sql->execute();
$row = $sql->rowCount();
while ($row = $sql->fetch()) {
$ccount = $ccount."<td>".$row['auth']."</td>";
$aca = $aca + $row['auth'];
}
$ccount = $ccount."<td>".$aca."</td>";
$auth = 0;
//$sql = $conn->prepare("SELECT designation, count(designation), count(posted) FROM armymember group by designation order by (select desiorder from armypost where armymember.designation = armypost.post)");
$sql = $conn->prepare("SELECT post, posted FROM armypost order by desiorder");
$sql->execute();
$row = $sql->rowCount();
while ($row = $sql->fetch()) {
$desi = $row['post'];
$tab = $tab."<td>".$desi."</td>";
$countdesi = $row['count(designation)'];
$count = $count."<td>".$countdesi."</td>";
$auth = $auth + 1;
$countpost = $row['posted'];
//$countpost = $row['count(designation)'];
$pcount = $pcount."<td>".$countpost."</td>";
$mcount = $mcount."<td></td>";
$countauth[$auth] = $countpost;
$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>";
$mcount = $mcount."<td></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">
<H2> PARADE STATE AS ON <b><?php echo $checkdate; ?> </b> </H2><br>
<table border = "1">
<tr> <?php echo $tab ?> </tr>
<tr> <?php echo $ccount ?> </tr>
<tr> <?php echo $pcount ?> </tr>
<?php
for($j = 0; $j < $i; $j++) {
echo "<tr>".$leavetype[$j]."</tr>";
}
?>
<tr> <?php echo $mcount ?></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>