Advertisement
Guest User

example

a guest
Jan 13th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // AJAX call for fetching data
  2.     $.ajax({
  3.         url: "../resources/db_api.php",
  4.         type: 'POST',
  5.         dataType: 'xml',
  6.         cache: false,
  7.         data: {
  8.             sp: "BS_Fetch_Salesforce_ApprovalBreakdown",
  9.             type: "xml",
  10.             params: {
  11.                 year: selectedYear
  12.             }
  13.         },
  14.         error: function(err) {
  15.             alert(err.statusText);
  16.         },
  17.         success: function(data) {
  18.  
  19.             // Do we have data?
  20.             if (data) {
  21.                 output += '<table class="table table-condensed">';
  22.                 output += '<thead>';
  23.                 output += '<tr>';
  24.                 output += '<th class="small"><input type="checkbox" name="checkAllBreakdown"></th>';
  25.                 output += '<th class="small">Request ID</th>';
  26.                 output += '<th class="small">Month</th>';
  27.                 output += '<th class="small">Year</th>';
  28.                 output += '<th class="small">Priority</th>';
  29.                 output += '<th class="small">Title</th>';
  30.                 output += '<th class="small">Requestor</th>';
  31.                 output += '<th class="small">Date Requested</th>';
  32.                 output += '<th class="small">Desired Completion</th>';
  33.                 output += '<th class="small">Budget</th>';
  34.                 output += '<th class="small">Dev Hours</th>';
  35.                 output += '<th class="small">Size</th>';
  36.                 output += '<th class="small">Status</th>';
  37.                 output += '<th class="small">Outcome</th>';
  38.                 output += '</tr>';
  39.                 output += '</thead>';
  40.                 output += '<tbody name="breakdownResults">';
  41.                 $(data).find('requests').each(function() {
  42.  
  43.                     output += '<tr requestid="' + $(this).find('requestID').text() + '">';
  44.                     output += '<td class="small"><input type="checkbox" name="cbBreakdown" class="breakdownCB" value="' + $(this).find('requestID').text() + '"></td>';
  45.                     output += '<td class="small"><a href="request.php?id=' + $(this).find('requestID').text() + '" target="_BLANK">' + $(this).find('requestID').text() + '</a></td>';
  46.                     output += '<td class="small">' + $(this).find('monthTargetName').text() + '</td>';
  47.                     output += '<td class="small">' + $(this).find('yearTargetName').text() + '</td>';
  48.                     output += '<td class="small">' + $(this).find('priorityLevel').text() + '</td>';
  49.                     output += '<td class="small">' + $(this).find('requestTitle').text() + '</td>';
  50.                     output += '<td class="small"><a href="#' + $(this).find('proposedByNTID').text() + '" target="_BLANK">' + $(this).find('proposedByFirst').text() + ' ' + $(this).find('proposedByLast').text() + '</a></td>';
  51.                     output += '<td class="small">' + $(this).find('dateRequested').text() + '</td>';
  52.                     output += '<td class="small">' + $(this).find('dateNeeded').text() + '</td>';
  53.                     output += '<td class="small">' + ($(this).find('budget').text() ? $(this).find('budget').text() : '-') + '</td>';
  54.                     output += '<td class="small">' + ($(this).find('devHours').text() ? $(this).find('devHours').text() : '-') + '</td>';
  55.                     output += '<td class="small">' + ($(this).find('size').text() ? $(this).find('size').text() : '-') + '</td>';
  56.                     output += '<td class="small">' + $(this).find('requestStatus').text() + '</td>';
  57.                     output += '<td class="small">' + $(this).find('requestOutcome').text() + '</td>';
  58.                     output += '</tr>';
  59.  
  60.                 });
  61.                 output += '</tbody>';
  62.                 output += '</table>';
  63.  
  64.                 // Append the output
  65.                 $('[name=breakdownPlaceholder]').empty().append(output);
  66.                 $('.breakdownFooter').show();
  67.             } else {
  68.                 // No data returned, clean up.
  69.                 $('[name=breakdownPlaceholder]').empty().append('<br /><div class="alert alert-info"><center>No Requests Found</center></div>');
  70.                 $('.breakdownFooter').hide();
  71.             }
  72.  
  73.  
  74.         }
  75.  
  76.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement