<?php 
include ("kfunctions.php");
adminall("overadmin","secadmin","priadmin");
?>

<html>
<head>
<?php kheader(); ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.js"></script>
<script src="js/input.js"></script>
</head>
<body>

    <div id="wrapper">

        <!-- Navigation -->
        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
            <!-- Brand and toggle get grouped for better mobile display -->
            <?php ktopbar(); ?>
            <!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
            <?php kleftbar(); ?>
            <!-- /.navbar-collapse -->
        </nav>

        <div id="page-wrapper">

            <div class="container-fluid" style='margin-top:10px;'>
>

      

                <!-- /.row -->

                            <?php

if(isset($_POST["adminsubmit"])){
  include ("connect.php");
$yy=date("Y"); $fyy=substr($yy,2,2); $mm=date("m"); 
$dd=date("d"); $hi=date("h"); $mi=date("i");
$sa=date("sa"); $sa=date("s");

$fsid=$_POST["fsid"];
$lastupdate=date("Y-m-d");

$result_scrap=$dbh->query("select * from scrap where type='requirement'");
$row_scrap=$result_scrap->fetchObject(); $count_scrap=$result_scrap->rowCount();

if($count_scrap>0){ $f=1; do{
if(!empty(str_replace(',','',$_POST[$row_scrap->item."_amount"]))){
$fitemid=$row_scrap->autoid;
$amount=str_replace(',','',$_POST[$row_scrap->item."_amount"]);
$update_fs=$dbh->query("update fsitems set amount='$amount', lastupdate='$lastupdate', ouruser='$rolenumber' where fsid='$fsid' and fsitemid='$fitemid'");

}
}while($row_scrap=$result_scrap->fetchObject());}

if($insert_scrap){echo "<div class='alert alert-success'>Success: Fee structure has been added.</div>";}
}

$fsid=$_GET["fsid"];
                            $result_scrap=$dbh->query("select * from scrap where type='fee_structure' and item='$fsid'");
                            $row_scrap=$result_scrap->fetchObject(); $count_scrap=$result_scrap->rowCount();

     echo "<form method='post'>               
<div class='col-lg-12'>
  <div class='panel panel-yellow'>
                <div class='panel-heading'>
                                <h3 class='panel-title'>Edit Fees Structure : ".$row_scrap->item2."</h3>
                            </div>
                            <div class='panel-body'> ";                             
                           

                  echo "<input type='hidden' name='fsid' value='".$fsid."'>"; 

$result_scrap=$dbh->query("select * from scrap where type='requirement'");
$row_scrap=$result_scrap->fetchObject(); $count_scrap=$result_scrap->rowCount();

if($count_scrap>0){ do{
  $result_fsitem=$dbh->query("select * from fsitems where fsitemid='$row_scrap->autoid' and fsid='$fsid'");
$row_fsitem=$result_fsitem->fetchObject(); $count_fsitem=$result_fsitem->rowCount();

if($count_fsitem>0){$amount=$row_fsitem->amount;
     echo " <div class='col-lg-3'>
".$row_scrap->item2." <input type='text' name='".$row_scrap->item."_amount' class='form-control' id='uni' data-type='number' value='".$amount."' ><br>
                  </div>"; }
    }while($row_scrap=$result_scrap->fetchObject());}
                

                 
echo "

<div class='col-lg-3'> 
<input type='submit' name='adminsubmit' class='btn btn-sm btn-success' value='Update Form'>
</form>
</div>


                    </div>
                </div>
              </div>"; 
              ?>


               

                </div>                
            </div>

<!----row---->

                     


                             
                                </div>
                                
                            </div>
                        </div>
                    </div>
                  </div>
                <!-- /.row -->
</form>




                  </div>
                <!-- /.row -->

            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->
<?php useractivity("on page","2"); ?>
    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

    <!-- Morris Charts JavaScript -->

</body>

</html>