@extends('layouts.nav')
@section('title')
{{$JournalType}} Journal
@endsection
@section('content')

                    <!-- Page Heading -->
                    <div class="d-sm-flex align-items-center justify-content-between mb-4">

                      <div class="d-sm-flex align-items-center justify-content-between mb-4">
                        <h1 class="h3 mb-0 text-gray-800">{{$JournalType}}  Journal</h1>
                      </div>
                      <div class="d-sm-flex align-items-center justify-content-between mb-4">
                      <li class="d-sm-flex align-items-center justify-content-between mb-4">
                            <a class="nav-link" href="{{route('journalprocessing')}}">
                                <i class="fas fa-wallet"></i>
                                <span>Back To Journals</span></a>
                      </li>
                      </div>

                      </div>



                    <div class="card shadow mb-4">
                        <div class="card-header py-3">
                            <h6 class="m-0 font-weight-bold text-primary"   id="formHeader">Process {{$JournalType}}  Journal</h6>
                        </div>
                        @if (session('success'))
                            <div class="alert alert-success" id="successMessage"  style="margin: 20px;">
                                {{ session('success') }}
                            </div>
                        @endif

                        @if ($errors->any())

                                    <div class="form-group"  id="successMessage"  style="margin: 20px;">
                                        <div class="card bg-warning text-white shadow">
                                            <div class="card-body">

                                                @foreach ($errors->all() as $error)
                                                <div style="color: red; ">{{ $error }}</div>
                                                @endforeach

                                            </div>
                                        </div>
                                    </div>
                                    @endif
                            <form class="card-body" action="{{route('addjournals')}}" method="post"  id="accountTypeForm">
                            @csrf
                            <input type="hidden" id="accountId" name="id" value="">
                            <input type="hidden" id="source" name="source" value="{{$JournalType}}">

                            <div class="form-group row">
                                    <div class="col-sm-6 mb-3 mb-sm-0">
                                    <input type="text" class="form-control form-control-user" id="AccCode" placeholder="Journal Code" name="AccCode"  value="{{ $journal }}" required readonly>
                                    </div>
                                    <div class="col-sm-6">
                                    <input type="date" class="form-control form-control-user" id="date" placeholder="Entry Date" name="date"  value="{{ old('date', \Carbon\Carbon::now()->format('Y-m-d')) }}" required>
                                   </div>
                                </div>


                                <div class="form-group row">
                                    <div class="col-sm-6 mb-3 mb-sm-0">
                                    <input type="text" class="form-control form-control-user" id="narr" placeholder="Narration" name="narr"  value="{{ old('narr') }}" required>

                                    </div>
                                    <div class="col-sm-6">
                                    <select class="form-control form-control-user" id="account" name="account"  value="{{ old('account') }}"  required>
                                        <option value="" disabled selected>Select {{$JournalType}} Account</option>

                                        @foreach ($Accounts as $Account)

                                        <option value="{{ $Account->Code }}">{{ $Account->Code.'/'.$Account->Name }}</option>

                                        @endforeach
                                    </select>
                                   </div>

                                </div>

                                <div class="form-group row">
                                    <div class="col-sm-6 mb-3 mb-sm-0">
                                    <input type="text" class="form-control form-control-user" id="reff" placeholder="Refference" name="reff"  value="{{ old('reff') }}" required>

                                    </div>
                                    <div class="col-sm-6">

                                    <select class="form-control form-control-user" id="tr" name="tr"  value="{{ old('tr') }}"  required>
                                        <option value="" disabled selected>TR Code</option>
                                        <option value="DR">DR</option>
                                        <option value="CR">CR</option>
                                    </select>
                                     </div>
                                </div>

                                <div class="form-group row">
                                    <div class="col-sm-6 mb-3 mb-sm-0">
                                    <select class="form-control form-control-user" id="curr" name="curr"  value="{{ old('curr') }}"  required>
                                        <option value="" disabled selected>Select Currency</option>

                                        @foreach ($currencys as $currency)

                                        <option value="{{ $currency->ID}}">{{ $currency->Name }}</option>

                                        @endforeach
                                    </select>
                                    </div>
                                    <div class="col-sm-6">

                                    <input type="text" class="form-control form-control-user" id="amount" placeholder="00.00" name="amount"  value="{{ old('amount') }}" required>

                                        </div>

                                </div>


                               <div style="display: flex;">
                               <input type="submit" style="width: 100px;height: 40px; margin-right: 10px; margin-top: 6px" value="Proccess" class="btn btn-primary btn-user btn-block" id="submitButton"/>

                                <input style="width: 100px;"    type="reset" value="Refresh" class="btn btn-secondary btn-user btn-block"  onclick="hideMessages()"/>

                               </div>

                                <hr>
                             </form>

                    </div>

                </div>



            </div>




@endsection
