<?php include("auth.php");

require("conn.php");
$v_code = $_SESSION['v_code'];


function getPhoto_url()
{
    $photo_url = "";
    require "conn.php";

    $sql = "select * from  tbl_vendor";
    $rs = mysqli_query($conn, $sql);
    $row = mysqli_fetch_assoc($rs);

    if ($row['photo_url'])
        $photo_url = $row['photo_url'];

    return ($photo_url);
}

?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">

    <title>Profile</title>
    <meta content="" name="description">
    <meta content="" name="keywords">
      <link href="assets/img/favicon.png" rel="icon">
    <link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
    <?php include("templates/inc.php"); ?>
    <script src="scripts/notice.js" type="text/javascript" language="javascript"></script>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>



    <script>
        $(document).ready(function () {

            //Upload image_url 

            $(document).on('change', '#solution-file', function () {
                var name = document.getElementById("solution-file").files[0].name;
                var form_data = new FormData();
                var ext = name.split('.').pop().toLowerCase();
                if (jQuery.inArray(ext, ['pdf', 'jpeg', 'jpg', 'png']) == -1) {
                    alert("Invalid Image File");
                }
                var oFReader = new FileReader();
                oFReader.readAsDataURL(document.getElementById("solution-file").files[0]);
                var f = document.getElementById("solution-file").files[0];
                var fsize = f.size || f.fileSize;
                if (fsize > 2000000) {
                    alert("Image File Size is very big");
                } else {
                    form_data.append("solution-file", document.getElementById('solution-file').files[
                        0]);

                    $.ajax({

                        url: "upload.php",
                        method: "POST",
                        data: form_data,
                        contentType: false,
                        cache: false,
                        processData: false,
                        beforeSend: function () {
                            $('#uploaded_solutionfile_url').html(
                                "<label class='text-success'>Uploading...</label>");
                        },
                        success: function (data) {
                            $('#uploaded_solutionfile_url').html(data);
                        }
                    });
                }
            });



            // Upload file_url End

            $(document).ready(function () {

                $("#submit").click(function () {

                    $("#submit").html("Uploading...");

                    var v_code = $("#v_code").val();

                    $.ajax({
                        type: 'post',
                        url: 'profile-action.php',
                        data: {
                            'v_code': v_code,

                        },
                        success: function (data) {
                            alert(data);
                            window.location = "profile.php";
                        }

                    });

                });
            });


        });



        $(document).ready(function () {

            $("#submit-button").click(function () {

                $("#submit-button").html("Submitting Data...");

                var name = $("#name").val();
                var role = $("#role").val();
                var email = $("#email").val();
                var dob = $("#dob").val();
                var mobile = $("#mobile").val();
                var uid = $("#uid").val();
                var pan = $("#pan").val();
                var acc_holder = $("#acc_holder").val();
                var acc_no = $("#acc_no").val();
                var bank_name = $("#bank_name").val();
                var ifsc = $("#ifsc").val();
                var branch = $("#branch").val();



                $.ajax({
                    type: 'post',
                    url: 'profile-details-action.php',
                    data: {
                        'name': name,
                        'role': role,
                        'email': email,
                        'mobile': mobile,
                         'dob': dob,
                        'uid': uid,
                        'pan': pan,
                        'acc_holder': acc_holder,
                        'acc_no': acc_no,
                        'bank_name': bank_name,
                        'ifsc': ifsc,
                        'branch': branch,
                      

                    },
                    success: function (data) {
                        alert(data);
                        $("#submit-button").html("Update Profile");
                        $("#msg").html(data);
                        $("#msg").slideDown("slow");
                        $("#msg").slideUp(8000);
                        location.reload();
                    }

                });

            });

        });
    </script>

</head>
<style>

</style>

<body>

    <!-- ======= Header ======= -->
    <?php
    include("templates/header.php");
    ?>

    <!-- End Header -->

    <!-- ======= Sidebar ======= -->
    <?php
    include("templates/sidebar.php");

    ?>
    <!-- End Sidebar-->

    <?php
    include("./conn.php");
    $sql = "select * from tbl_vendor where v_code='$v_code'";
    $smt = mysqli_query($conn, $sql);
    $rs = mysqli_fetch_assoc($smt);

    ?>


    <main id="main" class="main">

        <div class="pagetitle">
            <h1>Profile</h1>
           
        </div><!-- End Page Title -->

        <section class="section profile">
            <div class="row">
                <div class="col-sm-4">

                    <div class="card">
                        <div class="card-body profile-card pt-4 d-flex flex-column align-items-center">

                            <span id="uploaded_solutionfile_url"><img src="<?php echo $rs['photo_url']; ?>" class="border border-info"></span><br>

                            <input class="form-control" type="file" id="solution-file" name="solution-file" />
                            <input type="hidden" id="v_code" name="v_code" value="<?php echo $rs['v_code']; ?>" />


                            <h4>
                                <?php echo $rs['name']; ?>
                            </h4>
                            <h3>
                                <?php echo $rs['role']; ?>
                            </h3>

                            <center><button type="button" class="btn btn-primary mt-3" id="submit"
                                    name="submit">Upload</button></center>


                        </div>
                    </div>

                </div>

                <div class="col-sm-8">

                    <div class="card">
                        <div class="card-body pt-3">
                            <!-- Bordered Tabs -->
                            <ul class="nav nav-tabs nav-tabs-bordered">

                                <li class="nav-item">
                                    <button class="nav-link active" data-bs-toggle="tab"
                                        data-bs-target="#profile-overview">Profile Details</button>
                                </li>


                            </ul>
                            <div class="tab-content pt-2">

                                <div class="tab-pane fade show active profile-overview" id="profile-overview">

                                    <div class="card mb-4">

                                        <div class="card-body py-3">


                                            <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">Customer
                                                    ID</label>
                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" name="v_code" id="v_code"
                                                        value="<?php echo $rs['v_code']; ?>" disabled="">
                                                </div>
                                            </div>
                                            <hr>

                                            <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">Name</label>
                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" name="name" id="name"
                                                        value="<?php echo $rs['name']; ?>">
                                                </div>
                                            </div>
                                            <hr>

                                            <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">Role</label>
                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" name="role" id="role"
                                                        value="<?php echo $rs['role']; ?>" readonly>
                                                </div>
                                            </div>

                                            <hr>
                                            <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">Email ID</label>
                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" name="email" id="email"
                                                        value="<?php echo $rs['email']; ?>">
                                                </div>
                                            </div>
                                            <hr>
                                            <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">Date of Birth</label>
                                                <div class="col-sm-10">
                                                    <input type="date" class="form-control" name="dob" id="dob"
                                                        value="<?php echo $rs['dob']; ?>">
                                                </div>
                                            </div>


                                            <hr>
                                            <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">phone</label>
                                                <div class="col-sm-10">
                                                    <input type="number" class="form-control" name="mobile" id="mobile"
                                                        value="<?php echo $rs['mobile']; ?>">
                                                </div>
                                            </div>

                                         
                                            <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">Adhaar No</label>
                                                <div class="col-sm-10">
                                                    <input type="number" class="form-control" name="uid" id="uid"
                                                        value="<?php echo $rs['uid']; ?>">
                                                </div>
                                            </div>

                                             <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">Pan No</label>
                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" name="pan" id="pan"
                                                        value="<?php echo $rs['pan']; ?>">
                                                </div>
                                            </div>  
                                                <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">Account Holder</label>
                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" name="acc_holder" id="acc_holder"
                                                        value="<?php echo $rs['acc_holder']; ?>">
                                                </div>
                                            </div>

                                            <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">Account No</label>
                                                <div class="col-sm-10">
                                                    <input type="number" class="form-control" name="acc_no" id="acc_no"
                                                        value="<?php echo $rs['acc_no']; ?>">
                                                </div>
                                            </div>


                                          <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">Bank Name</label>
                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" name="bank_name" id="bank_name"
                                                        value="<?php echo $rs['bank_name']; ?>">
                                                </div>
                                            </div>
                                         
                                         
                                         
                                         <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">Branch</label>
                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" name="branch" id="branch"
                                                        value="<?php echo $rs['branch']; ?>">
                                                </div>
                                            </div>
                                            
                                            
                                              <div class="row mb-3">
                                                <label for="inputText" class="col-sm-2 col-form-label">IFSC</label>
                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" name="ifsc" id="ifsc"
                                                        value="<?php echo $rs['ifsc']; ?>">
                                                </div>
                                            </div>
                                         
                                            <center><button type="button" name="submit-button" id="submit-button"
                                                    class="btn btn-outline-success">Update Profile</button></center>


                                        </div>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>

                </div>

                <div class="tab-pane fade profile-edit pt-3" id="profile-edit">

                    <!-- Profile Edit Form -->
                    <form>
                        <div class="row mb-3">
                            <label for="profileImage" class="col-md-4 col-lg-3 col-form-label">Profile Image</label>
                            <div class="col-md-8 col-lg-9">
                                <img src="assets/img/profile-img.jpg" alt="Profile">
                                <div class="pt-2">
                                    <a href="#" class="btn btn-primary btn-sm" title="Upload new profile image"><i
                                            class="bi bi-upload"></i></a>
                                    <a href="#" class="btn btn-danger btn-sm" title="Remove my profile image"><i
                                            class="bi bi-trash"></i></a>
                                </div>
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="fullName" class="col-md-4 col-lg-3 col-form-label">Full Name</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="fullName" type="text" class="form-control" id="fullName"
                                    value="Kevin Anderson">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="about" class="col-md-4 col-lg-3 col-form-label">About</label>
                            <div class="col-md-8 col-lg-9">
                                <textarea name="about" class="form-control" id="about"
                                    style="height: 100px">Sunt est soluta temporibus accusantium neque nam maiores cumque temporibus. Tempora libero non est unde veniam est qui dolor. Ut sunt iure rerum quae quisquam autem eveniet perspiciatis odit. Fuga sequi sed ea saepe at unde.</textarea>
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="company" class="col-md-4 col-lg-3 col-form-label">Company</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="company" type="text" class="form-control" id="company"
                                    value="Lueilwitz, Wisoky and Leuschke">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="Job" class="col-md-4 col-lg-3 col-form-label">Job</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="job" type="text" class="form-control" id="Job" value="Web Designer">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="Country" class="col-md-4 col-lg-3 col-form-label">Country</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="country" type="text" class="form-control" id="Country" value="USA">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="Address" class="col-md-4 col-lg-3 col-form-label">Address</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="address" type="text" class="form-control" id="Address"
                                    value="A108 Adam Street, New York, NY 535022">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="Phone" class="col-md-4 col-lg-3 col-form-label">Phone</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="phone" type="text" class="form-control" id="Phone"
                                    value="(436) 486-3538 x29071">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="Email" class="col-md-4 col-lg-3 col-form-label">Email</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="email" type="email" class="form-control" id="Email"
                                    value="k.anderson@example.com">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="Twitter" class="col-md-4 col-lg-3 col-form-label">Twitter Profile</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="twitter" type="text" class="form-control" id="Twitter"
                                    value="https://twitter.com/#">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="Facebook" class="col-md-4 col-lg-3 col-form-label">Facebook Profile</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="facebook" type="text" class="form-control" id="Facebook"
                                    value="https://facebook.com/#">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="Instagram" class="col-md-4 col-lg-3 col-form-label">Instagram Profile</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="instagram" type="text" class="form-control" id="Instagram"
                                    value="https://instagram.com/#">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="Linkedin" class="col-md-4 col-lg-3 col-form-label">Linkedin Profile</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="linkedin" type="text" class="form-control" id="Linkedin"
                                    value="https://linkedin.com/#">
                            </div>
                        </div>

                        <div class="text-center">
                            <button type="submit" class="btn btn-primary">Save Changes</button>
                        </div>
                    </form><!-- End Profile Edit Form -->

                </div>

                <div class="tab-pane fade pt-3" id="profile-settings">

                    <!-- Settings Form -->
                    <form>

                        <div class="row mb-3">
                            <label for="fullName" class="col-md-4 col-lg-3 col-form-label">Email Notifications</label>
                            <div class="col-md-8 col-lg-9">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" id="changesMade" checked>
                                    <label class="form-check-label" for="changesMade">
                                        Changes made to your account
                                    </label>
                                </div>
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" id="newProducts" checked>
                                    <label class="form-check-label" for="newProducts">
                                        Information on new products and services
                                    </label>
                                </div>
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" id="proOffers">
                                    <label class="form-check-label" for="proOffers">
                                        Marketing and promo offers
                                    </label>
                                </div>
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" id="securityNotify" checked
                                        disabled>
                                    <label class="form-check-label" for="securityNotify">
                                        Security alerts
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="text-center">
                            <button type="submit" class="btn btn-primary">Save Changes</button>
                        </div>
                    </form><!-- End settings Form -->

                </div>

                <div class="tab-pane fade pt-3" id="profile-change-password">
                    <!-- Change Password Form -->
                    <form>

                        <div class="row mb-3">
                            <label for="currentPassword" class="col-md-4 col-lg-3 col-form-label">Current
                                Password</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="password" type="password" class="form-control" id="currentPassword">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="newPassword" class="col-md-4 col-lg-3 col-form-label">New Password</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="newpassword" type="password" class="form-control" id="newPassword">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <label for="renewPassword" class="col-md-4 col-lg-3 col-form-label">Re-enter New
                                Password</label>
                            <div class="col-md-8 col-lg-9">
                                <input name="renewpassword" type="password" class="form-control" id="renewPassword">
                            </div>
                        </div>

                        <div class="text-center">
                            <button type="submit" class="btn btn-primary">Change Password</button>
                        </div>
                    </form><!-- End Change Password Form -->

                </div>

            </div><!-- End Bordered Tabs -->

            </div>
            </div>

            </div>
            </div>
        </section>

    </main><!-- End #main -->

    <!-- ======= Footer ======= -->
    <?php
    include("templates/footer.php");
    ?>
    <!-- End Footer -->


    <?php include("templates/vendors.php"); ?>

</body>

</html>