Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mcoil.corals.io/resources/views/admin/products/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mcoil.corals.io/resources/views/admin/products/edit.blade.php
@extends('layouts.admin.app')
@section('content')
<div class="row">
    <div class="col-md-12">
        <section class="content">
        @include('layouts.errors-and-messages')
            <div class="box">
                <form action="{{ route('admin.products.update', $product->id) }}" method="post" id="frm_edit" class="form" enctype="multipart/form-data">
                    <div class="box-body">
                        <div class="row">
                            {{ csrf_field() }}
                            <input type="hidden" name="_method" value="put">
                            <div class="col-md-12">
                                <ul class="nav nav-tabs" role="tablist" id="tablist">
                                    <li role="presentation" @if(!request()->has('combination')) class="active" @endif><a href="#info" aria-controls="home" role="tab" data-toggle="tab">Info</a></li>
                                    <li role="presentation" @if(request()->has('combination')) class="active" @endif id="combinationsTab"><a href="#combinations" aria-controls="profile" role="tab" data-toggle="tab">Combinations</a></li>
                                </ul>
                                <div class="tab-content" id="tabcontent">
                                    <div role="tabpanel" class="tab-pane @if(!request()->has('combination')) active @endif" id="info">
                                        <div class="row">
                                            <div class="col-md-8">
                                                <h3 class="bold">{{ ucfirst($product->name) }}</h3>
                                                <div class="row">
                                                    <div class="col-md-12">
                                                        <div class="alert alert-primary" role="alert">
                                                            <strong>Note:</strong> Products can't have the same SKU value
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="name">Product Name <span class="text-danger">*</span></label>
                                                            <input type="text" name="name" id="name" placeholder="Product Name" class="form-control input-lg" value="{!! $product->name !!}">
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="sku">SKU <span class="text-danger">*</span></label>
                                                            <input type="text" name="sku" id="sku" placeholder="SKU" class="form-control input-lg" value="{!! $product->sku !!}">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">
                                                        <div class="form-group">
                                                            <label for="description">Description </label>
                                                            <textarea class="form-control ckeditor" name="description" id="description" rows="5" placeholder="Description">{!! $product->description  !!}</textarea>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-6">
                                                        @if(!empty($product->cover))
                                                        <div class="form-group">
                                                            <img src="{{ URL::asset('/public/storage/'.$product->cover) }}" alt="" class="img-responsive img-thumbnail">
                                                            <button type="button" class="btn btn-danger btn-sm btn-block remove_cover_image">Remove image?</button>
                                                        </div>
                                                        @endif
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <ul id="thumbnails" class="col-md-12 list-unstyled margin-top-10">
                                                            @foreach($images as $image)
                                                                @if(!empty($image->src))
                                                                <li id="thumb-{{$image->id}}">
                                                                    <img src="{{ asset("/public/storage/$image->src") }}" alt="" class="img-responsive img-thumbnail">
                                                                    <div>
                                                                    <button type="button" id="{{$image->id}}" class="btn btn-danger btn-sm btn-block remove_thumb_image">Remove image?</button>
                                                                    </div>
                                                                </li>
                                                                @endif
                                                            @endforeach
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="cover">Upload a Cover Image </label>
                                                            <input type="file" name="cover" id="cover" class="form-control input-lg">
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="image">Upload Images </label>
                                                            <input type="file" name="image[]" id="image" class="form-control input-lg" multiple>
                                                            <span class="text-warning">You can use ctr (cmd) to select multiple images</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-3">
                                                        <div class="form-group">
                                                            <label for="price">Price ({{ config('cart.currency_symbol') }}) <span class="text-danger">*</span></label>
                                                            @if($productAttributes->isEmpty())
                                                                <div class="input-group">
                                                                    <span class="input-group-addon">{{ config('cart.currency_symbol') }}</span>
                                                                    <input type="text" name="price" id="price" placeholder="Price" class="form-control input-lg" value="{!! $product->price !!}">
                                                                </div>
                                                            @else
                                                                <input type="hidden" name="price" value="{!! $product->price !!}">
                                                                <div class="input-group">
                                                                    <span class="input-group-addon">{{ config('cart.currency_symbol') }}</span>
                                                                    <input type="text" name="price" id="price" placeholder="Price" class="form-control input-lg" value="{!! $product->price !!}" disabled>
                                                                </div>
                                                            @endif
                                                            @if(!$productAttributes->isEmpty())<span class="text-danger">Note: Price is disabled. Price is derived based on the combination.</span> @endif
                                                        </div>
                                                    </div>
                                                    <div class="col-md-3">
                                                        <div class="form-group">
                                                            <label for="tax">Vat (%) <span class="text-danger">*</span></label>
                                                            <div class="input-group">
                                                                <span class="input-group-addon">%</span>
                                                                <input type="text" name="tax" id="tax" placeholder="Tax" class="form-control input-lg" value="{{ $product->tax }}">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-3">
                                                        <div class="form-group">
                                                            <label for="sale_price">Total ({{ config('cart.currency_symbol') }})</label>
                                                            <div class="input-group">
                                                                <span class="input-group-addon">{{ config('cart.currency_symbol') }}</span>
                                                                <input type="text" name="sale_price" id="sale_price" readonly placeholder="Sale Price" class="form-control input-lg" value="{{ $product->sale_price }}">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-3">
                                                        <div class="form-group">
                                                            <label for="quantity">In Stock <span class="text-danger">*</span></label>
                                                            @if($productAttributes->isEmpty())
                                                            <div class="input-group">
                                                                <span class="input-group-addon"><i class="fa fa-cart-plus"></i></span>
                                                                <input type="text" name="quantity" id="quantity" placeholder="In Stock" class="form-control input-lg" value="{!! $product->quantity  !!}">
                                                            </div>
                                                            @else
                                                            <input type="hidden" name="quantity" value="{{ $qty }}">
                                                            <div class="input-group">
                                                                <span class="input-group-addon"><i class="fa fa-cart-plus"></i></span>
                                                                <input type="text" value="{{ $qty }}" class="form-control input-lg" disabled>
                                                            </div>
                                                            @endif
                                                            @if(!$productAttributes->isEmpty())<span class="text-danger">Note: Quantity is disabled. Total quantity is calculated by the sum of all the combinations.</span> @endif
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                @if(!$brands->isEmpty())
                                                    <div class="col-md-4">
                                                        <div class="form-group">
                                                            <label for="brand_id">Brand </label>
                                                            <select name="brand_id" id="brand_id" class="form-control custom-select input-lg">
                                                                <option value="">Choose Option</option>
                                                                @foreach($brands as $brand)
                                                                    <option @if($brand->id == $product->brand_id) selected="selected" @endif value="{{ $brand->id }}">{{ $brand->name }}</option>
                                                                @endforeach
                                                            </select>
                                                        </div>
                                                    </div>
                                                @endif
                                                    <div class="col-md-4">
                                                        <div class="form-group">
                                                            @include('admin.shared.status-select', ['status' => $product->status])
                                                        </div>
                                                    </div>
                                                     <div class="col-md-4">
                                                        <div class="form-group">
                                                                    <label for="brand_id">Display In Fontend </label>
                                                                    <select name="display_in_frontend" id="display_in_frontend" class="form-control custom-select input-lg">
                                                                        @if($product->display_in_frontend == 1)
                                                                        <option value="1" selected>Yes</option>
                                                                        <option value="0" >No</option>
                                                                        @else
                                                                         <option value="1" >Yes</option>
                                                                       <option value="0" selected>No</option>
                                                                       @endif
                                                                    </select>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-12">
                                                        @include('admin.shared.attribute-select', [compact('default_weight')])
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-4">
                                                <h3 class="bold">Categories</h3>
                                                @include('admin.shared.categories', ['categories' => $categories, 'ids' => $product])
                                            </div>
                                        </div>
                                         
                                        <div class="row">
                                            <div class="col-md-6">
                                                <button type="submit" class="btn btn-lg btn-block btn-success">Update</button>
                                            </div>
                                            <div class="col-md-6">
                                                <a href="{{ route('admin.products.index') }}" class="btn btn-lg btn-block btn-danger">Back</a>
                                            </div>
                                        </div>
                                    </div>
                                    <div role="tabpanel" class="tab-pane @if(request()->has('combination')) active @endif" id="combinations">
                                        <div class="row">
                                            <div class="col-md-4">
                                                @include('admin.products.create-attributes', compact('attributes'))
                                            </div>
                                            <div class="col-md-8">
                                                @include('admin.products.attributes', compact('productAttributes'))
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
</div>
@endsection
@section('js')
<script src="{{ asset('https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.1/jquery.validate.min.js') }}"></script>
<script type="text/javascript">
function backToInfoTab() {
    $('#tablist > li:first-child').addClass('active');
    $('#tablist > li:last-child').removeClass('active');
    $('#tabcontent > div:first-child').addClass('active');
    $('#tabcontent > div:last-child').removeClass('active');
}
$(document).ready(function () {
    $('#frm_edit').validate({
        errorPlacement: function(error, element) {
            if (element.parent('.input-group').length) {
                error.insertAfter(element.parent());
            } else {
                error.insertAfter(element);
            }
        },
        rules: {
			name: { required: true },
			sku: { required: true },
			price: { required: true },
			tax: { required: true },
			quantity: { required: true }
		},
		messages: {
			name: { required: 'Please enter a product name' },
			sku: { required: 'Please enter a sku' },
			price: { required: 'Please enter a price' },
			tax: { required: 'Please enter a vat' },
			quantity: { required: 'Please enter an amount in stock' }
		}
    });
	var checkedCategory = $('.product_category:checked').val();
	if(checkedCategory == 4) {
		$('#combinationsTab').show();
		$('.product_category').each(function() {
			if($(this).val() != '4') {
				$(this).attr('disabled', true);
			}
		});
	} else {
		$('#combinationsTab').hide();
	}
	$('.product_category').change(function() {
		var categoryId = $(this).val();
		if($(this).is(':checked')) {
			if( categoryId == 4 ) {
				$('.product_category').not(this).prop('checked', false);
				$('.product_category').not(this).attr('disabled', true);
				$('#combinationsTab').show();
			} else {
			    $('.product_category').attr('disabled', false);
			    $('.product_category').not(this).attr('disabled', false);
			    $('#combinationsTab').hide();
			}
		} else {
			$('#combinationsTab').hide();
			if(categoryId == 4) {
				$('.product_category').not(this).prop('checked', false);
				$('.product_category').not(this).attr('disabled', false);
			}
		}
	});
    const checkbox = $('input.attribute');
    $(checkbox).on('change', function () {
        const attributeId = $(this).val();
        if ($(this).is(':checked')) {
            $('#attributeValue' + attributeId).attr('disabled', false);
        } else {
            $('#attributeValue' + attributeId).attr('disabled', true);
        }
        const count = checkbox.filter(':checked').length;
        if (count > 0) {
            $('#productAttributeQuantity').attr('disabled', false);
            $('#productAttributePrice').attr('disabled', false);
            $('#salePrice').attr('disabled', false);
            $('#default').attr('disabled', false);
            $('#createCombinationBtn').attr('disabled', false);
            $('#combination').attr('disabled', false);
        } else {
            $('#productAttributeQuantity').attr('disabled', true);
            $('#productAttributePrice').attr('disabled', true);
            $('#salePrice').attr('disabled', true);
            $('#default').attr('disabled', true);
            $('#createCombinationBtn').attr('disabled', true);
            $('#combination').attr('disabled', true);
        }
    });
    var price = $('#price').val();
    var tax = $('#tax').val();
    if (price != '' && tax != '') {
        var total = (parseFloat(parseFloat(price) * (parseFloat(tax) / 100)) + parseFloat(price)).toFixed(2);
        $("#sale_price").val(total);
    }
    $(document).on('keyup change', '#price', function() {
        var price = $(this).val();
        var tax = $('#tax').val();
        if (price != '' && tax != '') {
            var total2 = (parseFloat(parseFloat(price) * (parseFloat(tax) / 100)) + parseFloat(price)).toFixed(2);
            $("#sale_price").val(total2);
        }
    });
    $(document).on('keyup change','#tax',function() {
        var price = $("#price").val();
        var tax   = $(this).val();
        if (price != '' && tax != '') {
            var total3 = (parseFloat(parseFloat(price) * (parseFloat(tax) / 100)) + parseFloat(price)).toFixed(2);
            $("#sale_price").val(total3);
        }
    });
    var quantityCheck = $('#quantity').val();
    if (quantityCheck <= 0) {
        $('#quantity').addClass('light-redbg-input');
    }
    $(document).on('keyup change','#quantity',function() {
        var quantityCheck = $("#quantity").val();
        if (quantityCheck <= 0) {
            $('#quantity').addClass('light-redbg-input');
        } else {
            $('#quantity').removeClass('light-redbg-input');
        }
    });
    $('#order_table').DataTable({
		"responsive": true,
		"bPaginate": false,
        "bLengthChange": false,
        "bFilter": false,
        "bInfo": false,
        "bSort": false,
		"order": [[ 0, "desc" ]],
        "bAutoWidth": false,
        "columnDefs": [
            { "orderable": false, "targets": [0, 1, 2, 3, 4, 5, 6] }
        ],
        "aaSorting": [],
        "columnDefs": [
          { "width": "140px", "targets": 6 }
        ]
	});
	$('.btn_update_default_attr').click(function() {
		var attributeId = $(this).attr('id');
		var refer = $(this);
		$.ajax({
		    url:"{{ route('admin.products.update.default.attribute') }}",
		    method: "POST",
		    data: {
		    	"_token": "{{ csrf_token() }}",
		    	productId: '{{ $product->id }}',
		    	attributeId: attributeId
		    },
		    success:function(response) {
		        if( response.status == 1 ) {
		        	alert(response.msg);
		        	$('.btn_update_default_attr').removeClass('btn-danger');
		        	$('.btn_update_default_attr').removeClass('btn-success');
		        	$('#order_table').find('.fa-check').removeClass('fa-check').addClass('fa-remove');
		        	$('.btn_update_default_attr').not($(refer)).addClass('btn-danger');
		        	$(refer).addClass('btn-success');
		        	$(refer).find('i').removeClass('fa-remove').addClass('fa-check');
		        } else {
		        	alert(response.msg);
		        }
		    }
		});
	});
    $(document).on('click','.remove_cover_image',function(e) {
        e.preventDefault();
        var data = {_token: "{{ csrf_token() }}",id : "{{$product->id}}"};
        $.ajax({
            type: "POST",
            url: "{{url('/admin/remove-image-product')}}",
            data : data,
            success: function(data) {
                if (data) {
                    $('.img-thumbnail').remove();
                    $(".remove_cover_image").remove();
                    toastr.remove();
                    toastr.clear();
                    toastr.options.closeButton = true;
                    toastr.options.debug = false;
                    toastr.options.progressBar = false;
                    toastr.options.positionClass = 'toast-bottom-full-width';
                    toastr.options.preventDuplicates = true;
                    toastr.options.onclick = null;
                    toastr.options.showDuration = 1000;
                    toastr.options.hideDuration = 1000;
                    toastr.options.timeOut = 5000;
                    toastr.options.extendedTimeOut = 1000;
                    toastr.options.showEasing = 'swing';
                    toastr.options.hideEasing = 'linear';
                    toastr.options.showMethod = 'fadeIn';
                    toastr.options.hideMethod = 'fadeOut';
                    toastr.success('Image Removed Successfully','Success');
                } else {
                    toastr.clear();
                    toastr.options.closeButton = true;
                    toastr.options.debug = false;
                    toastr.options.progressBar = false;
                    toastr.options.positionClass = 'toast-bottom-full-width';
                    toastr.options.preventDuplicates = true;
                    toastr.options.onclick = null;
                    toastr.options.showDuration = 1000;
                    toastr.options.hideDuration = 1000;
                    toastr.options.timeOut = 5000;
                    toastr.options.extendedTimeOut = 1000;
                    toastr.options.showEasing = 'swing';
                    toastr.options.hideEasing = 'linear';
                    toastr.options.showMethod = 'fadeIn';
                    toastr.options.hideMethod = 'fadeOut';
                    toastr.error('Invalid Request','Error');
                }
            }
        });
    });
    $(document).on('click','.remove_thumb_image',function(e) {
        e.preventDefault();
        var id = $(this).attr('id');
        var data = {_token: "{{ csrf_token() }}",id : id};
        $.ajax({
            type: "POST",
            url: "{{url('/admin/remove-image-thumb')}}",
            data : data,
            success: function(data) {
                if (data) {
                    $('#thumb-'+id).remove();
                    toastr.remove();
                    toastr.clear();
                    toastr.options.closeButton = true;
                    toastr.options.debug = false;
                    toastr.options.progressBar = false;
                    toastr.options.positionClass = 'toast-bottom-full-width';
                    toastr.options.preventDuplicates = true;
                    toastr.options.onclick = null;
                    toastr.options.showDuration = 1000;
                    toastr.options.hideDuration = 1000;
                    toastr.options.timeOut = 5000;
                    toastr.options.extendedTimeOut = 1000;
                    toastr.options.showEasing = 'swing';
                    toastr.options.hideEasing = 'linear';
                    toastr.options.showMethod = 'fadeIn';
                    toastr.options.hideMethod = 'fadeOut';
                    toastr.success('Image Removed Successfully','Success');
                } else {
                    toastr.clear();
                    toastr.options.closeButton = true;
                    toastr.options.debug = false;
                    toastr.options.progressBar = false;
                    toastr.options.positionClass = 'toast-bottom-full-width';
                    toastr.options.preventDuplicates = true;
                    toastr.options.onclick = null;
                    toastr.options.showDuration = 1000;
                    toastr.options.hideDuration = 1000;
                    toastr.options.timeOut = 5000;
                    toastr.options.extendedTimeOut = 1000;
                    toastr.options.showEasing = 'swing';
                    toastr.options.hideEasing = 'linear';
                    toastr.options.showMethod = 'fadeIn';
                    toastr.options.hideMethod = 'fadeOut';
                    toastr.error('Invalid Request','Error');
                }
            }
        });
    });
});
</script>
@endsection

Spamworldpro Mini