<?php include "layouts/menu.php"; ?> <div class="right_col" role="main">
            <div class="row">
                 <!-- page header -->
                <div class="col-lg-12">
                    <h1 class="page-header">Dealer Details</h1>
                </div>
                <!--end page header -->
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <!-- Form Elements -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Details
                        </div>
                        <div class="panel-body">
                            <div class="row">
   <div class="alert alert-info">Register Dealer Details</div>
   <form name="form1" class="form-horizontal" method="post" action="mdealer.php" enctype="multipart/form-data">
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Dealer Name</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="name" value="" placeholder="" required>
    </div>
  </div>
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Opening Balance</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="obal" value="" placeholder="" required>
    </div>
  </div>
    <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Address</label>
    <div class="col-sm-4">
      <textarea class="form-control" rows="3" name="details" value="" placeholder=""></textarea>
    </div>
  </div>  
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Area</label>
    <div class="col-sm-4">
      <select type="text" class="form-control" id="inputPassword3" name="area" value="" placeholder="" >
	  <option>Select</option>
	<?php 
$qry=mysqli_query($conn, "select * from marea");
	while($row2=mysqli_fetch_array($qry))
						{ ?> <option><?php echo $row2['name'];?></option>
						<?php } ?> </select>
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Phone No</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="pno" value="" placeholder="" >
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">E-mail Id</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" id="inputPassword3" name="email" value="" placeholder="" >
    </div>
  </div>
   <input type="hidden" class="form-control" id="inputPassword3" name="st" value="" placeholder="" >

      <input type="hidden" class="form-control" id="inputPassword3" name="cst" value="" placeholder="" >
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default" name="s1">Save This</button>
    </div>
  </div>
      <div class="alert alert-success">
	 <?php
							if(isset($_POST['s1']))
							{
								extract($_POST);
								$insert=mysqli_query($conn, "insert into mdealer(mfin,scode,name,area,pno,email,st,cst,details,obal)
											 values('$mfin','$scode','$name','$area','$pno','$email','$st','$cst','$details','$obal')");
								
								if($insert)
								{
									$insert2=mysqli_query($conn, "insert into ledger(mfin,scode,ledger,openbal,under)
											 values('$mfin','$scode','$name','$obal','Dealer')");
									echo "Registered Successfully";
									
								}
								else
								{
									echo "Failure";
								}
							}
?>
	  </div>
</form>
</div>
     <?php
					
						$qry=mysqli_query($conn, "select * from mdealer where mfin='$mfin'");
						$n=mysqli_num_rows($qry);
						if($n==0)
						{
							echo "Nothing To Display";
						}
						else
						
					{ 
						?>
                <!-- Main content -->
                <section class="content">
                    <div class="row">
                        <div class="col-xs-12"> 
                            <div class="box">
                               <!-- /.box-header -->
                                <div class="box-body table-responsive">
                                    <table id="table2" class="table table-bordered table-striped">
                                        <thead>
                                            <tr>
												<th>Name</th>
												<th>Opening Balance</th>
												<th>Address</th>
												<th>Area</th>
												<th>Phone</th>
												<th>E-mail</th>
												<th>Delete</th>
												
                                            </tr>
                                        </thead>
										<?php 
					while($row2=mysqli_fetch_array($qry))
						{
					?>
                                        <tbody>
                                           <tr>
                                               <td><?php echo $row2['name'];?></td>
						<td><?php echo $row2['obal'];?></td>
						<td><?php echo $row2['details']; ?></td>
						<td><?php echo $row2['area'];?></td>
						<td><?php echo $row2['pno'];?></td>
						<td><?php echo $row2['email'];?></td>
					<td><a href="dealerdel.php?id=<?php echo $row2['id'];?>" onclick="return confirm('Are you sure WANT TO DELETE?');">Delete</a></td>
                                            </tr>
                                          </tbody>
                                        <?php
						}
					}
				
					?>
					                    
                                    </table>		
                                </div><!-- /.box-body -->
                            </div><!-- /.box -->
 
</div>
</div></div>
</div></div></div> <?php include "layouts/footer.php"; ?></body></html>