IMMREX7
<?php $__env->startSection('content'); ?>
<div class="row clearfix">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="card">
<div class="header">
<h2><strong>Assign</strong> Location</h2>
</div>
<div class="body">
<?php if(isset($prodlocation)): ?>
<?php echo Form::model( $prodlocation, ['route' => ['storelocation.update', $prodlocation->idProductLocation], 'method' => 'put','class'=>'form-horizontal'] ); ?>
<?php else: ?>
<?php echo Form::open(['url' => 'school/prodlocation','class'=>'form-horizontal','id'=>'form']); ?>
<?php endif; ?>
<?php if(isset($prodlocation)): ?>
<div class="row clearfix">
<div class="col-sm-2 form-control-label required">
<label for="classname">Product</label>
</div>
<div class="col-sm-3">
<div class="form-group">
<?php echo Form::select('idProduct',null,['class' => 'form-control','required'=>'required']); ?>
<?php if($errors->has('idProduct')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idProduct')); ?></strong>
</label>
<?php endif; ?>
</div>
</div>
<div class="col-sm-2 form-control-label required">
<label for="classname">Location</label>
</div>
<div class="col-sm-3">
<div class="form-group">
<?php echo Form::select('idStoreLocation',null,['class' => 'form-control','required'=>'required']); ?>
<?php if($errors->has('idStoreLocation')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idStoreLocation')); ?></strong>
</label>
<?php endif; ?>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-2 form-control-label required">
<label for="classname">Sub Location</label>
</div>
<div class="col-sm-3">
<div class="form-group">
<?php echo Form::select('idSubLocation',null,['class' => 'form-control','required'=>'required']); ?>
<?php if($errors->has('idSubLocation')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idSubLocation')); ?></strong>
</label>
<?php endif; ?>
</div>
</div>
</div>
<?php else: ?>
<div class="row clearfix">
<table class="table">
<thead>
<tr>
<th>S. No.</th>
<th>Product</th>
<th>Location</th>
<th>Sub Location</th>
<th></th>
</tr>
</thead>
<tbody id="optional_list">
<?php $i =1;?>
<tr>
<td class="sno"><?php echo e($i); ?></td>
<td>
<?php echo Form::select('locations[1][idProduct]',$products,null,['class' => 'form-control show-tick ms','required'=>'required']); ?>
<span id="sublocerror1"></span>
</td>
<td>
<?php echo Form::select('locations[1][idStoreLocation]',$storelocations,null,['class' => 'form-control show-tick ms','required'=>'required','id'=>'storeloc1','onchange'=>'getSublocation(this,1)']); ?>
<span id="sublocerror1"></span>
</td>
<td>
<?php echo Form::select('locations[1][idSubLocation]',[''=>'----Select----'],null,['class' => 'form-control show-tick ms','required'=>'required','id'=>'subloc1']); ?>
<span id="sublocerror1"></span>
</td>
</tr>
<?php $i++ ; ?>
</tbody>
<tr>
<td colspan="4" style="text-align: right"><input type="button" class="add-row btn btn-sm btn-success" value="Add Row"></td>
</tr>
</table>
</div>
<?php endif; ?>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
<?php if(isset($prodlocation)): ?>
<?php echo Form::submit('UPDATE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']); ?>
<?php else: ?>
<?php echo Form::submit('SAVE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']); ?>
<?php endif; ?>
<?php echo Form::close(); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>List Of Assigned Locations </strong></h2>
</div>
<div class="body table-responsive">
<table class="table table-bordered table-striped table-hover js-basic-example dataTable">
<thead>
<tr>
<th>S.NO.</th>
<th>Product</th>
<th>Location</th>
<th>Sub Location</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
<?php $__currentLoopData = $product_locations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $var): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<tr>
<td><?php echo e($i); ?></td>
<td><?php echo e($var->product->productName); ?></td>
<td><?php echo e($var->storeloc->locationName); ?></td>
<td><?php echo e($var->sublocation->subLocation); ?></td>
<td>
<a href='<?php echo e(url('/school/prodlocation/'.$var->idProductLocation.'/edit')); ?>' class="btn btn-raised btn-info waves-effect btn-round"><i class="fa fa-edit"></i>Edit</a>
<button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="<?php echo e($var->idProductLocation); ?>" data-type="confirm">DELETE</button>
</td>
</tr>
<?php $i++; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script>
$(document).ready(function() {
var i = $('.sno:last').text();
$(".add-row").click(function(){
i++;
var markup = '<tr><td class="sno">'+i+'</td>\
<td><select name="locations['+i+'][idProduct]" class = "form-control select2 show-tick ms" required="required"><?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($key); ?>"><?php echo e($value); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></td>\n\
<td><select name="locations['+i+'][idStoreLocation]" class = "form-control select2 show-tick ms" required="required" id="storeloc'+i+'" onchange = "getSublocation(this,'+i+')" ><?php $__currentLoopData = $storelocations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($key); ?>"><?php echo e($value); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></td> \n\
<td><select name="locations['+i+'][idSubLocation]" class = "form-control select2 show-tick ms" required="required" id="subloc'+i+'"><option value=""></option></select></td>\n\
\n\
<td style="text-align:right;vertical-align: middle;"><input type="button" class="btn btn-sm btn-danger" value="Delete" id="remove_row"></td></tr>';
$("#optional_list").append(markup);
});
$('#optional_list').on('click', 'input[type="button"]', function () {
$(this).closest('tr').remove();
i = $('.sno:last').text();
});
});
function getSublocation(selected,sn){
//console.log($key);
var locID = selected.value;
if (locID) {
$.ajax({
url: "<?php echo e(url('/school/storelocation')); ?>" + '/' + locID + "/sublocations",
type: "GET",
dataType: "json",
success: function (data) {
$('#subloc'+ sn).empty();
$('#subloc'+ sn).append('<option value="">--Select--</option>');
$.each(data, function (key, value) {
$('#subloc'+ sn).append('<option value="' + key + '">' + value + '</option>');
});
}
});
}
}
$(document).on('click', '.js-sweetalert', function (e) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
e.preventDefault();
var id = $(this).data('id');
swal({
title: "Are you sure?",
text: "Are You sure you want to delete this Assigned Location!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "<?php echo e(url('/school/storelocation/')); ?>" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "Assigned Location has been successfully deleted",
type: "success"
},function() {
location.reload();
});
})
.error(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
return false;
});
});
// Saving form data
$('#form').on('submit',function(e){
$.ajaxSetup({
header:$('meta[name="_token"]').attr('content')
});
var formData = new FormData($('#form')[0]);
$("#submit-btn").prop('disabled', true);
$.ajax({
type:"POST",
url: "<?php echo e(url('school/prodlocation')); ?>",
processData: false,
contentType: false,
data:formData,
dataType: 'json',
success:function(data){
if( data[Object.keys(data)[0]] === 'SUCCESS' ){
$("#submit-btn").prop('disabled', true);
window.location = "<?php echo e(url('school/prodlocation')); ?>";
}
else { //False Case: With error msg
$("#msg").html(data); //$msg is the id of empty msg
}
},
error: function(data){
if( data.status === 422 ) {
$("#submit-btn").prop('disabled', false);
var errors = data.responseJSON.errors;
var errorHtml = '<div class="alert alert-danger"><ul>';
$('#formerrors').html(errorHtml);
$.each(errors, function (key, value) {
if (key.split(".")[1] + '.locationName' === key.split(".")[1] + '.' + key.split(".")[2])
{
errordept = '<span class="help-block">' + value + '</span>';
$('#depterror' + key.split(".")[1]).html(errordept);
}
});
}
}
});
return false;
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('schools.school_layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
Copyright © 2021 -