configs.blade.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. @extends('backend.layouts.app')
  2. @section('content')
  3. <div class="col-sm-12">
  4. <div class="card">
  5. <div class="card-header">
  6. <h5 class="mb-0 h6">{{ translate('Affiliate Registration Form')}}</h5>
  7. </div>
  8. <div class="card-body">
  9. <form action="{{ route('affiliate.configs.store') }}" method="post" enctype="multipart/form-data">
  10. @csrf
  11. <div class="row">
  12. <div class="col-lg-8 form-horizontal" id="form">
  13. @foreach (json_decode(\App\Models\AffiliateConfig::where('type', 'verification_form')->first()->value) as $key => $element)
  14. @if ($element->type == 'text' || $element->type == 'file')
  15. <div class="form-group row" style="background:rgba(0,0,0,0.1);padding:10px 0;">
  16. <input type="hidden" name="type[]" value="{{ $element->type }}">
  17. <div class="col-lg-3">
  18. <label class="control-label">{{ ucfirst($element->type) }}</label>
  19. </div>
  20. <div class="col-lg-7">
  21. <input class="form-control" type="text" name="label[]" value="{{ $element->label }}" placeholder="Label">
  22. </div>
  23. <div class="col-lg-2"><span class="btn btn-icon btn-circle" onclick="delete_choice_clearfix(this)"><i class="las la-times"></i></span></div>
  24. </div>
  25. @elseif ($element->type == 'select' || $element->type == 'multi_select' || $element->type == 'radio')
  26. <div class="form-group row" style="background:rgba(0,0,0,0.1);padding:10px 0;">
  27. <input type="hidden" name="type[]" value="{{ $element->type }}">
  28. <input type="hidden" name="option[]" class="option" value="{{ $key }}">
  29. <div class="col-lg-3">
  30. <label class="control-label">{{ ucfirst(str_replace('_', ' ', $element->type)) }}</label>
  31. </div>
  32. <div class="col-lg-7">
  33. <input class="form-control" type="text" name="label[]" value="{{ $element->label }}" placeholder="Select Label" style="margin-bottom:10px">
  34. <div class="customer_choice_options_types_wrap_child">
  35. @if (is_array(json_decode($element->options)))
  36. @foreach (json_decode($element->options) as $value)
  37. <div class="form-group row">
  38. <div class="col-sm-6 col-sm-offset-4">
  39. <input class="form-control" type="text" name="options_{{ $key }}[]" value="{{ $value }}" required="">
  40. </div>
  41. <div class="col-sm-2"> <span class="btn btn-icon btn-circle" onclick="delete_choice_clearfix(this)"><i class="las la-times"></i></span></div>
  42. </div>
  43. @endforeach
  44. @endif
  45. </div>
  46. <button class="btn btn-success pull-right" type="button" onclick="add_customer_choice_options(this)"><i class="glyphicon glyphicon-plus"></i> Add option</button>
  47. </div>
  48. <div class="col-lg-2"><span class="btn btn-icon btn-circle" onclick="delete_choice_clearfix(this)"><i class="las la-times"></i></span></div>
  49. </div>
  50. @endif
  51. @endforeach
  52. </div>
  53. <div class="col-lg-4">
  54. <ul class="list-group">
  55. <li class="list-group-item btn" style="text-align: left;" onclick="appenddToForm('text')">{{translate('Text Input')}}</li>
  56. <li class="list-group-item btn" style="text-align: left;" onclick="appenddToForm('select')">{{translate('Select')}}</li>
  57. <li class="list-group-item btn" style="text-align: left;" onclick="appenddToForm('multi-select')">{{translate('Multiple Select')}}</li>
  58. <li class="list-group-item btn" style="text-align: left;" onclick="appenddToForm('radio')">{{translate('Radio')}}</li>
  59. <li class="list-group-item btn" style="text-align: left;" onclick="appenddToForm('file')">{{translate('File')}}</li>
  60. </ul>
  61. </div>
  62. </div>
  63. <div class="form-group mb-0 text-right">
  64. <button type="submit" class="btn btn-primary">{{translate('Save')}}</button>
  65. </div>
  66. </form>
  67. </div>
  68. </div>
  69. </div>
  70. @endsection
  71. @section('script')
  72. <script type="text/javascript">
  73. var i = 0;
  74. function add_customer_choice_options(em){
  75. var j = $(em).closest('.form-group.row').find('.option').val();
  76. var str = '<div class="form-group row">'
  77. +'<div class="col-sm-6 col-sm-offset-4">'
  78. +'<input class="form-control" type="text" name="options_'+j+'[]" value="" required>'
  79. +'</div>'
  80. +'<div class="col-sm-2"> <span class="btn btn-icon btn-circle" onclick="delete_choice_clearfix(this)"><i class="las la-times"></i></span>'
  81. +'</div>'
  82. +'</div>'
  83. $(em).parent().find('.customer_choice_options_types_wrap_child').append(str);
  84. }
  85. function delete_choice_clearfix(em){
  86. $(em).parent().parent().remove();
  87. }
  88. function appenddToForm(type){
  89. //$('#form').removeClass('seller_form_border');
  90. if(type == 'text'){
  91. var str = '<div class="form-group row" style="background:rgba(0,0,0,0.1);padding:10px 0;">'
  92. +'<input type="hidden" name="type[]" value="text">'
  93. +'<div class="col-lg-3">'
  94. +'<label class="control-label">Text</label>'
  95. +'</div>'
  96. +'<div class="col-lg-7">'
  97. +'<input class="form-control" type="text" name="label[]" placeholder="Label">'
  98. +'</div>'
  99. +'<div class="col-lg-2">'
  100. +'<span class="btn btn-icon btn-circle" onclick="delete_choice_clearfix(this)"><i class="las la-times"></i></span>'
  101. +'</div>'
  102. +'</div>';
  103. $('#form').append(str);
  104. }
  105. else if (type == 'select') {
  106. i++;
  107. var str = '<div class="form-group row" style="background:rgba(0,0,0,0.1);padding:10px 0;">'
  108. +'<input type="hidden" name="type[]" value="select"><input type="hidden" name="option[]" class="option" value="'+i+'">'
  109. +'<div class="col-lg-3">'
  110. +'<label class="control-label">Select</label>'
  111. +'</div>'
  112. +'<div class="col-lg-7">'
  113. +'<input class="form-control" type="text" name="label[]" placeholder="Select Label" style="margin-bottom:10px">'
  114. +'<div class="customer_choice_options_types_wrap_child">'
  115. +'</div>'
  116. +'<button class="btn btn-success pull-right" type="button" onclick="add_customer_choice_options(this)"><i class="glyphicon glyphicon-plus"></i> Add option</button>'
  117. +'</div>'
  118. +'<div class="col-lg-2">'
  119. +'<span class="btn btn-icon btn-circle icon-lg fa fa-times" onclick="delete_choice_clearfix(this)"><i class="las la-times"></i></span>'
  120. +'</div>'
  121. +'</div>';
  122. $('#form').append(str);
  123. }
  124. else if (type == 'multi-select') {
  125. i++;
  126. var str = '<div class="form-group row" style="background:rgba(0,0,0,0.1);padding:10px 0;">'
  127. +'<input type="hidden" name="type[]" value="multi_select"><input type="hidden" name="option[]" class="option" value="'+i+'">'
  128. +'<div class="col-lg-3">'
  129. +'<label class="control-label">Multiple select</label>'
  130. +'</div>'
  131. +'<div class="col-lg-7">'
  132. +'<input class="form-control" type="text" name="label[]" placeholder="Multiple Select Label" style="margin-bottom:10px">'
  133. +'<div class="customer_choice_options_types_wrap_child">'
  134. +'</div>'
  135. +'<button class="btn btn-success pull-right" type="button" onclick="add_customer_choice_options(this)"><i class="glyphicon glyphicon-plus"></i> Add option</button>'
  136. +'</div>'
  137. +'<div class="col-lg-2">'
  138. +'<span class="btn btn-icon btn-circle" onclick="delete_choice_clearfix(this)"><i class="las la-times"></i></span>'
  139. +'</div>'
  140. +'</div>';
  141. $('#form').append(str);
  142. }
  143. else if (type == 'radio') {
  144. i++;
  145. var str = '<div class="form-group row" style="background:rgba(0,0,0,0.1);padding:10px 0;">'
  146. +'<input type="hidden" name="type[]" value="radio"><input type="hidden" name="option[]" class="option" value="'+i+'">'
  147. +'<div class="col-lg-3">'
  148. +'<label class="control-label">Radio</label>'
  149. +'</div>'
  150. +'<div class="col-lg-7">'
  151. +'<input class="form-control" type="text" name="label[]" placeholder="Radio Label" style="margin-bottom:10px">'
  152. +'<div class="customer_choice_options_types_wrap_child">'
  153. +'</div>'
  154. +'<button class="btn btn-success pull-right" type="button" onclick="add_customer_choice_options(this)"><i class="glyphicon glyphicon-plus"></i> Add option</button>'
  155. +'</div>'
  156. +'<div class="col-lg-2">'
  157. +'<span class="btn btn-icon btn-circle" onclick="delete_choice_clearfix(this)"><i class="las la-times"></i></span>'
  158. +'</div>'
  159. +'</div>';
  160. $('#form').append(str);
  161. }
  162. else if (type == 'file') {
  163. var str = '<div class="form-group row" style="background:rgba(0,0,0,0.1);padding:10px 0;">'
  164. +'<input type="hidden" name="type[]" value="file">'
  165. +'<div class="col-lg-3">'
  166. +'<label class="control-label">File</label>'
  167. +'</div>'
  168. +'<div class="col-lg-7">'
  169. +'<input class="form-control" type="text" name="label[]" placeholder="Label">'
  170. +'</div>'
  171. +'<div class="col-lg-2">'
  172. +'<span class="btn btn-icon btn-circle" onclick="delete_choice_clearfix(this)"><i class="las la-times"></i></span>'
  173. +'</div>'
  174. +'</div>';
  175. $('#form').append(str);
  176. }
  177. }
  178. </script>
  179. @endsection