Home News Contact Us Forum About Us Demos Products F.A.Q.
Shopping Cart
You currently have 0 items in your cart.


Recent Events
  • 23/11/2024 Black Friday 2024

    BIG SALE, 30% discount for all our extensions. Use BF24 coupon code. Hurry up the discount is valid till 3 December.

  • 31/12/2023 New Year SALE

    We are glad to announce New Year SALE. 25% discount for all our extensions. Use NY24 coupon code. Hurry up the discount is valid till 7 January.


2Checkout.com, Inc. is an authorized retailer of goods and services provided by ARI Soft. 2CheckOut




Follow us on twitter



Welcome, Guest
Please Login or Register.    Lost Password?

[SOLVED] Year dropdown menu above the table
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: [SOLVED] Year dropdown menu above the table
#58443
[SOLVED] Year dropdown menu above the table 8 Years, 2 Months ago Karma: 0
Is there a way to add a dropdown menu in an article that user can select the year for example, and then the chart will change the data based on that selection?
Last Edit: 2016/09/10 12:17 By vladimir84.
The administrator has disabled public write access.
 
#58444
Re:Year dropdown menu above the table 8 Years, 2 Months ago Karma: 760
The module doesn't contain built-in functionality for this case, but it is possible to use request variables in "WHERE" clause of SQL query. It is possible to load the module into an article and create a HTML drop-down (for year selection) outside the module and send the selected year from the drop-down. It will look like:

Code:


<form action="" method="post">
  <select name="chartYear" onchange="this.form.submit();">
    <option value="2008">2008</option>
    <option value="2009">2009</option>
    <option value="2010">2010</option>
  </select>
</form>



Query will look like:

Code:


SELECT
 id,
 title
FROM
 #__content C
WHERE
 year(C.created) = {$REQUEST:chartYear|empty:'2008'}



Regards,
ARI Soft
The administrator has disabled public write access.
 
#58453
Re:Year dropdown menu above the table 8 Years, 2 Months ago Karma: 0
looks great! thank you very much
The administrator has disabled public write access.
 
#58466
Re:Year dropdown menu above the table 8 Years, 2 Months ago Karma: 0
Just one quick follow-up question. For cumulative charts, this method doesn't consider the previous years (it sums up the values just for the given year.
Do you have any suggestion how can I do this: if the year is 2011, then @runtot = 0, else @runtot = (all previous years until december of the year before chartYearStart)? Can you point me to what should I be looking for?

The query is the same as in the other post:
Code:

SELECT
    CONCAT(q1.d,'-',LPAD(q1.m,2,0)) AS Periodo,
   (@runtot := @runtot + q1.c - q1.l) AS `N. dipendenti`
FROM
   (SELECT
       YEAR(calendar.datefield) AS d,
       month(calendar.datefield) AS m,
       SUM(statistica_assunti_n.assunzioni) AS c,
       SUM(statistica_licenziati_n.licenziamenti) AS l
    FROM  calendar
    INNER JOIN statistica_assunti_n
    ON calendar.datefield = statistica_assunti_n.data_assunzioni
  INNER JOIN statistica_licenziati_n
    ON calendar.datefield = statistica_licenziati_n.data_licenziamenti
WHERE YEAR(datefield) = {$REQUEST:chartYearStart|empty:'2011'} AND datefield <= DATE(NOW())
    GROUP  BY d, m
    ORDER  BY d, m) AS q1, (SELECT @runtot := 0) AS zero

The administrator has disabled public write access.
 
#58467
Re:Year dropdown menu above the table 8 Years, 2 Months ago Karma: 760
Could you specify what init value should be used for @runtot variable if chartYearStart is set to 2015 for example?

Regards,
ARI Soft
The administrator has disabled public write access.
 
#58468
Re:Year dropdown menu above the table 8 Years, 2 Months ago Karma: 0
Maybe it is better that I show you the picture first:


Now, if the year is 2011, then @runtot is 0 and it starts counting the total month after month, adding the current month to previous one.

If I select 2015, this is what I get (I added "WHERE YEAR(datefield) = 2015 AND datefield <= DATE(NOW())":


At 2015-01, it needs to sum all the years-months from before and set it as the initial value.
I was thinking about implementing "CASE WHEN" but I cannot visualize it in my head.
The administrator has disabled public write access.
 
Go to topPage: 12