<?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']) && !isset($_SESSION['uname']) )

        header("Location: logout.php");



    $web_url_with_ref_code = "http://classx.in/registration/index.php?r=".$_SESSION['uref_code'];

?>

<!DOCTYPE html>

<html lang="en">

<head>

 <?php include "include/meta.php"; ?>        

    <?php include "include/css.php"; ?>      

  



</head>

<body id="page-top" class="mt-55">



    <div style="margin-top: 70px;"></div>



      <?php include "include/user-header.php"; ?>



<div cl ass="container-fluid ">       

   <div class="row mx-0 justify-content-center mt-2">

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

            <h1 class="h3 text-gray-800 text-center"><?php echo $_SESSION['uname']; ?></h1>

                    <hr>

            <?php

                $ap_total_rows= 0;

                $ap_sql = "SELECT * FROM users WHERE upload_ref_code = '$_SESSION[uref_code]' AND reg_approved= '1'";

                $ap_res = mysqli_query($con,$ap_sql);

                $ap_total_rows=mysqli_num_rows($ap_res);



                $not_ap_total_rows= 0;

                $not_ap_sql = "SELECT * FROM users WHERE upload_ref_code = '$_SESSION[uref_code]' AND reg_approved= '0'";

                $not_ap_res = mysqli_query($con,$not_ap_sql);

                $not_ap_total_rows=mysqli_num_rows($not_ap_res);



                    

            ?>

            <div class="row mx-0 justify-content-center gx-1 md">

            

                <a data-toggle='modal'  class='viewDetails'  data-target='#modalNotes' data-ref="<?php echo $_SESSION['uref_code']; ?>" data-title='Payment'>

                

                    <div class="col-md-6 col-xs-6 text-center">  

                          <p class="md2" style="color: white;"><i class="fa fa-line-chart" aria-hidden="true"></i>  <?php echo $ap_total_rows; ?> </p>     

                    </div>

                    <div class="col-md-6 col-xs-6 text-center">  

                          <p class="md2" style="color: white;"><i class="fa fa-ban" aria-hidden="true"></i>  <?php echo $not_ap_total_rows; ?> </p>        

                    </div>

                </a> 

            </div>

            <!-- ref share -->

            <div style="border-top: 1px solid #ebebe0; margin-bottom: 5px;"> </div>



          <div class="row" > 

          <div class="col-md-12 text-center">Invite Your Friends</div>     

          <div class="col-md-4 col-xs-2"> </div>       

             <div class="col-md-1 col-xs-2 btn"> 

                    <a href="http://www.facebook.com/share.php?u=<?php echo $web_url_with_ref_code; ?>" >

                <div  style="padding:5px 5px 5px 5px;  background: #3B5998; color: white;font-size: 20px;text-align: center;text-decoration: none;border-radius: 10%;">

             <i class="fa fa-facebook"></i> </div></a>

             </div>

             <div class="col-md-1 col-xs-2 btn"> 

                    <a href="https://api.whatsapp.com/send?text=<?php echo "Click to Register"; ?>  <?php echo $web_url_with_ref_code; ?>" >

                <div  style="padding:5px 5px 5px 5px;  background: #25d366; color: white;font-size: 20px;text-align: center;text-decoration: none;border-radius: 10%;">

             <i class="fa fa-whatsapp"></i> </div></a>

             </div>

             <div class="col-md-1 col-xs-2 btn"> 

                     <a href="https://twitter.com/share?url=<?php echo $web_url_with_ref_code; ?>">

                <div  style="padding:5px 5px 5px 5px;  background: #55ACEE; color: white;font-size: 20px;text-align: center;text-decoration: none;border-radius: 10%;">

             <i class="fa fa-twitter"></i> </div></a>

             </div>

             <div class="col-md-1 col-xs-2 btn">  

                    <a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=<?php echo $web_url_with_ref_code; ?>">

                <div  style="padding:5px 5px 5px 5px;  background: #007bb5; color: white;font-size: 20px;text-align: center;text-decoration: none;border-radius: 10%;">

             <i class="fa fa-linkedin"></i> </div></a>

             </div>

             <div class="col-md-4 col-xs-2"> </div>



        </div> 

           

            <!-- ref share end -->

          

            <!--Profile details -->

    <?php



        $p_sql = "SELECT * FROM users WHERE uref_code = '$_SESSION[uref_code]'";

        $p_res = mysqli_query($con,$p_sql);

        $p_row = mysqli_fetch_assoc($p_res);

            

    ?>

        <div class="card shadow mt-3">

            <h5 class="card-header text-dark  text-center font-weight-bold"> Profile <span id="showUserNameDetails"></span></h5>

                <div class="card-body">

                    <form method="POST">   

                        <div class="row" id="Show_InsertUserName">

                            <div class="col-md-6 mt-2">

                                <label class="badge badge-warning">Name</label>

                                <label class="form-control"><?php echo $p_row['uname']; ?></label>

                            </div>

                            <div class="col-md-6 mt-2">

                                <label class="badge badge-warning">Phone No.</label>

                                <label class="form-control"><?php echo $p_row['ucontact']; ?></label>

                            </div>

                            

                        </div>



                        <div class="row" id="Show_InsertUserName">

                            <div class="col-md-6 mt-2">

                                <label class="badge badge-warning">Email Id</label>

                                <label class="form-control"><?php echo $p_row['uemail']; ?></label>

                            </div>

                            <div class="col-md-6 mt-2">

                                <label class="badge badge-warning">Category</label>

                                <label class="form-control"><?php echo $p_row['utype']; ?></label>

                            </div>

                            

                        </div>



                        <div class="row">

                            <div class="col-md-6 mt-2">

                                <label class="badge badge-warning">Address</label>

                                <label class="form-control" style="height: 60px;"><?php echo $p_row['saddress'].'<br>'.$p_row['dist'].'-'.$p_row['pin']; ?> </label>

                                        

                            </div>

                            <div class="col-md-6 mt-2">

                            <label class="badge badge-warning">About</label>

                            <label class="form-control" style="height: 60px;"><?php echo $p_row['uremark']; ?></label>

                            </div>

                        </div>

                        <div class="row">

                            <div class="col-md-6 mt-2">

                                <label class="badge badge-warning">UserId</label>

                                <label class="form-control"><?php echo $p_row['uphone']; ?></label>

                            </div>

                            <div class="col-md-6 mt-2">

                                <label class="badge badge-warning">Referance Code</label>

                                <label class="form-control"><?php echo $p_row['uref_code']; ?></label>

                            </div>

                        </div>

                        <div class="row">

                            <div class="col-md-12 mt-2">

                                <label class="badge badge-warning">Password</label>

                                <input type="password" class="form-control" name="password" value="<?php echo $p_row['upass']; ?>" id="myInput">

                                

                                <input type="checkbox" class="mt-3 ml-1" onclick="myFunction()"> Show Password

                            </div>

                        </div>

                            <div class=" row justify-content-center">

                                <button type="submit" class="btn btn-success text-sm-center mt-4" name="password_submit">

                                     Change Password

                                </button>

                            </div>

                    </form>

                </div>

            </div>







        </div>

     </div>

</div> 



<div class="modal fade" id="modalNotes" tabindex="-1" role="dialog" aria-labelledby="modelTitleId" aria-hidden="true">

        <div class="modal-dialog" role="document">

            <div class="modal-content">

                <div class="modal-header">

                    <h5 class="modal-name badge badge-primary text-light" id="modalName"></h5>

                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">

                        <span aria-hidden="true">&times;</span>

                    </button>

                </div>

                <div class="modal-body">

                    <span id=paymentShow></span>

                </div>

                <div class="modal-footer">

                    <button type="button" class="btn btn-warning text-dark" data-dismiss="modal">Close</button>

                </div>

            </div>

        </div>

    </div>













            <?php include "include/ft.php"; ?>

            <?php include "include/js.php"; ?>



<script>

function myFunction() {

  var x = document.getElementById("myInput");

  if (x.type === "password") {

    x.type = "text";

  } else {

    x.type = "password";

  }

}

</script>



        <script>

        $(document).ready(function(){



            $('.viewDetails').on('click', function () {

                var uref_code = $(this).data('ref');

                var title = $(this).data('title');

                console.log(uref_code);

                $('#modalName').text(title);



                $('.modal-css').css({

                    'color' : 'black'

                });

                $('.modal-name').css({

                    'text-align' : 'center',

                    'color' : 'black',

                    'font-size' : '20px'

                });



                 $.ajax({

                    url:'paymentDisplay-Ajax.php',

                    type:'post',

                    data:{

                      uref_code:uref_code

                    },

                    success:function(result){

                      $('#paymentShow').html(result);

                    }

                });



                

                

            });

        });

    </script>

</body>

</html>





<?php

    if(isset($_POST['password_submit'])){



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



        $up_sql = "UPDATE users SET upass = '$password' WHERE uid = '$_SESSION[uid]'";



        if(mysqli_query($con, $up_sql)){

            ?>

            <script>window.location = 'index.php';</script>

            <?php

        }

        else{

            ?>

            <script>

                alert('OOPS !!!!');

                setTimeout(() => {

                    window.location = 'index.php';

                }, 500);

            </script>

            <?php

        }

    }

?>



<?php 







