<?php
session_start();
if($_SESSION["username"]=="")
{
 	echo "You are not Logged in Please <a href='index.html'>Sign in </a> First ";
}
else
{

include 'dbc.php';
$username=$_SESSION["username"];
$current_file_name = basename($_SERVER['PHP_SELF']);
$sql = "SELECT * FROM adduser where feedisc2 = '$current_file_name' and uname = '$username'";
$result=$conn->query($sql);
$row = $result->fetch_assoc();
$status=$row['feedisc3'] ;

if ($status =="")
{
echo "You are not Authorized This Page <a href='maindashboard.php'>Back </a> ";
}
else
{
include 'dbc.php';
$id=$_REQUEST["id"];
$userid=$_SESSION["userid"];
$today=date("Y-m-d");
$month = date("m",strtotime($today));
		$year = date("Y",strtotime($today));
		 $month_name = date("F", mktime(0, 0, 0, $month, 10));
		
		
		 $my=$month_name . " " . $year;
		 
		$sql5 = "SELECT MAX( tr_no ) AS max FROM expense_voucher where user_id='$userid'";
$result5 = $conn->query($sql5);
$row5 = $result5 ->fetch_assoc();
$largestNumber = $row5['max'];
$largestNumber = $largestNumber +1;
$sql3="SELECT * FROM chartofaccounts where acc_type='Cash' and user_id='$userid'";
$result1 = $conn->query($sql3);
?>
<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->

<head>
   <?php include("includes/header.php") ?>
</head>

<body>


    <!-- Left Panel -->

    <?php include("includes/menu.php") ?><!-- /#left-panel -->

    <!-- Left Panel -->

    <!-- Right Panel -->

    <div id="right-panel" class="right-panel">

        <!-- Header-->
        <header id="header" class="header">

             <?php include("includes/headermenu.php") ?>

        </header><!-- /header -->
        <!-- Header-->

        <div class="breadcrumbs">
            <div class="col-sm-6">
                <div class="page-header float-left">
                    <div class="page-title">
                        <h1><? echo "" . $_SESSION["userid"]; ?></h1>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="page-header float-right">
                    <div class="page-title">
                        <ol class="breadcrumb text-right">
                            <li class="active"><? echo "" . $_SESSION["username"]; ?></li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>

        <div class="content mt-3">

           


          <div class="col-lg-12">
                        <div class="card">
                            <div class="card-header"><strong>Cash Receipt Voucher</strong><small> Form</small></div>
                            <div class="card-body card-block">
							
							 <?php
include 'dbc.php';

$subtypename=$_REQUEST["subtypename"];
$userid=$_SESSION["userid"];
$today=date("Y-m-d");


$sqlrec = "SELECT * FROM chartofaccounts where acc_symb='$subtypename' and user_id='$userid' ORDER BY acc_name";
$resultrec=$conn->query($sqlrec);
  
?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead>
									<?php
echo "<tr>";

echo "<th bgcolor=yellow> No </th>";
echo "<th bgcolor=yellow> Main Type </th>";
echo "<th bgcolor=yellow> Acc SubType </th>";
echo "<th bgcolor=yellow> Account Name </th>";
echo "<th bgcolor=yellow> Cr Amount </th>";


echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
echo "<form name='form_update' method='post' action='Cash_Receipt_Voucher_Save.php'>\n";
while($students = $resultrec->fetch_assoc()) {

	echo '<tr>';
	
	echo "<td>{$students['id']}<input type='hidden' name='id[$i]' value='{$students['id']}' /></td>";
	echo "<td>{$students['acc_type']}<input type='hidden' name='acc_type[$i]' value='{$students['acc_type']}' /></td>";

	echo "<td>{$students['acc_symb']}<input type='hidden' name='acc_symb[$i]' value='{$students['acc_symb']}' /></td>";
	
	echo "<td>{$students['acc_name']}<input type='hidden' name='acc_name[$i]' value='{$students['acc_name']}' /></td>";

	echo "<td><input type='text' size='20' name='sale_qty[$i]' /></td>";
	
	
	 
	echo '</tr>';
	++$i;
}
?>
												
												<div class="row form-group">
                                                                    <div class="col col-md-3"><label for="select" class=" form-control-label">Account Dr</label></div>
                                                                    <div class="col-12 col-md-4">
                                                                        <select name="acc_name_dr" id="acc_name_dr" class="form-control">
                                                                            <?php
  while($user_data3=$result1->fetch_assoc())
  {
  ?>
              <option value="<? echo $user_data3['acc_name']; ?>"><? echo $user_data3["acc_name"]; ?></option>
              <?php
  }
  ?>
                                                                        </select>
                                                                    </div>
                                                                </div>				
												<div class="col-3">
                                <div class="form-group"><label for="feedisc1" class=" form-control-label">Date</label><input type="text" id="expdate" name="expdate" placeholder="Date" class="form-control" value="<? echo $today ?>"></div>
								</div>
												
									
	
								
								<div class="col-3">
                                <div class="form-group"><label for="feedisc1" class=" form-control-label"> Voucher No</label><input type="text" id="vno" name="vno" placeholder=" Voucher No" class="form-control" value="<? echo $largestNumber ?>" readonly></div>
								</div>
								
								<div class="col-6">
                                <div class="form-group"><label for="feedisc1" class=" form-control-label"> Discription</label><input type="text" id="disc" name="disc" placeholder="Discription" class="form-control"></div>
								</div>
								
		
                                                    </div>
													<div class="card-footer">
                                                       <?php
echo '<tr>';
echo "<td><input type='submit' value='Submit Voucher' /></td>";

echo '</tr>';
echo "</form>";
echo '</table>';
?>
                                                       
                                                    </div>
													
													
                                                </div>
                                            </div>

            


        </div> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

   <?php include("includes/footermenu.php") ?>

</body>

</html>
<?php
}
}
?>