Skip to main content

Tax Information Request Details

{% assign TaxInformationRequestID = params.id %}

{% fetchxml recordContact %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="tt_taxinformationrequest">
<attribute name="tt_taxinformationrequestid" />
<attribute name="tt_name" />
<attribute name="tt_contact" />
<order attribute="tt_name" descending="false" />
<filter type="and">
<condition attribute="tt_taxinformationrequestid" operator="eq" uitype="tt_taxinformationrequest" value="{{ TaxInformationRequestID }}" />
</filter>
</entity>
</fetch>
{% endfetchxml %}

{% if recordContact.results.entities.size >= 1 %}
{% assign contact = recordContact.results.entities[0].tt_contact.id %}
{% endif %}
{% include 'Custom Integration - Header' %}
{% assign CRMPortalContact = false %}

{% fetchxml CRMPortalContacts %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="contact">
<attribute name="fullname" />
<attribute name="emailaddress1" />
<attribute name="tt_clientcode" />
<attribute name="tt_managername" />
<attribute name="ownerid" />
<attribute name="contactid" />
<order attribute="fullname" descending="false" />
<filter type="and">
<condition attribute="contactid" operator="eq" uitype="contact" value="{{ contact }}" />
</filter>
<link-entity name="sharepointdocumentlocation" from="regardingobjectid" to="contactid" link-type="inner" alias="ag">
<link-entity name="sharepointdocumentlocation" from="sharepointdocumentlocationid" to="parentsiteorlocation" link-type="inner" alias="ah">
<link-entity name="sharepointsite" from="sharepointsiteid" to="parentsiteorlocation" link-type="inner" alias="ai">
<filter type="and">
<condition attribute="isdefault" operator="eq" value="1" />
</filter>
</link-entity>
</link-entity>
</link-entity>
</entity>
</fetch>
{% endfetchxml %}

{% if CRMPortalContacts.results.entities.size >= 1 %}
{% assign CRMPortalContact = true %}
{% endif %}
{% if CRMPortalContact == false %}

{% fetchxml contactDocuments %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="tt_contactdocuments">
<attribute name='tt_contactdocumentsid' />
<attribute name='tt_name' />
<attribute name='createdon' />
<attribute name='tt_serviceline' />
<order attribute="tt_name" descending="false" />
<filter type="and">
<condition attribute="tt_taxinformationrequest" operator="eq" uitype="tt_taxinformationrequest" value="{{ TaxInformationRequestID }}" />
</filter>
<link-entity name="sharepointdocumentlocation" from="regardingobjectid" to="tt_contactdocumentsid" link-type="inner" alias="aj" />
</entity>
</fetch>
{% endfetchxml %}

{% assign documentSections = "" %}

{% if contactDocuments.results.entities.size >= 1 %}
{% assign records = contactDocuments.results.entities.size | minus: 1 %}
{% for i in (0...records) %}
{% assign contactDocumentName = contactDocuments.results.entities[i].tt_name %}

{% unless documentSections contains contactDocumentName %}
{% assign documentSections = documentSections | append:',' | append: contactDocumentName %}

{% assign contactDocumentRecord = contactDocuments.results.entities[i].tt_contactdocumentsid %}
{% assign contactDocumentServiceLine = contactDocuments.results.entities[i].tt_serviceline.label %}

{% assign RecordToGetSharePointDetails = contactDocumentRecord %}
{% assign EntityLogicalName = "tt_contactdocuments" %}
{% assign EnableUpload = true %}
{% assign EnableDeletion = true %}
{% assign EnableCollaboration = false %}
{% assign sectionName = contactDocumentName %}

{% assign serviceLine = "Corporation Tax" %}

{% include 'Utility/GetSharePointDetails' %}
{% include 'Custom Integration - Main' %}

<script>
var sectionName = "{{ sectionName }}";
// Get the div with the id matching sectionName
var documentSectionDiv = $(`.contactDocumentLocation[id="${sectionName}"]`);
// Select the h2 element with the specified section name
var sectionHeader = $('.section-title').filter(function() {
var text = $(this).text().trim().replace(/[&/.?%]/g, '-');
return text === sectionName;
});
// Get the next sibling element (the table)
var sectionTables = sectionHeader.next();
// Find the table row within sectionDiv
var sectionRows = sectionTables.find('tr');
//Locate the Notes field for the section
var notesElement = sectionTables.find('[aria-label="Notes"]').last();

// Check if there are at least two rows
if (notesElement.length > 0) {
// Get the penultimate row
var containingRow = notesElement.closest('tr');

// Insert the documentSectionDiv after the penultimate table
documentSectionDiv.insertBefore(containingRow);
} else {
// If there are fewer than two tables, just append documentSectionDiv at the end of sectionDiv
sectionTables.append(documentSectionDiv);
}
$(`.contactDocumentLocation[id="${sectionName}"]`).attr("style", "padding:10px");
$(`.contactDocumentLocation[id="${sectionName}"]`).find('h1').text(`Documents`);
$(`.contactDocumentLocation[id="${sectionName}"]`).find('h1').append(`<h5>{{ snippets['PracticeGateway/TIR/Documents/Label'] }}</h5>`);
$(`.contactDocumentLocation[id="${sectionName}"]`).hide();
</script>
{% endunless %}
{% endfor %}
{% endif %}
{% endif %}
<script>
function showDocumentsforSection(targetBooleanRadio)
{
const sectionsWithMultipleShowSelections = [
"#tt_researchanddevelopmentrd",
"#tt_patents"
]
//Exception for questions with four options in the choice:
if (sectionsWithMultipleShowSelections.includes("#" + targetBooleanRadio)) //exception for local choice that includes four options
{
var itemChecked = $("#" + targetBooleanRadio).find('input:checked').length;
if(itemChecked == 1)
{
var checkedItem = $("#" + targetBooleanRadio).find('input:checked')[0].id;
switch ("#" + checkedItem)
{
case "#" + targetBooleanRadio + "_0":
showDocumentsSection(targetBooleanRadio, true);
break;
case "#" + targetBooleanRadio + "_1":
showDocumentsSection(targetBooleanRadio, true);
break;
default:
showDocumentsSection(targetBooleanRadio, false);
break;
}
}
else
{
showDocumentsSection(targetBooleanRadio, false);
}

//Add Onclick Function to Options
$("#" + targetBooleanRadio + "_0").on('click', function() {
showDocumentsSection(targetBooleanRadio, true);
});
$("#" + targetBooleanRadio + "_1").on('click', function() {
showDocumentsSection(targetBooleanRadio, true);
});
$("#" + targetBooleanRadio + "_2").on('click', function() {
showDocumentsSection(targetBooleanRadio, false);
});
$("#" + targetBooleanRadio + "_3").on('click', function() {
showDocumentsSection(targetBooleanRadio, false);
});
}
else
{
var itemChecked = $("#" + targetBooleanRadio).find('input:checked').length;
if(itemChecked == 1)
{
var checkedItem = $("#" + targetBooleanRadio).find('input:checked')[0].id;
switch ("#" + checkedItem)
{
case "#" + targetBooleanRadio + "_0":
showDocumentsSection(targetBooleanRadio, true);
break;
default:
showDocumentsSection(targetBooleanRadio, false);
break;
}
}
else
{
showDocumentsSection(targetBooleanRadio, false);
}

//Add Onclick Function to Options
$("#" + targetBooleanRadio + "_0").on('click', function() {
showDocumentsSection(targetBooleanRadio, true);
});
$("#" + targetBooleanRadio + "_1").on('click', function() {
showDocumentsSection(targetBooleanRadio, false);
});
$("#" + targetBooleanRadio + "_2").on('click', function() {
showDocumentsSection(targetBooleanRadio, false);
});
}
}

function showDocumentsSection(element, visibility)
{
if(visibility)
{
$("#" + element).closest('table').find('.contactDocumentLocation').show();
}
else
{
$("#" + element).closest('table').find('.contactDocumentLocation').hide();
}
}

function showDocumentsByDefault() {
const sections = [
"tt_groupstructure",
"tt_legalprofessionalandconsultancyfees"
];

for (let i = 0; i < sections.length; i++) {
$("#" + sections[i]).closest('table').find('.contactDocumentLocation').show();
}
}
</script>
{% if CRMPortalContact == true %}
<div class="modal fade" id="maintenanceModal" role="dialog">
<div class="modal-dialog modal-lg" id="myModal">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title"><span class="fa fa-edit" aria-hidden="true"></span> Maintenance </h4>
</div>
<div class="modal-body">
<div style="padding:5px; text-align:center;" id="maintenance-image">
<img id="maintenance-documents" style="color:#ffff;width:auto;height:auto;max-width: 90%;vertical-align:middle;" data-id="entityimage.fieldControl-image-control-img" src="../maintenance-documents.png" alt="Maintenance notice for Documents sections">
</div>
</div>
</div>
</div>
</div>

<script>
$('div.contactDocumentLocation').hide()

var sectionName = "Other Documents";
// Get the div with the id matching sectionName
var documentSectionDiv = $(`div#maintenance-image`);
// Select the h2 element with the specified section name
var sectionHeader = $('.tab-title').filter(function() {
var text = $(this).text().trim().replace(/[&/.?%]/g, '-');
return text === sectionName;
});

// Get the next sibling element (the div)
var sectionDiv = sectionHeader.next();
// Find the table within sectionDiv
sectionDiv.append(documentSectionDiv);
</script>

{% elsif CRMPortalContact == false %}
<script>
$('table[data-name="sectionDocumentsCRMPortal"]').parent().hide();
</script>
{% endif %}
<script>
var CRMPortalContact = '{{ CRMPortalContact }}';
console.log(`CRMPortalContact : ${CRMPortalContact}`)
if(CRMPortalContact == "true")
{
$('#subgridDocuments').closest('tr').show();
}
else
{
$('#subgridDocuments').closest('tr').hide();
}
</script>