<?php if ($_GET['page'] == 'personList'){  ?>
<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['PERSON_TABLE_NAME']; ?></th>
          <th><?php echo $langArray['PERSON_TABLE_MISSION']; ?></th>
          <th><?php echo $langArray['PERSON_TABLE_EMAIL']; ?></th>
          <th><?php echo $langArray['PERSON_TABLE_PHONE']; ?></th>
          <th><?php echo $langArray['TABLE_STATUS']; ?></th>
          <th><?php echo $langArray['TABLE_OPERATION']; ?></th>
        </tr>
      </thead>
      <tbody>
        <?php while ($allPersonCheck=$allPersonAsk->fetch(PDO::FETCH_ASSOC)){ ?>
          <tr>
            <td><?php echo $allPersonCheck['order_sort']; ?></td>
            <td><?php echo $allPersonCheck['name']; ?></td>
            <td><?php echo $allPersonCheck['mission']; ?></td>
            <td><?php echo $allPersonCheck['email']; ?></td>
            <td><?php echo $allPersonCheck['phone']; ?></td>
            <td>
              <?php if ($allPersonCheck['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=personEdit&person_id=<?php echo $allPersonCheck['person_id'] ?>"><?php echo $langArray['TABLE_EDIT']; ?></a>
               <a class="btn btn-danger" data-toggle="modal" data-target="#dataDelete-<?php echo $allPersonCheck['person_id']?>"><?php echo $langArray['TABLE_DELETE']; ?></a>
               <div class="modal fade" id="dataDelete-<?php echo  $allPersonCheck['person_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?person_id=<?php echo $allPersonCheck['person_id']; ?>&banner=<?php echo $allPersonCheck['banner']; ?>&personDelete=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['PERSON_TABLE_NAME']; ?></th>
          <th><?php echo $langArray['PERSON_TABLE_MISSION']; ?></th>
          <th><?php echo $langArray['PERSON_TABLE_EMAIL']; ?></th>
          <th><?php echo $langArray['PERSON_TABLE_PHONE']; ?></th>
          <th><?php echo $langArray['TABLE_STATUS']; ?></th>
          <th><?php echo $langArray['TABLE_OPERATION']; ?></th>
        </tr>
      </tfoot>
    </table>
  </div>
</div>
<?php }elseif($_GET['page'] == 'personAdd'){  ?>
<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-8">
          <div class="card card-primary">
            <div class="card-body">
              <!-- #form-group -->
              <div class="form-group">
                <label for="name"><?php echo $langArray['PERSON_TABLE_NAME']; ?></label>
                <input type="text" name="name" class="form-control">
              </div>
              <!-- #form-group -->
              <div class="form-group">
                <label for="mission"><?php echo $langArray['PERSON_TABLE_MISSION']; ?></label>
                <input type="text" name="mission" class="form-control">
              </div>
              <!-- #form-group -->
              <div class="form-group">
                <label for="email"><?php echo $langArray['PERSON_TABLE_EMAIL']; ?></label>
                <input type="text" name="email" class="form-control">
              </div>
              <!-- #form-group -->
              <div class="form-group">
                <label for="phone"><?php echo $langArray['PERSON_TABLE_PHONE']; ?></label>
                <input type="text" name="phone" class="form-control" data-inputmask='"mask": "(999) 999-9999"' data-mask>
              </div>
              <!-- #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="" checked data-bootstrap-switch data-off-color="danger" data-on-color="success">
                </div>
              </div>
              <!-- #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 $personCount+1; ?>">
              </div>
            </div>
          </div>
          <div class="col-12">
            <a href="usersList" 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="personAdd">
          </div>
        </div>
        <div class="col-md-4">
          <div class="card card-secondary">
            <div class="card-body">
              <div class="form-group">
                <label for="image"><?php echo $langArray['TABLE_IMAGE']; ?></label>
                <div class="input-group">
                  <div class="custom-file">
                    <input type="file" name="upload_image" class="custom-file-input">
                    <label class="custom-file-label"><?php echo $langArray['TABLE_CHOOSE_FILE']; ?></label>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="clearfix"></div>
      </div>
    </form>
  </div>
</div>
<?php }elseif($_GET['page'] == 'personEdit'){  ?>
<?php
  $askData=$db->prepare("SELECT * FROM person where person_id=:person_id");
  $askData->execute(array(
    'person_id' => $_GET["person_id"]
    ));
  $checkData=$askData->fetch(PDO::FETCH_ASSOC);

  // $_GET null or nothing
  if ($_GET['person_id'] == null) {
    Header("Location:personList");
  }elseif($_GET['person_id'] != $checkData['person_id']){
    Header("Location:personList");
  }
?>
<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="person_id" value="<?=$checkData["person_id"] ?>">
      <input type="hidden" name="isset_banner" value="<?=$checkData["banner"] ?>">
      <div class="row">
        <div class="col-md-8">
          <div class="card card-primary">
            <div class="card-body">
              <!-- #form-group -->
              <div class="form-group">
                <label for="name"><?php echo $langArray['PERSON_TABLE_NAME']; ?></label>
                <input type="text" name="name" class="form-control" value="<?php echo $checkData['name']; ?>">
              </div>
              <!-- #form-group -->
              <div class="form-group">
                <label for="mission"><?php echo $langArray['PERSON_TABLE_MISSION']; ?></label>
                <input type="text" name="mission" class="form-control" value="<?php echo $checkData['mission']; ?>">
              </div>
              <!-- #form-group -->
              <div class="form-group">
                <label for="email"><?php echo $langArray['PERSON_TABLE_EMAIL']; ?></label>
                <input type="text" name="email" class="form-control" value="<?php echo $checkData['email']; ?>">
              </div>
              <!-- #form-group -->
              <div class="form-group">
                <label for="phone"><?php echo $langArray['PERSON_TABLE_PHONE']; ?></label>
                <input type="text" name="phone" class="form-control" data-inputmask='"mask": "(999) 999-9999"' data-mask value="<?php echo $checkData['phone']; ?>">
              </div>
              <!-- #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>
              <!-- #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>
          <div class="col-12">
            <a href="personList" 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="personUpdate">
          </div>
        </div>
        <div class="col-md-4">
          <div class="card card-secondary">
            <div class="card-body">
              <div class="form-group">
                <label for="image"><?php echo $langArray['TABLE_IMAGE']; ?></label>
                <div class="input-group">
                  <div class="custom-file">
                    <input type="file" name="upload_image" class="custom-file-input">
                    <label class="custom-file-label"><?php echo $langArray['TABLE_CHOOSE_FILE']; ?></label>
                  </div>
                </div>
              </div>
              <div class="form-group">
                <?php if ($checkData['banner'] != null) { ?>
                  <img src="../<?php echo $checkData['banner']; ?>" width="100%" class="img-responsive">
                <?php } ?>
              </div>
            </div>
          </div>
        </div>
        <div class="clearfix"></div>
      </div>
    </form>
  </div>
</div>
<?php }elseif($_GET['page'] == 'personSocialList'){   ?>
<div class="card">
  <div class="card-body">
    <table id="dataTable" class="table table-bordered table-striped">
      <thead>
        <tr>
          <th>#</th>
          <th><?php echo $langArray['PERSON_SOCIAL_TABLE_NAME']; ?></th>
          <th><?php echo $langArray['PERSON_SOCIAL_TABLE_LINK']; ?></th>
          <th><?php echo $langArray['TABLE_STATUS']; ?></th>
          <th><?php echo $langArray['TABLE_OPERATION']; ?></th>
        </tr>
      </thead>
      <tbody>
        <?php while ($allPerSocialCheck=$allPerSocialAsk->fetch(PDO::FETCH_ASSOC)){ ?>
          <tr>
            <td><?php echo $allPerSocialCheck['social_id']; ?></td>
            <td>
              <?php
              $askData=$db->prepare("SELECT * FROM person where person_id=:person_id");
              $askData->execute(array(
                'person_id' => $allPerSocialCheck["personel_id"]
                ));
              $checkData=$askData->fetch(PDO::FETCH_ASSOC);
              echo $checkData['name'];
              ?>
            </td>
            <td><a href="<?php echo $allPerSocialCheck['link']; ?>" target="_blank"><i class="fa <?php echo $allPerSocialCheck['icon']; ?>"></i></a></td>
            <td>
              <?php if ($allPerSocialCheck['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-danger" data-toggle="modal" data-target="#dataDelete-<?php echo $allPerSocialCheck['social_id']?>"><?php echo $langArray['TABLE_DELETE']; ?></a>
               <div class="modal fade" id="dataDelete-<?php echo  $allPerSocialCheck['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 $allPerSocialCheck['social_id']; ?>&personSocialDelete=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><?php echo $langArray['PERSON_SOCIAL_TABLE_NAME']; ?></th>
          <th><?php echo $langArray['PERSON_SOCIAL_TABLE_LINK']; ?></th>
          <th><?php echo $langArray['TABLE_STATUS']; ?></th>
          <th><?php echo $langArray['TABLE_OPERATION']; ?></th>
        </tr>
      </tfoot>
    </table>
  </div>
</div>
<?php }elseif($_GET['page'] == 'personSocialAdd'){   ?>
<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-8">
          <div class="card card-primary">
            <div class="card-body">
              <!-- #form-group -->
              <div class="form-group">
                <label for="icon"><?php echo $langArray['PERSON_SOCIAL_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>
              <!-- #form-group -->
              <div class="form-group">
                <label for="name"><?php echo $langArray['PERSON_SOCIAL_TABLE_NAME']; ?></label>
                <select class="form-control select2" name="personel_id">
                  <?php while ($allPersonCheck=$allPersonAsk->fetch(PDO::FETCH_ASSOC)){  ?>
                    <option value="<?php echo $allPersonCheck['person_id']; ?>"><?php echo $allPersonCheck['name']; ?></option>
                  <?php } ?>
                </select>
              </div>
              <!-- #form-group -->
              <div class="form-group">
                <label for="link"><?php echo $langArray['PERSON_SOCIAL_TABLE_LINK']; ?></label>
                <input type="text" name="link" class="form-control">
              </div>
            </div>
          </div>
          <div class="col-12">
            <a href="usersList" 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="personSocialAdd">
          </div>
        </div>
        <div class="col-md-4">
          <div class="card card-secondary">
            <div class="card-body">
              <!-- #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="" checked data-bootstrap-switch data-off-color="danger" data-on-color="success">
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="clearfix"></div>
      </div>
    </form>
  </div>
</div>
<?php } ?>
