@extends('user_type.auth', ['parentFolder' => 'offerwall', 'childFolder' => 'none'])

@section('content')
<main class="main-content mt-1 border-radius-lg">
    <div class="container my-3 py-3 d-flex flex-column">
        
        @if($errors->get('msgError'))
          <div class="m-3  alert alert-warning alert-dismissible fade show" role="alert">
            <span class="alert-text text-white">
              {{$errors->first()}}</span>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
              <i class="fa fa-close" aria-hidden="true"></i>
            </button>
          </div>
          @endif
          @if(session('success'))
          <div class="m-3  alert alert-success alert-dismissible fade show" id="alert-success" role="alert">
            <span class="alert-text text-white">
              {{ session('success') }}</span>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
              <i class="fa fa-close" aria-hidden="true"></i>
            </button>
          </div>
          @endif
        <div class="row mb-5 justify-content-center align-items-center">
            <div class="col-lg-9 col-12 mx-auto">
                
                <!-- Card Basic Info -->
                <div class="card mt-4" id="basic-info">
                    <div class="card-header">
                        <h5> Offerwall Configuration</h5>
                    </div>
                    <div class="card-body pt-0">
                        <form action="/offerwall/web/create" method="POST" enctype="multipart/form-data">
                            @csrf
                            <div class="row">
                                
                                
                                <div class="col-sm-12">
                                    <label class="form-label mt-4">Offerwall Category</label>
                                    <div class="input-group">
                                        <select name="offer_type" class="form-control">
                                            <option value="offers">Offers</option>
                                            <option value="survey">Survey</option>
                                        </select>
                                    </div>
                                </div>
                                
                                <div class="col-sm-12">
                                    <label class="form-label mt-4">Offerwall Name</label>
                                    <div class="input-group">
                                        <input class="form-control" name="title" type="text"  placeholder="Cpalead" required>
                                    </div>
                                </div>

                                <div class="col-sm-12">
                                    <label class="form-label mt-4">Offerwall Slug ( Fill Offerwall Original Name like tapjoy,cpalead)</label>
                                    <div class="input-group">
                                        <input class="form-control"  name="offerwall_slug" type="text" placeholder="Cpalead,Offerwall" required>
                                    </div>
                                </div>



                                <div class="col-sm-12">
                                    <label class="form-label mt-4">Offerwall Description</label>
                                    <div class="input-group">
                                        <input class="form-control"  name="description"  type="text" placeholder="Best Offers etc" required>
                                    </div>
                                </div>
                                
                                <div class="col-sm-12">
                                    <label class="form-label mt-4">Offerwall Icon</label>
                                    <div class="input-group">
                                        <input class="form-control" id="icon" name="icon" type="file" required>
                                    </div>
                                </div>
                                
                                
                                <div class="form-group row" >
                                    <label for="exampleInputConfirmPassword2" class="col-sm-3 col-form-label"></label>
                                    <div id="imgdiv"></div>
                                </div>
                                
                                
                                <div class="col-sm-12">
                                    <div class="row">
                                        <div class="col-sm-3"></div>
                                            <div class="col-sm-3">
                                               <label for="exampleInputPassword2" class="col-sm-12 col-form-label">Offerwall <b>Layout Color</b></label>
                                                <div class="col-sm-12">
                                                    <input  type="color" class="form-control" style="height:50px;" name="card_color" value="#ffffff"   required>
                                                    @error('card_color')
                                                    <span class="invalid-feedback" role="alert">
                                                        <strong>{{ $message }}</strong>
                                                    </span>
                                                    @enderror
                                                </div> 
                                            </div>
                                
                                        <div class="col-sm-3">
                                           <label for="exampleInputPassword2" class="col-sm-12 col-form-label">Offerwall<b>Text Color</b></label>
                                            <div class="col-sm-12">
                                                  <input   type="color" class="form-control" style="height:50px;" value="{{ old('text_color') }}"  name="text_color" required>
                                                  @error('text_color')
                                                <span class="invalid-feedback" role="alert">
                                                    <strong>{{ $message }}</strong>
                                                </span>
                                                @enderror
                                            </div> 
                                        </div>  
                                    </div>     
                                </div>
                                

                                
                                <div class="col-sm-12">
                                    <label class="form-label mt-4">Offerwall Complete Message </label>
                                    <div class="input-group">
                                        <input class="form-control"  name="offer_complete_title" type="text"  placeholder="Cpalead offer completed" required>
                                    </div>
                                </div>
                               
                                <div class="col-sm-12">
                                    <label class="form-label mt-4">Offerwall URL </label>
                                    <div class="input-group">
                                        <input class="form-control"  name="offerwall_url" type="text"  placeholder="https://fastrsrvr.com/list/452511" required>
                                    </div>
                                </div>
                                
                                

                                <div class="row">
                                    <div class="col-sm-6 col-lg-6">
                                        <label class="form-label mt-4">User ID Micro</label>
                                        <div class="input-group">
                                            <input class="form-control" type="text" name="u_tag" placeholder="subid={subid}" required>
                                        </div>
                                    </div>
        
                                    <div class="col-sm-6">
                                        <label class="form-label mt-4">User ID Tag Type</label>
                                        <div class="input-group">
                                            <select name="uid_type" class="form-control">
                                                 <option value="full">sub={subid}</option>
                                                <option value="short">/{subid}</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                             
                               <div class="col-sm-12">
                                    <label class="form-label mt-4">Advertising ID TAG {Optional}</label>
                                    <div class="input-group">
                                        <input class="form-control"  name="advid_tag" type="text"  placeholder="advert={advert}" value="blank">
                                    </div>
                                </div>   
                                
                                <div class="col-sm-12">
                                    <label class="form-label mt-4">Offerwall Order By</label>
                                    <div class="input-group">
                                        <input class="form-control"  name="item_order" type="number"  placeholder="1" required>
                                    </div>
                                </div>
                                
                                <div class="col-sm-12">
                                    <label class="form-label mt-4">Show on Home Screen?</label>
                                    <div class="input-group">
                                        <select name="home" class="form-control" required>
                                            <option value="0">Yes </option>
                                            <option value="1">No</option>
                                        </select>
                                    </div>
                                </div>
                                
                                <div class="col-sm-12">
                                    <label class="form-label mt-4">Open Offerwall In</label>
                                    <div class="input-group">
                                        <select name="browser_type" class="form-control" required>
                                             <option value="0" >In App Browser</option>
                                            <option value="1" >Chrome Custom Tab</option>
                                            <option value="2" >External Browser</option>
                                        </select>
                                    </div>
                                </div>

                    </div>
                    </div>
                </div>

                <div class="card mt-4" id="basic-info">
                    <div class="card-header">
                        <h5>Postback Configuration</h5>
                    </div>
                    <div class="card-body pt-0">
                        <div class="row">
                            <div class="col-sm-4 col-lg-4">
                                <label class="form-label mt-4">Paramater for <label class="text-info text-sm">USER ID</label></label>
                                <div class="input-group">
                                    <input class="form-control" type="text" name="p_userid" placeholder="{user_id}"  required>
                                </div>
                            </div>

                            <div class="col-sm-4 col-lg-4">
                                <label class="form-label mt-4">Paramater for <label class="text-info text-sm">OFFER ID</label></label>
                                <div class="input-group">
                                    <input class="form-control" type="text"  name="p_campaing_id" placeholder="{campaing_id}"  required>
                                </div>
                            </div>
                            
                            <div class="col-sm-4 col-lg-4">
                                <label class="form-label mt-4">Paramater for <label class="text-info text-sm">OFFER NAME</label></label>
                                <div class="input-group">
                                    <input class="form-control" type="text"  name="p_offername" placeholder="{offername}" value="blank"  required>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                             <div class="col-sm-4 col-lg-4">
                                <label class="form-label mt-4">Paramater for <label class="text-info text-sm">Reward Amount</label></label>
                                <div class="input-group">
                                    <input class="form-control"  type="text" name="p_payout" placeholder="{payout}" required>
                                </div>
                            </div>
                            
                           
                            
                            <div class="col-sm-4 col-lg-4">
                                <label class="form-label mt-4">Paramater for <label class="text-info text-sm">IP ADDRESS</label></label>
                                <div class="input-group">
                                    <input class="form-control" type="text"  name="p_ip" placeholder="{ip}" value="blank" >
                                </div>
                            </div>
                            
                            <div class="col-sm-4 col-lg-4">
                                <label class="form-label mt-4">PostBack Return <label class="text-info text-sm">RESPONSE CODE</label></label>
                                <div class="input-group">
                                    <input class="form-control" type="text"  name="response_code" value="201">
                                </div>
                            </div>
                            
                          
                        </div>
                        
                        <div class="row">
                          
                            <div class="col-sm-12 col-lg-12">
                                <label class="form-label mt-4">Paramater for <label class="text-info text-sm">Admin Payout ( For Calculate Admin Earning )</label></label>
                                <div class="input-group">
                                    <input class="form-control" type="text" name="p_admin_payout" value="blank" placeholder="{admin_payout}" required>
                                </div>
                            </div> 
                             

                        </div>

                        <div class="">
                            <button type="submit" class="btn bg-gradient-dark btn-sm float-end mt-6 mb-0">ADD</button>
                        </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
@endsection
@push('js')
<script src="{{ URL::asset('assets/js/plugins/choices.min.js') }}"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>

    $(document).ready(function() {
        $("#alert-success").delay(3000).slideUp(300);
        $("#conv").hide();

    });

    if (document.getElementById('choices-tag')) {
        var tag = document.getElementById('choices-tag');
        const example = new Choices(tag);
    }

    $('#choices-tag').change(function() {
        var optVal = $("#choices-tag option:selected").val();
        if (optVal == 1) {
            $('#conv').show();
        } else {
            $('#conv').hide();
        }
    });
    
    $("#icon").change(function(e) {

            for (var i = 0; i < e.originalEvent.srcElement.files.length; i++) {
                
                var file = e.originalEvent.srcElement.files[i];
                
                var img = document.createElement("img");
                var reader = new FileReader();
                reader.onloadend = function() {
                     img.src = reader.result;
                     img.height = 100;
                }
                
                reader.readAsDataURL(file);
                 $('#imgdiv').html(img);
                           
                // $("input").after(img);
            }
        });
</script>
@endpush