index.blade.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. @extends('salesman.layouts.app')
  2. @section('panel_content')
  3. <div class="aiz-titlebar text-left mt-2 mb-3 row align-items-center">
  4. <div class="align-items-center">
  5. <h1 class="h3">{{translate('All Customers')}}</h1>
  6. </div>
  7. <!--<div class="col text-right">
  8. <a href="{{ route('salesman.customers.create') }}" class="btn btn-circle btn-info">
  9. <span>{{translate('Add Virtual Account')}}</span>
  10. </a>
  11. </div> -->
  12. <div class="ml-auto" style="margin-right: 6px;">
  13. <button id="create_virtual_user" type="button" class="btn btn-outline-primary btn-block" onclick="">{{translate('Create Virtual Customers')}}</button>
  14. </div>
  15. </div>
  16. <div class="card">
  17. <form class="" id="sort_customers" action="" method="GET">
  18. <div class="card-header row gutters-5">
  19. <div class="col">
  20. <h5 class="mb-0 h6">{{translate('Customers')}}</h5>
  21. </div>
  22. <div class="dropdown mb-2 mb-md-0">
  23. <button class="btn border dropdown-toggle" type="button" data-toggle="dropdown">
  24. {{translate('Bulk Action')}}
  25. </button>
  26. <div class="dropdown-menu dropdown-menu-right">
  27. <a class="dropdown-item" href="#" onclick="bulk_delete()">{{translate('Delete selection')}}</a>
  28. </div>
  29. </div>
  30. <div class="col-md-3">
  31. <div class="form-group mb-0">
  32. <input type="text" class="form-control" id="search" name="search"@isset($sort_search) value="{{ $sort_search }}" @endisset placeholder="{{ translate('Type email or name & Enter') }}">
  33. </div>
  34. </div>
  35. </div>
  36. <div class="card-body">
  37. <table class="table aiz-table mb-0">
  38. <thead>
  39. <tr>
  40. <!--<th data-breakpoints="lg">#</th>-->
  41. <th>
  42. <div class="form-group">
  43. <div class="aiz-checkbox-inline">
  44. <label class="aiz-checkbox">
  45. <input type="checkbox" class="check-all">
  46. <span class="aiz-square-check"></span>
  47. </label>
  48. </div>
  49. </div>
  50. </th>
  51. <th>{{translate('Name')}}</th>
  52. <th data-breakpoints="lg">{{translate('Email Address')}}</th>
  53. <th data-breakpoints="lg">{{translate('Phone')}}</th>
  54. <th data-breakpoints="lg">{{translate('Package')}}</th>
  55. <th data-breakpoints="lg">{{translate('Wallet Balance')}}</th>
  56. <th>{{translate('Options')}}</th>
  57. </tr>
  58. </thead>
  59. <tbody>
  60. @foreach($users as $key => $user)
  61. @if ($user != null)
  62. <tr>
  63. <!--<td>{{ ($key+1) + ($users->currentPage() - 1)*$users->perPage() }}</td>-->
  64. <td>
  65. <div class="form-group">
  66. <div class="aiz-checkbox-inline">
  67. <label class="aiz-checkbox">
  68. <input type="checkbox" class="check-one" name="id[]" value="{{$user->id}}">
  69. <span class="aiz-square-check"></span>
  70. </label>
  71. </div>
  72. </div>
  73. </td>
  74. <td>@if($user->banned == 1) <i class="fa fa-ban text-danger" aria-hidden="true"></i> @endif {{$user->name}} @if($user->is_virtual_user == 1) (<font color="red">{{translate('Virtual')}}</font>) @endif</td>
  75. <td>{{$user->email}}</td>
  76. <td>{{$user->phone}}</td>
  77. <td>
  78. @if ($user->customer_package != null)
  79. {{$user->customer_package->getTranslation('name')}}
  80. @endif
  81. </td>
  82. <td>{{single_price($user->balance)}}</td>
  83. <td class="text-right">
  84. <a href="{{route('customers.login', encrypt($user->id))}}" class="btn btn-soft-primary btn-icon btn-circle btn-sm" title="{{ translate('Log in as this Customer') }}">
  85. <i class="las la-edit"></i>
  86. </a>
  87. @if(Auth::user()->user_type == 'salesman' && false)
  88. <a href="{{route('customers.login', encrypt($user->id))}}" class="btn btn-soft-primary btn-icon btn-circle btn-sm" title="{{ translate('Log in as this Customer') }}">
  89. <i class="las la-edit"></i>
  90. </a>
  91. @endif
  92. @if($user->banned != 1)
  93. <a href="#" class="btn btn-soft-danger btn-icon btn-circle btn-sm" onclick="confirm_ban('{{route('salesman.customers.ban', encrypt($user->id))}}');" title="{{ translate('Ban this Customer') }}">
  94. <i class="las la-user-slash"></i>
  95. </a>
  96. @else
  97. <a href="#" class="btn btn-soft-success btn-icon btn-circle btn-sm" onclick="confirm_unban('{{route('salesman.customers.ban', encrypt($user->id))}}');" title="{{ translate('Unban this Customer') }}">
  98. <i class="las la-user-check"></i>
  99. </a>
  100. @endif
  101. <a href="#" class="btn btn-soft-danger btn-icon btn-circle btn-sm confirm-delete" data-href="{{route('salesman.customers.destroy', $user->id)}}" title="{{ translate('Delete') }}">
  102. <i class="las la-trash"></i>
  103. </a>
  104. </td>
  105. </tr>
  106. @endif
  107. @endforeach
  108. </tbody>
  109. </table>
  110. <div class="aiz-pagination">
  111. {{ $users->appends(request()->input())->links() }}
  112. </div>
  113. </div>
  114. </form>
  115. </div>
  116. <div class="modal fade" id="confirm-ban">
  117. <div class="modal-dialog">
  118. <div class="modal-content">
  119. <div class="modal-header">
  120. <h5 class="modal-title h6">{{translate('Confirmation')}}</h5>
  121. <button type="button" class="close" data-dismiss="modal"></button>
  122. </div>
  123. <div class="modal-body">
  124. <p>{{translate('Do you really want to ban this Customer?')}}</p>
  125. </div>
  126. <div class="modal-footer">
  127. <button type="button" class="btn btn-light" data-dismiss="modal">{{translate('Cancel')}}</button>
  128. <a type="button" id="confirmation" class="btn btn-primary">{{translate('Proceed!')}}</a>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. <div class="modal fade" id="confirm-unban">
  134. <div class="modal-dialog">
  135. <div class="modal-content">
  136. <div class="modal-header">
  137. <h5 class="modal-title h6">{{translate('Confirmation')}}</h5>
  138. <button type="button" class="close" data-dismiss="modal"></button>
  139. </div>
  140. <div class="modal-body">
  141. <p>{{translate('Do you really want to unban this Customer?')}}</p>
  142. </div>
  143. <div class="modal-footer">
  144. <button type="button" class="btn btn-light" data-dismiss="modal">{{translate('Cancel')}}</button>
  145. <a type="button" id="confirmationunban" class="btn btn-primary">{{translate('Proceed!')}}</a>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. @endsection
  151. @section('modal')
  152. @include('modals.delete_modal')
  153. <div class="modal fade" id="virtual_user_form" data-backdrop="static">
  154. <div class="modal-dialog modal-lg">
  155. <div class="modal-content">
  156. <div class="modal-header">
  157. <h5 class="modal-title h6">{{translate('Create Virtual Customers')}}</h5>
  158. <button type="button" class="close" data-dismiss="modal"></button>
  159. </div>
  160. <div class="modal-body">
  161. <div style="margin-bottom: 16px; font-size: 14px; ">
  162. <i>{{translate('N:B: You can create virtual customers here, with a maximum of 100 people')}}</i>
  163. </div>
  164. <form class="form-horizontal" action="{{ route('customers.create_virtual_user') }}" method="POST">
  165. <!--<div class="form-group row">
  166. <div class="col-lg-2">{{translate('Name Prefix')}}</div>
  167. <div class="col-lg-6">
  168. <input type="text" class="form-control" name="name_prefix" value="" placeholder="Prefix of Name" required>
  169. </div>
  170. <div class="col-lg-4"><span>{{translate('Optional')}}</span></div>
  171. </div>-->
  172. <div class="form-group row" style="display:none;">
  173. <div class="col-lg-2">{{translate('Referrel User')}}</div>
  174. <div class="col-lg-6">
  175. <input type="number" class="form-control" name="referred_by" value="@php echo Auth::user()->id;@endphp" placeholder="Referrel User" required>
  176. </div>
  177. </div>
  178. <div class="form-group row">
  179. <div class="col-lg-2">{{translate('Quantity')}}</div>
  180. <div class="col-lg-6">
  181. <input type="number" min="1" step="1" max="100" class="form-control" name="quantity" value="1" placeholder="Quantity of generate" required>
  182. </div>
  183. </div>
  184. <div class="form-group row">
  185. <div class="col-lg-2">{{translate('Initial Balance')}}</div>
  186. <div class="col-lg-6">
  187. <input type="number" min="0" class="form-control" name="balance" value="0.00" placeholder="Initial Balance of Accounts" required>
  188. </div>
  189. </div>
  190. <div class="form-group row">
  191. <div class="col-lg-2"></div>
  192. <div class="col-lg-6">
  193. <div style="display: flex; align-items: center;">
  194. <div class="aiz-checkbox-inline" style="display: inline-block;">
  195. <label class="aiz-checkbox">
  196. <input type="checkbox" class="check-one" name="disable_login" value="1">
  197. <span class="aiz-square-check"></span>
  198. </label>
  199. </div>
  200. <span style="margin-top: 14px;">{{translate('Disable Log in')}}</span>
  201. </div>
  202. </div>
  203. </div>
  204. </form>
  205. </div>
  206. <div class="modal-footer">
  207. <button type="button" class="btn btn-light" data-dismiss="modal">{{translate('Cancel')}}</button>
  208. <a type="button" id="submitVirtualCustomer" class="btn btn-primary">{{translate('Submit')}}</a>
  209. </div>
  210. </div>
  211. </div>
  212. </div>
  213. @endsection
  214. @section('script')
  215. <script type="text/javascript">
  216. $(function() {
  217. $('#create_virtual_user').bind('click', function() {
  218. $('#virtual_user_form').modal('show')
  219. })
  220. $('#submitVirtualCustomer').bind('click', function() {
  221. let target = $(this)
  222. if (target.hasClass('disabled')) return false
  223. target.addClass('disabled');
  224. let max = $('input[name=quantity]').val()
  225. let balance = $('input[name=balance]').val()
  226. let referred_by = $('input[name=referred_by]').val()
  227. fetch('{{route('customers.create_virtual_user')}}', {
  228. method: 'POST',
  229. headers: {
  230. 'Content-Type': 'application/json',
  231. 'X-Requested-With': 'fetch'
  232. },
  233. body: JSON.stringify({
  234. _token: '{{csrf_token()}}',
  235. max,
  236. balance,
  237. referred_by,
  238. })
  239. })
  240. .then(resp => resp.text())
  241. .then(res => {
  242. if (res == 1) {
  243. AIZ.plugins.notify('success', '{{translate('Successfully created virtual customer')}}')
  244. setTimeout(() => {
  245. window.location.reload()
  246. }, 500)
  247. } else {
  248. AIZ.plugins.notify('danger', '{{translate('Executed failure Try again')}}')
  249. target.removeClass('disabled')
  250. }
  251. })
  252. .catch(err => null).finally(() => {
  253. //target.removeClass('disabled')
  254. })
  255. })
  256. })
  257. $(document).on("change", ".check-all", function() {
  258. if(this.checked) {
  259. // Iterate each checkbox
  260. $('.check-one:checkbox').each(function() {
  261. this.checked = true;
  262. });
  263. } else {
  264. $('.check-one:checkbox').each(function() {
  265. this.checked = false;
  266. });
  267. }
  268. });
  269. function sort_customers(el){
  270. $('#sort_customers').submit();
  271. }
  272. function confirm_ban(url)
  273. {
  274. $('#confirm-ban').modal('show', {backdrop: 'static'});
  275. document.getElementById('confirmation').setAttribute('href' , url);
  276. }
  277. function confirm_unban(url)
  278. {
  279. $('#confirm-unban').modal('show', {backdrop: 'static'});
  280. document.getElementById('confirmationunban').setAttribute('href' , url);
  281. }
  282. function bulk_delete() {
  283. var data = new FormData($('#sort_customers')[0]);
  284. $.ajax({
  285. headers: {
  286. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  287. },
  288. url: "{{route('bulk-customer-delete')}}",
  289. type: 'POST',
  290. data: data,
  291. cache: false,
  292. contentType: false,
  293. processData: false,
  294. success: function (response) {
  295. if(response == 1) {
  296. location.reload();
  297. }
  298. }
  299. });
  300. }
  301. </script>
  302. @endsection