@extends('layout.app')


@section('content')
    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-12">
                    <!-- Horizontal Form -->
                    <div class="card card-primary">
                        <div class="card-header bg-light">

                            <h3 class="card-title" style="color:#115548;">Add Income</h3>
                            <div class="card-tools">
                                <a href="{{ route('income.index') }}"><button class="btn btn-sm btn-primary"><i
                                            class="fa fa-list" aria-hidden="true"></i> &nbsp;See List</button></a>
                            </div>
                        </div>
                        <!-- /.card-header -->
                        <!-- form start -->
                        <form method="POST" action="{{ route('income.store') }}" enctype="multipart/form-data">
                            @csrf

                            <div class="card-body">
                                <div class="row">
                                    {{-- <div class="form-group">
                                    <label for="shortname">
                                        Name*
                                    </label>
                                    <input type="text" name="name" class="form-control" placeholder="Enter Name" required>
                                    @error('shortname')
                                        <div class="alert alert-danger mt-1">
                                            {{ $message }}
                                        </div>
                                    @enderror
                                    </div> --}}

                                    <div class="form-group col-md-4">
                                        <label for="shortname">
                                            Name*
                                        </label>
                                        <input type="text" name="name" class="form-control" placeholder="Enter Name"
                                            required>
                                    </div>

                                    <div class="form-group col-md-4">
                                        <label for="shortname">
                                            Income Head*
                                        </label>
                                        <select name="incomeHead" class="form-control" required>
                                            <option value="">Select One</option>
                                            @foreach ($incomeHead as $item)
                                                <option value="{{ $item->id }}">{{ $item->name }}</option>
                                            @endforeach
                                        </select>
                                    </div>

                                    <div class="form-group col-md-4">
                                        <label for="shortname">
                                            Invoice Number
                                        </label>
                                        <input type="text" name="invoice_number" class="form-control"
                                            placeholder="Enter Invoice Number">
                                    </div>
                                    <div class="form-group col-md-4">
                                        <label for="shortname">
                                            Date*
                                        </label>
                                        <input type="date" name="date" class="form-control" placeholder="Enter Date"
                                            required>
                                    </div>
                                    {{-- <div class="form-group">
                                    <label for="shortname">
                                        Date*
                                    </label>
                                    <div class="input-group date" id="searchTo" data-target-input="nearest">
                                        <input type="text" name="date"
                                            class="form-control datetimepicker-input input-group-append"
                                            data-toggle="datetimepicker" data-target="#searchTo" autocomplete="off">
                                    </div>
                                    </div> --}}
                                    <div class="form-group col-md-4">
                                        <label for="shortname">
                                            Amount*
                                        </label>
                                        <input type="number" name="amount" class="form-control" placeholder="Enter Amount"
                                            required>
                                    </div>

                                    @if (checkSettings('bank_account_deposit_from_payment') == 'enable')
                                    <div class="form-group col-md-4">
                                        <label for="bank_account_id">
                                            Bank Account (Optional)
                                        </label>
                                        <select name="bank_account_id" class="form-control">
                                            <option value="">Select Bank Account (Leave empty for Cash)</option>
                                            @if(isset($bankAccounts) && $bankAccounts->count() > 0)
                                                @foreach ($bankAccounts as $bankAccount)
                                                    <option value="{{ $bankAccount->id }}">{{ $bankAccount->account_name }} -- {{ $bankAccount->bank_name }}</option>
                                                @endforeach
                                            @endif
                                        </select>
                                        <small class="text-muted">If selected, income will be deposited to this bank account.</small>
                                    </div>
                                    @endif

                                    <div class="form-group col-md-4">
                                        <label for="shortname">
                                            Attach Document*
                                        </label>
                                        <input type="file" name="attach_document" class="form-control">

                                        {{-- <input type="hidden" name="id" value="{{ $model->id }}"> --}}
                                    </div>

                                    <div class="form-group col-md-12">
                                        <label for="shortname">
                                            Description*
                                        </label>
                                        <textarea name="description" class="form-control" placeholder="Type Description"></textarea>
                                    </div>
                                </div>
                                <div class="form-group float-right">
                                    <button type="submit" name="btn" class="btn btn-primary">Save</button>
                                </div>
                            </div>
                        </form>

                    </div>
                    <!-- /.card -->
                </div>
                <div class="col-2"></div>
            </div>
            <!-- /.row -->

        </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
@endsection
@push('script-bottom')
@endpush
