{{ include('common/header.twig') }}
<div class="page-title">
    <div class="row align-items-center">
        <div class="col-sm-12">
            <h2 class="page-title-text d-inline-block">{{ page_title }}</h2>
            <div class="breadcrumbs d-inline-block">
                <ul>
                    <li><a href="{{ common.info.url }}">Dashboard</a></li>
                    <li><a href="{{ common.info.url_route }}expenses">Expenses</a></li>
                    <li>{{ page_title }}</li>
                </ul>
            </div>
        </div>
    </div>
</div>

<form action="{{ action }}" method="post">
    <div class="panel panel-default">
        <div class="panel-body">
            <input type="hidden" name="_token" value="{{ common.token }}">
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label>Name <span class="form-required">*</span></label>
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text"><i class="las la-user"></i></span>
                            </div>
                            <input type="text" name="expense[name]" class="form-control" value="{{ result.name }}" placeholder="Enter Name . . ." required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>Amount <span class="form-required">*</span></label>
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text">{{ common.info.currency_abbr }}</span>
                            </div>
                            <input type="text" name="expense[amount]" class="form-control" value="{{ result.amount }}" placeholder="Enter Purchase Amount . . ." required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>Date <span class="form-required">*</span></label>
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text"><i class="las la-calendar"></i></span>
                            </div>
                            <input type="text" name="expense[date]" class="form-control date bg-white" value="{{ result.date|date(common.info.date_format) }}" placeholder="Select Purchase Date . . ." readonly autocomplete="off" required>
                        </div>
                    </div>
                    {% if result.id %}
                        <div class="form-group">
                            <label>Receipt/Documents</label>
                            <div class="attach-file">
                                <a class="btn btn-warning btn-sm" data-toggle="modal" data-target="#attach-file"><i class="las la-cloud-upload-alt mr-2"></i> Upload</a>
                            </div>
                        </div>
                        <div class="attachment-container">
                            {% for value in receipt %}
                                <div class="attachment-image attachment-pdf">
                                    {% if value.ext == 'pdf' %}
                                        <a href="public/uploads/attachments/{{ value.file }}" class="open-pdf"><i class="las la-file-pdf"></i></a>
                                    {% else %}
                                        <a data-fancybox="gallery" href="public/uploads/attachments/{{ value.file }}">
                                            <img src="public/uploads/attachments/{{ value.file }}" alt="">
                                        </a>
                                    {% endif %}
                                    <div class="attachment-delete" data-toggle="tooltip" title="Delete"><a class="las la-trash-alt"></a></div>
                                    <input type="hidden" name="report_name" value="{{ value.file }}">
                                </div>
                            {% endfor %}
                        </div>
                    {% endif %}
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label>Expense Type <span class="form-required">*</span></label>
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text"><i class="las la-hand-point-right"></i></span>
                            </div>
                            <select class="custom-select" name="expense[expensetype]" required>
                                {% for value in expensetype %}
                                    <option value="{{ value.id }}"{% if value.id == result.expense_type %} selected{% endif %} >{{ value.name }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>Method <span class="form-required">*</span></label>
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text"><i class="las la-credit-card"></i></span>
                            </div>
                            <select name="expense[method]" class="custom-select" required>
                                {% for value in method %}
                                    <option value="{{ value.id }}"{% if result.method == value.id %} selected {% endif %}>{{ value.name }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>Description</label>
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text"><i class="las la-paragraph"></i></span>
                            </div>
                            <textarea name="expense[description]" class="form-control" rows="6">{{ result.description }}</textarea>
                        </div>
                    </div>
                </div>
            </div>
            <input type="hidden" name="expense[id]" class="view-id" value="{{ result.id }}">
        </div>
        <div class="panel-footer">
            <div class="content-submit text-center">
                <button type="submit" name="submit" class="btn btn-primary">Save</button>
            </div>
        </div>
    </div>
</form>
<!-- Attach File Modal -->
<div id="attach-file" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Upload Receipt</h5>
                <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
            <div class="modal-body">
                <form action="{{ common.info.url_route }}attach/documents" class="dropzone" id="attach-file-upload">
                    <input type="hidden" name="id" value="{{ result.id }}">
                    <input type="hidden" name="type" value="expense">
                    <input type="hidden" name="_token" value="{{ common.token }}">
                </form>
            </div>
        </div>
    </div>
</div>
{{ include('common/footer.twig') }}