fixed otp email settings and added edit/delete to show tabs
This commit is contained in:
@@ -832,7 +832,7 @@ class ClientsController extends Controller
|
|||||||
}
|
}
|
||||||
public function update_notes(Request $request, $id)
|
public function update_notes(Request $request, $id)
|
||||||
{
|
{
|
||||||
$note = ClientNote::findOrFail($id);
|
$note = Models\ClientNote::findOrFail($id);
|
||||||
|
|
||||||
// Optional: Double-check the 2-day rule on the backend for security
|
// Optional: Double-check the 2-day rule on the backend for security
|
||||||
if ($note->created_at->diffInDays(now()) > 2) {
|
if ($note->created_at->diffInDays(now()) > 2) {
|
||||||
@@ -859,7 +859,7 @@ class ClientsController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Find the record and update it
|
// Find the record and update it
|
||||||
$shortcode = ShortCode::findOrFail($id); // Adjust 'ShortCode' to your actual model name
|
$shortcode = Models\ShortCode::findOrFail($id); // Adjust 'ShortCode' to your actual model name
|
||||||
$shortcode->update($validated);
|
$shortcode->update($validated);
|
||||||
|
|
||||||
// Return the JSON response for SweetAlert
|
// Return the JSON response for SweetAlert
|
||||||
@@ -879,7 +879,7 @@ class ClientsController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Find the record and update it
|
// Find the record and update it
|
||||||
$payment = ClientPayment::findOrFail($id); // Adjust 'ClientPayment' to your actual model name
|
$payment = Models\ClientPayment::findOrFail($id); // Adjust 'ClientPayment' to your actual model name
|
||||||
$payment->update($validated);
|
$payment->update($validated);
|
||||||
|
|
||||||
// Return the JSON response for SweetAlert
|
// Return the JSON response for SweetAlert
|
||||||
@@ -889,6 +889,44 @@ class ClientsController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function destroy_note($id)
|
||||||
|
{
|
||||||
|
$note = Models\ClientNote::findOrFail($id);
|
||||||
|
|
||||||
|
// Enforce the 2-day restriction on the backend for security
|
||||||
|
if ($note->created_at->diffInDays(now()) > 2) {
|
||||||
|
return response()->json(['message' => 'Cannot delete notes older than 2 days.'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$note->delete();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Note deleted successfully.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
public function destroy_short_code($id)
|
||||||
|
{
|
||||||
|
$shortcode = Models\ShortCode::findOrFail($id); // Adjust model name if needed
|
||||||
|
$shortcode->delete();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Short code deleted successfully.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy_payment($id)
|
||||||
|
{
|
||||||
|
$payment = Models\ClientPayment::findOrFail($id); // Adjust model name if needed
|
||||||
|
$payment->delete();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Payment record deleted successfully.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -386,16 +386,11 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
$(document).on('click', '.delete-note-btn', function() {
|
$(document).on('click', '.delete-note-btn', function() {
|
||||||
let id = $(this).data('id');
|
let id = $(this).data('id');
|
||||||
if(confirm("Are you sure you want to delete this note? This action cannot be undone.")) {
|
if(confirm("Are you sure you want to delete this note? This action cannot be undone.")) {
|
||||||
// Send AJAX DELETE request using the meta tag for CSRF
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/notes/${id}`,
|
url: base_url + `/client-notes/${id}`,
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
headers: {
|
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
|
||||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
success: function(res) { location.reload(); }
|
||||||
},
|
|
||||||
success: function(res) {
|
|
||||||
location.reload();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -405,7 +400,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
let id = $(this).data('id');
|
let id = $(this).data('id');
|
||||||
if(confirm("Are you sure you want to delete this short code?")) {
|
if(confirm("Are you sure you want to delete this short code?")) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/shortcodes/${id}`,
|
url: base_url + `/shortcodes/${id}`,
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
|
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
|
||||||
success: function(res) { location.reload(); }
|
success: function(res) { location.reload(); }
|
||||||
@@ -418,7 +413,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
let id = $(this).data('id');
|
let id = $(this).data('id');
|
||||||
if(confirm("Are you sure you want to delete this payment record?")) {
|
if(confirm("Are you sure you want to delete this payment record?")) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/payments/${id}`,
|
url: base_url + `/client-payments/${id}`,
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
|
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
|
||||||
success: function(res) { location.reload(); }
|
success: function(res) { location.reload(); }
|
||||||
@@ -426,7 +421,9 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// --- POPULATE NOTE EDIT MODAL ---
|
// --- POPULATE EDIT MODALS ---
|
||||||
|
|
||||||
|
// Populate Note Edit Modal
|
||||||
$(document).on('click', '.edit-note-btn', function() {
|
$(document).on('click', '.edit-note-btn', function() {
|
||||||
let id = $(this).data('id');
|
let id = $(this).data('id');
|
||||||
let body = $(this).closest('.list-group-item').find('p').text();
|
let body = $(this).closest('.list-group-item').find('p').text();
|
||||||
@@ -434,13 +431,12 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
$('#edit_note_id').val(id);
|
$('#edit_note_id').val(id);
|
||||||
$('#edit_note_body').val(body);
|
$('#edit_note_body').val(body);
|
||||||
|
|
||||||
$('#editNoteForm').attr('action', `/notes/${id}`);
|
// Fixed URL
|
||||||
|
$('#editNoteForm').attr('action', base_url + `/client-notes/${id}`);
|
||||||
// Replaced vanilla JS with jQuery modal show
|
|
||||||
$('#editNoteModal').modal('show');
|
$('#editNoteModal').modal('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
// --- POPULATE SHORT CODE EDIT MODAL ---
|
// Populate Short Code Edit Modal
|
||||||
$(document).on('click', '.edit-shortcode-btn', function() {
|
$(document).on('click', '.edit-shortcode-btn', function() {
|
||||||
let id = $(this).data('id');
|
let id = $(this).data('id');
|
||||||
|
|
||||||
@@ -452,13 +448,12 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
$('#edit_sc_expiry').val($(this).data('expiry'));
|
$('#edit_sc_expiry').val($(this).data('expiry'));
|
||||||
$('#edit_sc_remarks').val($(this).data('remarks'));
|
$('#edit_sc_remarks').val($(this).data('remarks'));
|
||||||
|
|
||||||
$('#editShortcodeForm').attr('action', `/shortcodes/${id}`);
|
// Fixed URL
|
||||||
|
$('#editShortcodeForm').attr('action', base_url + `/shortcodes/${id}`);
|
||||||
// Replaced vanilla JS with jQuery modal show
|
|
||||||
$('#editShortcodeModal').modal('show');
|
$('#editShortcodeModal').modal('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
// --- POPULATE PAYMENT EDIT MODAL ---
|
// Populate Payment Edit Modal
|
||||||
$(document).on('click', '.edit-payment-btn', function() {
|
$(document).on('click', '.edit-payment-btn', function() {
|
||||||
let id = $(this).data('id');
|
let id = $(this).data('id');
|
||||||
|
|
||||||
@@ -468,9 +463,8 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
$('#edit_pay_date').val($(this).data('date'));
|
$('#edit_pay_date').val($(this).data('date'));
|
||||||
$('#edit_pay_status').val($(this).data('status'));
|
$('#edit_pay_status').val($(this).data('status'));
|
||||||
|
|
||||||
$('#editPaymentForm').attr('action', `/payments/${id}`);
|
// Fixed URL
|
||||||
|
$('#editPaymentForm').attr('action', base_url + `/client-payments/${id}`);
|
||||||
// Replaced vanilla JS with jQuery modal show
|
|
||||||
$('#editPaymentModal').modal('show');
|
$('#editPaymentModal').modal('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,23 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
|
|
||||||
Route::get('/', [App\Http\Controllers\DashboardController::class, 'index'])->name('dashboard');
|
Route::get('/', [App\Http\Controllers\DashboardController::class, 'index'])->name('dashboard');
|
||||||
Route::get('home', [App\Http\Controllers\DashboardController::class, 'index'])->name('home');
|
Route::get('home', [App\Http\Controllers\DashboardController::class, 'index'])->name('home');
|
||||||
#Clients
|
|
||||||
|
|
||||||
Route::put('/notes/{id}', [App\Http\Controllers\ClientsController::class, 'update_notes']);
|
#Clients
|
||||||
|
Route::put('/clients/notes/{id}', [App\Http\Controllers\ClientsController::class, 'update_notes']);
|
||||||
|
Route::post('/clients/shortcodes/{id}', [App\Http\Controllers\ClientsController::class, 'update_short_code']);
|
||||||
|
Route::put('/clients/payments/{id}', [App\Http\Controllers\ClientsController::class, 'update_payment']);
|
||||||
|
|
||||||
|
// Notes
|
||||||
|
Route::put('/client-notes/{id}', [App\Http\Controllers\ClientsController::class, 'update_notes']);
|
||||||
|
Route::delete('/client-notes/{id}', [App\Http\Controllers\ClientsController::class, 'destroy_notes']);
|
||||||
|
|
||||||
|
// Payments
|
||||||
|
Route::put('/client-payments/{id}', [App\Http\Controllers\ClientsController::class, 'update_payment']);
|
||||||
|
Route::delete('/client-payments/{id}', [App\Http\Controllers\ClientsController::class, 'destroy_payment']);
|
||||||
|
|
||||||
|
// Shortcodes
|
||||||
Route::put('/shortcodes/{id}', [App\Http\Controllers\ClientsController::class, 'update_short_code']);
|
Route::put('/shortcodes/{id}', [App\Http\Controllers\ClientsController::class, 'update_short_code']);
|
||||||
Route::put('/payments/{id}', [App\Http\Controllers\ClientsController::class, 'update_payment']);
|
Route::delete('/shortcodes/{id}', [App\Http\Controllers\ClientsController::class, 'destroy_short_code']);
|
||||||
|
|
||||||
Route::get('/clients/data', [App\Http\Controllers\ClientsController::class, 'fetchData'])->name('clients.data');
|
Route::get('/clients/data', [App\Http\Controllers\ClientsController::class, 'fetchData'])->name('clients.data');
|
||||||
Route::get('/clients/export', [App\Http\Controllers\ClientsController::class, 'export'])->name('clients.export');
|
Route::get('/clients/export', [App\Http\Controllers\ClientsController::class, 'export'])->name('clients.export');
|
||||||
|
|||||||
Reference in New Issue
Block a user