308 lines
18 KiB
PHP
308 lines
18 KiB
PHP
@extends('Admin.layouts.master')
|
|
@section('title', 'Product Commission')
|
|
@section('style')
|
|
<link rel="stylesheet"
|
|
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/css/bootstrap-datepicker.min.css"
|
|
integrity="sha512-34s5cpvaNG3BknEWSuOncX28vz97bRI59UnVtEEpFX536A7BtZSJHsDyFoCl8S7Dt2TPzcrCEoHBGeM4SUBDBw=="
|
|
crossorigin="anonymous" referrerpolicy="no-referrer" />
|
|
@endsection
|
|
@section('content')
|
|
<div class="app-main flex-column flex-row-fluid" id="kt_app_main">
|
|
<div class="d-flex flex-column flex-column-fluid">
|
|
<div id="kt_app_content_container" class="app-container container-xxl">
|
|
<div class="row max-w-100 index_table mt-10">
|
|
<div class="add_new_investors my-5 mb-0">
|
|
<div class="top_header d-flex justify-content-between">
|
|
<p class='fs-2 fw-bold'>Product Commission</p>
|
|
<div class="table_right_options d-flex">
|
|
<a class="btn me-3" href="{{ route('manage_commission') }}">Back</a>
|
|
</div>
|
|
</div>
|
|
<form id="editCommission" enctype="multipart/form-data" autocomplete="off">
|
|
@csrf
|
|
@method('patch')
|
|
<input type="hidden" name="products_id" value="{{ $product->id }}">
|
|
{{-- @dd($product); --}}
|
|
<div class="card mb-8">
|
|
<div class="card-body py-4">
|
|
<div class="row add_category_area">
|
|
<div class="col-md-6">
|
|
<label class="fs-6 fw-semibold form-label mt-3">
|
|
<span class="">Product Name</span>
|
|
</label>
|
|
|
|
<input type="text" class="form-control form-control-solid"
|
|
value="{{ $product_name }}" readonly>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="fs-6 fw-semibold form-label mt-3">
|
|
<span class="">Category</span>
|
|
</label>
|
|
<input type="text" class="form-control form-control-solid"
|
|
value="{{ $product->category->category_name }}" readonly>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="fs-6 fw-semibold form-label mt-3">
|
|
<span class="required">Commission Type</span>
|
|
</label>
|
|
@if($product->commission_type)
|
|
<input type="text" class="form-control form-control-solid"
|
|
value="{{ $product->commission_type }}" name="commission_type" id="commission_type" readonly>
|
|
@else
|
|
<select class="form-control form-control-solid" id="commission_type"
|
|
name="commission_type" id="">
|
|
<option value="">Please Select Commission Type</option>
|
|
<option value="One-Time Commission"
|
|
{{ $product->commission_type == 'One-Time Commission' ? 'selected' : null }}>
|
|
One-Time Commission</option>
|
|
<option value="Trail Commission"
|
|
{{ $product->commission_type == 'Trail Commission' ? 'selected' : null }}>
|
|
Trail Commission</option>
|
|
<option value="Hybrid Structure"
|
|
{{ $product->commission_type == 'Hybrid Structure' ? 'selected' : null }}>
|
|
Hybrid Structure</option>
|
|
</select>
|
|
@endif
|
|
</div>
|
|
<div
|
|
class="col-md-6 upfront-commission-input {{ $product->commission_type == 'One-Time Commission' || $product->commission_type == 'Hybrid Structure' ? '' : 'd-none' }}">
|
|
<label class="fs-6 fw-semibold form-label mt-3">
|
|
<span class="required">Upfront Rate</span>
|
|
</label>
|
|
<input type="number" name="upfront_rate"
|
|
class="form-control form-control-solid"
|
|
value="{{ $product->upfront_rate }}">
|
|
</div>
|
|
<div
|
|
class="col-md-6 trail-commission-input {{ $product->commission_type == 'Trail Commission' || $product->commission_type == 'Hybrid Structure' ? '' : 'd-none' }}">
|
|
<label class="fs-6 fw-semibold form-label mt-3">
|
|
<span class="required">Trail Rate</span>
|
|
</label>
|
|
<input type="number" name="trail_rate" class="form-control form-control-solid"
|
|
value="{{ $product->trail_rate }}">
|
|
</div>
|
|
{{-- @if($product->commission_type == 'Trail Commission' || $product->commission_type == 'Hybrid Structure') --}}
|
|
<div
|
|
class="col-md-6 end-of-trail-input ml-auto {{ $product->commission_type == 'Trail Commission' || $product->commission_type == 'Hybrid Structure' ? '' : 'd-none' }}">
|
|
<label class="fs-6 fw-semibold form-label mt-3">
|
|
<span class="required">Return Type</span>
|
|
</label>
|
|
{{-- <input type="text" name="end_of_trail" class="form-control form-control-solid end-of-trail" value="{{ $product->end_of_trail }}"> --}}
|
|
<select name="return_type" id=""
|
|
class="form-control form-control-solid">
|
|
<option value="">Please select return type</option>
|
|
<option value="Monthly"
|
|
{{ $product->return_type == 'Monthly' ? 'selected' : '' }}>Monthly
|
|
</option>
|
|
<option value="Quarterly"
|
|
{{ $product->return_type == 'Quarterly' ? 'selected' : '' }}>Quarterly
|
|
</option>
|
|
<option value="Half-Yearly"
|
|
{{ $product->return_type == 'Half-Yearly' ? 'selected' : '' }}>
|
|
Half-Yearly
|
|
</option>
|
|
<option value="Yearly"
|
|
{{ $product->return_type == 'Yearly' ? 'selected' : '' }}>
|
|
Yearly</option>
|
|
</select>
|
|
</div>
|
|
{{-- @endif --}}
|
|
<div
|
|
class="col-md-6 end-of-trail-input {{ $product->commission_type == 'Trail Commission' || $product->commission_type == 'Hybrid Structure' ? '' : 'd-none' }} ml-auto">
|
|
<label class="fs-6 fw-semibold form-label mt-3">
|
|
<span class="required">End Of Trail</span>
|
|
</label>
|
|
<input type="text" name="end_of_trail"
|
|
class="form-control form-control-solid end-of-trail"
|
|
value="{{ optional($product->end_of_trail)->format('d-m-Y') }}">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="fs-6 fw-semibold form-label mt-3">
|
|
<span class="required">GST</span>
|
|
</label>
|
|
<input type="number" name="gst" class="form-control form-control-solid"
|
|
value="{{ $product->gst }}">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="fs-6 fw-semibold form-label mt-3">
|
|
<span class="required">TDS</span>
|
|
</label>
|
|
<input type="number" name="tds" class="form-control form-control-solid"
|
|
value="{{ $product->tds }}">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="fs-6 fw-semibold form-label mt-3">
|
|
<span class="">Profit Sharing</span>
|
|
</label>
|
|
<input type="number" name="profit_sharing"
|
|
class="form-control form-control-solid"
|
|
value="{{ $product->profit_sharing }}">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="fs-6 fw-semibold form-label mt-3">
|
|
<span class="">Channel Partner Agreement</span>
|
|
</label>
|
|
<input type="file" name="channel_partner_agreement"
|
|
class="form-control form-control-solid" >
|
|
</div>
|
|
</div>
|
|
<div class="submit_btn d-flex justify-content-center my-15">
|
|
<button id="save_btn" type="submit" class="btn btn-dark">Save</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
@section('scripts')
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.10.0/js/bootstrap-datepicker.min.js"
|
|
integrity="sha512-LsnSViqQyaXpD4mBBdRYeP6sRwJiJveh2ZIbW41EBrNmKxgr/LFZIiWT6yr+nycvhvauz8c2nYMhrP80YhG7Cw=="
|
|
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
|
<script>
|
|
$('.end-of-trail').datepicker({
|
|
// format: 'mm/yyyy',
|
|
// format: 'M-yy',
|
|
format: 'yyyy-mm-dd',
|
|
autoclose: true,
|
|
startDate: new Date(),
|
|
// startDate: '-3d',
|
|
minViewMode: 1,
|
|
viewMode: "months",
|
|
minViewMode: "months",
|
|
}).on('changeDate', function(ev) {
|
|
// if (ev.viewMode == 'months') {
|
|
var endingDate = new Date(ev.date);
|
|
var endingMonth = endingDate.getMonth();
|
|
var endingYear = endingDate.getFullYear();
|
|
// var endingDay = getDaysInMonth(endingMonth, endingYear);
|
|
var endingDay = new Date(endingDate.getFullYear(), endingDate.getMonth() + 1, 0);
|
|
// alert(endingDay)
|
|
// endingDate = new Date(endingYear, endingMonth, endingDay);
|
|
// alert(endingDay);
|
|
$('.end-of-trail').datepicker('setDate', endingDay);
|
|
$('.end-of-trail').datepicker('hide');
|
|
// }
|
|
});
|
|
|
|
$('#commission_type').change(function() {
|
|
if ($(this).val() === 'One-Time Commission') {
|
|
$('.upfront-commission-input').removeClass('d-none');
|
|
$('.trail-commission-input').addClass('d-none');
|
|
$('.end-of-trail-input').addClass('d-none');
|
|
} else if ($(this).val() === 'Trail Commission') {
|
|
$('.upfront-commission-input').addClass('d-none');
|
|
$('.trail-commission-input').removeClass('d-none');
|
|
$('.end-of-trail-input').removeClass('d-none');
|
|
} else if ($(this).val() === 'Hybrid Structure') {
|
|
$('.upfront-commission-input').removeClass('d-none');
|
|
$('.trail-commission-input').removeClass('d-none');
|
|
$('.end-of-trail-input').removeClass('d-none');
|
|
}
|
|
})
|
|
|
|
$("#editCommission").validate({
|
|
ignore: [],
|
|
debug: false,
|
|
rules: {
|
|
commission_type: 'required',
|
|
profit_sharing: {
|
|
range: [0, 100]
|
|
},
|
|
upfront_rate: {
|
|
required: true,
|
|
range: [0, 100],
|
|
required: function(element) {
|
|
return $('#commission_type').val() == 'One-Time Commission' || $('#commission_type')
|
|
.val() == 'Hybrid Structure';
|
|
}
|
|
},
|
|
trail_rate: {
|
|
required: true,
|
|
range: [0, 100],
|
|
required: function(element) {
|
|
return $('#commission_type').val() == 'Trail Commission' || $('#commission_type')
|
|
.val() == 'Hybrid Structure';
|
|
}
|
|
},
|
|
gst: {
|
|
required: true,
|
|
range: [0, 100]
|
|
},
|
|
tds: {
|
|
required: true,
|
|
range: [0, 100]
|
|
},
|
|
return_type: {
|
|
required: true,
|
|
required: function(element) {
|
|
return $('#commission_type').val() == 'Trail Commission' || $('#commission_type')
|
|
.val() == 'Hybrid Structure';
|
|
}
|
|
},
|
|
end_of_trail: {
|
|
required: true,
|
|
required: function(element) {
|
|
return $('#commission_type').val() == 'Trail Commission' || $('#commission_type')
|
|
.val() == 'Hybrid Structure';
|
|
}
|
|
},
|
|
},
|
|
messages: {
|
|
commission_type: "Please enter commission type",
|
|
profit_sharing: {
|
|
range: 'Please enter number between 0 and 100'
|
|
},
|
|
upfront_rate: {
|
|
required: "Please enter upfront rate.",
|
|
range: 'Please enter number between 0 and 100'
|
|
},
|
|
trail_rate: {
|
|
required: "Please enter trail rate.",
|
|
range: 'Please enter number between 0 and 100'
|
|
},
|
|
gst: {
|
|
required: "Please enter gst.",
|
|
range: 'Please enter number between 0 and 100'
|
|
},
|
|
tds: {
|
|
required: "Please enter tds.",
|
|
range: 'Please enter number between 0 and 100'
|
|
},
|
|
return_type: "Please enter return type",
|
|
end_of_trail: "Please enter end of trail",
|
|
},
|
|
submitHandler: function(form) {
|
|
var formData = new FormData(form);
|
|
// $("#save_btn").text("Please wait...");
|
|
// $("#save_btn").attr("disabled", true);
|
|
$.ajax({
|
|
url: "{{ route('edit-product') }}",
|
|
type: "POST",
|
|
headers: {
|
|
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
|
},
|
|
data: formData,
|
|
processData: false,
|
|
contentType: false,
|
|
dataType: "json",
|
|
success: function(result) {
|
|
if (result.status == 200) {
|
|
toastr.success(result.message);
|
|
setTimeout(() => {
|
|
window.location = "{{ route('manage_commission') }}"
|
|
}, 1000);
|
|
}
|
|
if (result.status == 400) {
|
|
toastr.warning(result.message);
|
|
}
|
|
},
|
|
});
|
|
},
|
|
});
|
|
</script>
|
|
@endsection
|