restaurants.blade.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. @extends('layouts.app')
  2. @section('css')
  3. <link href="{!! env('APP_ASSETS') !!}css/dashboard.css" rel="stylesheet" type="text/css">
  4. @endsection
  5. @section('content')
  6. <div class="content-wrapper">
  7. <div class="container-full">
  8. <section class="content">
  9. <div class="row">
  10. <div class="col-6"><h3 style="margin-left: 10px">Businesses</h3></div>
  11. <div class="col-6 text-end"><a href="{!! env('APP_URL') !!}restaurant/new" class="btn btn-sm btn-danger float-right"><i class="glyphicon glyphicon-plus"></i> Add New </a></div>
  12. </div>
  13. <div class="row">
  14. <div class="col-xl-12">
  15. <div class="card mb-4">
  16. <div class="card-body">
  17. <div class="table-responsive">
  18. <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
  19. <thead>
  20. <tr class="text-uppercase">
  21. <!-- <th>Resto</th>-->
  22. <th width="30%">Resto Name</th>{{--
  23. <th>Short Description</th>--}}
  24. <th width="30%">Address</th>{{--
  25. <th>Phone</th>--}}
  26. <td>Status</td>
  27. <th>Action</th>
  28. </tr>
  29. </thead>
  30. <tbody>
  31. <!----><!---->
  32. @if(isset($restaurants) && $restaurants->count() > 0)
  33. @foreach($restaurants as $restaurant)
  34. <tr>
  35. <td> {!! $restaurant->name !!} </td>
  36. {{-- <td>{!! $restaurant->short_description !!}</td>--}}
  37. <td>{!! nl2br($restaurant->address) !!}</td>{{--
  38. <td>{!! $restaurant->phone !!}</td>--}}
  39. <td>{!! $restaurant->users->is_active?'<span class="badge badge-success">Active</span>':'<span class="badge badge-danger">In-active</span>' !!}</td>
  40. <td>
  41. <!-- <a href="{!! env('APP_URL') !!}restaurant/show/{!! \App\Helpers\CommonMethods::encrypt($restaurant->id) !!}" class="btn btn-success btn-sm" data-toggle="tooltip" data-placement="top" title="View"><i class="feather-eye"></i></a> -->
  42. <a href="{!! env('APP_URL') !!}restaurant/edit/{!! \App\Helpers\CommonMethods::encrypt($restaurant->id) !!}" class="btn btn-sm btn-primary" data-toggle="tooltip" data-placement="top" title="Edit"><i class="glyphicon glyphicon-edit"></i></a>
  43. <a href="javascript:;" data-id="{!! $restaurant->id !!}" class="btn btn-sm btn-danger delete-restaurant" data-toggle="tooltip" data-placement="top" title="Delete"><i class="glyphicon glyphicon-trash"></i></a>
  44. <a href="#!" class="btn btn-sm btn-info create-credentials" data-id="{!! $restaurant->id !!}" data-toggle="tooltip" data-placement="top" title="New Credentials"><i class="glyphicon glyphicon-lock"></i></a>
  45. </td>
  46. </tr>
  47. @endforeach
  48. @endif
  49. </tbody>
  50. </table>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </section>
  57. </div>
  58. </div>
  59. <div class="modal" id="create-credentials" tabindex="-1" role="dialog">
  60. <div class="modal-dialog" role="document">
  61. <div class="modal-content">
  62. <div class="modal-header">
  63. <h5 class="modal-title">Rest Login Details </h5>
  64. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  65. <span aria-hidden="true">&times;</span>
  66. </button>
  67. </div>
  68. <div class="modal-body">
  69. <p>You can reset login credentails after submitting by <strong>Save Credentails</strong></p>
  70. <table border="0" style="width: 100%">
  71. <tr>
  72. <th width="30%">Username</th>
  73. <td id="username"></td>
  74. </tr>
  75. <tr>
  76. <th>Password</th>
  77. <td id="password"></td>
  78. </tr>
  79. </table>
  80. <div class="alert alert-success" style="display: none;">Credentails are created successfully.</div>
  81. </div>
  82. <div class="modal-footer">
  83. <button type="button" class="btn btn-primary save-credentails">Save Credentails</button>
  84. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. @endsection
  90. @section('js')
  91. <script>
  92. var resto_id = 0;
  93. $(function () {
  94. $('#dataTable').DataTable({
  95. "bSort": true,
  96. "searching": true,
  97. "paging": true,
  98. "info": true,
  99. lengthMenu: [
  100. [25, 50, 100, -1],
  101. [25, 50, 100, 'All'],
  102. ],
  103. language: {
  104. paginate: {
  105. next: '<img src="{!! env("APP_ASSETS") !!}images/icons/next.png">', // or '→'
  106. previous: '<img src="{!! env("APP_ASSETS") !!}images/icons/preivew.png">' // or '←'
  107. }
  108. },
  109. });
  110. $("body").on('click','.delete-restaurant',function () {
  111. var id = $(this).data('id');
  112. $.ajax({
  113. url:"{!! env('APP_URL') !!}restaurant/delete/"+id,
  114. success:function (response) {
  115. location.reload();
  116. }
  117. });
  118. });
  119. $("body").on('click','.create-credentials',function () {
  120. var id = $(this).data('id');
  121. resto_id = id;
  122. $.ajax({
  123. url:"{!! env('APP_URL') !!}restaurant/get/credentials/"+id,
  124. success:function (response) {
  125. $("#username").html(response.username);
  126. $("#password").html(response.password);
  127. $("#create-credentials").modal('show');
  128. }
  129. });
  130. });
  131. $("body").on('click','.save-credentails',function () {
  132. var password = $("#password").html();
  133. $.ajax({
  134. url:"{!! env('APP_URL') !!}update/password",
  135. type:"POST",
  136. data:{
  137. resto_id:resto_id,
  138. password:password,
  139. '_token':"{!! csrf_token() !!}"
  140. },
  141. success:function (response) {
  142. $("#create-credentials .alert").show();
  143. setTimeout(function () {
  144. location.reload();
  145. },1500)
  146. }
  147. });
  148. });
  149. })
  150. </script>
  151. @endsection