<?php
    session_start();
    
    include "../../db.php";
    date_default_timezone_set('Asia/Kolkata');
    $currentTime = date('M j, Y g:i a');
    if ( !isset($_SESSION['uid']) && !isset($_SESSION['uref']) && !isset($_SESSION['utype']) )
        header("Location: logout.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include "includes/meta.php"; ?>             
    <?php include "includes/css.php"; ?>
    <link href="css/all.min.css" rel="stylesheet" type="text/css">
    <link href="css/alltable.css" rel="stylesheet"> 

    
</head>

<body>

  <!--==========================
  Header
  ============================-->
   <?php include "includes/header2.php"; ?>
  
  <!-- #header -->

  <!--==========================
    Intro Section
  ============================-->
                
<div id="content">
                <div class="container-fluid px-0">

                    <div class="card shadow mb-4">
                        <div class="card-body">

                            <h1 class="h3 mb-2 text-gray-800 text-center">Profile</h1>
                            <hr>
                            
  
          <div class="col-sm-12 row">
          <div class="col-sm-2 mb-1 mb-sm-0">
                      </div>  
                          <div class="col-sm-8 mb-1 mb-sm-0">
                          
          
          <form class="user" method="post" enctype="multipart/form-data">
              <h4 class="mb-3 badge badge-secondary"> Client's Details</h4>
              <div class="row justify-content-center ">
              
              <div class="  col-md-5 ">
                  <div class=" mb-1 mb-sm-0">
                   Name *
                      <input type="text" class="form-control form-control-sm mb-2" id="name" placeholder="" name="name"  required>
                  </div>
                  <div class=" mb-1 mb-sm-0">
                   WhatsApp No.
                      <input type="text" class="form-control form-control-sm mb-2" id="whatsapp" placeholder="" name="whatsapp" >
                  </div>
                  <div class=" mb-1 mb-sm-0">
                  Phone No. *
                      <input type="text" class="form-control form-control-sm mb-2" id="phone" placeholder="" name="phone" required>
                  </div>
                  <div class=" mb-1 mb-sm-0">
                  Other Phone No. 
                      <input type="text" class="form-control form-control-sm mb-2" id="ophone" placeholder="" name="ophone">
                  </div>
                  <div class=" mb-1 mb-sm-0">
                  Email Id 
                      <input type="email" class="form-control form-control-sm mb-2" id="email" placeholder="" name="email"  >
                  </div>
                  <div class=" mb-1 mb-sm-0">
                  Address
                      <input type="text" class="form-control form-control-sm mb-2" id="address" placeholder="" name="address"  >
                  </div>
                  <div class=" mb-1 mb-sm-0">
                  About
                      <input type="text" class="form-control form-control-sm mb-2" id="abt" placeholder="" name="abt" >
                  </div>
                  <div class=" mb-1 mb-sm-0">
                  Contact Person
                      <input type="text" class="form-control form-control-sm mb-2" id="con_name" placeholder="" name="con_name" >
                  </div>
                  <div class=" mb-1 mb-sm-0">
                  Contact Person Ph No.
                      <input type="text" class="form-control form-control-sm mb-2" id="con_name_ph" placeholder="" name="con_name_ph" >
                  </div>
                  

                  
                  </div>

                  <div class="col-md-5 ">
                  <div class=" mb-1 mb-sm-0">
                  Facebook Link 
                      <input type="text" class="form-control form-control-sm mb-2" id="fb" placeholder="" name="fb"  >
                  </div>
                  <div class=" mb-1 mb-sm-0">
                  Instagram Link 
                      <input type="text" class="form-control form-control-sm mb-2" id="insta" placeholder="" name="insta"  >
                  </div>
                  <div class=" mb-1 mb-sm-0">
                  Linkedin Link 
                      <input type="text" class="form-control form-control-sm mb-2" id="linkedin" placeholder="" name="linkedin"  >
                  </div>
                  <div class=" mb-1 mb-sm-0">
                  Website Link 
                      <input type="text" class="form-control form-control-sm mb-2" id="web" placeholder="" name="web"  >
                  </div>
                  <div class=" mb-1 mb-sm-0">
                  Google Map Link 
                      <textarea name="map" rows="3" cols="44" placeholder="" class="form-control form-control-sm mb-2" id="map"></textarea>
                  </div>
                  <div class=" mb-1 mb-sm-0">
                  Google Rate & Review 
                      <input type="text" class="form-control form-control-sm mb-2" id="web" placeholder="" name="grate"  >
                  </div>
                  <div class="mb-1 mb-sm-0">
                    Category      
                      <select name="cat" id="cat" class="form-control mb-3" >
                        <option value=''>Select Category</option>
                          <?php
                            $cat_sql = "SELECT * FROM cat ORDER BY sl DESC";
                            $cat_run = mysqli_query($con, $cat_sql);
                            while ( $cat_rows = mysqli_fetch_assoc($cat_run) ) 
                            {
                              echo "
                              <option value='$cat_rows[category]'>$cat_rows[category]</option>
                              ";
                            } ?>
                      </select>
                  </div>
                  
                 
                  
                  <div class="mb-1 mb-sm-0">
                    Status      
                      <select name="status" id="status" class="form-control mb-3" >
                          <option value="Pending">Pending</option>
                          <option value="Reject">Reject</option>
                          <option value="Interested">Interested</option>
                          <option value="Ready_To_Join">Ready_To_Join</option>
                          <option value="Successful">Successful</option>
                      </select>
                  </div>

              </div>
                                    
        </div>
                                
    <button type="submit" class="btn btn-success btn-user m-2" name="submit_details">
        <i class="far fa-image"></i> Submit Details
    </button>
    <a href="index.php" class="btn btn-warning btn-user m-2"> <i class="fas fa-ban"></i> Cancel </a>
    
    <a href="cat.php" class="btn btn-success btn-user m-2"> Add Category </a>
</form>
<br><br>
                            <hr>
                            </div></div>

                        </div>
                    </div>

                </div>

            </div>
 
<!--============================== -->
        
                


 <!--==========================
    Footer
  ============================-->
    <?php include "includes/ft.php"; ?>
  
  <!-- #footer -->
<script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.easing.min.js"></script>
    <script src="js/sb-admin-2.min.js"></script>
    <script src="js/sweetalert2.min.js"></script>
    <script src="js/jquery.dataTables.min.js"></script>
    <script src="js/dataTables.bootstrap4.min.js"></script>
    <script src="js/datatables.mark.min.js"></script>
    <script src="js/jquery-ui-custom.min.js"></script>
    <script src="js/custom.js"></script>
    <script src="js/mobile-nav/mobile-nav.js"></script>
</body>
</html>



 

<?php
    if(isset($_POST['submit_details']))
    {
              

              $name = mysqli_real_escape_string($con, strip_tags($_POST['name']));
              $whatsapp = mysqli_real_escape_string($con, strip_tags($_POST['whatsapp']));
              $phone = mysqli_real_escape_string($con, strip_tags($_POST['phone']));
              $ophone = mysqli_real_escape_string($con, strip_tags($_POST['ophone']));
              $email = mysqli_real_escape_string($con, strip_tags($_POST['email']));
              $address = mysqli_real_escape_string($con, strip_tags($_POST['address']));
              $abt = mysqli_real_escape_string($con, strip_tags($_POST['abt']));
              $con_name = mysqli_real_escape_string($con, strip_tags($_POST['con_name']));
              $con_name_ph = mysqli_real_escape_string($con, strip_tags($_POST['con_name_ph']));

              $fb = mysqli_real_escape_string($con, strip_tags($_POST['fb']));
              $insta = mysqli_real_escape_string($con, strip_tags($_POST['insta']));
              $linkedin = mysqli_real_escape_string($con, strip_tags($_POST['linkedin']));
              $web = mysqli_real_escape_string($con, strip_tags($_POST['web']));
              $map = mysqli_real_escape_string($con, strip_tags($_POST['map']));
              $grate = mysqli_real_escape_string($con, strip_tags($_POST['grate']));
              $map = mysqli_real_escape_string($con, strip_tags($_POST['map']));
              $cat = mysqli_real_escape_string($con, strip_tags($_POST['cat']));

              $status = mysqli_real_escape_string($con, strip_tags($_POST['status']));

$chk_ph = mysqli_query($con, "SELECT cl_ph FROM client_details WHERE  cl_ph = '$phone'");
        $chk_ph_count = mysqli_num_rows($chk_ph);
        if ( $chk_ph_count < 1 ) {

         $sql = "INSERT INTO client_details (cl_name, cl_wp_no, cl_ph, cl_oPh, cl_email, cl_address, cl_about, contact_person, contact_person_ph, cl_fb, cl_insta, cl_linkedin, cl_website, cl_mapLink, cl_g_rate_review, cl_category, cl_status, uploadDT, cl_by) VALUES ('$name', '$whatsapp', '$phone', '$ophone', '$email', '$address', '$abt', '$con_name', '$con_name_ph', '$fb', '$insta', '$linkedin', '$web', '$map', '$grate', '$cat','$status','$currentTime', '$_SESSION[uid]')";

                
                if(mysqli_query($con, $sql)){
                    ?>
                    <script>
                      alert("Record updated successfully");
                    window.location = 'profile.php';
                    </script>
                    <?php
                }
                else{
                    ?>
                    <script>
                        alert('OOPS !!!!');
                        setTimeout(() => {
                            window.location = 'profile.php';
                        }, 500);
                    </script>
                    <?php
                }


        } else {
            ?>
            <script>
                alert('Mobile Number Exists');
                setTimeout(() => {
                    window.location = 'profile.php';
                }, 500);
            </script>
      
            <?php
      
      
      
        }



    }
?>














