@extends('layouts.app')
@section('title', $page_title)

@push('scripts')
<script src="{{asset('assets/js/split_test.js')}}"></script>
@endpush

@section('content')
<div class="card custom-card">
   <div class="card-body">
      <form method="POST" action="{{ route('split_tests.store') }}" class="row g-3 mt-0 needs-validation" novalidate>
         @csrf       
         <div class="col-md-6">
            <label class="form-label">{{__('app.active')}}</label>
            <select name="is_active" class="form-select form-select-lg">
               <option value="1">{{ __('app.yes') }}</option>
               <option value="0">{{ __('app.no')}}</option>
            </select>
         </div>
         <div class="col-md-6 mt-3">
            <label class="form-label">{{__('app.name')}}</label>
            <input type="name" class="form-control" placeholder="{{__('app.name')}}" value="{{ old('name') }}" name="name" required>
         </div>
         <div class="col-md-12 mt-3">
           <label class="form-label">{{ __('app.send') }} 
           <a tabindex="-1" role="button"
            data-bs-toggle="popover" data-bs-trigger="focus" data-bs-placement="right" title="{{__('app.send')}}"
            data-bs-content="{{__('app.split_test_speed_help')}}" data-bs-custom-class="header-primary">   <i class="bi bi-question-square text-primary"></i>
            </a></label>
           <select name="send" id="send" class="form-select form-select-lg">
             <option value="now">{{ __('app.now') }}</option>
             <option value="later">{{ __('app.later') }}</option>
           </select>
         </div>
         <div class="col-md-12 mt-3" id="send_datetime_div" style="display: none;">
           <label class="form-label">{{ __('app.sending_datetime') }}</label>
           <div class="form-group">
             <div class="input-group">
               <div class="input-group-text"> <i class="ri-calendar-line"></i> </div>
               <input type="text" name="send_datetime" class="form-control" id="send_datetime" placeholder="{{ __('app.choose_date_time') }}" value="{{ !empty($attributes->send_datetime) ? \App\Http\Helper\Helper::datetimeDisplay($attributes->send_datetime) : ''}}">
               <input type="hidden" name="db_send_datetime" id="db_send_datetime" value="">
               <input type="hidden" name="timezone" id="timezone" value="{{ \Auth::user()->timezone }}" >
             </div>
           </div>
         </div>
         <div class="col-md-12 mt-3">
           <label class="form-label">{{__('app.lists')}}
             <a href="{{route('lists.create')}}" tabindex="-1">
               <i class="bi bi-plus-circle text-primary"></i>
             </a>
             <a tabindex="-1" role="button"
             data-bs-toggle="popover" data-bs-trigger="focus" data-bs-placement="right" title="{{__('app.lists')}}"
             data-bs-content="{{__('app.split_test_lists')}}" data-bs-custom-class="header-primary"><i class="bi bi-question-square text-primary"></i>
             </a>
           </label>
           @include('includes.dropdown_lists', ['popup' => 0, 'multiple' => 1, 'required' => 1, 'client_package_lists' => 1])
         </div>
         <div class="col-md-12 mt-3">
           <label class="form-label">{{__('app.campaigns')}}
             <a href="{{route('broadcasts.create')}}" tabindex="-1">
               <i class="bi bi-plus-circle text-primary"></i>
             </a>
             <a tabindex="-1" role="button"
             data-bs-toggle="popover" data-bs-trigger="focus" data-bs-placement="right" title="{{__('app.campaigns')}}"
             data-bs-content="{{__('app.split_test_campaigns')}}" data-bs-custom-class="header-primary"><i class="bi bi-question-square text-primary"></i>
             </a>
           </label>
           @include('includes.dropdown_broadcasts', ['popup' => 0, 'multiple' => 1, 'required' => 1])
         </div> 
         <div class="col-md-6 mt-3">
           <label class="form-label">{{ __('app.winning_criteria') }} 
           <a tabindex="-1" role="button"
            data-bs-toggle="popover" data-bs-trigger="focus" data-bs-placement="right" title="{{__('app.winning_criteria')}}"
            data-bs-content="{{__('app.split_test_winning_criteria_help')}}" data-bs-custom-class="header-primary">   <i class="bi bi-question-square text-primary"></i>
            </a></label>
           <select name="winning_criteria" class="form-select form-select-lg">
             <option value="open">{{ __('app.split_test_winning_criteria_open') }}</option>
             <option value="click">{{ __('app.split_test_winning_criteria_click') }}</option>
           </select>
         </div>
         <div class="col-md-6 mt-3">
           <label class="form-label">{{ __('app.decision_percentage') }} 
           <a tabindex="-1" role="button"
            data-bs-toggle="popover" data-bs-trigger="focus" data-bs-placement="right" title="{{__('app.decision_percentage')}}"
            data-bs-content="{{__('app.split_test_decision_percentage_help')}}" data-bs-custom-class="header-primary">   <i class="bi bi-question-square text-primary"></i>
            </a></label>
           <select name="decision_percentage" class="form-select form-select-lg">
             @for($i=5; $i<=100; $i+=5)
                <option value="{{$i}}">{{$i}} %</option>
              @endfor
           </select>
         </div>
         <div class="col-md-4 mt-3">
           <label class="form-label">{{ __('app.action') }} 
           <a tabindex="-1" role="button"
            data-bs-toggle="popover" data-bs-trigger="focus" data-bs-placement="right" title="{{__('app.action')}}"
            data-bs-content="{{__('app.split_test_action_help')}}" data-bs-custom-class="header-primary">   <i class="bi bi-question-square text-primary"></i>
            </a></label>
           <select name="action" class="form-select form-select-lg">
             <option value="send_remaining">{{ __('app.send_remaining') }}</option>
             <option value="show_results">{{ __('app.show_results') }}</option>
           </select>
         </div>
         <div class="col-md-4 mt-3">
           <label class="form-label">{{ __('app.split_test_after') }}
           <a tabindex="-1" role="button"
             data-bs-toggle="popover" data-bs-trigger="focus" data-bs-placement="right" title="{{__('app.split_test_after')}}"
             data-bs-content="{{__('app.split_test_after_help')}}" data-bs-custom-class="header-primary"><i class="bi bi-question-square text-primary"></i>
             </a>
           </label>
           <input type="number" class="form-control" name="send_remaining_after" value="30" min="1" placeholder="30">
         </div>
         <div class="col-md-4 mt-3">
           <label class="form-label">&nbsp;</label>
           <select name="send_remaining_after_duration" class="form-select form-select-lg">
                <option value="minutes">{{ __('app.minutes') }}</option>
                <option value="hours">{{ __('app.hours') }}</option>
                <option value="days">{{ __('app.days') }}</option>
           </select>
         </div>
         <div class="col-md-12 mt-3">
           <label class="form-label">{{__('app.sending_server')}}
             <a href="{{route('sending_servers.create')}}" tabindex="-1">
               <i class="bi bi-plus-circle text-primary"></i>
             </a>
             <a tabindex="-1" role="button"
             data-bs-toggle="popover" data-bs-trigger="focus" data-bs-placement="right" title="{{__('app.delivery_servers')}}"
             data-bs-content="{{__('app.split_test_sending_servers')}}" data-bs-custom-class="header-primary"><i class="bi bi-question-square text-primary"></i>
             </a>
           </label>
           @include('includes.dropdown_sending_server', ['popup' => 0, 'multiple' => 1, 'required' => 1, 'client_package_lists' => 1])
         </div>
         <div class="col-md-12 mt-3">
              <label class="form-label">{{__('app.from_detail')}}
                <a tabindex="-1" role="button"
                data-bs-toggle="popover" data-bs-trigger="focus" data-bs-placement="right" title="{{__('app.from_detail')}}"
                data-bs-content="{{__('app.from_detail_help')}}" data-bs-custom-class="header-primary"><i class="bi bi-question-square text-primary"></i>
                </a>
              </label><br>
              <input name="from_detail" class="form-check-input ms-2" type="radio" checked="checked" value="sending_server"> {{__('app.as_defined_for_sending_server')}} &nbsp;
              <input name="from_detail" class="form-check-input ms-2" type="radio" value="list"> {{__('app.as_defined_for_list')}} &nbsp;
              <input name="from_detail" class="form-check-input ms-2" type="radio" value="custom"> {{__('app.custom')}}
          </div>
          <div class="row mt-3" id="custom_email_data" style="display: none;">
              <div class="col-md-3">
                 <input type="text" class="form-control" placeholder="{{__('app.from_name')}}" value="" name="from_name">
              </div>
              <div class="col-md-5">
                 <div class="input-group">
                    <div style="width: 35%;">
                      <input type="text" name="from_email_part1" value="" class="form-control" placeholder="{{__('app.from_email_example')}}">
                    </div>
                    <span class="input-group-text">@</span>
                    <select name="from_email_part2" class="form-select">
                      @include('includes.dropdown_sending_domains')
                    </select>
                  </div>
              </div>
              <div class="col-md-4">
                 <input type="email" class="form-control" placeholder="{{__('app.reply_email')}}" value="" name="reply_email">
              </div>
          </div>
         <div class="col-md-12">
            <label class="form-label">{{ __('app.sending_speed') }}
              <a tabindex="-1" role="button"
            data-bs-toggle="popover" data-bs-trigger="focus" data-bs-placement="right" title="{{__('app.sending_speed')}}"
            data-bs-content="{{__('app.sending_speed_help')}}" data-bs-custom-class="header-primary"><i class="bi bi-question-square text-primary"></i>
              </a>
            </label>
            <select class="form-select form-select-lg" name="sending_speed" id="speed">
               <option value="unlimited">{{ __('app.unlimited') }}</option>
               <option value="limited">{{ __('app.limited') }}</option>
            </select>
         </div>
         <div class="col-md-12" id="speed-attributes" style="display: none;">
         <div class="row">
            <div class="col-md-6 mt-3" >
                <input type="number" class="form-control" name="limit" id="limit" value="1000" min="1" placeholder="1000">
            </div>
            <div class="col-md-6 mt-3" >
                <select name="duration" id="duration" class="form-select form-select-lg" >
                  <option value="hour">{{ __('app.hourly') }}</option>
                </select>
            </div>
          </div>

          <div class="row">
            <div class="col-md-6 mt-3" >
                <label class="form-label">{{ __('app.pause_after_send') }} 
                <a tabindex="-1" role="button"
            data-bs-toggle="popover" data-bs-trigger="focus" data-bs-placement="right" title="{{__('app.pause_after_send')}}"
            data-bs-content="{{__('app.pause_after_send_help')}}" data-bs-custom-class="header-primary"><i class="bi bi-question-square text-primary"></i>
            </a>
                </label>
                <input type="number" class="form-control" name="pause_limit" value="0" min="0" placeholder="0">
            </div>
            <div class="col-md-6 mt-3" >
              <label class="form-label">&nbsp;</label>
                <select name="pause_duration" class="form-control" >
                  <option value="minutes">{{ __('app.minutes') }}</option>
                </select>
            </div>
          </div>
         </div>

         <div class="col-12">
            <button type="submit" name="submit" value="save" class="btn btn-primary btn-loading"><i class=""></i> {{__('app.save')}}</button>
             <button type="button" class="btn btn-danger btn-loading"><i class=""></i> {{__('app.exit')}}</button>
           </a>
         </div>
      </form>
   </div>
</div>
@endsection