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

<?php if ($category_tpl) { ?>
  <!-- Category View -->

  <div class="container-fluid">
    <div class="col-md-6 ml-auto mr-auto text-center">
      <h2 class="title mb-0"><?php echo $catgory_title;?></h2>
      <?php echo (isset($catgory_description) && !empty($catgory_description) ? '<h5 class="description">'.$catgory_description.'</h5>' : '')?>
      <hr>
    </div>
  </div>

  <div class="section section-white">
    <div class="container">
      <div class="row">
        <nav class="col-md-3 sidebar" id="sidebar">
          <div class="sidebar-sticky">
            <span class="badge badge-info"><i class="fa fa-feather" aria-hidden="true"></i>&nbsp; <?php echo $jkl['hd76'];?></span>

            <ul class="list-group list-group-flush">
              <?php if (isset($allcategories) && !empty($allcategories)) foreach ($allcategories as $c) { if ($c["subcat"] == 0) { ?>
                <li class="list-group-item">
                  <a href="#dropdownMenuLink<?php echo $c["id"];?>" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle"><strong><?php echo $c["title"];?></strong></a> <span class="badge badge-pill badge-info float-right mb-0"><?php echo $c["articles"];?></span>

                  <ul class="collapse list-group list-group-flush<?php if ($c["id"] == $showcat) echo " show";?>" id="dropdownMenuLink<?php echo $c["id"];?>">
                    <li class="list-group-item"><a href="<?php echo JAK_rewrite::jakParseurl(JAK_FAQ_URL, 'c', $c["id"], JAK_rewrite::jakCleanurl($c["title"]));?>"><span class="fa fa-angle-right mr-2"></span><?php echo $c["title"];?></a></li>
                    <?php foreach ($allcategories as $sc) { if ($sc["subcat"] == $c["id"]) { ?>

                      <li class="list-group-item"><a href="<?php echo JAK_rewrite::jakParseurl(JAK_FAQ_URL, 'c', $sc["id"], JAK_rewrite::jakCleanurl($sc["title"]));?>"><span class="fa fa-angle-right mr-2"></span><?php echo $sc["title"];?></a> <span class="badge badge-pill badge-primary float-right mb-0"><?php echo $sc["articles"];?></span></li>

                    <?php } } ?>
                  </ul>
                </li>
              <?php } } ?>
            </ul>
          </div>
        </nav>

        <div class="col-md-9 pl-5 pr-5">
          <div class="row">
            <?php if (isset($allfaq) && !empty($allfaq)) foreach($allfaq as $faq) {
              $faqparseurl = JAK_rewrite::jakParseurl(JAK_FAQ_URL, 'a', $faq["id"], JAK_rewrite::jakCleanurl($faq["title"]));
              ?>
              <div class="col-xl-4">
                <div class="card card-blog">
                  <div class="card-icon">
                    <i class="<?php echo $faq["icon"];?>"></i>
                  </div>
                  <div class="card-body text-center">
                    <h6 class="card-category text-info"><?php echo $faq["titlecat"];?></h6>
                    <h4 class="card-title">
                      <?php echo $faq["title"];?>
                    </h4>
                    <p class="card-description">
                      <?php echo jak_cut_text($faq["content"], 150, '...');?></p>
                      <div class="card-footer">
                        <a href="<?php echo $faqparseurl;?>" class="btn btn-danger btn-round"><?php echo $jkl['hd1'];?></a>
                      </div>
                    </div>
                  </div>
                </div>

              <?php } ?>
            </div>

            <?php if ($JAK_PAGINATE) echo $JAK_PAGINATE;?>

          </div>
        </div>
      </div>
    </div>

  <?php } else { ?>
    <!-- Main view -->

    <?php if (JAK_FAQ_A && isset($allfaq) && is_array($allfaq)) { ?>
      <div class="section section-white">
        <div class="container">
          <?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 f-<?php echo $pageid;?>" data-area="faq-<?php echo $pageid;?>" data-pageid="f-<?php echo $pageid;?>" data-lighteditor="false" type="button"><?php echo $jkl['hd66'];?></button>
              <button class="btn btn-sm btn-success firefrontsave f-<?php echo $pageid;?>" data-area="faq-<?php echo $pageid;?>" data-pageid="f-<?php echo $pageid;?>" type="button"><?php echo $jkl['hd53'];?></button>
              <button class="btn btn-sm btn-danger firefrontclose f-<?php echo $pageid;?>" data-area="faq-<?php echo $pageid;?>" data-pageid="f-<?php echo $pageid;?>" type="button"><?php echo $jkl['hd162'];?></button>
            </div>
          <?php } ?>
          <div class="col-md-12 faq-<?php echo $pageid;?>">
            <?php if (isset($cms_text) && !empty($cms_text)) foreach ($cms_text as $t) { if ($t["cmsslug"].$t["cmsid"] == 'faq-'.$pageid) { echo $t["description"]; break; } } ?>
          </div>
        </div>
      </div>

      <div class="section bg-gradient-3">
        <div class="container">
          <div class="row justify-content-center space-bot-big">
            <ul class="nav nav-pills nav-pills-primary justify-content-center">
              <li class="nav-item">
                <a class="nav-link<?php if (empty($page1)) echo ' active';?>" href="<?php echo JAK_rewrite::jakParseurl(JAK_FAQ_URL);?>"><?php echo $jkl['hd122'];?></a>
              </li>
              <?php if (isset($allcategories) && !empty($allcategories)) foreach ($allcategories as $c) { if ($c["subcat"] == 0) { ?>
                <li class="nav-item">
                  <a class="nav-link<?php if ($page2 == $c["id"]) echo ' active';?>" href="<?php echo JAK_rewrite::jakParseurl(JAK_FAQ_URL, 'c', $c["id"], JAK_rewrite::jakCleanurl($c["title"]));?>"><?php echo $c["title"];?></a>
                </li>
              <?php } } ?>
            </ul>
          </div>
        </div>

        <div class="container">
          <div class="card-columns">
            <?php if (isset($allfaq) && !empty($allfaq)) foreach($allfaq as $faq) {
              $faqparseurl = JAK_rewrite::jakParseurl(JAK_FAQ_URL, 'a', $faq["id"], JAK_rewrite::jakCleanurl($faq["title"]));
              ?>
              <div class="card card-blog">
                <div class="card-icon">
                  <i class="<?php echo $faq["icon"];?>"></i>
                </div>
                <div class="card-body text-center">
                  <h6 class="card-category text-info"><?php echo $faq["titlecat"];?></h6>
                  <h4 class="card-title">
                    <?php echo $faq["title"];?>
                  </h4>
                  <p class="card-description">
                    <?php echo jak_cut_text($faq["content"], 200, '...');?></p>
                    <div class="card-footer">
                      <a href="<?php echo $faqparseurl;?>" class="btn btn-danger btn-round"><?php echo $jkl['hd1'];?></a>
                      <hr>

                      <div class="stats pb-3">
                        <i class="fa fa-clock-o" aria-hidden="true"></i> <?php echo JAK_base::jakTimesince($faq['time'], JAK_DATEFORMAT, JAK_TIMEFORMAT);?>
                      </div>
                    </div>
                  </div>
                </div>
              <?php } ?>
            </div>
          </div>

          <div class="container">
            <div class="row justify-content-center">

              <?php if ($JAK_PAGINATE) echo $JAK_PAGINATE;?>
              <?php if (isset($_SESSION["webembed"]) && $page1 == 'c') { ?>
                <p><a href="<?php echo JAK_rewrite::jakParseurl(JAK_FAQ_URL);?>" class="btn btn-secondary"><i class="fa fa-arrow-left"></i></a></p>
              <?php } ?>

            </div>
          </div>
        </div>

      <?php } ?>

      <div class="section section-white">
        <div class="container-fluid">
          <?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 fb-<?php echo $pageid;?>" data-area="faq-bottom-<?php echo $pageid;?>" data-pageid="fb-<?php echo $pageid;?>" data-lighteditor="false" type="button"><?php echo $jkl['hd66'];?></button>
              <button class="btn btn-sm btn-success firefrontsave fb-<?php echo $pageid;?>" data-area="faq-bottom-<?php echo $pageid;?>" data-pageid="fb-<?php echo $pageid;?>" type="button"><?php echo $jkl['hd53'];?></button>
              <button class="btn btn-sm btn-danger firefrontclose fb-<?php echo $pageid;?>" data-area="faq-bottom-<?php echo $pageid;?>" data-pageid="fb-<?php echo $pageid;?>" type="button"><?php echo $jkl['hd162'];?></button>
            </div>
          <?php } ?>
          <div class="col-md-12 faq-bottom-<?php echo $pageid;?>">
            <?php if (isset($cms_text) && !empty($cms_text)) foreach ($cms_text as $t) { if ($t["cmsslug"].$t["cmsid"] == 'faq-bottom-'.$pageid) { echo $t["description"]; break; } } ?>
          </div>
        </div>
      </div>

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