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

<?php if (JAK_BILLING_MODE == 0) { ?>
  <div class="alert alert-rose"><?php echo $jkl['hd86'];?></div>
<?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('billing');?>"><?php echo $jkl["hd57"];?></a>
      </li>
      <li class="nav-item">
        <a class="nav-link active" href="<?php echo JAK_rewrite::jakParseurl('billing', 'packages');?>"><?php echo $jkl["hd60"];?></a>
      </li>
      <li class="nav-item">
          <a class="nav-link" href="<?php echo JAK_rewrite::jakParseurl('billing', 'products');?>"><?php echo $jkl["hd296"];?></a>
      </li>
    </ul>
  </div>
</div>
<hr>

<div class="row">
  <div class="col-md-4">

    <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["hd70"];?></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"];
            if (isset($errors["e3"])) echo $errors["e3"];?></div>
          <?php } ?>


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

          <div class="form-group">
            <label class="control-label" for="content"><?php echo $jkl["g52"];?></label>
            <textarea class="form-control" name="content" rows="3"><?php if (isset($_POST["content"])) echo $_POST["content"];?></textarea>
          </div>

          <div class="form-group">
            <label class="control-label" for="previmg"><?php echo $jkl["hd34"];?></label>
            <div class="input-group">
              <input type="text" name="previmg" id="previmg" class="form-control" value="<?php if (isset($_POST["previmg"])) echo $_POST["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>
          </div>

          <?php if (JAK_BILLING_MODE == 1) { ?>
            <div class="form-group">
              <label class="control-label" for="credits"><?php echo $jkl["hd61"];?></label>
              <input type="number" min="0" name="credits" class="form-control<?php if (isset($errors["e1"])) echo " is-invalid";?>" value="<?php if (isset($_POST["credits"])) echo $_POST["credits"];?>">
            </div>
          <?php } else { ?>
            <div class="form-group">
              <label class="control-label" for="paidtill"><?php echo $jkl["hd62"];?></label>
              <select name="paidtill" class="selectpicker col-12" data-live-search="true" title="<?php echo $jkl["g335"];?>">
                <option value="1 WEEK"><?php echo sprintf($jkl['hd65'], "1");?></option>
                <option value="1 MONTH"><?php echo sprintf($jkl['hd67'], "1");?></option>
                <option value="6 MONTHS"><?php echo sprintf($jkl['hd68'], "6");?></option>
                <option value="1 YEAR"><?php echo sprintf($jkl['hd69'], "1");?></option>
              </select>
            </div>
          <?php } ?>

          <div class="form-group">
            <label class="control-label" for="jak_depid"><?php echo $jkl["hd2"].$jkl['hd132'];?></label>
            <select name="jak_depid[]" class="selectpicker col-12" data-live-search="true" title="<?php echo $jkl["g335"];?>" multiple>
              <option value="0"<?php if (isset($_POST["jak_depid"]) && $_POST["jak_depid"] == 0) echo ' selected';?>><?php echo $jkl["g246"];?></option>

              <?php if (isset($JAK_DEPARTMENTS) && is_array($JAK_DEPARTMENTS)) foreach($JAK_DEPARTMENTS as $v) { ?>

                <option value="<?php echo $v["id"];?>"><?php echo $v["title"];?></option>

              <?php } ?>
            </select>
          </div>

          <div class="form-group">
            <label class="control-label" for="jak_depids"><?php echo $jkl["hd3"].$jkl['hd132'];?></label>
            <select name="jak_depids[]" class="selectpicker col-12" data-live-search="true" title="<?php echo $jkl["g335"];?>" multiple>
              <option value="0"<?php if (isset($_POST["jak_depid"]) && $_POST["jak_depid"] == 0) echo ' selected';?>><?php echo $jkl["g246"];?></option>

              <?php if (isset($JAK_DEP_SUPPORT) && is_array($JAK_DEP_SUPPORT)) foreach($JAK_DEP_SUPPORT as $d) { ?>

                <option value="<?php echo $d["id"];?>"><?php echo $d["title"];?></option>

              <?php } ?>
            </select>
          </div>

          <div class="form-group">
            <label class="control-label" for="jak_depidf"><?php echo $jkl["hd4"].$jkl['hd132'];?></label>
            <select name="jak_depidf[]" class="selectpicker col-12" data-live-search="true" title="<?php echo $jkl["g335"];?>" multiple>
              <option value="0"<?php if (isset($_POST["jak_depid"]) && $_POST["jak_depid"] == 0) echo ' selected';?>><?php echo $jkl["g246"];?></option>

              <?php if (isset($JAK_CAT_FAQ) && is_array($JAK_CAT_FAQ)) foreach($JAK_CAT_FAQ as $f) { ?>

                <option value="<?php echo $f["id"];?>"><?php echo $f["title"];?></option>

              <?php } ?>
            </select>
          </div>

          <div class="form-group">
            <label class="control-label" for="amount"><?php echo $jkl["hd71"];?></label>
            <input type="number" min="0" name="amount" class="form-control<?php if (isset($errors["e2"])) echo " is-invalid";?>" value="<?php if (isset($_POST["amount"])) echo $_POST["amount"];?>">
          </div>

          <div class="form-group">
            <label class="control-label" for="currency"><?php echo $jkl["hd72"];?></label>
            <input type="text" maxlength="3" minlength="3" name="currency" class="form-control<?php if (isset($errors["e3"])) echo " is-invalid";?>" value="<?php if (isset($_POST["currency"])) echo $_POST["currency"];?>">
          </div>

        </div>

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

      </div>

    </form>

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

        <?php if (isset($BILLING_ALL) && is_array($BILLING_ALL) && !empty($BILLING_ALL)) { ?>
          <div class="table-responsive">
            <table class="table table-striped">
              <thead>
                <tr>
                  <th>#</th>
                  <th><?php echo $jkl["g16"];?></th>
                  <?php if (JAK_BILLING_MODE == 1) { ?>
                    <th><?php echo $jkl["hd74"];?></th>
                  <?php } else { ?>
                    <th><?php echo $jkl["hd75"];?></th>
                  <?php } ?>
                  <th><?php echo $jkl["hd71"];?></th>
                  <th><?php echo $jkl["g101"];?></th>
                  <th><?php echo $jkl["g48"];?></th>
                </tr>
              </thead>
              <?php foreach($BILLING_ALL as $v) { ?>
                <tr>
                  <td><?php echo $v["id"];?></td>
                  <td class="title"><a class="btn btn-sm btn-primary" href="<?php echo JAK_rewrite::jakParseurl('billing', 'packages', 'edit', $v["id"]);?>"><?php echo $v["title"];?></a></td>
                  <?php if (JAK_BILLING_MODE == 1) { ?>
                    <td><?php echo $v["credits"];?></td>
                  <?php } else { ?>
                    <td><?php echo $v["paidtill"];?></td>
                  <?php } ?>
                  <td><?php echo $v["amount"].' '.$v["currency"];?></td>
                  <td><a class="btn btn-default btn-sm" href="<?php echo JAK_rewrite::jakParseurl('billing', 'packages', 'lock', $v["id"]);?>"><i class="fa fa-<?php if ($v["active"] == '1') { ?>check<?php } else { ?>lock<?php } ?>"></i></a></td>
                  <td><a class="btn btn-danger btn-sm btn-confirm" href="<?php echo JAK_rewrite::jakParseurl('billing', 'packages', '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-info">
            <?php echo $jkl['i3'];?>
          </div>

        <?php } ?>

      </div>
    </div>
  </div>    
</div>

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