11-09-2020, 05:15 AM,
(This post was last modified: 11-09-2020, 08:43 AM by TurboPT.
Edit Reason: Format code block for PHP
)
|
|
HDeriauFF
Senior Member
|
Posts: 149
Threads: 56
Joined: Dec 2017
|
|
StockUsageGraph.php skipping periods with no sales
Hi folks
any specific reason for skipping periods with no sales by not passing $UsageArray ?
We would rather see everything
Thanks!
|
|
11-10-2020, 01:38 AM,
(This post was last modified: 11-10-2020, 01:42 AM by HDeriauFF.)
|
|
HDeriauFF
Senior Member
|
Posts: 149
Threads: 56
Joined: Dec 2017
|
|
RE: StockUsageGraph.php skipping periods with no sales
TurboPT Wrote:@HDeriauFF
So, looking into this last night, the reason that we break with !$UsageRow is because the loop count handling surrounding the row retrieval can be more than the query rows found, so the loop exits.
There is currently no handling to cover gaps within the period range, and that is what I believe you are looking to have, based on the September = 0 in the list of values?
(which would make a plot in the graph for 9/20, if it was handled)
Correct: to avoid retrieving 12 rows no matter what but only periods within the 12 previous periods, it needs to exist
Looking at the queries, it appears that it should be using query (with the CASE statement) the same as stock usage to get the correct counts without skipping any period if zero
|
|
11-10-2020, 02:13 AM,
(This post was last modified: 11-10-2020, 11:07 AM by TurboPT.
Edit Reason: Format code block for PHP
)
|
|
HDeriauFF
Senior Member
|
Posts: 149
Threads: 56
Joined: Dec 2017
|
|
RE: StockUsageGraph.php skipping periods with no sales
I replaced the queries with the ones used in StockUsage (with minor changes) and now get the expected result
PHP Code: $sql = "SELECT periods.periodno, periods.lastdate_in_period, SUM(CASE WHEN (stockmoves.type=10 Or stockmoves.type=11 OR stockmoves.type=28) AND stockmoves.hidemovt=0 AND stockmoves.stockid = '" . $_GET['StockID'] . "' AND stockmoves.loccode='" . $_GET['StockLocation'] . "' THEN -stockmoves.qty ELSE 0 END) AS qtyused FROM periods LEFT JOIN stockmoves ON periods.periodno=stockmoves.prd WHERE periods.periodno >'" . ($CurrentPeriod - 24) . "' AND stockmoves.loccode='" . $_GET['StockLocation'] . "' GROUP BY periods.periodno, periods.lastdate_in_period ORDER BY periodno ASC LIMIT 24";
|
|
11-12-2020, 11:13 AM,
|
|
TurboPT
Administrator
|
Posts: 727
Threads: 10
Joined: Jun 2012
|
|
RE: StockUsageGraph.php skipping periods with no sales
@ HDeriauFF ... what do you set for $CurrentPeriod in the WHERE clause change for:
PHP Code: WHERE periods.periodno > '" . ($CurrentPeriod - 24) . "'
... I don't see that we have that variable in existing code.
|
|
|