<?php
  require_once("../../session_check.php");
  require_once("../../../classes/main_classes.php");

  //OBJECTS
  $retrieveObj=new RETRIEVE();

  $get_contact_us=$retrieveObj->retriever("contact_us WHERE contact_us.c_status='deleted' ORDER BY contact_us.c_id DESC","*","fetchAll");
?>

<h4 class="page-title">
	<span class="la la-cubes"></span>
	Contacts
</h4>
<p><a href="#" class="bold" onclick="contact_us_view()">Contacts</a> <span class="fas fa-angle-right"></span> Removed contact messages</p>
<div class="row">
	<div class="col-md-12 mb-3">
    <div id="r_contacts_us_response">
      
    </div>
 		<table class="table table-head-bg-primary mt-4" id="contacts_us_table">
			<thead>
				<tr>
          <th scope="col">Fullname</th>
          <th scope="col">Email</th>
          <th scope="col">Subject</th>
          <th scope="col">Date</th>
          <th scope="col"></th>
        </tr>
			</thead>
			<tbody>
				<?php
                    
          if($get_contact_us!="1020"){
            $element_id="element_id";
              foreach ($get_contact_us as $contact_us) {
                $element_id=$element_id."Ot";
        ?>  
            <tr id="<?php echo $element_id ?>">         
              <td>
                <?php 
                  echo $contact_us->fullname;
                ?>
              </td>
              <td>
                <a href="mailto:<?php echo $contact_us->email ?>">
                  <?php 
                    echo $contact_us->email;
                  ?>
                </a>
              </td>
              <td>
                <?php 
                  echo $contact_us->subject;
                ?>
              </td>
              <td>
                <?php 
                  echo date("d-m-Y H:i:s", strtotime($contact_us->date_added));
                ?>
              </td>
              <td id="<?php echo $element_id.'Dbtn' ?>">
                  <div class="">
                    <form id="<?php echo 'R'.$element_id.'formI' ?>" class="mb-0 hand_cursor" style="display: inline;">
                        <input type="hidden" name="restore_contact_us_note" value="<?php echo $contact_us->c_id; ?>">
                        <button id="<?php echo $element_id.'Rbtn' ?>" onclick="restore_contact_us('<?php echo 'R'.$element_id.'formI' ?>','<?php echo $element_id; ?>','r_contact_us_response')" type="submit" title="Restore" class="btn btn-success hand_cursor"><span class="fas fa-sync"></span> Restore</button>
                    </form>
                    <form id="<?php echo 'R'.$element_id.'form' ?>" class="mb-0 hand_cursor" style="display: inline;">
                        <input type="hidden" name="delete_contact_us_note" value="<?php echo $contact_us->c_id; ?>">
                        <button id="<?php echo $element_id.'Rbtn' ?>" onclick="delete_contact_us('<?php echo 'R'.$element_id.'form' ?>','<?php echo $element_id; ?>','r_contact_us_response')" type="submit" title="Delete" class="btn btn-danger hand_cursor"><span class="fas fa-times "></span> Delete</button>
                    </form>
                    
                  </div>       
              </td>
            </tr>
          <?php
              }
            }
          ?>
				
			</tbody>
		</table>
	</div>
</div>
<script type="text/javascript">
  $(document).ready(function () {
    var table = $('#contacts_us_table').DataTable({
      columnDefs: [
        {bSortable: false, targets: [4]} 
      ]
    });
  })
</script>