GWM : placeholder auto append
This commit is contained in:
parent
646eba706c
commit
5ed8e9ab0e
@ -379,7 +379,7 @@ 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();
|
||||
@ -390,18 +390,27 @@ class MasterController extends BaseController
|
||||
$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);
|
||||
echo view('layout/footer');
|
||||
@ -410,8 +419,6 @@ 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;
|
||||
|
||||
@ -12,7 +12,10 @@
|
||||
padding-top: 3px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</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);
|
||||
}
|
||||
});
|
||||
|
||||
@ -4,21 +4,20 @@
|
||||
<!-- ============================================================== -->
|
||||
<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;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
</style>
|
||||
@ -214,16 +213,7 @@
|
||||
<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()
|
||||
@ -271,6 +261,8 @@ $("#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');
|
||||
}
|
||||
});
|
||||
@ -321,6 +315,35 @@ $(document).ready(function() {
|
||||
|
||||
}, 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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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,12 +246,6 @@
|
||||
<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()
|
||||
@ -363,6 +355,8 @@ $("#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');
|
||||
}
|
||||
});
|
||||
@ -413,6 +409,35 @@ $(document).ready(function() {
|
||||
|
||||
}, 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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user