<form method="post" action="<?php echo e(request()->url()); ?>" id="input_form">
	<?php echo csrf_field(); ?>
    <div class="row">
        <?php if($target->id == null): ?>
       <div class="form-group col-lg-12">
            <label>Pengguna <text class="text-danger">*</text></label>
            <select class="form-control" name="user_id" data-toggle="select2">
                <option value="" selected>Pilih...</option>
                <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($item->id); ?>" <?php echo e(old('user_id') ? (old('user_id') == $item->id ? 'selected' : '') : ($target->user_id == $item->id ? 'selected' : '')); ?>><?php echo e($item->username.' ('.$item->full_name.')'); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <small class="text-danger user_id_error"></small>
        </div>
        <?php else: ?>
        <div class="form-group col-lg-12">
            <label>Pengguna <text class="text-danger">*</text></label>
            <select class="form-control" name="user_id" data-toggle="select2">
                <option value="" selected>Pilih...</option>
                <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($item->id); ?>" <?php echo e(old('user_id') ? (old('user_id') == $item->id ? 'selected' : '') : ($target->user_id == $item->id ? 'selected' : '')); ?>><?php echo e($item->username.' ('.$item->full_name.')'); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <small class="text-danger user_id_error"></small>
        </div>
        <?php endif; ?>
        <div class="form-group col-lg-6">
            <label>Kategori <text class="text-danger">*</text></label>
            <select class="form-control" name="category_id" id="category_id" data-toggle="select2">
                <option value="" selected>Pilih...</option>
                <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if($item->category == true): ?>
                    <option value="<?php echo e($item->category->id); ?>" <?php echo e($target->id <> null ? ($target->service->category->id == $item->category->id ? 'selected' : '') : ''); ?>><?php echo e($item->category->name); ?></option>
                    <?php endif; ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <small class="text-danger category_id_error"></small>
        </div>
        <div class="form-group col-lg-6">
            <label>Layanan <text class="text-danger">*</text></label>
            <select class="form-control" name="service_id" id="service_id" data-toggle="select2">
                <option value="" selected>Pilih Kategori...</option>
                <?php $__currentLoopData = $services; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($item->id); ?>" <?php echo e($target->service_id <> null ? ($target->service_id == $item->id ? 'selected' : '') : ''); ?>><?php echo e($item->name.' (Rp '.number_format($item->price,0,',','.').'/K)'); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <small class="text-danger service_id_error"></small>
        </div>
    </div>
    <hr />
    <div class="row">
        <div class="form-group col-lg-6">
            <label>Harga/K <text class="text-danger">*</text></label>
            <input type="text" class="form-control autonumeric-currency" name="price" value="<?php echo e(old('price') ?? $target->price); ?>">
            <small class="text-danger price_error"></small>
        </div>
        <div class="form-group col-lg-6">
            <label>Keuntungan/K <text class="text-danger">*</text></label>
            <input type="text" class="form-control autonumeric-currency" name="profit" value="<?php echo e(old('profit') ?? $target->profit); ?>">
            <small class="text-danger profit_error"></small>
        </div>
    </div>
    <hr />
    <div class="text-right">
        <button type="reset" class="btn btn-danger"><i class="fa fa-redo"></i> Reset</button>
        <button type="submit" class="btn btn-success"><i class="fa fa-check"></i> Submit</button>
    </div>
</form>
<script src="<?php echo e(asset('assets/js/modal-form.js')); ?>"></script>
<script src="<?php echo e(asset('assets/js/app.js')); ?>"></script>
<script>
    // $('[data-toggle="select2-multiple"]').select2();
    $(document).ready(function() {
        $('#category_id').on('change', function() {
			var category_id = $('#category_id').val();
			$.ajax({
				type: "GET",
				url: "<?php echo e(url('ajax/service/list')); ?>",
				data: {
					type    : 'general',
					category: $('#category_id').val(),
				},
				dataType: "json",
				success: function(result) {
					$('#service_id').html(result.data);
				}, error: function() {
					swal.fire("Gagal!", "Terjadi kesalahan.", "error");
				}
			});
		});
        $('.autonumeric-currency').autoNumeric('init', {
            mDec  : '0',
            aSep  : '.',
            aDec  : ',',
            aSign : 'Rp ',
        });
        $('.autonumeric-quantity').autoNumeric('init', {
            mDec  : '0',
            aSep  : '.',
            aDec  : ',',
            aSign : '# ',
        });
    });
</script><?php /**PATH /home/glor5228/public_html/resources/views/admin/service/custom_price/form.blade.php ENDPATH**/ ?>