<?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('customfield', 'ticketstatus');?>"><?php echo $jkl["hd322"];?></a>
      </li>
      <li class="nav-item">
        <a class="nav-link active" href="<?php echo JAK_rewrite::jakParseurl('customfield');?>"><?php echo $jkl["hd149"];?></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="<?php echo JAK_rewrite::jakParseurl('customfield', 'options');?>"><?php echo $jkl["hd224"];?></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="<?php echo JAK_rewrite::jakParseurl('customfield', 'form');?>"><?php echo $jkl["hd148"];?></a>
      </li>
    </ul>
    <hr>
  </div>
</div>

<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<div class="row">
  <div class="col-md-4">

    <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["hd151"];?></h4>
      </div>
      <div class="card-body">
        
        <?php if ($errors) { ?>
          <div class="alert alert-danger"><?php if (isset($errors["e"])) echo $errors["e"];?></div>
        <?php } ?>

          <div class="form-group">
            <label class="control-label" for="jak_class"><?php echo $jkl["m13"];?></label>
            <select name="jak_class" class="selectpicker col-12" data-live-search="true">
              <option value="secondary"<?php if (isset($_POST["jak_class"]) && $_POST["jak_class"] == "default") { ?> selected="selected"<?php } ?>>Default</option>
              <option value="primary"<?php if (isset($_POST["jak_class"]) && $_POST["jak_class"] == "primary") { ?> selected="selected"<?php } ?>>Primary</option>
              <option value="success"<?php if (isset($_POST["jak_class"]) && $_POST["jak_class"] == "success") { ?> selected="selected"<?php } ?>>Success</option>
              <option value="info"<?php if (isset($_POST["jak_class"]) && $_POST["jak_class"] == "info") { ?> selected="selected"<?php } ?>>Info</option>
              <option value="warning"<?php if (isset($_POST["jak_class"]) && $_POST["jak_class"] == "warning") { ?> selected="selected"<?php } ?>>Warning</option>
              <option value="danger"<?php if (isset($_POST["jak_class"]) && $_POST["jak_class"] == "danger") { ?> selected="selected"<?php } ?>>Danger</option>
              <option value="dark"<?php if (isset($_POST["jak_class"]) && $_POST["jak_class"] == "dark") { ?> selected="selected"<?php } ?>>Dark</option>
            </select>
          </div>
          
          <div class="form-group">
            <label class="control-label" for="jak_depid"><?php echo $jkl["g131"];?></label>
            <select name="jak_depid" id="jak_depid" class="selectpicker col-12" data-live-search="true">
              <option value="0"<?php if (isset($_POST["jak_depid"]) && $_POST["jak_depid"] == 0) echo ' selected="selected"';?>><?php echo $jkl["g105"];?></option>
              <?php if (isset($JAK_DEPARTMENTS) && is_array($JAK_DEPARTMENTS)) foreach($JAK_DEPARTMENTS as $z) { ?>
                <option value="<?php echo $z["id"];?>"<?php if (isset($_POST["jak_depid"]) && $z["id"] == $_POST["jak_depid"]) echo ' selected';?>><?php echo $z["title"];?></option>
              <?php } ?>
            </select>
          </div>

          <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="jak_title" class="form-control" value="<?php if (isset($_POST["jak_title"])) echo $_POST["jak_title"];?>">
          </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" class="form-control" value="<?php if (isset($_POST["credits"])) { echo $_POST["credits"]; } else { echo "0";}?>">
            </div>
          <?php } else { ?>
            <input type="hidden" name="credits" value="0">
          <?php } ?>

          <div class="form-group">
            <label class="control-label" for="jak_oponly"><?php echo $jkl["hd18"];?></label>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_oponly" value="1"<?php if (!isset($_POST["jak_oponly"]) || isset($_POST["jak_oponly"]) && $_POST["jak_oponly"] == 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_oponly" value="0"<?php if (isset($_POST["jak_oponly"]) && $_POST["jak_oponly"] == 0) { ?> checked="checked"<?php } ?>> <?php echo $jkl["g18"];?>
                <span class="circle">
                  <span class="check"></span>
                </span>
              </label>
            </div>
          </div>

        </div>
        
        <div class="card-footer">
          <button type="submit" name="insert_priority" class="btn btn-primary btn-block"><?php echo $jkl["g38"];?></button>
        </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">low_priority</i>
        </div>
        <h4 class="card-title "><?php echo $jkl["hd148"];?></h4>
      </div>
      <form method="post" action="<?php echo $_SERVER['REQUEST_URI'];?>">
      <div class="card-body">

        <?php if (isset($PRIORITY_ALL) && is_array($PRIORITY_ALL) && !empty($PRIORITY_ALL)) { ?>
          <div class="table-responsive">
            <table class="table table-striped table-hover" id="sortTable">
              <thead>
                <tr>
                  <th>#</th>
                  <th><?php echo $jkl["g16"];?></th>
                  <th><?php echo $jkl["m13"];?></th>
                  <th><?php echo $jkl["g102"];?></th>
                  <th><?php echo $jkl["g47"];?></th>
                  <th><?php echo $jkl["g48"];?></th>
                </tr>
              </thead>
              <?php foreach($PRIORITY_ALL as $v) { ?>
                <tr>
                  <td><?php echo $v["id"];?><input type="hidden" name="real_option_id[]" value="<?php echo $v["id"];?>"></td>
                  <td class="title"><a href="<?php echo JAK_rewrite::jakParseurl('customfield', 'edit', $v["id"]);?>"><?php echo $v["title"];?></a></td>
                  <td><?php echo $v["class"];?></td>
                  <td><input type="number" name="corder[]" class="corder form-control" min="1" max="100" value="<?php echo $v["dorder"];?>"></td>
                  <td><a class="btn btn-default btn-sm" href="<?php echo JAK_rewrite::jakParseurl('customfield', '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('customfield', '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>

        <?php } else { ?>

          <div class="alert alert-rose">
            <?php echo $jkl['i3'];?>
          </div>

        <?php } ?>

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

</form>

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