GWM : placeholder auto append

This commit is contained in:
bitbucket 2024-06-15 12:02:23 +05:30
parent 646eba706c
commit 5ed8e9ab0e
5 changed files with 188 additions and 134 deletions

View File

@ -379,28 +379,37 @@ class MasterController extends BaseController
$doc_id = $this->request->getVar('doc_id');
$data['docData'] = $this->ClientDocsModel->docPreview($doc_id);
$data['clientData'] = $this->ClientBranchModel->select('client.* , client_branch.*')
$data['clientData'] = $this->ClientBranchModel->select('client.name , client.pan_no ,client_branch.gst_no , client_branch.mobile_no , client_branch.email , client_branch.address , client_branch.country , client_branch.state , client_branch.city , client_branch.pin_code ')
->join('client', 'client_branch.client_id = client.client_id', 'left')
->where('client_branch.id',$data['docData']->client_branch_id)
->get()->getRow();
$DateAndYears = $this->dateAndYearPlaceholder();
$data['header_html'] = $data['docData']->header_html;
$data['footer_html'] = $data['docData']->footer_html;
$data['body_html'] = $data['docData']->body_html;
//replace client details in template content
foreach ($data['clientData'] as $key => $value) {
$placeHolder = '%'.$key.'%';
$data['body_html'] = str_replace($placeHolder,$value,$data['body_html']);
}
//replace Date and Year values in template content
foreach ($DateAndYears as $key => $value) {
$placeHolder = '%'.$key.'%';
$data['body_html'] = str_replace($placeHolder,$value,$data['body_html']);
}
}
$sharedDate = $this->DocsStatusModel->where('client_docs_id',$doc_id)->where('status','Shared')->get()->getRow()->created_at;
if($sharedDate){
$date = \DateTime::createFromFormat('Y-m-d H:i:s', $sharedDate);
$formattedDate = $date->format('d-m-Y');
$data['body_html'] = str_replace('%CD%',$formattedDate,$data['body_html']);
}
echo view('layout/header', ['Data'=>$userData]);
echo view('client_docs_preview',$data);
@ -410,9 +419,7 @@ class MasterController extends BaseController
public function dateAndYearPlaceholder()
{
$currentDate = date('d-m-Y');
$currentYear = date('Y');
$currentMonth = date('m');
@ -439,7 +446,6 @@ class MasterController extends BaseController
}
$DateAndYears = [
"CD" => $currentDate,
"CY" => $currentYear,
"FY" => $financialYear,
"AY" => $assessmentYear,
@ -447,7 +453,6 @@ class MasterController extends BaseController
"Q2" => $q2,
"Q3" => $q3,
"Q4" => $q4,
];
return $DateAndYears;

View File

@ -12,7 +12,10 @@
padding-top: 3px;
}
</style>
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
@ -326,8 +329,7 @@
<script>
document.addEventListener("DOMContentLoaded", function() {
document.querySelector(".download-btnn").addEventListener("click", async function() {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var element = document.querySelector(".card-body");
// Get the HTML content of the element as a string
@ -363,13 +365,12 @@
link.click();
// Remove the link from the document
document.body.removeChild(link);
}
$('.loader').fadeOut();
$('.loader-mask').fadeOut('slow');
},
error: function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').fadeOut('slow');
console.error('Error : ' + error);
}
});

View File

@ -4,21 +4,20 @@
<!-- ============================================================== -->
<style>
.append-text-button {
display: inline-block;
padding: 10px 10px;
font-size: 13px;
color: black; /* Primary color */
background-color: transparent;
border: 2px solid #85a7c9; /* Border color */
border-radius: 4px; /* Rounded corners */
text-align: center;
cursor: pointer; /* Pointer cursor to indicate it's clickable */
transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transition */
font-size: 13px;
color: black;
background-color: transparent;
border-radius: 4px;
text-align: center;
cursor: pointer;
transition: background-color 0.3s ease, color 0.3s ease;
}
.append-text-button:hover {
background-color: #85a7c9; /* Background color on hover */
color: #fff; /* Text color on hover */
font-weight: bold;
color: black;
font-size: 15px;
}
</style>
@ -214,27 +213,18 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.1.0/js/select2.min.js"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/2.19.0/js/md5.min.js"></script>
<script>
$(document).ready(function() {
$('.append-text-button').on('click', function() {
var textToInsert = $(this).text(); // Get the text content of the clicked element
$('#summernote-basic').summernote('focus'); // Focus on the Summernote editor
$('#summernote-basic').summernote('editor.insertText', textToInsert); // Insert the text at the cursor position
});
});
$("#savedata").on("click", function()
{
var body_html = $('#summernote-basic').summernote('code');
formData ={
id : $('#doc_id').val(),
document_name : $('#document_name').val(),
body_html : body_html,
};
var body_html = $('#summernote-basic').summernote('code');
formData ={
id : $('#doc_id').val(),
document_name : $('#document_name').val(),
body_html : body_html,
};
@ -269,8 +259,10 @@ $("#savedata").on("click", function()
});
$(document).ready(function() {
var lastCursorRange;
$('#summernote-basic').summernote({
height: 750,
toolbar: [
@ -295,6 +287,7 @@ $(document).ready(function() {
contents: 'Client Details',
tooltip: 'Client Details Place Holders',
click: function() {
saveCursorPosition();
$('#customModal').modal('show');
}
});
@ -307,6 +300,7 @@ $(document).ready(function() {
contents: 'Date & Year',
tooltip: 'Date & Year Place Holders',
click: function() {
saveCursorPosition();
$('#YearsCustomModal').modal('show');
}
});
@ -318,9 +312,38 @@ $(document).ready(function() {
setTimeout(() =>
{
$('#summernote-basic').summernote('code', $('#body_html').val());
}, 500);
// Save the cursor position
function saveCursorPosition() {
var selection = window.getSelection();
if (selection.rangeCount > 0) {
lastCursorRange = selection.getRangeAt(0);
console.log('Cursor Range Saved:', lastCursorRange);
}
}
// Handle text insertion from modals
$(document).on('click', '.append-text-button', function() {
var textToInsert = $(this).text();
$('#customModal').modal('hide');
$('#YearsCustomModal').modal('hide');
$('#summernote-basic').summernote('focus');
if (lastCursorRange) {
var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(lastCursorRange);
document.execCommand('insertText', false, textToInsert);
console.log('Inserted text:', textToInsert);
} else {
$('#summernote-basic').summernote('editor.insertText', textToInsert);
}
});
});

View File

@ -43,7 +43,7 @@
<style>
.loader-mask {
.loader-mask {
position: fixed;
top: 0;
left: 0;
@ -92,44 +92,44 @@
-webkit-animation-delay: -1s;
animation-delay: -1s;
}
.dropdown-item:focus, .dropdown-item:hover{
background-color: #7ce4dd;
}
@media (min-width: 992px) {
.topnav { height: 56px; }
.logo-lg img{ height:50px; }
.navbar-custom{ height:60px; }
.logo-box .logo{ line-height: 60px; }
.navbar-custom .topnav-menu .nav-link{ line-height: 60px; height: 60px; color:#ffffff; }
.topnav{ margin-top:55px; height:50px; }
}
@media (max-width: 991px){
.logo-sm img{ height:50px; }
}
footer{
padding:10px 15px 10px!important;
}
.page-title-box-alt {
background-color: transparent;
padding: 15px 27px;
box-shadow: none;
margin-bottom: 0;
}
.navbar-custom{
background-color: #85a7c9;
/* background-color: #d44d4dd1; */
}
.select2-container .select2-selection--single{
height: 36px;
border:1px solid #ced4da;
}
.select2-container--default .select2-selection--single .select2-selection__rendered{
line-height: 36px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow{
top:4px;
}
.dropdown-item:focus, .dropdown-item:hover{
background-color: #7ce4dd;
}
@media (min-width: 992px) {
.topnav { height: 56px; }
.logo-lg img{ height:50px; }
.navbar-custom{ height:60px; }
.logo-box .logo{ line-height: 60px; }
.navbar-custom .topnav-menu .nav-link{ line-height: 60px; height: 60px; color:#ffffff; }
.topnav{ margin-top:55px; height:50px; }
}
@media (max-width: 991px){
.logo-sm img{ height:50px; }
}
footer{
padding:10px 15px 10px!important;
}
.page-title-box-alt {
background-color: transparent;
padding: 15px 27px;
box-shadow: none;
margin-bottom: 0;
}
.navbar-custom{
background-color: #85a7c9;
/* background-color: #d44d4dd1; */
}
.select2-container .select2-selection--single{
height: 36px;
border:1px solid #ced4da;
}
.select2-container--default .select2-selection--single .select2-selection__rendered{
line-height: 36px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow{
top:4px;
}

View File

@ -4,21 +4,19 @@
<!-- ============================================================== -->
<style>
.append-text-button {
display: inline-block;
padding: 10px 10px;
font-size: 13px;
color: black; /* Primary color */
color: black;
background-color: transparent;
border: 2px solid #85a7c9; /* Border color */
border-radius: 4px; /* Rounded corners */
border-radius: 4px;
text-align: center;
cursor: pointer; /* Pointer cursor to indicate it's clickable */
transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transition */
cursor: pointer;
transition: background-color 0.3s ease, color 0.3s ease;
}
.append-text-button:hover {
background-color: #85a7c9; /* Background color on hover */
color: #fff; /* Text color on hover */
font-weight: bold;
color: black;
}
</style>
@ -248,46 +246,40 @@
<script>
$(document).ready(function() {
$('.append-text-button').on('click', function() {
var textToInsert = $(this).text(); // Get the text content of the clicked element
$('#summernote-basic').summernote('focus'); // Focus on the Summernote editor
$('#summernote-basic').summernote('editor.insertText', textToInsert); // Insert the text at the cursor position
});
$('.select2-dropdown').select2();
$("#service_group_id").on("change", function()
{
var value = $(this).val();
$.ajax({
url: '<?= base_url("get_service_data") ?>?service_group_id=' + value,
type: 'GET',
dataType: 'json',
success: function(response) {
if (response.count > 0) {
$('#service_id option:not(:first)').remove();
$.each(response.data, function(index, item) {
$('#service_id').append($('<option>', {
value: item.service_id,
text: item.service_name
}));
});
$("#service_group_id").on("change", function()
{
var value = $(this).val();
$.ajax({
url: '<?= base_url("get_service_data") ?>?service_group_id=' + value,
type: 'GET',
dataType: 'json',
success: function(response) {
if (response.count > 0) {
$('#service_id option:not(:first)').remove();
} else {
toastr.warning('Service data not found.', 'Warning');
}
},
error: function(xhr, status, error) {
// Handle error
console.error(xhr.responseText);
toastr.error('Failed to fetch data.', 'Error');
}
});
});
$.each(response.data, function(index, item) {
$('#service_id').append($('<option>', {
value: item.service_id,
text: item.service_name
}));
});
} else {
toastr.warning('Service data not found.', 'Warning');
}
},
error: function(xhr, status, error) {
// Handle error
console.error(xhr.responseText);
toastr.error('Failed to fetch data.', 'Error');
}
});
});
});
$("#savedata").on("click", function()
@ -361,8 +353,10 @@ $("#savedata").on("click", function()
});
$(document).ready(function() {
var lastCursorRange;
$('#summernote-basic').summernote({
height: 750,
toolbar: [
@ -387,6 +381,7 @@ $(document).ready(function() {
contents: 'Client Details',
tooltip: 'Client Details Place Holders',
click: function() {
saveCursorPosition();
$('#customModal').modal('show');
}
});
@ -399,6 +394,7 @@ $(document).ready(function() {
contents: 'Date & Year',
tooltip: 'Date & Year Place Holders',
click: function() {
saveCursorPosition();
$('#YearsCustomModal').modal('show');
}
});
@ -412,6 +408,35 @@ $(document).ready(function() {
$('#summernote-basic').summernote('code', $('#body_html').val());
}, 500);
// Save the cursor position
function saveCursorPosition() {
var selection = window.getSelection();
if (selection.rangeCount > 0) {
lastCursorRange = selection.getRangeAt(0);
console.log('Cursor Range Saved:', lastCursorRange);
}
}
// Handle text insertion from modals
$(document).on('click', '.append-text-button', function() {
var textToInsert = $(this).text();
$('#customModal').modal('hide');
$('#YearsCustomModal').modal('hide');
$('#summernote-basic').summernote('focus');
if (lastCursorRange) {
var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(lastCursorRange);
document.execCommand('insertText', false, textToInsert);
console.log('Inserted text:', textToInsert);
} else {
$('#summernote-basic').summernote('editor.insertText', textToInsert);
}
});
});