


<?php $__env->startSection('title'); ?>
    Select Project
<?php $__env->stopSection(); ?>

<?php $__env->startSection('breadcrumb'); ?>
    <ol class="breadcrumb pull-right">
        <li><a href="<?php echo e(route('home')); ?>"><i class="fa fa-dashboard"></i> Home</a></li>
     
        <li class="active">Project before Inventory</li>
    </ol>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>


<div class="container-fluid">

  
       
 
    <!--.row-->
    <div id='updatecontent' style='margin-top:50px'>

        <div id="toaster"></div>
        
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('isSuperAdmin')): ?>
     
        <div class="row">
        
            
            <div class="col-md-12">
                <?php if($errors->any()): ?>
                    <div class="white-box">
                        <h2>Errors</h2>
                        <ul>
                            <?php echo implode('', $errors->all('<li><span class="help-block"><strong>:message</strong></span></li>')); ?>

                        </ul>
                    </div>
                <?php endif; ?>
                <div class="white-box">

                    <h3 class="box-title m-b-0"><i class="fa fa-dashboard"></i> Select Any Project</h3>
                    <p class="text-muted m-b-30 font-13">Select a project before add a new inventory </p>
                    <form class="form-horizontal" action="<?php echo e(route('inventory.add')); ?>" method="GET">
                        <?php echo e(csrf_field()); ?>

                        
                        
                       

                       

                        <div class="form-group">
                            <label for="address" class="col-sm-2 control-label" id="pro">Select Project</label>
                            <div class="col-sm-4">
                                <div class="input-group">
                                    <div class="input-group-addon"><i class="fa fa-circle-o"></i></div>
                                    <select id="multipro" class="form-control chosen-select" name="multipro_id">
                                        <option value=""><b>None</b></option>
                                        <?php $__currentLoopData = $multi_projects; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pro): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php
                                       $p_id= encrypt($pro->id); 
                                        ?>
                                            <?php if(old('multipro_id') == $p_id): ?>
                                                <option selected="" value="<?php echo e($p_id); ?>"><?php echo e($pro->name); ?>

                                                </option>
                                            <?php else: ?>
                                                <option value="<?php echo e($p_id); ?>"><?php echo e($pro->name); ?> </option>
                                            <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        
                                    </select>
                                    <?php if($errors->has('multipro_id')): ?>
                                        <span class="help-block">
                                            <strong><?php echo e($errors->first('multipro_id')); ?></strong>
                                        </span>
                                    <?php endif; ?>
                                </div>
                            </div>


                        </div>


                      



                      


                     

                        <div class="form-group">
                            <div class="col-sm-2">&nbsp;</div>
                            <div class=" col-sm-4">
                                <button type="submit" class="btn btn-info waves-effect waves-light "
                                    >Submit</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <?php endif; ?>

    </div>
    <!--./row-->
</div>
    <!-- /.container-fluid -->

<?php $__env->stopSection(); ?>


<?php $__env->startSection('js'); ?>

    <script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/jquery.inputmask.bundle.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>



    <script>
          function check_post(self) {

 
if ($(self).val() == 1) { //unallocated portion
    $('#parent_div').hide()
    $('#category_portion').hide();
    $('#inventory_type').html('Inventory Id')

    var data = {
        'type': $(self).val()
    };
    $('#unit_floor_id').html('<option selected value=""></option>');


    // $.get('/getNillFloor', data, function(data) {

    // $('#unit_floor_id').html('<option selected value="' + data.output.id + '">' + data.output.name +
    // '</option>');

    // // $(".chosen-select").val(data.output.id).trigger("chosen:updated");
    // }, 'json');



} else {

    $('#parent_div').show()
    $('#category_portion').show();
    $('#inventory_type').html('Unit No')

    var data = {
        'type': $(self).val()
    };

    $.get('/getNillFloor', data, function(data) {

        $option = '<option selected value="0">none</option>';

        $.each(data.output, function(index, val) {
            $option += '<option value="' + val.id + '">' + val.name + '</option>';
        });
        $('#unit_floor_id').html($option);
        $(".chosen-select").val(0).trigger("chosen:updated");
    }, 'json');
}
}

        

        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('isSuperAdmin')): ?>
        async function updateStatus(value) {
            $('.preloader').fadeIn();

            if (value === 'search') {
                $('.preloader').fadeOut();
                return false;
            }

            if (value == "") {
                $('.preloader').fadeOut();
                return false;
            }

            var data = {
                'multipro_id': value,
            };

          

            try {
                const response = await new Promise((resolve, reject) => {
                    $.get('<?php echo e(route('inventory.add')); ?>', data, function(data) {
                        resolve(data);
                    }).fail(function(xhr, status, error) {
                        reject(error);
                    });
                });

                $('.preloader').fadeOut();

                await new Promise(resolve => {
                    document.getElementById('updatecontent').innerHTML = response;
                    $('.chosen-select').trigger('chosen:updated');
                    $('.chosen-select').chosen({
                        // configuration options for the chosen select box
                    });
                    resolve();
                });

                await callItBack();
                $('#set_multipro_id').val(value);
                var successAlert = $('<div class="alert alert-success alert-dismissible">' +
                                '<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>' +
                                '<strong>Success!</strong> Form updated successfully!.' +
                            '</div>');
        $('#toaster').append(successAlert);
               


            } catch (error) {
                // Handle error if the request fails
                console.error(error);
            }

            $('.preloader').fadeOut();
        }
        <?php endif; ?>
    </script>


<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/proje372/akram-city.projecterp.net/resources/views/inventory/before-add-inventory-admin-form.blade.php ENDPATH**/ ?>