From 183531ada093f103c1bffafcaeb54ad4342c849a Mon Sep 17 00:00:00 2001 From: james Date: Wed, 9 Sep 2009 02:38:57 +0000 Subject: [PATCH] Fix 131 --- db/db.code.version.txt | 2 +- db/db.update.131.php | 37 +++++++++++++++++++++++++++++++++++++ db/db.update.131.sql | 0 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 db/db.update.131.php create mode 100644 db/db.update.131.sql diff --git a/db/db.code.version.txt b/db/db.code.version.txt index fd03ab2..a57f6ce 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -130 +131 diff --git a/db/db.update.131.php b/db/db.update.131.php new file mode 100644 index 0000000..197e966 --- /dev/null +++ b/db/db.update.131.php @@ -0,0 +1,37 @@ +id' AND year='$year'"); + while($awardr=mysql_fetch_object($awardq)) { + $prizeq=mysql_query("SELECT cash,scholarship,value,number FROM award_prizes WHERE award_awards_id='$awardr->id'"); + while($prizer=mysql_fetch_object($prizeq)) { + //some people never set the value for some reason, i dunno why.. + $realvalue=max($prizer->cash+$prizer->scholarship,$prizer->value); + $totalvalue=$realvalue*$prizer->number; + $total+=$totalvalue; + } + } + echo "Creating sponsorship for ID: $r->id value: $total\n"; + mysql_query("INSERT INTO sponsorships (sponsors_id,fundraising_type,value,status,probability,year) VALUES ( + '$r->id', + 'awards', + '$total', + 'pending', + '25', + '$year')"); + mysql_query("INSERT INTO sponsors_logs (sponsors_id,dt,users_id,log) VALUES ('$r->id',NOW(),0,'Automatically created sponsorship from existing sponsor. type=award, value=\$$total, status=pending, probability=25%')"); + } + +} + +?> diff --git a/db/db.update.131.sql b/db/db.update.131.sql new file mode 100644 index 0000000..e69de29