@extends('layout.loggedin')

@section('page-css')
    <style media="screen">

    </style>
    <link type="text/css" rel="stylesheet" href="{!! asset('css/jsgrid.min.css') !!}" />
    <link type="text/css" rel="stylesheet" href="{!! asset('css/jsgrid-theme.min.css') !!}" />
@endsection

@section('content')
    <section class="hero-wrap" style="background-image: url('{{ asset('images/fun.png')}}'); background-attachment:fixed">
        <div class="overlay"></div>
        <div class="container">
            <div class="row description align-items-center justify-content-center">
                <div class="col-md-12 text-center">
                    <div class="col-md-8 mx-auto text-center">
                        <div class="text">
                            <h2 class="mb-5">Fidelity Young Enterprenuer <br> Initiative</h2>
                            <div class="designed d-inline-block">
                                <d class="d-flex align-items-center">
                                    <div class="ml-3">
                                        <h3 class=" text-white mb-0">FYEI Application Form </h3> <br>
{{--                                        @include('layout.alert')--}}
                                    </div>
                                </d>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <section class="ftco-section bg-light pb-4 goto-here pb-0">
        <div class="container">
            @include('layout.alert')
            <form class="" id="SaveLater" action="{{ route('section2.process') }}" method="POST" enctype="multipart/form-data">
                @csrf

                <div >
                    <section class="ftco-section ftco-section-2 bg-light" id="navigationTabs">
                        <div class="container-fluid">

                            <div class="row">

                                <div class="col-lg-12" id="rootwizard">
                                    <div class="tabulation-2">
                                        <ul class="nav nav-pills nav-fill d-md-flex d-block">
                                            <li class="nav-item">
                                                <a class="nav-link active py-3" data-toggle="tab" href="#sectionA"><span class="ion-io"></span>1</a>
                                            </li>
                                            <li class="nav-item px-lg-2">
                                                <a class="nav-link  py-3" data-toggle="tab" href="#sectionB"><span class="ion-ios-"></span> 2</a>
                                            </li>
{{--                                            <li class="nav-item px-lg-2">--}}
{{--                                                <a class="nav-link py-3" data-toggle="tab" href="#sectionC"><span class="ion-io"></span> 3</a>--}}
{{--                                            </li>--}}
                                        </ul>
                                        <div class="tab-content rounded mt-2">


                                            <div class="tab-pane container p-4 active" id="sectionA">

                                                <h3 class="fid text-uppercase">Section G: FINANCIAL PERFORMANCE For Previous Year</h3>
                                                <div class="table-responsive">
                                                    <table class="table table-stried table-bordered table-hover">
                                                        <thead>
                                                        {{-- <tr class="text-center">
                                                            <th>2020</th>
                                                        </tr> --}}
                                                        </thead>
                                                        <tbody>
                                                        <tr class="text-center"><td colspan="3"><h4>LIQUIDITY  </h4></td></tr>

                                                        <tr>
                                                            <td colspan="3">
                                                              <div class="row">
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Current Assets <small>(the company’s inventory, plus trade receivables, plus cash and cash equivalent on the SOFP)</small> <span class="text-danger">*</span> </label>
                                                                      <input type="number" step="any"  name="current_assets" class="form-control" id="current_assets"  value="{{ old('curr_asset') }}">
                                                                  </div>
                                                                </div>
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Current Liabilities <small>(the company’s trade payables plus other payables on the statement of financial position (SOFP))</small> <span class="text-danger">*</span> </label>
                                                                      <input type="number" step="any"  name="current_liabilities" class="form-control" id="current_liabilities"  value="{{ old('curr_lia') }}">
                                                                  </div>
                                                                </div>
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Inventory <span class="text-danger">*</span> </label> <br> <br> <br>
                                                                      <input type="number" step="any"  name="inventory" class="form-control" id="inventory"  value="{{ old('inventory') }}">
                                                                  </div>
                                                                </div>
                                                              </div>

                                                            </td>

                                                            {{-- <td>
                                                                <div class="form-group">
                                                                    <label for="">Current Assets <small>(the company’s inventory, plus trade receivables, plus cash and cash equivalent on the SOFP)</small> <span class="text-danger">*</span> </label>
                                                                    <input type="number" step="any"  name="current_assets_21" class="form-control" id="current_assets_21"  value="{{ old('curr_asset') }}">
                                                                </div>
                                                            </td> --}}
                                                        </tr>
                                                        {{-- <tr> --}}

                                                            {{-- <td>
                                                                <div class="form-group">
                                                                    <label for="">Current Liabilities <small>(the company’s trade payables plus other payables on the statement of financial position (SOFP))</small> <span class="text-danger">*</span> </label>
                                                                    <input type="number" step="any"  name="current_liabilities_21" class="form-control" id="current_liabilities_21"  value="{{ old('curr_lia') }}">
                                                                </div>
                                                            </td> --}}
                                                        {{-- </tr>
                                                        <tr> --}}

                                                            {{-- <td>
                                                                <div class="form-group">
                                                                    <label for="">Inventory <span class="text-danger">*</span> </label>
                                                                    <input type="number" step="any"  name="inventory_21" class="form-control" id="inventory_21"  value="{{ old('inventory') }}">
                                                                </div>
                                                            </td> --}}
                                                        {{-- </tr> --}}
                                                        <tr class="text-center"><td colspan="3"> <h4 class="text-uppercase">Debt-to-Equity </h4></td></tr>

                                                        <tr>
                                                            <td colspan="3">
                                                              <div class="row">
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Total Debts <small>(current liabilities+ long term liabilities)</small> <span class="text-danger">*</span> </label> <br><br>
                                                                      <input type="number" step="any"  name="total_debt" class="form-control" id="total_debt"  value="{{ old('total_debt') }}">
                                                                  </div>
                                                                </div>
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Shareholders Equity <small>(Stated Capital+Revaluation Reserves +Retained Earnings )</small> <span class="text-danger">*</span> </label>
                                                                      <input type="number" step="any"  name="share_equity" class="form-control" id="share_equity"  value="{{ old('share_equity') }}">
                                                                  </div>
                                                                </div>
                                                              </div>

                                                            </td>

                                                            {{-- <td>
                                                                <h6>GEARING RATIOS</h6>
                                                                <div class="form-group">
                                                                    <label for="">Total Debts <small>(current liabilities+ long term liabilities)</small> <span class="text-danger">*</span> </label>
                                                                    <input type="number" step="any"  name="total_debt_21" class="form-control" id="total_debt_21"  value="{{ old('total_debt') }}">
                                                                </div>
                                                            </td> --}}
                                                        {{-- </tr>
                                                        <tr> --}}

                                                            {{-- <td>
                                                                <div class="form-group">
                                                                    <label for="">Shareholders Equity <small>(Stated Capital+Revaluation Reserves +Retained Earnings )</small> <span class="text-danger">*</span> </label>
                                                                    <input type="number" step="any"  name="share_equity_21" class="form-control" id="share_equity_21"  value="{{ old('share_equity') }}">
                                                                </div>
                                                            </td> --}}
                                                        </tr>
                                                        <tr class="text-center"><td colspan="3"><h4 class="text-uppercase">Efficiency </h4></td></tr>

                                                        <tr>
                                                            <td colspan="3">
                                                              <div class="row">
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Average Trade Receivables <small>(trade receivables in previous year , plus receivables in current year ,divided by two (2)-SOFP)</small> <span class="text-danger">*</span> </label>
                                                                      <input type="number" step="any"  name="trade_receivables" class="form-control" id="trade_receivables"  value="{{ old('trade_receivables') }}">
                                                                  </div>
                                                                </div>
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Credit Sales <small>(Total Sales – Cash Sales)</small> <span class="text-danger">*</span> </label> <br> <br> <br>
                                                                      <input type="number" step="any"  name="credit_sales" class="form-control" id="credit_sales"  value="{{ old('credit_sales') }}">
                                                                  </div>
                                                                </div>
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Average Trade Payables <small>(payables in previous year, plus payables in current year, divided by 2- SOFP)</small> <span class="text-danger">*</span> </label>
                                                                      <input type="number" step="any"  name="trade_payables" class="form-control" id="trade_payables"  value="{{ old('trade_payables') }}">
                                                                  </div>
                                                                </div>
                                                              </div>
                                                              <div class="row">
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Credit Purchases <small>(Total Purchases-Cash Purchases )</small> <span class="text-danger">*</span> </label>
                                                                      <input type="number" step="any"  name="credit_purchases" class="form-control" id="credit_purchases"  value="{{ old('credit_purchases') }}">
                                                                  </div>
                                                                </div>
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Average Inventory <small>(Inventory in previous year, plus inventory in current year, divided by 2-SOFP)</small> <span class="text-danger">*</span> </label>
                                                                      <input type="number" step="any"  name="avg_inventory" class="form-control" id="avg_inventory"  value="{{ old('credit_purchases') }}">
                                                                  </div>
                                                                </div>
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Cost of Sales <small>(Opening Inventory+Purchases-Closing Inventory)</small>  <span class="text-danger">*</span> </label>
                                                                      <input type="number" step="any"  name="cost_of_sales" class="form-control" id="cost_of_sales"  value="{{ old('cost_of_sales') }}">
                                                                  </div>
                                                                </div>
                                                              </div>

                                                            </td>

                                                        </tr>
                                                        <tr class="text-center">
                                                            <td colspan="3"><h4>PROFITABILITY </h4></td>
                                                        </tr>

                                                        <tr>
                                                            <td colspan="3">
                                                              <div class="row">
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Gross Profit <small>(Sales minus the cost of sales- Statement of Comprehensive Income (Income Statement))</small> <span class="text-danger">*</span> </label>
                                                                      <input type="number" step="any"  name="gross_profit" class="form-control" id="gross_profit"  value="{{ old('gross_profit') }}">
                                                                  </div>
                                                                </div>
                                                                <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Sales Turnover <span class="text-danger">*</span> </label> <br> <br>
                                                                      <input type="number" step="any"  name="sales_turnover" class="form-control" id="sales_turnover"  value="{{ old('sales_turnover') }}">
                                                                  </div>
                                                                </div>

                                                              </div>
                                                              <div class="row">
                                                                <div class="col-lg-6">
                                                                  <div class="form-group">
                                                                      <label for="">Net Profit <small>(Gross Profit minus total expenses-(Income Statement))</small> <span class="text-danger">*</span> </label>
                                                                      <input type="number" step="any"  name="net_profit" class="form-control" id="net_profit"  value="{{ old('net_profit') }}">
                                                                  </div>
                                                                </div>
                                                                {{-- <div class="col-lg">
                                                                  <div class="form-group">
                                                                      <label for="">Sales Turnover(Revenue) <span class="text-danger">*</span> </label>
                                                                      <input type="number" step="any"  name="sales_turnover_revenue" class="form-control" id="sales_turnover_revenue"  value="{{ old('sales_turnover_revenue') }}">
                                                                  </div>
                                                                </div> --}}

                                                              </div>

                                                            </td>
                                                            {{-- <td>
                                                                <div class="form-group">
                                                                    <label for="">Gross Profit <small>(Sales minus the cost of sales- Statement of Comprehensive Income (Income Statement))</small> <span class="text-danger">*</span> </label>
                                                                    <input type="number" step="any"  name="gross_profit_21" class="form-control" id="gross_profit"  value="{{ old('gross_profit') }}">
                                                                </div>
                                                            </td> --}}
                                                        </tr>

                                                        </tbody>
                                                    </table>
                                                </div>

                                            </div>
                                            <div class="tab-pane container p-4 fade" id="sectionB">
                                                <h3 class="fid">Upload Business Documents</h3>
                                                <div class="row">
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label> Business Plan / Pitch Deck<span class="text-danger">*</span></label>
                                                            <input type="file" name="business_plan" id="business_plan" class="form-control">
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label> Management Account / At least 1 year (balance sheet, income statement & cashflow statement) <span class="text-danger">*</span></label>
                                                            <input type="file" name="management_account[]" id="management_account" multiple class="form-control">
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label> ID Cards of Directors / Shareholders<span class="text-danger">*</span></label>
                                                            <input type="file" name="id_cards[]" id="id_cards" multiple class="form-control">
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label> 3 Years Projected Financial Statement<span class="text-danger">*</span></label>
                                                            <input type="file" name="projected_financial_statement" id="projected_financial_statement" class="form-control">
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label> Business Registration Documents<span class="text-danger">*</span></label>
                                                            <input type="file" name="business_registration_documents[]" multiple id="business_registration_documents" class="form-control">
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label> 1-year historic financials / previous year financials<span class="text-danger">*</span></label>
                                                            <input type="file" name="historic_financial[]" multiple id="historic_financial" class="form-control">
                                                        </div>
                                                    </div>

                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label> 12 Months Bank Statements<span class="text-danger">*</span></label>
                                                            <input type="file" name="bank_statements[]" multiple id="bank_statements" class="form-control">
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label> Regulatory Permits and Licenses<span class="text-danger">*</span></label>
                                                            <input type="file" name="permits[]" id="permits" multiple class="form-control">
                                                        </div>
                                                    </div>
                                                </div>

                                            </div>

                                            <input type="hidden" name="isocif" value="0">

                                            <div class="row pagination wizard  pb-4">
                                                <div class="col-lg  text-center">
                                                    <li class=" text-white previous disabled"><button type="button" class="text-white mb-3 btn fidbtn"><span class="text-white ion-ios-arrow-back" style="font-size:15px ;"> Previous</span></button></li>

                                                    {{-- <button type="button" class="btn btn-secondary" name="button">Save for later</button> --}}
                                                </div>
{{--                                                <div class="col-lg  text-center">--}}
{{--                                                    <li class=" text-white  "><button type="submit"  name="saveforlater" value="saveforlater" class="text-white mb-3 btn btn-success" style=""><span class="text-white " style="font-size:15px">  Save For Later</span></button></li>--}}
{{--                                                </div>--}}
                                                <input type="hidden" name="saveType" id="saveType">
                                                <div class="col-lg  text-center">
                                                    <li class="text-white "><button id="save" type="submit" style="width:150px !important;" name="complete" value="complete" class=" mb-3  text-white btn btn-success">Submit</button></li>
                                                </div>
                                                <div class="col-lg  text-center">
                                                    <li class=" text-white next "><button type="button" style="width:150px !important;" class="text-white hh mb-3 btn fidbtn">Next <span class="text-white ion-ios-arrow-forward" style="font-size:15px"> </span></button></li>
                                                </div>
                                            </div>
            </form>
        </div>
    </section>


    <div class="modal modal-fluid fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="modal_1" aria-hidden="true">
        <div class="modal-dialog modal-md" role="document">
            <div class="modal-content">
                <div class="modal-body">
                    <div class="row justify-content-center">
                        <div class="col-lg-12 text-center py-4">
                            <h5 class="heading h5">Required Fields Cannot be left Blank</h5>
                            <p class="lead text-muted">
                                Please fill all fields with the <span class="text-danger">*</span> mark <br>
                                {{--                                <small>Sections 1,2 and 7 are required</small>--}}
                            </p>

                            <button type="button" class="btn btn-primary" data-dismiss="modal">Okay</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {{-- <section class="ftco-section bg- goto-here pb-0">
      <div class="container">
        <div class="row">
          <div class="col-lg">
            <img src="{!! asset('images/team.png') !!}" class="img-fluid" alt="">
        </div>
    </div>

</section> --}}
@endsection

@section('page-js')
    <script src="{!! asset('js/jquery.bootstrap.wizard.min.js') !!}" charset="utf-8"></script>
    <script type="text/javascript">
        $(document).ready(function() {



            $('#rootwizard').bootstrapWizard({
                'tabClass': 'nav nav-pills',
                'onNext': function(tab, navigation, index) {

                    if (index ==1) {
                        if($('#current_assets').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }
                        else if($('#current_liabilities').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }else if($('#inventory').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }else if($('#total_debt').val() === ''){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#share_equity').val() === ''){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#trade_receivables').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#net_profit').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }
                        // else if($('#sales_turnover_revenue').val() === '' ){
                        //     $('#myModal').modal('show')
                        //     return false
                        // }
                        else if($('#sales_turnover').val() === ''){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#gross_profit').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#cost_of_sales').val() === ''){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#avg_inventory').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#credit_purchases').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#trade_payables').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#credit_sales').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }
                    } else if(index ==2){
                        if($('#business_plan').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }else if ($('#management_account').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }
                        else if ($('#id_cards').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }
                        else if ($('#projected_financial_statement').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }
                        else if ($('#business_registration_documents').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }
                        else if ($('#bank_statements').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }
                        else if ($('#permits').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }
                    }

                },

                'onTabClick': function(tab, navigation, index) {

                    if (index ==0) {
                        if($('#current_assets').val() === '' ) {
                            $('#myModal').modal('show')
                            return false;
                        }
                        else if($('#current_liabilities').val() === '' ) {
                            $('#myModal').modal('show')
                            return false;
                        }else if($('#inventory').val() === '' ) {
                            $('#myModal').modal('show')
                            return false;
                        }else if($('#total_debt').val() === ''){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#share_equity').val() === ''){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#trade_receivables').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#net_profit').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }
                        // else if($('#sales_turnover_revenue').val() === '' ){
                        //     $('#myModal').modal('show')
                        //     return false
                        // }
                        else if($('#sales_turnover').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#gross_profit').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#cost_of_sales').val() === ''){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#avg_inventory').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#credit_purchases').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#trade_payables').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }else if($('#credit_sales').val() === '' ){
                            $('#myModal').modal('show')
                            return false
                        }
                    }else if(index == 1){
                        if($('#business_plan').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }else if ($('#management_account').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }
                        else if ($('#id_cards').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }
                        else if ($('#projected_financial_statement').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }
                        else if ($('#business_registration_documents').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }
                        else if ($('#bank_statements').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }
                        else if ($('#permits').val() === '') {
                            $('#myModal').modal('show')
                            return false;
                        }

                    }

                }

            });

        });
    </script>

    <script type="text/javascript" src="{!! asset('css/jsgrid.min.js') !!}"></script>
    <script type="text/javascript">
        var token = $('input[name=_token]');




        $('#SaveLater').on('submit', function (e) {
            e.preventDefault();
            let saveType = $('#saveType').val($(this).find("button:focus").attr('value'));

            $(this).find("button:focus").text('Processing...');
            $(this).find("button:focus").attr('disabled', true);
            changeBtnLook('disable')

            let formData = new FormData(this),
                url = $(this).attr('action');

            $.ajax({
                url: url,
                method: 'POST',
                data: formData,
                dataType: 'JSON',
                contentType: false,
                cache: false,
                processData: false,
            }).done((response) => {
                console.log(response)
                if (response.msg == 'redirect'){
                    window.location.href = response.route;
                }else if(response.code == '402'){
                    runToast(response.msg, response.code)
                    changeBtnLook('enable')
                } else{
                    runToast(response.msg, response.code)
                    changeBtnLook('enable')
                }
            })
        });

        function changeBtnLook(status){
            let saveForLater = $('#saveForLater'),
                        save = $('#save');


            if (status ==='disable') {
                $(this).find("button:focus").text('Processing...');
                $(this).find("button:focus").prop('disabled', true);

            }
            if(status == 'enable'){
                save.prop('disabled', false)
                save.html('Submit')

                saveForLater.prop('disabled', false)
                saveForLater.html('Save For Later')
            }

        }
    </script>
@endsection
