<?php
	include "admin_top_menu.php";
	include "admin_side_menu.php";
	
	if($temp_id = isset($_GET['temp_id']) ? $_GET['temp_id'] : '')
	{
	   $row=mysqli_query($conn,"SELECT * FROM `manufacturer` WHERE mid='$temp_id'");
		$data=mysqli_fetch_array($row);
	}
	else{
		$data['mid']="";
		$data['mill_name']="";
		$data['mill_address']="";
		$data['contact_person']="";
		$data['contact_no']="";
		$data['email_id']="";
	}
?>
  
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Manufacturer
        <small>Manufacturer List</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Manufacturer</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
	<form name="frmfabric" action="code.php" method="post" enctype="multipart/form-data">
      <!--<div class="panel-body" align="right">
        <a href="" data-toggle="tooltip" class="btn btn-primary btn-md"><i class="fa fa-book"></i> Create Category</a>
      </div>-->
	  <div class="box box-info">
        <div class="box-header with-border">
          <h3 class="box-title">Manufacturer List</h3>
		  
          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-remove"></i></button>
          </div>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
          <div class="row">
            <div class="col-md-4">
              <div class="form-group">
                <label>Mill Name</label>
				        <input type="hidden" name="txt_mid" value="<?php echo $data['mid'];?>">
                <input type="text" class="form-control" name="txt_mname" placeholder="Mill Name" value="<?php echo $data['mill_name'];?>" required="" >
              </div>
            </div>
			
			<div class="col-md-8">
              <div class="form-group">
                <label>Mill Address</label>
				        <input type="text" class="form-control" name="txt_maddress" placeholder="Mill Address" value="<?php echo $data['mill_address'];?>" required="" >
              </div>
            </div>
			
			<div class="col-md-4">
              <div class="form-group">
                <label>Contact Person</label>
				        <input type="text" class="form-control" name="txt_cperson" placeholder="Contact Person" value="<?php echo $data['contact_person'];?>" required="" >
              </div>
            </div>
			
			<div class="col-md-4">
              <div class="form-group">
                <label>Contact No</label>
				        <input type="text" class="form-control" name="txt_cnumber" minlength="10" maxlength="13" placeholder="Contact No" value="<?php echo $data['contact_no'];?>" required="" >
              </div>
            </div>
			
			<div class="col-md-4">
              <div class="form-group">
                <label>Email Id</label>
				        <input type="email" class="form-control" name="txt_email" placeholder="Email Id" value="<?php echo $data['email_id'];?>" required="" >
              </div>
            </div>
			
		  </div>
		</div>
		
		<div class="box-footer">
		  <?php if($data['mid']==''){ ?>
          <button type="submit" name="btn_msubmit" class="btn btn-info pull-right">Submit</button>
		  <?php } else {?>
			   <button type="submit" name="btn_mupdate" class="btn btn-info pull-right">Update</button>
		  <?php } ?>
        </div>
	</div>
		<?php   
			if(isset($_GET['status'])&&$_GET['status']==1)
			echo "<font color=green>Data Successfully Insert..</font>";
				
			if(isset($_GET['status'])&&$_GET['status']==2)
			echo "<font color=green>Data Successfully Update..</font>";
				
			if(isset($_GET['status'])&&$_GET['status']==3)
			echo "<font color=red>Wrong click...</font>";   
		?>
	</form>
	

        <div class="box">
            <div class="box-header">
              <h3 class="box-title">Manufacturer List</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>Id</th> 
        				  <th>Mill Name</th> 
        				  <th>Address</th> 
        				  <th>Contact Person</th> 
        				  <th>Contact No</th> 
        				  <th>Email Id</th> 
        				  <th>Edit</th> 
        				  <th>Delete</th> 
                </tr>
                </thead>
                <tbody>
                  <?php 
					$qry=mysqli_query($conn,"SELECT * FROM `manufacturer`")or die(mysqli_error($conn));
					$count=1;
					while($row=mysqli_fetch_array($qry))
					{?>
            <tr>
						<td><?php echo $count++;?></td>
						<td><?php echo $row['mill_name'];?></td>
						<td><?php echo $row['mill_address'];?></td>
            <td><?php echo $row['contact_person'];?></td>
            <td><?php echo $row['contact_no'];?></td>
            <td><?php echo $row['email_id'];?></td>
						<td><?php echo "<a href='manufacturer.php?temp_id=".$row['mid']."'><i class='fa fa-edit fa-fw'></i></a>"; ?> </td>
						<td><?php echo "<a href='delete_code.php?dm_id=".$row['mid']."' onClick=\"javascript:return confirm('are you sure you want to delete this?');\"><i class='fa fa-times fa-fw'></i></a>"; ?></td>
					</tr>              
             <?php  } ?>
                </tbody>
              </table>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->


<?php
	include "admin_footer.php";
?>
