<?php include_once APP_PATH . 'template/business/tplblocks/header.php'; ?>

<?php if (isset($page1) && isset($page2) && $page1 == "pay") {
  if ($page2 == "success") { ?>
    <div class="alert alert-success"><?php echo $jkl['hd113']; ?></div>
  <?php } else { ?>
    <div class="alert alert-danger"><?php echo $jkl['hd114']; ?></div>
<?php }
} ?>

<?php if (isset($allcsupport) && is_array($allcsupport)) { ?>
  <div class="container">
    <div class="col-md-6 col-sm-8 ml-auto mr-auto">
      <div class="card card-profile card-plain">
        <div class="card-avatar border-white">
          <a href="#avatar">
            <img src="<?php echo BASE_URL . JAK_FILES_DIRECTORY . $jakclient->getVar("picture"); ?>" alt="<?php echo $jakclient->getVar("name"); ?>">
          </a>
        </div>
        <div class="card-body">
          <h4 class="card-title"><?php echo $jakclient->getVar("name"); ?></h4>
          <h6 class="card-category"><?php echo $jakclient->getVar("email"); ?></h6>

          <span class="badge badge-pill badge-primary"><?php echo sprintf($jkl['hd56'], (!empty($jakclient->getVar("chatrequests")) ? $jakclient->getVar("chatrequests") : 0)); ?></span>
          <span class="badge badge-pill badge-primary"><?php echo sprintf($jkl['hd57'], $jakclient->getVar("supportrequests")); ?></span>
          <?php if (JAK_BILLING_MODE == 1) { ?>
            <span class="badge badge-pill badge-success"><?php echo sprintf($jkl['hd44'], $jakclient->getVar("credits")); ?></span>
          <?php } elseif (JAK_BILLING_MODE == 2) { ?>
            <span class="badge badge-pill badge-success"><?php echo sprintf($jkl['hd45'], JAK_base::jakTimesince($jakclient->getVar("paid_until"), JAK_DATEFORMAT, JAK_TIMEFORMAT)); ?></span>
          <?php } elseif (JAK_BILLING_MODE == 3) { ?>
            <span class="badge badge-pill badge-success"><?php echo sprintf($jkl['hd142'], JAK_base::jakTimesince($jakclient->getVar("support_until"), JAK_DATEFORMAT, JAK_TIMEFORMAT)); ?></span>
          <?php } ?>

          <?php if (JAK_CLIENTID && $jakclient->getVar("frontendadmin") == 1) { ?>
            <div class="col-md-12 ml-auto mr-auto text-center mb-1">
              <button class="btn btn-sm btn-primary firefrontedit d-<?php echo $pageid; ?>" data-area="dashboard-<?php echo $pageid; ?>" data-pageid="d-<?php echo $pageid; ?>" data-lighteditor="false" type="button"><?php echo $jkl['hd66']; ?></button>
              <button class="btn btn-sm btn-success firefrontsave d-<?php echo $pageid; ?>" data-area="dashboard-<?php echo $pageid; ?>" data-pageid="d-<?php echo $pageid; ?>" type="button"><?php echo $jkl['hd53']; ?></button>
              <button class="btn btn-sm btn-danger firefrontclose d-<?php echo $pageid; ?>" data-area="dashboard-<?php echo $pageid; ?>" data-pageid="d-<?php echo $pageid; ?>" type="button"><?php echo $jkl['hd162']; ?></button>
            </div>
          <?php } ?>

          <div class="col-md-12 dashboard-<?php echo $pageid; ?>">
            <?php if (isset($cms_text) && !empty($cms_text)) foreach ($cms_text as $t) {
              if ($t["cmsslug"] . $t["cmsid"] == 'dashboard-' . $pageid) {

                $phold = array('{clientname}', '{clientregister}', '{clientlastactivity}', '{clientemail}');
                if (JAK_USERID) {
                  $replace   = array($jakuser->getVar("name"), JAK_base::jakTimesince($jakuser->getVar("time"), JAK_DATEFORMAT, JAK_TIMEFORMAT), JAK_base::jakTimesince($jakuser->getVar("lastactivity"), JAK_DATEFORMAT, JAK_TIMEFORMAT), $jakuser->getVar("email"));
                } else {
                  $replace   = array($jakclient->getVar("name"), JAK_base::jakTimesince($jakclient->getVar("time"), JAK_DATEFORMAT, JAK_TIMEFORMAT), JAK_base::jakTimesince($jakclient->getVar("lastactivity"), JAK_DATEFORMAT, JAK_TIMEFORMAT), $jakclient->getVar("email"));
                }
                $regtext = str_replace($phold, $replace, $t["description"]);

                echo $regtext;
                break;
              }
            } ?>
          </div>
          <hr>
          <a href="<?php echo JAK_rewrite::jakParseurl(JAK_SUPPORT_URL, 'n'); ?>"><button class="btn btn-rotate btn-round btn-outline-primary btn-sm"><i class="fa fa-paper-plane"></i> <?php echo $jkl['hd47']; ?></button></a>
          <a href="<?php echo JAK_rewrite::jakParseurl(JAK_CLIENT_URL, 'edit'); ?>" class="btn btn-rotate btn-round btn-outline-primary btn-sm"><i class="fa fa-cog"></i> <?php echo $jkl['g85']; ?></a>
          <?php if (JAK_BILLING_MODE == 3) { ?>
            <a href="<?php echo JAK_rewrite::jakParseurl(JAK_CLIENT_URL, 'envato'); ?>" class="btn btn-rotate btn-round btn-outline-primary btn-sm"><i class="fa fa-list-alt"></i> <?php echo $jkl['hd144']; ?></a>
          <?php } ?>

        </div>

      </div> <!-- end card -->
    </div>
  </div>

  <div class="section section-inputs section-white">
    <div class="container">

      <div class="navbar navbar-expand-lg bg-primary">
        <div class="container">
          <h4 class="navbar-brand"><?php echo $jkl['hd141']; ?></h4>



          <div class="col-md-2">
            <select class="selectpicker" name="jak_shownr" id="jak_shownr" data-style="select-with-transition btn-primary btn-round">
              <option value="10"><?php echo sprintf($jkl['hd139'], 10); ?></option>
              <option value="25" <?php if (isset($_SESSION["shownr"]) && $_SESSION["shownr"] == 25) echo ' selected'; ?>><?php echo sprintf($jkl['hd139'], 25); ?></option>
              <option value="50" <?php if (isset($_SESSION["shownr"]) && $_SESSION["shownr"] == 50) echo ' selected'; ?>><?php echo sprintf($jkl['hd139'], 50); ?></option>
              <option value="100" <?php if (isset($_SESSION["shownr"]) && $_SESSION["shownr"] == 100) echo ' selected'; ?>><?php echo sprintf($jkl['hd139'], 100); ?></option>
            </select>
          </div>

          <div class="col-md-3">
            <?php if (isset($dep_filter) && is_array($dep_filter) && !empty($dep_filter)) { ?>
              <form id="jak_statform" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
                <select name="jak_depid" id="jak_depid" class="selectpicker" data-style="select-with-transition btn-primary btn-round">
                  <option value="0"><?php echo $jkl['g88']; ?></option>
                  <?php foreach ($dep_filter as $v) { ?>
                    <option value="<?php echo $v["id"]; ?>" <?php if (isset($_SESSION["sortdepid"]) && $_SESSION["sortdepid"] == $v["id"]) echo ' selected'; ?>><?php echo $v["title"]; ?></option>
                  <?php } ?>
                </select>
                <input type="hidden" name="action" value="filter">
              </form>
            <?php } ?>
          </div>

          <div class="col-md-3 form-row align-items-center">
            <div class="col-10">
              <input class="form-control mr-sm-2 no-border" type="text" placeholder="Search" id="supportItext">
            </div>
            <div class="col-2 text-left">
              <button type="submit" class="btn btn-primary btn-just-icon btn-round" id="supportIsearch"><i class="fa fa-search" aria-hidden="true"></i></button>
            </div>
          </div>

          <div class="col-md-auto text-center">
            <a href="<?php echo (JAK_USERID ? JAK_rewrite::jakParseurl(JAK_OPERATOR_LOC, 'support', 'new') : JAK_rewrite::jakParseurl(JAK_SUPPORT_URL, 'n')); ?>" class="btn btn-block btn-rotate btn-round btn-danger"><i class="fa fa-paper-plane"></i> <?php echo $jkl['hd47']; ?></a>
          </div>


        </div>
      </div>

      <table id="dynamic-data" class="table table-hover" cellspacing="0" width="100%">
        <thead>
          <th class="text-center"><span class="badge badge-pill badge-info"><i class="fa fa-hashtag" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="" data-original-title="Ticket ID" aria-describedby="tooltip50022"></i></span></th>
          <th><?php echo $jkl['hd7']; ?></th>
          <th><?php echo $jkl['hd9']; ?></th>
          <th><?php echo $jkl['hd8']; ?></th>
          <th><?php echo $jkl['hd10']; ?></th>
          <th class="text-right"><?php echo $jkl['hd11'] . ' / ' . $jkl['hd12']; ?></th>
          <th class="text-right"><?php echo $jkl['hd13']; ?></th>
        </thead>
      </table>


    </div>
  </div>

  <div class="container">

    <?php if (JAK_BILLING_MODE != 0 && isset($allpackages) && !empty($allpackages)) { ?>
      <div class="row">
        <?php if (JAK_CLIENTID && $jakclient->getVar("frontendadmin") == 1) { ?>
          <div class="col-md-12 ml-auto mr-auto text-center mb-1">
            <button class="btn btn-sm btn-primary firefrontedit db-<?php echo $pageid; ?>" data-area="dashboard-billing-<?php echo $pageid; ?>" data-pageid="db-<?php echo $pageid; ?>" data-lighteditor="false" type="button"><?php echo $jkl['hd66']; ?></button>
            <button class="btn btn-sm btn-success firefrontsave db-<?php echo $pageid; ?>" data-area="dashboard-billing-<?php echo $pageid; ?>" data-pageid="db-<?php echo $pageid; ?>" type="button"><?php echo $jkl['hd53']; ?></button>
            <button class="btn btn-sm btn-danger firefrontclose db-<?php echo $pageid; ?>" data-area="dashboard-billing-<?php echo $pageid; ?>" data-pageid="db-<?php echo $pageid; ?>" type="button"><?php echo $jkl['hd162']; ?></button>
          </div>
        <?php } ?>
        <div class="col-md-12 dashboard-billing-<?php echo $pageid; ?>">
          <?php if (isset($cms_text) && !empty($cms_text)) foreach ($cms_text as $t) {
            if ($t["cmsslug"] . $t["cmsid"] == 'dashboard-billing-' . $pageid) {
              echo $t["description"];
              break;
            }
          } ?>
        </div>
      </div>
      <form method="post" id="buypackage" action="<?php echo $_SERVER['REQUEST_URI'];?>">
      <div class="row mb-3">
        <div class="col-md-12">
          <div class="card-deck">
            <?php foreach ($allpackages as $allp) { ?>
              <div class="card">
                <?php if (!empty($allp["previmg"])) { ?><img class="card-img-top img-fluid" src="<?php echo $allp["previmg"]; ?>" alt="<?php echo $allp["title"]; ?>"><?php } ?>
                <div class="card-body">
                  <h4 class="card-title"><?php echo $allp["title"]; ?></h4>
                  <p class="card-text"><?php echo $allp["content"]; ?></p>
                  <?php if (JAK_BILLING_MODE == 1) { ?>
                    <p class="card-text"><?php echo sprintf($jkl['hd50'], $allp["credits"]); ?></p>
                  <?php } elseif (JAK_BILLING_MODE == 2) { ?>
                    <p class="card-text"><?php echo sprintf($jkl['hd51'], $allp["paidtill"]); ?></p>
                  <?php } ?>
                  <p class="card-text"><?php echo sprintf($jkl['hd52'], jak_calc_indiv_price($allp["amount"], $jakclient->getVar("custom_price")) . ' ' . $allp["currency"]); ?></p>
                </div>
                <div class="card-footer">
                  <?php if (JAK_BILLING_MODE == 2) { ?>
                  <div class="form-check">
                    <label class="form-check-label">
                      <input class="form-check-input" type="checkbox" name="subscribe" id="subscribe-<?php echo $allp["id"]; ?>" value="1"> <?php echo $jkl["hd169"];?>
                      <span class="form-check-sign">
                        <span class="check"></span>
                      </span>
                    </label>
                  </div>
                  <?php } if (JAK_STRIPE_PUBLISH_KEY) { ?>
                    <a href="javascript:void(0)" class="btn btn-success btn-green paynow" data-package="<?php echo $allp["id"]; ?>" data-amount="<?php echo jak_calc_indiv_price($allp["amount"], $jakclient->getVar("custom_price")); ?>" data-currency="<?php echo $allp["currency"]; ?>" data-title="<?php echo $allp["title"]; ?>" data-description="<?php echo $allp["content"]; ?>" data-paidhow="stripe"><i class="jak-loadbtn"></i> <i class="fab fa-cc-stripe"></i> <?php echo $jkl['hd48'];?></a>
                  <?php }
                  if (JAK_PAYPAL_CLIENT) { ?>
                    <a href="javascript:void(0)" class="btn btn-success btn-green paynow" data-package="<?php echo $allp["id"]; ?>" data-amount="<?php echo jak_calc_indiv_price($allp["amount"], $jakclient->getVar("custom_price")); ?>" data-currency="<?php echo $allp["currency"]; ?>" data-title="<?php echo $allp["title"]; ?>" data-description="<?php echo $allp["content"]; ?>" data-paidhow="paypal"><i class="jak-loadbtn"></i> <i class="fab fa-paypal"></i> <?php echo $jkl['hd49'];?></a>
                  <?php }
                  if (JAK_YOOKASSA_ID) { ?>
                    <a href="javascript:void(0)" class="btn btn-success btn-green paynow" data-package="<?php echo $allp["id"]; ?>" data-amount="<?php echo jak_calc_indiv_price($allp["amount"], $jakclient->getVar("custom_price")); ?>" data-currency="<?php echo $allp["currency"]; ?>" data-title="<?php echo $allp["title"]; ?>" data-description="<?php echo $allp["content"]; ?>" data-paidhow="yookassa"><i class="jak-loadbtn"></i> <i class="fa fa-credit-card"></i> <?php echo $jkl['hd170'];?></a>
                  <?php }
                  if (JAK_PAYSTACK_SECRET) { ?>
                    <a href="javascript:void(0)" class="btn btn-success btn-green paynow" data-package="<?php echo $allp["id"]; ?>" data-amount="<?php echo jak_calc_indiv_price($allp["amount"], $jakclient->getVar("custom_price")); ?>" data-currency="<?php echo $allp["currency"]; ?>" data-title="<?php echo $allp["title"]; ?>" data-description="<?php echo $allp["content"]; ?>" data-paidhow="paystack"><i class="jak-loadbtn"></i> <i class="fa fa-credit-card"></i> <?php echo $jkl['hd171'];?></a>
                  <?php }
                  if (JAK_AUTHORIZE_ID) { ?>
                    <a href="javascript:void(0)" class="btn btn-success btn-green paynow" data-package="<?php echo $allp["id"]; ?>" data-amount="<?php echo jak_calc_indiv_price($allp["amount"], $jakclient->getVar("custom_price")); ?>" data-currency="<?php echo $allp["currency"]; ?>" data-title="<?php echo $allp["title"]; ?>" data-description="<?php echo $allp["content"]; ?>" data-paidhow="authorize.net"><i class="jak-loadbtn"></i> <i class="fa fa-credit-card"></i> <?php echo $jkl['hd172'];?></a>
                  <?php }
                  if (JAK_TWOCO) { ?>
                    <a href="javascript:void(0)" class="btn btn-success btn-green paynow" data-package="<?php echo $allp["id"]; ?>" data-amount="<?php echo jak_calc_indiv_price($allp["amount"], $jakclient->getVar("custom_price")); ?>" data-currency="<?php echo $allp["currency"]; ?>" data-title="<?php echo $allp["title"]; ?>" data-description="<?php echo $allp["content"]; ?>" data-paidhow="2checkout"><i class="jak-loadbtn"></i> <i class="fas fa-credit-card-front"></i> <?php echo $jkl['hd129'];?></a>
                  <?php } ?>
                </div>
              </div>
            <?php } ?>
          </div>
        </div>
        <input type="hidden" name="pid" id="pid">
        <input type="hidden" name="paidhow" id="paidhow">
        <input type="hidden" name="amount" id="amount">
        <input type="hidden" name="subscribe" id="subscribe" value="0">
        <input type="hidden" name="action" value="payment">
      </div>

  </form>
    <?php } ?>

    <?php if (JAK_BILLING_MODE != 0 && isset($last5pay) && !empty($last5pay)) { ?>
      <div class="row">
        <?php if (JAK_CLIENTID && $jakclient->getVar("frontendadmin") == 1) { ?>
          <div class="col-md-12 ml-auto mr-auto text-center mb-1">
            <button class="btn btn-sm btn-primary firefrontedit dbh-<?php echo $pageid; ?>" data-area="dashboard-billing-history-<?php echo $pageid; ?>" data-pageid="dbh-<?php echo $pageid; ?>" data-lighteditor="false" type="button"><?php echo $jkl['hd66']; ?></button>
            <button class="btn btn-sm btn-success firefrontsave dbh-<?php echo $pageid; ?>" data-area="dashboard-billing-history-<?php echo $pageid; ?>" data-pageid="dbh-<?php echo $pageid; ?>" type="button"><?php echo $jkl['hd53']; ?></button>
            <button class="btn btn-sm btn-danger firefrontclose dbh-<?php echo $pageid; ?>" data-area="dashboard-billing-history-<?php echo $pageid; ?>" data-pageid="dbh-<?php echo $pageid; ?>" type="button"><?php echo $jkl['hd162']; ?></button>
          </div>
        <?php } ?>
        <div class="col-md-12 dashboard-billing-history-<?php echo $pageid; ?>">
          <?php if (isset($cms_text) && !empty($cms_text)) foreach ($cms_text as $t) {
            if ($t["cmsslug"] . $t["cmsid"] == 'dashboard-billing-history-' . $pageid) {
              echo $t["description"];
              break;
            }
          } ?>
        </div>
      </div>
      <div class="row">
        <div class="col-md-12">
          <table class="table table-responsive table-light w-100 d-block d-md-table">
            <thead class="table-custom-green">
              <th><?php echo $jkl['hd38']; ?></th>
              <th><?php echo $jkl['hd39']; ?></th>
              <th><?php echo $jkl['hd41']; ?></th>
              <th><?php echo $jkl['hd40']; ?></th>
              <th><?php echo $jkl['hd178']; ?></th>
              <th><?php echo $jkl['hd46']; ?></th>
              <th><?php echo $jkl['hd11']; ?></th>
            </thead>
            <?php foreach ($last5pay as $l5p) { ?>
              <tr>
                <td><?php echo $l5p["title"]; ?></td>
                <td><?php echo $l5p["amount"] . ' ' . $l5p["currency"]; ?></td>
                <td><?php echo $l5p["paidhow"]; ?></td>
                <td><?php echo JAK_base::jakTimesince($l5p['paidwhen'], JAK_DATEFORMAT, JAK_TIMEFORMAT); ?></td>
                <td><?php echo JAK_base::jakTimesince($l5p['paidtill'], JAK_DATEFORMAT, JAK_TIMEFORMAT); ?></td>
                <td><?php echo ($l5p["subscribed"] && $l5p["active"] ? '<a href="'.JAK_rewrite::jakParseurl(JAK_CLIENT_URL, 'withdrawal', $l5p["id"], JAK_CLIENTID).'" class="btn btn-sm btn-danger">'.$jkl['hd179'].'</a>' : '-');?></td>
                <td><?php echo ($l5p["success"] == 0 ? '<span class="badge badge-warning">' . $jkl['hd43'] . '</span>' : '<span class="badge badge-success">' . $jkl['hd42'] . '</span>'); ?></td>
              </tr>
            <?php } ?>
          </table>
        </div>
      </div>

    <?php } ?>
  </div>
<?php } include_once APP_PATH . 'template/business/tplblocks/footer.php'; ?>
