FIX_FE
This commit is contained in:
parent
2bd43c094f
commit
ed828e3e7a
@ -55,7 +55,6 @@ $routes->post("add_advertise_image", "AppContentManagementController::add_advert
|
||||
$routes->post('remove_advertise_image', 'AppContentManagementController::remove_advertise_image');
|
||||
$routes->get("add_image_index", "AppContentManagementController::add_image_index");
|
||||
$routes->get("getAdvertiseImage/(:any)", "AppContentManagementController::getAdvertiseImage/$1");
|
||||
$routes->get("frontend_content", "AppContentManagementController::frontend_content");
|
||||
$routes->get('showAdvertiseImage/(:any)', 'AppContentManagementController::showAdvertiseImage/$1');
|
||||
|
||||
|
||||
@ -794,7 +793,8 @@ $routes->get("ticketHistoryList", "ThzController::ticketHistoryList");
|
||||
|
||||
// General FAQ
|
||||
$routes->match(['get','post','delete'], 'FAQ', 'AppContentManagementController::FAQ');
|
||||
|
||||
$routes->match(['get','post','delete'], 'frontend_content', 'AppContentManagementController::frontend_content');
|
||||
$routes->get("getFEContent", "EmployeeRestController::getFEContent");
|
||||
|
||||
//for testing
|
||||
$routes->group('test', function($routes) {
|
||||
|
||||
@ -136,61 +136,90 @@ class AppContentManagementController extends AdminController
|
||||
|
||||
|
||||
|
||||
// public function getAdvertiseImage($image_id){
|
||||
// $image_data = $this->addImgModel->select('name')->where(['id' => $image_id])->first();
|
||||
// if($image_data){
|
||||
// return $image_data['name'];
|
||||
// }else{
|
||||
// return ;
|
||||
// }
|
||||
// }
|
||||
public function frontend_content()
|
||||
{
|
||||
|
||||
$method = $this->request->getMethod();
|
||||
|
||||
if ($this->request->getMethod() === 'post') {
|
||||
|
||||
$id = $this->request->getPost('fe_id');
|
||||
$data = $this->request->getPost();
|
||||
|
||||
unset($data['fe_id']);
|
||||
|
||||
// Front End Content Area
|
||||
public function frontend_content(){
|
||||
foreach ($data as $k => $v) {
|
||||
if ($v === '' || $v === null) {unset($data[$k]);}
|
||||
}
|
||||
|
||||
// INSERT / UPDATE
|
||||
if (empty($id)) {
|
||||
$status = $this->feContentModel->insert($data);
|
||||
$text = "Created";
|
||||
} else {
|
||||
$status = $this->feContentModel->update($id, $data);
|
||||
$text = "Updated";
|
||||
}
|
||||
|
||||
$data['test'] = $this->feContentModel->findAll();
|
||||
$headerData['tab_name'] = 'Front-End Content';
|
||||
$headerData['page_name'] = 'Front-End Content';
|
||||
return $this->respond([
|
||||
'status' => $status ? true : false,
|
||||
'message' => "Frontend Content $text " . ($status ? 'successfully' : 'failed'),
|
||||
'code' => $status ? 200 : 400,
|
||||
'data' => $data,
|
||||
] , $status ? 200 : 400 );
|
||||
}
|
||||
elseif ($method === 'get') {
|
||||
|
||||
echo view('layout/header', $headerData);
|
||||
echo view('frontend_content_list', $data);
|
||||
echo view('layout/footer');
|
||||
$id = $this->request->getGet('fe_id') ?? null;
|
||||
|
||||
if (!empty($id)) {
|
||||
|
||||
$data['fe_list'] = $this->feContentModel->where('id', $id)->orderBy('id', 'DESC')->findAll();
|
||||
|
||||
if (!empty($data)) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
$data['fe_list'] = $this->feContentModel->orderBy('id', 'DESC')->findAll();
|
||||
|
||||
return $this->loadLayout('frontend_content_list', ['data' => $data,'tab_name' => 'Front-End Content','page_name' => 'Front-End Content']);
|
||||
|
||||
} elseif ($method === 'delete') {
|
||||
|
||||
// $input = $this->request->getRawInput();
|
||||
$id = $this->request->getGet('fe_id'); // ✅ THIS
|
||||
$id = $id ?? null;
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 404,
|
||||
'message' => 'No ID provided for deletion'
|
||||
], 200);
|
||||
}
|
||||
|
||||
$update_status = $this->feContentModel->where('id', $id)->set(['is_active' => 0])->update();
|
||||
|
||||
if ($update_status) {
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'message' => 'Data removed successfully',
|
||||
'fe_id' => $id
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 400,
|
||||
'message' => 'Failed to remove data',
|
||||
'fe_id' => $id
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// public function FAQ()
|
||||
// {
|
||||
|
||||
// $data['tab_name'] = "FAQ's";
|
||||
// $data['page_name'] = "FAQ's";
|
||||
// return $this->loadLayout('faq_list', $data);
|
||||
|
||||
// $returnType = strtolower($this->request->getGet('return_type') ?? 'api');
|
||||
|
||||
// $data = $this->request->getGet();
|
||||
|
||||
// $faq_list = $this->faqModel->select('*')->where('is_active', 1)->orderBy('id', 'desc')->findAll();
|
||||
|
||||
// if ($returnType === 'api') {
|
||||
// if (empty($faq_list)) {
|
||||
// $this->myLogger->logme('error', 'empty tickets in ticket list: ' . json_encode($faq));
|
||||
// return $this->response->setJSON([ 'status' => 'error','message' => 'No Details found'])->setStatusCode(404);
|
||||
// }
|
||||
// } else {
|
||||
// $data['tab_name'] = "FAQ's";
|
||||
// $data['page_name'] = "FAQ's";
|
||||
// return $this->loadLayout('faq_list', $data);
|
||||
// }
|
||||
|
||||
// return $this->response->setJSON([
|
||||
// 'status' => 'success',
|
||||
// 'data' => [],
|
||||
// ])->setStatusCode(200);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public function FAQ()
|
||||
|
||||
@ -34,9 +34,7 @@ class FAQModel extends Model
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
@ -45,12 +43,13 @@ class FAQModel extends Model
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
|
||||
$data['data']['updated_on'] = date('Y-m-d H:i:s');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
@ -19,6 +19,25 @@ class FEContentModel extends Model
|
||||
"is_active",
|
||||
];
|
||||
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
if (empty($data['data']['created_by'])) {
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -66,6 +66,7 @@ class PartnerPosModel extends Model
|
||||
'aadhar',
|
||||
'aadhar_file_name',
|
||||
'is_active',
|
||||
'updated_on',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'manager_id',
|
||||
@ -111,11 +112,9 @@ class PartnerPosModel extends Model
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
@ -124,12 +123,12 @@ class PartnerPosModel extends Model
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
$data['data']['updated_on'] = date('Y-m-d H:i:s');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@ -249,9 +249,6 @@
|
||||
let formData;
|
||||
|
||||
if (type === 'submit') {
|
||||
if (editor) {
|
||||
$('#answer').val(editor.value);
|
||||
}
|
||||
// CREATE FORMDATA FROM FORM
|
||||
formData = new FormData(form);
|
||||
formData.set('return_type', 'web');
|
||||
|
||||
@ -18,28 +18,28 @@
|
||||
<th class="font-weight-medium">Type</th>
|
||||
<th class="font-weight-medium">Content Section</th>
|
||||
<th class="font-weight-medium">Heading</th>
|
||||
<!-- <th class="font-weight-medium">Status</th> -->
|
||||
<th class="font-weight-medium">Status</th>
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if(isset($test)) { $slno = 1; ?>
|
||||
<?php foreach($test as $index => $row) { ?>
|
||||
<?php if(isset($data['fe_list'])) { $slno = 1; ?>
|
||||
<?php foreach($data['fe_list'] as $index => $row) { ?>
|
||||
<tr>
|
||||
<td class="text-center"><?= $slno++; ?></td>
|
||||
<td><?= $row['type']; ?></td>
|
||||
<td><?= $row['content_section']; ?></td>
|
||||
<td><?= $row['heading']; ?></td>
|
||||
<!-- <td>
|
||||
<td>
|
||||
<span class="<?php if($row['is_active'] == 1){ echo 'badge badge-primary'; }else{ echo 'badge badge-danger'; } ?>">
|
||||
<?php if($row['is_active'] == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?>
|
||||
</span>
|
||||
</td> -->
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right" style="cursor: pointer;">
|
||||
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
|
||||
<a class="dropdown-item" data-status="<?= $row['is_active']; ?>" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
|
||||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
||||
</a>
|
||||
<?php if ($row['is_active'] == 1): ?>
|
||||
@ -53,9 +53,9 @@
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<tr>
|
||||
<td colspan="3" class="text-center">No data available</td>
|
||||
</tr>
|
||||
<!-- <tr>
|
||||
<td colspan="6" class="text-center">No data available</td>
|
||||
</tr> -->
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
|
||||
@ -74,8 +74,8 @@
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body p-4">
|
||||
<form id="frontEndContentForm" enctype="multipart/form-data">
|
||||
<input type="hidden" name="pk" id="fe_id"/>
|
||||
<form class="parsley-examples" id="frontEndContentForm" enctype="multipart/form-data">
|
||||
<input type="hidden" name="fe_id" id="fe_id"/>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="col-md-4">
|
||||
@ -91,16 +91,32 @@
|
||||
<input type="text" class="form-control" id="heading" name="heading" placeholder="Enter Heading" required>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="content">Content<span class="text-danger">*</span></label>
|
||||
<textarea id="content" name="content" class="form-control content" rows="5">
|
||||
<!-- <h5>Hello {USER_NAME}, </h5>
|
||||
<p>We create simple, flat & responsive custom mail template.</p>
|
||||
<p>Please, write text here!</p> -->
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="notes">Notes<span class="text-danger">*</span></label>
|
||||
<textarea id="notes" name="notes" class="form-control notes" rows="5">
|
||||
<!-- <h5>Hello {USER_NAME}, </h5>
|
||||
<p>We create simple, flat & responsive custom mail template.</p>
|
||||
<p>Please, write text here!</p> -->
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn app-btn-secondary waves-effect waves-light text-end" onclick="AddContentsAndNotes()">Add Contents And Notes</button>
|
||||
<table>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="button" class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button>
|
||||
<button type="submit" class="btn app-btn-secondary" id="btnSubmit">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -110,7 +126,46 @@
|
||||
|
||||
<script>
|
||||
var table;
|
||||
let content_editor;
|
||||
let notes_editor;
|
||||
$(document).ready(function () {
|
||||
const editorConfig = {
|
||||
buttons: [
|
||||
"undo", "redo", "|",
|
||||
"paragraph",
|
||||
"bold", "italic", "strikethrough", "|",
|
||||
"superscript", "subscript", "|",
|
||||
"ul", "ol", "|",
|
||||
"outdent", "indent", "|",
|
||||
"blockquote", "table", "|",
|
||||
"align", "fontsize", "|",
|
||||
"source"
|
||||
],
|
||||
controls: {
|
||||
paragraph: {
|
||||
list: {
|
||||
p: "Normal",
|
||||
h1: "Heading 1",
|
||||
h2: "Heading 2",
|
||||
h3: "Heading 3",
|
||||
h4: "Heading 4"
|
||||
}
|
||||
}
|
||||
},
|
||||
fontsize: ["8px", "10px", "12px", "14px", "16px", "18px", "20px", "22px", "24px"], // Font sizes in pixels
|
||||
showPlaceholder: false,
|
||||
toolbarButtonSize: "small",
|
||||
toolbarAdaptive: false,
|
||||
saveHeightInStorage: true,
|
||||
minHeight: 400,
|
||||
height: 400, // Optional fixed height
|
||||
defaultMode: "1", // Start in WYSIWYG mode
|
||||
enableDragAndDropFileToEditor: true, // Allow file uploads via drag and drop
|
||||
placeholder: "Start typing here...", // Optional placeholder text
|
||||
};
|
||||
content_editor = Jodit.make("#content", editorConfig);
|
||||
notes_editor = Jodit.make("#notes", editorConfig);
|
||||
|
||||
var ticketsTable = $('#user-table');
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
@ -126,7 +181,7 @@
|
||||
text: 'Add',
|
||||
className: 'btn app-btn-primary mr-2',
|
||||
action: function(e, dt, node, config) {
|
||||
openModal()
|
||||
resetValues();openModal();// $('#btnSubmit').removeClass('d-none');
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -164,9 +219,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
$('.close').click(function(){
|
||||
resetValues()
|
||||
})
|
||||
$('.close').click(function(){ resetValues(); })
|
||||
|
||||
function openModal(){
|
||||
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||
@ -233,87 +286,147 @@
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
function handleSaveEditAndDelete(type = 'submit', el = null) {
|
||||
|
||||
let url = '<?= base_url('util/nhanceBranchMaster') ?>';
|
||||
let form = document.getElementById('frontEndContentForm');
|
||||
let url = '<?= base_url('frontend_content') ?>';
|
||||
let method = "POST";
|
||||
let requestData = {};
|
||||
let fe_id = el ? $(el).data('id') : null;
|
||||
let fe_status = 1;
|
||||
let formData;
|
||||
|
||||
let pk = null;
|
||||
|
||||
|
||||
// If element is passed (from edit/remove button), get its data-id
|
||||
if (el) { pk = $(el).data('id'); }
|
||||
|
||||
requestData.pk = pk;
|
||||
|
||||
if(type == 'submit'){
|
||||
$("#frontEndContentForm").find("input, select, textarea").each(function () {
|
||||
let name = $(this).attr("name");
|
||||
let value = $.trim($(this).val());
|
||||
if (name) requestData[name] = value;
|
||||
});
|
||||
}
|
||||
|
||||
if(type == 'remove'){
|
||||
method = "DELETE";
|
||||
} else if (type == 'edit'){
|
||||
if (type === 'submit') {
|
||||
// CREATE FORMDATA FROM FORM
|
||||
formData = new FormData(form);
|
||||
} else if (type == 'edit') {
|
||||
method = "GET";
|
||||
if (fe_id) url += '?fe_id=' + fe_id ;
|
||||
fe_status = el ? $(el).data('status') : 1;
|
||||
// $('#btnSubmit').addClass('d-none');
|
||||
// let name_text = fe_status ? "Edit" : "View";
|
||||
$('#modalLabel').text('Edit Front End Content');
|
||||
$('#frontEndContentForm')[0].reset();
|
||||
|
||||
} else if (type == 'remove') {
|
||||
method = "DELETE";
|
||||
if (fe_id) url += '?fe_id=' + fe_id ;
|
||||
}
|
||||
|
||||
console.log("type", type)
|
||||
console.log("url", url)
|
||||
console.log("method", method)
|
||||
console.log("requestData", requestData)
|
||||
// if (typeof fe_status !== 'undefined' && fe_status == 1) {
|
||||
// // $('#btnSubmit').addClass('d-none');
|
||||
// return; // optional: stop further actions
|
||||
// }else{
|
||||
// // $('#btnSubmit').removeClass('d-none');
|
||||
// }
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
$('.loader, .loader-mask').fadeIn();
|
||||
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, method, requestData, function(response) {
|
||||
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status) {
|
||||
if(type == 'edit'){
|
||||
appendEditData(response.data);
|
||||
} else if(type == 'remove'){
|
||||
toastr.success(response.message, 'Success');
|
||||
if(el) $(el).closest('tr').remove();
|
||||
window.location.reload();
|
||||
} else if(type == 'submit'){
|
||||
toastr.success(response.message, 'Success');
|
||||
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||
myModal.hide();
|
||||
$('#frontEndContentForm')[0].reset();
|
||||
window.location.reload();
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: method,
|
||||
data: (type === 'submit') ? formData : null,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
console.log('Response:', response);
|
||||
if (response.status === 'success' || response.status === true) {
|
||||
if (type == 'edit') {
|
||||
let record = response.data.fe_list[0]; // single record
|
||||
appendEditData(record);
|
||||
} else if(type == 'remove'){
|
||||
toastr.success(response.message, 'Success');
|
||||
// if(el) $(el).closest('tr').remove();
|
||||
window.location.reload();
|
||||
} else if(type == 'submit'){
|
||||
toastr.success(response.message, 'Success');
|
||||
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||
myModal.hide();
|
||||
$('#frontEndContentForm')[0].reset();
|
||||
window.location.reload();
|
||||
}
|
||||
} else {
|
||||
toastr.warning(response.message, 'Warning');
|
||||
}
|
||||
} else {
|
||||
toastr.warning(response.message, 'Warning');
|
||||
$('.loader, .loader-mask').fadeOut();
|
||||
},
|
||||
error: function () {
|
||||
$('.loader, .loader-mask').fadeOut();
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
});
|
||||
}
|
||||
|
||||
function resetValues(){
|
||||
$('#modalLabel').text('Add Front End Content');
|
||||
$('#frontEndContentForm')[0].reset();
|
||||
if (typeof content_editor !== 'undefined') {
|
||||
content_editor.value = '';
|
||||
}
|
||||
if (typeof notes_editor !== 'undefined') {
|
||||
notes_editor.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
function appendEditData(data){
|
||||
$('#fe_id').val(data[0]['id']);
|
||||
$('#branch_name').val(data[0]['branch_name']);
|
||||
openModal()
|
||||
function appendEditData(data) {
|
||||
$('#frontEndContentForm')[0].reset();
|
||||
$('#fe_id').val(data.id);
|
||||
$('#type').val(data.type);
|
||||
$('#content_section').val(data.content_section);
|
||||
$('#heading').val(data.heading);
|
||||
// $('#content').val(data.content);
|
||||
// $('#notes').val(data.notes);
|
||||
if (content_editor) {
|
||||
content_editor.value = data.content || '';
|
||||
}
|
||||
if (notes_editor) {
|
||||
notes_editor.value = data.notes || '';
|
||||
}
|
||||
openModal();
|
||||
}
|
||||
|
||||
$('#frontEndContentForm').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
const form = this;
|
||||
|
||||
// HTML5 built-in validation
|
||||
if (!form.checkValidity()) {
|
||||
form.reportValidity(); // shows required/pattern tooltips
|
||||
return;
|
||||
}
|
||||
|
||||
// Content validation
|
||||
if (typeof content_editor !== 'undefined') {
|
||||
if (isEditorEmpty(content_editor.value)) {
|
||||
toastr.warning("Content is required", 'Warning');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Notes validation
|
||||
if (typeof notes_editor !== 'undefined') {
|
||||
if (isEditorEmpty(notes_editor.value)) {
|
||||
toastr.warning("Notes is required", 'Warning');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If valid, submit via AJAX
|
||||
handleSaveEditAndDelete('submit');
|
||||
});
|
||||
|
||||
function isEditorEmpty(html) {
|
||||
if (!html) return true;
|
||||
|
||||
// Remove tags, , and trim
|
||||
const text = html
|
||||
.replace(/<[^>]*>/g, '')
|
||||
.replace(/ /g, '')
|
||||
.trim();
|
||||
|
||||
return text.length === 0;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@ -386,7 +386,7 @@
|
||||
$('#con-close-modal').one('shown.bs.modal', function () {
|
||||
$('#manager_id').val(data.manager_id).trigger('change');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$('#aadhar').on('input', function () {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user