<?php
// お問い合わせ入力画面のURL
define("CONTACT_URL", "http://bitrush.fun");

require_once (dirname(__FILE__). '/mail_common/index.php');
$title = 'BitRush Application Form';
$title_data_lang = 'h1';
require_once (dirname(__FILE__). '/_parts/header.php');
?>
        <?php /*
        <p data-lang="msg">必須項目は全て入力していただき、申込手続きをお願いします。</p>
        */ ?>

        <form class="needs-validation row g-3" name="form" action="confirm.php" method="post" enctype="multipart/form-data" novalidate>
          <input type="hidden" name="token" value="<?php echo $token; ?>">

          <?php if(!empty($_SESSION['errmsg'])): ?>
            <div class="alert alert-danger" role="alert"><?php echo $_SESSION['errmsg']; ?></div>
          <?php endif; ?>

          <!-- fullName -->
          <div class="col-md-12">
            <label class="d-flex align-items-center" data-lang="fullName" for="fullName">User　ID<span class="badge bg-danger ms-1">Required</span></label>
            <input type="text" class="form-control" id="fullName" name="fullName" value="<?php if (isset($_SESSION['data']['fullName'])): echo $_SESSION['data']['fullName']; endif; ?>" aria-describedby="fullNameHelp" minlength="6" required>
            <small id="fullNameHelp" class="form-text" data-lang="fullNameHelp">Please enter at least 6 single-byte alphanumeric characters and at least 3 digits for numbers.</small>
            <div class="invalid-feedback" data-lang="valid_required">
                Please fill in. Please fill in 8 single-byte numbers.
            </div>
          </div>

          <!-- country -->
          <div class="col-md-12">
            <label class="d-flex align-items-center" for="country">Country<span class="badge bg-danger ms-1">Required</span></label>
            <select class="form-control" name="country" required>
                <?php require_once (dirname(__FILE__). '/_parts/select_list_country.php'); ?>
            </select>
            <div class="invalid-feedback">
              Please select
            </div>
          </div>

          <!-- tell -->
          <div class="col-md-12">
            <label class="d-flex align-items-center" data-lang="tell" for="tell">Phone number<span class="badge bg-danger ms-1">Required</span></label>
            <input type="tell" class="form-control" id="tell" name="tell" aria-describedby="tellHelp" value="<?php if (isset($_SESSION['data']['tell'])): echo $_SESSION['data']['tell']; endif; ?>" required>
            <small id="tellHelp" class="form-text" data-lang="tellHelp">Example: 09012345678</small>
            <div class="invalid-feedback" data-lang="valid_required">
                Please fill in
            </div>
          </div>

          <!-- introducer -->
          <div class="col-md-12">
            <label class="d-flex align-items-center" data-lang="introducer" for="introducer">Referrer User ID<span class="badge bg-danger ms-1">Required</span></label>
            <input type="text" class="form-control" id="introducer" name="introducer" value="<?php if (isset($_SESSION['data']['introducer'])): echo $_SESSION['data']['introducer']; endif; ?>" required>
            <div class="invalid-feedback" data-lang="valid_required">
                Please fill in
            </div>
          </div>

          <!-- Connection User ID -->
          <div class="col-md-12">
            <label class="d-flex align-items-center" for="connUserId">Connection User ID</label>
            <input type="text" class="form-control" id="connUserId" name="connUserId" value="<?php if (isset($_SESSION['data']['connUserId'])): echo $_SESSION['data']['connUserId']; endif; ?>"  aria-describedby="connUserIdHelp">
            <small id="connUserIdHelp" class="form-text">If not filled in, it will be positioned to the left of the left group of the referrer.</small>
            <div class="invalid-feedback" data-lang="valid_required">
                Please fill in
          </div>

          <!-- RIGHT or LEFT -->
          <div class="col-md-12">
            <label class="d-flex align-items-center" for="connGroup">RIGHT or LEFT</label>
            <select class="form-control" name="connGroup" aria-describedby="connGroupHelp">
              <option value="">--</option>
              <option value="LEFT" <?php if (isset($_SESSION['data']['connGroup']) && $_SESSION['data']['connGroup'] == 'LEFT'): echo 'selected'; endif; ?>>LEFT</option>
              <option value="RIGHT" <?php if (isset($_SESSION['data']['connGroup']) && $_SESSION['data']['connGroup'] == 'RIGHT'): echo 'selected'; endif; ?>>RIGHT</option>
            </select>
            <small id="connGroupHelp" class="form-text">If not selected, it will be positioned to the left of the connection user.</small>
            <div class="invalid-feedback">
              Please select in
            </div>
          </div>

          <!-- Gmail address for Bustabit -->
          <div class="col-md-12">
            <label class="d-flex align-items-center" data-lang="email" for="email">Gmail address for Bustabit<span class="badge bg-danger ms-1">Required</span></label>
            <input type="email" class="js-manual-valid form-control mb-2" id="email" name="email" placeholder="info@example.com" aria-describedby="emailHelp" value="<?php if (isset($_SESSION['data']['email'])): echo $_SESSION['data']['email']; endif; ?>" required>
            <div class="invalid-feedback mb-2" data-lang="valid_required">
                Please fill in
            </div>
            <input type="email" class="js-manual-valid form-control" id="emailConfirm" name="emailConfirm" placeholder="for confirmation" aria-describedby="emailHelp" value="<?php if (isset($_SESSION['data']['emailConfirm'])): echo $_SESSION['data']['emailConfirm']; endif; ?>" required>
            <div class="invalid-feedback" data-lang="valid_same">
                No match
            </div>

          </div>

          <!-- Gmail password for Bustabit -->
          <div class="col-md-12">
            <label class="d-flex align-items-center" for="gmailPassBustabit">Gmail password for Bustabit<span class="badge bg-danger ms-1">Required</span></label>
            <input type="text" class="form-control" id="gmailPassBustabit" name="gmailPassBustabit" value="<?php if (isset($_SESSION['data']['gmailPassBustabit'])): echo $_SESSION['data']['gmailPassBustabit']; endif; ?>" required>
            <div class="invalid-feedback" data-lang="valid_required">
                Please fill in
            </div>
          </div>

          <!-- Application Plans -->
          <div class="col-md-12">
            <label for="applicationPlans">Application Plans<span class="badge badge-danger ms-1">Required</span></label>
            <select class="form-control" name="applicationPlans" required>
              <option value="">--</option>
              <option value="①Bronze Rush Plan 1000 USDT">①Bronze Rush Plan 1000 USDT</option>
              <option value="②Silver Rush Plan 2000 USDT">②Silver Rush Plan 2000 USDT</option>
              <option value="③Gold Rush Plan 3000 USDT">③Gold Rush Plan 3000 USDT</option>
            </select>
            <div class="invalid-feedback">
              Please select in
            </div>
          </div>

          <!-- text:usdt_address -->
          <div class="col-md-12">
            <label data-lang="usdtAddressLabel" for="usdtAddress">Your USDT address<span class="badge bg-danger ms-1">Required</span></label>
            <input type="text" class="js-manual-valid form-control" id="usdtAddress" name="usdt_address" value="<?php if (isset($_SESSION['data']['usdt_address'])): echo $_SESSION['data']['usdt_address']; endif; ?>" required>
            <div class="invalid-feedback" data-lang="valid_required">
                Please fill in
            </div>
          </div>

          <!-- radio:usdtNet -->
          <fieldset id="usdtNet" class="form-group">
            <legend class="col-form-label" data-lang="usdtAddressNet">USDT Network<span class="badge bg-danger ms-1">Required</span></legend>
            <div class="col-md-12 form-check">
              <input type="radio" class="form-check-input" id="erc20" name="usdtNet" value="ERC20" required>
              <label class="form-check-label" for="erc20">ERC20</label>
            </div>
            <div class="form-check">
              <input type="radio" class="form-check-input" id="trc20" name="usdtNet" value="TRC20" required>
              <label class="form-check-label" for="trc20">TRC20</label>
            </div>
            <div class="form-check">
              <input type="radio" class="form-check-input" id="bep20" name="usdtNet" value="BEP20" required>
              <label class="form-check-label" for="bep20">BEP20</label>
              <div class="invalid-feedback" data-lang="valid_required">
                  Please fill in
              </div>
            </div>
          </fieldset>

          <!-- text:transaction -->
          <div class="col-md-12 mb-3">
            <label for="transaction">If you have already paid the setup fee, please list the transaction.</label>
            <input type="text" class="form-control" id="transaction" name="transaction" value="<?php if (isset($_SESSION['data']['transaction'])): echo $_SESSION['data']['transaction']; endif; ?>" aria-describedby="transactionHelp">
            <small id="transaction" class="form-text" data-lang="transaction">
              ●USDT remittance address for setup fees<br>
              ⚠Do not make a mistake with the network. If you send money to the wrong network, you will lose your funds. Please be careful.<br>
              ” Ethereum network（ERC20）”<br>
              0x17bd79eFF1545c2D9a5A2b449aB6332CC28Fb8cb<br>
              <br>
              ”Binance Smart Chain network（BEP20）”<br>
              0x17bd79eFF1545c2D9a5A2b449aB6332CC28Fb8cb<br>
              <br>
              ”Tron network（TRC20）”<br>
              TB7cxUUTG5r8JjbK75gQUyVKd376Kt5g37
            </small>
            <div class="invalid-feedback" data-lang="valid_required">
                Please fill in
            </div>
          </div>

          <div class="col-md-12">
            <legend class="col-form-label">Please review and check the following information.<span class="badge bg-danger ms-1">Required</span></legend>
            <div class="d-flex mb-3">
              <input id="agree1" type="checkbox" class="flex-shrink-0 form-check-input me-2" required><label for="agree1">
                  I am over the age of majority. I understand the laws regarding casinos in my country of residence. I am participating in the online casino Bustabit and using BitRush at my own discretion and risk.<br>
In using Bustabit, I understand and agree that "the management cannot provide legal advice or warranties regarding the use of the service and the management makes no representations regarding the legality of the service in your country of residence".<br>
I understand and accept all risks of participating in an online casino using crypto assets.
              </label>
            </div>

            <div class="d-flex mb-3">
                <input id="agree2" type="checkbox" class="flex-shrink-0 form-check-input me-2" required><label for="agree2">
                    I understand that management reserves the right to change or discontinue the terms, conditions, specifications, or service for a variety of reasons, including commercial, legal, and customer service reasons.<br>
     I will use the service in good faith toward BitRush and other users. I promise that I will not use BitRush to engage in collusion, cheating, fraud, or criminal activity, and I understand that if management that I am using BitRush in bad faith, they may shut down my BitRush system and revoke all my rights within the service. I understand that in the aforementioned situation, my loss will be my own responsibility. I will not make any claim for any money or profit lost by me in the aforementioned situation.
                </label>
            </div>

            <div class="d-flex mb-3">
                <input id="agree3" type="checkbox" class="flex-shrink-0 form-check-input me-2" required><label for="agree3">
                    I will be responsible for managing my Bustabit account after BitRush is activated.<br>
    I will not make any factual or legal claim or demand of any kind against any third party for any damages arising out of or in connection with the use of BitRush.
                </label>
            </div>

            <div class="d-flex mb-3">
                <input id="agree4" type="checkbox" class="flex-shrink-0 form-check-input me-2" required><label for="agree4">
                    I acknowledge and agree that in the event of any disadvantages to me, the operation shall not be obligated to pay those benefits. I shall immediately notify the management determines of the error and agree to refund any profit that may have already been paid as a result of human or system error or mistake.<br>
    I will not make any claim against the management (including agents), partners (affiliates) or suppliers for any loss, including loss of profits, resulting from errors on the part of the operation or myself.
                </label>
            </div>

            <div class="d-flex mb-3">
                <input id="agree5" type="checkbox" class="flex-shrink-0 form-check-input me-2" required><label for="agree5">
                    I understand that the management makes no further promises or warranties with respect to the BitRush system and excludes (to the fullest extent permitted by law) all other implied warranties with respect thereto.<br>
The management acknowledges and agrees that operation shall not be liable for any loss or damage (including, but not limited to, loss of data, profits, business, opportunity, goodwill, reputation, etc.), future unanticipated business interruption or loss in connection with contract, tort, or negligence, and that operation shall not otherwise be liable.
                </label>
            </div>

            <div class="d-flex mb-3">
                <input id="agree6" type="checkbox" class="flex-shrink-0 form-check-input me-2" required><label for="agree6">
                    I agree that the information I submit may be used for the purpose of using BitRush.
                </label>
            </div>
          </div>

          <div class="d-grid gap-2 col-6 mx-auto mb-3">
            <!--<input class="btn my-5 w-100" type="image" src="img/to_confirm.jpg" align="submit" value="確認画面へ">-->
            <button class="c-btn btn btn-lg btn-block my-5 w-100" type="submit" data-lang="toConfirm">Confirmation</button>
          </div>

          <input type="hidden" name="action" value="confirm">

        </form>
      </div>

    </main>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" ></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" ></script>

<script>

    var elmMail = $('#email');
    var elmConfirm = $('#emailConfirm');

    // 無効なフィールドがある場合にフォーム送信を無効にするスターターJavaScriptの例
    (function() {
        'use strict';

        window.addEventListener('load', function() {
            // カスタムブートストラップ検証スタイルを適用するすべてのフォームを取得
            var forms = document.getElementsByClassName('needs-validation');
            // ループして帰順を防ぐ
            var validation = Array.prototype.filter.call(forms, function(form) {
                // submitボタンを押したら以下を実行
                form.addEventListener('submit', function(event) {
                    // HTML5のバリデーション失敗 or 手動バリデーションが失敗の時は送信しない
                    console.log(manualValid());
                    if (form.checkValidity() === false || !manualValid()) {
                        event.preventDefault();
                        event.stopPropagation();
                    }

                    // メアドと確認用アドを比較し結果次第で枠線の色やアイコンを変える
                    dispManualValid();

                    form.classList.add('was-validated');
                }, false);

                // 1回確認ボタン押した以降はリアルタイムにチェック
                $(document).on('change keyup', ".was-validated .js-manual-valid", function() {
                    // メアドと確認用アドを比較し結果次第で枠線の色やアイコンを変える
                    dispManualValid();
                });
            });
        }, false);
    })();

    /** 
     * バリデーションの結果で対象フィールドにクラスを付与する
     * @param {boolean} res
     * @param {Object} elm
     */
    function changeInputStyleByValid(res, elm) {
        if (res) {
            // OK用のbootstrapのスタイル
            elm.removeClass("is-invalid conf-invalid");
            elm.addClass("is-valid");
        } else {
            // NG用のbootstrapのスタイル
            elm.removeClass("is-valid");
            elm.addClass("is-invalid conf-invalid");
        }   
    }

    /**
     * フィールドごとにバリデーションを行い結果を見た目に反映する
     */
    function dispManualValid() {
        changeInputStyleByValid(isEmailConfirmed(), elmConfirm);
        // changeInputStyleByValid(isRequiredSenninPlan(), $("input[name='senninPlan']"));
        changeInputStyleByValid(isRequiredUsdtAdd(), $('#usdtAddress'));
        changeInputStyleByValid(isRequiredUsdtNet(), $("input[name='usdtNet']"));
    }

    /** 
     * メアドと確認用メアドが一致しているかどうか
     * @return {boolean}
     */
    function isEmailConfirmed() {
        return elmMail.val() === elmConfirm.val();
    }

    /**
     * パートナー会員２（GTS pro無し）の時、割引プランも選択しているかどうか
     * @return {boolean}
     **/
    /* function isRequiredSenninPlan() {
        if ($('#trade').prop('checked')) {
            // パートナー会員２（GTS pro無し）にチェックが入っている時、割引プランの選択は必須
            return $("input[name='senninPlan']:checked").val() != undefined;
        } else {
            return true;
        }
    } */

    /**
     * トレード仙人のプランを選択している時、利用するサービスにトレード仙人もチェックしているかどうか
     * @return {boolean}
     **/
    /* function isRequiredService() {
        if ($("input[name='senninPlan']:checked").val() != undefined) {
            // トレード仙人のプランが選択されている時トレード仙人へのチェックは必須
            return $('#trade').prop('checked');
        } else {
            return true;
        }
    } */

    /**
     * USDTアドレスネットワークを選択している時USDTアドレスが入力されているかどうか
     * @return {boolean}
     **/
    function isRequiredUsdtAdd() {
        if ($("input[name='usdtNet']:checked").val() != undefined) {
            return $('#usdtAddress').val() != '';
        } else {
            return true;
        }
    }

    /**
     * USDTアドレスが入力されている時年とワークも選択しているかどうか
     * @return {boolean}
     **/
    function isRequiredUsdtNet() {
        if ($('#usdtAddress').val() != '') {
            return $("input[name='usdtNet']:checked").val() != undefined;
        } else {
            return true;
        }
    }

    /**
     * 手動で行いたいバリデーションの全てがOKかどうか
     * return {boolean}
     */
    function manualValid() {
        return isEmailConfirmed() /* && isRequiredSenninPlan() && isRequiredService() */ && isRequiredUsdtAdd() && isRequiredUsdtNet();
    }


    /** 
     * チェックボックスを1つ以上選択必須にする
     */
     /*
    let checkedSum; //チェックが入っている個数
    $('.js-check').on("click",function(){
        checkedSum = $('.js-check:checked').length; //チェックが入っているチェックボックスの取得
        if( checkedSum > 0 ){
            $('.js-check').prop("required",false); //required属性の解除
        }else{
            $('.js-check').prop("required",true); //required属性の付与
        }
    });
    */
</script>
  </body>
</html>
