/
home
/
sjslayjy
/
public_html
/
olddevlok
/
storage
/
framework
/
views
/
Upload File
HOME
<?php $__env->startSection('title','Product Allotments'); ?> <?php $__env->startSection('content'); ?> <div class="main-content"> <div class="main-content-inner"> <div class="breadcrumbs ace-save-state" id="breadcrumbs"> <ul class="breadcrumb"> <li> <i class="ace-icon fa fa-home home-icon"></i> <a href="#"><?php echo e(__('messages.Home')); ?></a> </li> <li class="active"><?php echo e(__('messages.Product')); ?> <?php echo e(__('messages.Allotment')); ?></li> </ul> </div> <div class="page-content"> <div class="page-header"> <h1> <?php echo e(__('messages.Rake')); ?> <?php echo e(__('messages.Product')); ?> <?php echo e(__('messages.Allotment')); ?> </h1> </div><!-- /.page-header --> <form action="" role="form" id="AllotProductForm"> <div class="panel panel-primary"> <div class="panel-heading"> <h3 class="panel-title"> <?php echo e(__('messages.Rake')); ?> <?php echo e(__('messages.Product')); ?> <?php echo e(__('messages.Allotment')); ?> </h3> </div> <div class="panel-body"> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label for="master_rake_id"> <?php echo e(__('messages.masterrake')); ?></label> <select class="form-control select2" name="master_rake_id" id="master_rake_id" onchange="getMasterRakeDetails(this.value)"> <option value=""><?php echo e(__('messages.SelectMasterRake')); ?></option> <?php $__currentLoopData = $master_rakes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $master_rake): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <option value="<?php echo e($master_rake->id); ?>"><?php echo e($master_rake->name); ?></option> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </select> <span class="label label-danger" id="add_master_rake_error" style="display: none;"></span> </div> </div> </div> <div class="row"> <div class="col-md-3"> <div class="form-group"> <label for="dealer_id"><?php echo e(__('messages.Dealer')); ?></label> <select class="form-control select2" name="dealer_id[]" id="dealer_id"> <option value=""> <?php echo e(__('messages.Dealer')); ?> <?php echo e(__('messages.Select')); ?></option> <?php $__currentLoopData = $dealers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dealer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <option value="<?php echo e($dealer->id); ?>"><?php echo e($dealer->name); ?>(<?php echo e($dealer->address1); ?>)</option> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </select> <span class="label label-danger" id="add_dealer_id_error" style="display: none;"></span> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="product_id_1"> <?php echo e(__('messages.Product')); ?></label> <select class="form-control checkIfValid select2" name="product_id[]" id="product_id_1"> <option value=""> <?php echo e(__('messages.Product')); ?> <?php echo e(__('messages.Select')); ?></option> </select> <span class="label label-danger" id="add_product_error" style="display: none;"></span> </div> </div> <div class="col-md-2"> <div class="form-group"> <label for="unit_id"> <?php echo e(__('messages.Unit')); ?></label> <select class="form-control checkIfValid select2" name="unit_id[]"> <option value=""> <?php echo e(__('messages.Unit')); ?> <?php echo e(__('messages.Select')); ?></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($unit->unit); ?></option> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </select> <span class="label label-danger" id="add_unit_error" style="display: none;"></span> </div> </div> <div class="col-md-2"> <div class="form-group"> <label for="quantity"> <?php echo e(__('messages.Alloted')); ?> <?php echo e(__('messages.Quantity')); ?></label> <input type="text" name="quantity[]" class="form-control checkIfValid"> <span class="label label-danger" id="add_quantity_error" style="display: none;"></span> </div> </div> </div> <div id="addMoreProductSection"> </div> <div class="pull-left"> <button type="button" id="addMoreProduct" class="btn btn-danger"><i class="fa fa-plus"></i> Add More </button> </div> <div class="pull-right"> <a href="<?php echo e(URL('/user/allot-product')); ?>" class="btn btn-default" >Reset</a> <button type="button" id="allotProductBtn" class="btn btn-primary">Submit</button> </div> </div> </div> </form> </div> </div><!-- /.page-content --> </div><!-- /.main-content --> <?php $__env->startSection('script'); ?> <?php echo e(Html::script("assets/js/ace-elements.min.js")); ?> <?php echo e(Html::script("assets/js/ace.min.js")); ?> <?php echo e(Html::script("assets/js/bootstrap-datepicker.min.js")); ?> <script type="text/javascript"> function getMasterRakeDetails(id){ if(id == ""){ swal('Error','Master Rake id is missing','warning'); }else{ $('.loading-bg').show(); $.ajax({ url: "<?php echo e(url('/get-master-rake-details/')); ?>"+"/"+id, type: 'GET', success:function(data){ console.log(data); $('.loading-bg').hide(); if(data.flag){ var company_option = "<option value='"+data.master_rake.product_company.id+"'>"+data.master_rake.product_company.name+"</option>" $('#product_company_id').html(company_option).trigger('change'); var product_option = "<option value=''>Select Product</option>"; $.each(data.master_rake.master_rake_products, function(i, value) { product_option += "<option value="+value.product_id+">"+value.product.name+"</option>"; }); console.log(product_option); $("select[name='product_id[]']").each(function() { $(this).html(product_option).trigger('change'); }); }else{ swal('Error',data.message,'warning'); } } }); } } $(document).ready(function() { $('#allotProductBtn').click(function(e){ e.preventDefault(); if(validateField()){ return false; }else{ $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') } }); $('.loading-bg').show(); $.ajax({ url: $('#AllotProductForm').attr('action'), method: 'POST', data: $('#AllotProductForm').serialize(), success: function(data){ $('.loading-bg').hide(); if(!data.flag){ showError('add_master_rake_error',data.errors.master_rake_id); showError('add_company_error',data.errors.company_id); showError('add_dealer_id_error',data.errors.dealer_id); showError('add_product_error',data.errors.product_id); showError('add_unit_error',data.errors.unit_id); showError('add_quantity_error',data.errors.quantity); }else{ swal({ title: "Success!", text: data.message, type: "success" }, function() { window.location.reload(); }); } } }); } }); $('#addMoreProduct').click(function(){ var product_count = $("select[name='product_id[]']").length+1; var product_option = $("#product_id_1").html(); var count = $('.row').length + 1; var newRow = `<div class="row" id="newRow`+count+`"> <div class="col-md-3"> <div class="form-group"> <label for="dealer_id"><?php echo e(__('messages.Dealer')); ?></label> <select class="form-control select2" name="dealer_id[]" id="dealer_id"> <option value=""><?php echo e(__('messages.Dealer')); ?> <?php echo e(__('messages.Select')); ?></option> <?php $__currentLoopData = $dealers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dealer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <option value="<?php echo e($dealer->id); ?>"><?php echo e($dealer->name); ?>(<?php echo e($dealer->address1); ?>)</option> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </select> <span class="label label-danger" id="add_dealer_id_error" style="display: none;"></span> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="product_id"><?php echo e(__('messages.Product')); ?></label> <select class="form-control checkIfValid select2" name="product_id[]" id="product_id_`+product_count+`"> `+product_option+` </select> <span class="label label-danger" id="add_product_error" style="display: none;"></span> </div> </div> <div class="col-md-2"> <div class="form-group"> <label for="unit_id"><?php echo e(__('messages.Unit')); ?></label> <select class="form-control checkIfValid select2" name="unit_id[]" > <option value="">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($unit->unit); ?></option> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </select> <span class="label label-danger" id="add_unit_error" style="display: none;"></span> </div> </div> <div class="col-md-2"> <div class="form-group"> <label for="quantity"><?php echo e(__('messages.Alloted')); ?> <?php echo e(__('messages.Quantity')); ?></label> <input type="text" name="quantity[]" class="form-control checkIfValid"> <span class="label label-danger" id="add_quantity_error" style="display: none;"></span> </div> </div> <div class="col-md-1" style="margin-top: 30px;"> <a href="javascript:;" onclick="removeRow(`+count+`)"><i class="fa fa-close fa-2x"></i></a> </div> </div> `; $('#addMoreProductSection').append(newRow); $('.select2').select2(); }); }); function validateField(){ var errorCount = 0; $('.checkIfValid').each(function(){ console.log($(this).val()); if($(this).val() == ""){ errorCount = errorCount + 1; $(this).closest('.form-group').find('.label-danger').text('Required'); $(this).closest('.form-group').find('.label-danger').show(); }else{ $(this).closest('.form-group').find('.label-danger').hide(); } }); if(errorCount > 0){ return true; }else{ return false; } } function removeRow(id){ $('#newRow'+id).remove(); } function showError(id,error){ if(typeof(error) === "undefined"){ $('#'+id).hide(); }else{ $('#'+id).show(); $('#'+id).text(error); } } </script> <?php $__env->stopSection(); ?> <?php $__env->stopSection(); ?> <?php echo $__env->make('dashboard.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/sjslayjy/public_html/devlok/resources/views/dashboard/rake/allot-product.blade.php ENDPATH**/ ?>