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/create.blade.php
@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">-->

    <link rel="stylesheet" type="text/css" href="{{ asset('assets/datetime/jquery.timepicker.css')}}" />
    <link rel="stylesheet" type="text/css" href="{{ asset('assets/datetime/bootstrap-datepicker.css')}}" />
@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.create') }} {{ 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 action="{{ route("admin.opportunities.store") }}" method="POST" enctype="multipart/form-data" autocomplete="off">
                        @csrf
                        <div class="card">
                            <div class="card-body">

                                <h3>{{trans('opportunity.opportunity_detail')}}</h3>
                               
                                <hr/>
                                <div class="col-12 mb-2 mt-2">
                                    
                                    <label >{{trans('opportunity.ongoing_opportunity')}}<small class="text-danger">*</small></label>
                                    
                                    <div class="form-check  {{ $errors->has('slug') ? 'has-error' : '' }} form-check-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">
                                    </div>
                                    <div class="form-check  {{ $errors->has('slug') ? 'has-error' : '' }} form-check-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" checked value="0">
                                    </div>
                                </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)
                                                            <?php $partner_id = old('partner_id', isset($opportunity) ? $opportunity->partner_id : ''); ?>
                                                            <option value="{{$partner->id}}" @if($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 mb-2">
                                        <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 start_date_div" id="opportunity_datepair">

                                    <div class="ccol-sm-4 col-sm-4 col-md-4 " >
                                        <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" autocomplete="off" id="start_date" name="start_date" class="form-control start_date date start" 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="ccol-sm-4 col-sm-4 col-md-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 start_time time start" 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="ccol-sm-4 col-sm-4 col-md-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 end_time time end" 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="ccol-sm-4 col-md-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="ccol-sm-4 col-md-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="ccol-sm-4 col-md-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.select_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>
                                    <button class="btn btn-primary" type="submit" >{{ trans('global.next') }}</button>
                                    <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="{{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 type="text/javascript" src="{{ asset('assets/datetime/jquery.timepicker.js')}}"></script>
<script type="text/javascript" src="{{ asset('assets/datetime/bootstrap-datepicker.js')}}"></script>
<script src="{{ asset('assets/datetime/datepair.js')}}"></script>
<script src="{{ asset('assets/datetime/jquery.datepair.js')}}"></script>
<script>
    var dateNow = new Date();
    $('#opportunity_datepair .time').timepicker({
        'showDuration': true,
        'timeFormat': 'H:i:s',
        'autoclose': true,
        'minTime': $('#start_time').val(),
        'step':60,
        //'show2400': true,
    });

    $('#opportunity_datepair .date').datepicker({
        'format': 'yyyy-mm-dd',
        'autoclose': true,
        'startDate': dateNow,
    });

    $('#opportunity_datepair').datepair();

    $('#opportunity_datepair .time').on('change',function(){
        setTimeout(function () {
            $('#opportunity_datepair').datepair('refresh');
            var milliseconds = $('#opportunity_datepair').datepair('getTimeDiff');
            if(parseInt(milliseconds)){
                var tt = Math.floor((((milliseconds / 1000) / 60)/60));
                $('#opportunity_hours').val(tt);
            }
        }, 300);
    });
</script>

<script>

    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());
            }
        });

        
        /*$('#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();
        });*/
        
        $('.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();
                $('#end_time').val('00:00:00');
                $('#start_time').val('00:00:00');
            } else { 
                $('#start_date').val('');
                $('.start_date_div').show();
            }
        });
            
        
        
        
    });
    
</script>
@endsection