request.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <script>
  2. $('.buttonEdit').click(function(){
  3. var id = $(this).attr('data-id');
  4. $('.selectData').select2({ width: '100%', height: 'auto', theme: 'bootstrap4'});
  5. $.ajax
  6. ({
  7. url: '{{URL::current()}}/viewById/' + id,
  8. type: 'get',
  9. success: function(result){
  10. $.ajax
  11. ({
  12. url: '{{URL::current()}}/getRoleName/' + result.role_id,
  13. type: 'get',
  14. success: function(roleName){
  15. $('#editRoleId').append('<option value="'+ result.role_id +'" selected>'+ roleName +'</option>');
  16. },
  17. error: function () {
  18. $('#editClose').click();
  19. $.confirm({
  20. title: 'Something Wrong',
  21. content: 'Wait few Minutes',
  22. type: 'red',
  23. typeAnimated: true,
  24. icon: 'fas fa-exclamation-triangle',
  25. buttons: {
  26. close: function () {
  27. }
  28. }
  29. });
  30. }
  31. });
  32. if (result.user_type == 'user') {
  33. $('#editUserType').append('<option value="user" selected>User</option>');
  34. $('.selectData').val('');
  35. $('.div-type-code').css('visibility', 'hidden');
  36. }
  37. if (result.user_type == 'upt') {
  38. $.ajax
  39. ({
  40. url: '{{URL::current()}}/getTypeCodeUpt/' + result.type_code,
  41. type: 'get',
  42. success: function(typeCode){
  43. $('#editUserType').append('<option value="upt" selected>UPT</option>');
  44. $.ajax({
  45. url: "{{ route('getUpt') }}",
  46. method: 'GET',
  47. success: function(data) {
  48. $('.div-type-code').css('visibility', 'visible');
  49. jQuery("label[for='editTypeCode']").html("UPT Name");
  50. $('#editTypeCode').html('<option value="'+ result.type_code +'" selected>'+ typeCode +'</option>' + data.html);
  51. }
  52. });
  53. },
  54. error: function () {
  55. $('#editClose').click();
  56. $.confirm({
  57. title: 'Something Wrong',
  58. content: 'Wait few Minutes',
  59. type: 'red',
  60. typeAnimated: true,
  61. icon: 'fas fa-exclamation-triangle',
  62. buttons: {
  63. close: function () {
  64. }
  65. }
  66. });
  67. }
  68. });
  69. }
  70. if (result.user_type == 'waba') {
  71. $.ajax
  72. ({
  73. url: '{{URL::current()}}/getTypeCodeWaba/' + result.type_code,
  74. type: 'get',
  75. success: function(typeCode){
  76. $('#editUserType').append('<option value="waba" selected>Waba</option>');
  77. $.ajax({
  78. url: "{{ route('getWaba') }}",
  79. method: 'GET',
  80. success: function(data) {
  81. $('.div-type-code').css('visibility', 'visible');
  82. jQuery("label[for='editTypeCode']").html("Waba Name");
  83. $('#editTypeCode').html('<option value="'+ result.type_code +'" selected>'+ result.type_code +' - '+ typeCode +'</option>' + data.html);
  84. }
  85. });
  86. },
  87. error: function () {
  88. $('#editClose').click();
  89. $.confirm({
  90. title: 'Something Wrong',
  91. content: 'Wait few Minutes',
  92. type: 'red',
  93. typeAnimated: true,
  94. icon: 'fas fa-exclamation-triangle',
  95. buttons: {
  96. close: function () {
  97. }
  98. }
  99. });
  100. }
  101. });
  102. }
  103. $('#editId').val(result.id);
  104. $('#editName').val(result.name);
  105. $('#editEmail').val(result.email);
  106. $('#editOldPhotoProfile').html('<img width="150" style="border-radius: 50%;" id="editOldPhotoProfilePreview" height="150" src="'+ '../images/user/' + result.profile_photo +'">');
  107. },
  108. error: function () {
  109. $('#editClose').click();
  110. $.confirm({
  111. title: 'Something Wrong',
  112. content: 'Wait few Minutes',
  113. type: 'red',
  114. typeAnimated: true,
  115. icon: 'fas fa-exclamation-triangle',
  116. buttons: {
  117. close: function () {
  118. }
  119. }
  120. });
  121. }
  122. });
  123. });
  124. $('.buttonDetail').click(function(){
  125. var id = $(this).attr('data-id');
  126. $.ajax
  127. ({
  128. url: '{{URL::current()}}/viewById/' + id,
  129. type: 'get',
  130. success: function(result){
  131. $.ajax
  132. ({
  133. url: '{{URL::current()}}/getRoleName/' + result.role_id,
  134. type: 'get',
  135. success: function(roleName){
  136. $('#detailRoleId').val(roleName);
  137. },
  138. error: function () {
  139. $('#detailClose').click();
  140. $.confirm({
  141. title: 'Something Wrong',
  142. content: 'Wait few Minutes',
  143. type: 'red',
  144. typeAnimated: true,
  145. icon: 'fas fa-exclamation-triangle',
  146. buttons: {
  147. close: function () {
  148. }
  149. }
  150. });
  151. }
  152. });
  153. if (result.user_type == 'user') {
  154. $('#detailTypeCode').val('There is no type code');
  155. $('#detailUserType').val('User');
  156. }
  157. if (result.user_type == 'upt') {
  158. $.ajax
  159. ({
  160. url: '{{URL::current()}}/getTypeCodeUpt/' + result.type_code,
  161. type: 'get',
  162. success: function(typeCode){
  163. $('#detailUserType').val('UPT');
  164. $('#detailTypeCode').val(typeCode);
  165. },
  166. error: function () {
  167. $('#detailClose').click();
  168. $.confirm({
  169. title: 'Something Wrong',
  170. content: 'Wait few Minutes',
  171. type: 'red',
  172. typeAnimated: true,
  173. icon: 'fas fa-exclamation-triangle',
  174. buttons: {
  175. close: function () {
  176. }
  177. }
  178. });
  179. }
  180. });
  181. }
  182. if (result.user_type == 'waba') {
  183. $.ajax
  184. ({
  185. url: '{{URL::current()}}/getTypeCodeWaba/' + result.type_code,
  186. type: 'get',
  187. success: function(typeCode){
  188. $('#detailUserType').val('Waba');
  189. $('#detailTypeCode').val(typeCode);
  190. },
  191. error: function () {
  192. $('#detailClose').click();
  193. $.confirm({
  194. title: 'Something Wrong',
  195. content: 'Wait few Minutes',
  196. type: 'red',
  197. typeAnimated: true,
  198. icon: 'fas fa-exclamation-triangle',
  199. buttons: {
  200. close: function () {
  201. }
  202. }
  203. });
  204. }
  205. });
  206. }
  207. $('#detailName').val(result.name);
  208. $('#detailEmail').val(result.email);
  209. $('#detailPhotoProfile').html('<img width="150" height="150" style="border-radius: 50%;" src="'+ '../images/user/' + result.profile_photo +'">');
  210. },
  211. error: function () {
  212. $('#detailClose').click();
  213. $.confirm({
  214. title: 'Something Wrong',
  215. content: 'Wait few Minutes',
  216. type: 'red',
  217. typeAnimated: true,
  218. icon: 'fas fa-exclamation-triangle',
  219. buttons: {
  220. close: function () {
  221. }
  222. }
  223. });
  224. }
  225. });
  226. });
  227. $("#userType").change(function () {
  228. var selected_option = $('#userType').val();
  229. if (selected_option === 'user') {
  230. $('.selectData').val('');
  231. $('.div-type-code').css('visibility', 'hidden');
  232. }
  233. if (selected_option === 'upt') {
  234. $('.selectData').select2({ width: '100%', height: 'auto',theme: 'bootstrap4'});
  235. $.ajax({
  236. url: "{{ route('getUpt') }}",
  237. method: 'GET',
  238. success: function(data) {
  239. $('.div-type-code').css('visibility', 'visible');
  240. jQuery("label[for='typeCode']").html("Select UPT");
  241. $('#typeCode').html(data.html);
  242. }
  243. });
  244. }
  245. if (selected_option === 'waba') {
  246. $('.selectData').select2({ width: '100%', height: 'auto',theme: 'bootstrap4'});
  247. $.ajax({
  248. url: "{{ route('getWaba') }}",
  249. method: 'GET',
  250. success: function(data) {
  251. $('.div-type-code').css('visibility', 'visible');
  252. jQuery("label[for='typeCode']").html("Select Waba");
  253. $('#typeCode').html(data.html);
  254. }
  255. });
  256. }
  257. });
  258. $("#editUserType").change(function () {
  259. var selected_option = $('#editUserType').val();
  260. if (selected_option === 'user') {
  261. $('.selectData').val('');
  262. $('.div-type-code').css('visibility', 'hidden');
  263. }
  264. if (selected_option === 'upt') {
  265. $('.selectData').select2({ width: '100%', height: 'auto', theme: 'bootstrap4' });
  266. $.ajax({
  267. url: "{{ route('getUpt') }}",
  268. method: 'GET',
  269. success: function(data) {
  270. $('.div-type-code').css('visibility', 'visible');
  271. jQuery("label[for='editTypeCode']").html("Select UPT");
  272. $('#editTypeCode').html(data.html);
  273. }
  274. });
  275. }
  276. if (selected_option === 'waba') {
  277. $('.selectData').select2({ width: '100%', height: 'auto', theme: 'bootstrap4' });
  278. $.ajax({
  279. url: "{{ route('getWaba') }}",
  280. method: 'GET',
  281. success: function(data) {
  282. $('.div-type-code').css('visibility', 'visible');
  283. jQuery("label[for='editTypeCode']").html("Select Waba");
  284. $('#editTypeCode').html(data.html);
  285. }
  286. });
  287. }
  288. });
  289. </script>