@extends('layouts.master')

@section('content')
 <div class="row">
 <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">Add New Revenue</h3>
        </div>
        <div class="panel-body">
            @include('layouts.message')
            <form action="{{ url('account/revenue/save') }}" method="POST" class="form-horizontal" role="form">
                {{ csrf_field() }}

            <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                <div class="form-group">
                    <label for="debit_head" class="col-sm-12 col-xs-12 col-md-3 col-lg-3 control-label">Debit Head</label>
                
                <div class="col-xs-12 col-sm-12 col-md-7 col-lg-7">
                    <select name="debit_head" id="debit_head" class="form-control">
                        <option value="">-Select Account Head-</option>
                        @if($account_types)
                            @foreach($account_types as $type)
                                <option value="{{ $type->id }}">{{ $type->name }}</option>
                            @endforeach
                        @endif
                    </select>
                </div>
                </div>
                <div class="form-group">
                    <label for="amount" class="col-sm-12 col-xs-12 col-md-3 col-lg-3 control-label">Amount</label>
                
                <div class="col-xs-12 col-sm-12 col-md-7 col-lg-7">
                    <input type="text" name="amount" id="amount" class="form-control" onkeypress="return checkNumber(event)" required placeholder="Amount"> 
                </div>
                </div>
                <div class="form-group">
                    <label for="description" class="col-sm-12 col-xs-12 col-md-3 col-lg-3 control-label">Description</label>
                
                <div class="col-xs-12 col-sm-12 col-md-7 col-lg-7">
                    <textarea name="description" id="description" class="form-control" placeholder="Description"></textarea>
                </div>
                </div>
        
                <div class="form-group">
                    <div class="col-sm-10 col-sm-offset-3">
                        <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Save</button>

                        <a href="{{ url('account/journal') }}" class="btn btn-default"><i class="fa fa-times"></i> Cancel</a>
                    </div>
                </div>
            </div>

            <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                <div class="form-group">
                    <label for="credit_head" class="col-sm-12 col-xs-12 col-md-3 col-lg-3 control-label">Credit Head</label>
                
                    <div class="col-xs-12 col-sm-12 col-md-7 col-lg-7">
                        <select name="credit_head" id="credit_head" class="form-control">
                            <option value="">-Select Account Head-</option>
                            @if($credit_heads)
                                @foreach($credit_heads as $type)
                                    <option value="{{ $type->id }}">{{ $type->name }}</option>
                                @endforeach
                            @endif
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label for="client" class="col-sm-12 col-xs-12 col-md-3 col-lg-3 control-label">Client</label>
                
                    <div class="col-xs-12 col-sm-12 col-md-7 col-lg-7">
                        <select name="client" id="client" class="form-control">
                            <option value="">-Select Client-</option>
                            @if($companies)
                            @foreach($companies as $row)
                                <option value="{{ $row->id }}">{{ $row->name}}</option>
                            @endforeach
                            @endif
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label for="date" class="col-sm-12 col-xs-12 col-md-3 col-lg-3 control-label">Date</label>
                
                    <div class="col-xs-12 col-sm-12 col-md-7 col-lg-7">
                        <input type="text" name="date" id="date" class='form-control date' value="{{ date('Y-m-d') }}">
                    </div>
                </div>
            </div>
            </form>
        </div>
    </div>
 </div>
 </div>
@stop

@section('script')
<script type="text/javascript">
$(document).ready(function() {
     $( ".date" ).datepicker({
          changeMonth: true,
          changeYear: true,
          dateFormat:"yy-mm-dd"
     });
});

function checkNumber(evt)
{
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode != 46 && charCode > 31 
      && (charCode < 48 || charCode > 57))
    {
        alert('Invalid amount  !!');
       return false;
    }

    return true;
}
</script>
@stop