<?php include_once APP_PATH.JAK_OPERATOR_LOC.'/template/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('settings');?>"><?php echo $jkl["hd9"];?></a>
      </li>
      <?php if ($jakosub['tickets'] && jak_get_access("support", $jakuser->getVar("permissions"), JAK_MAIN_OP)){?>
        <li class="nav-item">
          <a class="nav-link" href="<?php echo JAK_rewrite::jakParseurl('settings', 'support');?>"><?php echo $jkl["hd10"];?></a>
        </li>
      <?php } if ($jakosub['faq'] && jak_get_access("faq", $jakuser->getVar("permissions"), JAK_MAIN_OP)){?>
        <li class="nav-item">
          <a class="nav-link" href="<?php echo JAK_rewrite::jakParseurl('settings', 'faq');?>"><?php echo $jkl["hd11"];?></a>
        </li>
      <?php } if ($jakosub['blog'] && jak_get_access("blog", $jakuser->getVar("permissions"), JAK_MAIN_OP)){?>
        <li class="nav-item">
          <a class="nav-link" href="<?php echo JAK_rewrite::jakParseurl('settings', 'blog');?>"><?php echo $jkl["hd12"];?></a>
        </li>
      <?php } ?>
      <li class="nav-item">
        <a class="nav-link" href="<?php echo JAK_rewrite::jakParseurl('settings', 'email');?>"><?php echo $jkl["hd119"];?></a>
      </li>
      <?php if ($jakosub['tickets'] && jak_get_access("support", $jakuser->getVar("permissions"), JAK_MAIN_OP)){?>
        <li class="nav-item">
          <a class="nav-link active" href="<?php echo JAK_rewrite::jakParseurl('settings', 'phpimap');?>"><?php echo $jkl["hd43"];?></a>
        </li>
      <?php } ?>
    </ul>
  </div>
</div>
<hr>

<?php if (!$addphpimap) { ?>
  <div class="alert alert-info"><?php echo sprintf($jkl['i14'], $totalAll, $totalphpimap, $jkl['i62']);?></div>
<?php } ?>

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

        <?php if (isset($PHPIMAP_ALL) && is_array($PHPIMAP_ALL)) { ?>
          <form method="post" class="jak_form" action="<?php echo $_SERVER['REQUEST_URI'];?>">
            <div class="table-responsive">
              <?php foreach($PHPIMAP_ALL as $v) { ?>
                <table class="table table-striped" cellspacing="0" width="100%">
                  <thead>
                    <tr>
                      <th>#</th>
                      <th><?php echo $jkl['hd48'];?></th>
                      <th><?php echo $jkl['u2'];?></th>
                      <th><?php echo $jkl['g47'];?></th>
                      <th><?php echo $jkl["g101"];?></th>
                      <th><?php echo $jkl["g48"];?></th>
                    </tr>
                  </thead>
                  <tr>
                    <td><?php echo $v["id"];?></td>
                    <td class="title"><a href="<?php echo JAK_rewrite::jakParseurl('settings', 'phpimap', 'edit', $v["id"]);?>"><?php echo $v["mailbox"];?></a></td>
                    <td class="desc"><?php echo $v["username"];?></td>
                    <td><a href="<?php echo JAK_rewrite::jakParseurl('settings', 'phpimap', 'edit', $v["id"]);?>" class="btn btn-sm btn-primary"><i class="fa fa-pencil"></i></a></td>
                    <td><a href="<?php echo JAK_rewrite::jakParseurl('settings', 'phpimap', 'lock', $v["id"]);?>" title="<?php if ($v["active"] == 1) { echo $jkl['g101']; } else { echo $jkl['hd54'];}?>" class="btn btn-sm btn-default"><i class="fa fa-<?php if ($v["active"] == '1') { ?>check<?php } else { ?>times<?php } ?>"></i></a></td>
                    <td><a href="<?php echo JAK_rewrite::jakParseurl('settings', 'phpimap', 'delete', $v["id"]);?>" class="btn btn-sm btn-danger" onclick="if(!confirm('<?php echo $jkl['e30'];?>'))return false;"><i class="fa fa-trash"></i></a></td>
                  </tr>

                </table>
              <?php } ?>
            </div>
          </form>
        <?php } else { ?>
          <div class="alert alert-rose"><?php echo $jkl['i3'];?></div>
        <?php } ?>
      </div>
    </div>
  </div>
  <div class="col-md-4">

    <?php if ($addphpimap) { ?>

      <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">add</i>
            </div>
            <h4 class="card-title "><?php echo $jkl["hd46"];?></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 } ?>

            <div class="form-group">
              <select name="jak_depid" id="jak_depid" class="selectpicker col-12" data-live-search="true">
                <option disabled><?php echo $jkl['g131'];?></option>
                <?php foreach ($JAK_DEPARTMENTS as $p) { ;?><option value="<?php echo $p["id"];?>"<?php if (isset($_POST['jak_depid']) && $_POST['jak_depid'] == $p["id"]) { ?> selected="selected"<?php } ?>><?php echo $p["title"];?></option><?php } ?>
              </select>
            </div>
            <div class="form-group<?php if (isset($errors["e"])) echo " has-danger";?>">
              <label class="control-label" for="mailbox"><?php echo $jkl['hd48'];?></label>
              <input type="text" name="mailbox" class="form-control" value="<?php if (isset($_POST["mailbox"])) echo $_POST["mailbox"];?>">
            </div>
            <div class="form-group<?php if (isset($errors["e1"])) echo " has-danger";?>">
              <label class="control-label" for="usrphpimap"><?php echo $jkl['u2'];?></label>
              <input type="text" name="usrphpimap" class="form-control" value="<?php if (isset($_POST["usrphpimap"])) echo $_POST["usrphpimap"];?>" autocomplete="off">
            </div>
            <div class="form-group">
              <label class="control-label" for="passphpimap"><?php echo $jkl['u4'];?></label>
              <input type="password" name="passphpimap" class="form-control" value="<?php if (isset($_POST["passphpimap"])) echo $_POST["passphpimap"];?>">
            </div>
            <div class="form-group">
              <label class="control-label" for="encryption"><?php echo $jkl['hd49'];?></label>
              <input type="text" name="encryption" class="form-control" value="<?php if (isset($_POST["encryption"])) echo $_POST["encryption"];?>">
            </div>
            <div class="form-group">
              <label class="control-label" for="inbox"><?php echo $jkl['hd50'];?></label>
              <input type="text" name="inbox" class="form-control" value="<?php if (isset($_POST["inbox"])) echo $_POST["inbox"];?>">
            </div>
            <div class="form-group<?php if (isset($errors["e2"])) echo " has-danger";?>">
              <label class="control-label" for="email"><?php echo $jkl['u1'];?></label>
              <input type="text" name="email" class="form-control" value="<?php if (isset($_POST["email"])) echo $_POST["email"];?>">
            </div>

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

        </div>

      </form>

    <?php } ?>

  </div>

</div>

<?php include_once APP_PATH.JAK_OPERATOR_LOC.'/template/footer.php';?>
