referral code added
This commit is contained in:
@@ -186,12 +186,15 @@ class DashboardController extends Controller
|
||||
public function createOrUpdateReferralCode(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
// dd($request->all());
|
||||
|
||||
DB::beginTransaction();
|
||||
if($request->id){
|
||||
CustomReferralCode::updateOrCreate(['id', $request->id], [
|
||||
CustomReferralCode::where('id', $request->id)->update( [
|
||||
'referral_code' => $request->referral_code,
|
||||
]);
|
||||
|
||||
}else{
|
||||
CustomReferralCode::updateOrCreate([
|
||||
'referral_code' => $request->referral_code,
|
||||
@@ -250,4 +253,148 @@ class DashboardController extends Controller
|
||||
return response()->json(['error' => 'Export failed. Something went wrong.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 07 June 2024
|
||||
Use : To get the page.
|
||||
*/
|
||||
|
||||
public function index()
|
||||
{
|
||||
$referralCodes = CustomReferralCode::orderBy('id', 'desc')->get();
|
||||
// return $location;
|
||||
return view('Admin.pages.manage_referral_codes.index', compact('referralCodes'));
|
||||
}
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 07 June 2024
|
||||
Use : To store the location.
|
||||
*/
|
||||
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
$request->validate([
|
||||
'referral_code' => 'required|string|max:15',
|
||||
|
||||
]);
|
||||
|
||||
try {
|
||||
if (CustomReferralCode::where('referral_code', $request->referral_code)->exists()) {
|
||||
return response()->json(['success' => false, 'error' => 'Referral Code name already exists', 'status' => 422]);
|
||||
}
|
||||
|
||||
// new location
|
||||
$storeCode = new CustomReferralCode();
|
||||
$storeCode->referral_code = $request->referral_code;
|
||||
$storeCode->save();
|
||||
|
||||
|
||||
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'error' => $e->getMessage(), 'status' => 500]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 07 June 2024
|
||||
Use : To change status.
|
||||
*/
|
||||
public function change_referral_code_status(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
// dd($request->all());
|
||||
DB::beginTransaction();
|
||||
$status = CustomReferralCode::find($request->referral_id);
|
||||
$status->is_active = $request->status;
|
||||
$status->save();
|
||||
// return response()->json(['status' => 200]);
|
||||
DB::commit();
|
||||
|
||||
return jsonResponseWithSuccessMessage(__('success.update_data'));
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("Update Status function Load Failed " . $e->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 07 June 2024
|
||||
Use : To delete location.
|
||||
*/
|
||||
public function delete_referral_code($id)
|
||||
{
|
||||
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$passport = CustomReferralCode::find($id);
|
||||
$passport->delete();
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
\Log::error("delete_location function Load Failed " . $e->getMessage());
|
||||
return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 07 June 2024
|
||||
Use : To update location.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public function update_referral_code(Request $request)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
// Find the location data
|
||||
$updateReferralCode = CustomReferralCode::find($request->id);
|
||||
if (!$updateReferralCode) {
|
||||
return response()->json(['success' => false, 'error' => 'Referral Code not found', 'status' => 404]);
|
||||
}
|
||||
|
||||
// Update the location data
|
||||
$updateReferralCode->referral_code = $request->referral_code;
|
||||
$updateReferralCode->save();
|
||||
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json(['success' => true, 'message' => __('success.update_data'), 'status' => 200]);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
\Log::error("Failed to update Code: " . $e->getMessage());
|
||||
return response()->json(['success' => false, 'error' => __('auth.something_went_wrong'), 'status' => 500]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,11 +4,14 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
class CustomReferralCode extends Model
|
||||
{
|
||||
protected $table = 'custom_referral_code';
|
||||
|
||||
use HasFactory;
|
||||
protected $guarded = [ ];
|
||||
use SoftDeletes;
|
||||
protected $table = 'custom_referral_code';
|
||||
protected $guarded = [];
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
<input type="text" class="form-control" name="referral_code"
|
||||
id="referral_code" value="" placeholder="Enter Referral Code"
|
||||
oninput="this.value = this.value.toUpperCase()" maxlength="15">
|
||||
oninput="this.value = this.value.toUpperCase().replace(/\s/g, '')" maxlength="15">
|
||||
<div class="">
|
||||
<button id="create_custom_code" type="submit" class="download-btn-custom mt-3 custom-width-10">Submit</button>
|
||||
</div>
|
||||
@@ -43,11 +43,11 @@
|
||||
|
||||
<input type="text" class="form-control" name="referral_code"
|
||||
id="referral_code" value="{{$customReferralCode->referral_code}}" placeholder="Enter Referral Code"
|
||||
oninput="this.value = this.value.toUpperCase()" maxlength="15">
|
||||
oninput="this.value = this.value.toUpperCase().replace(/\s/g, '')" maxlength="15">
|
||||
<input type="hidden" name="id" value="{{$customReferralCode->id}}"/>
|
||||
<div class="d-flex" style="justify-content: space-between;">
|
||||
<button id="create_custom_code" type="submit" class="download-btn-custom mt-3 custom-width-10">Update</button>
|
||||
<button id="create_custom_code" type="submit" class="download-btn-cancel mt-3 custom-width-10">Deactivate Code</button>
|
||||
{{-- <button id="create_custom_code" type="submit" class="download-btn-cancel mt-3 custom-width-10">Deactivate Code</button> --}}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -161,18 +161,6 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{{-- <li class="tooltip-element <?php
|
||||
if ($currentPage == 'manage-vouchers') {
|
||||
echo 'active';
|
||||
}
|
||||
?>" data-tooltip="3">
|
||||
<a href="{{ route('manage.voucher') }}" data-active="3">
|
||||
<div class="icons">
|
||||
<img src="{{ asset('public/assets/img/fluent-mdl2_coupon.svg') }}" >
|
||||
<span class="text">Manage Vouchers</span>
|
||||
</div>
|
||||
</a>
|
||||
</li> --}}
|
||||
@endif
|
||||
@if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-contact-us'))
|
||||
<li class="tooltip-element <?php
|
||||
@@ -203,6 +191,21 @@
|
||||
</a>
|
||||
</li>
|
||||
@endif
|
||||
@if (Auth::guard('admin')->user()->getPermissionGranted(Auth::guard('admin')->user()->id, 'manage-referral-codes'))
|
||||
<li class="tooltip-element <?php
|
||||
if ($currentPage == 'manage-referral-codes') {
|
||||
echo 'active';
|
||||
}
|
||||
?>" data-tooltip="9">
|
||||
<a href="{{ route('manage-referral-codes') }}" data-active="3">
|
||||
<div class="icons">
|
||||
<img src="{{ asset('public/assets/img/coupon 1.svg') }}" />
|
||||
<span class="text">Referral Codes</span>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,453 @@
|
||||
@extends('Admin.layouts.master')
|
||||
|
||||
@section('content')
|
||||
@php
|
||||
$currentPage = 'manage-referral-codes';
|
||||
@endphp
|
||||
<style>
|
||||
.switch-btn input[switch]+label {
|
||||
width: 6.8rem !important;
|
||||
}
|
||||
|
||||
.switch-btn input[switch]:checked+label:after {
|
||||
left: 5.22rem !important;
|
||||
}
|
||||
</style>
|
||||
<div class="layout-px-spacing">
|
||||
<div class="middle-content container-xxl p-0">
|
||||
<div class="row layout-top-spacing ">
|
||||
<div class="top-tabel">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h6 class="card-title">Manage Referral Codes </h6>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing">
|
||||
<div class="widget-content widget-content-area br-8 position-btn" style="overflow: auto;">
|
||||
<table id="zero-config" class="table dt-table-hover manage_referral_table" style="width:100%">
|
||||
<thead class="text-center">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<tr>
|
||||
<th class="text-center">Sr no</th>
|
||||
<th class="text-center">Referral Code</th>
|
||||
<th class="no-content">Status</th>
|
||||
|
||||
<th class="no-content">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-center">
|
||||
@foreach ($referralCodes as $referralCodeItem)
|
||||
<tr>
|
||||
<td class="text-center">{{ $loop->iteration }}</td>
|
||||
<td class="text-center">{{ $referralCodeItem->referral_code }}</td>
|
||||
<td class="text-start">
|
||||
<div class="switch-btn">
|
||||
<input type="checkbox" data-id = "{{ $referralCodeItem->id }}"
|
||||
class="active_referral_code" id="switch{{ $referralCodeItem->id }}"
|
||||
value="1" {{ $referralCodeItem->is_active ? 'checked' : '' }}
|
||||
switch="bool" />
|
||||
<label for="switch{{ $referralCodeItem->id }}" data-on-label="Active"
|
||||
data-off-label="Deactivated"></label>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="dropout">
|
||||
<button class="more">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</button>
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="#" data-toggle="modal"
|
||||
data-target="#edit-referral-code"
|
||||
class="edit_referral_code_value"
|
||||
data-code-id="{{ $referralCodeItem->id }}"
|
||||
data-code-referral_code="{{ $referralCodeItem->referral_code }}">
|
||||
<img src="{{ asset('public/assets/img/edit.svg') }}" />
|
||||
<span>Edit</span>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a class="delete_location" data-id="{{ $referralCodeItem->id }}"
|
||||
data-toggle="modal" data-target="#delete-location-modal">
|
||||
<img
|
||||
src="{{ asset('public/assets/img/delete-recycle.svg') }}" />
|
||||
<span>Delete</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="add_code_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<div class="modal-header p-0">
|
||||
<h5 class="modal-title">Add Referral Code</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<form id="store_referral_code">
|
||||
@csrf
|
||||
<div class="col-md-12">
|
||||
<label for="referral_code">Referral Code</label>
|
||||
<input id="referral_code" name="referral_code" class="form-control" type="text"
|
||||
placeholder="Enter Referral Code"
|
||||
oninput="this.value = this.value.toUpperCase().replace(/\s/g, '')" maxlength="15">
|
||||
|
||||
|
||||
</div>
|
||||
<button type="submit" id="submit_referral_code" class="download-btn-custom mt-4 mx-auto w-25">
|
||||
<span>Save</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="modal fade" id="edit-referral-code" tabindex="-1" role="dialog" aria-labelledby="editLocationModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<form id="edit_referral_code" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<input class="form-control" name="id" type="hidden" id="referral_id" value="">
|
||||
<input class="form-control" name="referral_code" type="hidden" id="referral_code" value="">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editLocationModalLabel" style="text-align:center;">Edit Referral Code
|
||||
</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="referral_code">Referral Code</label>
|
||||
<input type="text" class="form-control" id="referral_code" name="referral_code"
|
||||
placeholder="Enter Referral Code"
|
||||
oninput="this.value = this.value.toUpperCase().replace(/\s/g, '')" maxlength="15">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" id="update_referral_code" class="download-btn-custom mt-4 mx-auto w-25">
|
||||
<span>Update</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="modal fade" id="delete-location-modal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="btn-close" data-dismiss="modal" aria-label="Close">
|
||||
x
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="delete_referral_code_id" name="location_id">
|
||||
<p class="modal-text">Are you sure you want to delete<br> this referral code </p>
|
||||
<div class="modal-btn d-flex ">
|
||||
<a type="button" class="extra-btn" data-dismiss="modal">No</a>
|
||||
<a type="button" class="download-btn-custom delete_referral_code_button"
|
||||
data-dismiss="modal">Yes</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@section('section_script')
|
||||
<script src="{{ asset('public/assets/js/admin/manage_location/main.js') }}"></script>
|
||||
{{-- <script src="{{ asset('public/assets/js/admin/manage_location/add_location.js') }}"></script>
|
||||
<script src="{{ asset('public/assets/js/admin/manage_location/edit_location.js') }}"></script> --}}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$(' <button><a class="extra-btn width-max-content" data-toggle="modal" data-target="#add_code_modal" href="">Add</a></button>')
|
||||
.insertBefore("#zero-config_filter label");
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
//add referral code
|
||||
$(document).on("click", "#submit_referral_code", function(e) {
|
||||
$('#store_referral_code').validate({
|
||||
rules: {
|
||||
referral_code: {
|
||||
required: true,
|
||||
maxlength: 15
|
||||
},
|
||||
|
||||
},
|
||||
messages: {
|
||||
referral_code: {
|
||||
required: "Please enter referral code.",
|
||||
},
|
||||
|
||||
},
|
||||
errorClass: 'error-message',
|
||||
submitHandler: function(form) {
|
||||
e.preventDefault();
|
||||
let base_url = url_path;
|
||||
var formData = new FormData(form);
|
||||
$('#submit_referral_code').text('Please wait...');
|
||||
$('#submit_referral_code').attr('disabled', true);
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
});
|
||||
$.ajax({
|
||||
url: base_url + '/add-referral-code',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(response) {
|
||||
if (response.status == 200) {
|
||||
toastr.success('Referral Code added successfully');
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url +
|
||||
"/manage-referral-codes";
|
||||
}, 1000);
|
||||
} else if (response.status == 422 && response.error ===
|
||||
'Referral Code name already exists') {
|
||||
toastr.error('Referral Code name already exists');
|
||||
} else {
|
||||
toastr.error("Something went wrong");
|
||||
window.location.reload();
|
||||
}
|
||||
$('#submit_referral_code').attr('disabled', false);
|
||||
$('#submit_referral_code').text('Save');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle the case where the server returns an error
|
||||
if (xhr.status == 422 && xhr.responseJSON.error ===
|
||||
'Referral Code name already exists') {
|
||||
toastr.error('Referral Code name already exists');
|
||||
} else {
|
||||
toastr.error("An error occurred");
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
$('#submit_referral_code').attr('disabled', false);
|
||||
$('#submit_referral_code').text('Save');
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$(document).on("click", ".edit_referral_code_value", function(e) {
|
||||
e.preventDefault(); // Prevent default action
|
||||
|
||||
var referralId = $(this).data('code-id');
|
||||
var referralCode = $(this).data('code-referral_code');
|
||||
|
||||
|
||||
console.log('referralId ID:', referralId);
|
||||
|
||||
|
||||
$('#referral_id').val(referralId);
|
||||
$('#referral_code').val(referralCode);
|
||||
|
||||
|
||||
$('#edit-referral-code').modal('show');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Assuming you have a mechanism to set manage_state_xid in the modal
|
||||
$('#edit-referral-code').on('show.bs.modal', function(event) {
|
||||
var button = $(event.relatedTarget); // Button that triggered the modal
|
||||
var locationId = button.data('code-id'); // Extract info from data-* attributes
|
||||
var manageStateXid = button.data('code-referral_code');
|
||||
|
||||
// If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
|
||||
// Update the modal's content.
|
||||
var modal = $(this);
|
||||
modal.find('#location_id').val(locationId);
|
||||
modal.find('#manage_state_xid').val(manageStateXid);
|
||||
|
||||
modal.find('#referral_id').val(locationId);
|
||||
modal.find('#referral_code').val(manageStateXid);
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('#edit_referral_code').validate({
|
||||
rules: {
|
||||
referral_code: {
|
||||
required: true
|
||||
},
|
||||
|
||||
},
|
||||
messages: {
|
||||
referral_code: {
|
||||
required: "Please enter the Referral name."
|
||||
},
|
||||
|
||||
},
|
||||
errorClass: 'error-message',
|
||||
submitHandler: function(form) {
|
||||
var formData = new FormData(form);
|
||||
let base_url = url_path;
|
||||
$('#update_referral_code').text('Please wait...');
|
||||
$('#update_referral_code').attr('disabled', true);
|
||||
$.ajax({
|
||||
url: base_url + '/update_referral_code',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(result) {
|
||||
if (result.success) {
|
||||
toastr.success('Referral Code updated successfully');
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url +
|
||||
"/manage-referral-codes";
|
||||
}, 2000);
|
||||
} else {
|
||||
toastr.error(result.error || 'Something went wrong');
|
||||
window.location.reload();
|
||||
}
|
||||
$('#update_referral_code').attr('disabled', false);
|
||||
$('#update_referral_code').text('Save');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
toastr.error('Something went wrong');
|
||||
$('#update_referral_code').attr('disabled', false);
|
||||
$('#update_referral_code').text('Save');
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).on("click", ".delete_location", function() {
|
||||
var delete_id = $(this).data('id');
|
||||
$('#delete_referral_code_id').val(delete_id);
|
||||
});
|
||||
|
||||
$(document).on("click", ".delete_referral_code_button", function(e) {
|
||||
e.preventDefault();
|
||||
let base_url = url_path;
|
||||
var delete_id = $('#delete_referral_code_id').val();
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
});
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: base_url + "/delete_referral_code/" + delete_id,
|
||||
success: function(response) {
|
||||
if (response.status == 200) {
|
||||
toastr.success('Referral Code deleted successfully');
|
||||
setTimeout(function() {
|
||||
window.location.href = base_url + "/manage-referral-codes";
|
||||
}, 1000);
|
||||
} else {
|
||||
toastr.error("Something went wrong");
|
||||
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(".manage_referral_table").on("change", ".active_referral_code", function() {
|
||||
let base_url = url_path;
|
||||
var status = $(this).prop("checked") == true ? 1 : 0;
|
||||
var referral_id = $(this).data("id");
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: base_url + '/change_referral_code_status',
|
||||
data: {
|
||||
status: status,
|
||||
referral_id: referral_id,
|
||||
},
|
||||
success: function(data) {
|
||||
if (status == 1) {
|
||||
toastr.options = {
|
||||
"timeOut": 9000
|
||||
}
|
||||
|
||||
toastr.success("Referral Code Activated successfully.");
|
||||
setTimeout(function() {
|
||||
window.location.reload();
|
||||
}, 3000);
|
||||
|
||||
} else {
|
||||
toastr.error("Referral Code Deactivated successfully.");
|
||||
setTimeout(function() {
|
||||
window.location.reload();
|
||||
}, 3000);
|
||||
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@@ -127,7 +127,7 @@
|
||||
<button class="apply" type="button" onclick="applyReferralCode()">Apply</button>
|
||||
</div>
|
||||
<input type="text" class="form-control coupon-input mt-3"
|
||||
name ="referral_code" id="referral_code" placeholder="Enter Referral Code" oninput="this.value = this.value.toUpperCase()" maxlength="15">
|
||||
name ="referral_code" id="referral_code" placeholder="Enter Referral Code" oninput="this.value = this.value.toUpperCase().replace(/\s/g, '')" maxlength="15">
|
||||
|
||||
<input type="hidden" class="form-control coupon-input mt-3" name ="iam_principal_xid"
|
||||
id="iam_principal_xid" value="{{ $userData->id }}">
|
||||
|
||||
@@ -224,6 +224,14 @@ Route::group(['middleware' => ['checkStatus']], function () {
|
||||
Route::delete('/delete_location/{id}', [ManageLocationController::class, 'delete_location']);
|
||||
Route::post('/update_location', [ManageLocationController::class, 'update_location']);
|
||||
|
||||
//*******************************************************manage Referral Codes********************************************************
|
||||
|
||||
Route::get('/manage-referral-codes', [DashboardController::class, 'index'])->name('manage-referral-codes');
|
||||
Route::post('/add-referral-code', [DashboardController::class, 'store'])->name('store_referral_code');
|
||||
Route::get('/change_referral_code_status', [DashboardController::class, 'change_referral_code_status']);
|
||||
Route::delete('/delete_referral_code/{id}', [DashboardController::class, 'delete_referral_code']);
|
||||
Route::post('/update_referral_code', [DashboardController::class, 'update_referral_code']);
|
||||
|
||||
//*******************************************************Rules and regulation********************************************************
|
||||
//*******************************************************manage redemptions rules********************************************************
|
||||
Route::get('/manage_rules', [ManageRulesController::class, 'index'])->name('manage_rules');
|
||||
|
||||
Reference in New Issue
Block a user