<?php if ($_GET['page'] == 'offerList'){  ?>
<div class="card">
  <div class="card-body table-responsive">
    <table id="dataTable" class="table table-bordered table-striped">
      <thead>
        <tr>
          <th>#</th>
          <th>IP</th>
          <th><?php echo $langArray['NAME_SURNAME']; ?></th>
          <th><?php echo $langArray['PHONE']; ?></th>
          <th><?php echo $langArray['EMAIL']; ?></th>
          <th><?php echo $langArray['TABLE_STATUS']; ?></th>
          <th><?php echo $langArray['TABLE_OPERATION']; ?></th>
        </tr>
      </thead>
      <tbody>
        <?php while ($allOfferCheck=$allOfferAsk->fetch(PDO::FETCH_ASSOC)){ ?>
          <tr>
            <td><?php echo $allOfferCheck['offer_id']; ?></td>
            <td><?php echo $allOfferCheck['ip']; ?></td>
            <td><?php echo $allOfferCheck['offer_name']; ?></td>
            <td><?php echo $allOfferCheck['offer_phone']; ?></td>
            <td><?php echo $allOfferCheck['offer_email']; ?></td>
            <td>
              <?php if ($allOfferCheck['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=offerEdit&offer_id=<?php echo $allOfferCheck['offer_id'] ?>"><?php echo $langArray['TABLE_EDIT']; ?></a>
               <a class="btn btn-danger" data-toggle="modal" data-target="#dataDelete-<?php echo $allOfferCheck['offer_id'] ?>"><?php echo $langArray['TABLE_DELETE']; ?></a>
               <div class="modal fade" id="dataDelete-<?php echo $allOfferCheck['offer_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?offer_id=<?php echo $allOfferCheck['offer_id']; ?>&offerDelete=success" class="btn btn-outline-light"><?php echo $langArray['TABLE_DELETE']; ?></a>
                     </div>
                   </div>
                 </div>
               </div>
            </td>
          </tr>
        <?php } ?>
      </tbody>
      <tfoot>
        <tr>
          <th>#</th>
          <th>IP</th>
          <th><?php echo $langArray['NAME_SURNAME']; ?></th>
          <th><?php echo $langArray['PHONE']; ?></th>
          <th><?php echo $langArray['EMAIL']; ?></th>
          <th><?php echo $langArray['TABLE_STATUS']; ?></th>
          <th><?php echo $langArray['TABLE_OPERATION']; ?></th>
        </tr>
      </tfoot>
    </table>
  </div>
</div>
<?php }elseif($_GET['page'] == 'offerEdit'){  ?>
<?php
  $askData=$db->prepare("SELECT * FROM offer where offer_id=:offer_id");
  $askData->execute(array(
    'offer_id' => $_GET["offer_id"]
    ));
  $checkData=$askData->fetch(PDO::FETCH_ASSOC);

  // $_GET null or nothing
  if ($_GET['offer_id'] == null) {
    Header("Location:offerList");
  }elseif($_GET['offer_id'] != $checkData['offer_id']){
    Header("Location:offerList");
  }
?>
<div class="card">
  <div class="card-body">
    <form action="system/operation.php" method="post" enctype="multipart/form-data" data-parsley-validate>
      <input type="hidden" name="offer_id" value="<?=$checkData["offer_id"] ?>">
        <div class="card">
          <div class="card-body">
            <div class="row">
              <div class="col-md-12">
                <!-- #form-group -->
                <div class="form-group">
                  <label for="name">IP</label>
                  <strong><?php echo $checkData['ip']; ?></strong>
                </div>
              </div>
              <div class="col-md-12">
                <!-- #form-group -->
                <div class="form-group">
                  <label for="name"><?php echo $langArray['NAME_SURNAME']; ?></label>
                  <strong><?php echo $checkData['offer_name']; ?></strong>
                </div>
              </div>
              <div class="col-md-12">
                <!-- #form-group -->
                <div class="form-group">
                  <label for="name"><?php echo $langArray['PHONE']; ?></label>
                  <strong><?php echo $checkData['offer_phone']; ?></strong>
                </div>
              </div>
              <div class="col-md-12">
                <!-- #form-group -->
                <div class="form-group">
                  <label for="name"><?php echo $langArray['EMAIL']; ?></label>
                  <strong><?php echo $checkData['offer_email']; ?></strong>
                </div>
              </div>
              <div class="col-md-12">
                <!-- #form-group -->
                <div class="form-group">
                  <label for="name"><?php echo $langArray['SERVICES_TITLE']; ?></label>
                  <strong>
                    <?php
                      $allPostAsk1->execute(array(
                        'post_type' => 'post_services',
                        'post_id'   => $checkData['offer_services'],
                        'language'  => $getLangCheck['language_id']
                      ));
                      $servicesCheck=$allPostAsk1->fetch(PDO::FETCH_ASSOC);
                      echo $servicesCheck['title'];
                    ?>
                  </strong>
                </div>
              </div>
              <div class="col-md-12">
                <!-- #form-group -->
                <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 class="col-12">
          <a href="offerList" 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="offerUpdate">
        </div>
      </div>
    </form>
  </div>
</div>
<?php } ?>
