

<?php $__env->startSection('title'); ?> Item | Edit <?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="content d-flex flex-column flex-column-fluid" id="kt_content">
    <div class="d-flex flex-column-fluid pb-20">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <form id="form_item">
                        <div class="form-group row">
                            <label class="col-lg-2 col-form-label text-right">Trade :</label>
                            <div class="col-lg-9">
                                <select id="trade" class="form-control selectpicker" multiple data-live-search="true" data-size="4">
                                    <option data-tokens="-">-</option>
                                <?php $__currentLoopData = $trades; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $trade): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($trade->id); ?>" data-tokens="<?php echo e($trade->id); ?>" <?php echo e($trade->id == $item_details[0]->trade_id ? 'selected' : ''); ?> ><?php echo e($trade->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>        
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 col-form-label text-right">Item Name :</label>
                            <div class="col-lg-9">
                                <input class="form-control" type="text" name="item_name" value="<?php echo e($item_details[0]->name); ?>" />
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 col-form-label text-right">Item Description :</label>
                            <div class="col-lg-9">
                                <textarea class="form-control" type="text" rows="4" name="item_desc"><?php echo e($item_details[0]->description); ?></textarea>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 col-form-label text-right">Unit :</label>
                            <div class="col-lg-9">
                                <select id="item_unit" class="form-control selectpicker" data-live-search="true" data-size="4">
                                <?php $__currentLoopData = $measurements; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $measurement): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option data-tokens="<?php echo e($measurement->name); ?>" <?php echo e($measurement->name == $item_details[0]->unit ? 'selected' : ''); ?>><?php echo e($measurement->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>                                   
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 col-form-label text-right">Upload Image :</label>
                            <div class="col-lg-9">
                                <div></div>
                                <div class="custom-file">
                                    <input type="file" class="custom-file-input" id="item_image"/>
                                    <label class="custom-file-label" for="item_image">Choose file</label>
                                </div>
                                <?php
                                    $img = $item_details[0]->img;
                                ?>
                               
                                <div class="img_preview mt-5">
                                    <?php if($img != ""): ?>                           
                                    <div class="img_item" data-file="<?php echo e($img); ?>">
                                        <a href="#img1">
                                            <div class="thumb_img" style="background-image: url(<?php echo e(asset('images')); ?>/<?php echo e($company_id); ?>/<?php echo e($img); ?>);"></div>
                                        </a>
                                        <a href="#" class="delete_img" data-toggle="modal" data-file="<?php echo e($img); ?>" data-target="#ConfirmDelete" data-id="<?php echo e($item_details[0]->id); ?>"><i class="fas fa-times"></i></a>
                                        <a href="#" class="lightbox" id="img1">
                                            <span style="background-image: url(<?php echo e(asset('images')); ?>/<?php echo e($company_id); ?>/<?php echo e($img); ?>)"></span>
                                        </a>
                                    </div>  
                                    <?php endif; ?>                                 
                                </div>                               
                            </div>
                        </div>
                        
                    </form>
                    
                    <div class="row">
                        <div class="col-lg-12 text-center">
                            <a href="#" class="btn btn-primary font-weight-bolder btnSaveItem" data-id="<?php echo e($item_details[0]->id); ?>">Save</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
			
<?php $__env->stopSection(); ?>

<?php $__env->startSection('custom_js'); ?>
<script src="<?php echo e(asset('js/material.js')); ?>"></script>
<script>
    const ui = {
        confirm: async (message) => createConfirm(message)
    }

    const createConfirm = (message) => {
        return new Promise((complete, failed)=>{
            $('#confirmMessage').text(message)

            $('#confirmYes').off('click');
            $('#confirmNo').off('click');
            
            $('#confirmYes').on('click', ()=> { $('.confirm').hide(); complete(true); });
            $('#confirmNo').on('click', ()=> { $('.confirm').hide(); complete(false); });
            
            $('.confirm').show();
        });
    }
                        
    const save = async () => {
        const confirm = await ui.confirm('Are you sure to update the user?');
        
        if(confirm){
            alert('yes clicked');
        } else{
            alert('no clicked');
        }
    }
</script>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/stagedo/public_html/inventory/resources/views/material/edit_item.blade.php ENDPATH**/ ?>