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

<?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="card">
    <div class="card-header card-header-icon card-header-success">
      <div class="card-icon">
        <i class="material-icons">create</i>
      </div>
      <h4 class="card-title "><?php echo $jkl["hd129"];?></h4>
    </div>
    <div class="card-body">
      <div class="row">
        <div class="col-md-6">

          <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 echo $JAK_FORM_DATA["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 echo $JAK_FORM_DATA["url_slug"];?>">
          </div>

          <div class="form-group">
            <p><label class="control-label" for="jak_prepage"><?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 ($JAK_FORM_DATA["prepage"] == JAK_CLIENT_URL) echo ' selected';?>><?php echo JAK_CLIENT_URL;?></option>
              <option value="<?php echo JAK_SEARCH_URL;?>"<?php if ($JAK_FORM_DATA["prepage"] == JAK_SEARCH_URL) echo ' selected';?>><?php echo JAK_SEARCH_URL;?></option>
              <option value="<?php echo JAK_BLOG_URL;?>"<?php if ($JAK_FORM_DATA["prepage"] == JAK_BLOG_URL) echo ' selected';?>><?php echo JAK_BLOG_URL;?></option>
              <option value="<?php echo JAK_FAQ_URL;?>"<?php if ($JAK_FORM_DATA["prepage"] == JAK_FAQ_URL) echo ' selected';?>><?php echo JAK_FAQ_URL;?></option>
              <option value="<?php echo JAK_SUPPORT_URL;?>"<?php if ($JAK_FORM_DATA["prepage"] == JAK_SUPPORT_URL) echo ' selected';?>><?php echo JAK_SUPPORT_URL;?></option>
              <option value="<?php echo JAK_CONTACT_URL;?>"<?php if ($JAK_FORM_DATA["prepage"] == JAK_CONTACT_URL) echo ' selected';?>><?php echo JAK_CONTACT_URL;?></option>
            </select>
          </div>

          <div class="form-group">
            <p><label class="control-label" for="jak_lang"><?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_FORM_DATA["lang"] == $lf) { ?> selected="selected"<?php } ?>><?php echo ucwords($lf);?></option><?php } ?>
            </select>
          </div>

          <!-- Custom Stuff from the template -->
          <input type="hidden" name="jak_custom" value="">

          <?php if (isset($jaktplclient["custom2"]) && is_array($jaktplclient["custom2"])) { ?>

              <div class="form-group">
                <p><label for="order"><?php echo $jaktplclient["custom2title"];?></label></p>
                <select name="jak_custom2" class="selectpicker col-12" data-live-search="true">
                  <?php foreach($jaktplclient["custom2"] as $k => $v) { ?>
                    <option value="<?php echo $k;?>"<?php if ($JAK_FORM_DATA["custom2"] == $k) echo " selected";?>><?php echo $v;?></option>
                  <?php } ?>
                </select>
              </div>

            <?php } else { ?>
              <input type="hidden" name="jak_custom2" value="">
            <?php } ?>

            <?php if (isset($header_tpl) && is_array($header_tpl)) { ?>

              <div class="form-group">
                <p><label for="jak_header_tpl"><?php echo $jkl['hd310'];?></label></p>
                <select name="jak_header_tpl" class="selectpicker col-12" data-live-search="true">
                  <?php foreach($header_tpl as $v) { ?>
                    <option value="<?php echo $v;?>"<?php if ($JAK_FORM_DATA["header_tpl"] == $v) echo " selected";?>><?php echo substr($v, 0, -4);?></option>
                  <?php } ?>
                </select>
              </div>

            <?php } else { ?>
              <input type="hidden" name="jak_header_tpl" value="">
            <?php } ?>

            <?php if (isset($main_tpl) && is_array($main_tpl)) { ?>

              <div class="form-group">
                <p><label for="jak_main_tpl"><?php echo $jkl['hd308'];?></label></p>
                <select name="jak_main_tpl" class="selectpicker col-12" data-live-search="true">
                  <?php foreach($main_tpl as $v) { ?>
                    <option value="<?php echo $v;?>"<?php if ($JAK_FORM_DATA["main_tpl"] == $v) echo " selected";?>><?php echo substr($v, 0, -4);?></option>
                  <?php } ?>
                </select>
              </div>

            <?php } else { ?>
              <input type="hidden" name="jak_main_tpl" value="">
            <?php } ?>

            <?php if (isset($footer_tpl) && is_array($footer_tpl)) { ?>

              <div class="form-group">
                <p><label for="jak_footer_tpl"><?php echo $jkl['hd311'];?></label></p>
                <select name="jak_footer_tpl" class="selectpicker col-12" data-live-search="true">
                  <?php foreach($footer_tpl as $v) { ?>
                    <option value="<?php echo $v;?>"<?php if ($JAK_FORM_DATA["footer_tpl"] == $v) echo " selected";?>><?php echo substr($v, 0, -4);?></option>
                  <?php } ?>
                </select>
              </div>

            <?php } else { ?>
              <input type="hidden" name="jak_footer_tpl" value="">
            <?php } ?>

            <?php if (isset($jaktplclient["custom4"]) && is_array($jaktplclient["custom4"])) { ?>

              <div class="form-group">
                <p><label for="order"><?php echo $jaktplclient["custom4title"];?></label></p>
                <select name="jak_custom4" class="selectpicker col-12" data-live-search="true">
                  <?php foreach($jaktplclient["custom4"] as $k => $v) { ?>
                    <option value="<?php echo $k;?>"<?php if ($JAK_FORM_DATA["custom4"] == $k) echo " selected";?>><?php echo $v;?></option>
                  <?php } ?>
                </select>
              </div>

            <?php } else { ?>
              <input type="hidden" name="jak_custom4" value="">
            <?php } ?>

            <input type="hidden" name="jak_custom3" value="">
            <input type="hidden" name="jak_custom5" value="">

        </div>
        <div class="col-md-6">

          <div class="form-group">
            <label class="control-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 echo $JAK_FORM_DATA["external_url"];?>">
          </div>

          <div class="form-group">
            <label class="control-label" for="previmg"><?php echo $jkl["hd312"];?></label>
            <div class="input-group">
              <input type="text" name="previmg" id="previmg" class="form-control" value="<?php echo $JAK_FORM_DATA["previmg"];?>">
              <span class="input-group-btn">
                <a class="btn btn-rose btn-round btn-fab" data-toggle="modal" data-target="#jakFM" type="button" href="javascript:void(0)"><i class="far fa-file-archive"></i></a>
              </span>
            </div><!-- /input-group -->
          </div>

          <div class="form-group">
            <label class="control-label" for="meta_key"><?php echo $jkl["hd204"];?></label>
            <input type="text" maxlength="200" name="meta_key" class="form-control" value="<?php echo $JAK_FORM_DATA["meta_keywords"];?>">
          </div>

          <div class="form-group">
            <label class="control-label" for="meta_desc"><?php echo $jkl["hd205"];?></label>
            <input type="text" maxlength="200" name="meta_desc" class="form-control" value="<?php echo $JAK_FORM_DATA["meta_description"];?>">
          </div>

          <div class="form-group">
            <label class="control-label" for="jak_header"><?php echo $jkl["hd201"];?></label>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_header" value="1"<?php if ($JAK_FORM_DATA["showheader"] == 1) { ?> checked="checked"<?php } ?>> <?php echo $jkl["g19"];?>
                <span class="circle">
                  <span class="check"></span>
                </span>
              </label>
            </div>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_header" value="0"<?php if ($JAK_FORM_DATA["showheader"] == 0) { ?> checked="checked"<?php } ?>> <?php echo $jkl["g18"];?>
                <span class="circle">
                  <span class="check"></span>
                </span>
              </label>
            </div>
          </div>

          <div class="form-group">
            <label class="control-label" for="jak_ishome"><?php echo $jkl["hd203"];?></label>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_ishome" value="1"<?php if ($JAK_FORM_DATA["ishome"] == 1) { ?> checked="checked"<?php } ?>> <?php echo $jkl["g19"];?>
                <span class="circle">
                  <span class="check"></span>
                </span>
              </label>
            </div>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_ishome" value="0"<?php if ($JAK_FORM_DATA["ishome"] == 0) { ?> checked="checked"<?php } ?>> <?php echo $jkl["g18"];?>
                <span class="circle">
                  <span class="check"></span>
                </span>
              </label>
            </div>
          </div>

          <div class="form-group">
            <label class="control-label" for="jak_footer"><?php echo $jkl["hd202"];?></label>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_footer" value="1"<?php if ($JAK_FORM_DATA["showfooter"] == 1) { ?> checked="checked"<?php } ?>> <?php echo $jkl["g19"];?>
                <span class="circle">
                  <span class="check"></span>
                </span>
              </label>
            </div>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_footer" value="0"<?php if ($JAK_FORM_DATA["showfooter"] == 0) { ?> checked="checked"<?php } ?>> <?php echo $jkl["g18"];?>
                <span class="circle">
                  <span class="check"></span>
                </span>
              </label>
            </div>
          </div>

          <div class="form-group">
            <label class="control-label" for="jak_membersonly"><?php echo $jkl["hd18"];?></label>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_membersonly" value="1"<?php if ($JAK_FORM_DATA["access"] == 1) { ?> checked="checked"<?php } ?>> <?php echo $jkl["hd207"];?>
                <span class="circle">
                  <span class="check"></span>
                </span>
              </label>
            </div>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_membersonly" value="2"<?php if ($JAK_FORM_DATA["access"] == 2) { ?> checked="checked"<?php } ?>> <?php echo $jkl["hd208"];?>
                <span class="circle">
                  <span class="check"></span>
                </span>
              </label>
            </div>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_membersonly" value="3"<?php if ($JAK_FORM_DATA["access"] == 3) { ?> checked="checked"<?php } ?>> <?php echo $jkl["hd209"];?>
                <span class="circle">
                  <span class="check"></span>
                </span>
              </label>
            </div>
          </div>

          <div class="form-group">
            <label class="control-label" for="order"><?php echo $jkl["g102"];?></label>
            <input type="number" min="1" name="order" id="order" class="form-control" value="<?php echo $JAK_FORM_DATA["dorder"];?>">
          </div>

          <div class="form-group">
            <label class="control-label" for="hits"><?php echo $jkl["hd42"];?></label>
            <input type="number" min="1" name="hits" id="hits" class="form-control" value="<?php echo $JAK_FORM_DATA["hits"];?>">
          </div>

        </div>
      </div>
      <div class="alert alert-rose"><?php echo $jkl['h14'];?></div>
    </div>
    <div class="card-footer">
      <a href="<?php echo JAK_rewrite::jakParseurl('answers', 'cms');?>" class="btn btn-default"><?php echo $jkl["g103"];?></a>
      <button type="submit" name="save" class="btn btn-primary pull-right"><?php echo $jkl["g38"];?></button>
    </div>
  </div>
</form>

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