<?php
include"initialize_page.php";
include"systemfunctions.php";
require "../twilio_sms.php";





$t_u_phonenumber=user_details($user_id,"x_phonenumber");
$t_account_query = "select * from x_anotheracc where x_userid='$user_id' and x_for_main='main_account'";			
$t_account_result = mysqli_query($con,$t_account_query);
$t_account_row = mysqli_fetch_array($t_account_result);

$acc_id = $t_account_row['x_id'];

$t_fund_trans_query = "select * from x_fundtransfer where x_userid='$user_id' and x_code=".$_SESSION['temp_trans_code']."";
$t_fund_trans_result = mysqli_query($con,$t_fund_trans_query);
$t_fund_trans_row = mysqli_fetch_array($t_fund_trans_result);

// echo "<pre>";
// print_r($t_fund_trans_row);
// exit;

$t_useraccount=user_details($acc_id,"x_time");
$t_tttx=date("l jS \of F Y h:i:s A");
$email_user_balance=user_details($acc_id ,"x_totalbalance");

// $t_message_text = 'Debit Alert,
// Acc:'.$t_useraccount.',
// Amt:'.$t_fund_trans_row['x_amount'].' 
// Desc: '.$t_fund_trans_row['x_description'].'
// Time:'.$t_tttx.'
// Avail Bal:'.$email_user_balance;


$t_message_text="Debit Alert, Acc: ".$t_useraccount.", Amt:".$t_fund_trans_row['x_amount'].", Desc:". $t_fund_trans_row['x_description'].",  Time:".$t_tttx." , Avail Bal:".$email_user_balance;
sendMessage($t_u_phonenumber,$t_message_text);




$step=0;
if(isset($_REQUEST['url']) && ($_REQUEST['url']=='local2.php' || $_REQUEST['url']=='local2b.php'))
    $step=1;
if(isset($_REQUEST['url']) && ($_REQUEST['url']=='local3.php' || $_REQUEST['url']=='local3b.php'))
    $step=2;
if(isset($_REQUEST['url']) && ($_REQUEST['url']=='local4.php' || $_REQUEST['url']=='local4b.php'))
    $step=3;
if(isset($_REQUEST['url']) && ($_REQUEST['url']=='local5.php' || $_REQUEST['url']=='local5b.php'))
    $step=4;

if(website_settingdata("noofstepinfundtransfer")==1){
if (isset($_REQUEST['url']) && $_REQUEST['url'] == 'complete.php') {
    $value = 0;
    $maxValue = 100;
    $speed = 30;
    $set = 50;
    $delay=500;
} 
}

if(website_settingdata("noofstepinfundtransfer")==2){
if (isset($_REQUEST['url']) && $_REQUEST['url'] == 'complete.php') {
    $value = 50;
    $maxValue = 100;
    $speed = 15;
    $set = 50;
    $delay=1250;
} else {
    $value = 0;
    $maxValue = 50;
    $speed = 5;
    $set = 0;
    $delay=1200;
}
}

if(website_settingdata("noofstepinfundtransfer")==3){
if (isset($_REQUEST['url']) && $_REQUEST['url'] == 'complete.php') {
    $value = 66;
    $maxValue = 100;
    $speed = 15;
    $set = 50;
    $delay=1250;
} else if($step==1) {
    $value = 0;
    $maxValue = 33;
    $speed = 5;
    $set = 0;
    $delay=1200;
}
else if(isset($_REQUEST['url']) && ($_REQUEST['url']=='local5.php' || $_REQUEST['url']=='local5b.php')) {
    $value = 33;
    $maxValue = 66;
    $speed = 5;
    $set = 0;
    $delay=1200;
}
}

if(website_settingdata("noofstepinfundtransfer")==4){
if (isset($_REQUEST['url']) && $_REQUEST['url'] == 'complete.php') {
    $value = 75;
    $maxValue = 100;
    $speed = 15;
    $set = 50;
    $delay=1250;
} else if($step==1) {
    $value = 0;
    $maxValue = 25;
    $speed = 5;
    $set = 0;
    $delay=1200;
}
else if($step==2) {
    $value = 25;
    $maxValue = 50;
    $speed = 5;
    $set = 0;
    $delay=1200;
}
else if(isset($_REQUEST['url']) && ($_REQUEST['url']=='local5.php' || $_REQUEST['url']=='local5b.php')) {
    $value = 50;
    $maxValue = 75;
    $speed = 5;
    $set = 0;
    $delay=1200;
}
}

if(website_settingdata("noofstepinfundtransfer")==5){
if (isset($_REQUEST['url']) && $_REQUEST['url'] == 'complete.php') {
    $value = 81;
    $maxValue = 100;
    $speed = 15;
    $set = 50;
    $delay=1250;
} else if($step==1) {
    $value = 0;
    $maxValue = 20;
    $speed = 5;
    $set = 0;
    $delay=1200;
}
else if($step==2) {
    $value = 21;
    $maxValue = 40;
    $speed = 5;
    $set = 0;
    $delay=1200;
}
else if($step==3) {
    $value = 41;
    $maxValue = 60;
    $speed = 5;
    $set = 0;
    $delay=1200;
}
else if(isset($_REQUEST['url']) && ($_REQUEST['url']=='local5.php' || $_REQUEST['url']=='local5b.php')) {
    $value = 61;
    $maxValue = 80;
    $speed = 5;
    $set = 0;
    $delay=1200;
}
}
?>


<?php include('resources/header.php') ?>
<title>Please Wait</title>
<meta http-equiv="refresh" content="120;url=<?php echo website_settingdata('x_weburl'); ?>user/<?php
if (isset($_REQUEST['url'])) {
    echo $_REQUEST['url'];
}
?>" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<?php include('resources/css-file.php') ?>
<script>
    (function (i, s, o, g, r, a, m) {
        i['GoogleAnalyticsObject'] = r;
        i[r] = i[r] || function () {
            (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date();
        a = s.createElement(o),
                m = s.getElementsByTagName(o)[0];
        a.async = 1;
        a.src = g;
        m.parentNode.insertBefore(a, m)
    })(window, document, 'script', 'js/analytics.js', 'ga');

    ga('create', 'UA-19175540-9', 'auto');
    ga('send', 'pageview');
</script>
<?php include('resources/navigation.php') ?> 
<!-- Dashboard wrapper starts -->
<link rel="stylesheet" type="text/css" href="<?php echo website_settingdata('x_weburl'); ?>user/css/progressbar.css" />
<script type="text/javascript" src="<?php echo website_settingdata('x_weburl'); ?>user/js/progressbar.js"></script>
<div class="dashboard-wrapper">
    <div class="main-container" >				
        <div style="background-image: url('img/bg1.jpg');background-size: cover;background-repeat: no-repeat;position: absolute;top: 0;left: 0;width: 100%;height: 100%;opacity: 0.7;" ></div>
        <div class="row">
            <div class="col-sm-12 ac-summ" >
                <h2>Please Wait....</h2>
            </div>
        </div>
        <div class="col-sm-12 text-center" style="margin-top: 126px;">
            <h3>Transfer in progress, do not quit or refresh your browser.</h3>
        </div>
        <div class="row gutter">
            <div class="col-sm-6 col-md-offset-3">
                 <div class="progress skill-bar ">
                <div class="progress-bar progress-bar-striped btn-info" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="<?php echo $maxValue; ?>">
                    <span class="skill"> <i class="val">0%</i></span>
                </div>
            </div>
            </div>
        </div>
        <div class="row gutter" style="display: none;">
            <div class="col-sm-4  col-sm-offset-4">
                <div style="width: 100%; height: 100%; margin-top: 80px; margin-left: -75px">
                    <div id="my_progress_bar_1" style="position: relative; top: 45%; margin: 0px auto;"></div>
                </div>
               
                <script type="text/javascript">

    var myProgressBar = null
    var timerId = null

    function loadProgressBar() {
        myProgressBar = new ProgressBar("my_progress_bar_1", {
            borderRadius: 20,
            width: 500,
            height: 30,
            value: <?php echo $value; ?>,
            maxValue: <?php echo $maxValue; ?>,
            orientation: ProgressBar.Orientation.Horizontal,
            direction: ProgressBar.Direction.LeftToRight,
            animationStyle: ProgressBar.AnimationStyle.LeftToRight1,
            animationSmoothness: ProgressBar.AnimationSmoothness.Smooth1,
            animationSpeed: 3,
            imageUrl: 'images/h_fg8.png',
            backgroundUrl: 'images/h_bg2.png'
        });
         myProgressBar.setValue(<?php echo $set; ?>);
        timerId = window.setInterval(function () {

            if (myProgressBar.value >= myProgressBar.maxValue) {
         /*         window.location.href="<?php echo website_settingdata('x_weburl'); ?>user/<?php
if (isset($_REQUEST['url'])) {
    echo $_REQUEST['url'];
}
?>"; */
                myProgressBar.setValue(0);
            } else {
                myProgressBar.setValue(myProgressBar.value + <?php echo $speed; ?>);

                break;
            }
        },
                <?php echo $delay; ?>);
    }
    loadProgressBar();
                </script>
            </div>
        </div>	
        </br>
    </div>
    <!-- Main container ends -->
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $('.progressbar_right').css("margin-right", "2px");
    });
</script>
<!-- Dashboard wrapper ends -->
<?php include('resources/footer.php') ?>
<?php include('resources/js-file.php') ?>
<script src="js/jQuery.style.switcher.js"></script>

<style type="text/css">
    .progress {
  height: 35px;

}
.progress .skill {
 
  line-height: 35px;
  padding: 0;
  margin: 0 0 0 20px;
  text-transform: uppercase;
  position: absolute;
  left: 45%;
  font-size: 15px;
  color: #000;
}
.progress .skill .val {
  
  font-style: normal;
  
}

.progress-bar {
  text-align: left;
  transition-duration: 0.5s;
}
</style>
<script type="text/javascript">
     $(document).ready(function() {
        
       
        var ti=<?php echo $value; ?>;
       
            $('.val').html(ti+"%");
            $('.progress .progress-bar').css("width",ti+"%");
      window.setInterval(function () {
        
        if(ti<<?php echo $maxValue; ?>){
        ti+=<?php echo website_settingdata("noofstepinfundtransfer");?>;
        
        if(ti>100)
            ti=100;
        if(ti>=<?php echo $maxValue; ?>)
        ti=<?php echo $maxValue; ?>;
        
        $('.val').html(ti+"%");
        $('.progress .progress-bar').css("width",ti+"%");
        }
        if(ti>=<?php echo $maxValue; ?>)
             window.setInterval(function () {
               /*   window.location.href="<?php echo website_settingdata('x_weburl'); ?>user/<?php
if (isset($_REQUEST['url'])) {
    echo $_REQUEST['url'];
}
?>"; */
},1000)
    },<?php echo $delay; ?>);


    });
</script>