Hello
Recently, we had a need to show the total bill of a site in the Comprehensive Analysis Report and export the report as a PDF.
I have worked on a Chrome extension to achieve this.
I believe it will add value to the platform.
Here is the code I wrote:
$('#form > table > tbody > tr > td:nth-child(3)').append('<input id="printBtn" type="submit" value="download" class="btn btn-success" style="display: none;">'); $("#printBtn").click(() => { $("#form > table").hide(); $("#div_weekend").css("margin-top","200px"); window.print(); $("#form > table").show(); $("#div_weekend").css("margin-top","0px"); }) function loadReport() { // get site id var siteID = $("a.cur.online").attr('id').replace(/\D/g, ''); // get selected month var selectedMonth = $('#month').val(); $.ajax({ url: `https://www.iammeter.com/dz/user/ReportResult/${siteID}?reportType=1&Time1=${selectedMonth}`, method: 'GET', success: function(data) { var tempDiv = $('<div>').html(data); var lastTdValue = tempDiv.find('span').text().trim(); var intervalId = setInterval(function() { var selector = '#collapse_overview > div > div:nth-child(1) > table > tbody' if ($(selector).length) { clearInterval(intervalId); // Stop checking $("#printBtn").show(); $(selector).append((`<tr> <th>Total Bill</th> <td> ${lastTdValue} </td> </tr>`)); } }, 1); }, error: function(xhr, status, error) { console.log('Error:', error); } }); } $("#loadBtn").click(function(event){ $("#printBtn").hide(); setTimeout(function() { loadReport() }, 0); }) |
---|