  <?php 

  $myHttp = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';

  $myDomain = $_SERVER['HTTP_HOST'];



  $url = "https://".$myDomain;





  ?>









  <?php

  include_once("classes/database.class.php");

  include_once("classes/oanda.php");

  $loggedIn = false;

  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);

    $account = new oandaAPI();

    $account->retrieveAccount($userDetails->accountId);

    $loggedIn = true;

    $getAccountType = $userDetails->acctype;



    $getTheme = $db->db->prepare("SELECT * FROM layout WHERE layoutname = 'theme' AND user = '$userId'");

    $getTheme->execute();

    $getThemeValue = $getTheme->fetch();

    $getLayoutValue = $getThemeValue['layout'];





    $getkeys = $db->db->prepare("SELECT * FROM shortkeys where uid = '$userId'");

    $getkeys->execute();

    $keysname = $getkeys->fetch();







  }



  ?>



  <?php 



$salesKeysSetting = $keysname['sales'];

$firstSaleChar = substr($salesKeysSetting, 0, 3);

$secondChar = substr($salesKeysSetting, 3, 1);



$buyKeySetting = $keysname['buy'];

$firstBuyChar = substr($buyKeySetting, 0, 3);

$secondBuyChar = substr($buyKeySetting, 3, 1);



$closeKeySetting = $keysname['close'];

$firstCloseChar = substr($closeKeySetting, 0, 3);

$secondCloseChar = substr($closeKeySetting, 3, 1);



?>







  <!DOCTYPE html>

  <html lang="en">

     <meta http-equiv="content-type" content="text/html;charset=UTF-8" />

     <head class="crypt-dark">

        <meta charset="UTF-8">

        <title>Invata.io</title>

        <link rel="stylesheet" href="dashboard_assets/bootstrap/css/bootstrap.min.css">

        <link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">

  <script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>

        <link rel="stylesheet" href="dashboard_assets/css/style.css">

        <link rel="stylesheet" href="dashboard_assets/css/icons.css">

        <link rel="stylesheet" href="dashboard_assets/css/ui.css">

        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

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

        <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> 





        <style type="text/css">

          #tablelayout

          {

             background-color: #0E162D;

          }

        </style>



        <style type="text/css">

          

          .crypt-light

          {

            background: #aaa;

          }

          .themeLabel

          {

            padding-top: 5px !important;

            padding-bottom: 5px !important;

          }

          .hmLightView

          {

            background: #fff !important;

          }

          .hmLightView > div > h3{

            color: #0E162D !important;

          }

          .hmLightTable > thead > tr > th

          {

            border: 1px solid #0E162D !important;



          }



        </style>





















        <style type="text/css">

           .newformcontrol

           {

              height: 56px !important;

           }

           .modal-content { background-color: #202943 !important; }

           label { color: white; }

        </style>

        <?php 

        if ($loggedIn == false) {

            # code...

            ?>

            <script type="text/javascript">

              location.href = "<?=$url; ?>";

            </script>

            <?php 

          }



        ?>



        <style type="text/css">

          .toggle-off

          {

            color: #fff !important;

          }

        </style>

        <style type="text/css">

          #tableAlert

          {

            background-color: #131722;

            color:white;

          }

        </style>

        <style type="text/css">

          .commandInput

          {

            background:#fff !important;

          }

          .commandInput > div > .inputlayout > h3

          {

            color: #0E162D !important;

          }

          .commandInput > div > .inputlayout > select, .commandInternalLayout > .no-gutters > div > .row > div > select

          {

            background: #eee !important;

            border: 1px solid #aaa !important;

            color: #0E162D !important;

          }

          .commandInput > div > .inputlayout > input, .commandInput > div > .inputlayout > textarea, .commandInternalLayout > .no-gutters > div > .row > div > input 

          {

            background: #eee !important;

            border: 1px solid #aaa !important;

            color: #0E162D !important;

          }

          .commandInternalLayout

          {

            background:#fff !important;

          }



           .commandInternalLayout > h3

          {

            background: transparent !important;

          }

          .alertLightLayout

          {

            background:#fff !important;

          }

          .alertLightLayout > h3

          {

            background: transparent !important;

          }

          .alertLightLayout > .no-gutters > div > div > table

          {

            background-color: #eee !important;

            color: #0E162D !important;

          }

          .lightChartVersion, .lightBoxVersion, .lightTableVersion

          {

            background-color: #fff !important;

          }

          .lightTableVersion > table > thead > tr > th

          {

            background: #eee !important;

            color: #0E162D !important;

            border: 1px solid #eee !important;

          }

          .lightTableVersion > table > tbody > tr > td

          {

            background: #fff !important;

            color: #0E162D !important;

            border: 1px solid #eee !important;

          }

          

          .lightTableVersion > table

          {

            background-color: #fff !important;

            background: #fff !important;

          }

          #boxlayout

          {

            background-color: #1f2638;

          }

          .lightBoxes

          {

            background-color: #eee !important;

          }

           .panel-body

            {

              background-color: #0E162D !important;

              text-align: center;

              font-size: 48px !important;



            }

          .light-panel-body

          {

            background-color: #fff !important;

          }

            .price

            {

              font-size: 32px !important;

              color: #fff;

              text-align: center;

            }

            .price > sup

            {

              font-size: 18px !important;

            }

            .mainPrice

            {

              font-size: 20px !important;

              color: #fff;

              text-align: left; 

              margin-bottom: -10px;

              margin-left: 20px;

              padding-top: 30px;

            }



            .LightMainPrice, .LightPrice

            {

              color: #0E162D !important;

            }
            .switch-toggle label:nth-child(2):nth-last-child(4), .switch-toggle label:nth-child(2):nth-last-child(4) ~ label, .switch-toggle label:nth-child(2):nth-last-child(4) ~ a
    {
        padding-top: 10px;
        padding-bottom: 10px;
        font-size: 14px;
    }
    .switch-toggle.switch-candy, .switch-light.switch-candy > span {

      background-color: #F7614E !important
    }
    .heatmaptable > thead > tr > th
    {
      color: #fff !important;
      padding-top: 10px;
      padding-bottom: 10px;
    }
    .heatmaptable > tbody > tr > td
    {
      color: #fff;
    }



        </style>











        <style type="text/css">

          



              @keyframes ticker {

    0% { transform: translate3d(1.5%, 0, 0); }

    100% { transform: translate3d(-100%, 0, 0); }

  }

  .tcontainer{

    width: 100%;

    overflow: hidden;

    margin-bottom: 20px;

  }

  .ticker-wrap {

    width: 100%;

    padding-left: 100%;

    background-color: #000;

  }

  .ticker-move {

    display: inline-block;

    white-space: nowrap;

    padding-right: 100%;

    animation-iteration-count: infinite;

    animation-timing-function: linear;

    animation-name: ticker;

    animation-duration: 300s;

  }

  .ticker-move:hover{

    animation-play-state: paused;

  }

  .ticker-item{

    display: inline-block;

    padding: 1rem 2rem;

    color: #fff;

  }





        </style>













     </head>

     <body class="crypt-dark">

        <header>

           <div class="container-full-width">

              <div class="crypt-header">

                 <div class="row">

                    <div class="col-xl-2 col-lg-2 col-md-2 col-sm-2">

                       <div class="row">

                          <div class="col-xs-2">

                             <div class="crypt-logo" style="padding-left: 20px;padding-top:10px;padding-bottom:"><img src="images/invata-image-logo.png" alt="" style="height:50px !important;"></div>

                          </div>

                       </div>

                    </div>

                    <div class="col-xl-10 col-lg-10 col-md-10 d-none d-md-block d-lg-block">

                       <ul class="crypt-heading-menu fright">

                          <li><a href="dashboard.php">Dashboard</a></li>

                          <li><a href="trading-chart.php">Charting</a></li>

                          <li><a href="true-range.php">ATR</a></li>


                          <li class="crypto-has-dropdown"><a href="javascript:void(0)">Trading News</a>

                              <ul class="crypto-dropdown">

                                  <li><a href="news.php">News</a></li>

                                  <li><a href="stockwit.php">Stockwit</a></li>

                                   <li><a href="twitter-feeds.php">Twitter Feeds</a></li>

                              </ul>

                          </li>



                         

                          <li><a href="economic-calendar.php">Stats</a></li>

                          <li><a href="forex-screener.php">Forex Screener</a></li>

                          <li><a href="forex-hours.php">Forex Hours</a></li>

                          

                           <li><a href="allinone.php">Layout</a></li>

                          <li class="crypto-has-dropdown"><a href="javascript:void(0)">Logged In As <?=$userDetails->name; ?></a>

                              <ul class="crypto-dropdown">

                                <li><a href="account.php">Account</a></li>

                                  <li><a href="calendar.php">Trade Calendar</a></li>
                                   <li><a href="trade-history.php">Trade History</a></li>

                                  <li><a href="logout.php">Logout</a></li>

                              </ul>

                          </li>

                       </ul>

                    </div>

                   

                    <i class="menu-toggle pe-7s-menu d-xs-block d-sm-block d-md-none d-sm-none"></i>

                 </div>

              </div>

           </div>

        </header>





<?php 



$tickerAvail = false;



    $getTicker = $db->db->prepare("SELECT * FROM tickersetting WHERE user = '$userId'");

    $getTicker->execute();

    $tickerSettingGet = $getTicker->fetch();



    if (empty($tickerSettingGet)) {

      # code...

      $tickerAvail = false;

    }else{


      if ($tickerSettingGet['ticker'] == '1') {

        # code...

        $tickerAvail = true;

      }else{

        $tickerAvail = false;

      }



    }







$activeTikers = array();



$get_tikers = $db->db->prepare("SELECT * FROM tickers WHERE userid = '$userId'");



$get_tikers->execute();



$user_tickers = $get_tikers->fetch();



if (!empty($user_tickers)) {

# code... 

$activeTikers = unserialize($user_tickers['tickers']);



}











?>

<?php 

if ($tickerAvail == true) {
  # code...


?>



<div class="tcontainer" id="tcontainer">

    <div class="ticker-wrap" id="tickerWrapping">

      <div class="ticker-move" id="tickerMovalble">

       

        <?php 

          $getallcurforticker = $db->db->prepare("SELECT * FROM allcurrencies WHERE id = '1'");

          $getallcurforticker->execute();

          $tickerchoicesss = $getallcurforticker->fetch();



          $tickerchoicesarray = unserialize($tickerchoicesss['cur']);



          foreach ($tickerchoicesarray as $tChoice) {

            # code...

            ?>

             <div class="ticker-item" id="<?=$tChoice ?>" style="display: none;"><i id="<?=$tChoice; ?>_icon"></i>&nbsp;&nbsp;<?=$tChoice; ?>&nbsp;&nbsp;<span style='font-weight:700;' id="<?=$tChoice ?>_price"></span></div>

            <?php 

          }



        ?>

      </div>

  </div>

</div>


<?php 

}
?>




<?php 





$tjsonarray = array();



if (empty($activeTikers)) {

  # code...

  $getallcur = $db->db->prepare("SELECT * FROM allcurrencies WHERE id = '1'");

  $getallcur->execute();

  $fetchallcur = $getallcur->fetch();



  $tjsonarray = unserialize($fetchallcur['cur']);



}else{

  $tjsonarray = $activeTikers;

}





$tjsonarray = json_encode($tjsonarray);



?>







    <!-- Trial Send Command Modal -->

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

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

      <div class="modal-content">

        <div class="modal-header">

          <h5 class="modal-title" id="exampleModalLongTitle">Send Command</h5>

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

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

          </button>

        </div>

        <div class="modal-body">

          <div class="row">



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

                <select placeholder="Identifier" class="form form-control newformcontrol" name="TrialsymbolCommand" id="TrialsymbolCommand" >

                              <option value="SGDCHF">SGDCHF </option>

                              <option value="NZDCHF">NZDCHF</option>

                              <option value="AUDCHF">AUDCHF</option>

                              <option value="SGDJPY">SGDJPY</option>

                              <option value="ZARJPY">ZARJPY</option>

                              <option value="TRYJPY">TRYJPY</option>

                              <option value="NZDCAD">NZDCAD</option>

                              <option value="GBPNZD">GBPNZD</option>

                              <option value="GBPCHF">GBPCHF</option>

                              <option value="GBPCAD">GBPCAD</option>

                              <option value="GBPAUD">GBPAUD</option>

                              <option value="EURNZD">EURNZD</option>

                              <option value="EURCHF">EURCHF</option>

                              <option value="EURCAD">EURCAD</option>

                              <option value="CADCHF">CADCHF</option>

                              <option value="AUDNZD">AUDNZD</option>

                              <option value="AUDCAD">AUDCAD</option>

                              <option value="GBPUSD">GBPUSD</option>

                              <option value="USDCHF">USDCHF</option>

                              <option value="USDCAD">USDCAD</option>

                              <option value="NZDUSD">NZDUSD</option>

                              <option value="NZDJPY">NZDJPY</option>

                              <option value="GBPJPY">GBPJPY</option>

                              <option value="EURGBP">EURGBP</option>

                              <option value="EURAUD">EURAUD</option>

                              <option value="CHFJPY">CHFJPY</option>

                              <option value="CADJPY">CADJPY</option>

                              <option value="AUDJPY">AUDJPY</option>

                              <option value="AUDUSD">AUDUSD</option>

                              <option value="EURJPY">EURJPY</option>

                              <option value="USDJPY">USDJPY</option>

                              <option value="EURUSD">EURUSD</option>

                  </select>

            </div>



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

                        <select name="TrialorderCommand" id="TrialorderCommand" class="form form-control newformcontrol" style="margin-top: 15px;">

                        <option value="Buy">Buy</option>

                        <option value="Sell">Sell </option>

                        <option value="Close">Close</option>

                        </select>

            </div>

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

               <input type="number" class="form form-control newformcontrol" id="orderCommandPrice" value="" placeholder="Unit Size" style="height: 50px;margin-top: 15px;" />

            </div> 

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

               <div class="row" style="margin-top: 15px !important;">

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

                  </div>

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

                    <button type="button" class="btn btn-secondary" data-dismiss="modal" style="width: 100%;">Close</button>    

                  </div>

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

                    <button type="button" class="btn btn-primary pull-right" style="background-color: #F15A24;width: 100%;border: none;">Send Command</button>    

                  </div>

                </div>

            </div> 

          </div>

        </div>

      </div>

    </div>

  </div>

  <!-- END Modal -->