<?php if ($_GET['page'] == 'socialList'){ ?>
<div class="card">
  <div class="card-body 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['GLOBAL_FORM_TABLE_ICON']; ?></th>
          <th><?php echo $langArray['GLOBAL_FORM_TABLE_TITLE']; ?></th>
          <th><?php echo $langArray['TABLE_STATUS']; ?></th>
          <th><?php echo $langArray['TABLE_OPERATION']; ?></th>
        </tr>
      </thead>
      <tbody>
        <?php while ($allSocialCheck=$allSocialAsk->fetch(PDO::FETCH_ASSOC)){ ?>
          <tr>
            <td><?php echo $allSocialCheck['social_id']; ?></td>
            <td><i class="fa <?php echo $allSocialCheck['icon']; ?>"></i></td>
            <td><?php echo $allSocialCheck['name']; ?></td>
            <td>
              <?php if ($allSocialCheck['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=socialEdit&social_id=<?php echo $allSocialCheck['social_id'] ?>"><?php echo $langArray['TABLE_EDIT']; ?></a>
               <a class="btn btn-danger" data-toggle="modal" data-target="#dataDelete-<?php echo $allSocialCheck['social_id'] ?>"><?php echo $langArray['TABLE_DELETE']; ?></a>
               <div class="modal fade" id="dataDelete-<?php echo $allSocialCheck['social_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?social_id=<?php echo $allSocialCheck['social_id']; ?>&socialDelete=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['GLOBAL_FORM_TABLE_ICON']; ?></th>
          <th><?php echo $langArray['GLOBAL_FORM_TABLE_TITLE']; ?></th>
          <th><?php echo $langArray['TABLE_STATUS']; ?></th>
          <th><?php echo $langArray['TABLE_OPERATION']; ?></th>
        </tr>
      </tfoot>
    </table>
  </div>
</div>
<?php }elseif($_GET['page'] == 'socialAdd'){ ?>
<div class="card">
  <div class="card-body">
    <form action="system/operation.php" method="post" enctype="multipart/form-data" data-parsley-validate>
      <div class="row">
        <div class="col-md-12">
          <div class="card card-secondary">
            <div class="card-body row">
              <div class="col-md-6">
                <!-- #form-group -->
                <div class="form-group">
                  <label for="icon"><?php echo $langArray['GLOBAL_FORM_TABLE_ICON']; ?></label>
                  <select class="form-control select2 select-awesome" name="icon">
                    <?php while ($allIconCheck=$allIconAsk->fetch(PDO::FETCH_ASSOC)){  ?>
                      <option value="<?php echo $allIconCheck['icon_class']; ?>"><?php echo $allIconCheck['icon_cheatsheet']; ?> - <?php echo $allIconCheck['icon_class']; ?></option>
                    <?php } ?>
                  </select>
                </div>
              </div>
              <div class="col-md-6">
                <!-- #form-group -->
                <div class="form-group">
                  <label for="name"><?php echo $langArray['GLOBAL_FORM_TABLE_TITLE']; ?></label>
                  <input type="text" name="name" class="form-control">
                </div>
              </div>
              <div class="col-md-6">
                <!-- #form-group -->
                <div class="form-group">
                  <label for="link"><?php echo $langArray['GLOBAL_FORM_TABLE_LINK']; ?></label>
                  <input type="text" name="link" class="form-control">
                </div>
              </div>
              <div class="col-md-6">
                <!-- #form-group -->
                <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 $socialCount+1; ?>">
                </div>
              </div>
              <div class="col-md-6">
                <!-- #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[]" checked data-bootstrap-switch data-off-color="danger" data-on-color="success">
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="col-12">
            <a href="socialList" 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="socialAdd">
          </div>
          <div class="clearfix"></div>
        </div>
      </div>
    </form>
  </div>
</div>
<?php }elseif($_GET['page'] == 'socialEdit'){ ?>
<?php
  $askData=$db->prepare("SELECT * FROM social where social_id=:social_id");
  $askData->execute(array(
    'social_id' => $_GET["social_id"]
    ));
  $checkData=$askData->fetch(PDO::FETCH_ASSOC);
  // $_GET null or nothing
  if ($_GET['social_id'] == null) {
    Header("Location:socialList");
  }elseif($_GET['social_id'] != $checkData['social_id']){
    Header("Location:socialList");
  }
?>
<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="social_id" value="<?=$checkData["social_id"] ?>">
      <div class="row">
        <div class="col-md-12">
          <div class="card card-secondary">
            <div class="card-body row">
              <div class="col-md-6">
                <!-- #form-group -->
                <div class="form-group">
                  <label for="icon"><?php echo $langArray['GLOBAL_FORM_TABLE_ICON']; ?></label>
                  <select class="form-control select2 select-awesome" name="icon">
                    <?php while ($allIconCheck=$allIconAsk->fetch(PDO::FETCH_ASSOC)){  ?>
                      <option <?php echo $checkData['icon'] == $allIconCheck['icon_class'] ? 'selected=""' : ''; ?> value="<?php echo $allIconCheck['icon_class']; ?>"><?php echo $allIconCheck['icon_cheatsheet']; ?> - <?php echo $allIconCheck['icon_class']; ?></option>
                    <?php } ?>
                  </select>
                </div>
              </div>
              <div class="col-md-6">
                <!-- #form-group -->
                <div class="form-group">
                  <label for="name"><?php echo $langArray['GLOBAL_FORM_TABLE_TITLE']; ?></label>
                  <input type="text" name="name" class="form-control" value="<?php echo $checkData['name']; ?>">
                </div>
              </div>
              <div class="col-md-6">
                <!-- #form-group -->
                <div class="form-group">
                  <label for="link"><?php echo $langArray['GLOBAL_FORM_TABLE_LINK']; ?></label>
                  <input type="text" name="link" class="form-control" value="<?php echo $checkData['link']; ?>">
                </div>
              </div>
              <div class="col-md-6">
                <!-- #form-group -->
                <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 class="col-md-6">
                <!-- #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[]" <?php echo $checkData['status'] == "1" ? 'checked=""' : ''; ?> data-bootstrap-switch data-off-color="danger" data-on-color="success">
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="col-12">
            <a href="socialList" 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="socialUpdate">
          </div>
          <div class="clearfix"></div>
        </div>
      </div>
    </form>
  </div>
</div>
<?php } ?>
