MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 8.0.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/liftcincy.imenso.co/resources/views/admin/opportunities/edit.blade.php_old
@extends('layouts.admin')
@section("style")
    <link href="{{ asset('assets/plugins/select2/css/select2.min.css')}}" rel="stylesheet" />
    <link href="{{ asset('assets/plugins/select2/css/select2-bootstrap4.css')}}" rel="stylesheet" />
    <link rel="stylesheet" href="{{URL::asset('assets/plugins/bootstrap-material-datetimepicker/css/bootstrap-material-datetimepicker.min.css')}}">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
@endsection
@section('pageTitle')
<title>{{ trans('panel.site_title') }} {{ trans('global.opportunities') }}</title>
@endsection

@section('content')

    <!--start page wrapper -->
    <div class="page-wrapper">
        <div class="page-content">
            <!--breadcrumb-->
            <div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
                <div class="breadcrumb-title pe-3">{{ trans('global.opportunities') }}</div>
                <div class="ps-3">
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb mb-0 p-0">
                            <li class="breadcrumb-item"><a href="javascript:;"><i class="bx bx-home-alt"></i></a>
                            </li>
                            <li class="breadcrumb-item active" aria-current="page">{{ trans('global.edit') }} {{ trans('global.opportunity') }} </li>
                        </ol>
                    </nav>
                </div>
                
                <div class="ms-auto">
                    <div class="btn-group">
                        <a href="{{ route("admin.opportunities.index") }}" class="btn btn-primary"> {{ trans('global.opportunity') }} {{ trans('global.list') }}</a>
                        
                    </div>
                </div>
                <hr/>
            </div>
            <!--end breadcrumb-->
            
                    @include('layouts/notification')
                    <form id="update_opportunity_form" action='{{ route("admin.opportunities.update", [$opportunity->id]) }}' method="POST" enctype="multipart/form-data">
                        @csrf
                        @method('PUT')
                        <div class="card">
                            <div class="card-body">

                                <h3>{{trans('opportunity.opportunity_detail')}}</h3>
                                <hr/>
                                <div class="col-12 mb-2 mt-2">
                                    
                                    <label class="inline">{{trans('opportunity.ongoing_opportunity')}}<small class="text-danger">*</small></label>
                                    
                                    <div class="form-check  {{ $errors->has('slug') ? 'has-error' : '' }} form-check-inline inline">
                                        <label class="form-check-label" for="on_going1">Yes </label>
                                        <input class="form-check-input on_going" type="radio" name="on_going" id="on_going1" value="1" @if($opportunity->on_going == 1) checked @endif >
                                    </div>
                                    <div class="form-check  {{ $errors->has('slug') ? 'has-error' : '' }} form-check-inline inline">
                                        <label class="form-check-label" for="on_going0">No </label>
                                        <input class="form-check-input on_going" type="radio" name="on_going" id="on_going0" value="0" @if($opportunity->on_going == 0) checked @endif >
                                    </div>
                                    @if($opportunity->on_going == 1 && !empty($opportunity->end_date))
                                        <div class="form-group form-inline inline">
                                            <p>Opportunity ended on {{date('M d Y', strtotime($opportunity->end_date))}}</p>
                                        </div>
                                    @endif

                                    @if($opportunity->on_going == 1 && empty($opportunity->end_date))
                                        <div class="form-group form-inline inline">
                                            <a href="{{route('admin.opportunities.end_ongoing_opportunity',$opportunity->id)}}" class="btn btn-sm btn-danger">End This Opportunity</a>
                                        </div>
                                    @endif
                                </div>
                                <div class="row">
                                    @if($user_type == 'Admin')
                                        <div class="col-12">
                                            <div class="form-group {{ $errors->has('partner_id') ? 'has-error' : '' }}">
                                                <label for="partner_id">Organization<small class="text-danger">*</small></label>
                                                <select class="select2 single-select form-control" id="partner_id" name="partner_id">
                                                    <option value="">Select Organization</option>
                                                    @if($partners->count())
                                                        @foreach($partners as $key=>$partner)
                                                            <option value="{{$partner->id}}" @if(old('partner_id', isset($opportunity) ? $opportunity->partner_id : '') == $partner->id) selected @endif>{{$partner->org_name}}</option>
                                                        @endforeach
                                                    @endif
                                                </select>
                                                @if($errors->has('partner_id'))
                                                    <p class="text-danger small">
                                                        {{ $errors->first('partner_id') }}
                                                    </p>
                                                @endif
                                            </div>
                                        </div>
                                    @elseif($user_type == 'Partner')
                                        <input type="hidden" name="partner_id" value="{{Auth::user()->id}}" />
                                    @endif

                                    
                                    <div class="col-12">
                                        <div class="form-group {{ $errors->has('opportunity_title') ? 'has-error' : '' }}">
                                            <label for="opportunity_title">Title<small class="text-danger">*</small></label>
                                            <input type="text" id="opportunity_title" name="opportunity_title" class="form-control" value="{{ old('opportunity_title', isset($opportunity) ? $opportunity->opportunity_title : '') }}" >
                                            @if($errors->has('opportunity_title'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('opportunity_title') }}
                                                </p>
                                            @endif
                                        </div>
                                    </div>
                                    <div class="col-12">
                                        <div class="form-group {{ $errors->has('slug') ? 'has-error' : '' }}">
                                            <label for="slug">Slug<small class="text-danger">*</small></label>
                                            <input type="text" id="slug" name="slug" class="form-control" value="{{ old('slug', isset($opportunity) ? $opportunity->slug : '') }}" >
                                            @if($errors->has('slug'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('slug') }}
                                                </p>
                                            @endif
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-sm-4 col-4 start_date_div" @if($opportunity->on_going == 1) style="display:none;" @endif >
                                        <div class="form-group {{ $errors->has('start_date') ? 'has-error' : '' }}">
                                            <label for="start_date">Start Date<small class="text-danger">*</small></label>
                                            <input type="text" id="start_date" name="start_date" class="form-control " value="{{ old('start_date', isset($opportunity) ? $opportunity->start_date : '') }}" >
                                            @if($errors->has('start_date'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('start_date') }}
                                                </p>
                                            @endif
                                        </div>
                                    </div>
                                    <div class="col-sm-4 col-4">
                                        <div class="form-group {{ $errors->has('start_time') ? 'has-error' : '' }}">
                                            <label for="start_time">Start Time<small class="text-danger">*</small></label>
                                            <input type="text" id="start_time" name="start_time" class="form-control " value="{{ old('start_time', isset($opportunity) ? $opportunity->start_time : '') }}" >
                                            @if($errors->has('start_time'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('start_time') }}
                                                </p>
                                            @endif
                                        </div>
                                    </div>
                                    <div class="col-sm-4 col-4">
                                        <div class="form-group {{ $errors->has('end_time') ? 'has-error' : '' }}">
                                            <label for="end_time">End Time<small class="text-danger">*</small></label>
                                            <input type="text" id="end_time" name="end_time" class="form-control " value="{{ old('end_time', isset($opportunity) ? $opportunity->end_time : '') }}" >
                                            @if($errors->has('end_time'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('end_time') }}
                                                </p>
                                            @endif
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-sm-4 col-3">
                                        <div class="form-group {{ $errors->has('opportunity_hours') ? 'has-error' : '' }}">
                                            <label for="opportunity_hours">No. of Hours<small class="text-danger">*</small></label>
                                            <input type="number" min="" id="opportunity_hours" name="opportunity_hours" class="form-control " value="{{ old('opportunity_hours', isset($opportunity) ? $opportunity->opportunity_hours : '') }}" >
                                            @if($errors->has('opportunity_hours'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('opportunity_hours') }}
                                                </p>
                                            @endif
                                        </div>
                                    </div>
                                    <div class="col-sm-4 col-3">
                                        <div class="form-group {{ $errors->has('no_of_volunteers') ? 'has-error' : '' }}">
                                            <label for="no_of_volunteers">No. of Volunteers<small class="text-danger">*</small></label>
                                            <input type="number" min="" id="no_of_volunteers" name="no_of_volunteers" class="form-control " value="{{ old('no_of_volunteers', isset($opportunity) ? $opportunity->no_of_volunteers : '') }}" >
                                            @if($errors->has('no_of_volunteers'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('no_of_volunteers') }}
                                                </p>
                                            @endif
                                        </div>
                                    </div>  
                                    <div class="col-sm-4 col-6">
                                        <div class="form-group {{ $errors->has('opportunity_type') ? 'has-error' : '' }}">
                                            <label for="opportunity_type">{{trans('opportunity.opportunity_type')}}<small class="text-danger">*</small></label>
                                            <select name="opportunity_type" class="form-control select2 single-select opportunity_type" id="opportunity_type">
                                                <option value="">{{trans('opportunity.opportunity_type')}}</option>
                                            
                                                <option value="1" @if(old('opportunity_type', isset($opportunity) ? $opportunity->opportunity_type : '') == 1) selected @endif >{{trans('opportunity.public')}}</option>
                                                <option value="2" @if(old('opportunity_type', isset($opportunity) ? $opportunity->opportunity_type : '') == 2) selected @endif >{{trans('opportunity.private')}}</option>

                                                
                                            </select>
                                            
                                            @if($errors->has('opportunity_type'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('opportunity_type') }}
                                                </p>
                                            @endif
                                        </div>
                                    </div>                                  
                                </div>
                            </div>
                        </div>
                        <div class="card">
                            <div class="card-body">
                                <h3>Opportunity Image & Description</h3>
                                <div class="row">
                                    <div class="col-12 mb-2">
                                        <div class="form-group {{ $errors->has('feature_image') ? 'has-error' : '' }}">
                                            <label for="feature_image">Feature Image<small class="text-danger">*</small></label>
                                            
                                            <input class="form-control upload_feature_image"  type="file" id="feature_image" accept="image/*" value="Upload" />
                                            <div class="progress mb-3 mt-3 bg-white" style="height: 5px">
                                                <div class="progress-bar feature_image_bar" role="progressbar" style="width: 0%" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100"></div>
                                            </div>
                                            @if($errors->has('feature_image'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('feature_image') }}
                                                </p>
                                            @endif
                                        </div>
                                    </div>
                                    
                                    <div class="col-12 mb-3 feature_image_div">
                                        <?php $feature_image = URL::asset('images/feature_image.png'); ?>
                                        @if(!empty($opportunity->feature_image))
                                            <?php $feature_image = URL::asset('Opportunity/'.$opportunity->partner_id.'/'.$opportunity->id.'/'.$opportunity->feature_image); ?>
                                        @endif
                                        <a href="{{$feature_image}}" class="" border download><img src="{{$feature_image}}" class="feature_imag img-responsive feature_image_file" alt="Feature Image" /></a>
                                        
                                        <a href="javascript:;" class="text-danger delete_feature_image" data_id="{{$opportunity->id}}" data_col="feature_image">Delete</a>
                                       
                                        
                                    </div>


                                    <div class="col-12">
                                        <div class="form-group {{ $errors->has('opportunity_desc') ? 'has-error' : '' }}">
                                            <label for="opportunity_desc">Description<small class="text-danger">*</small></label>
                                            <textarea type="opportunity_desc" id="opportunity_desc" name="opportunity_desc" class="form-control textarea_editor"  >{{ old('opportunity_desc', isset($opportunity) ? $opportunity->opportunity_desc : '') }}</textarea>
                                            @if($errors->has('opportunity_desc'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('opportunity_desc') }}
                                                </p>
                                            @endif
                                        </div>
                                    </div>
                                    
                                    <div class="col-12">
                                        <div class="form-group {{ $errors->has('category_id') ? 'has-error' : '' }}">
                                            <label for="category_id">Category<small class="text-danger">*</small></label>
                                            <select class="select2 single-select form-control" id="category_id" name="category_id">
                                                <option value="">Select Category</option>
                                                @if($categories->count())
                                                    @foreach($categories as $key=>$category)
                                                        <option value="{{$category->id}}" @if(old('category_id', isset($opportunity) ? $opportunity->category_id : '') == $category->id) selected @endif>{{$category->category_title}}</option>
                                                    @endforeach
                                                @endif
                                            </select>
                                            @if($errors->has('category_id'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('category_id') }}
                                                </p>
                                            @endif
                                        </div>
                                    </div>
                                    
                                </div>
                            </div>
                        </div>
                        <div class="card">
                            <div class="card-body">
                                <h3>Opportunity Address</h3>
                                <div class="row">
                                    <div class="col-12">

                                        <div class="form-group {{ $errors->has('address_location') ? 'has-error' : '' }}">
                                            <label for="address_location">Address <small class="text-danger">*</small></label>
                                            <input type="text" id="address_location" name="address_location" class="form-control" value="{{ old('address_location', isset($opportunity) ? $opportunity->address_location : '') }}" >
                                            @if($errors->has('address_location'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('address_location') }}
                                                </p>
                                            @endif
                                        </div> 

                                        
                                    </div>

                                    <div class="col-12">
                                        <div class="form-group {{ $errors->has('address_line1') ? 'has-error' : '' }}">
                                            <label for="address_line1">Address Extra Detail<small class="text-danger"> If required</small></label>
                                            <input type="text" idff="address_line1" id="autocomplete__" name="address_line1" class="form-control" value="{{ old('address_line1', isset($opportunity) ? $opportunity->address_line1 : '') }}" >
                                            <input type="hidden" name="org_lat" id="org_lat" />
                                            <input type="hidden" name="org_lang" id="org_lang" />
                                            @if($errors->has('address_line1'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('address_line1') }}
                                                </p>
                                            @endif
                                        </div> 
                                    </div>
                                </div>
                                <div class="row " style="opacity:0.25;">
                                    <div class="col-4">
                                        <div class="form-group {{ $errors->has('address_city') ? 'has-error' : '' }}">
                                            <label for="address_city">City<small class="text-danger">*</small></label>
                                            <input  type="text" id="locality" name="address_city" class="form-control" value="{{ old('address_city', isset($opportunity) ? $opportunity->address_city : '') }}" >
                                            @if($errors->has('address_city'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('address_city') }}
                                                </p>
                                            @endif
                                        </div> 
                                    </div>
                                    <div class="col-4">
                                        <div class="form-group {{ $errors->has('address_state') ? 'has-error' : '' }}">
                                            <label for="address_state">State<small class="text-danger">*</small></label>
                                            <input  type="text" id="administrative_area_level_1" name="address_state" class="form-control" value="{{ old('address_state', isset($opportunity) ? $opportunity->address_state : '') }}" >
                                            @if($errors->has('address_state'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('address_state') }}
                                                </p>
                                            @endif
                                        </div> 
                                    </div>
                                    <div class="col-4">
                                        <div class="form-group {{ $errors->has('address_country') ? 'has-error' : '' }}">
                                            <label for="address_country">Country<small class="text-danger">*</small></label>
                                            <?php /*<select name="address_country" class="form-control select2 single-select address_country" id="country_code">
                                                <option value="">Select Country</option>
                                            @if($countries->count())
                                                @foreach($countries as $key=>$country)
                                                    <option value="{{$country->country_code}}" @if(old('address_country', isset($opportunity) ? $opportunity->address_country : '') == $country->country_code) selected @endif >{{$country->country_name}}</option>
                                                @endforeach
                                            @endif
                                            </select>*/ ?>
                                            <input type="hidden" id="country" name="country" class="form-control" value="" >
                                            <input  type="text" id="country_code" name="address_country" class="form-control" value="{{ old('address_country', isset($opportunity) ? $opportunity->address_country : '') }}" >
                                            @if($errors->has('address_country'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('address_country') }}
                                                </p>
                                            @endif
                                        </div>
                                    </div>
                                    
                                    
                                    
                                    
                                    <div class="col-4">
                                        <div class="form-group {{ $errors->has('address_postcode') ? 'has-error' : '' }}">
                                            <label for="address_postcode">Postcode<small class="text-danger">*</small></label>
                                            <input  type="text" id="address_postcode" name="address_postcode" class="form-control" value="{{ old('address_postcode', isset($opportunity) ? $opportunity->address_postcode : '') }}" >
                                            @if($errors->has('address_postcode'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('address_postcode') }}
                                                </p>
                                            @endif
                                        </div> 
                                    </div>

                                    <div class="col-4">
                                        <div class="form-group {{ $errors->has('address_lat') ? 'has-error' : '' }}">
                                            <label for="address_lat">lat<small class="text-danger">*</small></label>
                                            <input  type="text" id="lat" name="address_lat" class="form-control" value="{{ old('address_lat', isset($opportunity) ? $opportunity->address_lat : '') }}" >
                                            @if($errors->has('address_lat'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('address_lat') }}
                                                </p>
                                            @endif
                                        </div> 
                                    </div>

                                    <div class="col-4">
                                        <div class="form-group {{ $errors->has('address_long') ? 'has-error' : '' }}">
                                            <label for="address_long">Long<small class="text-danger">*</small></label>
                                            <input  type="text" id="lng" name="address_long" class="form-control" value="{{ old('address_long', isset($opportunity) ? $opportunity->address_long : '') }}" >
                                            @if($errors->has('address_long'))
                                                <p class="text-danger small">
                                                    {{ $errors->first('address_long') }}
                                                </p>
                                            @endif
                                        </div> 
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="card">
                            <div class="card-body">
                                <div>
                                    @if($opportunity->on_going == 1 && !empty($opportunity->end_date))
                                        <button class="btn btn-primary" onClick="show_ongoing_message();" type="button" >{{ trans('global.update') }}</button>
                                    @else
                                        <button class="btn btn-primary update_opportunity" type="submit" >{{ trans('global.update') }}</button>
                                    @endif
                                    <a class="btn btn-secondary waves-effect waves-ripple mr-3" href="{{ route('admin.opportunities.index') }}">{{ trans('global.back_to_list') }}</a>
                                    
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    
@endsection
@section("script")
<script src="{{ asset('assets/plugins/select2/js/select2.min.js')}}"></script>
<script src="https://maps.googleapis.com/maps/api/js?libraries=places&key=AIzaSyC_yU9pJxAP7_h1YlGOpMPBHgZrpPkoc9k"></script>
<script src="{{URL::asset('assets/plugins/bootstrap-material-datetimepicker/js/moment.min.js')}}"></script>
<script src="{{URL::asset('assets/plugins/bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker.min.js')}}"></script>
<script>
    function show_ongoing_message(){
        swal({
          title: "Are you sure?",
          text: "{{ trans('opportunity.show_ongoing_message') }}",
          icon: "info", //Success, warning, info, error
          buttons: true,
          dangerMode: true,
        })
        .then((willComment) => {
            if (willComment) {
                $('#update_opportunity_form').submit();
            }
        });
    }
    function get_time_diff(){
        var start_time = $('#start_time').val();
        var end_time = $('#end_time').val();
        var start_date = $('#start_date').val();
        if(start_time && end_time){
            dt1 = new Date(start_date+' '+start_time);
            dt2 = new Date(start_date+' '+end_time);
            
            var diff =(dt2.getTime() - dt1.getTime()) / 1000;
              diff /= (60 * 60);
              $('#opportunity_hours').val(Math.abs(Math.round(diff)));
              
        }
        //alert(+' - '+);
    }
    $(document).ready(function(){
        
        $('#opportunity_title').on('blur',function(){
            var opp_name = $(this).val();
            var slug = opp_name.replace(/\s+/g, '-');
            if($('#slug').val().length == 0){
                $('#slug').val(slug.toLowerCase());
            }
        });
        
        var dateNow = new Date();
        $('#start_date').bootstrapMaterialDatePicker({
            time: false,
            format: 'YYYY-MM-DD',
            minDate: moment(),
            //currentDate:dateNow
        }).on('change',function(e, date){
            var dd = new Date('YYYY-MM-DD',date);
            var first_date = moment(date).format('DD-MM-YYYY');
            //alert(first_date);
            //$('#start_time').bootstrapMaterialDatePicker('setMinDate', '2022-03-10 01:00:00');
            //$('#end_time').bootstrapMaterialDatePicker('setMinDate', '2022-03-10 01:00:00');
            //$('#start_time').bootstrapMaterialDatePicker('setMaxDate', date);
            //$('#end_time').bootstrapMaterialDatePicker('setMaxDate', date);
            
        });
        
        $('#start_time').bootstrapMaterialDatePicker({
            time: true,
            date: false,
            format: 'HH:mm',
            switchOnClick : true,
            shortTime: true,
            //currentDate:dateNow
        }).on('change',function(e, date){
            
            $('#end_time').bootstrapMaterialDatePicker('setMinDate', date);
            get_time_diff();
        });

        $('#end_time').bootstrapMaterialDatePicker({
            time: true,
             date: false,
            format: 'HH:mm',
            switchOnClick : true,
            shortTime: true,
            //currentDate:dateNow
        }).on('change',function(e, date){
            
            $('#start_time').bootstrapMaterialDatePicker('setMaxDate', date);
            get_time_diff();
        });
        
        
        
        
        
        
    });
    
</script>
<script>
    //new google.maps.places.Autocomplete(document.getElementById("address_location"));
    

    // This example displays an address form, using the autocomplete feature
    // of the Google Places API to help users fill in the information.

    function fillInAddress() {
      // Get the place details from the autocomplete object.
      var place = autocomplete.getPlace();

      for (var component in componentForm) {
        document.getElementById(component).value = '';
      }

      // Get each component of the address from the place details
      // and fill the corresponding field on the form.
      for (var i = 0; i < place.address_components.length; i++) {
        console.log(place.address_components[i]);
        var addressType = place.address_components[i].types[0];
        if (componentForm[addressType]) {
          var val = place.address_components[i][componentForm[addressType]];
          document.getElementById(addressType).value = val;
        }
        // for the country, get the country code (the "short name") also
        if (addressType == "country") {
          document.getElementById("country_code").value = place.address_components[i].short_name;
        }

        if (addressType == "postal_code") {
          document.getElementById("address_postcode").value = place.address_components[i].short_name;
        }
      }
    }

    var placeSearch, autocomplete;
    var componentForm = {
      locality: 'long_name',
      administrative_area_level_1: 'short_name',
      country: 'long_name',
    };

    function initAutocomplete() {
      // Create the autocomplete object, restricting the search to geographical
      // location types.
      autocomplete = new google.maps.places.Autocomplete(document.getElementById('address_location'));

      // When the user selects an address from the dropdown, populate the address
      // fields in the form.
      // Get Latitude and longitude
      google.maps.event.addListener(autocomplete, 'place_changed', function() {
        var place = autocomplete.getPlace();
        document.getElementById('lat').value = place.geometry.location.lat();
        document.getElementById('lng').value = place.geometry.location.lng();
        fillInAddress();
      });
    }
    google.maps.event.addDomListener(window, 'load', initAutocomplete);



    $(document).ready(function(){

        
        $('.on_going').on('click',function(e){
            if ($(this).val() == 1) {
                var myDate = new Date();
                var start_date = moment(myDate).format('YYYY-MM-DD');
                $('#start_date').val(start_date);
                $('.start_date_div').hide();
            } else { 
                $('#start_date').val('');
                $('.start_date_div').show();
            }
        });

        $('.single-select').select2({
            theme: 'bootstrap4',
            width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style',
            placeholder: $(this).data('placeholder'),
            allowClear: Boolean($(this).data('allow-clear')),
        });
        $('.multiple-select').select2({
            theme: 'bootstrap4',
            width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style',
            placeholder: $(this).data('placeholder'),
            allowClear: Boolean($(this).data('allow-clear')),
        });


        $('body').on('click', '.delete_feature_image', function(ev) {

            var data_id = $(this).attr('data_id');
            var data_col = $(this).attr('data_col');
            var files_div = data_col+'_file';
            var postData=new FormData();
            postData.append('opportunity_id','{{$opportunity->id}}');    
            postData.append('data_col','feature_image');     
            var url="{{ route('admin.opportunities.delete_feature_image') }}";

            swal({
              title: "Are you sure?",
              text: "{{ trans('global.deleteFeatureImage') }}",
              icon: "info", //Success, warning, info, error
              buttons: true,
              dangerMode: true,
            })
            .then((willComment) => {
                if (willComment) {

                    $.ajax({
                        headers:{'X-CSRF-Token':'{{ csrf_token() }}'},
                        async:true,
                        type:"post",
                        dataType: 'json',
                        contentType:false,
                        url:url,
                        data:postData,
                        processData:false,
                        success:function(data){
                            if(data.success == 'done'){
                                $('body').find('.'+files_div).attr('src',data.doc_url);
                                $('.delete_feature_image').hide();
                                swal("Done!",data.msg,"success");
                            }else{
                                swal("Opps!",data.msg,"error");
                            }
                        },
                        error: function(data, errorThrown)
                        {
                            swal("Opps!",errorThrown,"error");
                        },
                    });
                }
            });
        });
        $('body').on('change', '.upload_feature_image', function(ev) {
            var filedata=this.files[0];
            var input = $(this).attr('id');
            var input_id = $(this).attr('id');
            var prograss_bar = input+'_bar';
            var files_div = input+'_file';

            $('body').find('.'+prograss_bar).parent('.progress').show();
            $('body').find('.'+prograss_bar).attr('style','');
            $('body').find('.'+prograss_bar).removeClass('bg-success');
            $('body').find('.'+prograss_bar).addClass('bg-danger');

            var imgtype=filedata.type;
            var reader=new FileReader();
            reader.onload=function(ev){
                //$('.front_door_img_file').attr('src',ev.target.result).css('width','150px').css('height','150px');
            }

            reader.readAsDataURL(this.files[0]);
            var postData=new FormData();
            postData.append('partner_id','{{$opportunity->partner_id}}');    
            postData.append('opportunity_id','{{$opportunity->id}}');    
            postData.append('field_name',input);     
            postData.append('field_value',this.files[0]);
            var url="{{ route('admin.opportunities.upload_feature_image') }}";

            $.ajax({
                headers:{'X-CSRF-Token':'{{ csrf_token() }}'},
                async:true,
                type:"post",
                dataType: 'json',
                contentType:false,
                url:url,
                data:postData,
                processData:false,
                success:function(data){
                    if(data.success == 'done'){
                        swal("Done!",data.msg,"success");
                        $('body').find('.'+files_div).attr('src',data.doc_url);
                        $('body').find('.'+prograss_bar).removeClass('bg-danger');
                        $('body').find('.'+prograss_bar).addClass('bg-success');
                        
                        $('.delete_feature_image').show();
                        $('.delete_feature_image').attr('data_id');
                        
                        var $el = $('#'+input_id);
                        $el.wrap('<form>').closest('form').get(0).reset();
                        $el.unwrap();
                         
                        
                    }else{
                        swal("Opps!",data.msg,"error");
                    }
                },
                error: function(data, errorThrown)
                    {
                        swal("Opps!",errorThrown,"error");
                    },
                xhr: function()
                {
                var xhr = new window.XMLHttpRequest();
                xhr.upload.addEventListener("progress", function(evt){
                  if (evt.lengthComputable) {
                    var percentComplete = evt.loaded / evt.total;
                    var pers = parseInt(percentComplete * 100);
                    var bar_per = 5;
                    if(pers > 5){
                        bar_per = (pers / 5) * 5;
                    } 
                    var class_p = 'width: '+bar_per+'%';
                    $('body').find('.'+prograss_bar).attr('style',class_p);
                    
                  }
                }, false);

                xhr.addEventListener("progress", function(evt){
                  if (evt.lengthComputable) {
                    var percentComplete = evt.loaded / evt.total;

                  }

                }, false);

                return xhr;

                }

            });

        });
    });
</script>
@endsection