<?php include 'header1.php';
include'config.php';
?>
<div class="content-wrapper">
  <section class="content-header">
    <h1>
      Pump Manager
      
    </h1>
    <ol class="breadcrumb">
      <li>
        <a href="#">
          <i class="fa fa-dashboard">
          </i> Home
        </a>
      </li>
      <li>
        <a href="#">Pump Manager
        </a>
      </li>
      <li class="active">24 HR Client List
      </li>
    </ol>
  </section>
  <section class="content"> 
    <div class="row">
      <div class="col-xs-12">
        <div class="box">
          <div class="box-header">
            <h3 class="box-title"> 24 HR Client list
            </h3>
          </div>
          <div class="box-body">

            <div class="container-fluid">  

              <div class="table-responsive">  
                <div align="right">  
                  <button type="button" name="add" id="add" data-toggle="modal" data-target="#add_data_Modal" class="btn btn-warning btn-md">Add
                  </button>  
                </div>  
                <br />  
                <div id="alert_message">
                </div>
                <div id="employee_table">  
                </div>  
                <br>
              </div>  
            </div>  
          </div>
        </div>
      </div>
    </div>
  </section>
</div>
<footer class="main-footer">
  <div class="pull-right hidden-xs">
    <b>Version
    </b> 2.4.18
  </div>
  <strong>Copyright &copy; 2019 
    <a href="https://adminlte.io">Pump Manager
    </a>.
  </strong> All rights
  reserved.
  <span> Powered by 
    <a href="http://qisystems.in/"> QI Systems
    </a>
  </span>
</footer>
<script src="bower_components/jquery/dist/jquery.min.js">
</script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js">
</script>
<script src="bower_components/datatables.net/js/jquery.dataTables.min.js">
</script>
<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js">
</script>
<script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js">
</script>
<script src="bower_components/fastclick/lib/fastclick.js">
</script>
<script src="dist/js/adminlte.min.js">
</script>
<script src="dist/js/demo.js">
</script>
<script>
  $(function () {
    $('#example1').DataTable()
    $('#example2').DataTable({
      'paging'      : true,
      'lengthChange': false,
      'searching'   : false,
      'ordering'    : true,
      'info'        : true,
      'autoWidth'   : false
    }
    )
  }
  )
</script>
<script>  
  $(document).ready(function(){
    fetch_data();
    $('#add').click(function(){
      $('#insert').val("Insert");
      $('#insert_form')[0].reset();
      $('#employee_id').val('');
      $('#db').hide();
    }
    );
    function fetch_data()  
    {  
     $.ajax({  
      url:"feature_insert.php",  
      method:"POST", 
      data:{request_type:14},  
      success:function(data){  
       $('#employee_table').html(data);  
     }  
   });  
   } 
   $(document).on('click', '.edit_data', function(){
    var employee_id = $(this).attr("id");
    $.ajax({
      url:"feature_insert.php",  
      method:"POST",  
      data:{employee_id:employee_id,request_type:13},  
      dataType:"json",  
      success:function(data){
        $('#employee_id').val(data.Usr_id);
        $('#cuname').val(data.Usr_Name);
        $('#dbname').val(data.Usr_db);
        $('#dbnamevali').val(data.Usr_db);
        $('#c_name').val(data.cName);
        $('#cpass').val(data.Password);
        $('#ccontact').val(data.Usr_Phone);
        $('#cpass2').val(data.password2);
        $('#reg_date').val(data.date);
        $('#c_address').val(data.Usr_Address);
        $('#exp_date').val(data.expDate);
        $('#status').val(data.status);
        $('#brand').val(data.brand);
        $('#shift1').val(data.shift1);
        $('#shift2').val(data.shift2);
        $('#gst').val(data.Usr_Gst);
        $('#vat').val(data.Usr_Vat);
        $('#Usr_email').val(data.Usr_email);
        $('#insert').val("Update");
        $('#add_data_Modal').modal('show');
        $('#db').show();
      }
    }
    );
  }
  );
   $('#insert_form').on("submit", function(event){
    event.preventDefault();
    if($('#name').val() == "")  
    {
      alert("Name is required");
    }
    else if($('#address').val() == '')  
    {
      alert("Address is required");
    }
    else if($('#designation').val() == '')  
    {
      alert("Designation is required");
    }
    else if($('#age').val() == '')  
    {
      alert("Age is required");
    }
    // else if($('#dbnamevali').val() == '')  
    // {
    //   alert("database name is invalid");
    // }
    else  
    {
      $.ajax({
        url:"feature_insert.php",  
        method:"POST",  
        data:$('#insert_form').serialize(),  
        beforeSend:function(){
          $('#insert').val("Inserting");
        }
        ,  
        success:function(data){
            // alert(data);
            console.log(data);
            $('#insert_form')[0].reset();
            $('#add_data_Modal').modal('hide');
            //$('#employee_table').html(data);
            fetch_data();
            $('#notavailable').hide();
            $('#available').hide();
          }
        }
        );
    }
  }
  );
   $(document).on('click', '.view_data', function(){
    var employee_id = $(this).attr("id");
    if(employee_id != '')  
    {
      $.ajax({
        url:"feature_insert.php",
        method:"POST",
        data:{employee_id:employee_id,request_type:15},
        success:function(data){
          $('#employee_detail').html(data);
          $('#dataModal').modal('show');
          fetch_data();
        }
      }
      );
    }
  }
  );
   $(document).on('click', '.login', function(){
    var Usr = $(this).attr("name");
    $.ajax({
      url:"feature_insert.php",
      method:"POST",
      data:{Usr:Usr,request_type:36},
      success:function(data){
        $('#'+Usr).attr("href","http://hwaypumpmanager.imconnect.in/db_config/HOlogin.php?a="+Usr+"&b="+data);
      }
    });
  });
   $('#dbname').keyup(function(event) { 
    var a=$(this).val(); 
    $.ajax({
      url:"feature_insert.php",
      method:"POST",
      data:{id:a,request_type:7},
      success:function(data){
        console.log(data);  
        if(data=='lessthan3'){
         $('#notavailable').show();
         $('#notavailable').html('Enter Minimum 4 Character');
         $('#available').hide();
         $('#dbnamevali').val("");
       }else if(data=='no'){
        $('#notavailable').show();
        $('#notavailable').html('This Username Already Exist');
        $('#available').hide();
        $('#dbnamevali').val("");
      }else{
        $('#available').show();
        $('#notavailable').hide();
        $('#dbnamevali').val("1");
      }

    }
  });
  }); 
 }
 );
</script>
<script>
</script>
</body>
</html>
<div id="dataModal" class="modal fade">  
  <div class="modal-dialog">  
    <div class="modal-content">  
      <div class="modal-header">  
        <button type="button" class="close" data-dismiss="modal">&times;
        </button>  
        <h4 class="modal-title">Client Details
        </h4>  
      </div>  
      <div class="modal-body" id="employee_detail">  
      </div>  
    </div>  
  </div>  
</div>  
<div id="add_data_Modal" class="modal fade">  
  <div class="modal-dialog">  
    <div class="modal-content">  
      <div class="modal-header">  
        <button type="button" class="close" data-dismiss="modal">&times;
        </button>  
        <h4 class="modal-title">Pump Manager Clients detail
        </h4>  
      </div>  
      <div class="modal-body">  
        <form method="post" id="insert_form">  
          <div class="box-body">
            <div class="row">
              <div class="form-group" id="db">  
                <label for="dbname">Database Name
                </label>
                <input type="text" class="form-control" id="dbname" name="dbname" value='imconnect_' placeholder="Enter Database Name">
                <p id="notavailable" style="color:Red; display:none;">Already Exist</p>
                <p id="available" style="color:green; display:none;">This Is Perfect</p>
                <input type="hidden" name="dbnamevali" id="dbnamevali" readonly="" />  
              </div>
              <div class="col-md-4">
                <div class="form-group">
                  <label for="cuname">Client Username
                  </label>
                  <input type="text" class="form-control" id="cuname" name="cuname" placeholder="Enter Username">
                </div>

                <div class="form-group">
                  <label for="ccontact">Contact Number
                  </label>
                  <input type="tel" pattern="[0-9]{10}" title="Only 10 digit number" maxlength="10" class="form-control" id="ccontact" name="ccontact" placeholder="Enter Contact Number">
                </div>
                <div class="form-group">
                  <label for="cpass">Client Password
                  </label>
                  <input type="password" class="form-control" id="cpass" name="cpass" placeholder="Password">
                </div>
                <div class="form-group">
                  <label for="cpass2">Client Password 2
                  </label>
                  <input type="password" class="form-control" id="cpass2" name="cpass2" placeholder="Password">
                </div>
                <div class="form-group">
                  <label for="status">Status
                  </label>
                  <select type="text" class="form-control" id="status" name="status" placeholder="Enter Status">
                    <option selected="selected" value="Active">Active</option>
                    <option value="Deactive">Deactive</option>
                  </select>
                </div>


                
              </div>
              <div class="col-md-4">
                <div class="form-group">
                  <label for="c_name">Company Name
                  </label>
                  <input type="text" class="form-control" id="c_name" name="c_name" placeholder="Enter Client Name">
                </div>
                <div class="form-group">
                  <label for="c_address">Client Address
                  </label>
                  <input type="text" class="form-control" name="c_address" id="c_address" placeholder="Enter Client Address">
                </div>
                <div class="form-group">
                  <label for="shift1">Shift 1 - Time
                  </label>
                  <input type="text" class="form-control" id="shift1" name="shift1" placeholder="Shift 1 - Time">
                </div>
                <div class="form-group">
                  <label for="shift2">Shift 2 - Time
                  </label>
                  <input type="text" class="form-control" id="shift2" name="shift2" placeholder="Shift 2 - Time">
                </div>
                <div class="form-group">
                  <label for="brand">Brand
                  </label>
                  <select type="text" class="form-control" id="brand" name="brand" placeholder="Enter Status">
                    <option selected="selected" value="BPCL">BPCL</option>
                    <option value="HP">HP</option>
                    <option value="IOCL">IOCL</option>
                    <option value="ESSAR">ESSAR</option>
                  </select>
                </div>

              </div>
              <div class="col-md-4">
                <div class="form-group">
                  <label for="gst">Client Email
                  </label>
                  <input type="text" class="form-control" id="Usr_email" name="Usr_email" placeholder="Email">
                </div>
                <div class="form-group">
                  <label for="gst">GST No
                  </label>
                  <input type="text" class="form-control" id="gst" name="gst" placeholder="GST NO">
                </div>
                <div class="form-group">
                  <label for="vat">VAT No
                  </label>
                  <input type="text" class="form-control" id="vat" name="vat" placeholder="VAT No">
                </div>
                <div class="form-group">
                  <label for="reg_date">Registred Date
                  </label>
                  <input type="date" class="form-control" id="reg_date" name="reg_date" placeholder="Enter Registred Date">
                </div>
                <div class="form-group">
                  <label for="exp_date">Expire Date
                  </label>
                  <input type="date" class="form-control" id="exp_date" name="exp_date" placeholder="Enter Expire Date">
                </div>
              </div>
            </div>
          </div>  
          <input type="hidden" name="employee_id" id="employee_id" readonly="" />  
          <input type="hidden" name="request_type" id="request_type" readonly value="11" />  
          <input type="submit" name="insert" id="insert" value="Insert" class="btn btn-success" />  
        </form>  
      </div>   
    </div>  
  </div>  
</div>
</div>