<?php 

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
//error_reporting(E_ALL);


ini_set('session.gc_maxlifetime', 360000);
// each client should remember their session id for EXACTLY 4days
session_set_cookie_params(360000);
session_start();
 
require_once('../connect.php');
require_once('sql_required.php');

$datetoday = date('d F Y, h:i A'); 
$active_tab = "dashboard"; 


//if (!isset($_SESSION['uname'])) { 

  //$_SESSION['success'] = '<small class="text-danger"><b>Login First</b></small>';

?>

   <script language="javascript">

   //    window.location.href = '../index.php';

   </script>

<?php //} 

 


$success_messages = '';

$message = '';

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



    $selfie_file_name = $_FILES['logo']['name'];

    if ($selfie_file_name == '') {

      $message = 'Input file is Empty!';

    }else{

        $selfie_extension = substr($selfie_file_name,strlen($selfie_file_name)-4,strlen($selfie_file_name));

        $allowed_extensions = array(".jpg","jpeg",".png");



        if(!in_array($selfie_extension,$allowed_extensions)) {

        $success_messages = "<script>

                                swal({

                                  title: 'Error',

                                  text: 'Logo Invalid format. Only jpg / jpeg/ png format allowed! Try again',

                                  type: 'error',

                                  allowOutsideClick: false,

                                  showCancelButton: false,

                                  confirmButtonColor: '#343a40',

                                  confirmButtonText: 'OK'

                                }).then((value) => {

                                  window.location = 'dashboard.php'

                                }).catch(swal.noop)

                               </script>";

        }else{

          $file_store_selfie = $selfie_file_name;

          move_uploaded_file($_FILES['logo']['tmp_name'],'primary_pic/'.$selfie_file_name);



          $update_logo = "UPDATE users SET photo_url = '$file_store_selfie' WHERE id = '$currentid'";

          if (mysqli_query($conn, $update_logo)) {

            $success_messages = "<script>

                              swal({

                              title: 'Success',

                              text: 'Picture Successfully Changed!',

                              type: 'success',

                              allowOutsideClick: false,

                              showCancelButton: false,

                              confirmButtonColor: '#343a40',

                              confirmButtonText: 'OK'

                              }).then((value) => {

                              window.location = 'profile.php'

                              }).catch(swal.noop)

                          </script>";

          }else{

            $success_messages = "<script>

                              swal({

                              title: 'Success',

                              text: 'Image Unsuccessfully Change!',

                              type: 'success',

                              allowOutsideClick: false,

                              showCancelButton: false,

                              confirmButtonColor: '#343a40',

                              confirmButtonText: 'OK'

                              }).then((value) => {

                              window.location = 'profile.php'

                              }).catch(swal.noop)

                          </script>";

          }

        }

    }

}



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

  if ($_POST['new_password'] != '') {

    $password_update = $_POST['new_password'];

  }else{

    $password_update = $_POST['old_password'];

  }



  $update_password = "UPDATE users SET password = '$password_update' WHERE id = '$currentid'";

  if (mysqli_query($conn, $update_password)) {

    $success_messages = "<script>

                              swal({

                              title: 'Success',

                              text: 'Password Successfully Changes!',

                              type: 'success',

                              allowOutsideClick: false,

                              showCancelButton: false,

                              confirmButtonColor: '#343a40',

                              confirmButtonText: 'OK'

                              }).then((value) => {

                              window.location = 'profile.php'

                              }).catch(swal.noop)

                          </script>";

  }else{

    $success_messages = "<script>

                              swal({

                              title: 'Success',

                              text: 'Password Unsuccessfully Changes!',

                              type: 'success',

                              allowOutsideClick: false,

                              showCancelButton: false,

                              confirmButtonColor: '#343a40',

                              confirmButtonText: 'OK'

                              }).then((value) => {

                              window.location = 'profile.php'

                              }).catch(swal.noop)

                          </script>";

  }

}



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

 $username = $_POST['username'];

 $owner_name = $_POST['owner_name'];

 $mobile = $_POST['mobile'];
 $bdate = $_POST['bdate'];
 $address = $_POST['address'];
 $beneficiary_relationship = $_POST['beneficiary_relationship'];
 

 
   $update_info = "UPDATE users SET  beneficiary_relationship = '$beneficiary_relationship',bdate  = '$bdate', complete_add = '$address' , phone = '$mobile'WHERE id = '$currentid'";

  if (mysqli_query($conn, $update_info)) {

    $success_messages = "<script>

                              swal({

                              title: 'Success',

                              text: 'Information Successfully Updated!',

                              type: 'success',

                              allowOutsideClick: false,

                              showCancelButton: false,

                              confirmButtonColor: '#343a40',

                              confirmButtonText: 'OK'

                              }).then((value) => {

                              window.location = 'dashboard.php'

                              }).catch(swal.noop)

                          </script>";

  }else{

    $success_messages = "<script>

                              swal({

                              title: 'Success',

                              text: 'There is an error updating your account!',

                              type: 'success',

                              allowOutsideClick: false,

                              showCancelButton: false,

                              confirmButtonColor: '#343a40',

                              confirmButtonText: 'OK'

                              }).then((value) => {

                              window.location = 'profile.php'

                              }).catch(swal.noop)

                          </script>";

  }

}

?>  



<html>

<head>

<script data-ad-client="ca-pub-9305634393539471" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

  <meta charset="utf-8">

  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <title><?php echo $_uname; ?> | Dashboard</title>

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <meta name="description" content="Touch, responsive, flickable carousels">

  <link rel="shortcut icon" type="image/x-icon" href="images/affiliates-icon180.png">

    

  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">

  <!-- Ionicons -->

  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">

  <link rel="stylesheet" href="dist/css/adminlte.min.css">

  <link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css">



  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">

  <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker.css">

  <link rel="stylesheet" href="dist/css/adminlte.min.css">

    <link rel="stylesheet" href="plugins/select2/css/select2.min.css">

  <link rel="stylesheet" href="plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">

   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js" ></script>

  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" ></script>

  <link rel="stylesheet" href="sweetalert/css/sweetalert2.css">

  <script src="sweetalert/js/sweetalert2.js"></script>

   <link rel="stylesheet" type="text/css" href="css/style1.css">

  <style type="text/css">

.form-control:focus {

  border-color: #ff7108!important;;

}





  .picture {

    font-size: 14px;

    color: #343a40;

   }

}



.content-header {

  background: #fff;

/*  background: url(images/2.png);

  background-size: cover;

background-position: bottom;

background-repeat: no-repeat;*/

  padding: 15px 7.5px 1px 7.5px;

}

.recommedation {

  background: #fff;

  padding: 15px 7.5px 0px 7.5px!important;

}

.others {

  background: #fff;

  padding: 0px 7.5px 0px 7.5px!important;

}

.menu-main {

  background: #fff;

  padding: 0px 7.5px 0px 7.5px!important;

}



#loading {

  background: rgba( 255, 255, 255, 0.8 );

  display: none;

  height: 100%;

  position: fixed;

  width: 100%;

  z-index: 9999;

}



.transaction a {

  color: #808080!important;

}  



.transaction a.active {

  background-color: #343a40!important;

  color: #eb8810!important;

  font-weight: bold;

}   



#loading {

  background: rgba( 255, 255, 255, 0.8 );

  display: none;

  height: 100%;

  position: fixed;

  width: 100%;

  z-index: 9999;

}



#loading img

{

  left: 40%;

  margin-left: -32px;

  margin-top: -32px;

  position: absolute;

  top: 50%;

}



@media(max-width: 800px) {

  #loading img{

      left: 54%!important;

  }

}



@media(min-width: 801px) {

  #loading img {

    display: none!important;

  }

  #loading {

    display: none!important;

  }

}



.page-item.active .page-link {

  background: #343a40!important;

  border-color: #343a40!important;

}



.alert-success {

      color: #3c763d;

    background-color: #dff0d8;}

</style>







</head>

<body class="hold-transition sidebar-mini layout-fixed layout-navbar-fixed">
<?php include_once('linkStyle.php'); ?>
  
<div class="wrapper">

  <nav class="main-header navbar navbar-expand navbar-white navbar-light">

    <ul class="navbar-nav">

      <li class="nav-item">

        <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>

      </li>

      <li class="nav-item d-none d-sm-inline-block">

      Home

      </li>

    </ul>

    <ul class="navbar-nav ml-auto">

      <a href="logout.php" class="nav-link">Logout</a>



      </ul>

  </nav>



  <?php include_once('navbar.php'); ?>

  <div class="content-wrapper">

    <div id="loading" style="text-align: center;">

      <img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-small.gif" id="Img5" data-transition="slide" />

    </div>



    <br>

<!--     <section class="content-header mb-3">

          <div class="container-fluid">

                

          </div>

    </section> -->

<?php echo $success_messages; ?>



    <!-- Main content -->

    <section class="content">

      <div class="container-fluid">

        <div class="row">

          <div class="col-md-3">



            <!-- Profile Image -->

            <div class="card" style="border-top: 4px solid #ff7108!important;">

              <div class="card-body box-profile">

                <div class="text-center">


                <?php
                            if ($photourl == NULL) {

                              echo '<img src="/images/affiliates-icon180.png" />';


                            }else {?>

<img class="profile-user-img img-fluid img-circle"
src="/images/affiliates-icon180.png"  alt="User profile picture" width="150" height="150" class="img-thumbnail" />

<?php
                            }
                            ?>

   </div>

   <form method="POST" action="" enctype="multipart/form-data">

                      <div class="form-group">

                          <label class="label pb-2">Attach a photo (Only .jpg, .png file allowed.)</label>

                          <div class="row">

                  



                            <div class="col-12 pt-3" style="border-bottom: 1px solid #ced4da;">

                              <input type="file" name="logo" id="img_item" accept="image/*" capture="camera" style="display: none;" onchange="readURL(this); $('.loading').show(); setTimeout(function() { $('.loading').hide(); }, 500);" required/>

                              <center>  <input type="button" class="btn btn-danger" value="Select Photo" onclick="document.getElementById('img_item').click(); " />

                            

                              

                                <button type="submit" name="change_logo" class="btn btn-success ">Submit Changes</button>

                              </center>

                              

                            </div>

                          </div>

                      </div>
  </form>



                <h3 class="profile-username text-center"><?php echo $_uname; ?></h3>



         

                <ul class="list-group list-group-unbordered mb-3">

                  <li class="list-group-item">

                    <b>User ID: </b> <a class="float-right"><?php echo $currentid; ?></a>

                  </li>

                  <li class="list-group-item">

                    <b>Account Holder name:</b> <a class="float-right"><?php echo $_sid; ?></a>

                  </li>

                  <li class="list-group-item">

                    <b>Member Since:</b> <a class="float-right"><?php echo $_dateregistered; ?></a>
                    

                  </li>

                </ul>

              </div>

              <!-- /.card-body -->

            </div>

            <!-- /.card -->

          </div>

          <!-- /.col -->

          <div class="col-md-9">

            <div class="card">

              <div class="card-header p-2">

                <ul class="nav nav-pills">

                  <li class="nav-item"><a class="nav-link active" style="background: transparent; color: #ff7108!important; font-weight: bolder;" href="#settings" data-toggle="tab">Settings</a></li>

                </ul>

              </div><!-- /.card-header -->

              <div class="card-body">

                <div class="tab-content">

                  <div class="active tab-pane" id="settings">



                    

                    <form method="POST" action="" class="form-horizontal" id="quickForm" enctype="multipart/form-data">

                      <legend>Information</legend>

                      <input type="hidden" name="old_logo" value="<?php echo $logo; ?>">

                    

                      <div class="form-group row">

                        <label for="inputName" class="col-sm-2 col-form-label">Username</label>

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

                          <input type="text" class="form-control" id="inputName" name="username" value="<?php echo $username; ?>" placeholder="Owner name" readonly>

                        </div>

                      </div>



                      <div class="form-group row">

                        <label for="inputownerName" class="col-sm-2 col-form-label">First Name</label>

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

                          <input type="text" class="form-control" id="inputownerName" name="fname" value="<?php echo $_fname; ?>" placeholder="Owner name" readonly>

                        </div>

                      </div>

                      <div class="form-group row">

                      <label for="inputownerName" class="col-sm-2 col-form-label">Last Name</label>

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

                        <input type="text" class="form-control" id="inputownerName" name="lname" value="<?php echo $_lname; ?>" placeholder="Owner name" readonly>

                      </div>

                      </div>


                      <div class="form-group row">

                        <label for="inputContact" class="col-sm-2 col-form-label">Mobile Number</label>

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

                          <input type="number" class="form-control" id="inputContact" name="mobile" value="<?php echo $_phone; ?>" placeholder="Contact Number" required>

                        </div>

                      </div>



                      
                      <div class="form-group row">

                        <label for="inputContact" class="col-sm-2 col-form-label">Birthdate</label>

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

                        <div class="input-group date"  name="bdate"  id="reservationdate" data-target-input="nearest">
                        <input type="text" value = "<?php echo $_bdate ?>" class="form-control datetimepicker-input" name="bdate" data-target="#reservationdate"/>
                        <div class="input-group-append"  data-target="#reservationdate" data-toggle="datetimepicker">
                            <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                        </div>
                    </div>
                        </div>

                      </div>
 



                      <div class="form-group row">

                        <label for="inputName2" class="col-sm-2 col-form-label">Address</label>

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

                          <input type="text" class="form-control" id="inputName2" name="address" value="<?php echo $_address; ?>" placeholder="Address" required>

                        </div>

                      </div>

                      
                      <div class="form-group row">

                        <label for="inputName2" class="col-sm-2 col-form-label">Beneficiary:</label>

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

                          <input type="text" class="form-control" id="inputName2" name="beneficiary" value="<?php echo $_beneficiary; ?>" placeholder="Beneficiary Complete Name" required>

                        </div>
                        </div>


                        <div class="form-group row">

                        <label for="inputName2" class="col-sm-2 col-form-label"> Relationship:</label>

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

                          <input type="text" class="form-control" id="inputName2" name="beneficiary_relationship" value="<?php echo $_beneficiary_relationship; ?>" placeholder="Beneficiary Relationship" required>

                        </div>

                      </div>

                      <div class="form-group row">

                        <div class="offset-sm-2 col-sm-10">

                          <button type="submit" name="edit_info" class="btn btn-dark">Save Changes</button>

                        </div>

                      </div>

                    </form>

                    <hr>

                  <!--  <form method="POST" action="" class="form-horizontal">

                      <legend>Password</legend>

                       <div class="form-group row">

                        <label for="inputOldpassword" class="col-sm-2 col-form-label">Old Password</label>

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

                          <input type="text" class="form-control" id="inputOldpassword" name="old_password" value="<?php echo $password; ?>" placeholder="Old Password"readonly>

                        </div>

                      </div>

                      <div class="form-group row">

                        <label for="inputnewpassword" class="col-sm-2 col-form-label">New Password</label>

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

                          <input type="password" class="form-control" id="inputnewpassword" name="new_password" placeholder="New Password">

                        </div>

                      </div>

                      <div class="form-group row">

                        <div class="offset-sm-2 col-sm-10">

                          <button type="submit" name="changes_password" class="btn btn-dark">Save Changes</button>

                        </div>

                      </div>

                    </form>

                  </div> -->

                  <!-- /.tab-pane -->

                </div>

                <!-- /.tab-content -->

              </div><!-- /.card-body -->

            </div>

            <!-- /.nav-tabs-custom -->

          </div>

          <!-- /.col -->

        </div>

        <!-- /.row -->

      </div><!-- /.container-fluid -->

    </section>

    <!-- /.content -->

    

    

    <br>

</div>



</div>



<script src="dist/js/adminlte.min.js"></script>

    <script src="plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>

<script src="plugins/bs-custom-file-input/bs-custom-file-input.min.js"></script>

<script src="plugins/jquery/jquery.min.js"></script>

<!-- Bootstrap 4 -->

<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>

<script src="plugins/jquery-validation/jquery.validate.min.js"></script>

<script src="plugins/jquery-validation/additional-methods.min.js"></script>

<script src="plugins/select2/js/select2.full.min.js"></script>


<script src="plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Select2 -->
<script src="plugins/select2/js/select2.full.min.js"></script>
<!-- Bootstrap4 Duallistbox -->
<script src="plugins/bootstrap4-duallistbox/jquery.bootstrap-duallistbox.min.js"></script>
<!-- InputMask -->
<script src="plugins/moment/moment.min.js"></script>
<script src="plugins/inputmask/min/jquery.inputmask.bundle.min.js"></script>
<!-- date-range-picker -->
<script src="plugins/daterangepicker/daterangepicker.js"></script>
<!-- bootstrap color picker -->
<script src="plugins/bootstrap-colorpicker/js/bootstrap-colorpicker.min.js"></script>
<!-- Tempusdominus Bootstrap 4 -->
<script src="plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- Bootstrap Switch -->
<script src="plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>

</body>

</html>

<script type="text/javascript">

$(document).ready(function () {

  bsCustomFileInput.init();



  var form = $("#quickForm");

  form.validate({

    rules: {

      img: {

        required: true,

      }

    },

    errorElement: 'span',

    errorPlacement: function (error, element) {

      error.addClass('invalid-feedback');

      element.closest('.form-group').append(error);

    },

    highlight: function (element, errorClass, validClass) {

      $(element).addClass('is-invalid');

    },

    unhighlight: function (element, errorClass, validClass) {

      $(element).removeClass('is-invalid');

    }

  });



  $('#quickForm').submit(function() {

    if (form.valid() === true){

      $('#loading').show();

      $('#modal-comfirmation').modal('hide');

      return true;

    }else{

      $('#modal-comfirmation').modal('hide');

      return false;

    }

  });







});



function readURL(input) {

    if (input.files && input.files[0]) {

        var reader = new FileReader();



        reader.onload = function (e) {

            $('#blah')

                .attr('src', e.target.result)

                .width(150)

                .height(150);

        };



        reader.readAsDataURL(input.files[0]);

    }

}

</script>

<script>

// if ( window.history.replaceState ) {

//   window.history.replaceState( null, null, window.location.href );

// }




    //Datemask dd/mm/yyyy
    $('#datemask').inputmask('dd-mm-yyyy', { 'placeholder': 'dd-mm-yyyy' })
    //Datemask2 mm/dd/yyyy
    $('#datemask2').inputmask('mm-dd-yyyy', { 'placeholder': 'mm-dd-yyyy' })
    //Money Euro
    $('[data-mask]').inputmask()

    //Date range picker
    $('#reservationdate').datetimepicker({
        format: 'L'
    });
    //Date range picker
    $('#reservation').daterangepicker()
    //Date range picker with time picker
    $('#reservationtime').daterangepicker({
      timePicker: true,
      timePickerIncrement: 30,
      locale: {
        format: 'MM-DD-YYYY'
      }
    })
    //Date range as a button
    $('#daterange-btn').daterangepicker(
      {
        ranges   : {
          'Today'       : [moment(), moment()],
          'Yesterday'   : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
          'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
          'Last 30 Days': [moment().subtract(29, 'days'), moment()],
          'This Month'  : [moment().startOf('month'), moment().endOf('month')],
          'Last Month'  : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
        },
        startDate: moment().subtract(29, 'days'),
        endDate  : moment()
      },
      function (start, end) {
        $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
      }
    )


</script>



