<?php echo $__env->make('admin.layouts.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php echo $__env->make('admin.layouts.sidebar', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<style>
    table{
        width: 100%;
        font-family: Arial;
    }
    .emi-form > thead > tr > th{
        font-weight: 600 !important;
    }
    h4.panel-title > a{
        font-size: 14px;
        color: #5f5a5a !important;
    }
    .panel-group{
        border-color: #e4e1e1;
        border-style: solid;
        border-width: 1px;
        margin-bottom: 20px;
    }
    .panel-heading{
        background-color: #f9f9f9;
        padding: 3px 3px 3px 15px;
    }
    label{
        font-family: sans-serif;
    }
    .lead_1{
        color: #1c7531;
    }
    .lead_2{
        color: #4e4eb9;
    }
    .lead_3{
        color: #0a6aa1;
    }
    .lead_4{
        color: #0b2a41;
    }
    .lead_5{
        color: #0d2366;
    }
    .lead_6{
        color: #0b2a41;
    }
    .lead_7{
        color: #0e4377;
    }
    .lead_8{
        color: #0f6674;
    }
    #datatable-list-view-leads_filter{
        float: right;
    }
    ul.pagination{
        float: right;
    }
    .ad-cm-pt-p > button{
        left: 27px !important;
    }
    .popover-body > ul > li {
        list-style: none;
        cursor: pointer;
        border-bottom-style: solid;
        border-bottom-color: #c5bbbb;
        border-bottom-width: 1px;
        padding: 6px;
    }
    .popover-body > ul {
        padding: 0;
    }
</style>
<div class="m-grid__item m-grid__item--fluid m-wrapper">
    <!-- BEGIN: Subheader -->
    <div class="m-subheader ">
        <div class="d-flex align-items-center">
            <div class="mr-auto">
                <h3 class="m-subheader__title m-subheader__title--separator">
                    Vendor
                </h3>
            </div>

        </div>
    </div>
<?php setlocale(LC_MONETARY, 'en_IN.UTF-8'); ?>
<!-- END: Subheader -->
    <div class="m-content">
        <?php if(Session::has('success')): ?>
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"></button>
                <?php echo e(Session::get('success')); ?>

            </div>
        <?php endif; ?>
        <?php if(Session::has('error')): ?>
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"></button>
                <?php echo e(Session::get('error')); ?>

            </div>
        <?php endif; ?>
        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__head" style="position: relative;">
                <div class="m-portlet__head-caption">
                    <div class="m-portlet__head-title">
                        <span class="m-portlet__head-icon">
                            <i class="fa fa-file-text-o"></i>
                        </span>
                        <h3 class="m-portlet__head-text">
                            Vendor
                        </h3>
                    </div>
                </div>
            </div>
            <div class="m-portlet__body">
                <div class="m-section">
                    <div class="m-section__content">
                        <div>
                            <div class="row">
                                <div class="col-md-12">
                                    <form action="/admin/vendor/add" method="post" id="v-form" enctype="multipart/form-data">
                                        <input name="_token" value="<?php echo csrf_token(); ?>" hidden>
                                        <input name="vendor_id" value="<?php echo $vendor->id ?? 0; ?>" hidden>
                                    <div class="col-md-12">
                                        <div class="form-group row">
                                            <label for="business" class="col-sm-2 col-form-label">Name <span style="color: red;">*</span></label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control" id="name" name="name" value="<?php echo $vendor->name ?? ''; ?>" placeholder="Vendor Name" required="required"/>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <div class="form-group row">
                                            <label for="business" class="col-sm-2 col-form-label">Merchant <span style="color: red;">*</span> </label>
                                            <div class="col-md-8">
                                                <select class="form-control m-input selectpicker" name="merchant_id[]" data-live-search="true" required multiple>
                                                    <option value="" disabled> Select Merchant </option>
                                                    <?php $merchantArr = array();
                                                        $merchantName = array(); ?>
                                                    <?php // xdebug_break(); ?>
                                                    <?php $__currentLoopData = $merchants; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $merchant): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <?php
                                                            $vendors = explode(',', isset($vendor->merchant_id) ? $vendor->merchant_id : '');
                                                            if (in_array($merchant->id, $vendors)) {
                                                                array_push($merchantArr, $merchant->id);
                                                                array_push($merchantName, $merchant->merchant_name);
                                                            }
                                                        ?>
                                                        <option value="<?php echo e($merchant->id); ?>" <?php if(isset($vendor->merchant_id) && in_array($merchant->id, $vendors)): ?> selected="selected" <?php endif; ?> ><?php echo e($merchant->merchant_name); ?></option>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <div class="form-group row">
                                            <label for="business" class="col-sm-2 col-form-label">Status <span style="color: red;">*</span></label>
                                            <div class="col-sm-8">
                                                <select class="form-control" name="status">
                                                    <option value="0" <?php echo isset($vendor->status) && $vendor->status == 0 ? 'selected="selected"' : ''; ?>>Inactive</option>
                                                    <option value="1" <?php echo isset($vendor->status) && $vendor->status == 1 ? 'selected="selected"' : ''; ?>>Active</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <div class="form-group row">
                                        <label class="col-sm-2 col-form-label"> Logo: </label>
                                        <div class="col-lg-6">
                                            <input type="file" class="form-control m-input" name="logo">
                                            <?php if(isset($vendor->logo)): ?>
                                                <img style="width: 50px;" src="<?php echo isset($vendor->logo) ? $vendor->logo : ''; ?>"/>
                                            <?php endif; ?>
                                        </div>
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <div class="form-group row">
                                            <label for="business" class="col-sm-2 col-form-label"></label>
                                            <div class="col-sm-8">
                                                <button class="btn btn-primary">
                                                    <?php echo isset($vendor->name) ? 'Update' : 'Add'; ?> Vendor
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php echo $__env->make('admin.modal.modals', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php echo $__env->make("admin.layouts.footer", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js"></script>
