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'); $doc_id = $this->request->getVar('doc_id');
$data['docData'] = $this->ClientDocsModel->docPreview($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') ->join('client', 'client_branch.client_id = client.client_id', 'left')
->where('client_branch.id',$data['docData']->client_branch_id) ->where('client_branch.id',$data['docData']->client_branch_id)
->get()->getRow(); ->get()->getRow();
$DateAndYears = $this->dateAndYearPlaceholder(); $DateAndYears = $this->dateAndYearPlaceholder();
$data['header_html'] = $data['docData']->header_html; $data['header_html'] = $data['docData']->header_html;
$data['footer_html'] = $data['docData']->footer_html; $data['footer_html'] = $data['docData']->footer_html;
$data['body_html'] = $data['docData']->body_html; $data['body_html'] = $data['docData']->body_html;
//replace client details in template content
foreach ($data['clientData'] as $key => $value) { foreach ($data['clientData'] as $key => $value) {
$placeHolder = '%'.$key.'%'; $placeHolder = '%'.$key.'%';
$data['body_html'] = str_replace($placeHolder,$value,$data['body_html']); $data['body_html'] = str_replace($placeHolder,$value,$data['body_html']);
} }
//replace Date and Year values in template content
foreach ($DateAndYears as $key => $value) { foreach ($DateAndYears as $key => $value) {
$placeHolder = '%'.$key.'%'; $placeHolder = '%'.$key.'%';
$data['body_html'] = str_replace($placeHolder,$value,$data['body_html']); $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('layout/header', ['Data'=>$userData]);
echo view('client_docs_preview',$data); echo view('client_docs_preview',$data);
@ -410,9 +419,7 @@ class MasterController extends BaseController
public function dateAndYearPlaceholder() public function dateAndYearPlaceholder()
{ {
$currentDate = date('d-m-Y');
$currentYear = date('Y'); $currentYear = date('Y');
$currentMonth = date('m'); $currentMonth = date('m');
@ -439,7 +446,6 @@ class MasterController extends BaseController
} }
$DateAndYears = [ $DateAndYears = [
"CD" => $currentDate,
"CY" => $currentYear, "CY" => $currentYear,
"FY" => $financialYear, "FY" => $financialYear,
"AY" => $assessmentYear, "AY" => $assessmentYear,
@ -447,7 +453,6 @@ class MasterController extends BaseController
"Q2" => $q2, "Q2" => $q2,
"Q3" => $q3, "Q3" => $q3,
"Q4" => $q4, "Q4" => $q4,
]; ];
return $DateAndYears; return $DateAndYears;

View File

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

View File

@ -4,21 +4,20 @@
<!-- ============================================================== --> <!-- ============================================================== -->
<style> <style>
.append-text-button { .append-text-button {
display: inline-block;
padding: 10px 10px; font-size: 13px;
font-size: 13px; color: black;
color: black; /* Primary color */ background-color: transparent;
background-color: transparent; border-radius: 4px;
border: 2px solid #85a7c9; /* Border color */ text-align: center;
border-radius: 4px; /* Rounded corners */ cursor: pointer;
text-align: center; transition: background-color 0.3s ease, color 0.3s ease;
cursor: pointer; /* Pointer cursor to indicate it's clickable */
transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transition */
} }
.append-text-button:hover { .append-text-button:hover {
background-color: #85a7c9; /* Background color on hover */ font-weight: bold;
color: #fff; /* Text color on hover */ color: black;
font-size: 15px;
} }
</style> </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/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 src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/2.19.0/js/md5.min.js"></script>
<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() $("#savedata").on("click", function()
{ {
var body_html = $('#summernote-basic').summernote('code'); var body_html = $('#summernote-basic').summernote('code');
formData ={ formData ={
id : $('#doc_id').val(), id : $('#doc_id').val(),
document_name : $('#document_name').val(), document_name : $('#document_name').val(),
body_html : body_html, body_html : body_html,
}; };
@ -269,8 +259,10 @@ $("#savedata").on("click", function()
}); });
$(document).ready(function() { $(document).ready(function() {
var lastCursorRange;
$('#summernote-basic').summernote({ $('#summernote-basic').summernote({
height: 750, height: 750,
toolbar: [ toolbar: [
@ -295,6 +287,7 @@ $(document).ready(function() {
contents: 'Client Details', contents: 'Client Details',
tooltip: 'Client Details Place Holders', tooltip: 'Client Details Place Holders',
click: function() { click: function() {
saveCursorPosition();
$('#customModal').modal('show'); $('#customModal').modal('show');
} }
}); });
@ -307,6 +300,7 @@ $(document).ready(function() {
contents: 'Date & Year', contents: 'Date & Year',
tooltip: 'Date & Year Place Holders', tooltip: 'Date & Year Place Holders',
click: function() { click: function() {
saveCursorPosition();
$('#YearsCustomModal').modal('show'); $('#YearsCustomModal').modal('show');
} }
}); });
@ -318,9 +312,38 @@ $(document).ready(function() {
setTimeout(() => setTimeout(() =>
{ {
$('#summernote-basic').summernote('code', $('#body_html').val()); $('#summernote-basic').summernote('code', $('#body_html').val());
}, 500); }, 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> <style>
.loader-mask { .loader-mask {
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
@ -92,44 +92,44 @@
-webkit-animation-delay: -1s; -webkit-animation-delay: -1s;
animation-delay: -1s; animation-delay: -1s;
} }
.dropdown-item:focus, .dropdown-item:hover{ .dropdown-item:focus, .dropdown-item:hover{
background-color: #7ce4dd; background-color: #7ce4dd;
} }
@media (min-width: 992px) { @media (min-width: 992px) {
.topnav { height: 56px; } .topnav { height: 56px; }
.logo-lg img{ height:50px; } .logo-lg img{ height:50px; }
.navbar-custom{ height:60px; } .navbar-custom{ height:60px; }
.logo-box .logo{ line-height: 60px; } .logo-box .logo{ line-height: 60px; }
.navbar-custom .topnav-menu .nav-link{ line-height: 60px; height: 60px; color:#ffffff; } .navbar-custom .topnav-menu .nav-link{ line-height: 60px; height: 60px; color:#ffffff; }
.topnav{ margin-top:55px; height:50px; } .topnav{ margin-top:55px; height:50px; }
} }
@media (max-width: 991px){ @media (max-width: 991px){
.logo-sm img{ height:50px; } .logo-sm img{ height:50px; }
} }
footer{ footer{
padding:10px 15px 10px!important; padding:10px 15px 10px!important;
} }
.page-title-box-alt { .page-title-box-alt {
background-color: transparent; background-color: transparent;
padding: 15px 27px; padding: 15px 27px;
box-shadow: none; box-shadow: none;
margin-bottom: 0; margin-bottom: 0;
} }
.navbar-custom{ .navbar-custom{
background-color: #85a7c9; background-color: #85a7c9;
/* background-color: #d44d4dd1; */ /* background-color: #d44d4dd1; */
} }
.select2-container .select2-selection--single{ .select2-container .select2-selection--single{
height: 36px; height: 36px;
border:1px solid #ced4da; border:1px solid #ced4da;
} }
.select2-container--default .select2-selection--single .select2-selection__rendered{ .select2-container--default .select2-selection--single .select2-selection__rendered{
line-height: 36px; line-height: 36px;
} }
.select2-container--default .select2-selection--single .select2-selection__arrow{ .select2-container--default .select2-selection--single .select2-selection__arrow{
top:4px; top:4px;
} }

View File

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