Viewing file: index.blade.php (22.97 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
@extends('layouts.dashboard')
@if (auth()->user()->type =='admin') @section('title',trans('layout.customer')) @else @section('title',trans('layout.staff')) @endif
@section('css')
@endsection
@section('main-content') <div class="row page-titles mx-0"> <div class="col-sm-6 p-md-0"> <div class="welcome-text"> @if(auth()->user()->type =='admin') <h4>{{trans('layout.customer')}}</h4> @else <h4>{{trans('layout.staff')}}</h4> @endif <p class="mb-0"></p> </div> </div> <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex"> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="{{route('dashboard')}}">{{trans('layout.home')}}</a></li> @if(auth()->user()->type =='admin') <li class="breadcrumb-item active"><a href="javascript:void(0)">{{trans('layout.customer')}}</a></li> @else <li class="breadcrumb-item active"><a href="javascript:void(0)">{{trans('layout.staff')}}</a></li> @endif </ol> </div> </div> <!-- row -->
<div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-header"> <h4 class="card-title">{{trans('layout.list')}}</h4> <div class="pull-right"> <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#userCreateModal"> {{trans('layout.create')}} </button> </div> </div> <div class="card-body"> <div class="table-responsive"> <table class="table table-responsive-md"> <thead> <tr> <th><strong>#</strong></th> <th><strong>{{trans('layout.customer_details')}}</strong></th> @if(auth()->user()->type =='restaurant_owner') <th><strong>{{trans('layout.role')}}</strong></th> <th><strong>{{trans('layout.restaurant')}}</strong></th> @endif @if(auth()->user()->type =='admin') <th><strong>{{trans('layout.plan_name')}}</strong></th> <th><strong>{{trans('layout.expiry_date')}}</strong></th> <th><strong>{{trans('layout.plan_status')}}</strong></th> <th><strong>{{trans('layout.user_status')}}</strong></th> @else <th></th> <th></th> @endif <th><strong>{{trans('layout.action')}}</strong></th> </tr> </thead> <tbody> @foreach($customers as $key=> $customer) @php $currentPlan=isset($customer->current_plans[0])?$customer->current_plans[0]:''; @endphp <tr> <td>{{++$key}}</td> <td> {{$customer->name}} @if($customer->type == 'restaurant_owner') <div class="mb-1"> <span class="badge light badge-success"> {{$customer->restaurants->count()}} @if($customer->restaurants->count() == 1 || $customer->restaurants->count() == 0) {{ trans('layout.branch') }} @else {{ trans('layout.branches') }} @endif </span> </div> @endif </td> @if(auth()->user()->type =='restaurant_owner') <td>{{ucfirst(str_replace('_', ' ', $customer->role))}}</td> <td>{{$customer->restaurant->name}}</td> @endif
@if(auth()->user()->type=='admin') @if(isset($currentPlan->plan) && $currentPlan->plan->id == 1) <td>{{trans('layout.choose_a_plan')}}</td> @else <td>{{$currentPlan?ucwords($currentPlan->plan->title):''}}</td> @endif <td>{{$currentPlan?$customer->current_plans[0]->expired_date:''}}</td> <td> @if($currentPlan?ucwords($customer->current_plans[0]->status=='approved'):'') <span class="badge light badge-success">{{trans('layout.approved')}}</span> @else <span class="badge light badge-warning">{{trans('layout.pending')}}</span> @endif </td> <td> @if($customer->status=='pending') <span class="badge light badge-info">{{trans('layout.pending')}}</span> @elseif($customer->status=='banned') <span class="badge light badge-warning">{{trans('layout.banned')}}</span> @else <span class="badge light badge-success">{{trans('layout.approved')}}</span> @endif </td> @else <td></td> <td></td> @endif <td> <div class="dropdown"> <button type="button" class="btn btn-success light sharp" data-toggle="dropdown"> <svg width="20px" height="20px" viewBox="0 0 24 24" version="1.1"> <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <rect x="0" y="0" width="24" height="24"/> <circle fill="#000000" cx="5" cy="12" r="2"/> <circle fill="#000000" cx="12" cy="12" r="2"/> <circle fill="#000000" cx="19" cy="12" r="2"/> </g> </svg> </button> <div class="dropdown-menu"> <button class="dropdown-item edit_Customer" type="button" data-action="{{ route('customers.update', [$customer]) }}" data-toggle="modal" data-target="#editCustomer" data-name="{{ $customer->name }}" data-email="{{ $customer->email }}" data-role="{{ $customer->role ?? '' }}" data-restaurant="{{ $customer->restaurant_id ?? '' }}" data-plan="{{ $customer->current_plans[0]->plan_id ?? '' }}" data-id="{{ $customer->id }}"> {{ trans('layout.edit') }} </button> <button class="dropdown-item " type="button" data-message="{{trans('layout.message.customer_delete_warning')}}" data-action='{{route('customers.destroy',[$customer])}}' data-input={"_method":"delete"} data-toggle="modal" data-target="#modal-confirm">{{trans('layout.delete')}}</button> @if($customer->status == 'approved') <button class="dropdown-item" type="button" data-message="{{trans('layout.message.customer_banned_warning')}}" data-action='{{route('user.banned',[$customer])}}' data-input={"_method":"get","banned_id":"{{$customer->id}}"} data-toggle="modal" data-target="#modal-confirm">{{trans('layout.banned')}}</button> @elseif($customer->status == 'banned') <button class="dropdown-item" type="button" data-message="{{trans('layout.message.customer_approved_warning')}}" data-action='{{route('user.approved',[$customer])}}' data-input={"_method":"get","approved_id":"{{$customer->id}}"} data-toggle="modal" data-target="#modal-confirm">{{trans('layout.approved')}}</button> @else <button class="dropdown-item" type="button" data-message="{{trans('layout.message.customer_banned_warning')}}" data-action='{{route('user.banned',[$customer])}}' data-input={"_method":"get","banned_id":"{{$customer->id}}"} data-toggle="modal" data-target="#modal-confirm">{{trans('layout.banned')}}</button> <button class="dropdown-item" type="button" data-message="{{trans('layout.message.customer_approved_warning')}}" data-action='{{route('user.approved',[$customer])}}' data-input={"_method":"get","approved_id":"{{$customer->id}}"} data-toggle="modal" data-target="#modal-confirm">{{trans('layout.approved')}}</button> @endif
@if(auth()->user()->type=='admin') @if(!isset($customer->email_verified_at)) <a class="dropdown-item" href="{{route('verified.user', ['id'=>$customer->id])}}">{{trans('layout.verify')}}</a> @endif <button class="dropdown-item" type="button" data-message="{{trans('layout.message.login_as_warning')}}" data-action='{{route('restaurant.login.as',['id'=>$customer->id])}}' data-input={"_method":"get"} data-toggle="modal" data-target="#modal-confirm">{{trans('layout.login_as')}}</button> @endif </div> </div> </td> </tr> @endforeach </tbody> </table> </div> </div> </div> </div> </div> <!-- Modal Create --> @section('create-modal-id', 'userCreateModal') @section('create-modal-title', 'User Create') @section('create-modal-content-wapper') <form method="POST" action="{{route('customers.store')}}"> @csrf <div class="modal-body"> <div class="row"> <div class="col-lg-6 mb-2"> <div class="form-group"> <label class="text-label">{{trans('layout.name')}}*</label> <input type="text" name="name" class="form-control" placeholder="Ex: John Doe" required> </div> </div> <div class="col-lg-6 mb-2"> <div class="form-group"> <label class="text-label">{{trans('layout.email')}}</label> <input readonly onfocus="this.removeAttribute('readonly');" type="email" class="form-control" placeholder="Ex: hello@example.com" name="email"> </div> </div> <div class="col-lg-6 mb-2"> <div class="form-group"> <label class="text-label">{{trans('layout.password')}}</label> <input readonly onfocus="this.removeAttribute('readonly');" type="password" class="form-control" placeholder="{{trans('layout.password')}}" name="password"> </div> </div> @if(auth()->user()->type=='admin') <div class="col-lg-6"> <div class="form-group"> <label class="mb-1">{{trans('layout.choose_plan')}}</label> <select name="plan_id" id="plan" class="form-control"> @foreach($plans as $plan) <option {{isset($customer) && isset($customer->current_plans[0]) && $customer->current_plans[0]->plan_id==$plan->id?'selected':''}} value="{{$plan->id}}">{{$plan->title}} ({{formatNumberWithCurrSymbol($plan->cost)}}) </option> @endforeach </select> </div> </div> @endif @if(auth()->user()->type=='restaurant_owner') <div class="col-lg-6"> <div class="form-group"> <label class="mb-1">{{trans('layout.role')}}</label> <select name="role" class="form-control"> @foreach($roles as $role) <option {{isset($customer->role) && $customer->role==$role->name?'selected':''}} value="{{$role->name}}">{{$role->name}} </option> @endforeach </select> </div> </div> <div class="col-lg-12"> <div class="form-group"> <label class="mb-1">{{trans('layout.restaurant')}}</label> <select name="restaurant_id" class="form-control"> @foreach($restaurants as $restaurant) <option {{isset($customer->restaurant_id) && $customer->restaurant_id==$restaurant->id?'selected':''}} value="{{$restaurant->id}}">{{$restaurant->name}}</option> @endforeach </select> </div> </div> @endif </div> </div> <div class="modal-footer"> <button type="button" aria-label="Close" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary">Submit</button> </div> </form> @endsection <!-- Modal Edit -->
@section('edit-modal-id', 'editCustomer') @section('edit-modal-title', 'Edit Customer') @section('edit-modal-content-wapper') <form id="editCustomerForm" method="POST"> @csrf @method('PUT') <input type="hidden" value="" name="id" id="edit_id"> <div class="modal-body"> <div class="row"> <div class="col-lg-6 mb-2"> <div class="form-group"> <label class="text-label">{{ trans('layout.name') }}*</label> <input type="text" id="edit_name" name="name" class="form-control" placeholder="Ex: John Doe" required> </div> </div> <div class="col-lg-6 mb-2"> <div class="form-group"> <label class="text-label">{{ trans('layout.email') }}</label> <input readonly onfocus="this.removeAttribute('readonly');" id="edit_email" type="email" class="form-control" placeholder="Ex: hello@example.com" name="email"> </div> </div> <div class="col-lg-6 mb-2"> <div class="form-group"> <label class="text-label">{{ trans('layout.password') }}</label> <input readonly onfocus="this.removeAttribute('readonly');" id="edit_password" type="password" class="form-control" placeholder="{{ trans('layout.password') }}" name="password"> </div> </div> @if(auth()->user()->type == 'admin') <div class="col-lg-6"> <div class="form-group"> <label class="mb-1">{{ trans('layout.choose_plan') }}</label> <select id="edit_plan" name="plan_id" class="form-control"> @foreach($plans as $plan) <option value="{{ $plan->id }}">{{ $plan->title }} ({{ formatNumberWithCurrSymbol($plan->cost) }})</option> @endforeach </select> </div> </div> @endif @if(auth()->user()->type == 'restaurant_owner') <div class="col-lg-6"> <div class="form-group"> <label class="mb-1">{{ trans('layout.role') }}</label> <select id="edit_role" name="role" class="form-control"> @foreach($roles as $role) <option value="{{ $role->name }}">{{ $role->name }}</option> @endforeach </select> </div> </div> <div class="col-lg-12"> <div class="form-group"> <label class="mb-1">{{ trans('layout.restaurant') }}</label> <select id="edit_restaurant" name="restaurant_id" class="form-control"> @foreach($restaurants as $restaurant) <option value="{{ $restaurant->id }}">{{ $restaurant->name }}</option> @endforeach </select> </div> </div> @endif </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary">Submit</button> </div> </form> @endsection
@endsection
@section('js') <script> $(document).on("click", ".edit_Customer", function(e) { e.preventDefault();
const id = $(this).data('id'); const name = $(this).data('name'); const email = $(this).data('email'); const role = $(this).data('role'); const restaurant = $(this).data('restaurant'); const plan = $(this).data('plan'); const actionUrl = $(this).data('action');
$('#edit_id').val(id); $('#edit_name').val(name); $('#edit_email').val(email); $('#edit_password').val(''); $('#edit_role').val(role).trigger('change'); $('#edit_restaurant').val(restaurant).trigger('change'); $('#edit_plan').val(plan).trigger('change');
$('#editCustomerForm').attr('action', actionUrl); $('#editCustomerForm').attr('action', $(this).attr('data-url')); $("#editCustomer").modal('show'); }); </script>
@endsection
|