<?php include_once 'header.php';?>

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

    <ul class="nav nav-pills nav-pills-warning">
      <li class="nav-item">
        <a class="nav-link" href="<?php echo JAK_rewrite::jakParseurl('answers');?>"><?php echo $jkl["m20"];?></a>
      </li>
      <li class="nav-item">
        <a class="nav-link active" href="<?php echo JAK_rewrite::jakParseurl('answers', 'cms');?>"><?php echo $jkl["hd126"];?></a>
      </li>
    </ul>

    <hr>
  </div>
</div>

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

    <div class="card">
      <div class="card-header card-header-icon card-header-rose">
        <div class="card-icon">
          <i class="material-icons">language</i>
        </div>
        <h4 class="card-title "><?php echo $jkl["g22"];?></h4>
      </div>
      <div class="card-body">

        <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
          <div class="form-group">
            <select name="jak_lang_pack_cms" class="selectpicker col-12" data-live-search="true">
              <option disabled><?php echo $jkl["g22"];?></option>
              <?php if (isset($unique_lang) && is_array($unique_lang)) foreach($unique_lang as $lfu) { ?><option value="<?php echo $lfu;?>"><?php echo ucwords($lfu);?></option><?php } ?>
            </select>
          </div>

          <button type="submit" name="create_language_pack_cms" class="btn btn-primary btn-block"><?php echo $jkl["g326"];?></button>
        </form>
      </div>
    </div>

    <div class="card">
      <div class="card-header card-header-icon card-header-success">
        <div class="card-icon">
          <i class="material-icons">add</i>
        </div>
        <h4 class="card-title "><?php echo $jkl["hd128"];?></h4>
      </div>
      <div class="card-body">
        
        <?php if ($errors) { ?>
          <div class="alert alert-danger"><?php if (isset($errors["e"])) echo $errors["e"];
          if (isset($errors["e1"])) echo $errors["e1"];
          if (isset($errors["e2"])) echo $errors["e2"];?></div>
        <?php } ?>
        
        <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
          
          <div class="form-group">
            <label class="control-label" for="title"><?php echo $jkl["g16"];?></label>
            <input type="text" maxlength="255" name="title" id="title" class="form-control<?php if (isset($errors["e"])) echo " is-invalid";?>" value="<?php if (isset($_POST["title"])) echo $_POST["title"];?>">
          </div>

          <div class="form-group">
            <label class="control-label" for="url_slug"><?php echo $jkl["hd130"];?></label>
            <input type="text" name="url_slug" id="url_slug" class="form-control<?php if (isset($errors["e1"])) echo " is-invalid";?>" value="<?php if (isset($_POST["url_slug"])) echo $_POST["url_slug"];?>">
          </div>

          <div class="form-group">
            <label for="external_url"><?php echo $jkl["hd334"];?></label>
            <input type="text" maxlength="255" name="external_url" id="external_url" class="form-control" value="<?php if (isset($_REQUEST["external_url"])) echo $_REQUEST["external_url"];?>">
          </div>

          <div class="form-group">
            <p><label for="external_url"><?php echo $jkl["hd212"];?></label></p>
            <select name="jak_prepage" class="selectpicker col-12" data-live-search="true">
              <option disabled><?php echo $jkl["hd212"];?></option>
              <option value="0"><?php echo $jkl["hd213"];?></option>
              <option value="<?php echo JAK_CLIENT_URL;?>"<?php if (isset($_POST["jak_prepage"]) && $_POST["jak_prepage"] == JAK_CLIENT_URL) echo ' selected';?>><?php echo JAK_CLIENT_URL;?></option>
              <option value="<?php echo JAK_SEARCH_URL;?>"<?php if (isset($_POST["jak_prepage"]) && $_POST["jak_prepage"] == JAK_SEARCH_URL) echo ' selected';?>><?php echo JAK_SEARCH_URL;?></option>
              <option value="<?php echo JAK_BLOG_URL;?>"<?php if (isset($_POST["jak_prepage"]) && $_POST["jak_prepage"] == JAK_BLOG_URL) echo ' selected';?>><?php echo JAK_BLOG_URL;?></option>
              <option value="<?php echo JAK_FAQ_URL;?>"<?php if (isset($_POST["jak_prepage"]) && $_POST["jak_prepage"] == JAK_FAQ_URL) echo ' selected';?>><?php echo JAK_FAQ_URL;?></option>
              <option value="<?php echo JAK_SUPPORT_URL;?>"<?php if (isset($_POST["jak_prepage"]) && $_POST["jak_prepage"] == JAK_SUPPORT_URL) echo ' selected';?>><?php echo JAK_SUPPORT_URL;?></option>
              <option value="<?php echo JAK_CONTACT_URL;?>"<?php if (isset($_POST["jak_prepage"]) && $_POST["jak_prepage"] == JAK_CONTACT_URL) echo ' selected';?>><?php echo JAK_CONTACT_URL;?></option>
            </select>
          </div>
          
          <div class="form-group">
            <p><label for="external_url"><?php echo $jkl["g22"];?></label></p>
            <select name="jak_lang" class="selectpicker col-12" data-live-search="true">
              <option disabled><?php echo $jkl["g22"];?></option>
              <?php if (isset($lang_files) && is_array($lang_files)) foreach($lang_files as $lf) { ?><option value="<?php echo $lf;?>"<?php if (JAK_LANG == $lf) { ?> selected="selected"<?php } ?>><?php echo ucwords($lf);?></option><?php } ?>
            </select>
          </div>
          
          <div class="form-actions">
            <button type="submit" name="insert_page" class="btn btn-primary btn-block"><?php echo $jkl["g38"];?></button>
          </div>

        </form>
      </div>

    </div>

    <div class="card">
      <div class="card-header card-header-icon card-header-rose">
        <div class="card-icon">
          <i class="material-icons">view_timeline</i>
        </div>
        <h4 class="card-title "><?php echo $jkl["hd130"];?></h4>
      </div>
      <div class="card-body">

        <?php if ($errors) { ?>
          <div class="alert alert-danger"><?php
          if (isset($errors["e3"])) echo $errors["e3"];
          if (isset($errors["e4"])) echo $errors["e4"];
          if (isset($errors["e5"])) echo $errors["e5"];
          if (isset($errors["e6"])) echo $errors["e6"];
          if (isset($errors["e7"])) echo $errors["e7"];
          if (isset($errors["e8"])) echo $errors["e8"];?></div>
        <?php } ?>

        <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
          
          <div class="form-group">
            <label class="control-label" for="url_slug_client"><?php echo $jkl["hd77"];?></label>
            <input type="text" name="url_slug_client" id="url_slug_client" class="form-control<?php if (isset($errors["e3"])) echo " is-invalid";?>" value="<?php echo JAK_CLIENT_URL;?>">
          </div>

          <div class="form-group">
            <label class="control-label" for="url_slug_blog"><?php echo $jkl["hd13"];?></label>
            <input type="text" name="url_slug_blog" id="url_slug_blog" class="form-control<?php if (isset($errors["e4"])) echo " is-invalid";?>" value="<?php echo JAK_BLOG_URL;?>">
          </div>

          <div class="form-group">
            <label class="control-label" for="url_slug_faq"><?php echo $jkl["hd1"];?></label>
            <input type="text" name="url_slug_faq" id="url_slug_faq" class="form-control<?php if (isset($errors["e5"])) echo " is-invalid";?>" value="<?php echo JAK_FAQ_URL;?>">
          </div>

          <div class="form-group">
            <label class="control-label" for="url_slug_search"><?php echo $jkl["s5"];?></label>
            <input type="text" name="url_slug_search" id="url_slug_search" class="form-control<?php if (isset($errors["e6"])) echo " is-invalid";?>" value="<?php echo JAK_SEARCH_URL;?>">
          </div>

          <div class="form-group">
            <label class="control-label" for="url_slug_support"><?php echo $jkl["hd"];?></label>
            <input type="text" name="url_slug_support" id="url_slug_support" class="form-control<?php if (isset($errors["e7"])) echo " is-invalid";?>" value="<?php echo JAK_SUPPORT_URL;?>">
          </div>

          <div class="form-group">
            <label class="control-label" for="url_slug_contact"><?php echo $jkl["g261"];?></label>
            <input type="text" name="url_slug_contact" id="url_slug_contact" class="form-control<?php if (isset($errors["e8"])) echo " is-invalid";?>" value="<?php echo JAK_CONTACT_URL;?>">
          </div>

          <button type="submit" name="change_url_slug" class="btn btn-primary btn-block"><?php echo $jkl["g38"];?></button>
        </form>
      </div>
    </div>

  </div>
  <div class="col-md-8">
    <div class="card">
      <div class="card-header card-header-icon card-header-rose">
        <div class="card-icon">
          <i class="material-icons">list</i>
        </div>
        <h4 class="card-title "><?php echo $jkl["hd127"];?></h4>
      </div>
      <div class="card-body">

        <?php if (isset($only_used_lang) && count($only_used_lang) > 1) { ?>

          <p>
            <ul class="nav nav-pills nav-pills-primary">
              <?php foreach ($only_used_lang as $ul) { ?>
                <li class="nav-item">
                  <a class="nav-link<?php echo ($ul == $page2 ? ' active' : (empty($page2) && $ul == JAK_LANG ? ' active' : ''));?>" href="<?php echo JAK_rewrite::jakParseurl('answers', 'cms', ($ul == JAK_LANG ? '' : $ul));?>"><?php echo $ul;?></a>
                </li>
              <?php } ?>
            </ul>
          </p>

        <?php } ?>
        
        <div class="table-responsive">
          <table class="table table-striped">
            <thead>
              <tr>
                <th>#</th>
                <th><?php echo $jkl["g16"];?></th>
                <th><?php echo $jkl["hd130"];?></th>
                <th><?php echo $jkl["g22"];?></th>
                <th><?php echo $jkl["g102"];?></th>
                <th><?php echo $jkl["g101"];?></th>
                <th><?php echo $jkl["g47"];?></th>
                <th><?php echo $jkl["g48"];?></th>
              </tr>
            </thead>
            <?php if (isset($PAGES_ALL) && is_array($PAGES_ALL)) foreach($PAGES_ALL as $v) { ?>
              <tr>
                <td><?php echo $v["id"];?></td>
                <td class="title"><a href="<?php echo JAK_rewrite::jakParseurl('answers', 'cms', 'edit', $v["id"]);?>"><?php echo $v["title"];?></a></td>
                <td><?php echo $v["url_slug"];?></td>
                <td><?php echo $v["lang"];?></td>
                <td><?php echo $v["dorder"];?></td>
                <td><a class="btn btn-default btn-sm" href="<?php echo JAK_rewrite::jakParseurl('answers', 'cms', 'lock', $v["id"]);?>"><?php echo ($v["active"] == 1 ? '<i class="material-icons">check</i>' : '<i class="material-icons">clear</i>');?></a></td>
                <td><a class="btn btn-default btn-sm" href="<?php echo JAK_rewrite::jakParseurl('answers', 'cms', 'edit', $v["id"]);?>"><i class="fa fa-pencil"></i></a></td>
                <td><a class="btn btn-danger btn-sm btn-confirm" href="<?php echo JAK_rewrite::jakParseurl('answers', 'cms', 'delete', $v["id"]);?>" data-title="<?php echo addslashes($jkl["g48"]);?>" data-text="<?php echo addslashes($jkl["e31"]);?>" data-type="warning" data-okbtn="<?php echo addslashes($jkl["g279"]);?>" data-cbtn="<?php echo addslashes($jkl["g280"]);?>"><i class="fa fa-trash"></i></a></td>
              </tr>
            <?php } ?>
          </table>
        </div>

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

<?php include_once 'footer.php';?>
