<?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"];?>
  </div>
<?php } ?>

<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
  <div class="row">
    <div class="col-md-8">
      <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 ($page1 == 'faq' ? $jkl["hd19"] : $jkl["m17"]);?></h4>
        </div>
        <div class="card-body">

          <div class="form-group<?php if (isset($errors["e"])) echo " has-danger";?>">
            <label class="control-label" for="title"><?php echo $jkl["g16"];?></label>
            <input type="text" name="title" id="title" class="form-control" value="<?php echo $JAK_FORM_DATA["title"];?>">
          </div>

          <div class="form-group<?php if (isset($errors["e1"])) echo " has-danger";?>">
            <label class="control-label" for="email"><?php echo $jkl["g68"];?></label>
            <input type="text" name="email" id="email" class="form-control" value="<?php echo $JAK_FORM_DATA["email"];?>">
          </div>

          <?php if ($page1 == 'faq') { ?>

            <div class="form-group">
              <label for="jak_class"><?php echo $jkl["m13"];?></label>
              <select name="jak_class" class="selectpicker col-12" data-size="4" data-live-search="true">
                <option value="secondary"<?php if ($JAK_FORM_DATA["class"] == "default") echo ' selected';?>>Default</option>
                <option value="primary"<?php if ($JAK_FORM_DATA["class"] == "primary") echo ' selected';?>>Primary</option>
                <option value="success"<?php if ($JAK_FORM_DATA["class"] == "success") echo ' selected';?>>Success</option>
                <option value="info"<?php if ($JAK_FORM_DATA["class"] == "info") echo ' selected';?>>Info</option>
                <option value="warning"<?php if ($JAK_FORM_DATA["class"] == "warning") echo ' selected';?>>Warning</option>
                <option value="danger"<?php if ($JAK_FORM_DATA["class"] == "danger") echo ' selected';?>>Danger</option>
                <option value="dark"<?php if ($JAK_FORM_DATA["class"] == "dark") echo ' selected';?>>Dark</option>
                <option value="white"<?php if ($JAK_FORM_DATA["class"] == "white") echo ' selected';?>>White</option>
              </select>
            </div>

            <div class="form-group">
              <label for="subcat"><?php echo $jkl["hd4"];?></label>
              <select name="jak_subcat" id="subcat" class="selectpicker col-12" data-size="4" data-live-search="true">

                <option value="0"<?php if (!isset($JAK_FORM_DATA["subcat"]) || $JAK_FORM_DATA["subcat"] == 0) echo ' selected';?>><?php echo $jkl["hd289"];?></option>
                <?php if (isset($DEPARTMENTS_ALL) && is_array($DEPARTMENTS_ALL)) foreach($DEPARTMENTS_ALL as $z) { if ($z["subcat"] == 0) { ?>

                  <option value="<?php echo $z["id"];?>"<?php if (isset($JAK_FORM_DATA["subcat"]) && $JAK_FORM_DATA["subcat"] == $z["id"]) echo ' selected';?>><?php echo $z["title"];?></option>

                <?php } } ?>

              </select>
              <small class="form-text text-muted">
                <?php echo $jkl["hd310"];?>
              </small>
            </div>

          <?php } if (JAK_BILLING_MODE == 1) { ?>

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

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

          <?php } if ($page1 != 'faq') { ?>

            <div class="form-group">
              <label class="control-label" for="faq"><?php echo $jkl["g278"];?></label>
              <input type="text" name="faq" id="faq" class="form-control" value="<?php echo $JAK_FORM_DATA["faq_url"];?>">
            </div>

          <?php } ?>

          <div class="form-group">
            <label class="control-label" for="jak_guesta"><?php echo $jkl["hd18"];?></label>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_guesta" value="1"<?php if ($JAK_FORM_DATA["guesta"] == 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_guesta" value="0"<?php if ($JAK_FORM_DATA["guesta"] == 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="desc"><?php echo $jkl["g52"];?></label>
            <textarea name="description" id="desc" rows="3" class="form-control"><?php echo $JAK_FORM_DATA["description"];?></textarea>
          </div>

          <?php if ($page1 == 'support') { ?>
            <div class="form-group">
              <label for="predefined_content"><?php echo $jkl["g151"];?></label>
              <textarea name="predefined_content" id="content-editor" rows="5" class="form-control"><?php echo $JAK_FORM_DATA["pre_content"];?></textarea>
              <a href="javascript:void(0)" class="btn btn-info btn-sm btn-round btn-fab" onclick="md.showNotification('add_alert', '<?php echo addslashes($jkl["h13"]);?>', 'info', 'top', 'center')"><i class="material-icons">help</i></a>
            </div>
          <?php } ?>

        </div>
        <div class="card-footer">
          <a href="<?php echo (!in_array($page1, array("support", "faq")) ? JAK_rewrite::jakParseurl('departments') : JAK_rewrite::jakParseurl('departments', $page1));?>" 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>
    </div>
    <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["hd146"];?></h4>
        </div>
        <div class="card-body">

          <?php if (isset($lang_files) && is_array($lang_files)) foreach($lang_files as $lf) { ?>

            <?php $newtransl = array();
            if (isset($JAK_DEP_TRANSLATION) && is_array($JAK_DEP_TRANSLATION)) foreach($JAK_DEP_TRANSLATION as $tr) {
              if ($tr['lang'] == $lf) {
                $newtransl = $tr;
              }
            }?>

            <div class="form-group">
              <label class="control-label" for="title_<?php echo $lf;?>"><?php echo strtoupper($lf).' - '.$jkl["g16"];?></label>
              <input type="text" name="title_<?php echo $lf;?>" id="title_<?php echo $lf;?>" class="form-control" value="<?php if (isset($newtransl['title'])) echo $newtransl['title'];?>">
            </div>

            <?php if ($page1 != 'faq') { ?>
              <div class="form-group">
                <label class="control-label" for="faq_<?php echo $lf;?>"><?php echo strtoupper($lf).' - '.$jkl["g278"];?></label>
                <input type="text" name="faq_<?php echo $lf;?>" id="faq_<?php echo $lf;?>" class="form-control" value="<?php if (isset($newtransl['faq_url'])) echo $newtransl['faq_url'];?>">
              </div>
            <?php } ?>

            <div class="form-group">
              <label class="control-label" for="desc_<?php echo $lf;?>"><?php echo strtoupper($lf).' - '.$jkl["g52"];?></label>
              <textarea name="description_<?php echo $lf;?>" id="desc_<?php echo $lf;?>" rows="3" class="form-control"><?php if (isset($newtransl['description'])) echo $newtransl['description'];?></textarea>
            </div>
            <?php if (is_array($newtransl) && !empty($newtransl)) { ?>
              <div class="form-check form-check-inline">
                <label class="form-check-label">
                  <input class="form-check-input" type="checkbox" name="deltrans_<?php echo $lf;?>" value="<?php if (isset($lf)) echo $lf;?>"> <?php echo $jkl["hd147"];?>
                  <span class="form-check-sign">
                    <span class="check"></span>
                  </span>
                </label>
              </div>
              <hr>
            <?php } } ?>
          </div>
          <div class="card-footer">
            <a href="<?php echo (!in_array($page1, array("support", "faq")) ? JAK_rewrite::jakParseurl('departments') : JAK_rewrite::jakParseurl('departments', $page1));?>" 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>
      </div>
    </div>
  </form>

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