index.blade.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. @extends('backend.layouts.app')
  2. @section('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('customers.create') }}" class="btn btn-circle btn-info">
  9. <span>{{translate('Add Virtual Account')}}</span>
  10. </a>
  11. </div> -->
  12. <div class="" style="margin-left: 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>
  75. @if ($user->is_virtual_user == 1)<span class='badge badge-inline badge-warning' style="margin-right: 4px; ">{{translate('Virtual')}}</span>@endif
  76. @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>
  77. <td>{{$user->email}}</td>
  78. <td>{{$user->phone}}</td>
  79. <td>
  80. @if ($user->customer_package != null)
  81. {{$user->customer_package->getTranslation('name')}}
  82. @endif
  83. </td>
  84. <td>{{single_price($user->balance)}}</td>
  85. <td class="text-right">
  86. @if(Auth::user()->user_type == 'admin')
  87. <a href="#" class="btn btn-soft-success btn-icon btn-circle btn-sm" style="display: inline-flex;width: auto" onclick="show_make_wallet_recharge_modal('{{$user->id}}');" title="{{ translate('Recharge') }}">
  88. {{ translate('Recharge') }}
  89. </a>
  90. @endif
  91. <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') }}">
  92. <i class="las la-edit"></i> </a>
  93. @if(Auth::user()->user_type == 'salesman')
  94. <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') }}">
  95. <i class="las la-edit"></i>
  96. </a>
  97. @endif
  98. @if($user->banned != 1)
  99. <a href="#" class="btn btn-soft-danger btn-icon btn-circle btn-sm" onclick="confirm_ban('{{route('customers.ban', encrypt($user->id))}}');" title="{{ translate('Ban this Customer') }}">
  100. <i class="las la-user-slash"></i>
  101. </a>
  102. @else
  103. <a href="#" class="btn btn-soft-success btn-icon btn-circle btn-sm" onclick="confirm_unban('{{route('customers.ban', encrypt($user->id))}}');" title="{{ translate('Unban this Customer') }}">
  104. <i class="las la-user-check"></i>
  105. </a>
  106. @endif
  107. <a href="#" class="btn btn-soft-danger btn-icon btn-circle btn-sm confirm-delete" data-href="{{route('customers.destroy', $user->id)}}" title="{{ translate('Delete') }}">
  108. <i class="las la-trash"></i>
  109. </a>
  110. </td>
  111. </tr>
  112. @endif
  113. @endforeach
  114. </tbody>
  115. </table>
  116. <div class="aiz-pagination">
  117. {{ $users->appends(request()->input())->links() }}
  118. </div>
  119. </div>
  120. </form>
  121. </div>
  122. <div class="modal fade" id="confirm-ban">
  123. <div class="modal-dialog">
  124. <div class="modal-content">
  125. <div class="modal-header">
  126. <h5 class="modal-title h6">{{translate('Confirmation')}}</h5>
  127. <button type="button" class="close" data-dismiss="modal"></button>
  128. </div>
  129. <div class="modal-body">
  130. <p>{{translate('Do you really want to ban this Customer?')}}</p>
  131. </div>
  132. <div class="modal-footer">
  133. <button type="button" class="btn btn-light" data-dismiss="modal">{{translate('Cancel')}}</button>
  134. <a type="button" id="confirmation" class="btn btn-primary">{{translate('Proceed!')}}</a>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. <div class="modal fade" id="confirm-unban">
  140. <div class="modal-dialog">
  141. <div class="modal-content">
  142. <div class="modal-header">
  143. <h5 class="modal-title h6">{{translate('Confirmation')}}</h5>
  144. <button type="button" class="close" data-dismiss="modal"></button>
  145. </div>
  146. <div class="modal-body">
  147. <p>{{translate('Do you really want to unban this Customer?')}}</p>
  148. </div>
  149. <div class="modal-footer">
  150. <button type="button" class="btn btn-light" data-dismiss="modal">{{translate('Cancel')}}</button>
  151. <a type="button" id="confirmationunban" class="btn btn-primary">{{translate('Proceed!')}}</a>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. @endsection
  157. @section('modal')
  158. @include('modals.delete_modal')
  159. <div class="modal fade" id="virtual_user_form" data-backdrop="static">
  160. <div class="modal-dialog modal-lg">
  161. <div class="modal-content">
  162. <div class="modal-header">
  163. <h5 class="modal-title h6">{{translate('Create Virtual Customers')}}</h5>
  164. <button type="button" class="close" data-dismiss="modal"></button>
  165. </div>
  166. <div class="modal-body">
  167. <div style="margin-bottom: 16px; font-size: 14px; ">
  168. <i>{{translate('N:B: You can create virtual customers here, with a maximum of 100 people')}}</i>
  169. </div>
  170. <form class="form-horizontal" action="{{ route('customers.create_virtual_user') }}" method="POST">
  171. <!--<div class="form-group row">
  172. <div class="col-lg-2">{{translate('Name Prefix')}}</div>
  173. <div class="col-lg-6">
  174. <input type="text" class="form-control" name="name_prefix" value="" placeholder="Prefix of Name" required>
  175. </div>
  176. <div class="col-lg-4"><span>{{translate('Optional')}}</span></div>
  177. </div>-->
  178. <div class="form-group row" style="display:none;">
  179. <div class="col-lg-2">{{translate('Referrel User')}}</div>
  180. <div class="col-lg-6">
  181. <input type="number" class="form-control" name="referred_by" value="" placeholder="Referrel User" required>
  182. </div>
  183. </div>
  184. <div class="form-group row">
  185. <div class="col-lg-2">{{translate('Quantity')}}</div>
  186. <div class="col-lg-6">
  187. <input type="number" min="1" step="1" max="100" class="form-control" name="quantity" value="1" placeholder="Quantity of generate" required>
  188. </div>
  189. </div>
  190. <div class="form-group row">
  191. <div class="col-lg-2">{{translate('Initial Balance')}}</div>
  192. <div class="col-lg-6">
  193. <input type="number" min="0" class="form-control" name="balance" value="0.00" placeholder="Initial Balance of Accounts" required>
  194. </div>
  195. </div>
  196. <div class="form-group row">
  197. <div class="col-lg-2"></div>
  198. <div class="col-lg-6">
  199. <div style="display: flex; align-items: center;">
  200. <div class="aiz-checkbox-inline" style="display: inline-block;">
  201. <label class="aiz-checkbox">
  202. <input type="checkbox" class="check-one" name="disable_login" value="1">
  203. <span class="aiz-square-check"></span>
  204. </label>
  205. </div>
  206. <span style="margin-top: 14px;">{{translate('Disable Log in')}}</span>
  207. </div>
  208. </div>
  209. </div>
  210. </form>
  211. </div>
  212. <div class="modal-footer">
  213. <button type="button" class="btn btn-light" data-dismiss="modal">{{translate('Cancel')}}</button>
  214. <a type="button" id="submitVirtualCustomer" class="btn btn-primary">{{translate('Submit')}}</a>
  215. </div>
  216. </div>
  217. </div>
  218. </div>
  219. <!-- offline payment Modal -->
  220. <div class="modal fade" id="offline_wallet_recharge_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  221. <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
  222. <div class="modal-content">
  223. <div class="modal-header">
  224. <h5 class="modal-title" id="exampleModalLabel">{{ translate('Recharge') }}</h5>
  225. <button type="button" class="close" data-dismiss="modal" aria-label="Close"></button>
  226. </div>
  227. <div id="offline_wallet_recharge_modal_body"></div>
  228. </div>
  229. </div>
  230. </div>
  231. @endsection
  232. @section('script')
  233. <script type="text/javascript">
  234. function show_make_wallet_recharge_modal(user_id){
  235. $.post('{{ route('admin.admin_wallet_recharge_modal') }}', {_token:'{{ csrf_token() }}', user_id: user_id}, function(data){
  236. $('#offline_wallet_recharge_modal_body').html(data);
  237. $('#offline_wallet_recharge_modal').modal('show');
  238. });
  239. }
  240. $( function ()
  241. {
  242. $( '#create_virtual_user' ).bind( 'click', function ()
  243. {
  244. $( '#virtual_user_form' ).modal( 'show' )
  245. } )
  246. $( '#submitVirtualCustomer' ).bind( 'click', function ()
  247. {
  248. let target = $( this )
  249. if ( target.hasClass( 'disabled' ) ) return false
  250. target.addClass( 'disabled' );
  251. let max = $( 'input[name=quantity]' ).val()
  252. let balance = $( 'input[name=balance]' ).val()
  253. let referred_by = $( 'input[name=referred_by]' ).val()
  254. fetch( '{{route('customers.create_virtual_user')}}', {
  255. method: 'POST',
  256. headers: {
  257. 'Content-Type': 'application/json',
  258. 'X-Requested-With': 'fetch'
  259. },
  260. body: JSON.stringify( {
  261. _token: '{{csrf_token()}}',
  262. max,
  263. balance,
  264. referred_by
  265. } )
  266. } )
  267. .then( resp => resp.text() )
  268. .then( res =>
  269. {
  270. if ( res == 1 ) {
  271. AIZ.plugins.notify( 'success', '{{translate('Successfully created virtual customer')}}' )
  272. setTimeout( () =>
  273. {
  274. window.location.reload()
  275. }, 500 )
  276. }
  277. else {
  278. AIZ.plugins.notify( 'danger', '{{translate('Executed failure Try again')}}' )
  279. target.removeClass( 'disabled' )
  280. }
  281. } )
  282. .catch( err => null ).finally( () =>
  283. {
  284. //target.removeClass('disabled')
  285. } )
  286. } )
  287. } )
  288. $( document ).on( "change", ".check-all", function ()
  289. {
  290. if ( this.checked ) {
  291. // Iterate each checkbox
  292. $( '.check-one:checkbox' ).each( function ()
  293. {
  294. this.checked = true;
  295. } );
  296. }
  297. else {
  298. $( '.check-one:checkbox' ).each( function ()
  299. {
  300. this.checked = false;
  301. } );
  302. }
  303. } );
  304. function sort_customers(el) {
  305. $( '#sort_customers' ).submit();
  306. }
  307. function confirm_ban(url) {
  308. $( '#confirm-ban' ).modal( 'show', { backdrop: 'static' } );
  309. document.getElementById( 'confirmation' ).setAttribute( 'href', url );
  310. }
  311. function confirm_unban(url) {
  312. $( '#confirm-unban' ).modal( 'show', { backdrop: 'static' } );
  313. document.getElementById( 'confirmationunban' ).setAttribute( 'href', url );
  314. }
  315. function bulk_delete() {
  316. var data = new FormData( $( '#sort_customers' )[0] );
  317. $.ajax( {
  318. headers: {
  319. 'X-CSRF-TOKEN': $( 'meta[name="csrf-token"]' ).attr( 'content' )
  320. },
  321. url: "{{route('bulk-customer-delete')}}",
  322. type: 'POST',
  323. data: data,
  324. cache: false,
  325. contentType: false,
  326. processData: false,
  327. success: function (response)
  328. {
  329. if ( response == 1 ) {
  330. location.reload();
  331. }
  332. }
  333. } );
  334. }
  335. </script>
  336. @endsection