{
"Sas Radius Pro Dashboard": "Sas Radius Pro Dashboard",
"logo": "Logo",
"user_profile": "User Profile",
"Search...": "Search...",
"Traffic Report": "Traffic Report",
"Source:": "Source:",
"Wikipedia.com": "Wikipedia.com",
"Jan": "Jan",
"Feb": "Feb",
"Mar": "Mar",
"Apr": "Apr",
"May": "May",
"Jun": "Jun",
"Jul": "Jul",
"Aug": "Aug",
"Sep": "Sep",
"Oct": "Oct",
"Nov": "Nov",
"Dec": "Dec",
"Temperature (°C)": "Temperature (°C)",
"Reggane": "Reggane",
"Search": "Search",
"Home": "Home",
"Messages": "Messages",
"Client List | Found :count entries": "Client List | Found :count entries",
"Template List | Found :count entries": "Template List | Found :count entries",
"Message Settings": "Message Settings",
"Country Code": "Country Code",
"Egypt": "Egypt",
"Libya": "Libya",
"Iraq": "Iraq",
"UAE": "UAE",
"Saudi Arabia": "Saudi Arabia",
"Messaging Service": "Messaging Service",
"Additional keys you can use": "Additional keys you can use",
"Profile": "Profile",
"Expiration Date": "Expiration Date",
"Username": "Username",
"First Name": "First Name",
"Usage Example": "Usage Example",
"Hello": "Hello",
"the": "the",
"monthly package has been activated and will expire on": "monthly package has been activated and will expire on",
"The client will receive it like this": "The client will receive it like this",
"Hello Yasser, the 50GB monthly package has been activated and will expire on": "Hello Yasser, the 50GB monthly package has been activated and will expire on",
"Activation Message": "Activation Message",
"Expiry Message": "Expiry Message",
"About to Expire Subscription": "About to Expire Subscription",
"Upon Subscription Activation": "Upon Subscription Activation",
"Upon Package Renewal": "Upon Package Renewal",
"Upon Package Change": "Upon Package Change",
"Upon Client Deposit": "Upon Client Deposit",
"Upon Withdrawal from Client Balance": "Upon Withdrawal from Client Balance",
"Upon Editing Client Data": "Upon Editing Client Data",
"Upon Adding or Removing Consumption Capacities (GB) for Client": "Upon Adding or Removing Consumption Capacities (GB) for Client",
"Upon Client Deletion": "Upon Client Deletion",
"Upon Manager Login": "Upon Manager Login",
"Upon Manager Deposit": "Upon Manager Deposit",
"Upon Withdrawal from Manager Balance": "Upon Withdrawal from Manager Balance",
"Aggressive Messaging": "Aggressive Messaging",
"Operation Number": "Operation Number",
"Account Symbol": "Account Symbol",
"Last Name": "Last Name",
"Package": "Package",
"Balance": "Balance",
"Return to Menu": "Return to Menu",
"Card Activation Confirmation Message": "Card Activation Confirmation Message",
"Insufficient Balance for Package Activation Message": "Insufficient Balance for Package Activation Message",
"Package Activation Data Message": "Package Activation Data Message",
"Package Activation Confirmation Message": "Package Activation Confirmation Message",
"Enable Card Charging": "Enable Card Charging",
"Menu Message": "Menu Message",
"Successful Card Activation Message": "Successful Card Activation Message",
"Card Entry Request Message": "Card Entry Request Message",
"Bot Preferences": "Bot Preferences",
"Message Sent Successfully!": "Message Sent Successfully!",
"Operations": "Operations",
"Add": "Add",
"View": "View",
"Send Message": "Send Message",
"Change Group": "Change Group",
"Reload": "Reload",
"Filter": "Filter",
"Template": "Template",
"Message": "Message",
"Creation Date": "Creation Date",
"Name": "Name",
"Group": "Group",
"Phone": "Phone",
"Phones": "Phones",
"Notes": "Notes",
"Delete": "Delete",
"Delete Confirmation": "Delete Confirmation",
"Are you sure you want to delete the selected groups?": "Are you sure you want to delete the selected groups?",
"Confirm": "Confirm",
"Cancel": "Cancel",
"Profile data sent successfully:": "Profile data sent successfully:",
"Error sending profile data:": "Error sending profile data:",
"Button with id "aview" not found.": "Button with id "aview" not found.",
"Modal element not provided.": "Modal element not provided.",
"Element with ID "deleteConfirmationModal" not found.": "Element with ID "deleteConfirmationModal" not found.",
"Element with ID "confirmDelete" not found.": "Element with ID "confirmDelete" not found.",
"Element with ID "deletebtn" not found.": "Element with ID "deletebtn" not found.",
"Element with ID "selectAllcheckbox" not found.": "Element with ID "selectAllcheckbox" not found.",
"No checkboxes found.": "No checkboxes found.",
"Please select at least one client to delete.": "Please select at least one client to delete.",
"Selected clients have been successfully deleted.": "Selected clients have been successfully deleted.",
"Error deleting clients: ": "Error deleting clients: ",
"An error occurred while deleting clients.": "An error occurred while deleting clients.",
"No Group": "No Group",
"Default selected": "Default selected",
"Unexpected value, setting to default": "Unexpected value, setting to default",
"Enable Account Balance Display": "Enable Account Balance Display",
"Card Charging": "Card Charging",
"Operation Confirmation": "Operation Confirmation",
"Settings have been saved successfully!": "Settings have been saved successfully!",
"An error occurred:": "An error occurred:",
"An unexpected error occurred.": "An unexpected error occurred.",
"Operation data sent successfully:": "Operation data sent successfully:",
"Error in sending operation data:": "Error in sending operation data:",
"Name input is not in focus.": "Name input is not in focus.",
"Submitting data:": "Submitting data:",
"General": "General",
"Edit": "Edit",
"Add Client": "Add Client",
"Delete Clients": "Delete Clients",
"Add Phone": "Add Phone",
"Phone Number": "Phone Number",
Assistant
"Attach Image": "Attach Image",
"Enter phone number here": "Enter phone number here",
"Enter your message here": "Enter your message here",
"Choose a specific phone number to send the message": "Choose a specific phone number to send the message",
"Enter Session": "Enter Session",
"Choose a specific session to send messages from": "Choose a specific session to send messages from",
"Choose a group to be used as a sender": "Choose a group to be used as a sender",
"Main phone only": "Main phone only",
"Choose a phone number": "Choose a phone number",
"Choose a group": "Choose a group",
"Enter the message to be used": "Enter the message to be used",
"Are you sure you want to send the message?": "Are you sure you want to send the message?",
"Template has been successfully deleted.": "Template has been successfully deleted.",
"An error occurred while deleting the template. Please try again.": "An error occurred while deleting the template. Please try again.",
"Template has been successfully updated.": "Template has been successfully updated.",
"An error occurred while editing the template. Please try again.": "An error occurred while editing the template. Please try again."
}{
"Sas Radius Pro Dashboard": "لوحة مراقبة Sash Radius Pro",
"logo": "شعار",
"user_profile": "ملف المستخدم",
"Search...": "بحث...",
"Traffic Report": "تقرير المرور",
"Source:": "المصدر:",
"Wikipedia.com": "ويكيبيديا.كوم",
"Jan": "يناير",
"Feb": "فبراير",
"Mar": "مارس",
"Apr": "أبريل",
"May": "مايو",
"Jun": "يونيو",
"Jul": "يوليو",
"Aug": "أغسطس",
"Sep": "سبتمبر",
"Oct": "أكتوبر",
"Nov": "نوفمبر",
"Dec": "ديسمبر",
"Temperature (°C)": "درجة الحرارة (°م)",
"Reggane": "رجانة",
"Search": "بحث",
"Home": "الرئيسية",
"Messages": "الرسائل",
"Client List | Found :count entries": "قائمة العملاء | تم العثور على :count مدخلات",
"Template List | Found :count entries": "قائمة القوالب | تم العثور على :count مدخلات",
"Message Settings": "إعدادات الرسائل",
"Country Code": "كود الدولة",
"Egypt": "مصر",
"Libya": "ليبيا",
"Iraq": "العراق",
"UAE": "الإمارات",
"Saudi Arabia": "السعودية",
"Messaging Service": "خدمة الرسائل",
"Additional keys you can use": "مفاتيح إضافية يمكنك استخدامها",
"Profile": "البروفايل",
"Expiration Date": "تاريخ الانتهاء",
"Username": "اسم المستخدم",
"First Name": "الاسم الأول",
"Usage Example": "مثال للاستخدام",
"Hello": "مرحبا",
"the": "ال",
"monthly package has been activated and will expire on": "باقة شهرية تم تفعيلها وسوف تنتهي في",
"The client will receive it like this": "سوف يتلقى العميل ذلك بهذا الشكل",
"Hello Yasser, the 50GB monthly package has been activated and will expire on": "مرحبا ياسر، تم تفعيل باقة 50 جيجابايت الشهرية وسوف تنتهي في",
"Activation Message": "رسالة التفعيل",
"Expiry Message": "رسالة انتهاء الصلاحية",
"About to Expire Subscription": "اشتراك على وشك الانتهاء",
"Upon Subscription Activation": "عند تفعيل الاشتراك",
"Upon Package Renewal": "عند تجديد الباقة",
"Upon Package Change": "عند تغيير الباقة",
"Upon Client Deposit": "عند إيداع العميل",
"Upon Withdrawal from Client Balance": "عند السحب من رصيد العميل",
"Upon Editing Client Data": "عند تعديل بيانات العميل",
"Upon Adding or Removing Consumption Capacities (GB) for Client": "عند إضافة أو إزالة سعات استهلاك (جيجابايت) للعميل",
"Upon Client Deletion": "عند حذف العميل",
"Upon Manager Login": "عند تسجيل دخول المدير",
"Upon Manager Deposit": "عند إيداع المدير",
"Upon Withdrawal from Manager Balance": "عند السحب من رصيد المدير",
"Aggressive Messaging": "الرسائل العنيفة",
"Operation Number": "رقم العملية",
"Account Symbol": "رمز الحساب",
"Last Name": "الاسم الأخير",
"Package": "باقة",
"Balance": "الرصيد",
"Return to Menu": "العودة إلى القائمة",
"Card Activation Confirmation Message": "رسالة تأكيد تفعيل البطاقة",
"Insufficient Balance for Package Activation Message": "رصيد غير كافٍ لتفعيل الباقة",
"Package Activation Data Message": "رسالة بيانات تفعيل الباقة",
"Package Activation Confirmation Message": "رسالة تأكيد تفعيل الباقة",
"Enable Card Charging": "تمكين شحن البطاقة",
"Menu Message": "رسالة القائمة",
"Successful Card Activation Message": "رسالة تفعيل البطاقة الناجحة",
"Card Entry Request Message": "رسالة طلب إدخال البطاقة",
"Bot Preferences": "تفضيلات الروبوت",
"Message Sent Successfully!": "تم إرسال الرسالة بنجاح!",
"Operations": "العمليات",
"Add": "إضافة",
"View": "عرض",
"Send Message": "إرسال رسالة",
"Change Group": "تغيير المجموعة",
"Reload": "إعادة تحميل",
"Filter": "تصفية",
"Template": "القالب",
"Message": "الرسالة",
"Creation Date": "تاريخ الإنشاء",
"Name": "الاسم",
"Group": "المجموعة",
"Phone": "الهاتف",
"Phones": "الهواتف",
"Notes": "ملاحظات",
"Delete": "حذف",
"Delete Confirmation": "تأكيد الحذف",
"Are you sure you want to delete the selected groups?": "هل أنت متأكد من حذف المجموعات المحددة؟",
"Confirm": "موافق",
"Cancel": "إلغاء",
"Profile data sent successfully:": "تم إرسال بيانات الملف الشخصي بنجاح:",
"Error sending profile data:": "خطأ في إرسال بيانات الملف الشخصي:",
"Button with id "aview" not found.": "لم يتم العثور على الزر بمعرف "aview".",
"Modal element not provided.": "لم يتم توفير عنصر المودال.",
"Element with ID "deleteConfirmationModal" not found.": "لم يتم العثور على العنصر بمعرف "deleteConfirmationModal".",
"Element with ID "confirmDelete" not found.": "لم يتم العثور على العنصر بمعرف "confirmDelete".",
"Element with ID "deletebtn" not found.": "لم يتم العثور على العنصر بمعرف "deletebtn".",
"Element with ID "selectAllcheckbox" not found.": "لم يتم العثور على العنصر بمعرف "selectAllcheckbox".",
"No checkboxes found.": "لم يتم العثور على مربعات اختيار.",
"Please select at least one client to delete.": "الرجاء تحديد عميل واحد على الأقل للحذف.",
"Selected clients have been successfully deleted.": "تم حذف العملاء المحددين بنجاح.",
"Error deleting clients: ": "خطأ في حذف العملاء: ",
"An error occurred while deleting clients.": "حدث خطأ أثناء حذف العملاء.",
"No Group": "لا توجد مجموعة",
"Default selected": "تم تحديد الافتراضي",
"Unexpected value, setting to default": "قيمة غير متوقعة، سيتم التعيين على الافتراضي",
"Enable Account Balance Display": "تمكين عرض رصيد الحساب",
"Card Charging": "شحن البطاقة",
"Operation Confirmation": "تأكيد العملية",
"Settings have been saved successfully!": "تم حفظ الإعدادات بنجاح!",
"An error occurred:": "حدث خطأ:",
"An unexpected error occurred.": "حدث خطأ غير متوقع.",
"Operation data sent successfully:": "تم إرسال بيانات العملية بنجاح:",
"Error in sending operation data:": "خطأ في إرسال بيانات العملية:",
"Name input is not in focus.": "حقل الاسم ليس في التركيز.",
"Submitting data:": "جارٍ إرسال البيانات:",
"General": "عام",
"Edit": "تعديل",
"Add Client": "إضافة عميل",
"Delete Clients": "حذف العملاء",
"Add Phone": "إضافة هاتف",
"Phone Number": "رقم الهاتف",
"Attach Image": "إرفاق صورة",
"Enter phone number here": "أدخل رقم الهاتف هنا",
"Enter your message here": "أدخل رسالتك هنا",
"Choose a specific phone number to send the message": "اختر رقم هاتف محدد لإرسال الرسالة",
"Enter Session": "أدخل الجلسة",
"Choose a specific session to send messages from": "اختر جلسة محددة لإرسال الرسائل منها",
"Choose a group to be used as a sender": "اختر مجموعة لاستخدامها كمرسل",
"Main phone only": "الهاتف الرئيسي فقط",
"Choose a phone number": "اختر رقم هاتف",
"Choose a group": "اختر مجموعة",
"Enter the message to be used": "أدخل الرسالة التي سيتم استخدامها",
"Are you sure you want to send the message?": "هل أنت متأكد من أنك تريد إرسال الرسالة؟",
"Template has been successfully deleted.": "تم حذف القالب بنجاح.",
"An error occurred while deleting the template. Please try again.": "حدث خطأ أثناء حذف القالب. يرجى المحاولة مرة أخرى.",
"Template has been successfully updated.": "تم تعديل القالب بنجاح.",
"An error occurred while editing the template. Please try again.": "حدث خطأ أثناء تعديل القالب. يرجى المحاولة مرة أخرى."
}
code
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sas Radius Pro Dashboard</title>
<link rel="stylesheet" href="css/style.css" />
<!-- Bootstrap -->
<link rel="stylesheet" href="css/bootstrap.css" />
<script src="js/bootstrap.js"></script>
<!-- Font Awesome -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link
rel="stylesheet"
href="https://cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css"
/>
<style>
/* Include the modal CSS here as shown above */
.custom-modal {
display: none; /* Hidden by default */
position: fixed;
z-index: 1001; /* Higher than other elements */
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto; /* Enable scroll if needed */
background-color: rgba(0, 0, 0, 0.5); /* Black with opacity */
}
.custom-modal-content {
background-color: #fefefe;
margin: 15% auto; /* 15% from the top and centered */
padding: 20px;
border: 1px solid #888;
width: 40%; /* Adjust as needed */
border-radius: 8px;
position: relative;
}
.custom-modal-content .close {
color: #aaa;
position: absolute;
top: 10px;
right: 20px;
font-size: 28px;
font-weight: bold;
cursor: pointer;
}
.custom-modal-content .close:hover,
.custom-modal-content .close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
.custom-modal-content button {
margin: 10px 5px 0 0;
}
/* Optional: Disable background scrolling when any modal is open */
body.modal-open {
overflow: hidden;
}
</style>
</div>
</div>
</div>
<div class="content_profile_subscriber">
<div class="path">
<span>الرئيسيه</span> /
<span>القوالب</span>
</div>
<div class="nav_container">
<div class="nav_profile">
<div class="item active" data-num="1">
<i class="fa-regular fa-user"></i>
<span>عام</span>
</div>
<div class="item" data-num="2">
<i class="fa-regular fa-pen-to-square"></i>
<span>تعديل</span>
</div>
</div>
</div>
<div class="section_profile general_information active" data-num="1">
<div class="line">
<div class="main_details">
<div class="box_main_details">
<div class="image">
<img
src="./images/profile-img.jpeg"
alt=""
loading="lazy"
/>
</div>
<!-- <h5 class="name">Rick James</h5>
<span class="position">Lead Designer / Developer</span> -->
</div>
<div class="box_btns_utils">
<div class="box">
<a id="delbtn" class="item btn_remove_user">
<i class="fa-solid fa-trash"></i>
<span> حذف</span>
</a>
</div>
</div>
</div>
<div class="info_details">
<div class="row">
<div class="col-12">
<div class="item">
<h6>القالب</h6>
<span id="ttname">{{$tname}}</span>
</div>
<div class="item">
<h6>الرساله</h6>
<span>{{$message}}</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="section_profile update_infomation" data-num="2">
<div class="general_information">
<div class="head">
<h4>اضافه عميل</h4> <!-- "Add Client" -->
</div>
<form action="">
<div class="row">
<div class="col-12">
<div class="input_item">
<label for="">القالب</label>
<input id="tempname" type="text" placeholder="اكتب اي اسم" />
</div>
<div class="input_item">
<label for=""> الرسالة</label>
<textarea name="" id="msg"></textarea>
</div>
</div>
</div>
</form>
</div>
<div class="btns_add">
<button id="add" class="btn_add">موافق</button> <!-- "Confirm" -->
<button class="btn_close">الغاء</button> <!-- "Cancel" -->
</div>
</div>
</div>
</div>
</main>
<!-- Delete Confirmation Modal -->
<div id="deleteConfirmationModal" class="custom-modal">
<div class="custom-modal-content">
<span class="close">×</span>
<h5>تأكيد الحذف</h5> <!-- "Confirm Deletion" -->
<p>هل أنت متأكد من حذف هذا القالب؟</p> <!-- "Are you sure you want to delete this template?" -->
<button class="btn btn-primary" id="confirmDelete">موافق</button> <!-- "Confirm" -->
<button class="btn btn-close" id="cancelDelete">الغاء</button> <!-- "Cancel" -->
</div>
</div>
<!-- Edit Confirmation Modal -->
<div id="editConfirmationModal" class="custom-modal">
<div class="custom-modal-content">
<span class="close">×</span>
<h5>تأكيد التعديل</h5> <!-- "Confirm Edit" -->
<p>هل أنت متأكد من حفظ التعديلات على هذا القالب؟</p> <!-- "Are you sure you want to save the changes to this template?" -->
<button class="btn btn-primary" id="confirmEdit">موافق</button> <!-- "Confirm" -->
<button class="btn btn-close" id="cancelEdit">الغاء</button> <!-- "Cancel" -->
</div>
</div>
<!-- End of Modals -->
<!-- Scripts -->
<script src="js/model.js"></script>
<script src="js/boxs-header.js"></script>
<script src="js/sidebar.js"></script>
<script src="js/nav-profile.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
<!-- Updated JavaScript for Handling Delete and Edit Confirmations -->
<script>
document.addEventListener('DOMContentLoaded', function() {
// Data object to hold template information
let data = {};
const mtname = document.getElementById('ttname').textContent;
const btnsubmit = document.getElementById('add');
const delbtn = document.getElementById('delbtn');
const msgname = document.getElementById('tempname');
const tmsg = document.getElementById('msg');
// **Delete Confirmation Modal Elements**
const deleteConfirmationModal = document.getElementById('deleteConfirmationModal');
const closeDeleteModalElements = deleteConfirmationModal.querySelectorAll('.close, #cancelDelete');
const confirmDeleteButton = document.getElementById('confirmDelete');
// **Edit Confirmation Modal Elements**
const editConfirmationModal = document.getElementById('editConfirmationModal');
const closeEditModalElements = editConfirmationModal.querySelectorAll('.close, #cancelEdit');
const confirmEditButton = document.getElementById('confirmEdit');
/**
* Function to Show a Modal
* @param {HTMLElement} modal - The modal element to display.
*/
function showModal(modal) {
modal.style.display = 'block';
document.body.classList.add('modal-open');
}
/**
* Function to Hide a Modal
* @param {HTMLElement} modal - The modal element to hide.
*/
function hideModal(modal) {
modal.style.display = 'none';
document.body.classList.remove('modal-open');
}
/**
* SETUP for Delete Confirmation Modal
*/
// Function to show the delete confirmation modal
function showDeleteConfirmationModal() {
showModal(deleteConfirmationModal);
}
// Function to hide the delete confirmation modal
function hideDeleteConfirmationModal() {
hideModal(deleteConfirmationModal);
}
// Attach event listeners to close buttons in the delete modal
closeDeleteModalElements.forEach(element => {
element.addEventListener('click', hideDeleteConfirmationModal);
});
// Event listener for "Confirm Delete" button in the delete modal
confirmDeleteButton.addEventListener('click', () => {
hideDeleteConfirmationModal();
performDelete(); // Proceed with deletion
});
// Modify the delete button to show the modal instead of immediate deletion
delbtn.addEventListener('click', function(event){
event.preventDefault(); // Prevent default action if it's a link
showDeleteConfirmationModal();
});
// Function to perform the deletion
function performDelete() {
const deld = { 'name': mtname };
fetch('/del-temp-message', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify(deld)
})
.then(response => response.json())
.then(responseData => {
if (responseData.success) { // Ensure your backend returns a success status
alert('تم حذف القالب بنجاح.'); // "Template has been successfully deleted."
window.location.href = '/temp-messages'; // Redirect after deletion
} else {
console.error('Deletion Error:', responseData.error);
alert('حدث خطأ أثناء حذف القالب. يرجى المحاولة مرة أخرى.'); // "An error occurred while deleting the template. Please try again."
}
})
.catch(error => {
console.error('Fetch Error:', error);
alert('حدث خطأ أثناء حذف القالب. يرجى المحاولة مرة أخرى.'); // "An error occurred while deleting the template. Please try again."
});
}
/**
* SETUP for Edit Confirmation Modal
*/
// Function to show the edit confirmation modal
function showEditConfirmationModal() {
showModal(editConfirmationModal);
}
// Function to hide the edit confirmation modal
function hideEditConfirmationModal() {
hideModal(editConfirmationModal);
}
// Attach event listeners to close buttons in the edit modal
closeEditModalElements.forEach(element => {
element.addEventListener('click', hideEditConfirmationModal);
});
// Event listener for "Confirm Edit" button in the edit modal
confirmEditButton.addEventListener('click', () => {
hideEditConfirmationModal();
performEdit(); // Proceed with editing
});
// Modify the submit (add) button to show the edit confirmation modal instead of immediate submission
btnsubmit.addEventListener('click', function(event){
event.preventDefault(); // Prevent default form submission
showEditConfirmationModal();
});
// Function to perform the edit
function performEdit() {
// Prepare the data to be sent
data.name = mtname;
data.y = msgname.value.trim();
data.s = tmsg.value.trim();
fetch('/edit-template-messages', { // Ensure there's no space at the end of the URL
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(responseData => {
if(responseData.success){
alert('تم تعديل القالب بنجاح.'); // "Template has been successfully updated."
window.location.href = "/temp-messages"; // Redirect after successful edit
} else {
console.error('Edit Error:', responseData.error);
alert('حدث خطأ أثناء تعديل القالب. يرجى المحاولة مرة أخرى.'); // "An error occurred while editing the template. Please try again."
}
})
.catch(error => {
console.error('Fetch Error:', error);
alert('حدث خطأ أثناء تعديل القالب. يرجى المحاولة مرة أخرى.'); // "An error occurred while editing the template. Please try again."
});
}
// Initialize DataTable if needed
$("#table").DataTable({
pagingType: "full_numbers",
scrollX: true,
autoWidth: false,
});
});
</script>
Certainly! I'll help you extract the necessary texts from the provided HTML document, integrate them into your en.json and ar.json translation files, and update the HTML to utilize these translations effectively. Below are the updated files along with explanations.
1. Updated en.json
Here's the updated English translation file (en.json) with all the necessary keys extracted from your HTML document. I've added new keys where translations were missing and ensured consistency with the existing structure.
json
{
"Sas Radius Pro Dashboard": "Sas Radius Pro Dashboard",
"logo": "Logo",
"user_profile": "User Profile",
"Search...": "Search...",
"Traffic Report": "Traffic Report",
"Source:": "Source:",
"Wikipedia.com": "Wikipedia.com",
"Jan": "Jan",
"Feb": "Feb",
"Mar": "Mar",
"Apr": "Apr",
"May": "May",
"Jun": "Jun",
"Jul": "Jul",
"Aug": "Aug",
"Sep": "Sep",
"Oct": "Oct",
"Nov": "Nov",
"Dec": "Dec",
"Temperature (°C)": "Temperature (°C)",
"Reggane": "Reggane",
"Search": "Search",
"Home": "Home",
"Messages": "Messages",
"Client List | Found :count entries": "Client List | Found :count entries",
"Template List | Found :count entries": "Template List | Found :count entries",
"Message Settings": "Message Settings",
"Country Code": "Country Code",
"Egypt": "Egypt",
"Libya": "Libya",
"Iraq": "Iraq",
"UAE": "UAE",
"Saudi Arabia": "Saudi Arabia",
"Messaging Service": "Messaging Service",
"Additional keys you can use": "Additional keys you can use",
"Profile": "Profile",
"Expiration Date": "Expiration Date",
"Username": "Username",
"First Name": "First Name",
"Usage Example": "Usage Example",
"Hello": "Hello",
"the": "the",
"monthly package has been activated and will expire on": "monthly package has been activated and will expire on",
"The client will receive it like this": "The client will receive it like this",
"Hello Yasser, the 50GB monthly package has been activated and will expire on": "Hello Yasser, the 50GB monthly package has been activated and will expire on",
"Activation Message": "Activation Message",
"Expiry Message": "Expiry Message",
"About to Expire Subscription": "About to Expire Subscription",
"Upon Subscription Activation": "Upon Subscription Activation",
"Upon Package Renewal": "Upon Package Renewal",
"Upon Package Change": "Upon Package Change",
"Upon Client Deposit": "Upon Client Deposit",
"Upon Withdrawal from Client Balance": "Upon Withdrawal from Client Balance",
"Upon Editing Client Data": "Upon Editing Client Data",
"Upon Adding or Removing Consumption Capacities (GB) for Client": "Upon Adding or Removing Consumption Capacities (GB) for Client",
"Upon Client Deletion": "Upon Client Deletion",
"Upon Manager Login": "Upon Manager Login",
"Upon Manager Deposit": "Upon Manager Deposit",
"Upon Withdrawal from Manager Balance": "Upon Withdrawal from Manager Balance",
"Aggressive Messaging": "Aggressive Messaging",
"Operation Number": "Operation Number",
"Account Symbol": "Account Symbol",
"Last Name": "Last Name",
"Package": "Package",
"Balance": "Balance",
"Return to Menu": "Return to Menu",
"Card Activation Confirmation Message": "Card Activation Confirmation Message",
"Insufficient Balance for Package Activation Message": "Insufficient Balance for Package Activation Message",
"Package Activation Data Message": "Package Activation Data Message",
"Package Activation Confirmation Message": "Package Activation Confirmation Message",
"Enable Card Charging": "Enable Card Charging",
"Menu Message": "Menu Message",
"Successful Card Activation Message": "Successful Card Activation Message",
"Card Entry Request Message": "Card Entry Request Message",
"Bot Preferences": "Bot Preferences",
"Message Sent Successfully!": "Message Sent Successfully!",
"Operations": "Operations",
"Add": "Add",
"View": "View",
"Send Message": "Send Message",
"Change Group": "Change Group",
"Reload": "Reload",
"Filter": "Filter",
"Template": "Template",
"Message": "Message",
"Creation Date": "Creation Date",
"Name": "Name",
"Group": "Group",
"Phone": "Phone",
"Phones": "Phones",
"Notes": "Notes",
"Delete": "Delete",
"Delete Confirmation": "Delete Confirmation",
"Are you sure you want to delete the selected groups?": "Are you sure you want to delete the selected groups?",
"Confirm": "Confirm",
"Cancel": "Cancel",
"Profile data sent successfully:": "Profile data sent successfully:",
"Error sending profile data:": "Error sending profile data:",
"Button with id \"aview\" not found.": "Button with id \"aview\" not found.",
"Modal element not provided.": "Modal element not provided.",
"Element with ID \"deleteConfirmationModal\" not found.": "Element with ID \"deleteConfirmationModal\" not found.",
"Element with ID \"confirmDelete\" not found.": "Element with ID \"confirmDelete\" not found.",
"Element with ID \"deletebtn\" not found.": "Element with ID \"deletebtn\" not found.",
"Element with ID \"selectAllcheckbox\" not found.": "Element with ID \"selectAllcheckbox\" not found.",
"No checkboxes found.": "No checkboxes found.",
"Please select at least one client to delete.": "Please select at least one client to delete.",
"Selected clients have been successfully deleted.": "Selected clients have been successfully deleted.",
"Error deleting clients: ": "Error deleting clients: ",
"An error occurred while deleting clients.": "An error occurred while deleting clients.",
"No Group": "No Group",
"Default selected": "Default selected",
"Unexpected value, setting to default": "Unexpected value, setting to default",
"Enable Account Balance Display": "Enable Account Balance Display",
"Card Charging": "Card Charging",
"Operation Confirmation": "Operation Confirmation",
"Settings have been saved successfully!": "Settings have been saved successfully!",
"An error occurred:": "An error occurred:",
"An unexpected error occurred.": "An unexpected error occurred.",
"Operation data sent successfully:": "Operation data sent successfully:",
"Error in sending operation data:": "Error in sending operation data:",
"Name input is not in focus.": "Name input is not in focus.",
"Submitting data:": "Submitting data:",
"General": "General",
"Edit": "Edit",
"Add Client": "Add Client",
"Delete Clients": "Delete Clients",
"Add Phone": "Add Phone",
"Phone Number": "Phone Number",
"Attach Image": "Attach Image",
"Enter phone number here": "Enter phone number here",
"Enter your message here": "Enter your message here",
"Choose a specific phone number to send the message": "Choose a specific phone number to send the message",
"Enter Session": "Enter Session",
"Choose a specific session to send messages from": "Choose a specific session to send messages from",
"Choose a group to be used as a sender": "Choose a group to be used as a sender",
"Main phone only": "Main phone only",
"Choose a phone number": "Choose a phone number",
"Choose a group": "Choose a group",
"Enter the message to be used": "Enter the message to be used",
"Are you sure you want to send the message?": "Are you sure you want to send the message?",
"Template has been successfully deleted.": "Template has been successfully deleted.",
"An error occurred while deleting the template. Please try again.": "An error occurred while deleting the template. Please try again.",
"Template has been successfully updated.": "Template has been successfully updated.",
"An error occurred while editing the template. Please try again.": "An error occurred while editing the template. Please try again.",
"Templates": "Templates",
"Enter any name": "Enter any name",
"Confirm Deletion": "Confirm Deletion",
"Are you sure you want to delete this template?": "Are you sure you want to delete this template?",
"Confirm Edit": "Confirm Edit",
"Are you sure you want to save the changes to this template?": "Are you sure you want to save the changes to this template?",
"An error occurred while deleting the template. Please try again.": "An error occurred while deleting the template. Please try again.",
"An error occurred while editing the template. Please try again.": "An error occurred while editing the template. Please try again."
}
2. Updated ar.json
Here's the updated Arabic translation file (ar.json) with all the necessary keys and their corresponding translations extracted from your HTML document.
json
3. Updated HTML Document
Below is the updated HTML document (dashboard.blade.php) with translation functions integrated. All user-facing texts have been replaced with Laravel's __ translation helper to fetch the appropriate translations from your en.json and ar.json files.
html
Key Changes Explained:
Translation Helper Integration:
Blade Syntax: All user-facing texts have been wrapped with Laravel's __ translation helper. For example:
html
<span>{{ __('Home') }}</span>
Consistency: Both static texts and dynamic content within attributes (like alt tags) utilize the translation helper.
Added Translation Keys:
New keys such as "Templates", "Enter any name", "Confirm Deletion", "Confirm Edit", and their corresponding Arabic translations have been added to the JSON files to ensure all texts are translatable.
JavaScript Alerts:
Alert messages within the JavaScript code now utilize Blade syntax to fetch translations. For example:
javascript
alert('{{ __("Template has been successfully deleted.") }}');
This ensures that alerts are displayed in the correct language based on the user's locale.
Accessibility Enhancements:
The alt attributes for images now utilize the translation helper to provide context-sensitive descriptions.
4. Implementation Notes
Localization Configuration:
Ensure that your Laravel application is properly configured for localization. This typically involves setting the default locale and providing mechanisms for users to switch between languages.
Caching Translations:
After updating the translation files, it might be necessary to clear the translation cache to see the changes. You can do this using the following Artisan command:
For any dynamic content that requires translation, ensure that the corresponding keys are present in both en.json and ar.json files.
Consistent Key Usage:
Maintain consistency in your translation keys. Since the keys are based on English phrases, any additions should follow this pattern to avoid confusion.
RTL Support:
Your HTML <html> tag correctly sets the dir attribute based on the locale. Ensure that your CSS handles RTL (Right-To-Left) layouts appropriately to provide a seamless user experience for Arabic users.
By following the above updates and implementation notes, your application will have a robust localization setup, ensuring that all user-facing texts are properly translated and displayed based on the selected language.
If you have any further questions or need additional assistance, feel free to ask!
Not yet included in a published release.
{
"Sas Radius Pro Dashboard": "لوحة مراقبة Sash Radius Pro Dashboard",
"logo": "شعار",
"user_profile": "ملف المستخدم",
"Search...": "بحث...",
"Traffic Report": "تقرير المرور",
"Source:": "المصدر:",
"Wikipedia.com": "ويكيبيديا.كوم",
"Jan": "يناير",
"Feb": "فبراير",
"Mar": "مارس",
"Apr": "أبريل",
"May": "مايو",
"Jun": "يونيو",
"Jul": "يوليو",
"Aug": "أغسطس",
"Sep": "سبتمبر",
"Oct": "أكتوبر",
"Nov": "نوفمبر",
"Dec": "ديسمبر",
"Temperature (°C)": "درجة الحرارة (°م)",
"Reggane": "رجانة",
"Search": "بحث",
"Home": "الرئيسية",
"Messages": "الرسائل",
"Client List | Found :count entries": "قائمة العملاء | تم العثور على :count مدخلات",
"Template List | Found :count entries": "قائمة القوالب | تم العثور على :count مدخلات",
"Message Settings": "إعدادات الرسائل",
"Country Code": "كود الدولة",
"Egypt": "مصر",
"Libya": "ليبيا",
"Iraq": "العراق",
"UAE": "الإمارات",
"Saudi Arabia": "السعودية",
"Messaging Service": "خدمة الرسائل",
"Additional keys you can use": "مفاتيح إضافية يمكنك استخدامها",
"Profile": "البروفايل",
"Expiration Date": "تاريخ الانتهاء",
"Username": "اسم المستخدم",
"First Name": "الاسم الأول",
"Usage Example": "مثال للاستخدام",
"Hello": "مرحبا",
"the": "ال",
"monthly package has been activated and will expire on": "باقة شهرية تم تفعيلها وسوف تنتهي في",
"The client will receive it like this": "سوف يتلقى العميل ذلك بهذا الشكل",
"Hello Yasser, the 50GB monthly package has been activated and will expire on": "مرحبا ياسر، تم تفعيل باقة 50 جيجابايت الشهرية وسوف تنتهي في",
"Activation Message": "رسالة التفعيل",
"Expiry Message": "رسالة انتهاء الصلاحية",
"About to Expire Subscription": "اشتراك على وشك الانتهاء",
"Upon Subscription Activation": "عند تفعيل الاشتراك",
"Upon Package Renewal": "عند تجديد الباقة",
"Upon Package Change": "عند تغيير الباقة",
"Upon Client Deposit": "عند إيداع العميل",
"Upon Withdrawal from Client Balance": "عند السحب من رصيد العميل",
"Upon Editing Client Data": "عند تعديل بيانات العميل",
"Upon Adding or Removing Consumption Capacities (GB) for Client": "عند إضافة أو إزالة سعات استهلاك (جيجابايت) للعميل",
"Upon Client Deletion": "عند حذف العميل",
"Upon Manager Login": "عند تسجيل دخول المدير",
"Upon Manager Deposit": "عند إيداع المدير",
"Upon Withdrawal from Manager Balance": "عند السحب من رصيد المدير",
"Aggressive Messaging": "الرسائل العنيفة",
"Operation Number": "رقم العملية",
"Account Symbol": "رمز الحساب",
"Last Name": "الاسم الأخير",
"Package": "باقة",
"Balance": "الرصيد",
"Return to Menu": "العودة إلى القائمة",
"Card Activation Confirmation Message": "رسالة تأكيد تفعيل البطاقة",
"Insufficient Balance for Package Activation Message": "رصيد غير كافٍ لتفعيل الباقة",
"Package Activation Data Message": "رسالة بيانات تفعيل الباقة",
"Package Activation Confirmation Message": "رسالة تأكيد تفعيل الباقة",
"Enable Card Charging": "تمكين شحن البطاقة",
"Menu Message": "رسالة القائمة",
"Successful Card Activation Message": "رسالة تفعيل البطاقة الناجحة",
"Card Entry Request Message": "رسالة طلب إدخال البطاقة",
"Bot Preferences": "تفضيلات الروبوت",
"Message Sent Successfully!": "تم إرسال الرسالة بنجاح!",
"Operations": "العمليات",
"Add": "إضافة",
"View": "عرض",
"Send Message": "إرسال رسالة",
"Change Group": "تغيير المجموعة",
"Reload": "إعادة تحميل",
"Filter": "تصفية",
"Template": "القالب",
"Message": "الرسالة",
"Creation Date": "تاريخ الإنشاء",
"Name": "الاسم",
"Group": "المجموعة",
"Phone": "الهاتف",
"Phones": "الهواتف",
"Notes": "ملاحظات",
"Delete": "حذف",
"Delete Confirmation": "تأكيد الحذف",
"Are you sure you want to delete the selected groups?": "هل أنت متأكد من حذف المجموعات المحددة؟",
"Confirm": "موافق",
"Cancel": "إلغاء",
"Profile data sent successfully:": "تم إرسال بيانات الملف الشخصي بنجاح:",
"Error sending profile data:": "خطأ في إرسال بيانات الملف الشخصي:",
"Button with id \"aview\" not found.": "لم يتم العثور على الزر بمعرف \"aview\".",
"Modal element not provided.": "لم يتم توفير عنصر المودال.",
"Element with ID \"deleteConfirmationModal\" not found.": "لم يتم العثور على العنصر بمعرف \"deleteConfirmationModal\".",
"Element with ID \"confirmDelete\" not found.": "لم يتم العثور على العنصر بمعرف \"confirmDelete\".",
"Element with ID \"deletebtn\" not found.": "لم يتم العثور على العنصر بمعرف \"deletebtn\".",
"Element with ID \"selectAllcheckbox\" not found.": "لم يتم العثور على العنصر بمعرف \"selectAllcheckbox\".",
"No checkboxes found.": "لم يتم العثور على مربعات اختيار.",
"Please select at least one client to delete.": "الرجاء تحديد عميل واحد على الأقل للحذف.",
"Selected clients have been successfully deleted.": "تم حذف العملاء المحددين بنجاح.",
"Error deleting clients: ": "خطأ في حذف العملاء: ",
"An error occurred while deleting clients.": "حدث خطأ أثناء حذف العملاء.",
"No Group": "لا توجد مجموعة",
"Default selected": "تم تحديد الافتراضي",
"Unexpected value, setting to default": "قيمة غير متوقعة، سيتم التعيين على الافتراضي",
"Enable Account Balance Display": "تمكين عرض رصيد الحساب",
"Card Charging": "شحن البطاقة",
"Operation Confirmation": "تأكيد العملية",
"Settings have been saved successfully!": "تم حفظ الإعدادات بنجاح!",
"An error occurred:": "حدث خطأ:",
"An unexpected error occurred.": "حدث خطأ غير متوقع.",
"Operation data sent successfully:": "تم إرسال بيانات العملية بنجاح:",
"Error in sending operation data:": "خطأ في إرسال بيانات العملية:",
"Name input is not in focus.": "حقل الاسم ليس في التركيز.",
"Submitting data:": "جارٍ إرسال البيانات:",
"General": "عام",
"Edit": "تعديل",
"Add Client": "إضافة عميل",
"Delete Clients": "حذف العملاء",
"Add Phone": "إضافة هاتف",
"Phone Number": "رقم الهاتف",
"Attach Image": "إرفاق صورة",
"Enter phone number here": "أدخل رقم الهاتف هنا",
"Enter your message here": "أدخل رسالتك هنا",
"Choose a specific phone number to send the message": "اختر رقم هاتف محدد لإرسال الرسالة",
"Enter Session": "أدخل الجلسة",
"Choose a specific session to send messages from": "اختر جلسة محددة لإرسال الرسائل منها",
"Choose a group to be used as a sender": "اختر مجموعة لاستخدامها كمرسل",
"Main phone only": "الهاتف الرئيسي فقط",
"Choose a phone number": "اختر رقم هاتف",
"Choose a group": "اختر مجموعة",
"Enter the message to be used": "أدخل الرسالة التي سيتم استخدامها",
"Are you sure you want to send the message?": "هل أنت متأكد من أنك تريد إرسال الرسالة؟",
"Template has been successfully deleted.": "تم حذف القالب بنجاح.",
"An error occurred while deleting the template. Please try again.": "حدث خطأ أثناء حذف القالب. يرجى المحاولة مرة أخرى.",
"Template has been successfully updated.": "تم تعديل القالب بنجاح.",
"An error occurred while editing the template. Please try again.": "حدث خطأ أثناء تعديل القالب. يرجى المحاولة مرة أخرى.",
"Templates": "القوالب",
"Enter any name": "اكتب أي اسم",
"Confirm Deletion": "تأكيد الحذف",
"Are you sure you want to delete this template?": "هل أنت متأكد من حذف هذا القالب؟",
"Confirm Edit": "تأكيد التعديل",
"Are you sure you want to save the changes to this template?": "هل أنت متأكد من حفظ التعديلات على هذا القالب؟",
"An error occurred while deleting the template. Please try again.": "حدث خطأ أثناء حذف القالب. يرجى المحاولة مرة أخرى.",
"An error occurred while editing the template. Please try again.": "حدث خطأ أثناء تعديل القالب. يرجى المحاولة مرة أخرى."
}
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}" dir="{{ app()->getLocale() == 'ar' ? 'rtl' : 'ltr' }}">
<head>
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{ __('Sas Radius Pro Dashboard') }}</title>
<link rel="stylesheet" href="css/style.css" />
<!-- Bootstrap -->
<link rel="stylesheet" href="css/bootstrap.css" />
<script src="js/bootstrap.js"></script>
<!-- Font Awesome -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link
rel="stylesheet"
href="https://cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css"
/>
<style>
/* Include the modal CSS here as shown above */
.custom-modal {
display: none; /* Hidden by default */
position: fixed;
z-index: 1001; /* Higher than other elements */
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto; /* Enable scroll if needed */
background-color: rgba(0, 0, 0, 0.5); /* Black with opacity */
}
.custom-modal-content {
background-color: #fefefe;
margin: 15% auto; /* 15% from the top and centered */
padding: 20px;
border: 1px solid #888;
width: 40%; /* Adjust as needed */
border-radius: 8px;
position: relative;
}
.custom-modal-content .close {
color: #aaa;
position: absolute;
top: 10px;
right: 20px;
font-size: 28px;
font-weight: bold;
cursor: pointer;
}
.custom-modal-content .close:hover,
.custom-modal-content .close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
.custom-modal-content button {
margin: 10px 5px 0 0;
}
/* Optional: Disable background scrolling when any modal is open */
body.modal-open {
overflow: hidden;
}
</style>
</head>
<body>
<main>
<div class="overflow_sidebar"></div>
<!-- start sidebar -->
<div class="sidebar">
@include('include.sidebar')
</div>
<!-- end sidebar -->
<div class="content_page">
<div class="header">
<div class="left">
<div class="icon_menu">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"
/>
</svg>
</div>
<div class="logo_header">
<img src="images/logo.png" alt="{{ __('logo') }}" loading="lazy" />
</div>
<div class="input_search">
<input type="text" placeholder="{{ __('Search...') }}" />
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"
/>
</svg>
</div>
</div>
<div class="right">
@include('include.translation')
<div class="notfication">
<div class="head">
<div class="icon">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0M3.124 7.5A8.969 8.969 0 015.292 3m13.416 0a8.969 8.969 0 012.168 4.5"
/>
</svg>
</div>
</div>
</div>
<div class="nav_item">
<div class="head">
<img
class="img_profile"
src="images/user-1.jpg"
alt="{{ __('user_profile') }}"
loading="lazy"
/>
</div>
@include('include.profile')
</div>
</div>
</div>
<div class="content_profile_subscriber">
<div class="path">
<span>{{ __('Home') }}</span> /
<span>{{ __('Templates') }}</span>
</div>
<div class="nav_container">
<div class="nav_profile">
<div class="item active" data-num="1">
<i class="fa-regular fa-user"></i>
<span>{{ __('General') }}</span>
</div>
<div class="item" data-num="2">
<i class="fa-regular fa-pen-to-square"></i>
<span>{{ __('Edit') }}</span>
</div>
</div>
</div>
<div class="section_profile general_information active" data-num="1">
<div class="line">
<div class="main_details">
<div class="box_main_details">
<div class="image">
<img
src="./images/profile-img.jpeg"
alt="{{ __('Profile') }}"
loading="lazy"
/>
</div>
<!-- <h5 class="name">Rick James</h5>
<span class="position">Lead Designer / Developer</span> -->
</div>
<div class="box_btns_utils">
<div class="box">
<a id="delbtn" class="item btn_remove_user">
<i class="fa-solid fa-trash"></i>
<span>{{ __('Delete') }}</span>
</a>
</div>
</div>
</div>
<div class="info_details">
<div class="row">
<div class="col-12">
<div class="item">
<h6>{{ __('Template') }}</h6>
<span id="ttname">{{$tname}}</span>
</div>
<div class="item">
<h6>{{ __('Message') }}</h6>
<span>{{$message}}</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="section_profile update_infomation" data-num="2">
<div class="general_information">
<div class="head">
<h4>{{ __('Add Client') }}</h4>
</div>
<form action="">
<div class="row">
<div class="col-12">
<div class="input_item">
<label for="">{{ __('Template') }}</label>
<input id="tempname" type="text" placeholder="{{ __('Enter any name') }}" />
</div>
<div class="input_item">
<label for="">{{ __('Message') }}</label>
<textarea name="" id="msg"></textarea>
</div>
</div>
</div>
</form>
</div>
<div class="btns_add">
<button id="add" class="btn_add">{{ __('Confirm') }}</button>
<button class="btn_close">{{ __('Cancel') }}</button>
</div>
</div>
</div>
</div>
</main>
<!-- Delete Confirmation Modal -->
<div id="deleteConfirmationModal" class="custom-modal">
<div class="custom-modal-content">
<span class="close">×</span>
<h5>{{ __('Confirm Deletion') }}</h5>
<p>{{ __('Are you sure you want to delete this template?') }}</p>
<button class="btn btn-primary" id="confirmDelete">{{ __('Confirm') }}</button>
<button class="btn btn-close" id="cancelDelete">{{ __('Cancel') }}</button>
</div>
</div>
<!-- Edit Confirmation Modal -->
<div id="editConfirmationModal" class="custom-modal">
<div class="custom-modal-content">
<span class="close">×</span>
<h5>{{ __('Confirm Edit') }}</h5>
<p>{{ __('Are you sure you want to save the changes to this template?') }}</p>
<button class="btn btn-primary" id="confirmEdit">{{ __('Confirm') }}</button>
<button class="btn btn-close" id="cancelEdit">{{ __('Cancel') }}</button>
</div>
</div>
<!-- End of Modals -->
<!-- Scripts -->
<script src="js/model.js"></script>
<script src="js/boxs-header.js"></script>
<script src="js/sidebar.js"></script>
<script src="js/nav-profile.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
<!-- Updated JavaScript for Handling Delete and Edit Confirmations -->
<script>
document.addEventListener('DOMContentLoaded', function() {
// Data object to hold template information
let data = {};
const mtname = document.getElementById('ttname').textContent;
const btnsubmit = document.getElementById('add');
const delbtn = document.getElementById('delbtn');
const msgname = document.getElementById('tempname');
const tmsg = document.getElementById('msg');
// **Delete Confirmation Modal Elements**
const deleteConfirmationModal = document.getElementById('deleteConfirmationModal');
const closeDeleteModalElements = deleteConfirmationModal.querySelectorAll('.close, #cancelDelete');
const confirmDeleteButton = document.getElementById('confirmDelete');
// **Edit Confirmation Modal Elements**
const editConfirmationModal = document.getElementById('editConfirmationModal');
const closeEditModalElements = editConfirmationModal.querySelectorAll('.close, #cancelEdit');
const confirmEditButton = document.getElementById('confirmEdit');
/**
* Function to Show a Modal
* @param {HTMLElement} modal - The modal element to display.
*/
function showModal(modal) {
modal.style.display = 'block';
document.body.classList.add('modal-open');
}
/**
* Function to Hide a Modal
* @param {HTMLElement} modal - The modal element to hide.
*/
function hideModal(modal) {
modal.style.display = 'none';
document.body.classList.remove('modal-open');
}
/**
* SETUP for Delete Confirmation Modal
*/
// Function to show the delete confirmation modal
function showDeleteConfirmationModal() {
showModal(deleteConfirmationModal);
}
// Function to hide the delete confirmation modal
function hideDeleteConfirmationModal() {
hideModal(deleteConfirmationModal);
}
// Attach event listeners to close buttons in the delete modal
closeDeleteModalElements.forEach(element => {
element.addEventListener('click', hideDeleteConfirmationModal);
});
// Event listener for "Confirm Delete" button in the delete modal
confirmDeleteButton.addEventListener('click', () => {
hideDeleteConfirmationModal();
performDelete(); // Proceed with deletion
});
// Modify the delete button to show the modal instead of immediate deletion
delbtn.addEventListener('click', function(event){
event.preventDefault(); // Prevent default action if it's a link
showDeleteConfirmationModal();
});
// Function to perform the deletion
function performDelete() {
const deld = { 'name': mtname };
fetch('/del-temp-message', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify(deld)
})
.then(response => response.json())
.then(responseData => {
if (responseData.success) { // Ensure your backend returns a success status
alert('{{ __("Template has been successfully deleted.") }}');
window.location.href = '/temp-messages'; // Redirect after deletion
} else {
console.error('Deletion Error:', responseData.error);
alert('{{ __("An error occurred while deleting the template. Please try again.") }}');
}
})
.catch(error => {
console.error('Fetch Error:', error);
alert('{{ __("An error occurred while deleting the template. Please try again.") }}');
});
}
/**
* SETUP for Edit Confirmation Modal
*/
// Function to show the edit confirmation modal
function showEditConfirmationModal() {
showModal(editConfirmationModal);
}
// Function to hide the edit confirmation modal
function hideEditConfirmationModal() {
hideModal(editConfirmationModal);
}
// Attach event listeners to close buttons in the edit modal
closeEditModalElements.forEach(element => {
element.addEventListener('click', hideEditConfirmationModal);
});
// Event listener for "Confirm Edit" button in the edit modal
confirmEditButton.addEventListener('click', () => {
hideEditConfirmationModal();
performEdit(); // Proceed with editing
});
// Modify the submit (add) button to show the edit confirmation modal instead of immediate submission
btnsubmit.addEventListener('click', function(event){
event.preventDefault(); // Prevent default form submission
showEditConfirmationModal();
});
// Function to perform the edit
function performEdit() {
// Prepare the data to be sent
data.name = mtname;
data.y = msgname.value.trim();
data.s = tmsg.value.trim();
fetch('/edit-template-messages', { // Ensure there's no space at the end of the URL
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(responseData => {
if(responseData.success){
alert('{{ __("Template has been successfully updated.") }}');
window.location.href = "/temp-messages"; // Redirect after successful edit
} else {
console.error('Edit Error:', responseData.error);
alert('{{ __("An error occurred while editing the template. Please try again.") }}');
}
})
.catch(error => {
console.error('Fetch Error:', error);
alert('{{ __("An error occurred while editing the template. Please try again.") }}');
});
}
// Initialize DataTable if needed
$("#table").DataTable({
pagingType: "full_numbers",
scrollX: true,
autoWidth: false,
});
});
</script>
</body>
</html>