@extends('publisher.layout.dashboard')
@section('content')
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.5.0/css/flag-icon.min.css">
<style type="text/css">
    h4 {
        font-size: 18px !important;
    }

    #offer_name {
        font-size: 20px;
    }

    #offer_name1 {
        font-size: 16px;
        color: #384A50;
    }

    span.flag-icon {
        transition: all .2s;
        padding: 10px 16px;
        margin: 2px;
        border-radius: 9px;
    }

    span.flag-icon:hover {
        transform: scale(1.3);
        border-radius: 9px;
    }

    .tracking {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .tracking #copie i {
        font-size: 20px;
    }

    .world-icon {
        width: 30px;
    }

    .more,
    .less {
        cursor: pointer;
    }
</style>


<!-- Start Content-->
<div class="container-fluid">

    <!-- start page title -->
    <div class="row">
        <div class="col-12">
            <div class="bg-flower">
                <img src="{{ config('app.url') }}/public/public/assets/assets/images/flowers/img-3.png">
            </div>

            <div class="bg-flower-2">
                <img src="{{ config('app.url') }}/public/public/assets/assets/images/flowers/img-1.png">
            </div>

            <div class="page-title-box">
                <div class="page-title-right">
                    <ol class="breadcrumb m-0">
                        <li class="breadcrumb-item"><a href="javascript: void(0);">Publisher</a></li>
                        <li class="breadcrumb-item active">Offer</li>
                    </ol>
                </div>
                <h4 class="page-title">Offer Details</h4>
            </div>
        </div>
    </div>
    <!-- end page title -->

    <div class="row">
        <div class="col-12">
            <h3>
                <span>#{{ $qry->id }}</span> {{ $qry->offer_name }}
            </h3>
        </div>
        @if ($qry->offer_type == 'public' || $qry->offer_type == 'special')
        @if ($qry->publishercount >= 0)
        <div class="col-lg-6 col-12">
            <div class="alert alert-primary bg-transparent">
                <div class="title">
                    <h4><i class="fa-solid fa-tags"></i> Details</h4>
                </div>
                <div class="content mt-4">
                    <div class="offer-details">
                        <div class="row">
                            <div class="col-md-6">
                                <h5>Description:</h5>
                            </div>
                            <div class="col-md-6">
                                <div class="contents">
                                    {!! $qry->description !!}
                                </div>
                            </div>
                            <hr>
                            <div class="col-md-6">
                                <h5>Restrictions:</h5>
                            </div>
                            <div class="col-md-6">
                                <div class="contents">
                                    {!! $qry->requirements !!}
                                </div>
                            </div>
                            <hr>
                            <div class="col-md-6">
                                <h5>Daily Caps: </h5>
                            </div>
                            <div class="col-md-6">
                                @if ($qry->lead_qty != null)
                                <span>{{ $qry->lead_qty }}</span>
                                @else
                                <span>Unlimited</span>
                                @endif
                            </div>
                            <hr>
                            <div class="col-md-6">
                                <h5>Category: </h5>
                            </div>
                            <div class="col-md-6">
                                <span>{{ $qry->category->category_name }}</span>
                            </div>
                            <hr>
                            <div class="col-md-6">
                                <h5>Preview Url:</h5>
                            </div>
                            <div class="col-md-6">
                                <a target="_blank" href="{{ $qry->preview_link }}"><i class="ri-eye-line"></i></a>
                                <a target="_blank" href="{{ $qry->preview_link }}">View</a>
                            </div>
                            <hr>
                            <div class="col-md-6">
                                <h5>Preview:</h5>
                            </div>
                            <div class="col-md-6">
                                @if ($qry->preview_url != null && $qry->preview_url != '')
                                <img src="{{ asset('uploads') }}/{{ $qry->preview_url }}" class="rounded" style="height:100%;width: 100%;object-fit: fill">
                                @else
                                <img src="/site_images/offer-logo.png" class="rounded" style="height:100%;width: 100%;object-fit: fill">
                                @endif
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-6 col-12">
            <div class="card p-2 bg-transparent text-danger">
                <div class="title">
                    <h4><i class="fa-solid fa-tags"></i> GEO & Payouts</h4>
                </div>
                <div class="card-body mt-4">
                    <div class="row">
                        <div class="col-6">
                            <h5>Payout:</h5>
                        </div>
                        <div class="col-6">
                            @if ($qry->payout_type == 'revshare')
                            <span id="offer_name">RevShare</span>
                            @else
                            <span id="offer_name">
                                ${{ round(($qry->payout * $qry->payout_percentage) / 100, 2) }}</span>
                            @endif
                        </div>
                        <hr>
                        <div class="col-6">
                            <h5>Device:</h5>
                        </div>
                        <div class="col-6">
                            <span id="offer_name1"> @php $device=explode('|',$qry->ua_target); @endphp
                                @foreach ($device as $d)
                                @if ($d == 'Windows')
                                <i class="fab fa-microsoft" title="Windows"></i>
                                @elseif($d == 'Mac')
                                <i class="fadeIn animated fas fa-laptop" title="Mac"></i>
                                @elseif($d == 'Iphone')
                                <i class="fadeIn animated fas fa-mobile-alt" title="Iphone"></i>
                                @elseif($d == 'Ipad')
                                <i class="fas fa-mobile" title="Ipad"></i>
                                @elseif($d == 'Android')
                                <i class="fadeIn animated fab fa-android" title="Android"></i>
                                @elseif($d == 'All')
                                <i class="fab fa-microsoft" title="Windows"></i>
                                <i class="fadeIn animated fas fa-mobile-alt" title="Iphone"></i>
                                <i class="fas fa-mobile" title="Ipad"></i>
                                <i class="fadeIn animated fab fa-android" title="Android"></i>
                                <i class="fadeIn animated fas fa-laptop" title="Mac"></i>
                                @endif
                                @endforeach
                            </span>
                        </div>
                        <hr>
                        <div class="col-6">
                            <h5>Browser:</h5>
                        </div>
                        <div class="col-6">
                            <span id="offer_name1"> @php $browsers=explode('|',$qry->browsers); @endphp
                                @foreach ($browsers as $d)
                                @if ($d == 'Firefox')
                                <i class="fab fa-firefox-browser" title="Windows"></i>
                                @elseif($d == 'Chrome')
                                <i class="fab fa-chrome" title="Mac"></i>
                                @elseif($d == 'Safari')
                                <i class="fab fa-safari" title="Iphone"></i>
                                @elseif($d == 'EDGE')
                                <i class="fab fa-edge" title="Ipad"></i>
                                @elseif($d == 'OPERA MINI')
                                <i class="fab fa-opera" title="Ipad"></i>
                                @elseif($d == 'Internet Explorer')
                                <i class="fab fa-internet-explorer" title="Android"></i>
                                @elseif($d == 'All')
                                <i class="fab fa-firefox-browser" title="Windows"></i>
                                <i class="fab fa-chrome" title="Mac"></i>
                                <i class="fab fa-safari" title="Iphone"></i>
                                <i class="fab fa-edge" title="Ipad"></i>
                                <i class="fab fa-opera" title="Ipad"></i>
                                <i class="fab fa-internet-explorer" title="Android"></i>
                                @endif
                                @endforeach
                            </span>
                        </div>
                        <hr>
                        <div class="col-6">
                            <h5>Country:</h5>
                        </div>
                        <div class="col-6">

                            @if ($qry->countries == 'ALL')
                            <img class="world-icon" src="{{ config('app.url ') }}/public/public/assets/assets/world.png">
                            @else
                            @foreach ($iso as $iso_code)
                            <span data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ $iso_code->country_name }}" class="flag-icon flag-icon-{{ strtolower($iso_code->iso) }}"></span>
                            @endforeach
                            @endif

                        </div>
                    </div>

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

    </div>
    <div class="col-12">
        <div class="card p-2 bg-transparent text-success" role="alert">
            <div class="title">
                <h4><i class="fa-solid fa-tags"></i> Tracking</h4>
            </div>
            <div class="col-12">
                <div class="card p-2 bg-transparent text-success" role="alert">
                    <div class="title">
                        <h5><i class="fa-solid fa-wand-magic-sparkles"></i> Pre-landings</h5 <div class="form-check form-switch">
                        <input class="form-check-input" type="checkbox" id="flexSwitchCheckDefault" checked>
                        <label class="form-check-label" for="flexSwitchCheckDefault">Default No Pre-landing</label>
                    </div>
                    @if(!empty($lander))
                        @foreach($lander as $land)
                            <div style="width: 50%">
                                <div class="row">
                                    <div class="col-lg-6">
                                        <div class="form-check form-switch">
                                            <input class="form-check-input" type="checkbox" name="prelandSelect" value="{{$land->id}}" id="prelandSelect{{$land->id}}">
                                            <label class="form-check-label" for="prelandSelect{{$land->id}}">{{$land->prelander_name}}</label>
                                        </div>
                                    </div>
                                    <div class="col-lg-6">
                                        <a href="{{$land->prelander_pvr_link}}"><i class="fas fa-eye"></i> Preview</a>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                    @endif

                </div>
                                    <div class="row g-4">
                                      <div class="col-lg-6">
                                        <p class="mb-1 fw-bold text-muted">Select Tracking Domain</p>
                                        <select class="form-control" id="domain" name="domain">
                                            
                                             @foreach ($domain as $q)
                                            <option value="{{ $q->url }}">{{ $q->url }}
                                          </option>
                                          @endforeach
                                        </select>
                                    </div> <!-- end col -->
                <div class="row mt-4">
                    <div class="col-md-8 col-12">
                        <h5>Tracking Url</h5>
                        <div class="form-control tracking" style="background: #eee" id="trackingUrlContainer">
                            @php
                                $camp = $cmp;
                                $pubid = $pubID;
                                $prelandshow = $qry->pre_land;
                            @endphp
                                @if ($prelandshow === 'yes')
                                    <span id="offer_names"><span id="url">{{ @$domain[0]->url }}</span>/pre-land/eyJpdiI6IitQMkR6cE8yeHZLM?plf={{ $camp }}&plp={{ $pubid }}<span id="sid"></span><span id="sid2"></span><span id="sid3"></span><span id="sid4"></span><span id="sid5"></span></span>
                                @else
                                    <span id="offer_names"><span id="url">{{ @$domain[0]->url }}</span>/click?camp={{ $qry->id }}&pubid={{ Auth::guard('publisher')->id() }}<span id="pridn"></span><span id="sid"></span><span id="sid2"></span><span id="sid3"></span><span id="sid4"></span><span id="sid5"></span></span>
                                @endif
                                <span id="copie">
                                    <i class="fa-regular fa-copy"></i>
                                </span>
                        </div>
                        <p class="mt-2">
                            You can append subIDs to this URL for tracking purposes, for example add &sid=1234
                            where
                            1234 is
                            your
                            unique tracking ID. If you have <a href="/publisher/postback" class="color5" target="_blank">Postback</a> set up, once a lead is generated, this information
                            will be
                            sent according to your postback setup.
                        </p>
                        <p>Supported subIDs: <code>&amp;sid=</code>, <code>&amp;sid2=</code>,
                            <code>&amp;sid3=</code>,
                            <code>&amp;sid4=</code>, <code>&amp;sid5=</code>
                        </p>
                    </div>
                    <div class="col-md-4 col-12">
                        <div class="subId-table">
                            <div class="row">

                                <div class="col-6">
                                    <h5>Enter SubID1:</h5>
                                </div>
                                <div class="col-6">
                                    <span>
                                        <input class="form-control" type="text" id="myInput" oninput="sid1()">
                                    </span>
                                </div>
                                <div class="col-6">
                                    <h5>Enter SubID2:</h5>
                                </div>
                                <div class="col-6">
                                    <span class="mt-1 mb-1">
                                        <input class="form-control" type="text" id="myInput2" oninput="sid2()">
                                    </span>
                                </div>
                                <div class="col-6">
                                    <h5>Enter SubID3:</h5>
                                </div>
                                <div class="col-6">
                                    <input class="form-control" type="text" id="myInput3" oninput="sid3()">
                                </div>
                                <div class="col-6">
                                    <h5>Enter SubID4:</h5>
                                </div>
                                <div class="col-6">
                                    <input class="form-control" type="text" id="myInput4" oninput="sid4()">
                                </div>
                                <div class="col-6">
                                    <h5>Enter SubID5:</h5>
                                </div>
                                <div class="col-6">
                                    <input class="form-control" type="text" id="myInput5" oninput="sid5()">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        @endif
        @else
        @if ($qry->offer_type == 'private')
        @if (@$approval_request->approval_status == 'Rejected')
        <div class="alert alert-danger">You are not allowed to see this offer</div>
        @else
        <div class="row my-3">
            <div class="col-4">
                @if (@$approval_request->approval_status == 'Requested')
                <h4 class="text-danger">Offer Requested</h4>
                @elseif(@$approval_request->approval_status == 'Rejected')
                @endif
                @if ($approval_request == '')
                <button class="btn btn-danger" itype="button" data-bs-toggle="modal" data-bs-target="#request">Request Approval</button>
                @endif
            </div>
        </div>
        <div class="col-lg-6 col-12">
            <div class="alert alert-primary bg-transparent">
                <div class="title">
                    <h4><i class="fa-solid fa-tags"></i> Details</h4>
                </div>
                <div class="content mt-4">
                    <div class="offer-details">
                        <div class="row">
                            <div class="col-md-6">
                                <h5>Description:</h5>
                            </div>
                            <div class="col-md-6">
                                <div class="contents">
                                    {!! $qry->description !!}
                                </div>
                            </div>
                            <hr>
                            <div class="col-md-6">
                                <h5>Restrictions:</h5>
                            </div>
                            <div class="col-md-6">
                                <div class="contents">
                                    {!! $qry->requirements !!}
                                </div>
                            </div>
                            <hr>
                            <div class="col-md-6">
                                <h5>Daily Caps: </h5>
                            </div>
                            <div class="col-md-6">
                                @if ($qry->lead_qty != null)
                                <span>{{ $qry->lead_qty }}</span>
                                @else
                                <span>Unlimited</span>
                                @endif
                            </div>
                            <hr>
                            <div class="col-md-6">
                                <h5>Category: </h5>
                            </div>
                            <div class="col-md-6">
                                <span>{{ $qry->category->category_name }}</span>
                            </div>
                            <hr>
                            <div class="col-md-6">
                                <h5>Preview Url:</h5>
                            </div>
                            <div class="col-md-6">
                                <a target="_blank" href="{{ $qry->preview_link }}"><i class="ri-eye-line"></i></a>
                                <a target="_blank" href="{{ $qry->preview_link }}">View</a>
                            </div>
                            <hr>
                            <div class="col-md-6">
                                <h5>Preview:</h5>
                            </div>
                            <div class="col-md-6">
                                <img src="{{ asset('uploads') }}/{{ $qry->preview_url }}" class="rounded" style="height:100%;width: 100%;object-fit: fill">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-6 col-12">
            <div class="card p-2 bg-transparent text-danger">
                <div class="title">
                    <h4><i class="fa-solid fa-tags"></i> GEO Payouts</h4>
                </div>
                <div class="card-body mt-4">
                    <div class="row">
                        <div class="col-6">
                            <h5>Payout:</h5>
                        </div>
                        <div class="col-6">
                            @if ($qry->payout_type == 'revshare')
                            <span id="offer_name">RevShare</span>
                            @else
                            <span id="offer_name">
                                ${{ round(($qry->payout * $qry->payout_percentage) / 100, 2) }}</span>
                            @endif
                        </div>
                        <hr>
                        <div class="col-6">
                            <h5>Device:</h5>
                        </div>
                        <div class="col-6">
                            <span id="offer_name1"> @php $device=explode('|',$qry->ua_target); @endphp
                                @foreach ($device as $d)
                                @if ($d == 'Windows')
                                <i class="fab fa-microsoft" title="Windows"></i>
                                @elseif($d == 'Mac')
                                <i class="fadeIn animated fas fa-laptop" title="Mac"></i>
                                @elseif($d == 'Iphone')
                                <i class="fadeIn animated fas fa-mobile-alt" title="Iphone"></i>
                                @elseif($d == 'Ipad')
                                <i class="fas fa-mobile" title="Ipad"></i>
                                @elseif($d == 'Android')
                                <i class="fadeIn animated fab fa-android" title="Android"></i>
                                @elseif($d == 'All')
                                <i class="fab fa-microsoft" title="Windows"></i>
                                <i class="fadeIn animated fas fa-mobile-alt" title="Iphone"></i>
                                <i class="fas fa-mobile" title="Ipad"></i>
                                <i class="fadeIn animated fab fa-android" title="Android"></i>
                                <i class="fadeIn animated fas fa-laptop" title="Mac"></i>
                                @endif
                                @endforeach
                            </span>
                        </div>
                        <hr>
                        <div class="col-6">
                            <h5>Browser:</h5>
                        </div>
                        <div class="col-6">
                            <span id="offer_name1"> @php $browsers=explode('|',$qry->browsers); @endphp
                                @foreach ($browsers as $d)
                                @if ($d == 'Firefox')
                                <i class="fab fa-firefox-browser" title="Windows"></i>
                                @elseif($d == 'Chrome')
                                <i class="fab fa-chrome" title="Mac"></i>
                                @elseif($d == 'Safari')
                                <i class="fab fa-safari" title="Iphone"></i>
                                @elseif($d == 'EDGE')
                                <i class="fab fa-edge" title="Ipad"></i>
                                @elseif($d == 'OPERA MINI')
                                <i class="fab fa-opera" title="Ipad"></i>
                                @elseif($d == 'Internet Explorer')
                                <i class="fab fa-internet-explorer" title="Android"></i>
                                @elseif($d == 'All')
                                <i class="fab fa-firefox-browser" title="Windows"></i>
                                <i class="fab fa-chrome" title="Mac"></i>
                                <i class="fab fa-safari" title="Iphone"></i>
                                <i class="fab fa-edge" title="Ipad"></i>
                                <i class="fab fa-opera" title="Ipad"></i>
                                <i class="fab fa-internet-explorer" title="Android"></i>
                                @endif
                                @endforeach
                            </span>
                        </div>
                        <hr>
                        <div class="col-6">
                            <h5>Country:</h5>
                        </div>
                        <div class="col-6">

                            @if ($qry->countries == 'ALL')
                            <img class="world-icon" src="{{ config('app.url ') }}/public/public/assets/assets/world.png">
                            @else
                            @foreach ($iso as $iso_code)
                            <span data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ $iso_code->country_name }}" class="flag-icon flag-icon-{{ strtolower($iso_code->iso) }}"></span>
                            @endforeach
                            @endif

                        </div>
                    </div>

                </div>
            </div>
        </div>
        @if (@$approval_request->approval_status == 'Approved')
       <div class="col-12">
        <div class="card p-2 bg-transparent text-success" role="alert">
            <div class="title">
                <h4><i class="fa-solid fa-tags"></i> Tracking</h4>
            </div>
            <div class="col-12">
                <div class="card p-2 bg-transparent text-success" role="alert">
                    <div class="title">
                        <h5><i class="fa-solid fa-wand-magic-sparkles"></i> Pre-landings</h5 <div class="form-check form-switch">
                        <input class="form-check-input" type="checkbox" id="flexSwitchCheckDefault" checked>
                        <label class="form-check-label" for="flexSwitchCheckDefault">Default No Pre-landing</label>
                    </div>
                    @if(!empty($lander))
                        @foreach($lander as $land)
                            <div style="width: 50%">
                                <div class="row">
                                    <div class="col-lg-6">
                                        <div class="form-check form-switch">
                                            <input class="form-check-input" type="checkbox" name="prelandSelect" value="{{$land->id}}" id="prelandSelect{{$land->id}}">
                                            <label class="form-check-label" for="prelandSelect{{$land->id}}">{{$land->prelander_name}}</label>
                                        </div>
                                    </div>
                                    <div class="col-lg-6">
                                        <a href="{{$land->prelander_pvr_link}}"><i class="fas fa-eye"></i> Preview</a>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                    @endif

                </div>
                                    <div class="row g-4">
                                      <div class="col-lg-6">
                                        <p class="mb-1 fw-bold text-muted">Select Tracking Domain</p>
                                        <select class="form-control" id="domain" name="domain">
                                            
                                             @foreach ($domain as $q)
                                            <option value="{{ $q->url }}">{{ $q->url }}
                                          </option>
                                          @endforeach
                                        </select>
                                    </div> <!-- end col -->
                        </div>
                    <div class="row mt-4">
                    <div class="col-md-8 col-12">
                        <h5>Tracking Url</h5>
                        <div class="form-control tracking" style="background: #eee" id="trackingUrlContainer">
                            @php
                                $camp = $cmp;
                                $pubid = $pubID;
                                $prelandshow = $qry->pre_land;
                            @endphp
                                @if ($prelandshow === 'yes')
                                    <span id="offer_names"><span id="url">{{ @$domain[0]->url }}</span>/pre-land/eyJpdiI6IitQMkR6cE8yeHZLM?plf={{ $camp }}&plp={{ $pubid }}<span id="sid"></span><span id="sid2"></span><span id="sid3"></span><span id="sid4"></span><span id="sid5"></span></span>
                                @else
                                    <span id="offer_names"><span id="url">{{ @$domain[0]->url }}</span>/click?camp={{ $qry->id }}&pubid={{ Auth::guard('publisher')->id() }}<span id="pridn"></span><span id="sid"></span><span id="sid2"></span><span id="sid3"></span><span id="sid4"></span><span id="sid5"></span></span>
                                @endif
                                <span id="copie">
                                    <i class="fa-regular fa-copy"></i>
                                </span>
                        </div>
                        <p class="mt-2">
                            You can append subIDs to this URL for tracking purposes, for example add &sid=1234
                            where
                            1234 is
                            your
                            unique tracking ID. If you have <a href="/publisher/postback" class="color5" target="_blank">Postback</a> set up, once a lead is generated, this information
                            will be
                            sent according to your postback setup.
                        </p>
                        <p>Supported subIDs: <code>&amp;sid=</code>, <code>&amp;sid2=</code>,
                            <code>&amp;sid3=</code>,
                            <code>&amp;sid4=</code>, <code>&amp;sid5=</code>
                            </p>
                        </div>
                        <div class="col-md-4 col-12">
                            <div class="subId-table">
                                <div class="row">

                                    <div class="col-6">
                                        <h5>Enter SubID1:</h5>
                                    </div>
                                    <div class="col-6">
                                        <span>
                                            <input class="form-control" type="text" id="myInput" oninput="sid1()">
                                        </span>
                                    </div>
                                    <div class="col-6">
                                        <h5>Enter SubID2:</h5>
                                    </div>
                                    <div class="col-6">
                                        <span class="mt-1 mb-1">
                                            <input class="form-control" type="text" id="myInput2" oninput="sid2()">
                                        </span>
                                    </div>
                                    <div class="col-6">
                                        <h5>Enter SubID3:</h5>
                                    </div>
                                    <div class="col-6">
                                        <input class="form-control" type="text" id="myInput3" oninput="sid3()">
                                    </div>
                                    <div class="col-6">
                                        <h5>Enter SubID4:</h5>
                                    </div>
                                    <div class="col-6">
                                        <input class="form-control" type="text" id="myInput4" oninput="sid4()">
                                    </div>
                                    <div class="col-6">
                                        <h5>Enter SubID5:</h5>
                                    </div>
                                    <div class="col-6">
                                        <input class="form-control" type="text" id="myInput5" oninput="sid5()">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            @endif
            @endif
            @endif
            @endif
        </div>


    </div> <!-- container -->


    <!-- Edit MODAL -->

    <div id="request" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content position-relativet">
                <div class="modal-header">
                    <h5 class="modal-title">Confirm Approval</h5>
                    <div class="position-absolute top-0 end-0 mt-2 me-2 z-index-1">
                        <button class="btn-close btn btn-sm btn-circle d-flex flex-center transition-base" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                </div>
                <div class="modal-body">
                    <form id="update_form">
                        @csrf

                        <div class="row">
                            <div class="col-lg-12 form-group">
                                <label>HOW ARE YOU PLANNING TO PROMOTE THIS OFFER</label>
                                <textarea type="text" name="description" class="form-control" rows=5></textarea>
                            </div>
                            <div class="col-lg-12 form-group mt-2">

                                <input type="hidden" name="id" value="{{ $qry->id }}" class="form-cotrol">
                                <input type="checkbox" name="terms" checked="true" class="form-cotrol">
                                <label>AGREE WITH TERMS AND CONDITIONS OF THIS OFFER</label>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="btnUpdate">Confirm</button>
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
    @endsection('content')
    @section('js')
    <script src="https://code.jquery.com/jquery-3.5.1.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" crossorigin="anonymous"></script>
    <script src="https://xbladecdn.b-cdn.net/cnew/site/js/bootstrap-slider.js"></script>


    <script type="text/javascript">
        function sid1() {
            var x = document.getElementById("myInput").value;
            document.getElementById("sid").innerHTML = "&sid=" + x;
        }

        function sid2() {
            var x2 = document.getElementById("myInput2").value;
            document.getElementById("sid2").innerHTML = "&sid2=" + x2;
        }

        function sid3() {
            var x3 = document.getElementById("myInput3").value;
            document.getElementById("sid3").innerHTML = "&sid3=" + x3;
        }

        function sid4() {
            var x4 = document.getElementById("myInput4").value;
            document.getElementById("sid4").innerHTML = "&sid4=" + x4;
        }

        function sid5() {
            var x5 = document.getElementById("myInput5").value;
            document.getElementById("sid5").innerHTML = "&sid5=" + x5;
        }

        $(function() {
            $('#domain').change(function() {
                var slet_value = $("#domain option:selected").text();
                document.getElementById("url").innerHTML = "" + slet_value.trim() + "";
            });

            $('#btnUpdate').unbind().click(function() {
                let data = $('#update_form').serialize();
                $.ajax({
                    url: "{{ route('publisher.requestApproval') }}",
                    type: 'POST',
                    dataType: 'JSON',
                    data: data,
                    success: function(result) {
                        $('.loader').fadeOut();
                        // console.log(result);
                        if (!result.status) {
                            Swal.fire('Failed', result.message, 'error');

                        } else {
                            Swal.fire('Success', result.message, 'success');


                            location.reload();
                        }
                    },
                    error: function(xhr) {
                        $('.loader').fadeOut();
                        if (xhr.status == 422) {
                            $.each(xhr.responseJSON.errors, function(k, v) {
                                form.find('[name="' + k + '"]').after(
                                    '<div class="text-danger">' + v[0] +
                                    '</div>');
                            });
                        } else if (xhr.status == 419) {
                            window.location.href = "";
                        }
                        // console.log(xhr);
                    }
                });
            });

            $('#copie').click(function() {
                var offerName = $('#offer_names').text(); // Get the text inside offer_name span
                copyToClipboard(offerName); // Call function to copy the text to clipboard
                $('#copie').html(
                    '<i class="fa-solid text-primary fa-check-double"></i>'
                ); // Change icon to indicate successful copy
            });

            // Function to copy text to clipboard
            function copyToClipboard(text) {
                var $temp = $("<input>");
                $("body").append($temp);
                $temp.val(text).select();
                document.execCommand("copy");
                $temp.remove();
            }

            var showChar = 250; // How many characters are shown initially
            var ellipsestext = "...";
            var moretext = "More";
            var lesstext = "Less";

            $('.contents').each(function() {
                var LiN = $(this).find('p').length;

                if (LiN > 3) {
                    $('p', this).eq(1).nextAll().hide().addClass('toggleable');
                    $(this).append('<p class="more">More</p>');
                }
            });

            $('.contents').on('click', '.more', function() {
                if ($(this).hasClass('less')) {
                    $(this).text('More').removeClass('less');
                } else {
                    $(this).text('Less').addClass('less');
                }
                $(this).siblings('p.toggleable').slideToggle();
            });

        });
    </script>

    <script>
        // Function to update tracking URL
        function updateTrackingUrl() {
            var selectedPreland = $('input[type=checkbox][name=prelandSelect]:checked').val();
            var trackingUrl = "{{ @$domain[0]->url }}/click?camp={{ $qry->id }}&pubid={{ Auth::guard('publisher')->id() }}";

            if (selectedPreland) {
                trackingUrl = "&preland=" + selectedPreland;
                $('#trackingUrlContainer #pridn').text(trackingUrl);
            }

        }

        // Add event listener to each checkbox
        $('input[type=checkbox][name=prelandSelect]').change(function() {
            // Uncheck all other checkboxes
            $('input[type=checkbox][name=prelandSelect]').not(this).prop('checked', false);
            // Update tracking URL
            updateTrackingUrl();
        });
    </script>



    @endsection