Live update of dashboard without reloading

In my setting, the cashier keeps watching the dashboard to see when a new invoice arrives for further processing. I wish the dashboard was automatically updated. How may I implement this?

Place the code

<script type="text/javascript">
  setTimeout(function () { location.reload(true); }, 15000);
</script>

on top of the file /application/modules/dashboard/views/index.php

This will automatically reload the dashboard every 15 seconds. To increase / decrease the time just replace the 15000 with a value in seconds multiplied with 1000. (Every 2 Minutes would be 120000 then)

This works but is disadvantageous. If the user happens to be clicking somewhere, he will be interrupted by the reload, or if the create invoice form is open the reload closes it.
Isn’t there an Ajax option to update the 'Recent invoices’and ‘invoice overview’ tables on the background?

No. The dashboard can only be updated via page reload.

Amazing! It was so simple. On top of the above file I just added the following script to update recent invoices table and invoice overview table only, every 5 seconds:

<script>
setInterval("myfunction();",5000);
function myfunction(){
$('#panel-recent-invoices').load(location.href + ' #panel-recent-invoices');
$('#panel-invoice-overview').load(location.href + ' #panel-invoice-overview');
}
</script>
2 Likes