<?php
	include "admin_top_menu.php";
	include "admin_side_menu.php";
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="dist/fstdropdown.css">

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Chech In/Check Out
        <small>Details</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Sample</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
	<form name="frmfabric" action="sample_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">Customer Details</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>Company Name</label>
				<input type="hidden" name="txt_cusid" id="txt_cusid">
                <input type="text" class="form-control" name="txt_comname" id="txt_comname" placeholder="Company Name" required="" onkeyup="cust();">
              </div>
            </div>
			
			      <div class="col-md-8">
              <div class="form-group">
                <label>Company Address</label>
				    <input type="text" class="form-control" name="txt_comaddress" id="txt_comaddress" placeholder="Company Address" required="" >
              </div>
            </div>
			
			      <div class="col-md-4">
              <div class="form-group">
                <label>Customer Name</label>
				    <input type="text" class="form-control" name="txt_cusname" id="txt_cusname" placeholder="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_cuscontact" id="txt_cuscontact" minlength="10" maxlength="13" placeholder="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_cusemail" id="txt_cusemail" placeholder="Email Id" required="" >
              </div>
            </div>
			
		  </div>
		</div>
		
	</div>

  <div class="box box-info">
        <div class="box-header with-border">
          <h3 class="box-title">Log Details</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>Select Swatch</label>
                <select class="fstdropdown-select" name="txt_sswatch" required="">
                <option value="">Select Product</option>
                <?php 
                  $query=mysqli_query($conn,"SELECT * FROM `swatch`")or die(mysqli_error($conn));
                  while($row=mysqli_fetch_array($query))
                  {
                ?>
                  <option value="<?php echo $row['sid'];?>"><?php echo $row['snumber'];?></option>
                <?php  } ?>
              </select>
              </div>
            </div>
      
            <div class="col-md-4">
              <div class="form-group">
                <label>Date</label>
                <input type="date" class="form-control" name="txt_sdate" value="<?php echo date('Y-m-d'); ?>" required="" >
              </div>
            </div>

            <div class="col-md-4">
              <div class="form-group">
                <label>Status</label>
                <select class="form-control" name="txt_sstatus">
                  <option value="">Select Status</option>
                  <option value="Received">Chech In</option>
                  <option value="Send">Check Out</option>
                </select>
              </div>
            </div>
      
            <div class="col-md-8">
              <div class="form-group">
                <label>Notes</label>
                <textarea class="form-control" name="txt_snotes" placeholder="Description"></textarea>
              </div>
            </div>
      
      
      
      </div>
    </div>
    
      <div class="box-footer">
        <button type="submit" name="btn_samsubmit" class="btn btn-info pull-right">Submit</button>
      </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>
	

    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
<script src="dist/fstdropdown.js"></script>

<?php
	include "admin_footer.php";
?>
<!-- Script for autocomplete -->
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

<script type="text/javascript">
// This function is used for customer suggesions and fetch values
 function cust(){

    var txt_comname = document.getElementById("txt_comname").value;
    $("#txt_comname").autocomplete({
        source: 'cust_autocomplete.php', 
        select: function(a,b)
          {
              $(this).val(b.item.value); //grabed the selected value
              getCustOtherInfo(b.item.value);//passed that selected value
          }
    });
}

function getCustOtherInfo(com_name){
        $.ajax({
             url:'get_customer.php',
             type:'POST',
             data:{
                com_name:com_name
             },

             success: function(data)
             {
               var obj = $.parseJSON(data);
			    $('#txt_cusid').val(obj.cus_id);
                $('#txt_comname').val(obj.com_name);
                $('#txt_comaddress').val(obj.com_addr);
                $('#txt_cusname').val(obj.cus_name);
                $('#txt_cuscontact').val(obj.cus_contact);
                $('#txt_cusemail').val(obj.cus_email);
                if(data==1)
                {
                    alert("update");
                }
             } 
        });
    }


</script>

