- Posts: 25
- Thank you received: 0
donated_amount field in jd_campaigns
- Christian_Belgien
- Topic Author
- Offline
- Junior Member
-
Less
More
14 years 3 weeks ago #10887
by Christian_Belgien
donated_amount field in jd_campaigns was created by Christian_Belgien
The table #__jd_campaigns has a field 'goal' and a field 'donated_amount'.
I wrote a trigger to hide a campaign (actually to unpublish the article in which I display a campaign with the same title as the article) when the goal had been reached:
CREATE TRIGGER `t0r4j_tr_unpublish` AFTER UPDATE ON `t0r4j_jd_campaigns` FOR EACH ROW update t0r4j_content set state = 0 where new.donated_amount = new.goal and title = new.title
However, I do not see the 'donated_amount' field being updated when a donation is made. I have found the donated amount being shown in the table #__jd_donors, and I shall probably have to rewrite the trigger accordingly. But I wonder what is the intention of #__jd_campaigns.donated_amount. Is it my setup that is wanting (that I have broken some code or missed an option,) or has the field indeed no function?
I wrote a trigger to hide a campaign (actually to unpublish the article in which I display a campaign with the same title as the article) when the goal had been reached:
CREATE TRIGGER `t0r4j_tr_unpublish` AFTER UPDATE ON `t0r4j_jd_campaigns` FOR EACH ROW update t0r4j_content set state = 0 where new.donated_amount = new.goal and title = new.title
However, I do not see the 'donated_amount' field being updated when a donation is made. I have found the donated amount being shown in the table #__jd_donors, and I shall probably have to rewrite the trigger accordingly. But I wonder what is the intention of #__jd_campaigns.donated_amount. Is it my setup that is wanting (that I have broken some code or missed an option,) or has the field indeed no function?
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
-
14 years 2 weeks ago #10922
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: donated_amount field in jd_campaigns
Hi
The donated_amount was used in initial release of the extension. Now, it is not used anymore. The donated amount for a campaign now be calculated by sum total amount in #__jd_donors table .
Regards,
Tuan
The donated_amount was used in initial release of the extension. Now, it is not used anymore. The donated amount for a campaign now be calculated by sum total amount in #__jd_donors table .
Regards,
Tuan
Please Log in or Create an account to join the conversation.
- Christian_Belgien
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 25
- Thank you received: 0
14 years 2 weeks ago #10924
by Christian_Belgien
Replied by Christian_Belgien on topic Re: donated_amount field in jd_campaigns
Yes, the total amount donated can be calculated from jd_donors. I figured it out and rewrote the trigger this way:
CREATE TRIGGER `tr_unpublish` AFTER UPDATE ON `#__jd_donors`
FOR EACH ROW UPDATE `#__content` SET `state` = 0 WHERE `title` = (SELECT `title` from (SELECT a.`title` title, a.`goal`, SUM(new.`amount`) amount FROM `#__jd_campaigns` a JOIN `#__jd_donors` b ON a.id = new.`campaign_id` WHERE new.`published` = 1 GROUP BY new.`campaign_id` HAVING amount >= goal) d);
What confused me was, that the field had been left in the jd_campaigns.
Maybe I am still too much wrapped up in the nice theory I learned in the class because I lack practical experience. (The lack of experience I am now trying to do something about with the help of Joomla, Joon Donations, and your help here.) In respect of theory, I was also surprised that jd_donors repeats the personal data of the donor if one donor has made several donations, where the purists and theorists might have created two tables, one for donors and one for donations where the latter table would have a field donor_id as foreign key to the donors table.
CREATE TRIGGER `tr_unpublish` AFTER UPDATE ON `#__jd_donors`
FOR EACH ROW UPDATE `#__content` SET `state` = 0 WHERE `title` = (SELECT `title` from (SELECT a.`title` title, a.`goal`, SUM(new.`amount`) amount FROM `#__jd_campaigns` a JOIN `#__jd_donors` b ON a.id = new.`campaign_id` WHERE new.`published` = 1 GROUP BY new.`campaign_id` HAVING amount >= goal) d);
What confused me was, that the field had been left in the jd_campaigns.
Maybe I am still too much wrapped up in the nice theory I learned in the class because I lack practical experience. (The lack of experience I am now trying to do something about with the help of Joomla, Joon Donations, and your help here.) In respect of theory, I was also surprised that jd_donors repeats the personal data of the donor if one donor has made several donations, where the purists and theorists might have created two tables, one for donors and one for donations where the latter table would have a field donor_id as foreign key to the donors table.
Please Log in or Create an account to join the conversation.
Moderators: Dang Thuc Dam, Dang Dam
Support
Documentation
Information
Copyright © 2025 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.