user_group.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. @extends('layouts.master')
  2. @section('content')
  3. <!-- Main content -->
  4. <section class="content">
  5. <!-- Main row -->
  6. <div class="row">
  7. <div class="col-md-12">
  8. <section class="panel tasks-widget">
  9. <header class="panel-heading" style="height:40px;">
  10. <div class="pull-left">
  11. {{$title}}
  12. </div>
  13. <div>
  14. <button class="btn btn-success btn-xs pull-right" data-toggle="modal" data-target=".modal">Add user group</button>
  15. </div>
  16. </header>
  17. <div class="table-responsive project-list">
  18. @if(Session::has('msg'))
  19. {{Session::get('msg')}}
  20. @endif
  21. <table class="table table-striped">
  22. <thead>
  23. <tr>
  24. <th colspan="2">
  25. Group Name
  26. </th>
  27. <th>
  28. User
  29. </th>
  30. <th>
  31. Designation
  32. </th>
  33. <th>
  34. Action
  35. </th>
  36. </tr>
  37. </thead>
  38. <tbody>
  39. @if (session('data'))
  40. <div class="alert alert-success">
  41. {{ session('data') }}
  42. </div>
  43. @endif
  44. @if(!empty($all))
  45. <?php $count=1; $count_color=1; ?>
  46. @foreach($all as $info)
  47. <?php
  48. $chk = App\Models\Group::with('one_rlation')->where('depend_on',$info->id)->get();
  49. $count_color++;
  50. if($count_color%2==0){
  51. $sty = "#118314";
  52. }
  53. else{
  54. $sty = "#0861BE";
  55. }
  56. ?>
  57. @if($chk->count() > 0)
  58. @foreach($chk as $val)
  59. <tr>
  60. <td>
  61. {{$count++}}
  62. </td>
  63. <td style="color:<?php echo $sty; ?>">
  64. {{$info->group_name}}
  65. </td>
  66. <td>
  67. {{$val->one_rlation->name}}
  68. </td>
  69. <td>
  70. {{$val->designation}}
  71. </td>
  72. <td>
  73. <a href="" style="color: #7dcc93;">
  74. <i class="fa fa-pencil-square-o" aria-hidden="true"></i>
  75. </a>
  76. &nbsp; &nbsp;
  77. <a onclick="return confirm ('want to delete?')" href="{{url("admin/remove_group_user/$val->id")}}" style="color:#FD4B39;">
  78. <i class="fa fa-times" aria-hidden="true"></i>
  79. </a>
  80. </td>
  81. </tr>
  82. @endforeach
  83. @else
  84. <tr>
  85. <td>
  86. {{$count++}}
  87. </td>
  88. <td style="color:<?php echo $sty;?>">
  89. {{$info->group_name}}
  90. </td>
  91. <td>
  92. </td>
  93. <td>
  94. </td>
  95. <td>
  96. <a href="" style="color: #7dcc93;">
  97. <i class="fa fa-pencil-square-o" aria-hidden="true"></i>
  98. </a>
  99. &nbsp; &nbsp;
  100. <a onclick="return confirm ('want to delete?')" href="{{url("admin/remove_group_user/$info->id")}}" style="color:#FD4B39;">
  101. <i class="fa fa-times" aria-hidden="true"></i>
  102. </a>
  103. </td>
  104. </tr>
  105. @endif
  106. @endforeach
  107. @endif
  108. </tbody>
  109. </table>
  110. <hr>
  111. </hr>
  112. </div>
  113. <div class="panel-body">
  114. <div class=" add-task-row">
  115. </div>
  116. <div class="table-foot">
  117. <ul class="pagination pagination-sm no-margin ">
  118. <li>
  119. <a href="#">
  120. «
  121. </a>
  122. </li>
  123. <li>
  124. <a href="#">
  125. 1
  126. </a>
  127. </li>
  128. <li>
  129. <a href="#">
  130. 2
  131. </a>
  132. </li>
  133. <li>
  134. <a href="#">
  135. 3
  136. </a>
  137. </li>
  138. <li>
  139. <a href="#">
  140. »
  141. </a>
  142. </li>
  143. </ul>
  144. </div>
  145. </div>
  146. </section>
  147. </div>
  148. </div>
  149. </section>
  150. <!-- row end -->
  151. <!-- /.content -->
  152. <!-- Modal Add User -->
  153. <div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
  154. <div class="modal-dialog" role="document">
  155. <div class="modal-content">
  156. <div class="modal-header">
  157. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  158. <h4 class="modal-title" id="gridSystemModalLabel">Add Group/User Under Group</h4>
  159. </div>
  160. <div class="modal-body">
  161. <form action="{{url('admin/add_group_user')}}" method="POST">
  162. {{ csrf_field() }}
  163. <div class="form-group">
  164. <label for="exampleInputEmail1">What you want to insert</label>
  165. <select name="type" class="form-control s-type" name="">
  166. <option value="0">Select type</option>
  167. <option value="1">Group</option>
  168. <option value="2">User Under Group</option>
  169. </select>
  170. </div>
  171. <div class="form-group in-group">
  172. <label for="exampleInputEmail1">Group name</label>
  173. <input type="text" name="group_name" class="form-control" id="" placeholder="Group name" >
  174. </div>
  175. <div class="form-group in-g-user">
  176. <label for="exampleInputEmail1">Select Group</label>
  177. <select class="form-control" name="group_id">
  178. <option value="0">Select Group</option>
  179. @foreach($all_group as $ag)
  180. <option value="{{$ag->id}}">{{$ag->group_name}}</option>
  181. @endforeach
  182. </select>
  183. </div>
  184. <div class="form-group in-g-user">
  185. <label for="exampleInputEmail1">Select User</label>
  186. <select class="form-control" name="user_id">
  187. <option value="0">Select User</option>
  188. @foreach($all_user as $au)
  189. <option value="{{$au->id}}">{{$au->name}}</option>
  190. @endforeach
  191. </select>
  192. </div>
  193. <div class="form-group in-group in-g-user">
  194. <label for="exampleInputEmail1">Designation</label>
  195. <input type="text" name="designation" class="form-control" id="" placeholder="Designation" >
  196. </div>
  197. </div>
  198. <div class="modal-footer">
  199. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  200. <button type="submit" class="btn btn-primary">Submit</button>
  201. </div>
  202. </form>
  203. </div><!-- /.modal-content -->
  204. </div><!-- /.modal-dialog -->
  205. </div><!-- /.modal -->
  206. @endsection
  207. @section('script')
  208. <script type="text/javascript">
  209. jQuery(document).ready(function($)
  210. {
  211. $('.in-group').hide();
  212. $('.in-g-user').hide();
  213. $('.chk-active').click(function(event)
  214. {
  215. var id = $(this).val();
  216. var stat;
  217. if($(this).is(':checked'))
  218. {
  219. stat = 1;
  220. }
  221. else
  222. {
  223. stat = 0;
  224. }
  225. $.ajax({
  226. url: '{{url('admin/user_active')}}',
  227. type: 'POST',
  228. data: {id: id,stat: stat},
  229. })
  230. .done(function(data){
  231. alert(data);
  232. });
  233. });
  234. $('.s-type').change(function(event){
  235. var val = $(this).val();
  236. if(val == 1){
  237. $('.in-group').show();
  238. $('.in-g-user').hide();
  239. }
  240. else if(val == 2){
  241. $('.in-group').hide();
  242. $('.in-g-user').show();
  243. }
  244. else{
  245. $('.in-group').hide();
  246. $('.in-g-user').hide();
  247. }
  248. });
  249. });
  250. </script>
  251. @endsection