
<?php $__env->startSection('content'); ?>
    <!-- begin::main content -->
    <style>
        textarea {
            min-height: 30px !important;
        }
        .form-control, .swal-modal input.swal-content__input {
            height: 43px !important;
        }
        .btn.btn-add, .btn.btn-add-payment {
            padding-left: 2.8571428571em;
            background-repeat: no-repeat;
            background-position: 1.4285714286em center;
        }
        input {
            border: 1px solid #c6d9e0 !important;
        }
        .search-btn {
            position: relative;
            right: 31px;
            top: 1px;
            color: #bdbdbd;
        }
        label {
            display: block;
            font-size: 13px;
            line-height: 1.3846153846em;
            color: #526069;
            margin-bottom: 0.7692307692em;
            user-select: none;
            cursor: pointer;
            font-weight: 500;
            width: 10.7692307692em;
        }
        .search-card {
            width:100%;
            border:none;
        }
        .tab {
            display: inline-block;
            padding: 16px 12px;
            cursor: pointer;
            background-color: #E6EAED;
            margin-right: -4px;
        }
        .tab.active {
            background-color: white;
        }
        .tab-content {
            padding: 20px;
            border-radius: 0 0 5px 5px;
            display: none;
        }
        .tab-content.active {
            display: block;
        }
        /* Add new styles for inline fields */
        .inline-field-group {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        .inline-field {
            flex: 1;
        }
        .add-new-btn {
            margin-top: 28px;
        }
    </style>

    <main class="main-content">
        <div class="container">
            <!-- begin::page header -->
            <div class="page-header">
                <h3><?php echo e(__('message.edit')); ?> Item</h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="<?php echo e(asset('dashboard')); ?>"><?php echo e(__('message.dashboard')); ?></a></li>
                        <li class="breadcrumb-item"><a href="<?php echo e(asset('account/item')); ?>">Items</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo e(__('message.edit')); ?></li>
                    </ol>
                </nav>
            </div>
            <!-- end::page header -->

            <div class="row">
                <div class="col-md-12">
                    <?php if (isset($component)) { $__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74 = $component; } ?>
<?php $component = $__env->getContainer()->make(App\View\Components\FlashMessage::class, []); ?>
<?php $component->withName('flashMessage'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74)): ?>
<?php $component = $__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74; ?>
<?php unset($__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74); ?>
<?php endif; ?>
                    
                    <div class="card">
                        <div class="card-body py-0">
                            <div class="bg-white">
                                <form action="<?php echo e(asset('account/add-item')); ?>" method="post" enctype="multipart/form-data">
                                <?php echo csrf_field(); ?>
                                <div class="row p-5">
                                    <div class="col-md-6" style="border-right: 1px solid #e5e5e5;">
                                        <div class="card-body">
                                            
                                                <input type="hidden" name="item_id" value="<?php echo e($item->id); ?>">
                                                <!-- Item Name -->
                                                <div class="form-group mb-3 d-flex align-items-center">
                                                    <label class="me-3">Type</label>
                                                    <div class="d-flex justify-content-between w-100 align-items-center">
                                                        <div class="form-check">
                                                            <input type="radio" id="type_goods" name="type" class="form-check-input" value="goods" <?php echo e($item->type=="goods" ? "checked" : ""); ?>>
                                                            <label class="form-check-label pt-1" for="type_goods">Goods</label>
                                                        </div>
                                                        <div class="form-check">
                                                            <input type="radio" id="type_service" name="type" class="form-check-input" value="service" <?php echo e($item->type=="service" ? "checked" : ""); ?>>
                                                            <label class="form-check-label pt-1" for="type_service">Service</label>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group d-flex align-items-center">
                                                    <label for="item_name">Item Name</label>
                                                    <input type="text" class="form-control" id="item_name" name="name" required value="<?php echo e($item->name); ?>">
                                                </div>
                                                <?php $__errorArgs = ['item_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                    <div class="d-flex justify-content-end px-3 text-danger">
                                                        <p><?php echo e($message); ?></p>
                                                    </div>
                                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>

                                                <!-- Item Code/SKU -->
                                                <div class="form-group d-flex align-items-center">
                                                    <label for="item_code">Item Code/SKU</label>
                                                    <input type="text" class="form-control" id="item_code" name="item_code" value="<?php echo e($item->item_code); ?>">
                                                </div>

                                                <!-- Category Selection with Add New Option -->
                                                <div class="form-group d-flex align-items-center">
                                                    <label for="category_id">Category</label>
                                                    <div class="inline-field-group" style="width: 100%;">
                                                        <div class="inline-field">
                                                            <select name="category_id" id="category_id" class="form-control select2" >
                                                                <option value="" disabled selected>Select Category</option>
                                                                <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                    <option value="<?php echo e($category->id); ?>" <?php echo e($item->category_id == $category->id ? "selected" : ""); ?>><?php echo e($category->name); ?></option>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                            </select>
                                                        </div>
                                                        <button type="button" class="btn btn-primary add-new-btn mt-0" data-toggle="modal" data-target="#addCategoryModal">
                                                            <i class="ti ti-plus"></i>
                                                        </button>
                                                    </div>
                                                </div>
                                                <?php $__errorArgs = ['category_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                    <div class="d-flex justify-content-end px-3 text-danger">
                                                        <p><?php echo e($message); ?></p>
                                                    </div>
                                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>

                                                <!-- Unit of Measure with Add New Option -->
                                                <div class="form-group d-flex align-items-center">
                                                    <label for="unit_id">Unit of Measure</label>
                                                    <div class="inline-field-group" style="width: 100%;">
                                                        <div class="inline-field">
                                                            <select name="unit_id" id="unit_id" class="form-control select2" required>
                                                                <option value="" disabled selected>Select Unit</option>
                                                                <?php $__currentLoopData = $units; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $unit): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                    <option value="<?php echo e($unit->id); ?>" <?php echo e($item->unit_id == $unit->id ? "selected" : ""); ?>><?php echo e($unit->name); ?> (<?php echo e($unit->short_name); ?>)</option>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                                                               
                                                            </select>

                                                        </div>
                                                        <button type="button" class="btn btn-primary mt-0 add-new-btn" data-toggle="modal" data-target="#addUnitModal">
                                                            <i class="ti ti-plus"></i>
                                                        </button>
                                                        
                                                    </div>
                                                    
                                                </div>
                                                <?php $__errorArgs = ['unit_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                                    <div class="d-flex justify-content-end px-3 text-danger">
                                                        <p><?php echo e($message); ?></p>
                                                    </div>
                                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>

                                                <div class="form-group d-flex align-items-center">
                                                    <label for="quantity">Opening Quantity</label>
                                                    <input type="number" class="form-control" id="quantity" name="quantity"  value="<?php echo e($item->quantity); ?>">
                                                </div>

                                                <!-- Description -->
                                                <div class="form-group d-flex align-items-center">
                                                    <label for="description">Description</label>
                                                    <textarea rows="3" name="description" class="w-100 border px-2"><?php echo e($item->description); ?></textarea>
                                                </div>

                                        </div>
                                    </div>
                                    
                                    <div class="col-md-6 py-4">
                                        <!-- Additional fields can be added here -->
                                        <div class="form-group d-flex align-items-center">
                                            <label for="unit_id">Tax (%)</label>
                                            <div class="inline-field-group" style="width: 100%;">
                                                <div class="inline-field">
                                                    <select name="tax" id="tax" class="form-control select2" required>
                                                        <option value="" disabled selected>Select</option>  
                                                        <?php $__currentLoopData = $taxes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tax): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>                                                      
                                                        <option value="<?php echo e($tax->id); ?>" <?php echo e($item->tax == $tax->id ? 'selected' : ''); ?>><?php echo e($tax->tax); ?>%</option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                                                                 
                                                    </select>

                                                </div>
                                                
                                            </div>
                                            
                                        </div>

                                        <?php $__errorArgs = ['tax'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <div class="d-flex justify-content-end px-3 text-danger">
                                                <p><?php echo e($message); ?></p>
                                            </div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                        <h5>Sales Info</h5>
                                        <div class="row">
                                            <div class="form-group col-md-6 d-flex align-items-center">
                                                <label for="unit_id">Unit Price</label>
                                                <div class="inline-field-group" style="width: 100%;">
                                                    <div class="inline-field">
                                                        <input type="text" name="sales_unit_price" class="form-control " value="<?php echo e($item->sales_unit_price); ?>">                                                       
                    

                                                    </div>
                                                    
                                                </div>
                                                
                                            </div>
                                            <div class="form-group col-md-6 d-flex align-items-center">
                                                <label for="unit_id">Currency</label>
                                                <div class="inline-field-group" style="width: 100%;">
                                                    <div class="inline-field">
                                                        <select type="text" name="sales_currency" class="form-control " >                                                       
                                                            <option value="INR">INR</option>
                                                        </select>                                                       
                    

                                                    </div>
                                                    
                                                </div>
                                                
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="form-group col-md-6 d-flex align-items-center">
                                                <label for="unit_id">Cess %</label>
                                                <div class="inline-field-group" style="width: 100%;">
                                                    <div class="inline-field">
                                                        <input type="number" name="sales_cess_percentage" class="form-control " value="<?php echo e($item->sales_cess_percentage); ?>">                                                       
                    

                                                    </div>
                                                    
                                                </div>
                                                
                                            </div>
                                            <div class="form-group col-md-6 d-flex align-items-center">
                                                <label for="unit_id">Cess +</label>
                                                <div class="inline-field-group" style="width: 100%;">
                                                    <div class="inline-field">
                                                        <input type="number" name="sales_cess_plus" class="form-control " value="<?php echo e($item->sales_cess_plus); ?>">                                                       
                    

                                                    </div>
                                                    
                                                </div>
                                                
                                            </div>
                                        </div>

                                        <h5>Purchase Info</h5>
                                        <div class="row">
                                            <div class="form-group col-md-6 d-flex align-items-center">
                                                <label for="unit_id">Unit Price</label>
                                                <div class="inline-field-group" style="width: 100%;">
                                                    <div class="inline-field">
                                                        <input type="number" name="purchase_unit_price" class="form-control " value="<?php echo e($item->purchase_unit_price); ?>">                                                       
                    

                                                    </div>
                                                    
                                                </div>
                                                
                                            </div>
                                            <div class="form-group col-md-6 d-flex align-items-center">
                                                <label for="unit_id">Currency</label>
                                                <div class="inline-field-group" style="width: 100%;">
                                                    <div class="inline-field">
                                                        <select type="text" name="purchase_currency" class="form-control " >                                                       
                                                            <option value="INR">INR</option>
                                                        </select>

                                                    </div>
                                                    
                                                </div>
                                                
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="form-group col-md-6 d-flex align-items-center">
                                                <label for="unit_id">Cess %</label>
                                                <div class="inline-field-group" style="width: 100%;">
                                                    <div class="inline-field">
                                                        <input type="number" name="purchase_cess_percentage" class="form-control " value="<?php echo e($item->purchase_cess_percentage); ?>">                                                       
                    

                                                    </div>
                                                    
                                                </div>
                                                
                                            </div>
                                            <div class="form-group col-md-6 d-flex align-items-center">
                                                <label for="unit_id">Cess +</label>
                                                <div class="inline-field-group" style="width: 100%;">
                                                    <div class="inline-field">
                                                        <input type="number" name="purchase_cess_plus" class="form-control " value="<?php echo e($item->purchase_cess_plus); ?>">                                                       
                    

                                                    </div>
                                                    
                                                </div>
                                                
                                            </div>
                                        </div>
                                        
                                        <!-- Form Submission Buttons -->
                                        <div class="row bg-white py-4 w-100" style="position:fixed;bottom:0;left:266px">
                                            <div class="col-12 py-2 px-4">
                                                <button class="btn btn-success text-white mx-4" type="submit">
                                                    <i class="fa fa-check fa-lg"></i>&nbsp; SAVE
                                                </button>
                                                <button class="btn btn-primary" type="button">CANCEL</button>
                                            </div>
                                        </div>
                                        
                                    </div>
                                </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Add Category Modal -->
        <div class="modal fade" id="addCategoryModal" tabindex="-1" role="dialog" aria-labelledby="addCategoryModalLabel" aria-hidden="true">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="addCategoryModalLabel">Add New Category</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <form id="addCategoryForm" action="<?php echo e(asset('account/add-category')); ?>" method="POST">
                        <?php echo csrf_field(); ?>
                        <div class="modal-body">
                            <div class="form-group">
                                <label for="category_name">Category Name</label>
                                <input type="text" class="form-control"  name="name" required>
                            </div>
                            <div class="form-group">
                                <label for="category_description">Description</label>
                                <textarea class="form-control" name="description" rows="3"></textarea>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                            <button type="submit" class="btn btn-primary">Save Category</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <!-- Add Unit Modal -->
        <div class="modal fade" id="addUnitModal" tabindex="-1" role="dialog" aria-labelledby="addUnitModalLabel" aria-hidden="true">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="addUnitModalLabel">Add New Unit of Measure</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <form id="addUnitForm" action="<?php echo e(asset('account/add-unit')); ?>" method="POST">
                        <?php echo csrf_field(); ?>
                        <div class="modal-body">
                            <div class="form-group">
                                <label for="unit_name">Unit Name</label>
                                <input type="text" class="form-control" id="unit_name" name="name" required>
                            </div>
                            <div class="form-group">
                                <label for="short_name">Short Name</label>
                                <input type="text" class="form-control" id="short_name" name="short_name" required>
                            </div>
                            <div class="form-group">
                                <label for="unit_description">Description</label>
                                <textarea class="form-control" id="unit_description" name="description" rows="3"></textarea>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                            <button type="submit" class="btn btn-primary">Save Unit</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

    </main>
    <!-- end::main content -->
<?php $__env->stopSection(); ?>

<?php $__env->startPush('footer-script'); ?>
    <!-- begin::select2 -->
    <link rel="stylesheet" href="<?php echo e(asset('public/admin/vendors/select2/css/select2.min.css')); ?>" type="text/css">
    <script src="<?php echo e(asset('public/admin/vendors/select2/js/select2.min.js')); ?>"></script>
    <!-- end::select2 -->
    
    <!-- Bootstrap Modal JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        $(document).ready(function() {
            // Initialize select2
            $('.select2').select2();
            
            
        });    
    </script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\account_admin\resources\views/accounting/item/edit.blade.php ENDPATH**/ ?>