<?php

// FAQ is turned on in general
if (JAK_FAQ_A) {

// Client Access
if (JAK_CLIENTID) {
// All access
  if ($jakclient->getVar("faq_cat") == 0) {
    $newfaqart = $jakdb->select("faq_article", ["[>]faq_categories" => ["catid" => "id"]], ["faq_article.id", "faq_article.lang", "faq_article.title", "faq_article.content", "faq_article.time", "faq_categories.class", "faq_categories.title(titlecat)"], ["AND" => ["faq_article.lang" => $BT_LANGUAGE, "faq_article.active" => 1],
      "ORDER" => ["faq_article.dorder" => "DESC"],
      "LIMIT" => JAK_FAQ_HOME
    ]);
// Only for certain categories
  } else {
    $newfaqart = $jakdb->select("faq_article", ["[>]faq_categories" => ["catid" => "id"]], ["faq_article.id", "faq_article.lang", "faq_article.title", "faq_article.content", "faq_article.time", "faq_categories.class", "faq_categories.title(titlecat)"], ["AND" => ["faq_article.lang" => $BT_LANGUAGE, "faq_article.catid" => [$jakclient->getVar("faq_cat")], "faq_article.active" => 1],
      "ORDER" => ["faq_article.dorder" => "DESC"],
      "LIMIT" => JAK_FAQ_HOME
    ]);
  }
// Can see all active articles
} elseif (JAK_USERID) {
  $newfaqart = $jakdb->select("faq_article", ["[>]faq_categories" => ["catid" => "id"]], ["faq_article.id", "faq_article.lang", "faq_article.title", "faq_article.content", "faq_article.time", "faq_categories.class", "faq_categories.title(titlecat)"], ["AND" => ["faq_article.lang" => $BT_LANGUAGE, "faq_article.active" => 1],
    "ORDER" => ["faq_article.dorder" => "DESC"],
    "LIMIT" => JAK_FAQ_HOME
  ]);
// Can see categories for guests
} else {
  $newfaqart = $jakdb->select("faq_article", ["[>]faq_categories" => ["catid" => "id"]], ["faq_article.id", "faq_article.lang", "faq_article.title", "faq_article.content", "faq_article.time", "faq_categories.class", "faq_categories.title(titlecat)"], ["AND" => ["faq_categories.guesta" => 1, "faq_article.lang" => $BT_LANGUAGE, "faq_article.active" => 1],
    "ORDER" => ["faq_article.dorder" => "DESC"],
    "LIMIT" => JAK_FAQ_HOME
  ]);
}

}

if (isset($newfaqart) && !empty($newfaqart)){?>

<div class="card-columns">
  <?php foreach($newfaqart as $faqn) {
    $faqparseurl = JAK_rewrite::jakParseurl(JAK_FAQ_URL, 'a', $faqn["id"], JAK_rewrite::jakCleanurl($faqn["title"]));
    ?>

<div class="card card-blog">
        <div class="card-icon">
          <i class="<?php echo (!empty($faqn["icon"]) ? $faqn["icon"] : 'far fa-question-circle');?>"></i>
        </div>
        <div class="card-body text-center">
          <h6 class="card-category text-info"><?php echo $faqn["titlecat"];?></h6>
          <h4 class="card-title">
          <?php echo $faqn["title"];?>
          </h4>
          <p class="card-description">
            <?php echo jak_cut_text($faqn["content"], 180, '...');?></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($faqn['time'], JAK_DATEFORMAT, JAK_TIMEFORMAT);?>
              </div>
            </div>
          </div>
        </div>

    
  <?php } ?>
</div>
<?php } ?>
