users.blade.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. @extends('layouts.app')
  2. @section('css')
  3. <link href="{!! env('APP_ASSETS') !!}css/outlets.css?v=1.3" rel="stylesheet" type="text/css">
  4. @endsection
  5. @php
  6. $resto = \App\Models\Restaurants::find(\App\Helpers\CommonMethods::getRestuarantID());
  7. $lang = $resto->default_lang;
  8. app()->setLocale($lang);
  9. if(session('app_lang') !==null){
  10. $lang = session('app_lang');
  11. app()->setLocale($lang);
  12. }
  13. @endphp
  14. @section('content')
  15. <style>
  16. @-webkit-keyframes special {
  17. from { background-color: rgba(255, 121, 77, 0.27); }
  18. to { background-color: inherit; }
  19. }
  20. @-moz-keyframes special {
  21. from { background-color: rgba(255, 121, 77, 0.27);; }
  22. to { background-color: inherit; }
  23. }
  24. @-o-keyframes special {
  25. from { background-color: rgba(255, 121, 77, 0.27);; }
  26. to { background-color: inherit; }
  27. }
  28. @keyframes special {
  29. from { background-color: rgba(255, 121, 77, 0.27);; }
  30. to { background-color: inherit; }
  31. }
  32. .special {
  33. -webkit-animation: special 1s infinite; /* Safari 4+ */
  34. -moz-animation: special 1s infinite; /* Fx 5+ */
  35. -o-animation: special 1s infinite; /* Opera 12+ */
  36. animation: special 1s infinite; /* IE 10+ */
  37. }
  38. .btn-toggle.btn-sm,.btn-toggle.btn-sm > .handle{
  39. border-radius: 16px;
  40. }
  41. table.dataTable {
  42. clear: both;
  43. margin-top: 6px !important;
  44. margin-bottom: 6px !important;
  45. max-width: none !important;
  46. border-collapse: collapse !important;
  47. font-family: 'Open Sans';
  48. }
  49. .theme-primary .paging_simple_numbers .pagination .paginate_button.active a,.theme-primary .pagination li a:hover,.theme-primary .paging_simple_numbers .pagination .paginate_button:hover a{
  50. color: white !important;
  51. background: #ffa505 !important;
  52. }
  53. .search-outlet{
  54. width: 400px;
  55. background-color: white;
  56. }
  57. .search-buttom{
  58. top: 8px;
  59. right: 15px;
  60. font-size: 20px;
  61. color: #e1e1e1;
  62. }
  63. .btn-toggle.btn-sm:focus, .btn-toggle.btn-sm.focus, .btn-toggle.btn-sm:focus.active, .btn-toggle.btn-sm.focus.active{
  64. box-shadow: none;
  65. }
  66. .btn-outlet{
  67. }
  68. .btn-toggle.active{
  69. color: white !important;
  70. background: #ffa505;
  71. }
  72. </style>
  73. <!-- Content Wrapper. Contains page content -->
  74. <div class="content-wrapper">
  75. <div class="container-full">
  76. <!-- Main content -->
  77. <section class="content">
  78. <div class="row ">
  79. <div class="col-md-6">
  80. <div class="m-15">
  81. <h3 class="title">{{__('label.users')}}</h3>
  82. <p>{{__('label.invite_users_and_managers_their_access_to_your_account')}}</p>
  83. </div>
  84. </div>
  85. <div class="col-md-6">
  86. <a href="{!! env('APP_URL') !!}invite" class="form-control btn btn-primary btn-md add-outlet text-center">
  87. <i class="fa fa-plus mr-2"></i>
  88. <!-- <i class="mdi mdi-plus-circle"></i> --> {{__('label.invite_user')}}
  89. </a>
  90. </div>
  91. </div>
  92. <div class="row mt-15">
  93. <div class="col-md-12 pt-5">
  94. <div class="d-flex justify-content-between align-items-center">
  95. <h4 class="orange_text p-5" style="margin-left: 10px">{!! $users->count() !!} Users</h4>
  96. <div class="form-group has-search position-relative">
  97. <input type="text" class="form-control search-outlet" name="search" placeholder="Search Outlet">
  98. <a href="#!" class="search-buttom position-absolute"><i class="fa fa-search"></i> </a>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. <div class="table-responsive">
  104. <table class="table table-striped">
  105. <thead>
  106. <tr>
  107. <th scope="col">{{__('label.user')}}</th>
  108. <th scope="col">{{__('label.role')}}</th>
  109. <th scope="col">{{__('label.access')}}</th>
  110. <th></th>
  111. </tr>
  112. </thead>
  113. <tbody>
  114. @php
  115. $level = "All";
  116. @endphp
  117. @if(isset($invited_users) && $invited_users->count() > 0)
  118. @foreach($invited_users as $user)
  119. <tr>
  120. <td>{!! $user->email !!}<span class="badge badge-warning" style="margin-left:10px">pending</span></td>
  121. <td><span class="badge badge-dark">{!! $user->role !!}</span></td>
  122. <td>
  123. @php
  124. $level = "All";
  125. if($user->access_level=="all")
  126. $level = "All";
  127. elseif($user->access_level=="selected-outlets"){
  128. $s = explode(',',$user->selected_outlets);
  129. if(count($s) > 1){
  130. $level = (count($s)). ' Outlet(s)';;
  131. }else{
  132. $level = (count($s)). ' Outlet';;
  133. }
  134. }
  135. @endphp
  136. {!! $level !!}
  137. </td>
  138. <td>
  139. <a href="javascript:;" data-id="{!! $user->unique_key !!}" class="btn btn-sm btn-danger delete-user" data-toggle="tooltip" data-placement="top" title="Delete"><i class="glyphicon glyphicon-trash"></i></a>
  140. <a href="javascript:;" data-id="{!! $user->unique_key !!}" class="btn btn-sm btn-danger resend-link" data-toggle="tooltip" data-placement="top" title="Resend Invite"><i class="glyphicon glyphicon-repeat"></i></a>
  141. </td>
  142. </tr>
  143. @endforeach
  144. @endif
  145. @if(isset($users) && $users->count() > 0)
  146. @foreach($users as $user)
  147. <tr data-id="{!! $user->unique_key !!}">
  148. <td><h5>{!! $user->first_name.' '.$user->last_name !!}</h5> <p>{!! $user->email !!}</p></td>
  149. <td><span class="badge badge-dark">{!! $user->role !!}</span></td>
  150. <td>
  151. @php
  152. if($user->access_level=="all")
  153. $level = "All";
  154. elseif($user->access_level=="selected-outlets"){
  155. $s = explode(',',$user->selected_outlets);
  156. if(count($s) > 1){
  157. $level = (count($s)). ' Outlet(s)';;
  158. }else{
  159. $level = (count($s)). ' Outlet';;
  160. }
  161. }
  162. @endphp
  163. {!! $level !!}
  164. </td>
  165. <td>
  166. <a href="javascript:;" data-id="{!! $user->id !!}" class="btn btn-sm btn-danger delete-saved-user" data-toggle="tooltip" data-placement="top" title="Delete"><i class="glyphicon glyphicon-trash"></i></a>
  167. <a href="javascript:;" data-id="{!! $user->id !!}" class="btn btn-sm btn-danger credentials" data-toggle="tooltip" data-placement="top" title="New Credentials"><i class="glyphicon glyphicon-lock"></i></a>
  168. </td>
  169. </tr>
  170. @endforeach
  171. @endif
  172. </tbody>
  173. </table>
  174. </div>
  175. </section>
  176. <!-- /.content -->
  177. </div>
  178. </div>
  179. <!-- /.content-wrapper -->
  180. <div class="modal" id="send-credentials" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  181. <div class="modal-dialog">
  182. <div class="modal-content">
  183. <div class="modal-header">
  184. <h5 class="modal-title" id="staticBackdropLabel">{{__('label.user_new_credentails')}}</h5>
  185. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  186. </div>
  187. <div class="modal-body">
  188. <p>{{__('label.you_credentails_submitting_by')}} <strong>{{__('label.save_credentails')}}</strong></p>
  189. <table border="0" style="width: 100%">
  190. <tr>
  191. <th width="30%"></th>
  192. <td id="username"></td>
  193. </tr>
  194. <tr>
  195. <th>{{__('label.password')}}</th>
  196. <td id="password"></td>
  197. </tr>
  198. </table>
  199. <div class="alert alert-success" style="display: none;">{{__('label.credentails_successful')}}</div>
  200. </div>
  201. <div class="modal-footer">
  202. <button type="button" class="btn btn-primary save-credentails">{{__('label.save_credentials')}}</button>
  203. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  204. </div>
  205. </div>
  206. </div>
  207. </div>
  208. <div class="modal" id="send-invitation-link" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  209. <div class="modal-dialog">
  210. <div class="modal-content">
  211. <div class="modal-header">
  212. <h5 class="modal-title" id="staticBackdropLabel">{{__('label.resend_invitation_link')}}</h5>
  213. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  214. </div>
  215. <div class="modal-body">
  216. <table border="0" style="width: 100%">
  217. <tr>
  218. <td id="link">
  219. <img src="{!! env('APP_ASSETS') !!}images/preloader-1.svg" style="height: 25px;">
  220. </td>
  221. </tr>
  222. </table>
  223. </div>
  224. </div>
  225. </div>
  226. </div>
  227. @endsection
  228. @section('js')
  229. <script>
  230. var user_id = 0;
  231. $(function () {
  232. $('.table').DataTable({
  233. paging: true,
  234. bLengthChange:false,
  235. searching: false,
  236. language: {
  237. @if($lang=='ar')
  238. url:`{{asset('public/assets/js/dataTablear.json')}}`,
  239. @endif
  240. },
  241. });
  242. $("body").on('click','.save-credentails',function () {
  243. var password = $("#password").html();
  244. $.ajax({
  245. url:"{!! env('APP_URL') !!}user/update/password",
  246. type:"POST",
  247. data:{
  248. user_id:user_id,
  249. password:password,
  250. '_token':"{!! csrf_token() !!}"
  251. },
  252. success:function (response) {
  253. $("#create-credentials .alert").show();
  254. setTimeout(function () {
  255. location.reload();
  256. },1500)
  257. }
  258. });
  259. });
  260. $("body").on("click",".credentials",function(e){
  261. var _id = $(this).data('id');
  262. user_id = _id;
  263. $("#username").html('<img src="{!! env('APP_ASSETS') !!}images/preloader-1.svg" style="height: 25px;">');
  264. $("#password").html('<img src="{!! env('APP_ASSETS') !!}images/preloader-1.svg" style="height: 25px;">');
  265. $.ajax({
  266. url:"{!! env('APP_URL') !!}user/get/credentials/"+_id,
  267. success:function (response) {
  268. $("#username").html(response.username);
  269. $("#password").html(response.password);
  270. }
  271. });
  272. $("#send-credentials").modal('show');
  273. e.preventDefault();
  274. e.stopPropagation();
  275. });
  276. $("body").on("click",".resend-link",function(e){
  277. var _id = $(this).data('id');
  278. $("#send-invitation-link").modal('show');
  279. $.ajax({
  280. url:"{!! env('APP_URL') !!}get/invitation/info/"+_id,
  281. success:function (response) {
  282. $("#link").html(response.message);
  283. setTimeout(function(){
  284. location.reload();
  285. },2500);
  286. }
  287. });
  288. e.preventDefault();
  289. e.stopPropagation();
  290. });
  291. $("body").on("click",".delete-user",function(e){
  292. var id = $(this).data('id');
  293. var _this = $(this);
  294. $.ajax({
  295. url:"{!! env('APP_URL') !!}delete/invitation/"+id,
  296. success:function(response){
  297. _this.parents('tr').remove();
  298. }
  299. });
  300. e.preventDefault();
  301. e.stopPropagation();
  302. });
  303. $("body").on("click","tr",function(){
  304. var id = $(this).data('id');
  305. // alert(id);
  306. if(id)
  307. window.location.href = "{!! env('APP_URL') !!}user/tanent/"+id;
  308. });
  309. $("body").on("click",".delete-saved-user",function(e){
  310. var id = $(this).data('id');
  311. var _this = $(this);
  312. $.ajax({
  313. url:"{!! env('APP_URL') !!}delete/saved/user/"+id,
  314. success:function(response){
  315. _this.parents('tr').remove();
  316. }
  317. });
  318. e.preventDefault();
  319. e.stopPropagation();
  320. });
  321. })
  322. </script>
  323. @endsection