HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/fieldsblaze-heroku/resources/views/admin/view-customer.blade.php
@extends('admin.include.master')

@section('content')

<style>
.wrapper {
  position: relative;
  min-height: 500px;
}

.loading {

  position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background-color: rgba(70,70,70,.5);
    color: #ffffff;
    text-align: center;
    /* margin-top: 50%; */
    padding-top: 100px;
    z-index: 99999;
}


.tblloading {


     color: #000;
     text-align: center;
     /* margin-top: 50%; */

 }

table {
  width: 100%;
}
</style>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">
        <div class="col-sm-6">
          <h1>View Customer <span class="text-info">#{{ $ViewCustomer->CustomerName }}</span></h1>
        </div>
        <div class="col-sm-6 text-right">
          @if ($ViewCustomer->IsDeleted == 0)
          <button type="submit" class="btn btn-sm btn-info mx-1" data-id="{{ $ViewCustomer->CustomerId }}"
            onclick="editCustomerRecord('{{ $ViewCustomer->CustomerId }}')">Edit Customer</button>
          <button type="submit" class="btn btn-sm btn-outline-info" data-id="{{ $ViewCustomer->CustomerId }}"
            onclick="deleteTempCustomer('{{ $ViewCustomer->CustomerId }}');">Delete Customer</button>
          @else
          <button type="submit" class="btn btn-sm btn-outline-info" data-id="{{ $ViewCustomer->CustomerId }}"
            onclick="deletePermanentCustomer('{{ $ViewCustomer->CustomerId }}');">Delete Customer</button>
          @endif

        </div>
      </div>
    </div><!-- /.container-fluid -->
  </section>

  <!-- Main content -->
  <section class="content">
    <div class="container-fluid">
      <div class="row">
        <!-- /.col -->
        <div class="col-md-12">
          <div class="card">
            <div class="card-header p-2">
              <ul class="nav nav-pills">
                <li class="nav-item"><a class="nav-link active" href="#details" data-toggle="tab">Details</a></li>
                <li class="nav-item"><a class="nav-link" href="#contacts" data-toggle="tab" onclick="getContact();">Contacts ({{
                    $CustomerContact->count() }})</a></li>
                <li class="nav-item"><a class="nav-link" href="#orders" data-toggle="tab">Orders ({{
                    $CustomerOrder->count() }})</a></li>
                <li class="nav-item"><a class="nav-link" href="#collections" data-toggle="tab">Collections ({{
                    $CustomerCollection->count() }})</a></li>
                <li class="nav-item"><a class="nav-link" href="#visits" data-toggle="tab">Visits ({{
                    $CustomerVisit->count() }})</a></li>
                <li class="nav-item"><a class="nav-link" href="#files" data-toggle="tab">Files (<span
                      id="totalFiles"></span>)</a></li>

              </ul>
            </div><!-- /.card-header -->
            <div class="card-body">
              <div class="tab-content">
                {{-- Customer Info Tab --}}
                <div class="tab-pane active" id="details">
                  <div class="row">
                    <div class="col-md-6">
                      <div class="card card-primary">
                        <div class="card-header">
                          <h3 class="card-title">Customer Info</h3>
                          <div class="card-tools">
                            <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                              <i class="fas fa-minus"></i>
                            </button>
                          </div>
                        </div>
                        <div class="card-body">
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Customer Name:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->CustomerName }}</p>
                            </div>
                            <label for="inputName" class="col-sm-4">Customer Code:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->CustomerCode }}</p>
                            </div>
                            @if ($ViewCustomer->CustomerPAN)
                            <label for="inputName" class="col-sm-4">Customer PAN:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->CustomerPAN }}</p>
                            </div>
                            @endif
                            @if ($ViewCustomer->CustomerGST)
                            <label for="inputName" class="col-sm-4">Customer GST:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->CustomerGST }}</p>
                            </div>
                            @endif
                            <label for="inputName" class="col-sm-4">Parent Customer:</label>
                            <div class="col-sm-8">
                              <p class="">{{ ucwords($ViewCustomer->ParentCustomerName) }}</p>
                            </div>
                          </div>

                          <div class="row">
                            <label for="inputName" class="col-sm-4">Customer Type:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->CustomerType }}</p>
                            </div>
                          </div>
                          @if ($ViewCustomer->DistributorName)
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Distributor:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->DistributorName }}</p>
                            </div>
                          </div>
                          @endif
                          @if ($ViewCustomer->WholeSellerName)
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Whole Seller:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->WholeSellerName }}</p>
                            </div>
                          </div>
                          @endif
                          @if ($ViewCustomer->BeatPlanName)
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Beat Plan:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->BeatPlanName }}</p>
                            </div>
                          </div>
                          @endif
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Sales Area:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->SalesArea }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Payment Term:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->PaymentTermName }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Price Book:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->PriceBookName }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Created Date:</label>
                            <div class="col-sm-8">
                              <p class="">{{ date('d-M-y, h:i a', strtotime($ViewCustomer->Created_at)) }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Created By:</label>
                            <div class="col-sm-8">
                              <p class="">
                                @if ($ViewCustomer->AdminCreated_by)
                                {{ $ViewCustomer->AdminCreated_by }}
                                @else
                                {{ $ViewCustomer->Created_by }}
                               @endif
                              </p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Last Modified Date:</label>
                            <div class="col-sm-8">
                              <p class="">{{ date('d-M-y, h:i a', strtotime($ViewCustomer->Updated_at)) }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Last Modified By:</label>
                            <div class="col-sm-8">
                              <p class="">
                                @if ($ViewCustomer->AdminUpdated_by)
                                {{ $ViewCustomer->AdminUpdated_by }}
                                @else
                                {{ $ViewCustomer->Updated_by }}
                               @endif
                              </p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Description:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->Description }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">AssignTo:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->UserName }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Customer Status:</label>
                            <div class="col-sm-8">
                              @if ($ViewCustomer->Status=='1')
                              <a href="{{ url('/status-update-customer',$ViewCustomer->id) }}"
                                class="btn btn-success bg-success btn-xs" data-toggle="tooltip" data-placement="top"
                                title="Click to De-activate" data-id="{{ $ViewCustomer->id }}">Active</a>
                              @else
                              <a href="{{ url('/status-update-customer',$ViewCustomer->id) }}"
                                class="btn btn-danger btn-xs" data-toggle="tooltip" data-placement="top"
                                title="Click to Activate">InActive</a>
                              @endif
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Customer Image:</label>
                            <div class="col-sm-8">
                              @if ($ViewCustomer->CustomerProfileImage)
                              <a href="{{ asset($ViewCustomer->CustomerProfileImage) }}" title="Download"
                                download="{{ $ViewCustomer->CustomerName }}"><img class="profile-user-img img-fluid "
                                  style="width: 120px;" src="{{ asset($ViewCustomer->CustomerProfileImage) }}"
                                  alt="{{ $ViewCustomer->CustomerName }}"></a>
                              @else
                              <i class="fa fa-user img-circle"
                                style="color:#9e9d9d; border:2px solid #9e9d9d; padding:5px;"></i>
                              @endif
                            </div>
                          </div>
                        </div>
                        <!-- /.card-body -->
                      </div>

                      <!-- /.card -->
                    </div>
                    <div class="col-md-6">
                      <div class="card card-primary">
                        <div class="card-header">
                          <h3 class="card-title">Billing Address</h3>

                          <div class="card-tools">
                            <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                              <i class="fas fa-minus"></i>
                            </button>
                          </div>
                        </div>
                        <div class="card-body">
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Street Address:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->BillingAddress }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">City:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->BillingCity }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Country:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->BillingCountry }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">State:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->BillingState }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Postal Code:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->BillingPinCode }}</p>
                            </div>
                          </div>
                        </div>
                        <!-- /.card-body -->
                      </div>
                      <!-- /.card -->
                      <div class="card card-info">
                        <div class="card-header">
                          <h3 class="card-title">Shipping Address</h3>

                          <div class="card-tools">
                            <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                              <i class="fas fa-minus"></i>
                            </button>
                          </div>
                        </div>
                        <div class="card-body">
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Street Address:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->ShippingAddress }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">City:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->ShippingCity }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Country:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->ShippingCountryName }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">State:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->ShippingState }}</p>
                            </div>
                          </div>
                          <div class="row">
                            <label for="inputName" class="col-sm-4">Postal Code:</label>
                            <div class="col-sm-8">
                              <p class="">{{ $ViewCustomer->ShippingPinCode }}</p>
                            </div>
                          </div>
                        </div>
                        <!-- /.card-body -->
                      </div>
                    </div>
                  </div>
                </div>
                <!-- /.tab-pane -->

                {{-- Contact Tab --}}
                <div class="tab-pane" id="contacts">
                  <!-- Post -->
                  <div class="card">
                    <div class="card-body">
                      <div class="text-right">
                        <button type="submit" class="btn btn-sm btn-outline-info my-1" onClick="addCustomerContact('{{ $ViewCustomer->CustomerId }}');" data-id="{{ $ViewCustomer->CustomerId }}">Add New</button>
                      </div>
                      <table id="customerContact" class="table table-bordered table-striped table-sm">
                        <thead>
                          <tr>
                            <th>S.N.</th>
                            <th>Name</th>
                            <th>Address</th>
                            <th>Mobile</th>
                            <th>Primary</th>
                            <th>Status</th>
                            <th>Created at</th>
                            <th>Action</th>
                          </tr>
                        </thead>
                        <tbody>

                          <!-- @foreach ($CustomerContact as $Contact)
                          <tr>
                            <td>{{ $loop->iteration }}</td>
                            <td><a href="{{ url('view-contact', $Contact->ContactId) }}" target="_blank">{{
                                $Contact->FirstName }}
                                {{ $Contact->LastName }}</a></td>
                            <td>{{ $Contact->StreetAddress }}, {{ $Contact->City }}, {{ $Contact->State }} -
                              {{ $Contact->Country }}</td>
                            <td>{{ $Contact->Mobile }}</td>
                            <td>
                              @if ($Contact->IsPrimary=='1')
                              <span class="badge badge-primary">Yes</span>
                              @else
                              <span class="badge badge-warning">No</span>
                              @endif
                            </td>
                            <td>
                              @if ($Contact->Status=='1')
                              <a href="{{ url('/status-update-contact',$Contact->id) }}"
                                class="btn btn-success bg-success btn-xs" data-toggle="tooltip" data-placement="top"
                                title="Click to De-activate" data-id="{{ $Contact->id }}">Active</a>
                              @else
                              <a href="{{ url('/status-update-contact',$Contact->id) }}" class="btn btn-danger btn-xs"
                                data-toggle="tooltip" data-placement="top" title="Click to Activate">InActive</a>
                              @endif
                            </td>
                            <td>{{ $Contact->Created_by }}, {{ date('d-M-y h:i:s a', strtotime($Contact->Created_at)) }}
                            </td>
                            <td>
                              <div class="btn-group">
                                <button type="button" class="btn btn-default btn-sm dropdown-toggle dropdown-icon"
                                  data-toggle="dropdown" aria-expanded="false">
                                </button>
                                <div class="dropdown-menu dropdown-menu-right" role="menu">
                                  <button type="button" class="dropdown-item btn btn-default" id="{{ $Contact->id }}"
                                    onclick="editRecordContact('{{ $Contact->id }}')">Edit</button>
                                  <button type="button" class="dropdown-item btn btn-default"
                                    data-id="{{ $Contact->id }}"
                                    onclick="deleteContact('{{ $Contact->id }}');">Delete</button>
                                </div>
                              </div>
                            </td>
                          </tr>
                          @endforeach -->

                        </tbody>
                      </table>
                    </div>
                    <!-- /.card-body -->
                  </div>
                  <!-- /.card -->
                  <!-- /.post -->
                </div>
                <!-- /.tab-pane -->

                <!-- /.tab-pane -->
                {{-- Customer Order --}}
                <div class="tab-pane" id="orders">
                  <!-- Post -->
                  <div class="card">
                    <div class="card-body">
                      <div class="text-right">
                        <button type="button" class="btn btn-sm btn-outline-info mx-1" onclick="addCustomerOrder('{{ $ViewCustomer->CustomerId }}')">Add New</button>
                      </div>
                      <table id="customerView" class="table table-bordered table-striped table-sm">
                        <thead>
                          <tr>
                            <th>S.N.</th>
                            <th>Order No.</th>
                            <th>Book Date</th>
                            <th>Delivery</th>
                            <th>Order Status</th>
                            <th>Items</th>
                            <th>Created at</th>
                            <th>Action</th>
                          </tr>
                        </thead>
                        <tbody>
                          @foreach ($CustomerOrder as $Order)
                          <tr>
                            <td>{{ $loop->iteration }}</td>
                            <!-- <td><a href="{{ url('view-order',$Order->OrderId) }}" class="href">ODR000{{ $Order->id }}</a></td> -->
                            <td><a href="{{ url('view-order',$Order->OrderId) }}" class="href" target="_blank">{{
                                $Order->OrderNo }}</a>
                            </td>
                            <td>{{ date('d-M-y', strtotime($Order->OrderBookDate)) }}</td>
                            <td>{{ date('d-M-y', strtotime($Order->OrderDeliveryDate)) }}</td>
                            <td>{{ $Order->OrderStatusId }}</td>
                            <td class="text-center">
                              @if ($Order->CountOrderItem > 0)
                              <span class="badge badge-success">{{ $Order->CountOrderItem }}</span>
                              @else
                              <span class="badge badge-warning">0</span>
                              @endif
                            </td>
                            <td>{{ $Order->Created_by }}, {{ date('d-M-y h:i:s a', strtotime($Order->Created_at)) }}
                            </td>
                            <td>
                              <div class="btn-group btn-group-sm">
                                <button type="button" class="btn btn-default btn-sm dropdown-toggle dropdown-icon"
                                  data-toggle="dropdown" aria-expanded="false">
                                </button>
                                <div class="dropdown-menu dropdown-menu-right" role="menu">
                                  <button type="button" class="dropdown-item btn btn-default" data-toggle="modal"
                                    data-target="#addProduct"
                                    onclick="getOrderProduct('{{$Order->CustomerId}}', '{{$Order->OrderNo}}', '{{$Order->OrderId}}')">Add
                                    Product</button>
                                  <a type="submit" class="dropdown-item btn btn-default"
                                    href="{{ url('view-order') }}/{{ $Order->OrderId }}" target="_blank">View Order</a>
                                  @if ($Order->CountOrderItem > 0)
                                  <a type="submit" class="dropdown-item btn btn-default"
                                    href="{{ url('order-invoice',$Order->OrderId ) }}" target="_blank">Order Invoice</a>
                                  @endif
                                  <button type="button" class="dropdown-item btn btn-default" id="{{ $Order->id }}"
                                    onclick="editOrderRecord('{{ $Order->id }}')">Edit Order</button>
                                  <button type="submit" class="dropdown-item btn btn-default" data-id="{{ $Order->id }}"
                                    onclick="deleteOrderRecord('{{ $Order->id }}');">Delete Order</button>
                                  <button type="button" class="dropdown-item btn btn-default" id="{{ $Order->id }}"
                                    onclick="takeOrderReturn('{{ $Order->id }}')">Return Order</button>
                                </div>
                              </div>
                            </td>
                          </tr>
                          @endforeach
                        </tbody>
                      </table>
                    </div>
                    <!-- /.card-body -->
                  </div>
                  <!-- /.post -->
                </div>
                <!-- /.tab-pane -->

                <!-- /.tab-pane -->
                {{-- Customer Collection --}}
                <div class="tab-pane" id="collections">
                  <!-- Post -->
                  <div class="card">
                    <div class="card-body">
                      <div class="text-right">
                        <button type="button" class="btn btn-sm btn-outline-info my-1"
                          data-id="{{ $ViewCustomer->CustomerId }}"
                          onclick="addNewCustomerColl('{{ $ViewCustomer->CustomerId }}');">Add New</button>
                      </div>
                      <table id="CustomerCollection" class="table table-bordered table-striped table-sm">
                        <thead>
                          <tr>
                            <th>S.N.</th>
                            <th>Collection No.</th>
                            <th>Payment Type</th>
                            <th>Amount</th>
                            <th>Created at</th>
                            <th>Action</th>
                          </tr>
                        </thead>
                        <tbody>
                          @foreach ($CustomerCollection as $Collection)
                          <tr>
                            <td>{{ $loop->iteration }}</td>
                            <td><a href="{{ url('view-collection',$Collection->CollectionId ) }}" target="_blank">{{
                                $Collection->CollectionNo }}</a></td>
                            <td>{{ $Collection->PaymentType }}</td>
                            <td>&#8377;{{ $Collection->AmountPaid }}</td>
                            <td>{{ $Collection->Created_by }}, {{ date('d-M-y h:m:i a',
                              strtotime($Collection->Created_at)) }}</td>
                            </td>
                            <td>
                              <div class="btn-group btn-group-sm">
                                <button type="button" class="btn btn-default btn-sm dropdown-toggle dropdown-icon"
                                  data-toggle="dropdown" aria-expanded="false">
                                </button>
                                <div class="dropdown-menu dropdown-menu-right" role="menu">
                                  <button type="button" class="dropdown-item btn btn-default"
                                    data-id="{{ $Collection->CollectionId }}"
                                    onclick="editRecordColl('{{ $Collection->CollectionId }}')">Edit</button>
                                  <button type="button" class="dropdown-item btn btn-default"
                                    data-id="{{ $Collection->CollectionId }}"
                                    onclick="deleteTempColl('{{ $Collection->CollectionId }}');">Delete</button>
                                </div>
                              </div>
                            </td>
                          </tr>
                          @endforeach
                        </tbody>
                      </table>
                    </div>
                    <!-- /.card-body -->
                  </div>

                  <!-- /.post -->
                </div>
                <!-- /.tab-pane -->

                {{-- Customer Visit --}}
                <div class="tab-pane" id="visits">
                  <!-- The post -->
                  <div class="card">
                    <div class="card-body">
                      <div class="text-right">
                        <button type="submit" class="btn btn-sm btn-outline-info my-1"
                          data-id="{{ $ViewCustomer->CustomerId }}"
                          onclick="addVisitToCustomer('{{ $ViewCustomer->CustomerId }}');">Add New</button>
                      </div>
                      <table id="customerView" class="table table-bordered table-striped table-sm">
                        <thead>
                          <tr>
                            <th>S.N.</th>
                            <th>Visit No.</th>
                            <th>User Name</th>
                            <th>Visit Type</th>
                            <th>Visit Date</th>
                            <th>Visit Status</th>
                            <th>Created at</th>
                            <th>Action</th>
                          </tr>
                        </thead>
                        <tbody>
                          @foreach ($CustomerVisit as $visit)
                          <tr>
                            <td>{{ $loop->iteration }}</td>
                            <td><a href="{{ url('view-visit', $visit->VisitId) }}" target="_blank">{{ $visit->VisitNo
                                }}</a></td>
                            <td>{{ $visit->FirstName }}@if ($visit->LastName)
                              {{ $visit->LastName }}
                              @endif</td>
                            <td>
                              @if ($visit->VisitType == "BeatPlanType")
                              <span class="badge badge-dark">Beat Type</span>
                              @else
                              <span class="badge badge-secondary">Individual</span>
                              @endif
                            </td>
                            <td>{{ date('d-M-y', strtotime($visit->VisitDate)) }}</td>
                            <td>
                              @if ($visit->VisitStatus=='2')
                              <span class="badge badge-danger">Rejected</span>
                              @elseif($visit->VisitStatus=='1')
                              <span class="badge badge-success">Approved</span>
                              @else
                              <span class="badge badge-warning">Submitted</span>
                              @endif
                            </td>
                            <td>{{ $visit->Created_by }},
                              {{ date('d-M-y h:i:s a', strtotime($visit->Created_at)) }}</td>
                            <td>
                              <div class="btn-group">
                                <button type="button" class="btn btn-default btn-sm dropdown-toggle dropdown-icon"
                                  data-toggle="dropdown" aria-expanded="false">
                                </button>
                                <div class="dropdown-menu dropdown-menu-right" role="menu">
                                  <a type="submit" class="dropdown-item btn btn-default"
                                    href="{{ url('view-visit', $visit->VisitId) }}" target="_blank">View</a>
                                  @if ($visit->VisitStatus != 1)
                                  <button type="button" class="dropdown-item btn btn-default"
                                    data-id="{{ $visit->VisitId }}"
                                    onclick="editRecordVisit('{{ $visit->VisitId }}')">Edit</button>
                                  <button type="button" class="dropdown-item btn btn-default"
                                    data-id="{{ $visit->VisitId }}"
                                    onclick="approveVisit('{{ $visit->VisitId }}');">Approve</button>
                                  @if ($visit->VisitStatus == 0)
                                  <button type="button" class="dropdown-item btn btn-default"
                                    data-id="{{ $visit->VisitId }}"
                                    onclick="rejectVisit('{{ $visit->VisitId }}');">Reject</button>
                                  @endif
                                  <button type="button" class="dropdown-item btn btn-default"
                                    data-id="{{ $visit->VisitId }}"
                                    onclick="deleteVisit('{{ $visit->VisitId }}');">Delete</button>
                                  @endif
                                </div>
                              </div>
                            </td>
                          </tr>
                          @endforeach
                        </tbody>
                      </table>
                    </div>
                    <!-- /.card-body -->
                  </div>

                </div>
                <!-- /.tab-pane -->

                {{-- Customer File --}}
                <div class="tab-pane" id="files">
                  <!-- Post -->
                  <div class="card">
                    <div class="card-body">
                      <form method="POST" id="upload-file" enctype="multipart/form-data">
                        @csrf
                        <input type="hidden" name="CustomerId" id="CustomerId" value="{{ $ViewCustomer->CustomerId }}">
                        <div class="form-group">
                          <label for="uploadFile">Add File</label>
                          <div class="input-group">
                            <div class="custom-file">
                              <input type="file" class="custom-file-input" name="uploadFile" id="uploadFile"
                                accept=".xlsx,.xls,image/*,.doc, .docx,.ppt, .pptx,.txt,.pdf" required />
                              <label class="custom-file-label" for="uploadFile">Choose file</label>
                              <span class="text-danger" id="file-input-error"></span>
                            </div>
                            <div class="input-group-append">
                              <button type="submit" name-="save-file" id="save-file" value="Upload"
                                class="input-group-text btn btn-info">Upload</button>
                            </div>
                          </div>
                        </div>
                      </form>
                      <table id="customerFiles" class="table table-bordered table-striped table-sm">
                        <thead>
                          <tr>
                            <th class="text-center">SN.</th>
                            <th>File Name</th>
                            <th>Uploaded By</th>
                            <th>Action</th>
                          </tr>
                        </thead>
                        <tbody id="tableCustomerFiles">
                          {{-- @foreach ($CustomerFile as $CustomerFile)
                          <tr>
                            <td>{{$loop->iteration}}</td>
                            <td>
                              <a href="{{ url('/')}}{{ $CustomerFile->CustomerFile }}" class="href" target="_blank"><i
                                  class="fas fa-file"></i> {{ $CustomerFile->FileName }}</a>
                            </td>
                            <td>{{ $CustomerFile->Created_by }}, {{ date('d-M-y, h:i a',
                              strtotime($ViewCustomer->Created_at)) }}</td>
                            <td>{{ $CustomerFile->Updated_by }}, {{ date('d-M-y, h:i a',
                              strtotime($ViewCustomer->Updated_at)) }}</td>
                            <td>
                              <button type="button" class="btn btn-sm btn-outline-info"
                                data-id="{{ $CustomerFile->FileId }}"
                                onclick="deleteFileTemp('{{ $CustomerFile->FileId }}');"><i
                                  class="fas fa-trash-alt"></i></button>
                              <a href="{{ url('/')}}{{'/'}}{{ $CustomerFile->CustomerFile }}"
                                class="btn btn-sm btn-outline-info mx-1" download="{{ $CustomerFile->FileName }}"><i
                                  class="fa fa-download"></i></a>
                            </td>
                          </tr>
                          @endforeach --}}

                        </tbody>
                      </table>

                    </div>
                    <!-- /.card-body -->
                  </div>

                  <!-- /.post -->
                </div>
                <!-- /.tab-pane -->

              </div>
              <!-- /.tab-content -->
            </div><!-- /.card-body -->
          </div>
          <!-- /.card -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </div>
    <div class="row">
      <div class="col-12">
        <div class="d-flex align-items-center justify-content-center">
          @if ($ViewCustomer->IsDeleted == 0)
          <button type="submit" class="btn btn-sm btn-info mx-1" data-id="{{ $ViewCustomer->CustomerId }}"
            onclick="editCustomerRecord('{{ $ViewCustomer->CustomerId }}')">Edit Customer</button>
          <button type="submit" class="btn btn-sm btn-outline-info" data-id="{{ $ViewCustomer->CustomerId }}"
            onclick="deleteTempCustomer('{{ $ViewCustomer->CustomerId }}');">Delete Customer</button>
          @else
          <button type="submit" class="btn btn-sm btn-outline-info" data-id="{{ $ViewCustomer->CustomerId }}"
            onclick="deletePermanentCustomer('{{ $ViewCustomer->CustomerId }}');">Delete Customer</button>
          @endif
        </div>
      </div>
    </div>
  </section><br />
  <!-- /.content -->
</div>
<!-- /.content-wrapper -->
<x-CustomerModal />
<x-ContactModal />
<x-CollectionModal />
<x-OrderModal />
<x-VisitModal />
{{-- List Customer File --}}
<script>
  $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });





    fetchCustomerFile();
    function fetchCustomerFile(){
      var CustomerId = $("input#CustomerId").val();
      //alert(CustomerId);

      var i = 1;
      $.ajax({
        type: "GET",
        url: "{{ url('get-customer-file') }}/" + CustomerId,
        dataType: "json",
        success: function (response) {
          //console.log( "Total");
          $('tbody#tableCustomerFiles').html("");
          $.each(response.CustomerFile, function (key, item){
            //console.log($(response).find('tr').length);
            var d = new Date(item.Created_at);
            var month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
            var date = d.getDate() + " " + month[d.getMonth()] + ", " + d.getFullYear();
            var time = d.toLocaleTimeString().toLowerCase();
            var createdDate = (date + " " +time);
            //alert(newDate);
            $('#customerFiles tbody').append('<tr>\
              <td align="middle">'+ i++ +'</td>\
              <td><a href="{{ url("/") }}/'+ item.CustomerFile +'" class="href" target="_blank">'+ item.FileName +'</a></td>\
              <td><span style="text-transform:capitalize;">'+ item.Created_by +'</span>, '+ createdDate +'</td>\
              <td><button type="button" title="Delete" onClick=deleteCustomerFile("'+ item.FileId +'"); class="btn btn-sm btn-outline-danger delete-file" data-id="'+ item.FileId +'"><i class="fas fa-trash-alt"></i></button> <a href="{{ url("/") }}'+ item.CustomerFile +'" class="btn btn-sm btn-outline-info mx-1" title="Download" download="'+ item.FileName +'"><i class="fa fa-download"></i></a></td>\
            ');

          });

          //console.log($('#customerFiles tbody').find('tr').length);
          var totalFiles = ($('#customerFiles tbody').find('tr').length);
            $('span#totalFiles').html(+ totalFiles);
        }
      });
    }

  // Customer File validation
  $('#uploadFile').change(function () {
    var ext = this.value.match(/\.(.+)$/)[1];
    switch (ext) {
        case 'jpg':
        case 'jpeg':
        case 'png':
        case 'pdf':
        case 'xlsx':
        case 'xls':
        case 'doc':
        case 'docx':
        case 'ppt':
        case 'pptx':
        case 'txt':
            //$('#btn-save-collection').attr('disabled', false);
            break;
        default:
        Swal.fire({
                        icon: 'error',
                        title: 'Oops! Invalid file!',
                        showConfirmButton: false,
                        timer: 2000
                    });
            this.value = '';
        }
    });

   $('#upload-file').submit(function(e) {
       e.preventDefault();
       let formData = new FormData(this);
       $('#file-input-error').text('');

       $.ajax({
          type:'POST',
          url: "{{ url('upload-customer-file') }}",
           data: formData,
           contentType: false,
           processData: false,
           success: (response) => {
             if (response) {
               this.reset();
               Swal.fire({
                //position: 'top-end',
                icon: 'success',
                title: 'File uploaded successfully',
                showConfirmButton: false,
                timer: 1500
              });
             }fetchCustomerFile();
           },

           error: function(response){
              console.log(response);
                $('#file-input-error').text(response.responseJSON.errors.file);
           }
       });
  });

</script>

{{-- Delete Customer File --}}
<script>
  function deleteCustomerFile(id) {
        var id = id;
        Swal.fire({
            title: 'Delete File?',
            text: "Are you sure you want to delete this File?",
            icon: 'warning',
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, delete it!'
        }).then((result) => {
            if (result.isConfirmed) {
                $.ajax({
                    type: "get",
                    url: "{{ url('/') }}/delete-customer-file/" + id,
                    success: function(response) {
                        Swal.fire({
                            icon: 'success',
                            title: 'File has been deleted!',
                            showConfirmButton: false,
                            timer: 1500
                        }).then(function() {
                          location.reload();
                        });
                    }
                });
            }
        });
    }
</script>

{{-- Delete Customer File --}}
<script>
  // $(document).ready(function (){
  //   $(".delete-filess").click(function() {
  //       var id = this.id;
  //       Swal.fire({
  //           title: 'Delete File?',
  //           text: "Are you sure you want to delete this File?",
  //           icon: 'warning',
  //           showCancelButton: true,
  //           confirmButtonColor: '#3085d6',
  //           cancelButtonColor: '#d33',
  //           confirmButtonText: 'Yes, delete it!'
  //       }).then((result) => {
  //           if (result.isConfirmed) {
  //               $.ajax({
  //                   type: "get",
  //                   url: "{{ url('/') }}/delete-customer-file/" + id,
  //                   success: function(response) {
  //                       Swal.fire({
  //                           icon: 'success',
  //                           title: 'File has been deleted!',
  //                           showConfirmButton: false,
  //                           timer: 2000
  //                       });
  //                       fetchCustomerFile();
  //                       .then(function() {
  //                           location.reload();
  //                       });
  //                   }
  //               });
  //           }
  //       });
  //   });
  // });


$( document ).ready(function() {
  ajaxGetCustomerContactList();
});


function getContact()
{
  ajaxGetCustomerContactList();
}


function ajaxGetCustomerContactList()
{

  $('.tblloading').css('display','block');

  $('#customerContact tbody').empty();
  $("#customerContact tbody").append('<tr class="tblloading text-center"><td class="tblloading" colspan="8">Please  wait...</td></tr>');
    $.ajax({
      type:'GET',
      url: "{{ url('ajax-get-customer-contact') }}/{{$CustomerId}}",
       // data: formData,
        contentType: false,
        processData: false,
        success: (response) => {
          if (response) {
            //alert(response);
            $('.tblloading').css('display','none');
            $('#customerContact tbody').empty();
            $("#customerContact tbody").append(response);
          }
        },
        error: function(response){
          console.log(response);
        }
    });
}
</script>

@endsection