Auto refresh listing of common reports to get new data

Ask your questions here.
p.dimitrov
Posts: 166
Joined: 12 Jul 2017, 09:35
Name: Pavel
Location: Varna

Auto refresh listing of common reports to get new data

Post by p.dimitrov »

Hi, is there some way where the item listing of common reports can be automatically refreshed in predetermined interval ? We have some positions where the data can be very dynamic and it would be very good if the listing can be refreshed over 2 or 5mins for example. We tried some plugins for page refresh but this approach isn't good enough.
Didou12
Posts: 487
Joined: 14 Jan 2023, 14:53
Name: Louis
Location: Montreal, Canada

Re: Auto refresh listing of common reports to get new data

Post by Didou12 »

You can use JS. But the page is always opened ? Or you refresh sometimes ?
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
p.dimitrov
Posts: 166
Joined: 12 Jul 2017, 09:35
Name: Pavel
Location: Varna

Re: Auto refresh listing of common reports to get new data

Post by p.dimitrov »

It's open all the time, orders arrive and must be filled with action form so the operator must refresh the page all the time to see if there are new orders.If we use a simple refresh page plugin we could lose data if the form is open, i was thinking maybe something like the "reset filters" button when you have filter panels, but automated, because that only refreshed the list without the whole page.
Didou12
Posts: 487
Joined: 14 Jan 2023, 14:53
Name: Louis
Location: Montreal, Canada

Re: Auto refresh listing of common reports to get new data

Post by Didou12 »

I don’t understand ?

You want to refresh the page OR show all elements. Because if filter doesn’t refresh the page it means : the datas are just hidden in the code OR it’s an Ajax request. I don’t really know. I need to check. But in the first case, it’s not a refresh so new data isn’t available, in the second case I don’t really know how to perform an Ajax request directly, it’s more tricky (but I can check).

But, if you want to refresh the page, you can with a condition (to check if form is opened).

What is the url of the page after the “/“. And it’s for one page or several pages ?
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
p.dimitrov
Posts: 166
Joined: 12 Jul 2017, 09:35
Name: Pavel
Location: Varna

Re: Auto refresh listing of common reports to get new data

Post by p.dimitrov »

Hi, i'm attaching a screenshot. Lets say we have a station where orders must be filled and dispached to the next station when arrived:
LISTING.png
Lets say right now we have 2 orders in the listing. The orders can arrive at any time and the worker doesn't know if they are only 2 orders like in the screenshot or another 3 will show when they refresh the page. Or there is no orders at all and when refreshed 5 orders appear - so the worker must refresh to check all the time. I'm asking if there is a way to auto update the listing to be relatively actual, lets say by 2-5 mins, and not constantly refreshing manually to see if there is new orders.

For example the reset filters button only refreshes the listing when clicked, not the whole page. I'm thinking something like this but timed and automated?
techtr
Posts: 176
Joined: 23 Nov 2021, 04:48
Name: Zach S.
Location: United States

Re: Auto refresh listing of common reports to get new data

Post by techtr »

Hi, I am not sure if there is any fundamental difference between refreshing the whole page and just the listing like you showed in the sample. I had a similar need and I used some extension from the Chrome store which periodically (as stated in the settings) refreshed the whole page. Now, I know these may not necessarily be very safe so I used it for a while, it served its purpose and then I uninstalled it. I do not really remember which one it was, there are probably several. Just search through the Chrome extensions. It is probably not the real solution you are looking for but it may temporarily help you.
p.dimitrov
Posts: 166
Joined: 12 Jul 2017, 09:35
Name: Pavel
Location: Varna

Re: Auto refresh listing of common reports to get new data

Post by p.dimitrov »

Well when the whole page is refreshed if the editing/process form is open you obviously lose it if refreshed, so you have to pay attention to the timer. I tried to find a plugin that pauses the countdown on mouse/keyboard activity, but could not find one... That is not the case if only the list if refreshed, you don't lose open forms.
Didou12
Posts: 487
Joined: 14 Jan 2023, 14:53
Name: Louis
Location: Montreal, Canada

Re: Auto refresh listing of common reports to get new data

Post by Didou12 »

I’ll write you a solution as soon as possible. I’m little busy at this moment. I have some ideas.
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
Didou12
Posts: 487
Joined: 14 Jan 2023, 14:53
Name: Louis
Location: Montreal, Canada

Re: Auto refresh listing of common reports to get new data

Post by Didou12 »

Here is the solution :)

Rukovoditel is very good, so it's easy :)

JS code to add in custom HTML (configuration), before "</body>", in a script tag "<script></script>"
And it can run an ajax request to get data with function already implemented.

To apply the code only on one page of reports:

Code: Select all

var reportsId = 123; //report id
if (window.location.href.endsWith("/index.php?module=reports/view&reports_id=" + reportsId)) {
  setInterval(function() {
    var functionName = "load_common_items_listing_" + reportsId;
    window[functionName]("", 1); //page 1 of the table
  }, 5000); //time in ms
}

To apply the code only on several pages of reports :

Code: Select all

var reportsIds = [123, 456, 789]; //list of report ids
reportsIds.forEach(function(reportsId) {
  if (window.location.href.endsWith("/index.php?module=reports/view&reports_id=" + reportsId)) {
    setInterval(function() {
      var functionName = "load_common_items_listing_" + reportsId;
      window[functionName]("", 1); //page 1 of the table
    }, 5000); //time in ms
  }
});

To apply the code on other pages (dashboard, reports group, ...) where several reports are (code with a loop to get all report ids) :

Code: Select all

if (window.location.href.endsWith("/index.php?module=dashboard/dashboard")) { //I recommend to add an if with URL to be sure the code is apply only on this page, to avoid running for nothing. For example : "/index.php?module=dashboard/reports_groups&id=1" or "/index.php?module=dashboard/dashboard"
  var idArray = [];
  $(".entity_items_listing").each(function() {
    idArray.push($(this).attr("id"));
  });
  idArray.forEach(function(reportsId) {
    setInterval(function() {
      load_items_listing(reportsId,1); //page 1 of the table
    }, 5000); //time in ms
  });
}
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
p.dimitrov
Posts: 166
Joined: 12 Jul 2017, 09:35
Name: Pavel
Location: Varna

Re: Auto refresh listing of common reports to get new data

Post by p.dimitrov »

Thank you so much! I tried something similar, but my code was not that refined and after running for an hour slowed down the server quite a bit and didn't work with windows xp and Mac. I'll certainly give this a try!
Post Reply