<?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" 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 active" href="<?php echo JAK_rewrite::jakParseurl('customfield', 'form');?>"><?php echo $jkl["hd148"];?></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-success">
        <div class="card-icon">
          <i class="material-icons">add</i>
        </div>
        <h4 class="card-title "><?php echo $jkl["hd154"];?></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" name="jak_title" id="title" class="form-control<?php if (isset($errors["e"])) echo " is-invalid";?>" value="<?php if (isset($_POST["jak_title"])) echo $_POST["jak_title"];?>">
          </div>

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

          <div class="form-group">
            <label class="control-label" for="field_html"><?php echo $jkl["hd158"];?></label>
            <input type="text" name="jak_field_html" id="field_html" class="form-control<?php if (isset($errors["e2"])) echo " is-invalid";?>" value="<?php if (isset($_POST["jak_field_html"])) echo $_POST["jak_field_html"];?>">
            <small class="form-text text-muted">
              <?php echo $jkl["hd161"];?>
            </small>
          </div>

          <div class="form-group">
            <label class="control-label" for="jak_fieldloc"><?php echo $jkl["g224"];?></label>
            <select name="jak_fieldloc" class="selectpicker col-12" data-live-search="true">
              <option value="1"><?php echo $jkl['hd156'];?></option>
              <option value="2"><?php echo $jkl['hd157'];?></option>
              <option value="3"><?php echo $jkl['hd321'];?></option>
            </select>
          </div>

          <div class="form-group">
            <label class="control-label" for="field_html"><?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>
            <small class="form-text text-muted">
              <?php echo $jkl["hd162"];?>
            </small>
          </div>

          <div class="form-group">
            <label class="control-label" for="jak_fieldtype"><?php echo $jkl["hd160"];?></label>
            <select name="jak_fieldtype" class="selectpicker col-12" data-live-search="true">
              <option value="1"<?php if (isset($_POST["jak_fieldtype"]) && $_POST["jak_fieldtype"] == "1") { ?> selected="selected"<?php } ?>>INPUT</option>
              <option value="2"<?php if (isset($_POST["jak_fieldtype"]) && $_POST["jak_fieldtype"] == "2") { ?> selected="selected"<?php } ?>>RADIO</option>
              <option value="3"<?php if (isset($_POST["jak_fieldtype"]) && $_POST["jak_fieldtype"] == "3") { ?> selected="selected"<?php } ?>>CHECKBOX</option>
              <option value="4"<?php if (isset($_POST["jak_fieldtype"]) && $_POST["jak_fieldtype"] == "4") { ?> selected="selected"<?php } ?>>SELECT</option>
              <option value="5"<?php if (isset($_POST["jak_fieldtype"]) && $_POST["jak_fieldtype"] == "5") { ?> selected="selected"<?php } ?>>TEXTAREA</option>
            </select>
          </div>

          <div class="form-group">
            <label class="control-label" for="jak_mandatory"><?php echo $jkl["hd159"];?></label>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_mandatory" value="1"<?php if (!isset($_POST["jak_mandatory"]) || isset($_POST["jak_mandatory"]) && $_POST["jak_mandatory"] == 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_mandatory" value="0"<?php if (isset($_POST["jak_mandatory"]) && $_POST["jak_mandatory"] == 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_onregister"><?php echo $jkl["hd163"];?></label>
            <div class="form-check">
              <label class="form-check-label">
                <input class="form-check-input" type="radio" name="jak_onregister" value="1"<?php if (!isset($_POST["jak_onregister"]) || isset($_POST["jak_onregister"]) && $_POST["jak_onregister"] == 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_onregister" value="0"<?php if (isset($_POST["jak_onregister"]) && $_POST["jak_onregister"] == 0) { ?> checked="checked"<?php } ?>> <?php echo $jkl["g18"];?>
                <span class="circle">
                  <span class="check"></span>
                </span>
              </label>
            </div>
            <small class="form-text text-muted">
              <?php echo $jkl["hd164"];?>
            </small>
          </div>

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

      </form>
      
    </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">check_box</i>
        </div>
        <h4 class="card-title "><?php echo $jkl["hd148"];?></h4>
      </div>
      <div class="card-body">

        <?php if (isset($CUSTOMF_ALL) && is_array($CUSTOMF_ALL) && !empty($CUSTOMF_ALL)) { ?>
          <div class="table-responsive">
            <table class="table table-striped">
              <thead>
                <tr>
                  <th>#</th>
                  <th><?php echo $jkl["g16"];?></th>
                  <th><?php echo $jkl["g224"];?></th>
                  <th><?php echo $jkl["g102"];?></th>
                  <th><?php echo $jkl["g47"];?></th>
                  <th><?php echo $jkl["g48"];?></th>
                </tr>
              </thead>
              <?php foreach($CUSTOMF_ALL as $v) { ?>
                <tr>
                  <td><?php echo $v["id"];?></td>
                  <td class="title"><a href="<?php echo JAK_rewrite::jakParseurl('customfield', 'form', 'edit', $v["id"]);?>"><?php echo $v["title"];?></a></td>
                  <td class="desc"><?php echo ($v["fieldlocation"] == 1 ? '<i class="fa fa-user"></i>' : ($v["fieldlocation"] == 2 ? '<i class="fa fa-ticket-alt"></i>' : '<i class="fa fa-envelope"></i>'));?></td>
                  <td class="desc"><?php echo $v["dorder"];?></td>
                  <td><a class="btn btn-default btn-sm" href="<?php echo JAK_rewrite::jakParseurl('customfield', 'form', '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', 'form', '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>
  </div>    
</div>

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