<?php if ($_GET['page'] == 'banksList'){ ?>
<div class="card">
  <div class="card-body">
    <div class="table-responsive">
      <table id="dataTable" class="table table-bordered table-striped">
        <thead>
          <tr>
            <th><?php echo $langArray['TABLE_ORDER_SORT']; ?></th>
            <th><?php echo $langArray['BANK_TABLE_BANK_NAME']; ?></th>
            <th><?php echo $langArray['BANK_TABLE_ACCOUNT_NAME']; ?></th>
            <th><?php echo $langArray['TABLE_STATUS']; ?></th>
            <th><?php echo $langArray['TABLE_OPERATION']; ?></th>
          </tr>
        </thead>
        <tbody>
          <?php while ($allBanksCheck=$allBanksAsk->fetch(PDO::FETCH_ASSOC)){ ?>
            <tr>
              <td><?php echo $allBanksCheck['order_sort']; ?></td>
              <td><?php echo $allBanksCheck['bank_name']; ?></td>
              <td><?php echo $allBanksCheck['account_name']; ?></td>
              <td>
                <?php if ($allBanksCheck['status']== 1){ ?>
                  <i class="fas fa-eye text-success"></i>
                <?php }else{ ?>
                  <i class="fas fa-eye-slash text-danger"></i>
                <?php } ?>
              </td>
              <td>
                 <a class="btn btn-light" href="index.php?page=banksEdit&bank_id=<?php echo $allBanksCheck['bank_id'] ?>"><?php echo $langArray['TABLE_EDIT']; ?></a>
                 <a class="btn btn-danger" data-toggle="modal" data-target="#dataDelete-<?php echo $allBanksCheck['bank_id'] ?>"><?php echo $langArray['TABLE_DELETE']; ?></a>
                 <div class="modal fade" id="dataDelete-<?php echo $allBanksCheck['bank_id']  ?>">
                   <div class="modal-dialog customDialog">
                     <div class="modal-content bg-danger">
                       <div class="modal-header">
                         <h4 class="modal-title"><?php echo $langArray['ARE_YOU_SURE']; ?></h4>
                       </div>
                       <div class="modal-footer justify-content-between">
                         <button type="button" class="btn btn-outline-light" data-dismiss="modal"><?php echo $langArray['CANCEL_FORM']; ?></button>
                         <a href="system/operation.php?bank_id=<?php echo $allBanksCheck['bank_id']; ?>&banksDelete=success" class="btn btn-outline-light"><?php echo $langArray['TABLE_DELETE']; ?></a>
                       </div>
                     </div>
                   </div>
                 </div>
              </td>
            </tr>
          <?php } ?>
        </tbody>
        <tfoot>
          <tr>
            <th><?php echo $langArray['TABLE_ORDER_SORT']; ?></th>
            <th><?php echo $langArray['BANK_TABLE_BANK_NAME']; ?></th>
            <th><?php echo $langArray['BANK_TABLE_ACCOUNT_NAME']; ?></th>
            <th><?php echo $langArray['TABLE_STATUS']; ?></th>
            <th><?php echo $langArray['TABLE_OPERATION']; ?></th>
          </tr>
        </tfoot>
      </table>
    </div> 
  </div>
</div>
<?php }elseif($_GET['page'] == 'banksAdd'){ ?>
<div class="card">
  <div class="card-body">
    <form action="system/operation.php" method="post">
      <div class="row">
        <div class="col-md-8">
          <div class="card card-primary">
            <div class="card-body">
              <div class="row">
                <!-- #form-group -->
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="bank_name"><?php echo $langArray['BANK_TABLE_BANK_NAME']; ?></label>
                    <input type="text" name="bank_name" class="form-control">
                  </div>
                </div>
                <!-- #form-group -->
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="account_name"><?php echo $langArray['BANK_TABLE_ACCOUNT_NAME']; ?></label>
                    <input type="text" name="account_name" class="form-control">
                  </div>
                </div>
                <!-- #form-group -->
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="branch_code"><?php echo $langArray['BANK_TABLE_BRANCH_CODE']; ?></label>
                    <input type="number" name="branch_code" class="form-control">
                  </div>
                </div>
                <!-- #form-group -->
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="account_number"><?php echo $langArray['BANK_TABLE_ACCOUNT_NUMBER']; ?></label>
                    <input type="number" name="account_number" class="form-control">
                  </div>
                </div>
                <!-- #form-group -->
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="bank_iban"><?php echo $langArray['BANK_TABLE_BANK_IBAN']; ?></label>
                    <input type="text" name="bank_iban" class="form-control">
                  </div>
                </div>
                <!-- #form-group -->
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="order_sort"><?php echo $langArray['TABLE_ORDER_SORT']; ?></label>
                    <input type="number" name="order_sort" class="form-control" value="<?php echo $bankCount+1; ?>">
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="col-12">
            <a href="banksList" class="btn btn-secondary"><?php echo $langArray['CANCEL_FORM']; ?></a>
            <input type="submit" value="<?php echo $langArray['CREATE_FORM']; ?>" class="btn btn-success float-right" name="banksAdd">
          </div>
        </div>
        <div class="col-md-4">
          <div class="card card-primary">
            <div class="card-body">
              <!-- #form-group -->
              <div class="col-md-6">
                <div class="form-group">
                  <label for="status"><?php echo $langArray['TABLE_STATUS']; ?></label>
                  <div class="input-group">
                    <input type="checkbox" id="status" name="status[]" value="" checked data-bootstrap-switch data-off-color="danger" data-on-color="success">
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </form>
  </div>
</div>
<?php }elseif($_GET['page'] == 'banksEdit'){ ?>
<?php
  $askData=$db->prepare("SELECT * FROM banks where bank_id=:bank_id");
  $askData->execute(array(
    'bank_id' => $_GET["bank_id"]
    ));
  $checkData=$askData->fetch(PDO::FETCH_ASSOC);

  // $_GET null or nothing
  if ($_GET['bank_id'] == null) {
    Header("Location:banksList");
  }elseif($_GET['bank_id'] != $checkData['bank_id']){
    Header("Location:banksList");
  }
?>
<div class="card">
  <div class="card-body">
    <form action="system/operation.php" method="post">
      <input type="hidden" name="bank_id" value="<?=$checkData["bank_id"] ?>">
      <div class="row">
        <div class="col-md-8">
          <div class="card card-primary">
            <div class="card-body">
              <div class="row">
                <!-- #form-group -->
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="bank_name"><?php echo $langArray['BANK_TABLE_BANK_NAME']; ?></label>
                    <input type="text" name="bank_name" class="form-control" value="<?php echo $checkData['bank_name']; ?>">
                  </div>
                </div>
                <!-- #form-group -->
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="account_name"><?php echo $langArray['BANK_TABLE_ACCOUNT_NAME']; ?></label>
                    <input type="text" name="account_name" class="form-control" value="<?php echo $checkData['account_name']; ?>">
                  </div>
                </div>
                <!-- #form-group -->
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="branch_code"><?php echo $langArray['BANK_TABLE_BRANCH_CODE']; ?></label>
                    <input type="number" name="branch_code" class="form-control" value="<?php echo $checkData['branch_code']; ?>">
                  </div>
                </div>
                <!-- #form-group -->
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="account_number"><?php echo $langArray['BANK_TABLE_ACCOUNT_NUMBER']; ?></label>
                    <input type="number" name="account_number" class="form-control" value="<?php echo $checkData['account_number']; ?>">
                  </div>
                </div>
                <!-- #form-group -->
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="bank_iban"><?php echo $langArray['BANK_TABLE_BANK_IBAN']; ?></label>
                    <input type="text" name="bank_iban" class="form-control" value="<?php echo $checkData['bank_iban']; ?>">
                  </div>
                </div>
                <!-- #form-group -->
                <div class="col-md-6">
                  <div class="form-group">
                    <label for="order_sort"><?php echo $langArray['TABLE_ORDER_SORT']; ?></label>
                    <input type="number" name="order_sort" class="form-control" value="<?php echo $checkData['order_sort']; ?>">
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="col-12">
            <a href="banksList" class="btn btn-secondary"><?php echo $langArray['CANCEL_FORM']; ?></a>
            <input type="submit" value="<?php echo $langArray['UPDATE_FORM']; ?>" class="btn btn-warning float-right" name="banksUpdate">
          </div>
        </div>
        <div class="col-md-4">
          <div class="card card-primary">
            <div class="card-body">
              <!-- #form-group -->
              <div class="col-md-6">
                <div class="form-group">
                  <label for="status"><?php echo $langArray['TABLE_STATUS']; ?></label>
                  <div class="input-group">
                    <input type="checkbox" id="status" name="status[]" value="" <?php echo $checkData['status'] == "1" ? 'checked=""' : ''; ?> data-bootstrap-switch data-off-color="danger" data-on-color="success">
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </form>
  </div>
</div>

<?php } ?>
