123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- @extends('master')
-
- @section('title', 'Timeshare Agents')
-
- @section('description', '')
-
- @section('keywords', '')
-
- @section('content')
- <script>
- let rt = {};
-
- rt.adjustCount = 0;
- rt.firstRowValues = [];
- rt.MOBILE_SCREEN_WIDTH = 480;
-
- function reset() {
- rt.tableContainer = document.querySelector(".table-container");
- rt.initialState = rt.tableContainer.innerHTML;
- rt.table = document.querySelector(".responsive-table > tbody");
- rt.tableTitle = document.querySelector(".table-title");
- rt.firstRow = document.querySelector(".responsive-table tr:first-of-type");
- rt.firstRowValues = [];
- }
-
- reset();
-
- function getFirstRowValues() {
- for (let cell = 0; cell < rt.firstRow.children.length; cell++) {
- rt.firstRowValues.push(rt.firstRow.children[cell].textContent);
- }
- }
-
- function concatFirstRowValuesWithMainValues() {
- for (let row = 1; row < rt.table.children.length; row++) {
- for (let cell = 0; cell < rt.table.children[row].children.length; cell++) {
- rt.table.children[row].children[cell].textContent =
- rt.firstRowValues[cell] +
- ": " +
- rt.table.children[row].children[cell].textContent;
- }
- }
- }
-
- function consolidateCells() {
- for (let row = 1; row < rt.table.children.length; row++) {
- let rowValues = [];
-
- for (let cell = 0; cell < rt.table.children[row].children.length; cell++) {
- // Saving row values.
- rowValues.push(rt.table.children[row].children[cell].textContent);
- }
-
- rt.table.children[row].children[0].innerHTML = "";
-
- for (let value = 0; value < rowValues.length; value++) {
- // Inserting row values into first cell.
-
- let newValueFragment = document.createElement("div");
- let newValueFragmentContent = document.createTextNode(rowValues[value]);
- newValueFragment.appendChild(newValueFragmentContent);
-
- rt.table.children[row].children[0].appendChild(newValueFragment);
- }
- }
- }
-
- function removeExtraCells() {
- for (let row = 1; row < rt.table.children.length; row++) {
- for (let cell = 0; cell < rt.table.children[row].children.length; cell++) {
- // rt.table.children[row].children[cell].remove();
- }
- while (rt.table.children[row].children.length > 1) {
- rt.table.children[row].lastElementChild.remove();
- }
- }
- }
-
- function addTitleToTable() {
- rt.table.children[0].innerHTML = "<th>" + rt.tableTitle.textContent + "</th>";
- rt.tableTitle.remove();
- }
-
- function adjustTable() {
- rt.table.parentElement.classList.add("mobile");
- getFirstRowValues();
- concatFirstRowValuesWithMainValues();
- consolidateCells();
- removeExtraCells();
- addTitleToTable();
- }
-
- function restoreTable() {
- rt.tableContainer.innerHTML = rt.initialState;
- reset(); // Rebinding newly drawn elements.
- rt.table.parentElement.classList.remove("mobile");
- }
-
- document.addEventListener("DOMContentLoaded", () => {
- if (window.innerWidth <= rt.MOBILE_SCREEN_WIDTH) {
- rt.adjustCount++;
- adjustTable();
- }
- });
-
- window.addEventListener("resize", () => {
- if (window.innerWidth < rt.MOBILE_SCREEN_WIDTH) {
- if (!rt.adjustCount) {
- rt.adjustCount++;
- adjustTable();
- }
- } else {
- restoreTable();
- rt.adjustCount = 0;
- }
- });
-
- function Conform_Delete() {
- return confirm("Are you sure want to delete this timeshare agent?");
- }
-
- </script>
-
- <div class="container-fluid">
- <div class="row mb-4 mt-5">
- <div class="col-md-10 offset-md-1">
- <!--<form id="mainForm" method="POST" action="/search" accept-charset="UTF-8" enctype="multipart/form-data">
- @csrf
- <div class="form-row">
- <div class="col-md-5 offset-md-3">
- <input class="form-control" name="search" type="text">
- </div>
- <div class="col-md-2">
- <button class="btn btn-blue" type="submit">
- <i class="fas fa-search-plus"></i>
- SEARCH
- </button>
- </div>
- </div>
- </form> -->
-
- <!--
- <form id="mainForm" method="POST" action="/upload-timeshares" accept-charset="UTF-8" enctype="multipart/form-data">
- @csrf
- <div style="margin-left: 18rem;" class="col-md-10 offset-md-1">
- <label for="file">Excel Upload</label>
- <input type="file" id="file" name="ex_file">
- <button class="btn btn-blue" type="submit">
- LOAD
- </button>
- </div>
- </form> -->
- <h1>Timeshare Agents under {{ Auth::user()->agency }}</h1>
- </div>
- </div>
-
- <div class="row">
- <div class="col-md-10 offset-md-1 table-responsive">
- <a class="btn btn-blue" href="/register-timeshare-agent">Add an agent</a>
- <br><br>
- <table class="table table-bordered table-hover table-striped">
- <thead>
- <tr>
- <th>Name</th>
- <th>Email</th>
- <th>Phone</th>
- <th>Verified</th>
- <th>Edit</th>
- <th>Delete</th>
- </tr>
- </thead>
- <tbody>
- @foreach($agents as $agent)
- <tr>
- <td>{{ $agent->name }}</td>
- <td>{{ $agent->email }}</td>
- <td>{{ $agent->phone }}</td>
- @if($agent->timeshare_publish==1)
- <td class="text-center">
- <a href="/publishTimeshareAgent/{{ $agent->id }}">
- <i class="fas fa-cloud-upload-alt fa-2x text-success"></i>
- </a>
- </td>
- @else
- <td class="text-center">
- <a href="/publishTimeshareAgent/{{ $agent->id }}">
- <i class="fas fa-cloud-upload-alt fa-2x text-danger"></i>
- </a>
- </td>
- @endif
-
- <td class="text-center">
- <a href="/edit-timeshare-agent/{{ $agent->id }}">
- <i class="far fa-edit blue-text fa-2x"></i>
- </a>
- </td>
-
- <td class="text-center">
- <a onclick="return Conform_Delete()" href="/deleteTimeshareAgent/{{ $agent->id }}">
- <i class="fas fa-times fa-2x text-danger"></i>
- </a>
- </td>
- </tr>
- @endforeach
- </tbody>
- </table>
- </div>
-
- <div class="col-md-6 offset-md-3 mb-4 d-flex justify-content-center">
- <?php echo $agents->links(); ?>
- </div>
- </div>
- </div>
-
-
- @stop
|