@extends('dealer_layouts.dealer_master')
@section('page-title') 
    Dealer | Merchants
@endsection
@section('page-content')
@include('organisation.partials.create_merchant')
@include('organisation.partials.top_up_merchant_by_id')
<div class="row">
<div class="col-md-12">
        <div class="hpanel hblue">
            <div class="panel-heading hbuilt text-info">
                Sales to Merchants
                
                <buton class="btn btn-success btn-xs mb-2 pull-right" id="addNewMerchant"><i class="fa fa-plus"></i> Add Merchant</button>
                <input type="hidden" class="orgRowId" value="{{ $org_user['org_id'] }}">
                <div class="clearfix"></div>
            </div>
            <div class="panel-body">
                <div>
                    @include('commons.notifications')
                    <div class="clearfix"></div>
                </div>
                
                <div class="table-responsive">
                <table cellpadding="1" cellspacing="1" class="table table-bordered table-striped">
                    <thead>
                    <tr class="bg-info">
                        <th>Name</th>
                        <th>Phone</th>
                        <th>Language</th>
                        <th>Balance</th>
                        <th>Status</th>
                        <th>Registration Date</th>
                        <th>Action</th>
                    </tr>
                    </thead>
                    <tbody>
                    @forelse ($merchants as $row)
                    <tr>
                        <td>{{ $row->fullname }}</td>
                        <td>{{ $row->phone }}</td>
                        <td>{{ ucfirst($row->language) }}</td>
                        <td>{{ number_format($row->balance) }}</td>
                        <td class="<?php echo ($row->status == 'inactive') ? 'bg-warning' : 'bg-success'; ?>">{{ ucfirst($row->status) }}</td>
                        <td>{{ $row->created_at }}</td>
                        <td>
                            <input type="hidden" class="orgRowId" value="{{ $row->id }}">
                            <button type="button" class="btn btn-success btn-xs topUpMerchantBtn" ><i class="fa fa-plus"></i> Top Up</button>
                            <a href="{{ route('merchant.show', $row->id) }}" class="btn btn-primary btn-xs"><i class="fa fa-eye"></i> View</a>
                            <a href="{{ route('merchant.edit', $row->id) }}" class="btn btn-info btn-xs"><i class="fa fa-edit"></i> Edit</a>
                            <!-- <a href="{{ route('merchant.destroy', $row->id) }}" class="btn btn-danger btn-xs" onclick="return confirm('Are you sure you want to delete this merchant?')"><i class="fa fa-ban"></i> Disable</a> -->
                        </td>
                    </tr>
                    @empty
                        <tr>                      
                            <td colspan="7">No Data</td>
                        </tr>
                    @endforelse
                    </tbody>
                </table>
                </div>
                {{ $merchants->links() }}
            </div>
            <div class="panel-footer">
            Page : {{ $merchants->currentPage() }} of {{ $merchants->lastPage() }} |
            Total Records : <span id="totalRecords">{{ $merchants->total() }}</span>
            </div>
        </div>
    </div>
</div>
@endsection
@section('page-js')
 <script src="{{ url('public/js/dealer_landing.js') }}"></script>
<script>
    $(document).ready(function() {
    

});

</script>

@endsection
