<?php 
include('view/new_header_file.php');
include_once("classes/database.class.php");
include_once("classes/oanda.php");
include_once('classes/phpToPDF.php');
?>

<link rel="stylesheet" type="text/css" href="node_modules/css-toggle-switch/dist/toggle-switch.css">




  <style type="text/css">

    .tabs-left, .tabs-right {

      border-bottom: none;

      padding-top: 2px;

  }

  .tabs-left {

    border-right: 1px solid #ddd;

  }

  .tabs-right {

    border-left: 1px solid #ddd;

  }

  .tabs-left>li, .tabs-right>li {

    float: none;

    margin-bottom: 2px;

  }

  .tabs-left>li {

    margin-right: -1px;

  }

  .tabs-right>li {

    margin-left: -1px;

  }

  .tabs-left>li.active>a,

  .tabs-left>li.active>a:hover,

  .tabs-left>li.active>a:focus {

    border-bottom-color: #ddd;

    border-right-color: transparent;

  }



  .tabs-right>li.active>a,

  .tabs-right>li.active>a:hover,

  .tabs-right>li.active>a:focus {

    border-bottom: 1px solid #ddd;

    border-left-color: transparent;

  }

  .tabs-left>li>a {

    border-radius: 4px 0 0 4px;

    margin-right: 0;

    display:block;

  }

  .tabs-right>li>a {

    border-radius: 0 4px 4px 0;

    margin-right: 0;

  }

  .vertical-text {

    margin-top:50px;

    border: none;

    position: relative;

  }

  .vertical-text>li {

    height: 20px;

    width: 120px !!important;

    margin-bottom: 100px;

  }

  .vertical-text>li>a {

    border-bottom: 1px solid #ddd;

    border-right-color: transparent;

    text-align: center;

    border-radius: 4px 4px 0px 0px;

  }

  .vertical-text>li.active>a,

  .vertical-text>li.active>a:hover,

  .vertical-text>li.active>a:focus {

    border-bottom-color: transparent;

    border-right-color: #ddd;

    border-left-color: #ddd;

  }

  .vertical-text.tabs-left {

    left: -50px;

  }

  .vertical-text.tabs-right {

    right: -50px;

  }

  .vertical-text.tabs-right>li {

    -webkit-transform: rotate(90deg);

    -moz-transform: rotate(90deg);

    -ms-transform: rotate(90deg);

    -o-transform: rotate(90deg);

    transform: rotate(90deg);

  }

  .vertical-text.tabs-left>li {

    -webkit-transform: rotate(-90deg);

    -moz-transform: rotate(-90deg);

    -ms-transform: rotate(-90deg);

    -o-transform: rotate(-90deg);

    transform: rotate(-90deg);

  }

  .tabs-left > li 

  {

    padding-top: 5px !important;

    padding-bottom: 5px !important;

  }

  .panel-heading

  {

    background-color: #F7614E !important;

    text-align: center;

    padding: 7px !important;

    font-size: 18px !important;

    font-weight: 500;

  }

  .panel-body

  {

    background-color: #0E162D !important;

    text-align: center;

    padding-top: 40px;

    padding-bottom: 40px;

    font-size: 48px !important;

  }

  .swal-modal

  {

    background-color: #202943;

  }

  .swal-title

  {

    color: #F7614E;

  }

  .swal-text

  {

    color: #fff;

  }

  .swal-icon--success:before, .swal-icon--success:after

  {

    background-color: #202943;  

  }

  .swal-icon--success__hide-corners {



    background-color: #202943;  

  }

  .lightTabs

  {

    background: #fff !important;

  }

  .lightTabs > li > a

  {

    color: #F7614E !important; 

  }

  #home

  {

    color: white;

    background: #1F2638 !important;

  }

  #rightTab, #rightTab > .crypt-tab-content

  {

    background-color: #1F2638;

  }

  .lightRightTab, .lightRightTab > div, .lightRightTab > div > #home, .lightRightTab >  .crypt-tab-content 

  {

    background-color: #fff !important;

  }

  .light-panel-body

  {

    background: #eee !important;

    color: #1F2638 !important;

  }

  .lightTableVersion, .lightTableVersion > thead, .lightTableVersion > thead > tr, .lightTableVersion > thead > tr > th, .lightTableVersion > tbody, .lightTableVersion > tbody > tr, .lightTableVersion > tbody > tr > td

  {

    background-color: #fff;

    color: #1F2638 !important;

    border: 1px solid #1F2638 !important;

  }

  .lightRightTab > div > #profile > form > div > label, .lightRightTab > div > #messages > form > div > div > label, .lightRightTab > div > #targets > form > div > div > label, .lightRightTab > div > #userSettings > #acc_type_row > form > div > label, .lightRightTab > div > #userSettings > #logRules > form > div > label

  {

    color: #1F2638 !important;

  }

  .lightRightTab > div > #profile > form > div > input, .lightRightTab > div > #profile > form > div > select, .lightRightTab > div > #messages > form > div > div > input, .lightRightTab > div > #targets > form > div > div > input, .lightRightTab > div > #userSettings > #acc_type_row > form > div > input, .lightRightTab > div > #userSettings > #logRules > form > div > input, .lightRightTab > div > #userSettings > #logRules > form > div > select

  {

    color: #1F2638 !important;

    background-color: #eee !important;  

  }

  .round {

  position: relative;

}



.round label {

  background-color: #fff;

  border: 1px solid #ccc;

  border-radius: 50%;

  cursor: pointer;

  height: 28px;

  left: 0;

  position: absolute;

  top: 0;

  width: 28px;

}



.round label:after {

  border: 2px solid #fff;

  border-top: none;

  border-right: none;

  content: "";

  height: 6px;

  left: 7px;

  opacity: 0;

  position: absolute;

  top: 8px;

  transform: rotate(-45deg);

  width: 12px;

}



.round input[type="checkbox"] {

  visibility: hidden;

}



.round input[type="checkbox"]:checked + label {

  background-color: #66bb6a;

  border-color: #66bb6a;

}



.round input[type="checkbox"]:checked + label:after {

  opacity: 1;

}




  </style>

  <?php 

    if(isset($_COOKIE['id']) && isset($_COOKIE['uid'])){

    $userId = filter_input(INPUT_COOKIE, 'id');

    $userUId = filter_input(INPUT_COOKIE, 'uid');


    $db = new database();

    $stmt = $db->db->prepare("SELECT * FROM users WHERE id = :id and uid = :uid");

    $stmt->execute(array(':id' => $userId, ':uid' => $userUId));

    $userDetails = $stmt->fetch(PDO::FETCH_OBJ);

    $fullN = $userDetails->name;

    $splitname = explode(" ", $fullN);

    $loggedIn = true;

        $firstname = $splitname[0];

    $lastname = $splitname[1];

    $accType = $userDetails->acctype;

    $starting_money = $userDetails->starting_money;



  }

  ?>


      <div class="container">
         <div class="row sm-gutters">


                    <div class="col-xs-3 col-sm-3 col-lg-3">

                         
                          <?php 

                          include_once('menu.php');

                          ?>

                      </div>

                      <div class="col-xs-9 col-sm-9 col-lg-9" id="rightTab">


                          <div class="tab-content crypt-tab-content" style="width: 100%;">

                            <div class="tab-pane active" id="profile" style="color: white;padding-top: 20px !important;padding-bottom: 20px !important;">
                                

                                <form method="post" action="">



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

                          <label> First Name </label>

                          <input type="text" class="form form-control newformcontrol" id="fnamepi" name="fname" value="<?php echo $firstname; ?>" placeholder="Name" required />

                        </div>

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

                          <label> Last Name </label>

                          <input type="text" class="form form-control newformcontrol" name="lname" id="lnamepi" value="<?php echo $lastname; ?>" placeholder="Name" required />

                        </div>



                        <div class="col-md-12" style="margin-top: 10px;">

                          <label> User ID </label>

                          <input type="text" class="form form-control newformcontrol" name="userid" id="useridpi" value="<?php echo $userUId; ?>" placeholder="Email" required />

                        </div>



                        <div class="col-md-12" style="margin-top: 10px;">

                          <label> Email </label>

                          <input type="text" class="form form-control newformcontrol" id="emailpi" name="email" value="<?php echo $userDetails->email; ?>" placeholder="Email" required />

                        </div>

                        <div class="col-md-12" style="margin-top: 10px;">

                          <label> Phone Number </label>

                          <input type="text" class="form form-control newformcontrol" id="phnumberpi" name="phone" value="<?php echo $userDetails->phone; ?>" placeholder="Phone" required />

                        </div>

                        <div class="col-md-12" style="margin-top: 10px;">

                          <label>Phone Carrier</label>

                          <select class="form-control" style="width: 100%;height: 50px;" id="pcar" name="pcar">

                            <option value="0">Select Your Phone Carrier</option>

                            <option value="@txt.att.net">AT&T</option>

                            <option value="@tmomail.net">T-Mobile</option>

                            <option value="@vtext.com">Verizon</option>

                            <option value="@messaging.sprintpcs.com">number@messaging.sprintpcs.com</option>

                            <option value="@vtext.com">XFinity Mobile</option>

                            <option value="@vmobl.com">Virgin Mobile</option>

                            <option value="@mmst5.tracfone.com">Tracfone</option>

                            <option value="@mymetropcs.com">Metro PCS</option>

                            <option value="@sms.myboostmobile.com">Boost Mobile</option>

                            <option value="@sms.cricketwireless.net">Cricket</option>

                            <option value="@text.republicwireless.com">Republic Wireless</option>

                            <option value="@msg.fi.google.com">Google Fi</option>

                            <option value="@email.uscc.net">U.S. Cellular</option>

                            <option value="@message.ting.com">Ting</option>

                            <option value="@mailmymobile.net">Consumer Cellular</option>

                            <option value="@cspire1.com">C-Spire</option>

                            <option value="@vtext.com">Page Plus</option>

                          </select>

                        </div>

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

                          <button type="button" id="updatepibtn" onclick="updatepersonal()" class="btn btn-md btn-success" style="border-radius: 0px !important;margin-top: 10px !important;background-color: #F7614E !important;border: none !important;width: 100% !important;color: #fff;">Update Details</button>

                        </div>

                      </form>

                              </div>

                            </div>



                      </div>                      



        </div>
    </div>


<?php
include('view/new_footer_file.php');
?>


	  <script type="text/javascript">
	  	var getCar = '<?=$userDetails->pcarrier; ?>';
	  	$("#pcar").val(getCar).change();
	</script>
  <script type="text/javascript">
      
      $(function() {

            var firstcharsale = '<?=$firstSaleChar; ?>';
            var firstcharbuy = '<?=$firstBuyChar; ?>';
            var firstcharclose = '<?=$firstCloseChar ?>';

            $("#saleskey1").val(firstcharsale).change();
            $("#buykey1").val(firstcharbuy).change();
            $("#closekey1").val(firstcharclose).change();

      });

  </script>


   <script type="text/javascript">
    
      function updatepersonal()
      {
        var fname = $("#fnamepi").val();
        var lname = $("#lnamepi").val();
        var useridpi = $("#useridpi").val();
        var email = $("#emailpi").val();
        var phnumberpi = $("#phnumberpi").val();
        var pcar = $("#pcar").val();

        var uid = '<?=$userId; ?>';

        $("#updatepibtn").html('Please wait');

         $.post('controller/updateinfo.controller.php', {action:'pi', fname:fname, lname:lname, useridpi:useridpi, email:email, phnumberpi:phnumberpi, pcar:pcar, uid:uid})
              .done(function(data){

                var result = JSON.parse(data);
                var resu = result.result;
                if (resu == 'success') {

            swal("You have successfully updated personal information", {
            icon: "success",
            dangerMode:true,
            });

            $("#updatepibtn").html('Update Details');

                }

          });


      }
    

  </script>
