@extends('admin.template.master')
@section('content')
<!-- Nav tabs -->
<ul class="nav nav-tabs nav-tabs-custom nav-justified" role="tablist">
    <li class="nav-item">
        <a class="nav-link active" data-toggle="tab" href="#add-new" role="tab">
            <span class="d-block d-sm-none"><i class="fas fa-home"></i></span>
            <span class="d-none d-sm-block"> {{__('messages.add_new')}}</span> 
        </a>
    </li>
    <li class="nav-item">
        <a class="nav-link" data-toggle="tab" href="#view-all" role="tab">
            <span class="d-block d-sm-none"><i class="far fa-user"></i></span>
            <span class="d-none d-sm-block"> {{__('messages.view_all')}}</span> 
        </a>
    </li>
</ul>

<!-- Tab panes -->
<div class="tab-content p-3 text-muted">
    <div class="tab-pane active" id="add-new" role="tabpanel">
        <div class="row">
            <div class="form-group col-md-2">
                <label>{{__('messages.date')}}</label>
                <input type="text" name="purchase_date" id="purchase_date"
                    class="form-control datepickr" placeholder="Date" readonly />
            </div>
            <div class="form-group col-md-2">
                <label>{{__('messages.advance')}}</label>
                <input type="text" name="prd_advance" id="prd_advance" class="form-control isnumber"
                    placeholder="ADVANCE" />
            </div>
            <div class="form-group col-md-2">
                <label>{{__('messages.payment_type')}}</label>
                <select class="form-control" name="prd_ptype" id="prd_ptype">
                    <option value="" selected> {{__('messages.choose')}} </option>
                    <option value="cash"> {{__('messages.cash')}} </option>
                    <option value="cheque"> {{__('messages.cheque')}} </option>
                    <option value="card"> {{__('messages.card')}} </option>
                </select>
            </div>
            <div class="form-group col-md-3">
                <label>{{__('messages.cheque')}} #</label>
                <input type="text" name="prd_cheque" id="prd_cheque" class="form-control"
                    placeholder="Cheque Number" />
            </div>
            <div class="form-group col-md-3">
                <label>&nbsp;</label>
                <button type="button" id="btn-process-items" class="btn btn-block btn-danger"><i
                        class="fa fa-check"></i> {{__('messages.process_checkout')}} </button>
            </div>
            <input type="hidden" name="subtotal" id="subtotal">

        </div>
        <hr>
        <div class="row">
            <div class="form-group col-md-3">
                <label>{{__('messages.supplier')}}</label>
                <input type="hidden" name="spl_hid" id="spl_hid">
                <select name="prd_spl" id="prd_spl" class="form-control">
                    <option value="" selected> {{__('messages.choose')}}</option>
                    @foreach ($suppliers as $spl)
                        <option value="{{ $spl->spl_id }}">{{ $spl->spl_name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group col-md-2">
                <label>{{__('messages.name')}}/{{__('messages.barcode')}}</label>
                <input type="text" name="prd_stk" id="prd_stk" class="form-control"
                    placeholder="" />
            </div>
            <div class="form-group col-md-2">
                <label>{{__('messages.quantity')}} <span id="prd_stk_unit"></span></label>
                <input type="text" name="prd_stk_qty" id="prd_stk_qty" class="form-control isnumber"
                    placeholder="" />
            </div>
            <div class="form-group col-md-2">
                <label>{{__('messages.price')}} </label>
                <input type="text" name="prd_price" id="prd_price" class="form-control isnumber"
                    placeholder="" />
            </div>
            <div class="form-group col-md-3">
                <label>&nbsp;</label>
                <button type="button" id="btn-add-prd-stk-atl" class="btn btn-block btn-primary"><i
                        class="fa fa-plus"></i> </button>
            </div>
        </div>

        <div class="row">
            <div class="form-group col-md-12">
                <label> {{__('messages.notes')}} </label>
                <textarea class="form-control" id="pnotes"></textarea>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <table id=""
                    class="table table-striped table-bordered dt-responsive nowrap sr" cellspacing="0"
                    width="100%">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>{{__('messages.name')}}-{{__('messages.barcode')}}</th>
                            <th>{{__('messages.quantity')}}</th>
                            <th>{{__('messages.unit_price')}}</th>
                            <th>{{__('messages.total_price')}}</th>
                            <th>{{__('messages.remove')}}</th>
                        </tr>
                    </thead>
                    <tbody id="prd_stk_tbody">

                    </tbody>
                    <tfoot>
                        <tr>
                            <th colspan="4">{{__('messages.total')}}</th>
                            <th id="sub_total"></th>
                            <th>&nbsp;</th>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
    <div class="tab-pane" id="view-all" role="tabpanel">
        <div class="row">
            <div class="col-md-12">
                <div class="table-responsive">
                    <table id="purchaseTable"
                        class="table table-striped table-bordered dt-responsive nowrap"
                        style="width:100%;">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>{{__('messages.invoice')}} #</th>
                                <th>{{__('messages.supplier')}}</th>
                                <th>{{__('messages.total')}}</th>
                                <th>{{__('messages.date/time')}} </th>
                                <th>{{__('messages.actions')}}</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>   
       
<div id="pinvoice-details" class="modal fade" role="dialog">
    <div class="modal-dialog modal-lg">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">{{__('messages.invoice')}} : <span id="invoice_number"></span></h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body" id="pinvoice-mbody">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">{{__('messages.close')}}</button>
            </div>
        </div>
    </div>
</div>

<div id="purchase-edit-modal" class="modal fade" role="dialog">
    <div class="modal-dialog modal-lg">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">{{__('messages.invoice')}} : <span id="pedit_invoice_number"></span></h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body" id="pedit-mbody">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="btn-update-purchase">{{__('messages.save_changes')}}</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">{{__('messages.close')}}</button>
            </div>
        </div>
    </div>
</div>
    
@endsection
@section('customjs')
    <script src="{{ asset('custom_js/purchases.js') }}"></script>
@endsection
