Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vkrmbhaskaran/4681384 to your computer and use it in GitHub Desktop.
Save vkrmbhaskaran/4681384 to your computer and use it in GitHub Desktop.
This FreshPlugs calls requestor and company notes via api and displays them corresponding to a ticket.
<style type="text/css">
.note_plug_data{
border-bottom: 1px solid #666;
padding-top: 5px;
}
.plug-used-div{
margin-top: 5px;
margin-bottom: 5px;
min-height: 19px;
min-width: 230px;
background-size: 18px 18px;
}
h3{
font-size: 16px;
font-color: #666;
}
#company_notes{
padding-top: 5px;
}
</style>
<div id="sample_highrise_widget" title="Company and contact data plug">
<div id="contact_data" class="content note_plug_data"><h3>User Details:</h3><div class="plug-used-div"></div></div>
<div id="company_data" class="content note_plug_data"><h3>Company Details:</h3><div class="plug-used-div"></div></div>
<div id="company_notes" class="content"><h3>Company Notes:</h3><div class="plug-used-div"></div></div>
</div>
<script type="text/javascript">
jQuery('#contact_data div, #company_data div, #company_notes div').addClass('loading-center');
jQuery.getJSON("/contacts/{{ticket.requester.id}}", userCallback);
function userCallback(data)
{
if(data.user.customer_id != null)
{
jQuery.getJSON("/customers/"+data.user.customer_id, displayDetails);
}
else
{
noCompany();
noNotes();
}
if(data.user.description == null)
{
jQuery('#contact_data div').removeClass('loading-center').append("<p>Sorry, no information on this user</p>");
}
else
{
jQuery('#contact_data div').removeClass('loading-center').append("<p>"+data.user.description+"</p>");
}
}
function displayDetails(compdata)
{
if(compdata.customer.description == null)
{
noCompany();
}
else
{
jQuery('#company_data div').removeClass('loading-center').append("<p>"+compdata.customer.description+"</p>");
}
if(compdata.customer.note == null)
{
noNotes()
}
else
{
jQuery('#company_notes div').removeClass('loading-center').append("<p>"+compdata.customer.note+"</p>");
}
}
function noCompany()
{
jQuery('#company_data div').removeClass('loading-center').append("<p>Sorry, no information on this company</p>");
}
function noNotes()
{
jQuery('#company_notes div').removeClass('loading-center').append("<p>Sorry, no notes on this company</p>");
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment