Compare commits

..

173 Commits

Author SHA1 Message Date
dave
5bae61bb04 Allow existing parents, principals, mentors, and alumni to create mutlirole accounts. 2010-02-10 14:58:10 +00:00
james
0e9334eaa1 change teh version to 2.2.9 for development in preparation of 2.3.0 2009-09-09 00:35:33 +00:00
dave
2b10dc2131 - Add an example for how to use a draggable sortable list to the prize tag.
- Add jquery-ui to the scripts, it has support for drag and drop, as well as windows, will convert
the popup window to the jquery-ui version next, so we don't have to maintain our own.
2009-09-08 22:02:14 +00:00
dave
daf3314c03 - Fix the sql database for hte last commit
- move code around in curl for less indentation
2009-09-08 17:39:57 +00:00
dave
62941df880 - new htabs
- beginnings of a jquery award editor
- sfiab->sfiab award downloading 
- move most javascript into a sfiab.js file, so it can be cached and only
  pulled from the server once (instead of inline with the code each time)
2009-09-08 17:34:52 +00:00
dave
d91ac62015 - Convert award sources to fair users 2009-09-06 00:07:26 +00:00
dave
dbff1e0bbc - Move the curl query to its own file, and modify the two spots that it's used
to just call the function
- Rework the fair editor for user friendliness.
- Beginnings of sfiab->sfiab award download (and winner upload)
2009-09-05 23:04:14 +00:00
james
fd95489426 hopefully the last test 2009-08-20 14:37:15 +00:00
james
968d30a448 Testing stupid encoding on commit emails 2009-08-20 14:34:51 +00:00
james
8f344d2f8b test five 2009-08-20 14:03:54 +00:00
james
14e0d624d8 test four 2009-08-20 14:02:54 +00:00
james
4115d2993e itest threee 2009-08-20 14:01:46 +00:00
james
c2205f7def Testi two 2009-08-20 13:59:02 +00:00
james
88936f52af Test 2009-08-20 13:56:34 +00:00
james
a7e2d840bc commit daves changes from earlier today 2009-05-13 02:25:50 +00:00
james
86d4e37448 fix for timeslot check 2009-05-11 16:30:05 +00:00
dave
74d0c53dd3 - Update the printing of the user list, if it's a fair, print the fair name too. 2009-05-06 04:46:08 +00:00
dave
036cf2c295 - And the server side of the JSON stats. We should probably rename this file
since it has nothing to do with XML anymore.
2009-05-05 07:27:38 +00:00
dave
687d4ea875 - Convert fair stats to JSON 2009-05-05 07:27:02 +00:00
dave
ee978816b2 - More accurate info in fair_stats
- Enable the new fields in the fair editor
2009-05-04 06:41:02 +00:00
dave
4eea632521 - Sneak in a database update. We can use the fairs table to enable stats, awards, and winners.
For a feeder fair specifying the upstream fair, this means the feeder
	fair will request to download stats, download awards, and upload winners. 
	For the upstream fair specifying feeder fairs, this means the feeder
	fair is allowed to upload stats, download awards, and upload winners.

--This line, and those	below, will be ignored--

M    db/db.update.128.sql
2009-05-04 06:32:36 +00:00
dave
f58fd10749 - Serverside for the stats gathering. 2009-05-04 06:13:44 +00:00
dave
66fe2ed34f - Add remaining stats gathering info for SFFBC, try to make them generic so
anyone could use them.
2009-05-04 06:13:15 +00:00
dave
0f450e4426 - Remove the XML print from the stats upload, we can add that back in later as
something like "view/edit xml".
- Add a master list of all the stats we understand
- Map stats into YSF stats, so this file can be used as the YSF uploader too
  (going to need to convert the $config options into a fair user entry)
- Enable downloading manual entry stats, so it all appears seamless.  (note, we
  don't download auto-generated stats, like the number of students, well, we
  do, but we just overwrite it with what's in the local SFIAB, it would be a lot of work
  to keep it separate if it changes).
2009-05-03 06:31:03 +00:00
dave
3d15473906 - And uncomment the communication.... :) 2009-04-23 04:39:24 +00:00
dave
566c5aecff - Fix some of the stats reporting 2009-04-23 04:38:29 +00:00
dave
2aab58b28d - Fix a typo in the last db file 2009-04-23 03:53:41 +00:00
dave
cfdcfb7c9d - More data, more stats 2009-04-20 05:27:06 +00:00
dave
b5745656c1 - Add user/pass support to the fair info
- Add a generic fair stats uploader, can't do YSF stats yet, but it will soon
  (and when it does it can replace the YSF specific stats uploader)
- Add better authentication to the incoming xml transport.
2009-04-20 05:02:23 +00:00
dave
d2e9a4e64e - Partial DB updates, and an xml transport script for feeder fairs to communicate 2009-04-20 04:34:37 +00:00
dave
f3f9e1c342 - Updates for editting the fair 2009-04-20 04:33:49 +00:00
dave
9f80a3fd81 - Another missing file, oops 2009-04-16 06:51:13 +00:00
dave
56a6305570 - Add a science fairs manager 2009-04-16 06:49:40 +00:00
dave
2c6e90d37b - Handle multisel config options with <= 5 items 2009-04-14 06:25:55 +00:00
dave
255adde40a - Update the designate field, make it editable by everyone
- Add an "at risk" field, to flag schools.  This is purely for stats gathering.
- Add a fairs_stats page to gather stats from sub-fairs.  This will be used
  when linking SFIABs together so the feeder fairs can upload statistics to,
  say, a provincial body (both runnign SFIAB).
2009-04-12 21:38:51 +00:00
dave
6bd52d6ff2 - Add the basics for a science fair "user". 2009-04-12 03:13:09 +00:00
dave
38effb78ee - Add a basic, but funcitonal, new user option for any type of user. 2009-04-12 02:40:32 +00:00
dave
b5a9ca07d8 - Fix a typo 2009-04-12 02:39:48 +00:00
dave
52bd4ae2b7 - List schools by city first, then school name 2009-04-06 05:42:25 +00:00
dave
8af5de9625 - Also do the SSL trick for YSF stats 2009-04-05 19:22:09 +00:00
dave
e766945fcb Update the stats for the nwe user system 2009-04-05 19:20:43 +00:00
dave
6c32f2c2d7 - Merge the last 2 commits into the users makeover branch 2009-04-05 18:02:07 +00:00
dave
46178ca051 - Fix the list of all judges 2009-04-02 00:10:18 +00:00
dave
b2e1b1e74f Fix a typo 2009-04-01 23:41:05 +00:00
dave
57017cccc0 Add time availability to the judge info popup 2009-04-01 23:40:08 +00:00
dave
241d9ad1c1 - Fix printing the judge languages beside each judge 2009-04-01 23:24:54 +00:00
dave
411361e351 - Add active and delete checks to the judges/volunteers 2009-03-31 17:44:35 +00:00
dave
288410457d - Fix (almost all) judge communicaiton for this year, need to merge James'
change from vanilla trunk to fix the last one.
- Add volunteer communicaiton.
2009-03-31 17:12:08 +00:00
dave
466927a822 Ok, now the file i was tryign to commit. This one add components to the filter
options, in case the report filters on something that is not being displayed.
2009-03-30 20:15:42 +00:00
dave
bd8ce272b1 Undo the last patch 2009-03-30 20:14:44 +00:00
dave
ebb323dcb9 - Do compoenent in the filter field too, just in case the report filters on
something that isn't being displayed.
2009-03-30 20:09:48 +00:00
dave
601bc4be68 Sched. judges on >1 SA team if they request 2009-03-29 06:42:08 +00:00
dave
2e2b6910dc Only print the award name for SA only judges, so it makes sense visually. 2009-03-29 05:56:29 +00:00
dave
29d2f5b333 Remove the requirement for a judge to only select one special award if they are SA only. 2009-03-29 05:54:22 +00:00
dave
f39ffeced4 - Create one round2 team for each jdiv, instead of just one big team
- Fix the judge cost funciton a bit.
2009-03-29 05:43:22 +00:00
dave
f98b3b70b2 New judge scheduler, deals with multiple rounds of judging. Not quite ready
for general consumption (there is no way to turn OFF the 2nd round yet), and
the 2nd round scheduler needs a bit of work.
2009-03-29 04:31:16 +00:00
dave
a39fd80264 - Show "personal information complete/incomplete" to committee too.
- TODO: make it actually update the {$type}_complete columns.
2009-02-16 05:03:25 +00:00
dave
959f45d725 - Make the user list a little cleaner for multiple-role users. It makes the
code ugly however :(
2009-02-11 08:07:04 +00:00
dave
1b4e596a0f - Make the time selection look a little better 2009-02-11 05:53:23 +00:00
dave
2112dca205 Filter registration fee items by year too 2009-02-11 05:40:54 +00:00
dave
c158b9aad1 - Judge timeslot selection page, default: disabled. The scheduler doesn't use
it yet, but here it is.
2009-02-09 07:09:09 +00:00
dave
e508efece9 - Only show positions for the current year 2009-02-09 00:25:23 +00:00
dave
10bac6ca24 This isn't needed now, all user editors are in a popup window 2009-02-08 08:27:12 +00:00
dave
d3acfa1fe9 - Fix the create user, ask for an email, not a name (because need to insert a unique username,year pair now). Make it a popup window.
- TODO: use AJAX to give feedback as to whether the username already exists.
2009-02-08 08:23:27 +00:00
dave
cb39440d16 Fixup all other uses of user_create 2009-02-08 07:51:03 +00:00
dave
6a1de0f2f3 - Fix the new user function, the user table is now UNIQUE in (username,year),
so we need to insert both.
2009-02-08 07:40:36 +00:00
dave
eecb099e9b Add the registrations number to the field list 2009-02-07 15:35:51 +00:00
dave
934c8b4ef0 - Don't need this one either 2009-02-06 08:05:38 +00:00
dave
48424d9f31 - Don't need this anymore. 2009-02-06 08:04:02 +00:00
dave
cac041186a - Fixup the timeslot assignment editor to deal (primitively) with rounds 2009-02-06 07:05:29 +00:00
dave
c8705bc70d - Update judges_timesltos. to match 2009-02-06 06:56:39 +00:00
dave
799c014b6c - Use name, not round_name. Name will never confict 2009-02-06 06:55:32 +00:00
dave
d1f6bb925a Fix the require_once includes 2009-02-06 06:53:18 +00:00
dave
9b828b15d4 I used 'special' not 'specialawards' in the code 2009-02-06 06:52:28 +00:00
dave
37b774f68a - Cleanup the user list includes
- Fix a big that wasn't causing the "show only complete registrations" to stick.
2009-02-06 06:33:58 +00:00
dave
65ba63bd81 - Force the config page to reload when saved, so changes in $config are
reloaded and thus immediately displayed.
2009-02-05 09:22:31 +00:00
dave
0f763de1ac - Add a 'language' input type to the config editor
- Change config[default_language] type to langauge, no more people messing it
  up by typing in "English" or "American".
2009-02-05 09:14:41 +00:00
dave
c0e5a2cb91 - Delete debug print statements 2009-02-05 08:44:53 +00:00
dave
4c0cc8b3d5 - Remove award_sponsors from the rollover script, they will automatically be
handled by the user system (NOTE: make sure we use the users.uid instead of
  the users.id when linking to award contacts, because the users.id will change
  each year they login.
- Rollover timeslots and rounds
- Add a roll() function to simply rolling over simple databases, converted two
  rollovers to use it, could convert more.
2009-02-05 08:43:37 +00:00
dave
b39072f098 - Add an update php script to properly convert the old timeslots into rounds
with sub-timeslots.
2009-02-05 07:57:15 +00:00
dave
b7da5c59a5 - Convert old timeslots to the new rounds+timeslots format
- New timeslot editor (still needs icons)
2009-02-04 08:03:37 +00:00
dave
c2a5e6821e - Use the uid, not the id, when unlinking members 2009-02-03 23:37:34 +00:00
dave
ad27a96874 - Use the unique user id (users_uid) instead of the user id (that changes every year) when linking users to committees.
- Also use the uid when displaying committees and contact info.
2009-02-03 22:45:11 +00:00
dave
94d0e5022a - Add a user_load_by_uid() to load a user by their unique id (users are now cloned for each year);
- Fixup the committees.php page to always show the users from the latest year.
2009-02-03 08:19:15 +00:00
dave
8b430bd63f - Use the uid instead of the id (which changes every year) to see if an email address is in use.
- Only scan emails of non-deleted users
- Don't try and go back to the committee management page after save, we're in a popup window.
  FIXME: the popup window needs a close button.  :)
2009-02-02 23:48:26 +00:00
dave
68cdb98a8e - Add category short form and divison&category field
- Move division short form to be in the same order.
2009-02-02 06:51:01 +00:00
dave
53175acbfe - Obey the year specifier
- Add a "volunteer complete" option
2009-02-02 06:40:11 +00:00
dave
760b84f6ac - Fix volunteer reports to only show volunteers
- Also, show volunteers that haven't signed up for anything yet
2009-02-02 06:34:40 +00:00
dave
f83a04ab04 - Fixup the judge reports for the new user system 2009-02-02 06:31:39 +00:00
dave
3d1483975a - check for the number of tours before checking for tour assignment. This
fixes a bug where tour status always showed complete.
2009-01-29 08:14:16 +00:00
dave
099453e2c3 - Participants aren't judges. 2009-01-29 07:59:35 +00:00
dave
e045e016df - Make the delete button work. It's just a shortcut to delete the entire user
now, roles can be individually activated/deactivated/deleted in the user
  editor window.
- Make an edit button, in case someone can't figure out how to click on the name
- Add the role active status for each type (we could make this a toggle button
  too, for fast editting)
2009-01-26 07:27:07 +00:00
dave
eb87f5b6f1 Fix typo 2009-01-26 06:55:15 +00:00
dave
e76bef6cf9 - Add more trophy options to the student reports 2009-01-23 02:26:46 +00:00
james
23e6df6f37 Show the right type in the you are here cookie crumb instead of always showing Judge Registration 2009-01-22 18:03:26 +00:00
dave
c3ebf1f6cd - Add the activate screen to the editor
- Add sponsor user types to the editor
2009-01-22 05:24:34 +00:00
dave
cd1de0ddfd - This update was missed, it's kinda needed so we dont' have everyone on the committee with a unique user id of 0. 2009-01-22 01:27:10 +00:00
dave
b803c00881 Use the unique id (uid) to attach reports to committee members, instead of the
id, since now the id will change every year.
2009-01-22 01:23:14 +00:00
james
9756705aad Code style updates
Use odd/even row backgrounds to make each point easier to identify
2009-01-21 22:26:09 +00:00
james
7e250693af Fix report_awards for new sponsor format 2009-01-21 20:13:30 +00:00
james
f25a6d1e6b Fix AC script for new sponsors format 2009-01-21 20:13:02 +00:00
james
496b18d2e2 Allow switching back to "all" 2009-01-21 19:45:13 +00:00
dave
59c2809ef5 - Load from the sponsor table, instead of the awards_sponsor table 2009-01-21 18:33:46 +00:00
dave
f39b01d4c2 - Use NULL properly 2009-01-21 18:33:25 +00:00
dave
3ad971cb60 - Remove the old judge registration pages 2009-01-21 09:08:00 +00:00
dave
7610908a17 - Use the proper judge mainpage 2009-01-21 09:05:50 +00:00
dave
b102731ac2 - $config needs to be global, or the year doesn't work :) 2009-01-21 09:04:36 +00:00
dave
d5676576a7 - Fix the user dupe code, now that username,year is unique 2009-01-21 08:59:39 +00:00
dave
65e5bfc0fa - add volutneer position rollover code 2009-01-21 08:24:45 +00:00
dave
c2309c0174 - Fix a typo to let the .119 update apply 2009-01-21 08:10:55 +00:00
dave
d00086aea5 - speaking of errors 2009-01-21 08:02:45 +00:00
dave
af6eb12985 - Handle the case where a user is a volunteer and a committee member, tested. works.
- Add the UNIQUE username,year condition to the 117 update.
- Bump the version to 119.  I won't commit anything else to the existing
  updates, unless I find an error in a script.
2009-01-21 07:42:15 +00:00
dave
9c40cc91f8 A working user editor. It uses the same pages that the user actually sees (via
a $_SESSION['embed'] variable to change the behaviour).  It uses tabs to switch
between the various sections.  Converted committee, volunteer, and judge
editor.  Relies on using a popup window, don't know if that's a good idea or
not, but it sure looks cool.
2009-01-19 23:33:54 +00:00
dave
27f40a0fc9 Use the themed sfiab.css for popup windows too 2009-01-19 21:31:50 +00:00
dave
548a37ae16 - Link in the user invite page for judges and volunteers
- Delete the old invite page.
2008-11-08 08:47:22 +00:00
dave
dd5eae506f - save the file before trying to commit it :) 2008-11-08 08:36:11 +00:00
dave
bfb2b63a68 - the rest of the user invite system, should all be working now. Can be used
to invite Volunteers and Judges, or add the volunteer/judge role to an
  account, or send a reminder email to a specific volutneer/judge that
  registration is now open and they should login.
2008-11-08 08:35:08 +00:00
james
e4ed9f8772 Reorganize the left side menu, and add a new generic login page that lets you choose who you are and takes the user to the appropriate login page 2008-11-07 03:25:43 +00:00
james
95c559fa08 Add sponsorship levels to the sponsor main page 2008-11-07 03:23:42 +00:00
james
3ab46da3d5 Add defaults and descriptions to fundraising types and sponsorship levels
Start working on the sponsors main page for when a sponsor logs in
2008-11-06 21:07:40 +00:00
james
fb53a2cb2c Add sponsorship levels editor
Add description to funrdaising types
Add description/benefits to sponsorship levels
2008-11-06 21:06:40 +00:00
james
5970cc2782 Make backup/restore work in Internet Exploder over SSL 2008-11-06 19:06:31 +00:00
james
d4e604fed5 Don't show dates that aren't set on the front-end 2008-11-03 05:18:23 +00:00
james
e5e863e3f7 Update winners entry and award_downloader for award_sponsors->sponsors conversion 2008-11-03 05:15:03 +00:00
james
27a3a273d7 Disable the rest of the award_sponsor.confirmed stuff until we figure out what to do with it
Make the sponsor selector work when adding awards
2008-11-03 05:09:04 +00:00
james
4b573c7224 Update the rest of the awards system to pull from sponsors instead of award_sponsors 2008-11-03 05:05:09 +00:00
james
8df97afb4f Table editor CSS cleanups to look better 2008-11-03 04:50:00 +00:00
james
8a3dbc9284 Rename award_contacts to sponsor_contacts 2008-11-03 04:49:36 +00:00
james
0f3f5dd26c Re-implement award_contacts as sponsor_contacts, will full editor using the new user system 2008-11-03 04:48:48 +00:00
james
4316d2bb71 Fix translations dropdown to work in IE 2008-11-03 01:57:04 +00:00
james
b9253d4114 IE/Firefox consistency fixes (make IE not look screwed up) 2008-11-03 00:42:21 +00:00
dave
3b845d2d36 - working ajax part of the user invite script. No emails are sent yet, this is
just the working ajax part.  but.. it works.. at least in firefox.
2008-11-02 22:35:54 +00:00
dave
860de02d16 - remove unneeded line 2008-11-02 15:55:24 +00:00
dave
881d6b9be4 - fix the message in the config editor
- add a convenience $user['name'] setting
- update the judge SA
2008-11-02 06:15:05 +00:00
dave
1774225526 - fix the judge check in the scheduler 2008-11-02 05:29:36 +00:00
dave
f054ab69f9 - working judges_teams_members.php 2008-11-02 05:07:04 +00:00
james
566fb9ea3c Fix translation of headings for pre-translated headings, remove i18n calls from send_header calls that dont need it 2008-10-30 16:55:31 +00:00
james
fe07722b5b Fix the namecheck code 2008-10-30 16:39:06 +00:00
james
2bd3201196 Add new fields to sponsor editor, dont let sponsor be edited on a sponsorship, and adjust the dialog box sizes a bit 2008-10-28 21:19:21 +00:00
james
82d9e16dea Add sponsors_logs logging to sponsorship adding/editing 2008-10-28 19:23:09 +00:00
dave
43d58fb17f - missing line to last update 2008-10-26 19:42:49 +00:00
dave
4789bd4d60 - update the user_load routine to use the new method. 2008-10-26 17:21:26 +00:00
james
c41be1a17e Add more fields to the sponsor table 2008-10-25 05:01:29 +00:00
james
585510ad87 Sort the sponsorships list 2008-10-25 04:33:18 +00:00
james
48ee8ee629 Oops fix typo, howd that happen! 2008-10-25 04:28:41 +00:00
james
d849040872 Add ability to delete funds and delete sponsorships
Update some of the sponsors editor code to look a bit.. umm... better.... needs more work me thinks...
2008-10-25 04:25:38 +00:00
james
1d09e7fb38 Factor form handler into separate files for each of the dialog forms
Add form handling for fundraising types
2008-10-24 22:46:35 +00:00
james
b62fa76aab Refactor dialog code into separate include file
CSS changes for IE and for Dialog use
Switch fund types to use dialog (cant save yet)
2008-10-24 22:29:14 +00:00
james
18de1e13cf A few CSS changes to fix the problem with the ? icon being off the side of the page in inept exploder. 2008-10-24 00:04:54 +00:00
james
b7e72aa40c This file was renamed in the last commit 2008-10-23 21:33:06 +00:00
james
c100baef89 Add more fundraising module stuff, the SFIABDialog code will be refactored out into a separate library class eventually 2008-10-23 21:32:31 +00:00
james
10d71c4b57 Shrink Coins to 32x32, it was 48x48 for some reason, maybe need to find a new icon, this looks like crap now. 2008-10-23 21:26:14 +00:00
james
8c385c50aa Add coins icon for Fundraising module 2008-10-23 18:29:45 +00:00
james
f2101200b6 Add a start of the fundraising system's overview page and fund type editor 2008-10-22 21:46:31 +00:00
james
2d8c3a72ef Add more ISEF form handling database, keep as 999 cuz we're not ready for it yet 2008-10-22 20:48:22 +00:00
james
bf3942bc04 Make salutation work in user editor 2008-10-22 20:47:45 +00:00
james
4dd1111b76 Add salutation to user_personal 2008-10-22 20:36:05 +00:00
james
bce2cef92e Add some user sponsor stubs
Fix some multi-year user stuff
Add sponsor main page
2008-10-22 20:35:35 +00:00
james
3c1a4d29cc Merge judge records into existing user records
Start to cleanup users table to be able to add UNIQUE(username,year)
2008-10-22 16:44:03 +00:00
james
f981858df9 Change sex field in 116 so judges also default to NULL
Add start of sponsor contacts conversion to user system for fundraising module
2008-10-20 21:04:19 +00:00
james
35d3211391 Fix parse error 2008-10-20 16:56:31 +00:00
dave
d86ea6257f - partially working judges_teams_members
- working judges_info, except for the configurable questions/answers
2008-10-20 05:20:42 +00:00
dave
d1c7fa968e - more unneeded user code 2008-10-19 23:14:02 +00:00
dave
a0d27df91e - use the newer (faster) user load, and always load a full user.
- delete now deprecated code because of the new user loader
2008-10-19 21:42:57 +00:00
dave
f9d3913697 - remove old user_update_complete function, each user type now updates their
individual complete entry.
2008-10-19 15:49:28 +00:00
dave
74fe5db9f7 - update the volunteer reg, so the volunteer_complete is automatically updated.
- BUG: the user personal editor doesn't call the
  judge/volunteer/whatever_status_update() function, so if a user leaves their
  personal info to the end, they MUST load the whatever_main.php page so their
  overall status is updated correctly.
2008-10-19 15:46:43 +00:00
dave
7f1331d401 - update the judge team editor. Not ideal, this shouldn't query the users
table directly, but it works.  This will be reworked later when I add support
  for judges to select which timeslots they're available.
2008-10-19 02:52:28 +00:00
dave
81c211c913 - add judge special awards selection
- fixup the judge_complete detection
- rename judges_id to users_id in the 117 db update, so it's done after the 116
  update converts everything
2008-10-18 03:30:58 +00:00
dave
4b247de611 - implement the judge_other selection for years of experience and willing_chair and whatnot. 2008-10-17 22:44:33 +00:00
dave
ca81fc2273 - delete the year too, and do the users_id conversion in one spot only 2008-10-17 20:40:11 +00:00
dave
87c845c048 - convert the registrations_id in the question answers to the new users_id (it's really the users id anyway)
- add a 117 script to cleanup all the post 116 stuff, deleting unneeded tables and whatnot
- these are NOT THE FINAL scripts, more will be added to these.
2008-10-17 20:38:01 +00:00
dave
b021805246 - conversion of judges to new user system. Mostly works. 2008-10-17 19:34:11 +00:00
james
18f6d002a7 add branch for users makeover of judges and sponsors/fundraising 2008-10-17 15:25:32 +00:00
961 changed files with 13510 additions and 315142 deletions

View File

@ -1,10 +1,8 @@
php_flag register_globals off
php_flag magic_quotes_gpc off
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-l
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^web/(.*)$ cms.php?f=$1 [L]
RewriteRule ^api/(.*)$ api.php?request=$1 [L]

View File

@ -1,6 +0,0 @@
License for Rmail
=================
This software is covered by the PHPGuru License. You can read it, along with a few FAQs, here:
http://www.phpguru.org/static/license.html

View File

@ -1,880 +0,0 @@
<?php
/**
* o------------------------------------------------------------------------------o
* | This package is licensed under the Phpguru license. A quick summary is |
* | that for commercial use, there is a small one-time licensing fee to pay. For |
* | registered charities and educational institutes there is a reduced license |
* | fee available. You can read more at: |
* | |
* | http://www.phpguru.org/static/license.html |
* o------------------------------------------------------------------------------o
*
* © Copyright 2008,2009 Richard Heyes
*/
/**
* RFC 822 Email address list validation Utility
*
* What is it?
*
* This class will take an address string, and parse it into it's consituent
* parts, be that either addresses, groups, or combinations. Nested groups
* are not supported. The structure it returns is pretty straight forward,
* and is similar to that provided by the imap_rfc822_parse_adrlist(). Use
* print_r() to view the structure.
*
* How do I use it?
*
* $address_string = 'My Group: "Richard Heyes" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;';
* $structure = Mail_RFC822::parseAddressList($address_string, 'example.com', TRUE)
* print_r($structure);
*/
class Mail_RFC822
{
/**
* The address being parsed by the RFC822 object.
* @private string $address
*/
private $address = '';
/**
* The default domain to use for unqualified addresses.
* @private string $default_domain
*/
private $default_domain = 'localhost';
/**
* Should we return a nested array showing groups, or flatten everything?
* @private boolean $nestGroups
*/
private $nestGroups = true;
/**
* Whether or not to validate atoms for non-ascii characters.
* @private boolean $validate
*/
private $validate = true;
/**
* The array of raw addresses built up as we parse.
* @private array $addresses
*/
private $addresses = array();
/**
* The final array of parsed address information that we build up.
* @private array $structure
*/
private $structure = array();
/**
* The current error message, if any.
* @private string $error
*/
private $error = null;
/**
* An internal counter/pointer.
* @private integer $index
*/
private $index = null;
/**
* The number of groups that have been found in the address list.
* @private integer $num_groups
* @access public
*/
private $num_groups = 0;
/**
* A variable so that we can tell whether or not we're inside a
* Mail_RFC822 object.
* @private boolean $mailRFC822
*/
private $mailRFC822 = true;
/**
* A limit after which processing stops
* @private int $limit
*/
private $limit = null;
/**
* Sets up the object. The address must either be set here or when
* calling parseAddressList(). One or the other.
*
* @access public
* @param string $address The address(es) to validate.
* @param string $default_domain Default domain/host etc. If not supplied, will be set to localhost.
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
* @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
*
* @return object Mail_RFC822 A new Mail_RFC822 object.
*/
function __construct($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
{
if (isset($address)) $this->address = $address;
if (isset($default_domain)) $this->default_domain = $default_domain;
if (isset($nest_groups)) $this->nestGroups = $nest_groups;
if (isset($validate)) $this->validate = $validate;
if (isset($limit)) $this->limit = $limit;
}
/**
* Starts the whole process. The address must either be set here
* or when creating the object. One or the other.
*
* @access public
* @param string $address The address(es) to validate.
* @param string $default_domain Default domain/host etc.
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
* @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
*
* @return array A structured array of addresses.
*/
function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
{
if (!isset($this->mailRFC822)) {
$obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
return $obj->parseAddressList();
}
if (isset($address)) $this->address = $address;
if (isset($default_domain)) $this->default_domain = $default_domain;
if (isset($nest_groups)) $this->nestGroups = $nest_groups;
if (isset($validate)) $this->validate = $validate;
if (isset($limit)) $this->limit = $limit;
$this->structure = array();
$this->addresses = array();
$this->error = null;
$this->index = null;
while ($this->address = $this->_splitAddresses($this->address)) {
continue;
}
if ($this->address === false || isset($this->error)) {
return false;
}
// Reset timer since large amounts of addresses can take a long time to
// get here
set_time_limit(30);
// Loop through all the addresses
for ($i = 0; $i < count($this->addresses); $i++){
if (($return = $this->_validateAddress($this->addresses[$i])) === false
|| isset($this->error)) {
return false;
}
if (!$this->nestGroups) {
$this->structure = array_merge($this->structure, $return);
} else {
$this->structure[] = $return;
}
}
return $this->structure;
}
/**
* Splits an address into seperate addresses.
*
* @access private
* @param string $address The addresses to split.
* @return boolean Success or failure.
*/
function _splitAddresses($address)
{
if (!empty($this->limit) AND count($this->addresses) == $this->limit) {
return '';
}
if ($this->_isGroup($address) && !isset($this->error)) {
$split_char = ';';
$is_group = true;
} elseif (!isset($this->error)) {
$split_char = ',';
$is_group = false;
} elseif (isset($this->error)) {
return false;
}
// Split the string based on the above ten or so lines.
$parts = explode($split_char, $address);
$string = $this->_splitCheck($parts, $split_char);
// If a group...
if ($is_group) {
// If $string does not contain a colon outside of
// brackets/quotes etc then something's fubar.
// First check there's a colon at all:
if (strpos($string, ':') === false) {
$this->error = 'Invalid address: ' . $string;
return false;
}
// Now check it's outside of brackets/quotes:
if (!$this->_splitCheck(explode(':', $string), ':'))
return false;
// We must have a group at this point, so increase the counter:
$this->num_groups++;
}
// $string now contains the first full address/group.
// Add to the addresses array.
$this->addresses[] = array(
'address' => trim($string),
'group' => $is_group
);
// Remove the now stored address from the initial line, the +1
// is to account for the explode character.
$address = trim(substr($address, strlen($string) + 1));
// If the next char is a comma and this was a group, then
// there are more addresses, otherwise, if there are any more
// chars, then there is another address.
if ($is_group && substr($address, 0, 1) == ','){
$address = trim(substr($address, 1));
return $address;
} elseif (strlen($address) > 0) {
return $address;
} else {
return '';
}
// If you got here then something's off
return false;
}
/**
* Checks for a group at the start of the string.
*
* @access private
* @param string $address The address to check.
* @return boolean Whether or not there is a group at the start of the string.
*/
function _isGroup($address)
{
// First comma not in quotes, angles or escaped:
$parts = explode(',', $address);
$string = $this->_splitCheck($parts, ',');
// Now we have the first address, we can reliably check for a
// group by searching for a colon that's not escaped or in
// quotes or angle brackets.
if (count($parts = explode(':', $string)) > 1) {
$string2 = $this->_splitCheck($parts, ':');
return ($string2 !== $string);
} else {
return false;
}
}
/**
* A common function that will check an exploded string.
*
* @access private
* @param array $parts The exloded string.
* @param string $char The char that was exploded on.
* @return mixed False if the string contains unclosed quotes/brackets, or the string on success.
*/
function _splitCheck($parts, $char)
{
$string = $parts[0];
for ($i = 0; $i < count($parts); $i++) {
if ($this->_hasUnclosedQuotes($string)
|| $this->_hasUnclosedBrackets($string, '<>')
|| $this->_hasUnclosedBrackets($string, '[]')
|| $this->_hasUnclosedBrackets($string, '()')
|| substr($string, -1) == '\\') {
if (isset($parts[$i + 1])) {
$string = $string . $char . $parts[$i + 1];
} else {
$this->error = 'Invalid address spec. Unclosed bracket or quotes';
return false;
}
} else {
$this->index = $i;
break;
}
}
return $string;
}
/**
* Checks if a string has an unclosed quotes or not.
*
* @access private
* @param string $string The string to check.
* @return boolean True if there are unclosed quotes inside the string, false otherwise.
*/
function _hasUnclosedQuotes($string)
{
$string = explode('"', $string);
$string_cnt = count($string);
for ($i = 0; $i < (count($string) - 1); $i++)
if (substr($string[$i], -1) == '\\')
$string_cnt--;
return ($string_cnt % 2 === 0);
}
/**
* Checks if a string has an unclosed brackets or not. IMPORTANT:
* This function handles both angle brackets and square brackets;
*
* @access private
* @param string $string The string to check.
* @param string $chars The characters to check for.
* @return boolean True if there are unclosed brackets inside the string, false otherwise.
*/
function _hasUnclosedBrackets($string, $chars)
{
$num_angle_start = substr_count($string, $chars[0]);
$num_angle_end = substr_count($string, $chars[1]);
$this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]);
$this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]);
if ($num_angle_start < $num_angle_end) {
$this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')';
return false;
} else {
return ($num_angle_start > $num_angle_end);
}
}
/**
* Sub function that is used only by hasUnclosedBrackets().
*
* @access private
* @param string $string The string to check.
* @param integer &$num The number of occurences.
* @param string $char The character to count.
* @return integer The number of occurences of $char in $string, adjusted for backslashes.
*/
function _hasUnclosedBracketsSub($string, &$num, $char)
{
$parts = explode($char, $string);
for ($i = 0; $i < count($parts); $i++){
if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i]))
$num--;
if (isset($parts[$i + 1]))
$parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1];
}
return $num;
}
/**
* Function to begin checking the address.
*
* @access private
* @param string $address The address to validate.
* @return mixed False on failure, or a structured array of address information on success.
*/
function _validateAddress($address)
{
$is_group = false;
if ($address['group']) {
$is_group = true;
// Get the group part of the name
$parts = explode(':', $address['address']);
$groupname = $this->_splitCheck($parts, ':');
$structure = array();
// And validate the group part of the name.
if (!$this->_validatePhrase($groupname)){
$this->error = 'Group name did not validate.';
return false;
} else {
// Don't include groups if we are not nesting
// them. This avoids returning invalid addresses.
if ($this->nestGroups) {
$structure = new stdClass;
$structure->groupname = $groupname;
}
}
$address['address'] = ltrim(substr($address['address'], strlen($groupname . ':')));
}
// If a group then split on comma and put into an array.
// Otherwise, Just put the whole address in an array.
if ($is_group) {
while (strlen($address['address']) > 0) {
$parts = explode(',', $address['address']);
$addresses[] = $this->_splitCheck($parts, ',');
$address['address'] = trim(substr($address['address'], strlen(end($addresses) . ',')));
}
} else {
$addresses[] = $address['address'];
}
// Check that $addresses is set, if address like this:
// Groupname:;
// Then errors were appearing.
if (!isset($addresses)){
$this->error = 'Empty group.';
return false;
}
for ($i = 0; $i < count($addresses); $i++) {
$addresses[$i] = trim($addresses[$i]);
}
// Validate each mailbox.
// Format could be one of: name <geezer@domain.com>
// geezer@domain.com
// geezer
// ... or any other format valid by RFC 822.
array_walk($addresses, array($this, 'validateMailbox'));
// Nested format
if ($this->nestGroups) {
if ($is_group) {
$structure->addresses = $addresses;
} else {
$structure = $addresses[0];
}
// Flat format
} else {
if ($is_group) {
$structure = array_merge($structure, $addresses);
} else {
$structure = $addresses;
}
}
return $structure;
}
/**
* Function to validate a phrase.
*
* @access private
* @param string $phrase The phrase to check.
* @return boolean Success or failure.
*/
function _validatePhrase($phrase)
{
// Splits on one or more Tab or space.
$parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
$phrase_parts = array();
while (count($parts) > 0){
$phrase_parts[] = $this->_splitCheck($parts, ' ');
for ($i = 0; $i < $this->index + 1; $i++)
array_shift($parts);
}
for ($i = 0; $i < count($phrase_parts); $i++) {
// If quoted string:
if (substr($phrase_parts[$i], 0, 1) == '"') {
if (!$this->_validateQuotedString($phrase_parts[$i]))
return false;
continue;
}
// Otherwise it's an atom:
if (!$this->_validateAtom($phrase_parts[$i])) return false;
}
return true;
}
/**
* Function to validate an atom which from rfc822 is:
* atom = 1*<any CHAR except specials, SPACE and CTLs>
*
* If validation ($this->validate) has been turned off, then
* validateAtom() doesn't actually check anything. This is so that you
* can split a list of addresses up before encoding personal names
* (umlauts, etc.), for example.
*
* @access private
* @param string $atom The string to check.
* @return boolean Success or failure.
*/
function _validateAtom($atom)
{
if (!$this->validate) {
// Validation has been turned off; assume the atom is okay.
return true;
}
// Check for any char from ASCII 0 - ASCII 127
if (!preg_match('/^[\\x00-\\x7E]+$/i', $atom, $matches)) {
return false;
}
// Check for specials:
if (preg_match('/[][()<>@,;\\:". ]/', $atom)) {
return false;
}
// Check for control characters (ASCII 0-31):
if (preg_match('/[\\x00-\\x1F]+/', $atom)) {
return false;
}
return true;
}
/**
* Function to validate quoted string, which is:
* quoted-string = <"> *(qtext/quoted-pair) <">
*
* @access private
* @param string $qstring The string to check
* @return boolean Success or failure.
*/
function _validateQuotedString($qstring)
{
// Leading and trailing "
$qstring = substr($qstring, 1, -1);
// Perform check.
return !(preg_match('/(.)[\x0D\\\\"]/', $qstring, $matches) && $matches[1] != '\\');
}
/**
* Function to validate a mailbox, which is:
* mailbox = addr-spec ; simple address
* / phrase route-addr ; name and route-addr
*
* @access public
* @param string &$mailbox The string to check.
* @return boolean Success or failure.
*/
function validateMailbox(&$mailbox)
{
// A couple of defaults.
$phrase = '';
$comment = '';
// Catch any RFC822 comments and store them separately
$_mailbox = $mailbox;
while (strlen(trim($_mailbox)) > 0) {
$parts = explode('(', $_mailbox);
$before_comment = $this->_splitCheck($parts, '(');
if ($before_comment != $_mailbox) {
// First char should be a (
$comment = substr(str_replace($before_comment, '', $_mailbox), 1);
$parts = explode(')', $comment);
$comment = $this->_splitCheck($parts, ')');
$comments[] = $comment;
// +1 is for the trailing )
$_mailbox = substr($_mailbox, strpos($_mailbox, $comment)+strlen($comment)+1);
} else {
break;
}
}
for($i=0; $i<count(@$comments); $i++){
$mailbox = str_replace('('.$comments[$i].')', '', $mailbox);
}
$mailbox = trim($mailbox);
// Check for name + route-addr
if (substr($mailbox, -1) == '>' && substr($mailbox, 0, 1) != '<') {
$parts = explode('<', $mailbox);
$name = $this->_splitCheck($parts, '<');
$phrase = trim($name);
$route_addr = trim(substr($mailbox, strlen($name.'<'), -1));
if ($this->_validatePhrase($phrase) === false || ($route_addr = $this->_validateRouteAddr($route_addr)) === false)
return false;
// Only got addr-spec
} else {
// First snip angle brackets if present.
if (substr($mailbox,0,1) == '<' && substr($mailbox,-1) == '>')
$addr_spec = substr($mailbox,1,-1);
else
$addr_spec = $mailbox;
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false)
return false;
}
// Construct the object that will be returned.
$mbox = new stdClass();
// Add the phrase (even if empty) and comments
$mbox->personal = $phrase;
$mbox->comment = isset($comments) ? $comments : array();
if (isset($route_addr)) {
$mbox->mailbox = $route_addr['local_part'];
$mbox->host = $route_addr['domain'];
$route_addr['adl'] !== '' ? $mbox->adl = $route_addr['adl'] : '';
} else {
$mbox->mailbox = $addr_spec['local_part'];
$mbox->host = $addr_spec['domain'];
}
$mailbox = $mbox;
return true;
}
/**
* This function validates a route-addr which is:
* route-addr = "<" [route] addr-spec ">"
*
* Angle brackets have already been removed at the point of
* getting to this function.
*
* @access private
* @param string $route_addr The string to check.
* @return mixed False on failure, or an array containing validated address/route information on success.
*/
function _validateRouteAddr($route_addr)
{
// Check for colon.
if (strpos($route_addr, ':') !== false) {
$parts = explode(':', $route_addr);
$route = $this->_splitCheck($parts, ':');
} else {
$route = $route_addr;
}
// If $route is same as $route_addr then the colon was in
// quotes or brackets or, of course, non existent.
if ($route === $route_addr){
unset($route);
$addr_spec = $route_addr;
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
return false;
}
} else {
// Validate route part.
if (($route = $this->_validateRoute($route)) === false) {
return false;
}
$addr_spec = substr($route_addr, strlen($route . ':'));
// Validate addr-spec part.
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
return false;
}
}
if (isset($route)) {
$return['adl'] = $route;
} else {
$return['adl'] = '';
}
$return = array_merge($return, $addr_spec);
return $return;
}
/**
* Function to validate a route, which is:
* route = 1#("@" domain) ":"
*
* @access private
* @param string $route The string to check.
* @return mixed False on failure, or the validated $route on success.
*/
function _validateRoute($route)
{
// Split on comma.
$domains = explode(',', trim($route));
for ($i = 0; $i < count($domains); $i++) {
$domains[$i] = str_replace('@', '', trim($domains[$i]));
if (!$this->_validateDomain($domains[$i])) return false;
}
return $route;
}
/**
* Function to validate a domain, though this is not quite what
* you expect of a strict internet domain.
*
* domain = sub-domain *("." sub-domain)
*
* @access private
* @param string $domain The string to check.
* @return mixed False on failure, or the validated domain on success.
*/
function _validateDomain($domain)
{
// Note the different use of $subdomains and $sub_domains
$subdomains = explode('.', $domain);
while (count($subdomains) > 0) {
$sub_domains[] = $this->_splitCheck($subdomains, '.');
for ($i = 0; $i < $this->index + 1; $i++)
array_shift($subdomains);
}
for ($i = 0; $i < count($sub_domains); $i++) {
if (!$this->_validateSubdomain(trim($sub_domains[$i])))
return false;
}
// Managed to get here, so return input.
return $domain;
}
/**
* Function to validate a subdomain:
* subdomain = domain-ref / domain-literal
*
* @access private
* @param string $subdomain The string to check.
* @return boolean Success or failure.
*/
function _validateSubdomain($subdomain)
{
if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){
if (!$this->_validateDliteral($arr[1])) return false;
} else {
if (!$this->_validateAtom($subdomain)) return false;
}
// Got here, so return successful.
return true;
}
/**
* Function to validate a domain literal:
* domain-literal = "[" *(dtext / quoted-pair) "]"
*
* @access private
* @param string $dliteral The string to check.
* @return boolean Success or failure.
*/
function _validateDliteral($dliteral)
{
return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && $matches[1] != '\\';
}
/**
* Function to validate an addr-spec.
*
* addr-spec = local-part "@" domain
*
* @access private
* @param string $addr_spec The string to check.
* @return mixed False on failure, or the validated addr-spec on success.
*/
function _validateAddrSpec($addr_spec)
{
$addr_spec = trim($addr_spec);
// Split on @ sign if there is one.
if (strpos($addr_spec, '@') !== false) {
$parts = explode('@', $addr_spec);
$local_part = $this->_splitCheck($parts, '@');
$domain = substr($addr_spec, strlen($local_part . '@'));
// No @ sign so assume the default domain.
} else {
$local_part = $addr_spec;
$domain = $this->default_domain;
}
if (($local_part = $this->_validateLocalPart($local_part)) === false) return false;
if (($domain = $this->_validateDomain($domain)) === false) return false;
// Got here so return successful.
return array('local_part' => $local_part, 'domain' => $domain);
}
/**
* Function to validate the local part of an address:
* local-part = word *("." word)
*
* @access private
* @param string $local_part
* @return mixed False on failure, or the validated local part on success.
*/
function _validateLocalPart($local_part)
{
$parts = explode('.', $local_part);
// Split the local_part into words.
while (count($parts) > 0){
$words[] = $this->_splitCheck($parts, '.');
for ($i = 0; $i < $this->index + 1; $i++) {
array_shift($parts);
}
}
// Validate each word.
for ($i = 0; $i < count($words); $i++) {
if ($this->_validatePhrase(trim($words[$i])) === false) return false;
}
// Managed to get here, so return the input.
return $local_part;
}
/**
* Returns an approximate count of how many addresses are
* in the given string. This is APPROXIMATE as it only splits
* based on a comma which has no preceding backslash. Could be
* useful as large amounts of addresses will end up producing
* *large* structures when used with parseAddressList().
*
* @param string $data Addresses to count
* @return int Approximate count
*/
function approximateCount($data)
{
return count(preg_split('/(?<!\\\\),/', $data));
}
/**
* This is a email validating function seperate to the rest
* of the class. It simply validates whether an email is of
* the common internet form: <user>@<domain>. This can be
* sufficient for most people. Optional stricter mode can
* be utilised which restricts mailbox characters allowed
* to alphanumeric, full stop, hyphen and underscore.
*
* @param string $data Address to check
* @param boolean $strict Optional stricter mode
* @return mixed False if it fails, an indexed array
* username/domain if it matches
*/
function isValidInetAddress($data, $strict = false)
{
$regex = $strict ? '/^([.0-9a-z_-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i' : '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i';
if (preg_match($regex, trim($data), $matches)) {
return array($matches[1], $matches[2]);
} else {
return false;
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,313 +0,0 @@
<?php
/**
* o------------------------------------------------------------------------------o
* | This package is licensed under the Phpguru license. A quick summary is |
* | that for commercial use, there is a small one-time licensing fee to pay. For |
* | registered charities and educational institutes there is a reduced license |
* | fee available. You can read more at: |
* | |
* | http://www.phpguru.org/static/license.html |
* o------------------------------------------------------------------------------o
*
* © Copyright 2008,2009 Richard Heyes
*/
/**
*
* Raw mime encoding class
*
* What is it?
* This class enables you to manipulate and build
* a mime email from the ground up.
*
* Why use this instead of mime.php?
* mime.php is a userfriendly api to this class for
* people who aren't interested in the internals of
* mime mail. This class however allows full control
* over the email.
*
* Eg.
*
* // Since multipart/mixed has no real body, (the body is
* // the subpart), we set the body argument to blank.
*
* $params['content_type'] = 'multipart/mixed';
* $email = new Mail_mimePart('', $params);
*
* // Here we add a text part to the multipart we have
* // already. Assume $body contains plain text.
*
* $params['content_type'] = 'text/plain';
* $params['encoding'] = '7bit';
* $text = $email->addSubPart($body, $params);
*
* // Now add an attachment. Assume $attach is
* the contents of the attachment
*
* $params['content_type'] = 'application/zip';
* $params['encoding'] = 'base64';
* $params['disposition'] = 'attachment';
* $params['dfilename'] = 'example.zip';
* $attach =& $email->addSubPart($body, $params);
*
* // Now build the email. Note that the encode
* // function returns an associative array containing two
* // elements, body and headers. You will need to add extra
* // headers, (eg. Mime-Version) before sending.
*
* $email = $message->encode();
* $email['headers'][] = 'Mime-Version: 1.0';
*
*
* Further examples are available at http://www.phpguru.org
*
* TODO:
* - Set encode() to return the $obj->encoded if encode()
* has already been run. Unless a flag is passed to specifically
* re-build the message.
*
* @author Richard Heyes <richard@phpguru.org>
* @version $Revision: 1.3 $
* @package Mail
*/
class Mail_MIMEPart
{
/**
* The encoding type of this part
* @var string
*/
private $encoding;
/**
* An array of subparts
* @var array
*/
private $subparts;
/**
* The output of this part after being built
* @var string
*/
private $encoded;
/**
* Headers for this part
* @var array
*/
private $headers;
/**
* The body of this part (not encoded)
* @var string
*/
private $body;
/**
* Constructor.
*
* Sets up the object.
*
* @param $body - The body of the mime part if any.
* @param $params - An associative array of parameters:
* content_type - The content type for this part eg multipart/mixed
* encoding - The encoding to use, 7bit, 8bit, base64, or quoted-printable
* cid - Content ID to apply
* disposition - Content disposition, inline or attachment
* dfilename - Optional filename parameter for content disposition
* description - Content description
* charset - Character set to use
* @access public
*/
public function __construct($body = '', $params = array())
{
if (!defined('MAIL_MIMEPART_CRLF')) {
define('MAIL_MIMEPART_CRLF', defined('MAIL_MIME_CRLF') ? MAIL_MIME_CRLF : "\r\n", true);
}
foreach ($params as $key => $value) {
switch ($key) {
case 'content_type':
$headers['Content-Type'] = $value . (isset($charset) ? '; charset="' . $charset . '"' : '');
break;
case 'encoding':
$this->encoding = $value;
$headers['Content-Transfer-Encoding'] = $value;
break;
case 'cid':
$headers['Content-ID'] = '<' . $value . '>';
break;
case 'disposition':
$headers['Content-Disposition'] = $value . (isset($dfilename) ? '; filename="' . $dfilename . '"' : '');
break;
case 'dfilename':
if (isset($headers['Content-Disposition'])) {
$headers['Content-Disposition'] .= '; filename="' . $value . '"';
} else {
$dfilename = $value;
}
break;
case 'description':
$headers['Content-Description'] = $value;
break;
case 'charset':
if (isset($headers['Content-Type'])) {
$headers['Content-Type'] .= '; charset="' . $value . '"';
} else {
$charset = $value;
}
break;
}
}
// Default content-type
if (!isset($headers['Content-Type'])) {
$headers['Content-Type'] = 'text/plain';
}
// Default encoding
if (!isset($this->encoding)) {
$this->encoding = '7bit';
}
// Assign stuff to member variables
$this->encoded = array();
$this->headers = $headers;
$this->body = $body;
}
/**
* Encodes and returns the email. Also stores
* it in the encoded member variable
*
* @return An associative array containing two elements,
* body and headers. The headers element is itself
* an indexed array.
*/
public function encode()
{
$encoded =& $this->encoded;
if (!empty($this->subparts)) {
srand((double)microtime()*1000000);
$boundary = '=_' . md5(uniqid(rand()) . microtime());
$this->headers['Content-Type'] .= ';' . MAIL_MIMEPART_CRLF . "\t" . 'boundary="' . $boundary . '"';
// Add body parts to $subparts
for ($i = 0; $i < count($this->subparts); $i++) {
$headers = array();
$tmp = $this->subparts[$i]->encode();
foreach ($tmp['headers'] as $key => $value) {
$headers[] = $key . ': ' . $value;
}
$subparts[] = implode(MAIL_MIMEPART_CRLF, $headers) . MAIL_MIMEPART_CRLF . MAIL_MIMEPART_CRLF . $tmp['body'];
}
$encoded['body'] = '--' . $boundary . MAIL_MIMEPART_CRLF .
implode('--' . $boundary . MAIL_MIMEPART_CRLF, $subparts) .
'--' . $boundary.'--' . MAIL_MIMEPART_CRLF;
} else {
$encoded['body'] = $this->getEncodedData($this->body, $this->encoding) . MAIL_MIMEPART_CRLF;
}
// Add headers to $encoded
$encoded['headers'] =& $this->headers;
return $encoded;
}
/**
* Adds a subpart to current mime part and returns
* a reference to it
*
* @param $body The body of the subpart, if any.
* @param $params The parameters for the subpart, same
* as the $params argument for constructor.
* @return A reference to the part you just added.
*/
public function addSubPart($body, $params)
{
$this->subparts[] = new Mail_MIMEPart($body, $params);
return $this->subparts[count($this->subparts) - 1];
}
/**
* Returns encoded data based upon encoding passed to it
*
* @param $data The data to encode.
* @param $encoding The encoding type to use, 7bit, base64,
* or quoted-printable.
*/
private function getEncodedData($data, $encoding)
{
switch ($encoding) {
case '8bit':
case '7bit':
return $data;
break;
case 'quoted-printable':
return $this->quotedPrintableEncode($data);
break;
case 'base64':
return rtrim(chunk_split(base64_encode($data), 76, MAIL_MIMEPART_CRLF));
break;
default:
return $data;
}
}
/**
* Encodes data to quoted-printable standard.
*
* @param $input The data to encode
* @param $line_max Optional max line length. Should
* not be more than 76 chars
*/
private function quotedPrintableEncode($input , $line_max = 76)
{
$lines = preg_split("/\r?\n/", $input);
$eol = MAIL_MIMEPART_CRLF;
$escape = '=';
$output = '';
while(list(, $line) = each($lines)){
$linlen = strlen($line);
$newline = '';
for ($i = 0; $i < $linlen; $i++) {
$char = substr($line, $i, 1);
$dec = ord($char);
if (($dec == 32) AND ($i == ($linlen - 1))){ // convert space at eol only
$char = '=20';
} elseif($dec == 9) {
; // Do nothing if a tab.
} elseif(($dec == 61) OR ($dec < 32 ) OR ($dec > 126)) {
$char = $escape . strtoupper(sprintf('%02s', dechex($dec)));
}
if ((strlen($newline) + strlen($char)) >= $line_max) { // MAIL_MIMEPART_CRLF is not counted
$output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay
$newline = '';
}
$newline .= $char;
} // end of for
$output .= $newline . $eol;
}
$output = substr($output, 0, -1 * strlen($eol)); // Don't want last crlf
return $output;
}
} // End of class
?>

View File

@ -1,371 +0,0 @@
<?php
/**
* o------------------------------------------------------------------------------o
* | This package is licensed under the Phpguru license. A quick summary is |
* | that for commercial use, there is a small one-time licensing fee to pay. For |
* | registered charities and educational institutes there is a reduced license |
* | fee available. You can read more at: |
* | |
* | http://www.phpguru.org/static/license.html |
* o------------------------------------------------------------------------------o
*
* © Copyright 2008,2009 Richard Heyes
*/
define('SMTP_STATUS_NOT_CONNECTED', 1, true);
define('SMTP_STATUS_CONNECTED', 2, true);
class smtp
{
private $authenticated;
private $connection;
private $recipients;
private $headers;
private $timeout;
private $errors;
private $status;
private $body;
private $from;
private $host;
private $port;
private $helo;
private $auth;
private $user;
private $pass;
/**
* Constructor function. Arguments:
* $params - An assoc array of parameters:
*
* host - The hostname of the smtp server Default: localhost
* port - The port the smtp server runs on Default: 25
* helo - What to send as the HELO command Default: localhost
* (typically the hostname of the
* machine this script runs on)
* auth - Whether to use basic authentication Default: FALSE
* user - Username for authentication Default: <blank>
* pass - Password for authentication Default: <blank>
* timeout - The timeout in seconds for the call Default: 5
* to fsockopen()
*/
public function __construct($params = array())
{
if(!defined('CRLF'))
define('CRLF', "\r\n", TRUE);
$this->authenticated = FALSE;
$this->timeout = 5;
$this->status = SMTP_STATUS_NOT_CONNECTED;
$this->host = 'localhost';
$this->port = 25;
$this->helo = 'localhost';
$this->auth = FALSE;
$this->user = '';
$this->pass = '';
$this->errors = array();
foreach($params as $key => $value){
$this->$key = $value;
}
}
/**
* Connect function. This will, when called
* statically, create a new smtp object,
* call the connect function (ie this function)
* and return it. When not called statically,
* it will connect to the server and send
* the HELO command.
*/
public function connect($params = array())
{
if (!isset($this->status)) {
$obj = new smtp($params);
if($obj->connect()){
$obj->status = SMTP_STATUS_CONNECTED;
}
return $obj;
} else {
$this->connection = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
if (function_exists('socket_set_timeout')) {
@socket_set_timeout($this->connection, 5, 0);
}
$greeting = $this->get_data();
if (is_resource($this->connection)) {
return $this->auth ? $this->ehlo() : $this->helo();
} else {
$this->errors[] = 'Failed to connect to server: '.$errstr;
return FALSE;
}
}
}
/**
* Function which handles sending the mail.
* Arguments:
* $params - Optional assoc array of parameters.
* Can contain:
* recipients - Indexed array of recipients
* from - The from address. (used in MAIL FROM:),
* this will be the return path
* headers - Indexed array of headers, one header per array entry
* body - The body of the email
* It can also contain any of the parameters from the connect()
* function
*/
public function send($params = array())
{
foreach ($params as $key => $value) {
$this->set($key, $value);
}
if ($this->is_connected()) {
// Do we auth or not? Note the distinction between the auth variable and auth() function
if ($this->auth AND !$this->authenticated) {
if(!$this->auth())
return false;
}
$this->mail($this->from);
if (is_array($this->recipients)) {
foreach ($this->recipients as $value) {
$this->rcpt($value);
}
} else {
$this->rcpt($this->recipients);
}
if (!$this->data()) {
return false;
}
// Transparency
$headers = str_replace(CRLF.'.', CRLF.'..', trim(implode(CRLF, $this->headers)));
$body = str_replace(CRLF.'.', CRLF.'..', $this->body);
$body = substr($body, 0, 1) == '.' ? '.'.$body : $body;
$this->send_data($headers);
$this->send_data('');
$this->send_data($body);
$this->send_data('.');
$result = (substr(trim($this->get_data()), 0, 3) === '250');
//$this->rset();
return $result;
} else {
$this->errors[] = 'Not connected!';
return FALSE;
}
}
/**
* Function to implement HELO cmd
*/
private function helo()
{
if(is_resource($this->connection)
AND $this->send_data('HELO '.$this->helo)
AND substr(trim($error = $this->get_data()), 0, 3) === '250' ){
return true;
} else {
$this->errors[] = 'HELO command failed, output: ' . trim(substr(trim($error),3));
return false;
}
}
/**
* Function to implement EHLO cmd
*/
private function ehlo()
{
if (is_resource($this->connection)
AND $this->send_data('EHLO '.$this->helo)
AND substr(trim($error = $this->get_data()), 0, 3) === '250' ){
return true;
} else {
$this->errors[] = 'EHLO command failed, output: ' . trim(substr(trim($error),3));
return false;
}
}
/**
* Function to implement RSET cmd
*/
private function rset()
{
if (is_resource($this->connection)
AND $this->send_data('RSET')
AND substr(trim($error = $this->get_data()), 0, 3) === '250' ){
return true;
} else {
$this->errors[] = 'RSET command failed, output: ' . trim(substr(trim($error),3));
return false;
}
}
/**
* Function to implement QUIT cmd
*/
private function quit()
{
if(is_resource($this->connection)
AND $this->send_data('QUIT')
AND substr(trim($error = $this->get_data()), 0, 3) === '221' ){
fclose($this->connection);
$this->status = SMTP_STATUS_NOT_CONNECTED;
return true;
} else {
$this->errors[] = 'QUIT command failed, output: ' . trim(substr(trim($error),3));
return false;
}
}
/**
* Function to implement AUTH cmd
*/
private function auth()
{
if (is_resource($this->connection)
AND $this->send_data('AUTH LOGIN')
AND substr(trim($error = $this->get_data()), 0, 3) === '334'
AND $this->send_data(base64_encode($this->user)) // Send username
AND substr(trim($error = $this->get_data()),0,3) === '334'
AND $this->send_data(base64_encode($this->pass)) // Send password
AND substr(trim($error = $this->get_data()),0,3) === '235' ){
$this->authenticated = true;
return true;
} else {
$this->errors[] = 'AUTH command failed: ' . trim(substr(trim($error),3));
return false;
}
}
/**
* Function that handles the MAIL FROM: cmd
*/
private function mail($from)
{
if ($this->is_connected()
AND $this->send_data('MAIL FROM:<'.$from.'>')
AND substr(trim($this->get_data()), 0, 2) === '250' ) {
return true;
} else {
return false;
}
}
/**
* Function that handles the RCPT TO: cmd
*/
private function rcpt($to)
{
if($this->is_connected()
AND $this->send_data('RCPT TO:<'.$to.'>')
AND substr(trim($error = $this->get_data()), 0, 2) === '25' ){
return true;
} else {
$this->errors[] = trim(substr(trim($error), 3));
return false;
}
}
/**
* Function that sends the DATA cmd
*/
private function data()
{
if($this->is_connected()
AND $this->send_data('DATA')
AND substr(trim($error = $this->get_data()), 0, 3) === '354' ) {
return true;
} else {
$this->errors[] = trim(substr(trim($error), 3));
return false;
}
}
/**
* Function to determine if this object
* is connected to the server or not.
*/
private function is_connected()
{
return (is_resource($this->connection) AND ($this->status === SMTP_STATUS_CONNECTED));
}
/**
* Function to send a bit of data
*/
private function send_data($data)
{
if(is_resource($this->connection)){
return fwrite($this->connection, $data.CRLF, strlen($data)+2);
} else {
return false;
}
}
/**
* Function to get data.
*/
private function get_data()
{
$return = '';
$line = '';
$loops = 0;
if(is_resource($this->connection)){
while((strpos($return, CRLF) === FALSE OR substr($line,3,1) !== ' ') AND $loops < 100){
$line = fgets($this->connection, 512);
$return .= $line;
$loops++;
}
return $return;
}else
return false;
}
/**
* Sets a variable
*/
public function set($var, $value)
{
$this->$var = $value;
return true;
}
/**
* Function to return the errors array
*/
public function getErrors()
{
return $this->errors;
}
} // End of class
?>

View File

@ -1,556 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2010 David Grant <dave@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
function account_valid_user($user)
{
/* Find any character that doesn't match the valid username characters
* (^ inverts the matching remember */
$x = preg_match('[^a-zA-Z0-9@.-_]',$user);
/* If x==1, a match was found, and the input is bad */
return ($x == 1) ? false : true;
}
function account_valid_password($pass)
{
/* Same as user, but allow more characters */
$x = preg_match('[^a-zA-Z0-9 ~!@#$%^&*()-_=+|;:,<.>/?]',$pass);
/* If x==1, a match was found, and the input is bad */
if($x == 1) return false;
if(strlen($pass) < 6) return false;
return true;
}
/* Duplicate of common.inc.php:generatePassword, which will be deleted
* eventually when ALL users are handled through this file */
function account_generate_password($pwlen=8)
{
//these are good characters that are not easily confused with other characters :)
$available="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789";
$len=strlen($available) - 1;
$key="";
for($x=0;$x<$pwlen;$x++)
$key.=$available{rand(0,$len)};
return $key;
}
function account_set_password($accounts_id, $password = NULL)
{
$save_old = false;
if($password == NULL) {
$q = mysql_query("SELECT passwordset FROM accounts WHERE id='$accounts_id'");
$a = mysql_fetch_assoc($q);
/* Generate a new password */
$password = account_generate_password(12);
/* save the old password only if it's not an auto-generated one */
if($a['passwordset'] != '0000-00-00') $save_old = true;
/* Expire the password */
$save_set = "'0000-00-00'";
} else {
/* Set the password, no expiry, save the old */
$save_old = true;
$save_set = 'NOW()';
}
$p = mysql_escape_string($password);
$set = ($save_old == true) ? 'oldpassword=password, ' : '';
$set .= "password='$p', passwordset=$save_set ";
$query = "UPDATE accounts SET $set WHERE id='$accounts_id'";
mysql_query($query);
echo mysql_error();
return $password;
}
function account_load($id)
{
$id = intval($id);
//we dont want password or the pending email code in here
$q = mysql_query("SELECT id,
username,
link_username_to_email,
passwordset,
email,
pendingemail,
superuser,
deleted,
deleted_datetime,
created
FROM accounts WHERE id='$id'");
if(mysql_num_rows($q) == 0) {
return false;
}
if(mysql_num_rows($q) > 1) {
return false;
}
$a = mysql_fetch_assoc($q);
return $a;
}
function account_get_password($id) {
$id=intval($id);
$q=mysql_query("SELECT password FROM accounts WHERE id='$id'");
$r=mysql_fetch_object($q);
return $r->password;
}
function account_load_by_username($username)
{
$un = mysql_real_escape_string($username);
$q = mysql_query("SELECT * FROM accounts WHERE username='$un'");
if(mysql_num_rows($q) == 0) {
return false;
}
if(mysql_num_rows($q) > 1) {
return false;
}
$a = mysql_fetch_assoc($q);
return $a;
}
function account_create($username,$password=NULL)
{
global $config;
$errMsg = '';
/* Sanity check username */
if(!account_valid_user($username)) {
$errMsg .= i18n('Invalid user name "%1"', array($username)) . "\n";
}else{
/* Make sure the account doesn't exist */
$us = mysql_real_escape_string($username);
$q = mysql_query("SELECT * FROM accounts WHERE username='$us'");
if(mysql_num_rows($q)) {
$errMsg .= i18n("The username %1 is already in use", array($username)) . "\n";
}
}
//if the password is set, make sure its valid, if its null, thats OK, it'll get generated and set by account_set_password
if($password && !account_valid_password($password)) {
$errMsg .= i18n("Invalid password") . "\n";
}
if($errMsg != '') return $errMsg;
/* Create the account */
mysql_query("INSERT INTO accounts (`username`,`created`,`deleted`,`superuser`)
VALUES ('$us', NOW(),'no','no')");
echo mysql_error();
$accounts_id = mysql_insert_id();
account_set_password($accounts_id, $password);
$a = account_load($accounts_id);
return $a;
}
function account_set_email($accounts_id,$email) {
global $config;
//we dont actually set the email until its confirmed, we only set the pending email :p
if(isEmailAddress($email)) {
$code=generatePassword(24);
mysql_query("UPDATE accounts SET email=NULL, pendingemail='".mysql_real_escape_string($email)."', pendingemailcode='$code' WHERE id='$accounts_id'");
$link = account_build_email_confirmation_link($accounts_id);
email_send('account_email_confirmation',$email,array(),array("EMAIL"=>$email,"EMAILCONFIRMATIONLINK"=>$link));
}
}
// generate the email confirmation URL. Separated from account_set_email for use elsewhere.
// returns null if no confirmation code is set for this account
function account_build_email_confirmation_link($accounts_id){
global $config;
$q = mysql_query("SELECT pendingemail, pendingemailcode FROM accounts WHERE id = $accounts_id");
$row = mysql_fetch_assoc($q);
$code = $row['pendingemailcode'];
$email = $row['pendingemail'];
if(trim($code) == ''){
return null;
}
$urlproto = $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
$urlmain = "$urlproto{$_SERVER['HTTP_HOST']}{$config['SFIABDIRECTORY']}";
$urlemailconfirm = "emailconfirmation.php?i=$accounts_id&e=".rawurlencode($email)."&c=".$code;
return $urlmain."/".$urlemailconfirm;
}
// add the specified role to the account's user record for the specified conference
// return true on success, false on failure
function account_add_role($accounts_id, $roles_id, $conferences_id, $password = null){
global $config;
global $conference;
//if we get role as a type string instead of an id (eg, 'teacher'), lets just look it up
if(!is_numeric($roles_id)) {
$tq=mysql_query("SELECT id FROM roles WHERE type='".mysql_real_escape_string($roles_id)."'");
$tr=mysql_fetch_object($tq);
$roles_id=$tr->id;
}
// avoid injections
$accounts_id=intval($accounts_id);
$roles_id=intval($roles_id);
$conferences_id=intval($conferences_id);
$password=mysql_real_escape_string($password);
// make sure the specified id's actually exist
if(mysql_result(mysql_query("SELECT COUNT(*) FROM accounts WHERE id = $accounts_id"), 0) != 1){
return "invalidaccount";
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM roles WHERE id = $roles_id"), 0) != 1){
return "invalidrole";
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM conferences WHERE id = $conferences_id"), 0) != 1){
return "invalidconference";
}
// find out if this account has a user record for this conference
$data = mysql_fetch_array(mysql_query("
SELECT * FROM users
WHERE conferences_id = $conferences_id
AND accounts_id = $accounts_id
"));
if(is_array($data)){
// they do indeed have a user record for this conference. Let's load it
$u = user_load($data['id']);
$users_id = $data['id'];
}else{
// They're not actually connected to this conference, let's hook 'em up
$u = user_create($accounts_id, $conferences_id);
$users_id = $u['id'];
// if this applies to their current session, update their session user id
if($_SESSION['accounts_id'] == $accounts_id && $_SESSION['conferences_id'] == $conferences_id){
$_SESSION['users_id'] = $users_id;
}
}
// we now have the user id that we need, let's check to see whether or not they
// already have the specified role.
if(mysql_result(mysql_query("SELECT COUNT(*) FROM user_roles WHERE users_id = $users_id AND roles_id = $roles_id"), 0) != 0){
// they already have this role. shell_exec("man true");
return 'ok';
}
// see if this role conflicts with existing ones
if(!account_add_role_allowed($accounts_id, $conferences_id, $roles_id)){
return 'invalidrole(account_add_role_allowed)';
}
// get the type of the role (eg. "judge", "participant", etc.)
$role = mysql_result(mysql_query("SELECT type FROM roles WHERE id = $roles_id"), 0);
if($_SESSION['superuser']!='yes') {
// and see if it's a valid one for this conference
if(!array_key_exists($role . '_registration_type', $config)){
return 'invalidrole(_registration_type)';
}
}
if( in_array("admin",$_SESSION['roles']) ||
in_array("config",$_SESSION['roles']) ||
$_SESSION['superuser']=="yes")
{
//do nothing, we're logged in a a superuser, admin or config, so we
//dont want/need to check the types, just go ahead and invite them
//its easie than reversing the logic of the if above.
}
else {
// and let's see if we meet the conditions for the registration type
$error = "";
switch($config[$role . '_registration_type']){
case 'open':
case 'openorinvite':
// this is allowed.
break;
case 'singlepassword':
if($password != $config[$role . '_registration_singlepassword']){
$error = "invalidpassword";
}
break;
case 'schoolpassword':
if($password != null){
$schoolId = $u['schools_id'];
$schoolDat = mysql_fetch_assoc(mysql_query("SELECT registration_password FROM schools WHERE id=$schoolId"));
if(is_array($schoolDat)){
if($password == $schoolDat['registration_password']) $valid = true;
$error = "invalidpassword";
}
}
break;
case 'invite':
if( in_array("teacher",$_SESSION['roles']) && $role=='participant') {
//if they are a teacher, they can add a participant role a-ok
$error = '';
}
else {
$error = 'invalidrole(invite_only)';
}
break;
}
}
if($error != ""){
return $error;
}
// *whew* all conditions have been met. Let's go ahead and create the record
if(!mysql_query("INSERT INTO user_roles (accounts_id, users_id, roles_id, active, complete) VALUES($accounts_id, $users_id, $roles_id, 'yes', 'no')")){
return "mysqlerror:" . mysql_error();
}
$a=account_load($accounts_id);
$password=account_get_password($accounts_id);
//in this case, we want to send to pendingemail if thats all we have, because
//its possible that this is a new user that was just added and we just sent
//the email confirmation email as well, so on new user invitation, they will get
//the invite email as well as the email confirmation email.
if($a['email']) $e=$a['email'];
else if($a['pendingemail']) $e=$a['pendingemail'];
email_send("{$role}_new_invite",
$e,
array("FAIRNAME"=>$conference['name']),
array("FAIRNAME"=>$conference['name'],
"EMAIL"=>$e,
"USERNAME"=>$a['username'],
"PASSWORD"=>$password,
"ROLE"=>$role)
);
// if we made it this far, the role was successfully added
return 'ok';
}
// find out if the specifed role can be added to this account at the specified conference
function account_add_role_allowed($accounts_id, $roles_id, $conferences_id){
$returnval = true;
// avoid injections
$accounts_id *= 1;
$roles_id *= 1;
$conferences_id *= 1;
// get the user id for this account/conference
$userdat = mysql_fetch_assoc(mysql_query("SELECT id FROM users WHERE accounts_id = $accounts_id AND conferences_id = $conferences_id"));
// If this condition isn't met, then the account is not connected to the conference.
// In that case, the role can be allowed as there is no conflict.
if(is_array($userdat)){
$users_id = $userdat['id'];
// get the roles for the specified account at the specified conference
$query = mysql_query("
SELECT * FROM user_roles
WHERE users_id = $users_id
");
while($returnval && $row = mysql_fetch_assoc($query)){
switch($row['type']){
case 'participant':
// Student cant' add any other role
$returnval = false;
break;
default:
if($role == 'participant') {
// No role can add the participant role
$returnval = false;
}
// All other roles can coexist (even the fair role)
break;
}
}
}
return $returnval;
}
// remove the specified role from the account's user record for the specified conference
// return true on success, false on failure
function account_remove_role($accounts_id, $roles_id, $conferences_id){
// avoid injections
$accounts_id *= 1;
$roles_id *= 1;
$conferences_id *= 1;
// make sure the specified id's actually exist
if(mysql_result(mysql_query("SELECT COUNT(*) FROM accounts WHERE id = $accounts_id"), 0) != 1){
return "invalidaccount";
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM roles WHERE id = $roles_id"), 0) != 1){
return "invalidrole";
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM conferences WHERE id = $conferences_id"), 0) != 1){
return "invalidconference";
}
// very little error catching needed here. If the role's there, we hopfully succeed in
// removing it. If it's not, then we succeed in doing nothing
$data = mysql_fetch_array(mysql_query("
SELECT * FROM users
WHERE conferences_id = $conferences_id
AND accounts_id = $accounts_id
"));
if(is_array($data)){
// they do indeed have a user record for this conference.
$users_id = $data['id'];
// Do role-specific remove actions
$role = mysql_result(mysql_query("SELECT `type` FROM roles WHERE id = $roles_id"), 0);
switch($role) {
case 'committee':
mysql_query("DELETE FROM committees_link WHERE accounts_id='{$accounts_id}'");
break;
case 'judge':
mysql_query("DELETE FROM judges_teams_link WHERE users_id='$users_id'");
mysql_query("DELETE FROM judges_specialawards_sel WHERE users_id='$users_id'");
break;
default:
break;
}
// and now we can remove the role link itself
mysql_query("DELETE FROM user_roles WHERE roles_id={$roles_id} AND users_id='$users_id'");
}
return 'ok';
}
// A function for handling updates of any fields that can be modified through an API call.
// returns 'ok' on success, error message otherwise.
function account_update_info($fields){
if($_SESSION['accounts_id']) {
$accounts_id = $_SESSION['accounts_id'];
}else{
return 'you must be logged in to change your account settings';
}
if(!is_array($fields)) return 'account_update_info expects an array';
$message = 'ok';
$updates = array();
foreach($fields as $index => $value){
switch($index){
case 'username':
if(account_valid_user($value)){
$u = mysql_real_escape_string($value);
$q = mysql_query("SELECT id FROM accounts WHERE username = '$u' AND deleted = 'no' AND id != $accounts_id");
if(mysql_num_rows($q) != 0){
$message = "username already in use";
}else{
$updates[$index] = $value;
}
}else{
$message = "invalid username";
}
break;
case 'password':
$q = mysql_query("SELECT password FROM accounts WHERE id='$accounts_id' AND password='" . mysql_real_escape_string($value) . "'");
if(mysql_num_rows($q)){
// ignore this parameter. The password has not changed
}else if(!account_valid_password($value)){
$message = "invalid password";
}else{
$updates[$index] = $value;
}
break;
case 'link_username_to_email':
if(in_array($value, array('yes', 'no'))){
if($value=='yes') {
//if its yes, we can only do it if username==email
if($fields['username']==$fields['email']) {
$updates[$index] = $value;
} else {
$message="username and email must match for link_username_toemail";
}
}
else {
$updates[$index] = $value;
}
}else{
$message = '"link_username_to_email" must be either a "yes" or "no" value';
}
break;
case 'email':
if(isEmailAddress($value)){
$updates[$index] = $value;
}else{
$message = 'invalid e-mail address';
}
break;
default:
$message = 'invalid field name';
}
}
if($message != 'ok'){
return $message;
}
// the data's all been validated, so we can continue with the actual update.
// doing it separately from the above loop to ensure that it's an all-or nothing update;
// none of it will happen if any one part is erroneous.
foreach($updates as $index => $value){
switch($index){
case 'username':
$username = mysql_real_escape_string($value);
mysql_query("UPDATE accounts SET username = '$username' WHERE id = $accounts_id");
break;
case 'password':
account_set_password($accounts_id, mysql_real_escape_string($value));
break;
case 'link_username_to_email':
mysql_query("UPDATE accounts SET link_username_to_email = '$value' WHERE id = $accounts_id");
break;
case 'email':
account_set_email($accounts_id, $value);
break;
}
}
return $message;
}
?>

View File

@ -1,33 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
Copyright (C) 2009 David Grant <dave@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
function activities_status(&$u)
{
global $config;
/* They must select a language */
if(count($u['languages']) < 1) return 'incomplete';
return 'complete';
}

View File

@ -1,190 +0,0 @@
<?php
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?php
require_once('common.inc.php');
require_once('user.inc.php');
require_once('activities.inc.php');
require_once("questions.inc.php");
require_once('user_edit.inc.php');
/* Ensure they're logged in as a judge, volunteer or admin */
user_auth_required(array(), array('judge', 'volunteer', 'admin'));
$edit_id = isset($_GET['users_id']) ? intval($_GET['users_id']) : $_SESSION['users_id'];
if($edit_id != $_SESSION['users_id'])
user_auth_required('admin');
else
user_auth_required();
$u = user_load($edit_id);
// load the times at which the various events are happening
$times = array();
$q = mysql_query("
SELECT schedule.id, date, hour, minute, duration, title
FROM schedule
JOIN events ON schedule.events_id = events.id
WHERE schedule.conferences_id = {$conference['id']}
ORDER BY date, hour, minute
");
$x = 0;
while($r = mysql_fetch_assoc($q)){
$dateParts = explode('-', $r['date']);
$startTime = mktime($r['hour'], $r['minute'], 0, $dateParts[1], $dateParts[2], $dateParts[0]);
$endTime = $startTime + $r['duration'] * 60;
$times[$r['id']] = array(
'date' => $r['date'],
'starttime' => date('g:ia', $startTime),
'endtime' => date('g:ia', $endTime),
'name' => $r['title'],
);
}
switch($_GET['action']) {
case 'save':
if(!is_array($_POST['languages'])) $_POST['languages']=array();
$u['languages'] = array();
foreach($_POST['languages'] AS $val)
$u['languages'][] = $val;
$u['willing_chair'] = ($_POST['willing_chair'] == 'yes') ? 'yes' : 'no';
$u['highest_psd'] = stripslashes($_POST['highest_psd']);
$u['available_events'] = array_values($_POST['time']);
user_save($u);
/*
if(is_array($_POST['questions'])){
questions_save_answers("judgereg",$u['id'],$_POST['questions']);
}
*/
happy_("Preferences successfully saved");
$u = user_load($u['id']);
$newstatus=activities_status($u);
?>
<script type="text/javascript">
user_update_tab_status('activities','<?=$newstatus?>');
</script>
<?
exit;
}
$fields = array('languages[]', 'willing_chair','highest_psd','time[]');
$required = array('languages[]');
if(count($times) > 1) $required[] = 'time[]';
?>
<h4><?=i18n("Activity Information")?> - <span class="status_activities"></span></h4>
<br/>
<form class="editor" id="activities_form">
<table width="90%">
<tr><td style="text-align: left" colspan="2"><b><?=i18n('Language(s)')?></b><hr /></td></tr>
<tr><?=user_edit_item($u, 'Languages', 'languages[]', 'languages')?></tr>
<?php if(count($times) > 1) { ?>
<tr><td style="text-align: left" colspan="2"><br /><b><?=i18n('Time Availability')?></b><hr />
<i><?=i18n('Please specify the events you are available for')?></i>
</td></tr>
<?php
// get a list of the times they already have selected
$sel = array();
$q = mysql_query("
SELECT eual.* FROM schedule_users_availability_link eual
JOIN schedule ON schedule.id = eual.schedule_id
WHERE eual.users_id=\"{$u['id']}\"
AND schedule.conferences_id = {$conference['id']}
ORDER BY `schedule`.`date`, `schedule`.`hour`, `schedule`.`minute`
");
while($r = mysql_fetch_assoc($q)) {
foreach($times as $x => $t) {
if($x == $r['schedule_id']){
$sel[] = $x;
}
}
}
$items = array();
foreach($times as $x => $t) {
$items[$x] = "{$t['name']} ({$t['date']} {$t['starttime']} - {$t['endtime']})";
}
echo '<tr>';
user_edit_item($u, 'Time Availability', 'time[]', 'checklist', $items, $sel);
echo '</tr>';
}
//questions_print_answer_editor('judgereg', $u, 'questions');
?>
</table>
<br />
<button><?=i18n("Save Information")?></button>
</form>
<script type="text/javascript">
function activities_save()
{
$("#debug").load("<?=$config['SFIABDIRECTORY']?>/activities.php?action=save&users_id=<?=$u['id']?>", $("#activities_form").serializeArray());
return false;
}
$(document).ready(function() {
$("#activities_form").validate({
errorPlacement: function(error, element) {
if( element.attr('type') == 'checkbox' ) {
error.insertAfter( element.parent("span") );
} else {
error.insertAfter(element);
}
},
rules: {
"languages[]": { required: true },
"time[]": { required: <?=in_array('time[]', $required)?'true':'false'?> },
},
messages: {
"languages[]": { required: "<?=i18n('Please select the language(s) you can work in')?>" },
"time[]": { required: "<?=i18n('Please select the time(s) you are available')?>" }
},
submitHandler: function() {
activities_save();
return false;
},
cancelHandler: function() {
activities_save();
return false;
}
});
user_update_tab_status('activities');
});
</script>

View File

@ -1,144 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
if($_GET['show_types'])
$NAV_IDENT=$_GET['show_types'][0];
if($_POST['show_types'])
$NAV_IDENT=$_POST['show_types'][0];
require_once('../common.inc.php');
require_once('../user.inc.php');
require_once('../judge.inc.php');
user_auth_required('admin');
require_once('judges.inc.php');
if($_GET['action']=="join" && $_GET['accounts_id']) {
//we're making this user join this conference
echo "joining {$_GET['accounts_id']} with {$conference['id']}";
$u = user_create(intval($_GET['accounts_id']), $conference['id']);
echo happy(i18n("User joined conference"));
}
send_header("Account List",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php')
);
$querystr = "SELECT * FROM accounts ORDER BY username";
/*
echo $querystr;
echo "<br />\n";
echo "<br />\n";
*/
$q = mysql_query($querystr);
echo mysql_error();
echo "<br />\n";
$num = mysql_num_rows($q);
echo i18n("Listing %1 account total.",array($num));
echo mysql_error();
echo "<table class=\"tableview\">";
echo "<thead>";
echo "<tr>";
echo " <th>".i18n("Account ID")."</th>";
echo " <th>".i18n("Username")."</th>";
echo " <th>".i18n("Email Address")."</th>";
echo " <th>".i18n("Pending Email")."</th>";
echo " <th>".i18n("User Info")."</th>";
// echo " <th>".i18n("Actions")."</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
$tally = array();
$tally['active'] = array();
$tally['inactive'] = array();
$tally['active']['complete'] = 0;
$tally['active']['incomplete'] = 0;
$tally['active']['na'] = 0;
$tally['inactive']['complete'] = 0;
$tally['inactive']['incomplete'] = 0;
$tally['inactive']['na'] = 0;
while($r=mysql_fetch_assoc($q)) {
// get the role data for this user
echo "<tr>";
echo "<td>";
echo $r['id'];
echo "</td>";
echo "<td>";
echo $r['username'];
echo "</td>";
echo "<td>";
echo $r['email'];
echo "</td><td>";
echo $r['pendingemail'];
echo "</td>";
echo "<td>";
$u=user_load_by_accounts_id($r['id']);
if($u) {
//we can edit them even if they dont have any roles, duh
echo "<b>";
echo "<a href=\"#\" onclick=\"return openeditor({$u['id']})\">";
if($u['firstname'] || $u['lastname']) {
echo $u['firstname']." ".$u['lastname'];
}
else {
echo i18n("No name specified");
}
echo "</a>";
echo "</b>";
echo "<br />";
if(count($u['roles'])) {
echo "<table>";
foreach($u['roles'] AS $r=>$rd) {
echo "<tr><td>";
echo $rd['name'];
echo "</td>";
if($rd['active']=="yes"){ $cl="happy"; $cls=""; } else { $cl="error"; $cls="not "; }
echo "<td class=\"$cl\">{$cls}active</td>";
if($rd['complete']=="yes"){ $cl="happy"; $cls=""; } else { $cl="error"; $cls="not "; }
echo "<td class=\"$cl\">{$cls}complete</td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "no roles";
}
}
else {
echo "no user record for this conference. ";
echo " <a href=\"account_list.php?action=join&accounts_id={$r['id']}\">click to join conference</a>";
}
echo "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
send_footer();
?>

View File

@ -1,23 +1,18 @@
<?php
class annealer {
var $num_buckets;
var $bucket;
var $bucket_cost;
var $bucket_cost_new;
var $cost;
var $start_temp, $start_moves;
var $cost_function_callback;
var $pick_move_callback;
var $update_callback;
var $delta_cost_bucket_ids_callback;
var $iterations;
var $items_per_bucket;
var $max_items_per_bucket;
var $rate;
var $move_bucket_ids;
function annealer($num_buckets, $start_temp, $start_moves, $rate,
$cost_function_cb, $items)
@ -28,19 +23,15 @@ class annealer {
$this->cost_function_callback = $cost_function_cb;
unset($this->pick_move_callback);
unset($this->update_callback);
unset($this->delta_cost_bucket_ids_callback);
$this->bucket_cost = array();
$this->bucket_cost_old = array();
$this->bucket = array();
$this->iterations = 0;
$this->items_per_bucket = ceil(count($items) / $num_buckets);
$this->items_per_bucket = count($items) / $num_buckets;
$this->rate = $rate;
$this->max_items_per_bucket = 0;
$ipb = ceil($this->items_per_bucket);
$i=0;
$this->cost = 0;
/* Assign to buckets */
for($x=0; $x<$num_buckets; $x++) {
unset($b);
$b = array();
@ -50,10 +41,6 @@ class annealer {
$i++;
}
$this->bucket[] = $b;
}
/* Then do costs after all bucket assignments are done */
for($x=0; $x<$num_buckets; $x++) {
$c = $this->cost_function($x);
$this->bucket_cost[] = $c;
$this->cost += $c;
@ -67,19 +54,11 @@ class annealer {
{
$this->pick_move_callback = $func;
}
function set_update_callback($func)
{
$this->update_callback = $func;
}
function set_delta_cost_bucket_ids_callback($func)
{
$this->delta_cost_bucket_ids_callback = $func;
}
function set_max_items_per_bucket($num)
{
$this->max_items_per_bucket = $num;
}
function pick_move()
@ -91,20 +70,13 @@ class annealer {
}
$i1 = rand(0, count($this->bucket[$b1]) -1);
/* Pick a second bucket that is different than the first */
/* Pick a csecond bucket that is different thatn the first */
$b2 = rand(0, $this->num_buckets - 2);
if($b2 >= $b1) $b2++;
if($this->max_items_per_bucket > 0 && count($this->bucket[$b2]) >= $this->max_items_per_bucket) {
/* Can't move b1 into b2, it would exceed the max items per bucket, pick an
* item to swap with */
$i2 = rand(0, count($this->bucket[$b2])-1);
} else {
/* Pick an item, or a blank, in the second bucket */
$i2 = rand(0, count($this->bucket[$b2]));
if($i2 == count($this->bucket[$b2])) $i2 = -1;
}
/* Picket an item, or a blank, in the second bucket */
$i2 = rand(0, count($this->bucket[$b2]));
if($i2 == count($this->bucket[$b2])) $i2 = -1;
// TRACE("Move ($b1,$i1)<->($b2,$i2)\n");
return array($b1, $i1, $b2, $i2);
}
@ -124,66 +96,58 @@ class annealer {
list($b1, $i1, $b2, $i2) = $move;
if($b1 == $b2) {
echo "Called on same bucket, not supported!\n";
exit;
// return $this->compute_delta_cost_same_bucket($move);
return $this->compute_delta_cost_same_bucket($move);
}
$cost = 0;
/* Save the old lists for easy restore */
$b1_old = $this->bucket[$b1];
$b2_old = $this->bucket[$b2];
/* Setup new costs */
$this->bucket_cost_new = $this->bucket_cost;
/* Compute new lists with swapped elements */
if($i2 != -1) { /* Swap */
array_splice($this->bucket[$b1], $i1, 1, $b2_old[$i2]);
array_splice($this->bucket[$b2], $i2, 1, $b1_old[$i1]);
} else { /* Move one to other */
array_splice($this->bucket[$b1], $i1, 1);
$this->bucket[$b2][] = $b1_old[$i1];
$b1_new = array();
$b2_new = array();
/* Make 2 new bucket lists */
for($x=0; $x<count($b1_old); $x++) {
$id = $b1_old[$x];
if($x == $i1) {
/* Swap or remove this index */
if($i2 != -1) $b1_new[] = $b2_old[$i2];
} else {
$b1_new[] = $id;
}
}
/* Get the lists of buckets we need to recompute, by default
* just b1 and b2 */
if(isset ($this->delta_cost_bucket_ids_callback)) {
$cb = $this->delta_cost_bucket_ids_callback;
$ids = $cb($this, $b1);
$ids = array_unique(array_merge($ids, $cb($this, $b2)), SORT_NUMERIC );
} else {
$ids = array($b1, $b2);
for($x=0; $x<count($b2_old); $x++) {
$id = $b2_old[$x];
if($x == $i2) {
/* Swap or remove this index */
$b2_new[] = $b1_old[$i1];
} else {
$b2_new[] = $id;
}
}
// TRACE("Recompute IDs:\n");
// TRACE_R($ids);
if($i2 == -1) $b2_new[] = $b1_old[$i1];
/* Save that list */
$this->move_bucket_ids = $ids;
/* Assign the new item lists to the buckets */
$this->bucket[$b1] = $b1_new;
$this->bucket[$b2] = $b2_new;
/* Compute a delta cost, recompute all costs for all buckets */
foreach($ids as $bucket_id) {
/* Compute costs */
$cost -= $this->bucket_cost[$bucket_id];
$this->bucket_cost_new[$bucket_id] = $this->cost_function($bucket_id);
$cost += $this->bucket_cost_new[$bucket_id];
}
/* Compute costs */
$cost -= $this->bucket_cost[$b1];
$cost -= $this->bucket_cost[$b2];
$c1 = $this->cost_function($b1);
$c2 = $this->cost_function($b2);
/* Save the new lists */
$b1_new = $this->bucket[$b1];
$b2_new = $this->bucket[$b2];
$cost += $c1 + $c2;
/* Return to the original bucket lists */
$this->bucket[$b1] = $b1_old;
$this->bucket[$b2] = $b2_old;
return array($cost, array($b1_new, $b2_new));
return array($cost, array($c1, $b1_new, $c2, $b2_new));
}
/*
function compute_delta_cost_same_bucket($move)
{
list($b1, $i1, $b2, $i2) = $move;
@ -193,10 +157,10 @@ class annealer {
$b_old = $this->bucket[$b1];
$b_new = array();
/* Make a new bucket list
/* Make a new bucket list */
for($x=0; $x<count($b_old); $x++) {
if($x == $i1) {
/* Swap or remove this index
/* Swap or remove this index */
if($i2 != -1) $b_new[] = $b_old[$i2];
} else if($x == $i2) {
$b_new[] = $b_old[$i1];
@ -205,31 +169,32 @@ class annealer {
}
}
/* Assign the new item lists to the buckets
/* Assign the new item lists to the buckets */
$this->bucket[$b1] = $b_new;
/* Compute costs
/* Compute costs */
$cost -= $this->bucket_cost[$b1];
$c1 = $this->cost_function($b1);
$cost += $c1;
/* Return to the original bucket lists
/* Return to the original bucket lists */
$this->bucket[$b1] = $b_old;
return array($cost, array($c1, $b_new, 0, array()));
}
*/
function accept_move($move, $movedata)
{
list($b1, $i1, $b2, $i2) = $move;
list($b1_new, $b2_new) = $movedata;
list($c1, $b1_new, $c2, $b2_new) = $movedata;
$this->bucket[$b1] = $b1_new;
if($b1 != $b2) $this->bucket[$b2] = $b2_new;
$this->bucket_cost = $this->bucket_cost_new;
$this->bucket_cost[$b1] = $c1;
if($b1 != $b2) {
$this->bucket[$b2] = $b2_new;
$this->bucket_cost[$b2] = $c2;
}
}
function anneal()
@ -246,7 +211,6 @@ class annealer {
// $this->print_buckets();
$estimated_iterations = ceil(log(0.1 / $this->start_temp, $this->rate));
// print_r($this);
$iterations = 0;
while(1) {
$moves = $this->start_moves;
@ -311,34 +275,6 @@ class annealer {
break;
// TRACE("Cost is {$this->cost}\n");
$temperature *= $this->rate;
/*
FIXME: README: NOTE: TODO:
From Kris, 2009-03-24
Dave do you think we should consider something like this?
<Kris_School_1> here's the schedule i use in my academic annealer:
if( _params._useVPRTempSchedule ) {
// This is VPR's temperature schedule...
if( successRate > 0.96 ) {
_temp *= 0.5;
} else if( successRate > 0.8 ) {
_temp *= 0.9;
} else if( successRate > 0.15 || !windowsSized ) {
_temp *= 0.95;
} else {
_temp *= 0.8;
}
} else {
// This is identical to Aaarts and Van Laarhaven.
real64 kappa = _params._tempReduction; // 1.0 == slow, 10 = reasonable, 100 == fast
real64 sqrvar = std::sqrt( variance );
if( variance <= EPSNEG || sqrvar <= EPSNEG ) {
_temp = 0.;
} else {
_temp = _temp * ( sqrvar / ( sqrvar + kappa * _temp ) );
}
}
*/
}
TRACE("Annealing complete. {$this->iterations} iterations. Final cost is {$this->cost}\n");
}

View File

@ -24,8 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
require_once("awards.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
send_header('Create All Divisional Awards',
array('Committee Main' => 'committee_main.php',
@ -39,31 +38,21 @@
if($_GET['award_types_id']) $award_types_id=$_GET['award_types_id'];
else if($_POST['award_types_id']) $award_types_id=$_POST['award_types_id'];
if($_GET['force'] == "true") {
$q=mysql_query("SELECT id FROM award_awards WHERE award_types_id='1' AND conferences_id='{$conference['id']}'");
while($r=mysql_fetch_object($q)) {
award_delete($r->id);
}
}
//first, we can only do this if we dont have any type=divisional awards created yet
$q=mysql_query("SELECT COUNT(id) AS num FROM award_awards WHERE award_types_id='1' AND conferences_id='{$conference['id']}'");
$q=mysql_query("SELECT COUNT(id) AS num FROM award_awards WHERE award_types_id='1' AND year='{$config['FAIRYEAR']}'");
$r=mysql_fetch_object($q);
if($r->num)
{
echo error(i18n("%1 Divisional awards already exist. There must not be any divisional awards in order to run this wizard",array($r->num)));
echo "<p><a href='award_awardcreatedivisional.php?force=true'>" . i18n("Proceed Anyways?") . "</a> ";
echo i18n("This will delete all existing divisional awards.");
echo "</p>";
}
else
{
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='".$conference['id']."' ORDER BY id");
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
$div[$r->id]=$r->division;
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' ORDER BY id");
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
$cat[$r->id]=$r->category;
@ -71,7 +60,7 @@ if($_GET['force'] == "true") {
$ckeys = array_keys($cat);
if($config['filterdivisionbycategory']=="yes") {
$q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE conferences_id='".$conference['id']."' ORDER BY projectdivisions_id,projectcategories_id");
$q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE year='".$config['FAIRYEAR']."' ORDER BY projectdivisions_id,projectcategories_id");
$divcat=array();
while($r=mysql_fetch_object($q)) {
$divcat[]=array("c"=>$r->projectcategories_id,"d"=>$r->projectdivisions_id);
@ -90,7 +79,7 @@ if($_GET['force'] == "true") {
if($_GET['action']=="create" && $_GET['sponsors_id'])
{
$q=mysql_query("SELECT * FROM award_prizes WHERE conferences_id='-1' AND award_awards_id='0' ORDER BY `order`");
$q=mysql_query("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`");
$prizes=array();
while($r=mysql_fetch_object($q))
{
@ -117,27 +106,27 @@ if($_GET['force'] == "true") {
$c_category=$cat[$c_id];
echo i18n("Creating %1 - %2",array($c_category,$d_division))."<br />";
mysql_query("INSERT INTO award_awards (sponsors_id,award_types_id,name,criteria,`order`,conferences_id) VALUES (
mysql_query("INSERT INTO award_awards (sponsors_id,award_types_id,name,criteria,`order`,year) VALUES (
'{$_GET['sponsors_id']}',
'1',
'$c_category - $d_division',
'".i18n("Best %1 projects in the %2 division",array($c_category,$d_division))."',
'$ord',
'{$conference['id']}'
'{$config['FAIRYEAR']}'
)");
echo mysql_error();
$award_awards_id=mysql_insert_id();
mysql_query("INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,conferences_id) VALUES ('$award_awards_id','$c_id','{$conference['id']}')");
mysql_query("INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,conferences_id) VALUES ('$award_awards_id','$d_id','{$conference['id']}')");
mysql_query("INSERT INTO award_awards_projectcategories (award_awards_id,projectcategories_id,year) VALUES ('$award_awards_id','$c_id','{$config['FAIRYEAR']}')");
mysql_query("INSERT INTO award_awards_projectdivisions (award_awards_id,projectdivisions_id,year) VALUES ('$award_awards_id','$d_id','{$config['FAIRYEAR']}')");
$ord++;
echo "&nbsp;&nbsp;".i18n("Prizes: ");
foreach($prizes AS $prize)
{
mysql_query("INSERT INTO award_prizes (award_awards_id,cash,scholarship,value,prize,number,`order`,excludefromac,trophystudentkeeper,trophystudentreturn,trophyschoolkeeper,trophyschoolreturn,conferences_id) VALUES (
mysql_query("INSERT INTO award_prizes (award_awards_id,cash,scholarship,value,prize,number,`order`,excludefromac,trophystudentkeeper,trophystudentreturn,trophyschoolkeeper,trophyschoolreturn,year) VALUES (
'$award_awards_id',
'{$prize['cash']}',
'{$prize['scholarship']}',
@ -150,7 +139,7 @@ if($_GET['force'] == "true") {
'{$prize['trophystudentreturn']}',
'{$prize['trophyschoolkeeper']}',
'{$prize['trophyschoolreturn']}',
'{$conference['id']}'
'{$config['FAIRYEAR']}'
)");
echo $prize['prize'].",";
}
@ -183,10 +172,10 @@ if($_GET['force'] == "true") {
echo "</select>";
echo "</td></tr>";
echo "<tr><td>".i18n("Prizes")."</td><td><a href=\"award_awards.php?action=edit_prize_template\">Edit prize template for divisional awards</a>";
//the 'generic' template prizes for the awards are stored with conferences_id =-1 and award_awards_id=0
echo "<tr><td>".i18n("Prizes")."</td><td><a href=\"award_prizes.php?award_awards_id=-1\">Edit prize template for divisional awards</a>";
//the 'generic' template prizes for the awards are stored with year =-1 and award_awards_id=0
$q=mysql_query("SELECT * FROM award_prizes WHERE conferences_id='-1' AND award_awards_id='0' ORDER BY `order`");
$q=mysql_query("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`");
if(mysql_num_rows($q))
{

File diff suppressed because it is too large Load Diff

View File

@ -23,16 +23,18 @@
<?
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('admin');
user_auth_required('committee', 'admin');
require_once('curl.inc.php');
require_once('awards.inc.php');
send_header("Download Awards",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Awards Main' => 'admin/awards.php' ));
switch($_GET['action']) {
case 'check':
$fairs_id = intval($_GET['fairs_id']);
$q=mysql_query("SELECT * FROM fairs WHERE id='$fairs_id'");
function check_source($source)
{
global $config;
$q=mysql_query("SELECT * FROM fairs WHERE id='$source'");
$fair=mysql_fetch_assoc($q);
if(!($fair['username'] && $fair['password'])) {
echo error(i18n("Username and Password are not set for source '%1'. Please set them in the SFIAB Configuration/External Award Sources editor first",array($r->name)));
@ -42,10 +44,10 @@ case 'check':
echo i18n("Checking %1 for awards...",array($fair['name']));
echo "<br />";
if($fair['type'] == 'ysc') {
if($fair['type'] == 'ysf') {
$req=array("awardrequest"=>array(
"username"=>$fair['username'],
"password"=>$fair['password'],
"username"=>$r->username,
"password"=>$r->password,
"year"=>$config['FAIRYEAR'],
)
);
@ -61,23 +63,24 @@ case 'check':
exit;
}
echo notice(i18n('Server said: Success'));
// echo "sending [".nl2br(htmlspecialchars($xmldata))."]";
$keys=array_keys($data);
if(!array_key_exists('awards', $data)) {
echo error(i18n("Invalid XML response. Expecting '%1' in '%2'",array("awards",join(',',array_keys($data)))));
// echo "response=".print_r($data);
// echo "response=".print_r($datastream);
return;
}
//get a list of all the existing awards for this external source
$aq=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$fairs_id' AND conferences_id='{$conference['id']}'");
$aq=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$source' AND year='{$config['FAIRYEAR']}'");
$existingawards=array();
while($ar=mysql_fetch_object($aq)) {
$existingawards[$ar->id] = true;
}
echo "<i>";
$ar=$response['awardresponse'][0];
$awards = $data['awards'];
$postback = $data['postback'];
echo i18n("Postback URL: %1",array($postback))." <br />";
@ -90,9 +93,6 @@ case 'check':
return;
}
$divs = projectdivisions_load();
$cats = projectcategories_load();
foreach($awards as $award) {
$identifier=$award['identifier'];
$year=$award['year'];
@ -108,8 +108,8 @@ case 'check':
$tq=mysql_query("SELECT * FROM award_awards WHERE
external_identifier='$identifier' AND
award_source_fairs_id='$fairs_id' AND
conferences_id='{$conference['id']}'");
award_source_fairs_id='$source' AND
year='$year'");
if(mysql_num_rows($tq) == 0) {
/* Award doesn't exist, create it, then update it with the common code below */
mysql_query("INSERT INTO award_awards (award_types_id,
@ -117,13 +117,8 @@ case 'check':
award_source_fairs_id)
VALUES (2,'{$year}',
'".mysql_escape_string($identifier)."',
'$fairs_id')");
'$source')");
$award_id=mysql_insert_id();
/* By default make all divs/cats eligible */
foreach($divs as $id=>$d)
mysql_query("INSERT INTO award_awards_projectdivisions(award_awards_id,projectdivisions_id,conferences_id) VALUES ('$award_id','$id','{$conference['id']}')");
foreach($cats as $id=>$c)
mysql_query("INSERT INTO award_awards_projectcategories(award_awards_id,projectcategories_id,conferences_id) VALUES ('$award_id','$id','{$conference['id']}')");
} else {
echo i18n("Award already exists, updating info")."<br />";
$awardrecord=mysql_fetch_object($tq);
@ -139,24 +134,16 @@ case 'check':
if($sponsorr=mysql_fetch_object($sponsorq)) {
$sponsor_id=$sponsorr->id;
} else {
mysql_query("INSERT INTO sponsors (organization,year,notes)
VALUES ('$sponsor_str','$year','".mysql_escape_string("Imported from external source: $r->name")."')");
echo mysql_error();
mysql_query("INSERT INTO sponsors (organization,year,notes,confirmed)
VALUES ('$sponsor_str','$year','".mysql_escape_string("Imported from external source: $r->name")."','yes')");
$sponsor_id=mysql_insert_id();
}
$self_nominate = ($award['self_nominate'] == 'yes') ? 'yes' : 'no';
$schedule_judges = ($award['schedule_judges'] == 'yes') ? 'yes' : 'no';
mysql_query("UPDATE award_awards SET
sponsors_id='$sponsor_id',
name='".mysql_escape_string($award['name_en'])."',
criteria='".mysql_escape_string($award['criteria_en'])."',
external_postback='".mysql_escape_string($postback)."',
external_register_winners='".(($award['external_register_winners']==1)?1:0)."',
external_additional_materials='".(($award['external_additional_materials']==1)?1:0)."',
self_nominate='$self_nominate',
schedule_judges='$schedule_judges'
external_postback='".mysql_escape_string($postback)."'
WHERE
id='$award_id'
AND external_identifier='".mysql_escape_string($identifier)."'
@ -166,135 +153,112 @@ case 'check':
//update the prizes
$prizes = $award['prizes'];
if(!is_array($prizes)) {
continue;
}
echo i18n("Number of prizes: %1",array(count($prizes)))."<br />";
/* Get existing prizes */
$pq=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$award_id'");
$existingprizes=array();
while($pr=mysql_fetch_assoc($pq))
$existingprizes[$pr['prize']]=$pr;
/* Iterate over the downloaded pizes */
foreach($prizes AS $prize) {
//if it doesn't exist, add it
if(!array_key_exists($prize['prize_en'],$existingprizes)) {
/* Add a base entry, then update it below, yes it's two sql queries,
* but it's much shorter code, and means changing things in only
* one spot */
echo "&nbsp;".i18n("Adding prize %1",array($prize['prize_en']))."<br />";
$p = mysql_escape_string(stripslashes($prize['prize_en']));
mysql_query("INSERT INTO award_prizes (award_awards_id,prize,year,external_identifier)
VALUES ('$award_id','$p','$year','$p')");
$prize_id = mysql_insert_id();
} else {
$ep=$existingprizes[$prize['prize_en']];
echo "&nbsp;".i18n("Updating prize %1",array($ep['prize']))."<br />";
$prize_id = $ep['id'];
//remove it from the list
unset($existingprizes[$ep['prize']]);
if(is_array($prizes) && count($prizes) > 0) {
echo i18n("Number of prizes: %1",array(count($prizes)))."<br />";
$pq=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$award_id'");
//get a list of all the existing prizes
$existingprizes=array();
while($pr=mysql_fetch_object($pq)) {
$existingprizes[$pr->external_identifier]=$pr;
}
if(!array_key_exists('identifier', $prize)) $prize['identifier'] = $prize['prize_en'];
foreach($prizes AS $prize) {
//if it doesn't exist, add it
if(!array_key_exists($prize['identifier'],$existingprizes)) {
/* Add a base entry, then update it below, yes it's two sql queries,
* but it's much shorter code, and means changing things in only
* one spot */
echo "&nbsp;".i18n("Adding prize %1",array($prize['identifier']))."<br />";
mysql_query("INSERT INTO award_prizes (award_awards_id,year,externa_identifier)
VALUES ('$award_id','$year',".mysql_escape_string($prize['identifier'])."')");
} else {
$ep=$existingprizes[$prize['identifier']];
echo "&nbsp;".i18n("Updating prize %1",array($ep->external_identifier))."<br />";
}
mysql_query("UPDATE award_prizes SET
cash='".intval($prize['cash'])."',
scholarship='".intval($prize['scholarship'])."',
value='".intval($prize['value'])."',
prize='".mysql_escape_string($prize['prize_en'])."',
number='".intval($prize['number'])."',
`order`='".intval($prize['ord'])."',
external_identifier='".mysql_real_escape_string(stripslashes($prize['identifier']))."',
trophystudentkeeper='".intval($prize['trophystudentkeeper'])."',
trophystudentreturn='".intval($prize['trophystudentreturn'])."',
trophyschoolkeeper='".intval($prize['trophyschoolkeeper '])."',
trophyschoolreturn='".intval($prize['trophyschoolreturn'])."'
WHERE
id='$prize_id'");
if(!array_key_exists($prize['identifier'],$existingprizes)) {
$ep=$existingprizes[$prize['identifier']];
echo mysql_error();
mysql_query("UPDATE award_prizes SET
cash='".intval($prize['cash'])."',
scholarship='".intval($prize['scholarship'])."',
value='".intval($prize['value'])."',
prize='".mysql_escape_string($prize['prize_en'])."',
number='".intval($prize['number'])."',
`order`='".intval($prize['ord'])."'
WHERE
id='$ep->id'");
//remove it from the list
unset($existingprizes[$ep->external_identifier]);
}
//if an entry exists thats not in the xml -> delete it
foreach($existingprizes AS $ep) {
echo "&nbsp;".i18n("Removing prize %1",array($ep->external_identifier))."<br />";
mysql_query("DELETE FROM award_prizes WHERE id='$ep->id'");
}
}
//FIXME: update the translations
}
/* Delete local entries that weren't downloaded */
foreach($existingprizes AS $ep) {
echo "&nbsp;".i18n("Removing prize %1",array($ep['prize']))."<br />";
award_prize_delete($ep['id']);
}
}
echo "<br />";
//remove any awards that are left in the $existingawards array, they must have been removed from the source
foreach($existingawards AS $aid=>$val) {
//remove any awards that are left in the $existingawards array, they must have been removed from the source
foreach($existingawards AS $aid) {
echo i18n("Removing award id %1 that was removed from external source",array($aid))."<br />";
award_delete($aid);
mysql_query("DELETE FROM award_prizes WHERE award_awards_id='$aid'");
mysql_query("DELETE FROM award_awards WHERE id='$aid'");
}
echo "</i>";
exit;
}
send_header("Download Awards",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Awards Main' => 'admin/awards.php' ));
?>
<script type="text/javascript">
function award_download(id)
{
if(id == -1) return false;
$("#award_download_status").load("<?=$_SERVER['PHP_SELF']?>?action=check&fairs_id="+id);
}
</script>
<?
if(!function_exists('curl_init')) {
echo error(i18n("CURL Support Missing"));
echo notice(i18n("Your PHP installation does not support CURL. You will need to have CURL support added by your system administrator before being able to access external award sources"));
$links=false;
} else {
$links=true;
}
?>
<table class="tableview"><thead>
<tr><th><?=i18n("Source Name")?></th>
<th><?=i18n("Source Location URL")?></th>
<th><?=i18n("Check")?></th>
</tr></thead>
<?
$q=mysql_query("SELECT * FROM fairs WHERE enable_awards='yes' ORDER BY name");
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo "<td>{$r->name}</td>\n";
echo "<td>{$r->url}</td>";
echo "<td align=\"center\">";
if($links)
echo "<a href=\"#\" onclick=\"award_download({$r->id})\">".i18n("check")."</a>";
else
echo "n/a";
echo "</td>";
echo "</tr>";
// $checkurl.="&check[]={$r->id}";
}
/*
if($links)
echo "<a href=\"award_download.php?action=check$checkurl\">".i18n("Check all sources")."</a>";
*/
?>
</table>
<br />
<div id="award_download_status"></div>
<?
if($_GET['action']=="check") {
if(count($_GET['check'])) {
foreach($_GET['check'] AS $checksource) {
check_source(intval($checksource));
echo "<br />";
}
} else {
echo error(i18n("No sources available to check"));
}
} else {
if(!function_exists('curl_init')) {
echo error(i18n("CURL Support Missing"));
echo notice(i18n("Your PHP installation does not support CURL. You will need to have CURL support added by your system administrator before being able to access external award sources"));
$links=false;
} else {
$links=true;
}
$q=mysql_query("SELECT * FROM fairs WHERE enable_awards='yes' ORDER BY name");
echo "<table class=\"tableview\">";
echo "<tr><th>".i18n("Source Name")."</th>";
echo "<th>".i18n("Source Location URL")."</th>";
echo "<th>".i18n("Check")."</th>";
echo "</tr>";
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo "<td>{$r->name}</td>\n";
echo "<td>{$r->url}</td>";
echo "<td align=\"center\">";
if($links)
echo "<a href=\"award_download.php?action=check&check[]={$r->id}\">".i18n("check")."</a>";
else
echo "n/a";
echo "</td>";
echo "</tr>";
$checkurl.="&check[]={$r->id}";
}
echo "</table>\n";
echo "<br />";
if($links)
echo "<a href=\"award_download.php?action=check$checkurl\">".i18n("Check all sources")."</a>";
}
send_footer();
?>

250
admin/award_prizes.php Normal file
View File

@ -0,0 +1,250 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
send_header("Award Prizes",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Awards Main' => 'admin/awards.php',
'Awards Management' => 'admin/award_awards.php')
);
if($_GET['award_awards_id'])
$award_awards_id=$_GET['award_awards_id'];
else if($_POST['award_awards_id'])
$award_awards_id=$_POST['award_awards_id'];
?>
<?
if($award_awards_id)
{
if($award_awards_id==-1)
{
$award->name="Generic Prize Template";
}
else
{
$q=mysql_query("SELECT * FROM award_awards WHERE id='".$award_awards_id."'");
$award=mysql_fetch_object($q);
}
if($_POST['save']=="edit" || $_POST['save']=="add")
{
if($_POST['save']=="add")
{
if($award_awards_id==-1)
$q=mysql_query("INSERT INTO award_prizes (award_awards_id,year) VALUES ('0','-1')");
else
$q=mysql_query("INSERT INTO award_prizes (award_awards_id,year) VALUES ('$award_awards_id','".$config['FAIRYEAR']."')");
$id=mysql_insert_id();
}
else
$id=$_POST['id'];
$exec="UPDATE award_prizes SET ".
"prize='".mysql_escape_string(stripslashes($_POST['prize']))."', ".
"cash='".mysql_escape_string(stripslashes($_POST['cash']))."', ".
"scholarship='".mysql_escape_string(stripslashes($_POST['scholarship']))."', ".
"value='".mysql_escape_string(stripslashes($_POST['value']))."', ".
"number='".mysql_escape_string(stripslashes($_POST['number']))."', ".
"excludefromac='".mysql_escape_string(stripslashes($_POST['excludefromac']))."', ".
"trophystudentkeeper='".mysql_escape_string(stripslashes($_POST['trophystudentkeeper']))."', ".
"trophystudentreturn='".mysql_escape_string(stripslashes($_POST['trophystudentreturn']))."', ".
"trophyschoolkeeper='".mysql_escape_string(stripslashes($_POST['trophyschoolkeeper']))."', ".
"trophyschoolreturn='".mysql_escape_string(stripslashes($_POST['trophyschoolreturn']))."', ".
"`order`='".mysql_escape_string(stripslashes($_POST['order']))."' ".
"WHERE id='$id'";
mysql_query($exec);
if($_POST['save']=="add")
echo happy("Prize successfully added");
else
echo happy("Successfully saved changes to prize");
}
if($_POST['action']=="reorder")
{
if(is_array($_POST['reorder']))
{
foreach($_POST['reorder'] AS $key=>$val)
{
mysql_query("UPDATE award_prizes SET `order`='$val' WHERE id='$key'");
}
echo happy("Award Prizes successfully reordered");
}
}
if($_GET['action']=="delete" && $_GET['delete'])
{
mysql_query("DELETE FROM award_prizes WHERE id='".$_GET['delete']."'");
echo happy("Contact successfully deleted");
}
if($_GET['action']=="edit" || $_GET['action']=="add")
{
echo "<a href=\"award_prizes.php?award_awards_id=$award_awards_id\">&lt;&lt; ".i18n("Back to Prizes for %1",array($award->name))."</a>\n";
echo "<br />";
echo "<br />";
if($_GET['action']=="edit")
{
echo "<h3>".i18n("Edit Prize for %1",array($award->name))."</h3>\n";
$buttontext="Save Prize";
$q=mysql_query("SELECT * FROM award_prizes WHERE id='".$_GET['edit']."'");
$r=mysql_fetch_object($q);
}
else if($_GET['action']=="add")
{
echo "<h3>".i18n("Add Prize for %1",array($award->name))."</h3>\n";
$buttontext="Add Prize";
}
$buttontext=i18n($buttontext);
echo "<form method=\"post\" action=\"award_prizes.php\">\n";
echo "<input type=\"hidden\" name=\"award_awards_id\" value=\"$award_awards_id\">\n";
echo "<input type=\"hidden\" name=\"save\" value=\"".$_GET['action']."\">\n";
if($_GET['action']=="edit")
echo "<input type=\"hidden\" name=\"id\" value=\"".$_GET['edit']."\">\n";
echo "<table class=\"tableedit\">\n";
echo "<tr><td>".i18n("Prize Description")."<br />(".i18n("If non cash/scholarship").")</td><td></td><td><input type=\"text\" id=\"prize\" name=\"prize\" value=\"".htmlspecialchars($r->prize)."\" size=\"40\" maxlength=\"128\" /><script type=\"text/javascript\">translateButton('prize');</script></td></tr>\n";
echo "<tr><td>".i18n("Cash Amount")."</td><td>\$</td><td><input type=\"text\" name=\"cash\" value=\"".htmlspecialchars($r->cash)."\" size=\"10\" maxlength=\"10\" /></td></tr>\n";
echo "<tr><td>".i18n("Scholarship Amount")."</td><td>\$</td><td><input type=\"text\" name=\"scholarship\" value=\"".htmlspecialchars($r->scholarship)."\" size=\"10\" maxlength=\"10\" /></td></tr>\n";
echo "<tr><td>".i18n("Prize Value")."</td><td>\$</td><td><input type=\"text\" name=\"value\" value=\"".htmlspecialchars($r->value)."\" size=\"10\" maxlength=\"10\" /></td></tr>\n";
echo "<tr><td>".i18n("Number available")."</td><td></td><td><input type=\"text\" name=\"number\" value=\"".htmlspecialchars($r->number)."\" size=\"3\" maxlength=\"5\" /></td></tr>\n";
echo "<tr><td>".i18n("Order")."</td><td></td><td><input type=\"text\" name=\"order\" value=\"".htmlspecialchars($r->order)."\" size=\"3\" maxlength=\"5\" /></td></tr>\n";
echo "<tr><td valign=\"top\">".i18n("Plaque/Trophy")."</td><td align=\"right\" colspan=\"1\">";
if($r->trophystudentkeeper==1) $ch="checked=\"checked\""; else $ch="";
echo "<input $ch type=\"checkbox\" name=\"trophystudentkeeper\" value=\"1\"></td><td>".i18n("Student(s) keeper trophy")."</td></tr>";
echo "<tr><td align=\"right\" colspan=\"2\">";
if($r->trophystudentreturn==1) $ch="checked=\"checked\""; else $ch="";
echo "<input $ch type=\"checkbox\" name=\"trophystudentreturn\" value=\"1\"></td><td>".i18n("Student(s) annual return/reuse trophy")."</td></tr>";
echo "<tr><td align=\"right\" colspan=\"2\">";
if($r->trophyschoolkeeper==1) $ch="checked=\"checked\""; else $ch="";
echo "<input $ch type=\"checkbox\" name=\"trophyschoolkeeper\" value=\"1\"></td><td>".i18n("School keeper trophy")."</td></tr>";
echo "<tr><td align=\"right\" colspan=\"2\">";
if($r->trophyschoolreturn==1) $ch="checked=\"checked\""; else $ch="";
echo "<input $ch type=\"checkbox\" name=\"trophyschoolreturn\" value=\"1\"></td><td>".i18n("School annual return/reuse trophy")."</td></tr>";
echo "<tr><td>".i18n("Awards Ceremony")."</td><td align=\"right\" colspan=\"1\">";
if($r->excludefromac==1) $ch="checked=\"checked\""; else $ch="";
echo "<input $ch type=\"checkbox\" name=\"excludefromac\" value=\"1\"></td><td>".i18n("Exclude this prize from the award ceremony script")."</td></tr>";
echo "<tr><td colspan=\"3\" align=\"center\"><input type=\"submit\" value=\"$buttontext\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
}
else
{
echo "<br />";
echo "<a href=\"award_prizes.php?award_awards_id=$award_awards_id&action=add\">".i18n("Add New Prize to %1",array($award->name))."</a>\n";
echo "<br />";
if($award_awards_id==-1)
{
$q=mysql_query("SELECT * FROM award_prizes WHERE year='-1' AND award_awards_id='0' ORDER BY `order`");
}
else
{
$q=mysql_query("SELECT * FROM award_prizes WHERE year='".$config['FAIRYEAR']."' AND award_awards_id='$award_awards_id' ORDER BY `order`");
}
if(mysql_num_rows($q))
{
echo "<form method=\"post\" action=\"award_prizes.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"reorder\">";
echo "<input type=\"hidden\" name=\"award_awards_id\" value=\"$award_awards_id\">";
echo "<table class=\"tableview\">";
echo "<tr>";
echo " <th>".i18n("Order")."</th>";
echo " <th>".i18n("Prize Description")."</th>";
echo " <th>".i18n("Cash")."</th>";
echo " <th>".i18n("Scholarship")."</th>";
echo " <th>".i18n("Value")."</th>";
echo " <th>".i18n("# Available")."</th>";
echo " <th>Actions</th>";
echo "</tr>\n";
$hasexternal=false;
while($r=mysql_fetch_object($q))
{
if($r->external_identifier){ $cl="class=\"externalaward\""; $hasexternal=true; } else $cl="";
echo "<tr $cl>\n";
echo " <td><input type=\"text\" name=\"reorder[$r->id]\" value=\"$r->order\" size=\"3\" /></td>\n";
echo " <td>$r->prize</td>\n";
echo " <td align=\"right\">";
if($r->cash) echo "\$$r->cash";
else echo "&nbsp;";
echo " </td>";
echo " <td align=\"right\">";
if($r->scholarship) echo "\$$r->scholarship";
else echo "&nbsp;";
echo " </td>";
echo " <td align=\"right\">";
if($r->value) echo "\$$r->value";
else echo "&nbsp;";
echo " </td>";
echo " <td align=\"center\">$r->number</td>\n";
echo " <td align=\"center\">";
echo "<a href=\"award_prizes.php?award_awards_id=$award_awards_id&action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
echo "&nbsp;";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this prize?')\" href=\"award_prizes.php?award_awards_id=$award_awards_id&action=delete&delete=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo " </td>\n";
echo "</tr>\n";
}
if($hasexternal)
echo "<tr class=\"externalaward\"><td colspan=\"7\">".i18n("Indicates prize imported from an external source")."</td></tr>";
echo "</table>\n";
echo "<input type=\"submit\" value=\"".i18n("Re-order prizes")."\" />";
echo "</form>";
}
}
}
else
{
echo error(i18n("No Award ID specified"));
echo "<a href=\"award_awards.php\">".i18n("Choose an award")."</a>";
}
send_footer();
?>

View File

@ -20,525 +20,12 @@
Boston, MA 02111-1307, USA.
*/
require_once('../common.inc.php');
require_once('../user.inc.php');
require_once('../projects.inc.php');
require_once('curl.inc.php');
user_auth_required('admin');
//function get_cwsf_award_winners()
function get_winners($awardid, $fairs_id)
{
global $config;
/* Mappings of the name we want => to the column name returned in MYSQL */
$school_fields = array( 'schoolname'=>'school',
'schoollang'=>'schoollang',
'schoollevel'=>'schoollevel',
'board'=>'board',
'district'=>'district',
'phone'=>'phone',
'fax'=>'fax',
'address'=>'address',
'city'=>'city',
'province_code'=>'province_code',
'postalcode'=>'postalcode',
'schoolemail'=>'schoolemail');
/* 'principal'=>'principal',
'sciencehead'=>'sciencehead',
'scienceheademail'=>'scienceheademail',
'scienceheadphone'=>'scienceheadphone');*/
$student_fields = array('firstname'=>'firstname',
'lastname'=>'lastname',
'email'=>'email',
'gender'=>'sex',
'grade'=>'grade',
'language'=>'lang',
'birthdate'=>'dateofbirth',
'address'=>'address',
'city'=>'city',
'province'=>'province',
'postalcode'=>'postalcode',
'phone'=>'phone',
'teachername'=>'teachername',
'teacheremail'=>'teacheremail');
$awards = array();
if($awardid == -1) {
/* Get all for this fair */
$q=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$fairs_id' AND conferences_id='{$conference['id']}'");
if(mysql_num_rows($q) == 0) {
error_("Can't find award id $awardid");
return false;
}
while($a = mysql_fetch_assoc($q)) {
$awards[] = $a;
}
} else {
/* Get the award */
$q=mysql_query("SELECT * FROM award_awards WHERE id='$awardid' AND conferences_id='{$conference['id']}'");
if(mysql_num_rows($q)!=1) {
error_("Can't find award id $awardid");
return false;
}
$award=mysql_fetch_assoc($q);
$awards[] = $award;
}
/* Get the fair for the div/cat mappings */
$q = mysql_query("SELECT * FROM fairs WHERE id='{$award['award_source_fairs_id']}'");
$fair = mysql_fetch_assoc($q);
$catmap = unserialize($fair['catmap']);
$divmap = unserialize($fair['divmap']);
foreach($awards as $award) {
$winners=array( 'id' => $award['id'],
'award_name' => $award['name'],
'external_identifier' => $award['external_identifier'],
'year' => $config['FAIRYEAR'], // FIXME - this needs to be updated to use conference id's
'prizes' => array());
if($fair['type'] != 'sfiab') {
/* YSC Compatability */
$winners['external_postback'] = $award['external_postback'];
}
/* Get the prizes */
$q=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='{$award['id']}'");
while($prize=mysql_fetch_assoc($q)) {
$pid = $prize['id'];
$wq=mysql_query("SELECT projects.* FROM award_prizes
LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id
LEFT JOIN projects ON projects.id=winners.projects_id
WHERE
awards_prizes_id='$pid' AND
winners.conferences_id='{$conference['id']}'");
echo mysql_error();
/* Get all projects assigned to this prize */
$prizewinners = array();
while($project=mysql_fetch_assoc($wq)) {
/* Get the students */
$sq=mysql_query("SELECT * FROM students WHERE registrations_id='{$project['registrations_id']}'
AND conferences_id='{$conference['id']}'");
$students=array();
while($s=mysql_fetch_assoc($sq)) {
/* Get the student's school */
$schoolq=mysql_query("SELECT * FROM schools WHERE id='{$s['schools_id']}'");
$schoolr=mysql_fetch_assoc($schoolq);
$school = array("xml_type"=>"school");/* for ysc compatability */
foreach($school_fields as $k=>$v)
$school[$k] = $schoolr[$v];
/* Pack up the student data too */
$student = array('xml_type'=>'student',/* for ysc compatability */
'school' => $school);
foreach($student_fields as $k=>$v)
$student[$k] = $s[$v];
$students[] = $student;
}
/* Turn our load ID into a server-side cat/div id */
$cat_id = $catmap[$project['projectcategories_id']];
$div_id = $divmap[$project['projectdivisions_id']];
/* Save the project info => students */
$prizewinners[]=array( 'xml_type' => 'project',/* for ysc compatability */
'projectid'=>$project['id'],
'projectnumber'=>$project['projectnumber'],
'title'=>$project['title'],
'abstract'=>$project['summary'],
'language'=>$project['language'],
'projectcategories_id'=>$cat_id,
'projectdivisions_id'=>$div_id,
'client_projectdivisions_id' => $project['projectdivisions_id'],
'students'=>$students );
}
/* Save the prize info => projects */
$winners['prizes'][$prize['prize']] = array(
'id' => $prize['id'],
'name' => $prize['prize'],
'xml_type'=>'prize', /* For ysc compatability */
'identifier'=>$prize['external_identifier'], /* for ysc compatability */
'projects'=>$prizewinners);
}
$all_winners[] = $winners;
}
return $all_winners;
}
function count_winners($awardid, $fairs_id)
{
global $config;
$count = 0;
$awards = array();
if($awardid == -1) {
/* Get all for this fair */
$q=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$fairs_id' AND conferences_id='{$conference['id']}'");
if(mysql_num_rows($q) == 0) {
error_("Can't find award id $awardid");
return 0;
}
while($a = mysql_fetch_assoc($q)) {
$awards[] = $a;
}
} else {
/* Get the award */
$q=mysql_query("SELECT * FROM award_awards WHERE id='$awardid' AND conferences_id='{$conference['id']}'");
if(mysql_num_rows($q)!=1) {
error_("Can't find award id $awardid");
return 0;
}
$award=mysql_fetch_assoc($q);
$awards[] = $award;
}
foreach($awards as $award) {
/* Get the prizes */
$q=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='{$award['id']}'");
while($prize=mysql_fetch_assoc($q)) {
$pid = $prize['id'];
$wq=mysql_query("SELECT COUNT(projects.id) as C FROM award_prizes
LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id
LEFT JOIN projects ON projects.id=winners.projects_id
WHERE
awards_prizes_id='$pid' AND
winners.conferences_id='{$conference['id']}'");
$wc = mysql_fetch_assoc($wq);
$count += $wc['C'];
}
}
return $count;
}
function load_server_cats_divs($fairs_id)
{
global $config;
$q = mysql_query("SELECT * FROM fairs WHERE id='$fairs_id'");
$fair = mysql_fetch_assoc($q);
$req = array('get_categories' => array('year' => $config['FAIRYEAR']), // FIXME - this needs to be updated to use conference id's
'get_divisions' => array('year' => $config['FAIRYEAR'])
);
$data = curl_query($fair, $req);
/* If selected mappings don't exist, try to discover some */
if(trim($fair['catmap']) != '') {
$catmap = unserialize($fair['catmap']);
} else {
$catmap = array();
/* Load ours */
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='{$conference['id']}' ORDER BY mingrade");
while($r=mysql_fetch_object($q)) {
foreach($data['categories'] as $id=>$c) {
if($c['mingrade'] == $r->mingrade) {
$catmap[$r->id] = $id;
break;
}
}
}
}
if(trim($fair['divmap']) != '') {
$divmap = unserialize($fair['divmap']);
} else {
$ret['divmap'] = array();
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='{$conference['id']}' ORDER BY id");
while($r=mysql_fetch_object($q)) {
$lowest = 999;
$lowest_id = 0;
foreach($data['divisions'] as $id=>$d) {
/* Who knew levenshtein was builtin to php as of PHP 4 */
$l = levenshtein($d['division'], $r->division);
if($l < $lowest) {
$lowest = $l;
$lowest_id = $id;
}
}
$divmap[$r->id] = $lowest_id;
}
}
return array($data['categories'], $data['divisions'], $catmap, $divmap);
}
switch($_GET['action']) {
case 'award_upload':
$award_awards_id = intval($_POST['award_awards_id']);
$fairs_id = intval($_POST['fairs_id']);
$divs = $_POST['div'];
$cats = $_POST['cat'];
$all_winners = get_winners($award_awards_id, $fairs_id);
/* Get the fair */
$q = mysql_query("SELECT * FROM fairs WHERE id='$fairs_id}'");
$fair = mysql_fetch_assoc($q);
echo '<br />';
/* Check that we're going to upload something, and override the
* divisions/cats with the divisions taht were set, and the categories
* that were computed */
$upload_something = false;
foreach($all_winners as &$w) {
foreach($w['prizes'] as &$p) {
if(count($p['projects']))
$upload_something = true;
/* Only update divs/cats for SFIAB fairs, the
* YSC/STO awards system doesn't care about divisions, but YSC
* registration does, but that's a different bit of code */
if($fair['type'] != 'sfiab') continue;
foreach($p['projects'] as &$pr) {
$div_id = intval($divs[$w['id']][$p['id']][$pr['projectid']]);
$pr['projectdivisions_id'] = $div_id;
$cat_id = intval($cats[$w['id']][$p['id']][$pr['projectid']]);
$pr['projectcategories_id'] = $cat_id;
}
}
}
if($upload_something == false) {
echo notice(i18n('No winners to be uploaded'));
exit;
}
if($fair['type'] == 'ysc') {
if($award_awards_id == -1) {
echo "Multiple uploads not supported for YSC targets.\n";
exit;
}
/* Pull the single-award out, get_winners() will never
* return more than one award for YSC targets */
$winners = array_shift($all_winners);
$w = array();
foreach($winners['prizes'] as $prize_name=>$prize) {
$w[] = $prize;
}
$req=array("awardwinners"=>array(
"username"=>$fair['username'],
"password"=>$fair['password'],
"identifier"=>$winners['external_identifier'],
"prizes"=>$w,
)
);
$url = $winners['external_postback'];
} else {
$req = array();
$req['awards_upload'] = $all_winners;
$url = ''; /* url is ignored for type = sfiab */
}
echo i18n("Sending winners to %1...", array('<b>'.$fair['name'].'</b>'));
echo '<br />';
// echo "<pre>"; print_r($req); echo "</pre>";
$data = curl_query($fair, $req, $url);
if($data['error'] != 0) {
echo error("Server said: ".htmlspecialchars(print_r($data,true)));
} else {
if(is_array($data['notice']))
echo notice("{$fair['name']} server said: <pre>".join("\n", $data['notice'])."</pre>");
else if(is_array($data['message']))
echo notice("{$fair['name']} server said: <pre>".join("\n", $data['message'])."</pre>");
else if($data['message'])
echo notice("{$fair['name']} server said: <pre>".$data['message']."</pre>");
else
echo notice("{$fair['name']} server said: <pre>".htmlspecialchars(print_r($data,true))."</pre>");
echo happy(i18n("Upload completed successfully"));
}
exit;
case 'catdiv_load':
$fairs_id = intval($_GET['fairs_id']);
list($c, $d, $cm, $dm) = load_server_cats_divs($fairs_id);
$divs = projectdivisions_load();
$q = mysql_query("SELECT * FROM fairs WHERE id='$fairs_id}'");
$fair = mysql_fetch_assoc($q);
?> <h4><?=i18n("Division Mapping")?></h4>
<br />
<form id="catdiv_form">
<input type="hidden" name="fairs_id" value="<?=$fairs_id?>" />
<table class="editor">
<tr><th><?=i18n("Our Division")?></th><th><?=i18n("%1 Division", array($fair['abbrv']))?></th></tr>
<?
foreach($divs as $div) {
echo "<tr><td class=\"label\">{$div['division']}&nbsp;=> </td>";
echo "<td><select name=\"div[{$div['id']}]\" class=\"upload_div\">";
$mapto = $dm[$div['id']];
foreach($d as $sdiv) {
$sel = ($sdiv['id'] == $mapto) ? 'selected="selected"' : '';
echo "<option $sel value=\"{$sdiv['id']}\">{$sdiv['division']}</option>";
}
echo '</select></td></tr>';
}
?>
</table>
</form>
<br />
<?
exit;
case 'catdiv_save':
$fairs_id = intval($_POST['fairs_id']);
$cat = array();
// foreach($_POST['cat'] AS $key=>$c) {
// $cat[intval($key)] = intval($c);
// }
$div = array();
foreach($_POST['div'] AS $key=>$d) {
$div[intval($key)] = intval($d);
}
$catmap = mysql_real_escape_string(serialize($cat));
$divmap = mysql_real_escape_string(serialize($div));
mysql_query("UPDATE fairs SET catmap='$catmap',divmap='$divmap' WHERE id='$fairs_id'");
echo "UPDATE fairs SET catmap='$catmap',divmap='$divmap' WHERE id='$fairs_id'";
echo mysql_error();
happy_("Category/Division mapping information saved");
exit;
case 'additional_materials':
$award_awards_id = intval($_GET['award_awards_id']);
$q = mysql_query("SELECT award_source_fairs_id,external_identifier FROM award_awards WHERE id='$award_awards_id'");
$a = mysql_fetch_assoc($q);
$q = mysql_query("SELECT * FROM fairs WHERE id='{$a['award_source_fairs_id']}'");
$fair = mysql_fetch_assoc($q);
$req = array('award_additional_materials' => array(
'year'=>$config['FAIRYEAR'], // FIXME - this needs to be updated to use conference id's
'identifier'=>$a['external_identifier'])
);
$data = curl_query($fair, $req, $url);
foreach($data['award_additional_materials']['pdf']['header'] as $h)
header($h);
echo base64_decode($data['award_additional_materials']['pdf']['data64']);
exit;
case 'load':
$award_awards_id = intval($_GET['id']);
$fairs_id = intval($_GET['fairs_id']);
$winners = get_winners($award_awards_id, $fairs_id);
$divs = projectdivisions_load();
$q = mysql_query("SELECT * FROM fairs WHERE id='$fairs_id}'");
$fair = mysql_fetch_assoc($q);
echo i18n("The following list of winning projects/students will be sent to: <b>%1</b>. Use the 'Edit Default Division Assignments' button to change the default mappings for divisions. You can over-ride any division assignment by changing it in the list below. Category assignments are done automatically based on grade. When you are happy with the list below, click the 'Upload Winners' button.", array($fair['name']));
if($fair['type'] != 'sfiab') {
echo '<br /><br />';
echo i18n('This server does not collection Division information, all division selection is disabled.');
$server_cats = array();
$server_divs = array();
$catmap =array();
$divmap = array();
$division_disabled = true;
} else {
list($server_cats, $server_divs, $catmap, $divmap) = load_server_cats_divs($fairs_id);
$division_disabled = false;
}
?>
<br /><br />
<button onClick="popup_divmap(<?=$fairs_id?>);return false;" <?=$division_disabled ? 'disabled="disabled' : ''?>
title="<?=i18n("Edit Default Division Assignments")?>"><?=i18n("Edit Default Division Assignments")?></button>
<form id="winner_divs_form">
<input type="hidden" name="fairs_id" value="<?=$fairs_id?>" />
<input type="hidden" name="award_awards_id" value="<?=$award_awards_id?>" />
<table class="tableview">
<?
foreach($winners as &$w) {
echo "<tr><td style=\"border: 0px;\" colspan=\"3\">";
echo "<br /><h3>{$w['award_name']}</h3>";
foreach($w['prizes'] as &$p) {
echo "<tr><td style=\"border: 0px;\" colspan=\"3\">";
echo "<h4>{$p['name']}</h4>";
echo '</td></tr>';
if(count($p['projects']) == 0) {
echo i18n('No winners to upload');
continue;
}
foreach($p['projects'] as &$pr) {
?> <tr><td style="border: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><b><?=$pr['projectnumber']?> - <?=$pr['title']?></b><br/>
<? $highest_grade = 0;
foreach($pr['students'] as &$s) {
echo i18n("Name").": ";
echo $s['firstname']." ".$s['lastname'];
echo "<br />";
echo "&nbsp;"; echo "&nbsp;"; echo "&nbsp;"; echo "&nbsp;";
echo i18n("Grade").": ".$s['grade'];
echo "<br />";
echo "&nbsp;"; echo "&nbsp;"; echo "&nbsp;"; echo "&nbsp;";
echo i18n("School").": ".$s['school']['schoolname'];
echo '<br />';
if($s['grade'] > $highest_grade) $highest_grade = $s['grade'];
}
$server_cat = '';
foreach($server_cats as $c) {
if($highest_grade >= $c['mingrade'] && $highest_grade <= $c['maxgrade']) {
$server_cat = $c['id'];
}
}
?>
</td>
<td>
<table class="default">
<tr> <td align="right" style="border: 0px;"><?=i18n('Our division')?>:</td>
<td><b><?=$divs[$pr['client_projectdivisions_id']]['division']?></td>
</tr>
<?
if($division_disabled == false) {
?> <tr> <td align="right"><?=i18n('%1 Division', array($fair['abbrv']))?>:</td>
<td><select name="div[<?=$w['id']?>][<?=$p['id']?>][<?=$pr['projectid']?>]">
<?
$mapto = $divmap[$pr['client_projectdivisions_id']];
foreach($server_divs as $d) {
$sel = ($mapto == $d['id']) ? 'selected="selected"' : '';
echo "<option $sel value=\"{$d['id']}\">{$d['division']}</option>";
}
?> </select>
<input type="hidden" name="cat[<?=$w['id']?>][<?=$p['id']?>][<?=$pr['projectid']?>]" value="<?=$server_cat?>" />
</td>
</tr>
<tr> <td align="right"><?=i18n('%1 Category', array($fair['abbrv']))?>:</td>
<td><b><?=$server_cats[$server_cat]['category']?> (<?=i18n('Grade')?> <?=$server_cats[$server_cat]['mingrade']?> - <?=$server_cats[$server_cat]['maxgrade']?>)</td>
</tr>
<? }
?> </table>
</td></tr>
<?
}
}
}
echo '</table></form><br />';
exit;
}
require_once("xml.inc.php");
require_once("../user.inc.php");
require("../common.inc.php");
require("../projects.inc.php");
user_auth_required('committee', 'admin');
send_header("Award Upload",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
@ -546,210 +33,239 @@ case 'load':
);
echo "<br />";
?>
<script type="text/javascript">
//function get_cwsf_award_winners()
function get_winners_for_award($awardid)
{
global $config;
$winners=array();
var fairs_id = -1;
var award_awards_id = -1;
function catdiv_save()
{
$("#debug").load("<?=$_SERVER['PHP_SELF']?>?action=catdiv_save",
$('#catdiv_form').serializeArray());
return false;
}
function popup_upload_load()
{
var ids = "&id="+award_awards_id+"&fairs_id="+fairs_id;
$("#popup_upload").load("<?=$_SERVER['PHP_SELF']?>?action=load"+ids);
}
function popup_upload(fid,aaid)
{
var w = (document.documentElement.clientWidth * 0.8);
var h = (document.documentElement.clientHeight * 0.8);
fairs_id = fid;
award_awards_id = aaid;
/* Load dialog content (it's in a function because we use it when
* the div editor closes too, to reload the content */
popup_upload_load();
/* Show the dialog */
$('#popup_upload').dialog('option', 'width', w);
$('#popup_upload').dialog('option', 'height', h);
$("#popup_upload").dialog('open');
return true;
}
function popup_divmap(fid)
{
var w = (document.documentElement.clientWidth * 0.4);
var h = (document.documentElement.clientHeight * 0.6);
/* Load dialog content */
$("#popup_divmap").load("<?=$_SERVER['PHP_SELF']?>?action=catdiv_load&fairs_id="+fairs_id);
/* Show the dialog */
$('#popup_divmap').dialog('option', 'width', w);
$('#popup_divmap').dialog('option', 'height', h);
$("#popup_divmap").dialog('open');
return true;
}
/* Setup the popup window */
$(document).ready(function() {
$("#popup_upload").dialog({
bgiframe: true, autoOpen: false,
modal: true, resizable: false,
draggable: false,
buttons: {
"<?=i18n('Cancel')?>": function() {
$(this).dialog("close");
},
"<?=i18n('Upload Winners')?>": function() {
$("#award_upload_status").load("<?=$_SERVER['PHP_SELF']?>?action=award_upload",
$('#winner_divs_form').serializeArray());
/* Don't need to wait for the .load to complete before closing */
$(this).dialog("close");
$q=mysql_query("SELECT * FROM award_awards WHERE id='$awardid' AND year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q)==1)
{
$award=mysql_fetch_object($q);
$pq=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$award->id'");
while($prize=mysql_fetch_object($pq))
{
$wq=mysql_query("SELECT
projects.id,
projects.projectnumber,
projects.title,
projects.summary,
projects.registrations_id,
projects.projectdivisions_id
FROM
winners,
projects
WHERE
winners.projects_id=projects.id AND
awards_prizes_id='$prize->id' AND
winners.year='".$config['FAIRYEAR']."'");
echo mysql_error();
while($project=mysql_fetch_object($wq))
{
$sq=mysql_query("SELECT * FROM students WHERE registrations_id='$project->registrations_id' AND year='".$config['FAIRYEAR']."'");
$students=array();
while($s=mysql_fetch_object($sq))
{
$schoolq=mysql_query("SELECT * FROM schools WHERE id='$s->schools_id'");
$school=array();
if($schoolr=mysql_fetch_object($schoolq)) {
$school=array(
"xml_type"=>"school",
"schoolname"=>$schoolr->school,
"schoollang"=>$schoolr->schoollang,
"schoollevel"=>$schoolr->schoollevel,
"board"=>$schoolr->board,
"district"=>$schoolr->district,
"phone"=>$schoolr->phone,
"fax"=>$schoolr->fax,
"address"=>$schoolr->address,
"city"=>$schoolr->city,
"province_code"=>$schoolr->province_code,
"postalcode"=>$schoolr->postalcode,
"principal"=>$schoolr->principal,
"schoolemail"=>$schoolr->schoolemail,
"sciencehead"=>$schoolr->sciencehead,
"scienceheademail"=>$schoolr->scienceheademail,
"scienceheadphone"=>$schoolr->scienceheadphone
);
}
}
});
$students[]=array(
"xml_type"=>"student",
"firstname"=>$s->firstname,
"lastname"=>$s->lastname,
"email"=>$s->email,
"gender"=>$s->sex,
"grade"=>$s->grade,
"language"=>$s->lang,
"birthdate"=>$s->dateofbirth,
"address1"=>$s->address,
"address2"=>"",
"city"=>$s->city,
"province"=>$s->province,
"postalcode"=>$s->postalcode,
"phone"=>$s->phone,
"teachername"=>$s->teachername,
"teacheremail"=>$s->teacheremail,
"school"=>$school
);
$("#popup_divmap").dialog({
bgiframe: true, autoOpen: false,
modal: true, resizable: false,
draggable: false,
buttons: {
"<?=i18n('Cancel')?>": function() {
$(this).dialog("close");
},
"<?=i18n('Save Mappings')?>": function() {
$("#debug").load("<?=$_SERVER['PHP_SELF']?>?action=catdiv_save",
$('#catdiv_form').serializeArray(), function() {
popup_upload_load();
}
}
$prizewinners[]=array(
"xml_type"=>"project",
"projectid"=>$project->id,
"projectnumber"=>$project->projectnumber,
"title"=>$project->title,
"abstract"=>$project->summary,
"students"=>$students,
);
/* Don't need to wait for the .load to complete before closing */
$(this).dialog("close");
}
$winners[]=array(
"xml_type"=>"prize",
"identifier"=>$prize->external_identifier,
"projects"=>$prizewinners
);
}
//print_r($award);
}
return $winners;
}
if($_GET['action']=="send")
{
if(count($_GET['send'])) {
require_once("xml.inc.php");
foreach($_GET['send'] AS $awardid) {
$q=mysql_query("SELECT award_awards.id,
award_awards.name AS awardname,
award_awards.external_identifier,
award_awards.external_postback,
award_sources.name AS sourcename,
award_sources.username,
award_sources.password
FROM
award_awards
JOIN award_sources ON award_awards.award_sources_id=award_sources.id
WHERE award_sources.enabled='yes'
AND award_awards.id='$awardid'");
if($r=mysql_fetch_object($q)) {
echo i18n("Sending award winners for %1 to %2...",array($r->awardname,$r->sourcename));
if(!($r->username && $r->password && $r->external_postback)) {
echo error(i18n("Username, Password or Postback Address missing, cannot send winners for this award"));
continue;
}
$winners=get_winners_for_award($r->id);
echo "<br />";
if(count($winners)==0) {
echo "&nbsp;&nbsp;".i18n("No winner(s) selected for this award... reporting no winners")."<br />";
}
$reg=array("awardwinners"=>array(
"username"=>$r->username,
"password"=>$r->password,
"identifier"=>$r->external_identifier,
"prizes"=>$winners
)
);
$output="";
xmlCreateRecurse($reg);
$xmldata=$output;
$ch = curl_init(); /// initialize a cURL session
curl_setopt ($ch, CURLOPT_URL,$r->external_postback);
curl_setopt ($ch, CURLOPT_HEADER, 0); /// Header control
curl_setopt ($ch, CURLOPT_POST, 1); /// tell it to make a POST, not a GET
curl_setopt ($ch, CURLOPT_POSTFIELDS, "xml=$xmldata"); /// put the query string here starting with "?"
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); /// This allows the output to be set into a variable $datastream
curl_setopt ($ch, CURLOPT_POSTFIELDSIZE, 0);
curl_setopt ($ch, CURLOPT_TIMEOUT, 360);
curl_setopt ($ch, CURLOPT_SSLVERSION, 3);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
$datastream = curl_exec ($ch); /// execute the curl session and return the output to a variable $datastream
$datastream = str_replace(" standalone=\"yes\"","",$datastream);
// echo "curl close <br />";
curl_close ($ch); /// close the curl session
echo i18n("Response from server:");
$response=xml_parsexml($datastream);
if($response && is_array($response)) {
$keys=array_keys($response);
if($keys[0]=="awardwinnersresponse") {
$status=$response['awardwinnersresponse'][0]['status'][0];
$statusmessage=$response['awardwinnersresponse'][0]['statusmessage'][0];
if($status=="success")
echo happy(i18n("Success: %1",array($statusmessage)));
else
echo error(ucfirst($status).": ".$statusmessage); //not translated, because it came right from the server!
}
else
{
echo error(i18n("Invalid XML response. Expecting '%1', received '%2'",array("awardwinnersresponse",$keys[0])));
echo "datastream: ".htmlspecialchars($datastream);
}
}
});
});
</script>
else
{
echo error(i18n("Invalid response. Couldn't parse XML or no data returned",array("awardwinnersresponse",$keys[0])));
echo "datastream: ".htmlspecialchars($datastream);
<div id="popup_upload" title="Upload Award" style="display: none"></div>
<div id="popup_divmap" title="Edit Mappings" style="display: none"></div>
}
<?
if(!function_exists('curl_init')) {
echo error(i18n("CURL Support Missing"));
echo notice(i18n("Your PHP installation does not support CURL. You will need to have CURL support added by your system administrator before being able to access external award sources"));
send_footer();
exit;
}
/* Fairs first */
$q = mysql_query("SELECT fairs.id, fairs.name, fairs.type, COUNT(award_awards.id) as AWARD_COUNT FROM fairs
LEFT JOIN award_awards ON award_awards.award_source_fairs_id=fairs.id
WHERE award_awards.award_source_fairs_id IS NOT NULL
AND award_awards.conferences_id='{$conference['id']}'
GROUP BY fairs.id
ORDER BY fairs.name ");
echo mysql_error();
?>
<h4><?=i18n('Upload all winners to a source')?>:</h4>
<table class="tableview"><thead>
<tr><th><?=i18n("Source Name")?></th>
<th><?=i18n("Number of Awards")?></th>
<th><?=i18n("Winners<br />Assigned")?></th>
<th><?=i18n("Send All")?></th>
</tr></thead>
<?
while($r=mysql_fetch_object($q)) {
$count = count_winners(-1, $r->id);
?>
<tr><td><?=$r->name?></td>
<td align="center"><?=$r->AWARD_COUNT?></td>
<td align="center"><?=$count?></td>
<td align="center">
<?
if($r->type == 'sfiab')
echo "<a href=\"#\" onClick=\"popup_upload({$r->id},-1)\" >".i18n("Send All")."</a>";
else
echo "Not available yet, we're working on it!";
echo "</td></tr>";
}
?>
</table>
<br />
<br />
<?
$q = mysql_query("SELECT award_awards.id, award_awards.name AS awardname,
fairs.name as fairname, award_source_fairs_id,
fairs.type as fairtype, award_awards.external_additional_materials
FROM award_awards
LEFT JOIN fairs ON fairs.id=award_awards.award_source_fairs_id
WHERE award_awards.award_source_fairs_id IS NOT NULL
AND award_awards.conferences_id='{$conference['id']}'
ORDER BY fairs.name, award_awards.name");
echo mysql_error();
?>
<h4><?=i18n('Upload individual winners to a source')?>:</h4>
<table class="tableview"><thead>
<tr><th><?=i18n("Award Name")?></th>
<th><?=i18n("Source Name")?></th>
<th><?=i18n("Winners<br />Assigned")?></th>
<th><?=i18n("Send")?></th>
<th><?=i18n("Additional<br />Info")?></th>
</tr></thead>
<?
while($r=mysql_fetch_object($q)) {
$count = count_winners($r->id, $r->award_source_fairs_id);
?>
<tr><td><?=$r->awardname?></td>
<td><?=$r->fairname?></td>
<td align="center"><?=$count?></td>
<td align="center">
<?
if($count > 0)
$onclick = "popup_upload({$r->award_source_fairs_id},{$r->id});return false;";
else
$onclick = "alert('".i18n('Assign a winner first')."');return false;";
?>
<a href="#" onClick="<?=$onclick?>"><?=i18n("send")?></a>
</td><td>
<? if($r->external_additional_materials) {
echo "<a href=\"{$_SERVER['PHP_SELF']}?action=additional_materials&award_awards_id={$r->id}\" target=\"_blank\">".i18n("download")."</a>";
}
echo "<br />";
}
}
echo '</td></tr>';
}
?>
</table>
<br />
<div id="award_upload_status"></div>
<?
/*<a href="award_upload.php?action=send<?=$sendurl?>"><?=i18n("Send all awards")?></a> */
send_footer();
}
else
{
if(!function_exists('curl_init'))
{
echo error(i18n("CURL Support Missing"));
echo notice(i18n("Your PHP installation does not support CURL. You will need to have CURL support added by your system administrator before being able to access external award sources"));
$links=false;
}
else
$links=true;
$q=mysql_query("SELECT award_awards.id,
award_awards.name AS awardname,
award_sources.name AS sourcename
FROM
award_awards
JOIN award_sources ON award_awards.award_sources_id=award_sources.id
WHERE award_sources.enabled='yes'
AND award_awards.year={$config['FAIRYEAR']}
ORDER BY award_sources.name, award_awards.name");
echo mysql_error();
echo "<table class=\"tableview\">";
echo "<tr><th>".i18n("Award Name")."</th>";
echo "<th>".i18n("Source Name")."</th>";
echo "<th>".i18n("Send")."</th>";
echo "</tr>";
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo "<td>$r->awardname</td>\n";
echo "<td>$r->sourcename</td>";
echo "<td align=\"center\">";
if($links)
echo "<a href=\"award_upload.php?action=send&send[]=$r->id\">".i18n("send")."</a>";
else
echo "n/a";
echo "</td>";
echo "</tr>";
$sendurl.="&send[]=$r->id";
}
echo "</table>\n";
echo "<br />";
if($links)
echo "<a href=\"award_upload.php?action=send$sendurl\">".i18n("Send all awards")."</a>";
}
send_footer();
?>

View File

@ -1,49 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2010 David Grant <dave@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
function award_delete($award_awards_id)
{
/* Delete all winners attached to this award */
$q = mysql_query("SELECT id FROM award_prizes WHERE award_awards_id='$award_awards_id'");
while(($p = mysql_fetch_assoc($q))) {
mysql_query("DELETE FROM winners WHERE award_prizes_id='{$p['id']}'");
}
/* FIXME: maybe delte judging teams and judge
* assignments and timeslots?
/* Delete the award */
mysql_query("DELETE FROM award_prizes WHERE award_awards_id='$award_awards_id'");
mysql_query("DELETE FROM award_awards_projectcategories WHERE award_awards_id='$award_awards_id'");
mysql_query("DELETE FROM award_awards_projectdivisions WHERE award_awards_id='$award_awards_id'");
mysql_query("DELETE FROM award_awards WHERE id='$award_awards_id'");
}
function award_prize_delete($award_prizes_id)
{
mysql_query("DELETE FROM winners WHERE award_prizes_id='$award_prizes_id'");
mysql_query("DELETE FROM award_prizes WHERE id='$award_prizes_id'");
}
?>

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
send_header("Awards",
array('Committee Main' => 'committee_main.php',
@ -34,10 +34,11 @@
require_once("rerollprizes.php");
echo "<br />";
echo "<a href=\"sponsors.php\">".i18n('Award Sponsors')."</a><br />";
echo "<a href=\"sponsor_contacts.php\">".i18n('Award Sponsors Contacts')."</a><br />";
echo "<a href=\"award_awards.php\">".i18n('Awards Management')."</a><br />";
echo "<a href=\"donors.php\">".i18n('Sponsors')."</a><br />";
echo "<br />";
echo "<a href=\"award_awards.php?action=edit_prize_template\">".i18n('Edit prize template for the divisional awards')."</a>";
echo "<a href=\"award_prizes.php?award_awards_id=-1\">".i18n('Edit prize template for the divisional awards')."</a>";
echo "<br />";
echo "<a href=\"award_awardcreatedivisional.php\">".i18n('Create divisional awards for all divisions & categories')."</a><br />";
echo "<br />";

View File

@ -23,7 +23,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
//make sure storage folder exists
if(!file_exists("../data/userfiles"))

View File

@ -1,56 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require_once("../common.inc.php");
require_once("../user.inc.php");
require_once("../committee.inc.php");
user_auth_required('admin');
require("../tableeditor.class.php");
/* Now, start the output for this page */
send_header("Committee Management",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php' ),
"committee_management");
echo "<a href=\"committees.php\">Manage Committee Members</a><br />";
$_SESSION['last_page'] = 'committee_management';
//make sure storage folder exists
$editor=new TableEditor("committees",
array("name"=>"Committee Name",
)
);
$editor->setPrimaryKey("id");
$editor->setDefaultSortField("name");
$editor->setRecordType("Committee");
$editor->execute();
send_footer();
?>

View File

@ -26,14 +26,14 @@
require_once("../user.inc.php");
require_once("../committee.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
if($_POST['accounts_id'])
$accounts_id = intval($_POST['accounts_id']);
if($_POST['users_uid'])
$uid = intval($_POST['users_uid']);
/* Now, start the output for this page */
send_header("Committee Member Management",
send_header("Committee Management",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php' ),
"committee_management");
@ -46,10 +46,16 @@ if($_POST['accounts_id'])
<script type="text/javascript">
<!--
function openeditor(id)
{
window.open("user_editor_window.php?id="+id,"User Editor","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
return false;
}
function neweditor()
{
var username = document.forms.addmember.add_member.value;
window.open("../user_editor_window.php?type=committee&username="+username,"UserEditor","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
window.open("user_editor_window.php?type=committee&username="+username,"User Editor","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
document.forms.addmember.add_member.value = "";
return false;
}
@ -95,7 +101,7 @@ function actionSubmit()
alert('You must choose an action');
return false;
}
if(document.forms.memberaction.accounts_id.selectedIndex==0)
if(document.forms.memberaction.users_uid.selectedIndex==0)
{
alert('You must choose a member');
return false;
@ -103,7 +109,7 @@ function actionSubmit()
if(document.forms.memberaction.action.selectedIndex == 2) {
// Edit
var id = document.forms.memberaction.accounts_id.options[document.forms.memberaction.accounts_id.selectedIndex];
var id = document.forms.memberaction.users_uid.options[document.forms.memberaction.users_uid.selectedIndex];
openeditor(id.value);
// alert("id="+id.value);
return false;
@ -119,15 +125,26 @@ function actionSubmit()
</script>
<?
if($_POST['committees_id']) {
if($_POST['addcommittee'])
{
//add a new committee
mysql_query("INSERT INTO committees (name) VALUES ('".mysql_escape_string($_POST['addcommittee'])."')");
echo happy(i18n("Committee successfully added"));
}
if($_POST['committees_id'] && $_POST['committees_ord'])
{
//re-order the committees
$x=0;
$ids=$_POST['committees_id'];
$ords=$_POST['committees_ord'];
$titles=$_POST['title'];
$pords = $_POST['order'];
while($ids[$x]) {
while($ids[$x])
{
$cid = intval($ids[$x]);
mysql_query("UPDATE committees SET ord='".intval($ords[$x])."' WHERE id='$cid'");
$x++;
$ctitle = $titles[$cid];
@ -136,15 +153,13 @@ if($_POST['committees_id']) {
/* If the committee has no members, don't bother trying to do
* anything */
if(!is_array($ctitle)) continue;
// print_r($ctitle);
foreach($ctitle as $accounts_id=>$title) {
$o = intval($cord[$accounts_id]);
foreach($ctitle as $uid=>$title) {
$o = intval($cord[$uid]);
$t = mysql_escape_string(stripslashes($title));
$u = intval($accounts_id);
$u = intval($uid);
$q = "UPDATE committees_link SET title='$t', ord='$o'
WHERE committees_id='$cid' AND accounts_id='$u'";
// echo $q;
WHERE committees_id='$cid' AND users_uid='$u'";
mysql_query($q);
}
@ -155,12 +170,14 @@ if($_POST['committees_id']) {
if($_POST['action']=="assign")
{
if($_POST['committees_id'] && $_POST['accounts_id']) {
if($_POST['committees_id'] && $_POST['users_uid'])
{
$cid = intval($_POST['committees_id']);
$q=mysql_query("SELECT * FROM committees_link WHERE committees_id='$cid' AND accounts_id='$accounts_id'");
$q=mysql_query("SELECT * FROM committees_link WHERE committees_id='$cid' AND users_uid='$uid'");
if(!mysql_num_rows($q)) {
mysql_query("INSERT INTO committees_link (committees_id,accounts_id) VALUES ('$cid','$accounts_id')");
if(!mysql_num_rows($q))
{
mysql_query("INSERT INTO committees_link (committees_id,users_uid) VALUES ('$cid','$uid')");
echo happy(i18n("Successfully added member to committee"));
}
else
@ -168,24 +185,63 @@ if($_POST['action']=="assign")
}
else
echo error(("You must choose both a member and a committee"));
}
if($_POST['action']=="remove") {
if($_GET['deletecommittee'])
{
$del = intval($_GET['deletecommittee']);
mysql_query("DELETE FROM committees WHERE id='$del'");
echo happy(i18n("Committee removed"));
}
if($_POST['action']=="remove")
{
/* user_delete takes care of unlinking the user in other tables */
user_delete($accounts_id, 'committee');
user_delete($uid, 'committee');
echo happy(i18n("Committee member deleted"));
}
if($_GET['unlinkmember'] && $_GET['unlinkcommittee']) {
if($_GET['unlinkmember'] && $_GET['unlinkcommittee'])
{
$mem = intval($_GET['unlinkmember']);
$com = intval($_GET['unlinkcommittee']);
//unlink the member from the committee
mysql_query("DELETE FROM committees_link WHERE accounts_id='$mem' AND committees_id='$com'");
mysql_query("DELETE FROM committees_link WHERE users_uid='$mem' AND committees_id='$com'");
echo happy(i18n("Committee member unlinked from committee"));
}
echo '<a href="../user_invite.php?type=committee">Create a new member</a><br/>';
echo "<a href=\"committee_committees.php\">Manage Committees</a><br />";
echo "<table>";
echo "<tr><td>";
echo "<h4>".i18n("Add Committee")."</h4>\n";
echo "<form method=\"post\" action=\"committees.php\">\n";
echo "<table>\n";
echo "<tr><td>".i18n("Committee Name").": </td><td><input type=\"text\" size=\"15\" name=\"addcommittee\" /></td>";
echo " <td><input type=\"submit\" value=\"".i18n("Add")."\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
echo "</td><td width=\"40\">&nbsp;</td><td>";
echo "<h4>".i18n("Add Committee Member")."</h4>\n";
echo "<form method=\"post\" name=\"addmember\" action=\"committees.php\">\n";
echo "<table>\n";
echo "<tr><td>".i18n("Member Email").": </td><td>";
echo "<input type=\"text\" size=\"15\" name=\"add_member\" />\n";
echo "</td>\n";
echo " <td><input type=\"submit\" onclick=\"neweditor();\" value=\"".i18n("Add")."\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
echo "</td></tr>";
echo "</table>";
echo "<hr />";
echo "<h4>".i18n("Committee Member Management")."</h4>\n";
echo "<form name=\"memberaction\" method=\"post\" action=\"committees.php\" onsubmit=\"return actionSubmit()\">\n";
echo "<table>";
echo "<tr><td>";
@ -197,23 +253,17 @@ if($_GET['unlinkmember'] && $_GET['unlinkcommittee']) {
echo "</select>";
echo "</td><td>";
$query = "
SELECT accounts_id, firstname, lastname, email, deleted FROM users WHERE accounts_id IN(
SELECT accounts_id FROM user_roles JOIN roles ON user_roles.roles_id = roles.id WHERE roles.type = 'committee'
)
AND conferences_id = " . $conference['id'];
$q = mysql_query($query);
echo "<select name=\"accounts_id\">";
$q=mysql_query("SELECT uid,MAX(year),firstname,lastname,deleted FROM users WHERE types LIKE '%committee%' GROUP BY uid ORDER BY firstname");
echo "<select name=\"users_uid\">";
echo "<option value=\"\">".i18n("Select a Member")."</option>\n";
while($r=mysql_fetch_object($q))
{
if($r->deleted == 'yes') continue;
if($r->deleted != 'no') continue;
$displayname = $r->firstname.' '.$r->lastname;
echo "<option value=\"$r->accounts_id\">$displayname ($r->email)</option>\n";
echo "<option value=\"$r->uid\">$displayname</option>\n";
}
echo "</select>";
echo "</td><td>";
@ -245,57 +295,63 @@ if($_GET['unlinkmember'] && $_GET['unlinkcommittee']) {
$q=mysql_query("SELECT * FROM committees ORDER BY ord,name");
if(mysql_num_rows($q))
{
echo "<h4>".i18n("Committees")."</h4>";
echo "<form method=\"post\" action=\"committees.php\">\n";
echo "<table>";
echo "<tr><td colspan=\"2\"></td><th colspan=\"2\">".i18n('Title within committee / Sort order')."</th>";
echo "</tr>";
while($r=mysql_fetch_object($q)) {
echo "<tr><td colspan=\"2\"></td><td><b>".i18n('Title')."</b></td>";
echo "<td><b>".i18n('Order')."</b></td>";
echo "<td><b>".i18n("Public Email / Private Email")."</b></td></tr>";
while($r=mysql_fetch_object($q))
{
echo "<tr>";
echo "<td colspan=\"4\">";
echo "<td colspan=\"3\">";
echo "<input type=\"hidden\" name=\"committees_id[]\" value=\"$r->id\" />";
// echo "<input size=\"1\" type=\"text\" name=\"committees_ord[]\" value=\"$r->ord\" />";
echo "<b>".i18n($r->name)."</b>";
echo "<input size=\"1\" type=\"text\" name=\"committees_ord[]\" value=\"$r->ord\" />";
echo "&nbsp; <b>$r->name</b>";
$q2=mysql_query("SELECT
committees_link.title,
committees_link.ord,
committees_link.accounts_id
FROM committees_link
$q2=mysql_query("SELECT committees_link.title,committees_link.ord,users.uid,MAX(users.year),users.lastname
FROM committees_link LEFT JOIN users ON users.uid = committees_link.users_uid
WHERE committees_id='{$r->id}'
ORDER BY ord");
GROUP BY users.uid ORDER BY ord,users.lastname ");
if(mysql_num_rows($q2)==0) {
echo "&nbsp; &nbsp;";
echo "<a title=\"Remove Committee\" onclick=\"return confirmClick('Are you sure you want to remove this committee?');\" href=\"committees.php?deletecommittee=$r->id\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=\"0\" alt=\"Remove Committee\" /></a>";
}
echo "</td></tr>\n";
echo mysql_error();
while($r2=mysql_fetch_object($q2)) {
$u = user_load_by_accounts_id($r2->accounts_id);
//if rollover is proper, this shouldnt be necessary, but, the simcoe rollover didnt do this, so lets do it here as a safety
if(!$u) {
$roleq=mysql_query("SELECT * FROM roles WHERE type='committee'");
$roler=mysql_fetch_object($roleq);
//hmm thats okay,w e must have missed something in the rollover... sicne its tied to the accounts_id, we just need to add a record
account_add_role($r2->accounts_id,$roler->id,$conference['id']);
//and now we should be able to load them
$u = user_load_by_accounts_id($r2->accounts_id);
}
$u = user_load_by_uid($r2->uid);
echo "<tr><td align=\"right\">&nbsp;&nbsp;&nbsp;&nbsp;";
echo "<a title=\"Edit Member\" href=\"#\" onclick=\"openeditor({$u['id']})\"><img src=\"{$config['SFIABDIRECTORY']}/images/16/edit.{$config['icon_extension']}\" border=\"0\" alt=\"Edit\" /></a>";
echo "&nbsp;";
echo "<a title=\"Unlink Member from Committee\" onclick=\"return confirmClick('Are you sure you want to unlink this member from this committee?');\" href=\"committees.php?unlinkmember={$u['accounts_id']}&amp;unlinkcommittee={$r->id}\"><img src=\"{$config['SFIABDIRECTORY']}/images/16/undo.{$config['icon_extension']}\" border=\"0\" alt=\"Unlink\" /></a>";
echo "<a title=\"Unlink Member from Committee\" onclick=\"return confirmClick('Are you sure you want to unlink this member from this committee?');\" href=\"committees.php?unlinkmember={$u['uid']}&amp;unlinkcommittee={$r->id}\"><img src=\"{$config['SFIABDIRECTORY']}/images/16/undo.{$config['icon_extension']}\" border=\"0\" alt=\"Unlink\" /></a>";
echo "</td>";
echo "<td valign=\"top\">";
echo "<b>{$u['firstname']} {$u['lastname']}</b>";
echo "<b>{$u['name']}</b>";
echo "</td><td>";
echo "<input type=\"text\" value=\"{$r2->title}\" name=\"title[{$r->id}][{$u['accounts_id']}]\" size=\"25\">";
echo "<input type=\"text\" value=\"{$r2->title}\" name=\"title[{$r->id}][{$u['id']}]\" size=\"15\">";
echo "</td><td>";
echo "<input type=\"text\" value=\"{$r2->ord}\" name=\"order[{$r->id}][{$u['accounts_id']}]\" size=\"2\">";
echo "<input type=\"text\" value=\"{$r2->ord}\" name=\"order[{$r->id}][{$u['id']}]\" size=\"2\">";
echo "</td><td>";
if($u['email']) {
list($b,$a)=split("@",$u['email']);
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
}
if($u['emailprivate']) {
if($u['email']) echo " <b>/</b> ";
list($b,$a)=split("@",$u['emailprivate']);
echo "<script language=\"javascript\" type=\"text/javascript\">em('$b','$a')</script>";
}
echo "</td></tr>\n";
}
echo "<tr><td colspan=\"4\">&nbsp;</td></tr>\n";
echo "<tr><td colspan=\"2\">&nbsp;</td></tr>\n";
}
echo "<tr><td colspan=\"2\"><input type=\"submit\" value=\"".i18n("Save Committee Orders and Titles")."\" /></td></tr>\n";
echo "</table>";

View File

@ -1,244 +1,62 @@
<?
$mailqueries=array(
"myself"=>array("name"=>"Yourself (for testing)","query"=>"SELECT users.id FROM users WHERE users.id='{$_SESSION['users_id']}'"),
"committee_all"=>array("name"=>"Committee members (all)","query"=>
"SELECT users.id FROM users
JOIN accounts ON users.accounts_id=accounts.id
JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.roles_id
WHERE roles.type = 'committee' AND accounts.deleted = 'no' "),
"SELECT firstname, lastname, organization, email FROM users WHERE types LIKE '%committee%' AND deleted='no' AND year='{$config['FAIRYEAR']}' "),
/* The WHERE clause evaluates which rows to add to the GROUP
BY, the HAVING clase evaluates which grouped rows show up. We
want to to evaluate 'deleted' AFTER the grouping, so we catch
the case where the MAX(conferences_id) has deleted='yes'. If we use WHERE
deleted='no', we'll only add non-deleted rows to the group, and
end up picking up a user active in, say 2007 and 2008, but
deleted in 2009. */
"judges_all"=>array("name"=>"Judges from all conferences (except deleted judges)","query"=>
"SELECT firstname, lastname, email, deleted, MAX(conferences_id) FROM users
JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.roles_id
WHERE roles.type ='judge' GROUP BY users.accounts_id HAVING deleted='no' ORDER BY email"),
"judges_all"=>array("name"=>"(BROKEN, DO NOT USE) Judges from all years","query"=>
"SELECT firstname, lastname, email FROM users WHERE 0 ORDER BY email"),
"judges_active_thisconference"=>array("name"=>"Judges active for this conference", "query"=>
"SELECT users.id FROM users
LEFT JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.roles_id
WHERE roles.type='judge' AND conferences_id={$conference['id']} AND deleted='no' AND user_roles.active='yes' ORDER BY email"),
"judges_active_thisyear"=>array("name"=>"Judges active for this year", "query"=>
"SELECT firstname, lastname, email FROM users LEFT JOIN users_judge ON users_judge.users_id=users.id WHERE types LIKE '%judge%' AND year='{$config['FAIRYEAR']}' AND deleted='no' AND users_judge.judge_active='yes' ORDER BY email"),
"judges_inactive_thisconference"=>array("name"=>"Judges in the conference that are not active", "query"=>
"SELECT users.id FROM users
LEFT JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.roles_id
WHERE roles.type='judge' AND conferences_id={$conference['id']} AND deleted='no' AND user_roles.active='no' ORDER BY email"),
"judges_inactive"=>array("name"=>"(BROKEN, DO NOT USE) Judges not active for this year", "query"=>
"SELECT DISTINCT(judges.id), firstname, lastname, email FROM judges LEFT JOIN judges_years ON judges_years.judges_id=judges.id WHERE judges_years.year!='".$config['FAIRYEAR']."' ORDER BY email"),
"judges_inactive_allconferences"=>array("name"=>"Judges inactive for any conference", "query"=>
"SELECT users.id FROM users
LEFT JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.roles_id
WHERE roles.type='judge' AND deleted='no' AND user_roles.active='no' ORDER BY email"),
"judges_active_complete_thisyear"=>array("name"=>"Judges active for this year and complete", "query"=>
"SELECT firstname, lastname, email FROM users LEFT JOIN users_judge ON users_judge.users_id=users.id WHERE types LIKE '%judge%' AND year='{$config['FAIRYEAR']}' AND users_judge.judge_complete='yes' AND deleted='no' AND users_judge.judge_active='yes' ORDER BY email"),
"judges_active_complete_thisconference"=>array("name"=>"Judges active for this conference and complete", "query"=>
"SELECT users.id FROM users
LEFT JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.id
WHERE roles.type = 'judge' AND conferences_id = {$conference['id']}
AND user_roles.complete='yes'
AND deleted='no'
AND user_roles.active='yes'
ORDER BY email"),
"judges_active_incomplete_thisyear"=>array("name"=>"Judges active for this year but not complete", "query"=>
"SELECT firstname, lastname, email FROM users LEFT JOIN users_judge ON users_judge.users_id=users.id WHERE types LIKE '%judge%' AND year='{$config['FAIRYEAR']}' AND users_judge.judge_complete='no' AND deleted='no' AND users_judge.judge_active='yes' ORDER BY email"),
"judges_active_incomplete_thisconference"=>array("name"=>"Judges active for this conference but not complete", "query"=>
"SELECT users.id FROM users
LEFT JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.id
WHERE roles.type = 'judge' AND conferences_id = {$conference['id']}
AND user_roles.complete='no'
AND deleted='no'
AND user_roles.active='yes'
ORDER BY email"),
"participants_complete_thisyear"=>array("name"=>"Participants complete this year","query"=>
"SELECT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND registrations.year='".$config['FAIRYEAR']."' AND ( registrations.status='complete' OR registrations.status='paymentpending') ORDER BY students.email"),
"participants_all_thisconference"=>array("name"=>"Participants (all) for this conference","query"=>
"SELECT users.id
FROM users
JOIN user_roles ON user_roles.users_id=users.id
JOIN roles ON user_roles.roles_id=roles.id
WHERE users.conferences_id='{$conference['id']}'
AND roles.type='participant'"),
"participants_complete_paymentpending_thisyear"=>array("name"=>"Participants complete this year but payment pending","query"=>
"SELECT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND registrations.year='".$config['FAIRYEAR']."' AND registrations.status!='complete' AND registrations.status='paymentpending' ORDER BY students.email"),
"participants_complete_thisconference"=>array("name"=>"Participants complete/paymentpending for this conference","query"=>
"SELECT users.id FROM users
JOIN registrations ON users.registrations_id=registrations.id
JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.roles_id
WHERE roles.type = 'participant'
AND registrations.conferences_id='".$conference['id']."'
AND ( registrations.status='complete' OR registrations.status='paymentpending')"),
"participants_notcomplete_thisyear"=>array("name"=>"Participants not complete this year","query"=>
"SELECT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND registrations.year='".$config['FAIRYEAR']."' AND registrations.status!='complete' AND registrations.status!='new' ORDER BY students.email"),
"participants_complete_paymentpending_thisconference"=>array("name"=>"Participants payment pending for this conference","query"=>
"SELECT users.id FROM users
JOIN registrations ON users.registrations_id=registrations.id
JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.roles_id
WHERE roles.type = 'participant'
AND registrations.conferences_id='".$conference['id']."'
AND registrations.status='paymentpending'"),
"participants_notcomplete_thisconference"=>array("name"=>"Participants not complete for this conference","query"=>
"SELECT users.id
FROM users
JOIN user_roles ON user_roles.users_id=users.id
JOIN roles ON user_roles.roles_id=roles.id
LEFT JOIN registrations ON users.registrations_id=registrations.id
WHERE users.conferences_id='{$conference['id']}'
AND roles.type='participant'
AND (registrations.status IS NULL OR registrations.status='open' OR registrations.status='new')"),
/* // FIXME - not sure if this has a sensible equivalent when dealing with "conferences" rather than fair years
"participants_complete_lastyear"=>array("name"=>"Participants complete last year","query"=>
"SELECT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND registrations.year='".($config['FAIRYEAR']-1)."' AND ( registrations.status='complete' OR registrations.status='paymentpending') ORDER BY students.email"),
"participants_complete_allconferences"=>array("name"=>"Participants complete for all conferences","query"=>
"SELECT users.id, users.firstname, users.lastname, accounts.email FROM users
JOIN accounts on users.accounts_id=accounts.id
JOIN registrations ON users.registrations_id=registrations.id
JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.roles_id
WHERE roles.type = 'participant'
AND (registrations.status='complete' OR registrations.status='paymentpending') ORDER BY accounts.email"),
"participants_complete_allyears"=>array("name"=>"Participants complete all years","query"=>
"SELECT DISTINCT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND ( registrations.status='complete' OR registrations.status='paymentpending') ORDER BY students.email"),
*/
"participants_cwsf_thisconference"=>array("name"=>"CWSF Winners for this conference","query"=>"
SELECT users.id
FROM award_awards
JOIN award_prizes ON award_prizes.award_awards_id=award_awards.id
JOIN winners ON winners.awards_prizes_id=award_prizes.id
JOIN projects ON winners.projects_id=projects.id
JOIN registrations ON projects.registrations_id=registrations.id
JOIN users ON users.registrations_id=registrations.id
WHERE award_awards.cwsfaward='1'
AND winners.conferences_id='".$conference['id']."' "),
"special_award_sponsors_confirmed"=>array("name"=>"Special award sponsors (confirmed only)","query"=>
"SELECT DISTINCT(award_sponsors.id), organization, firstname, lastname, award_contacts.email FROM award_sponsors, award_awards, award_contacts WHERE award_awards.award_sponsors_id=award_sponsors.id AND award_contacts.award_sponsors_id=award_sponsors.id AND award_sponsors.confirmed='yes' AND award_awards.award_types_id='2' AND award_contacts.year='".$config['FAIRYEAR']."'"),
"sponsors"=>array("name"=>"Organization sponsors","query"=>
"SELECT id, organization, email FROM sponsors WHERE email!='' ORDER BY email"),
"sponsors_primarycontacts"=>array("name"=>"Organization sponsors (primary contacts)","query"=>
"SELECT users.id, conferences_id, organization, firstname, lastname, email, `primary`
FROM users
JOIN user_roles on users.id = user_roles.id
JOIN roles ON user_roles.roles_id = roles.id
WHERE
roles.type = 'sponsor'
AND email != ''
AND deleted='no'
AND `primary`='yes'
ORDER BY email
"),
"sponsors_allcontacts"=>array("name"=>"Organization sponsors (all contacts)","query"=>
"SELECT DISTINCT(users.email), sponsors.organization, users.firstname, users.lastname, users.email
FROM sponsors
JOIN users_sponsor ON users_sponsor.sponsors_id = sponsors.id
JOIN users ON users.id = users_sponsor.users_id
JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.roles_id
WHERE
roles.type = 'sponsor'
AND users.deleted='no'
AND users.email!=''
ORDER BY users.email"),
/*
"special_award_sponsors_unconfirmed"=>array("name"=>"Special award sponsors (unconfirmed only)","query"=>
"SELECT DISTINCT(award_sponsors.id), organization, firstname, lastname, award_contacts.email FROM award_sponsors, award_awards, award_contacts WHERE award_awards.sponsors_id=award_sponsors.id AND award_contacts.award_sponsors_id=award_sponsors.id AND award_sponsors.confirmed='no' AND award_awards.award_types_id='2' AND award_contacts.year='".$config['FAIRYEAR']."'"),
"SELECT DISTINCT(award_sponsors.id), organization, firstname, lastname, award_contacts.email FROM award_sponsors, award_awards, award_contacts WHERE award_awards.award_sponsors_id=award_sponsors.id AND award_contacts.award_sponsors_id=award_sponsors.id AND award_sponsors.confirmed='no' AND award_awards.award_types_id='2' AND award_contacts.year='".$config['FAIRYEAR']."'"),
"special_award_sponsors_all"=>array("name"=>"Special award sponsors (all)","query"=>
"SELECT DISTINCT(award_sponsors.id), organization, firstname, lastname, award_contacts.email FROM award_sponsors, award_awards, award_contacts WHERE award_awards.sponsors_id=award_sponsors.id AND award_contacts.award_sponsors_id=award_sponsors.id AND award_awards.award_types_id='2' AND award_contacts.year='".$config['FAIRYEAR']."'"),
*/
"school_principals"=>array("name"=>"School principals this conference","query"=>
"SELECT principal_uid AS id FROM schools
WHERE schools.conferences_id='".$conference['id']."'
AND principal_uid>0
"),
"school_scienceheads"=>array("name"=>"School science heads this conference","query"=>
"SELECT sciencehead_uid AS id FROM schools
WHERE schools.conferences_id='".$conference['id']."'
AND sciencehead_uid>0
"),
"teachers_with_school"=>array("name"=>"Teachers with a school in this conference","query"=>
"SELECT users.id
FROM users
JOIN schools ON users.schools_id=schools.id
JOIN user_roles ON users.id=user_roles.users_id
JOIN roles ON user_roles.roles_id=roles.id
WHERE schools.conferences_id='".$conference['id']."'
AND roles.type='teacher'
"),
"teachers_without_school"=>array("name"=>"Teachers without a school in this conference","query"=>
"SELECT users.id
FROM users
JOIN user_roles ON users.id=user_roles.users_id
JOIN roles ON user_roles.roles_id=roles.id
WHERE roles.type='teacher'
AND users.conferences_id='".$conference['id']."'
AND (users.schools_id='' OR users.schools_id=0)
"),
/*
"school_teachers_thisconference"=>array("name"=>"Teachers (as entered by students) for this conference","query"=>
"SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE conferences_id='".$conference['id']."' AND teacheremail!=''"),
*/
/* // FIXME again, not sure that this has a sensible equivalent with conferences
"SELECT DISTINCT(award_sponsors.id), organization, firstname, lastname, award_contacts.email FROM award_sponsors, award_awards, award_contacts WHERE award_awards.award_sponsors_id=award_sponsors.id AND award_contacts.award_sponsors_id=award_sponsors.id AND award_awards.award_types_id='2' AND award_contacts.year='".$config['FAIRYEAR']."'"),
"school_principals"=>array("name"=>"School principals","query"=>
"SELECT school, principal AS firstname, schoolemail AS email FROM schools WHERE schools.year='".$config['FAIRYEAR']."' AND schoolemail!=''"),
"school_scienceheads"=>array("name"=>"School science heads","query"=>
"SELECT school, sciencehead AS firstname, scienceheademail AS email FROM schools WHERE schools.year='".$config['FAIRYEAR']."' AND scienceheademail!=''"),
"school_teachers_thisyear"=>array("name"=>"Teachers (as entered by students) this year","query"=>
"SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE year='".$config['FAIRYEAR']."' AND teacheremail!=''"),
"school_teachers_lastyear"=>array("name"=>"Teachers (as entered by students) last year","query"=>
"SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE year='".($config['FAIRYEAR']-1)."' AND teacheremail!=''"),
*/
/*
"school_teachers_allconferences"=>array("name"=>"Teachers (as entered by students) all conferences","query"=>
"school_teachers_allyears"=>array("name"=>"Teachers (as entered by students) all years","query"=>
"SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE teacheremail!=''"),
*/
/* Volunteers */
"volunteers_active_complete_thisconference"=>array("name"=>"Volunteers active for this conference and complete", "query"=>
"SELECT users.id, firstname, lastname, email
FROM users LEFT JOIN user_roles ON user_roles.users_id = users.id JOIN roles ON roles.id = user_roles.roles_id
WHERE users.conferences_id = '".$conference['id']."'
AND roles.type='volunteer'
AND user_roles.complete='yes'
AND user_roles.active='yes'
AND users.deleted='no'
ORDER BY email"),
"volunteers_active_complete_thisyear"=>array("name"=>"Volunteers active for this year and complete", "query"=>
"SELECT id, firstname, lastname, email FROM users LEFT JOIN users_volunteer ON users_volunteer.users_id=users.id WHERE users.year='{$config['FAIRYEAR']}' AND users_volunteer.volunteer_complete='yes' AND users_volunteer.volunteer_active='yes' AND users.deleted='no' AND types LIKE '%volunteer%' ORDER BY email"),
"volunteers_active_incomplete_thisconference"=>array("name"=>"Volunteers active for this conference but not complete", "query"=>
"SELECT users.id, firstname, lastname, email
FROM users LEFT JOIN user_roles ON user_roles.users_id = users.id JOIN roles ON roles.id = user_roles.roles_id
WHERE users.conferences_id = '".$conference['id']."'
AND roles.type='volunteer'
AND user_roles.complete='no'
AND user_roles.active='yes'
AND users.deleted='no'
ORDER BY email"),
"volunteers_active_incomplete_thisyear"=>array("name"=>"Volunteers active for this year but not complete", "query"=>
"SELECT id, firstname, lastname, email FROM users LEFT JOIN users_volunteer ON users_volunteer.users_id=users.id WHERE users.year='{$config['FAIRYEAR']}' AND users_volunteer.volunteer_complete='no' AND users_volunteer.volunteer_active='yes' AND users.deleted='no' AND users.types LIKE '%volunteer%' ORDER BY email"),
"accounts_email_unconfirmed" => array("name" => "Users active in any active conference with unconfirmed e-mail addresses", "query" =>
"SELECT users.id
FROM users
JOIN accounts ON users.accounts_id = accounts.id
JOIN conferences ON users.conferences_id = conferences.id
WHERE conferences.status = 'running'
AND accounts.pendingemail IS NOT NULL
AND accounts.pendingemail != ''
"),
"accounts_email_unconfirmed_thisconference" => array("name" => "Users active for this conference with unconfirmed e-mail addresses", "query" =>
"SELECT users.id
FROM users JOIN accounts ON users.accounts_id = accounts.id
WHERE users.conferences_id = {$conference['id']}
AND accounts.pendingemail IS NOT NULL
AND accounts.pendingemail != ''
"),
);
?>

File diff suppressed because it is too large Load Diff

View File

@ -24,137 +24,55 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
if($_GET['action']=="status") {
$q=mysql_query("SELECT * FROM emailqueue WHERE finished IS NULL");
if($config['emailqueue_lock'] || mysql_num_rows($q)) {
echo "<h4>".i18n("Active Send Queues")."</h4>\n";
$q=mysql_query("SELECT *,UNIX_TIMESTAMP(started) AS ts FROM emailqueue WHERE finished IS NULL ORDER BY started DESC");
if(!$config['emailqueue_lock']) {
echo error(i18n("It looks like there's emails waiting to send, but the sending process isnt running.").
"<br />".
"<a href=\"communication.php?action=restartqueue\">".i18n("Click here to manually restart the process")."</a>");
}
echo "<table class=\"tableview\">";
echo "<thead><tr>";
echo " <th>".i18n("Name")."</th>\n";
echo " <th>".i18n("Subject")."</th>\n";
echo " <th>".i18n("Started")."</th>\n";
echo " <th>".i18n("Progress")."</th>\n";
echo " <th>".i18n("Duration")."</th>\n";
echo " <th>".i18n("ETA")."</th>\n";
echo " <th>".i18n("Cancel")."</th>\n";
echo "</tr></thead>\n";
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo " <td>$r->name</td>\n";
echo " <td>$r->subject</td>\n";
echo " <td>$r->started</td>\n";
$remaining=$r->numtotal-$r->numsent;
$now=time();
$duration=$now-$r->ts;
$num=$r->numsent+$r->numfailed;
echo " <td align=\"center\">$num / $r->numtotal</td>\n";
echo "<td>";
echo format_duration($duration);
echo "</td>";
echo "<td>";
if($r->numsent || $r->numfailed) {
$emailspersecond=($r->numsent+$r->numfailed)/$duration;
$remainingduration=$remaining/$emailspersecond;
echo format_duration($remainingduration);
}
else {
echo "Unknown";
}
echo "</td>";
echo "<td><a href=\"#\" onclick=\"return cancelQueue($r->id)\">".i18n("cancel")."</td>";
echo "</tr>\n";
}
echo "</table>";
echo "<br /><br />\n";
}
else {
echo notice("No Email Communications are currently being sent out");
?>
<script type="text/javascript">
stopRefreshing();
</script>
<?
}
$q=mysql_query("SELECT * FROM emailqueue WHERE finished IS NOT NULL ORDER BY started DESC LIMIT 10");
echo "<h4>".i18n("Completed Send Queues")."</h4>\n";
echo "<table class=\"tableview\">\n";
echo "<thead><tr>";
echo " <th>".i18n("Name")."</th>\n";
echo " <th>".i18n("Subject")."</th>\n";
echo " <th>".i18n("Started")."</th>\n";
echo " <th>".i18n("Finished")."</th>\n";
echo " <th>".i18n("Total Emails")."</th>\n";
echo " <th>".i18n("Success")."</th>\n";
echo " <th>".i18n("Failed")."</th>\n";
//FIXME: comment bounced until we implement it
// echo " <th>".i18n("Bounced")."</th>\n";
echo "</tr></thead>\n";
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo " <td>$r->name</td>\n";
echo " <td>$r->subject</td>\n";
echo " <td>$r->started</td>\n";
echo " <td>$r->finished</td>\n";
echo " <td align=\"center\">$r->numtotal</td>\n";
echo " <td align=\"center\">$r->numsent</td>\n";
echo " <td align=\"center\">$r->numfailed</td>\n";
//echo " <td align=\"center\">$r->numbounced</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
exit;
}
user_auth_required('committee', 'admin');
send_header("Communication Sending Status",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Communication' => 'admin/communication.php')
);
?>
<script type="text/javascript">
$(document).ready( function() {
refreshStatus();
});
var refreshTimeout;
function refreshStatus() {
$("#queuestatus").load("communication_send_status.php?action=status",null,function() {
<? if($config['emailqueue_lock']) { ?>
refreshTimeout=setTimeout('refreshStatus()',1000);
<? } ?>
});
}
function stopRefreshing() {
if(refreshTimeout) {
clearTimeout(refreshTimeout);
window.location.href="communication_send_status.php";
}
}
function cancelQueue(id) {
$("#debug").load("communication.php?action=cancel&cancel="+id,null,function() { if(!refreshTimeout) refreshStatus(); });
}
</script>
<?
echo "<br />";
echo "<div id=\"queuestatus\" style=\"margin-left: 20px;\">";
echo "</div>";
echo "<br />";
echo "<h3>".i18n("Communication Sending Status")."</h3>\n";
echo "<div style=\"margin-left: 20px\">";
if(file_exists("../data/communication.lock"))
{
$lines=file("../data/communication.lock");
echo "<b>Email ID:</b> ".$lines[0]." <br>";
echo "<b>Started:</b> ".$lines[1]." <br>";
echo "<b>Subject:</b> ".$lines[2]." <br>";
echo "<b>Total Recipients:</b> ".$lines[3]." <br>";
echo "<b>To:</b> ".$lines[4]." <br>";
echo "</div>";
$id=trim($lines[0]);
$total=trim($lines[3]);
echo "<h3>".i18n("Progress")."</h3>";
echo "<div style=\"margin-left: 20px\">";
if(file_exists("../data/communication.lock.$id"))
{
$progresslines=file("../data/communication.lock.$id");
$num=$progresslines[0];
$percent=round($num/$total*100,1);
echo i18n("%1 of %2 (%3%)",array($num,$total,$percent));
}
else
{
echo "Queued to start (should start within the next minute)";
}
echo "</div>";
echo "<br><br>Press your browsers 'Refresh' Button to see updated status";
}
else
{
echo notice("No Email Communications are currently being sent out");
echo "</div>";
}
send_footer();
?>

View File

@ -24,69 +24,35 @@
<?
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('admin');
user_auth_required('committee', 'admin');
require_once('xml.inc.php');
function xml_dearray(&$array)
{
// echo "<pre>";print_r($array);echo "</pre>";
$keys = array_keys($array);
foreach($keys as $k) {
if(!is_array($array[$k])) {
echo "Not array at key $k";
exit;
}
/* Special cases, leave these as arrays of entries */
if($k == 'award' || $k == 'prize') {
foreach($array[$k] as &$a) {
xml_dearray($a);
}
continue;
}
if(count($array[$k]) != 1) {
echo "Unexpected multielement array, stop.";
exit;
};
$array[$k] = $array[$k][0];
if(is_array($array[$k])) {
xml_dearray($array[$k]);
}
}
}
function curl_query($fair, $data, $ysc_url='')
function curl_query($fair, $data, $ysf_url='')
{
global $output;
switch($fair['type']) {
case 'sfiab':
$url = $fair['url'].'/remote.php';
$url = $fair['url'].'/xmltransport.php';
$var = 'json';
$d = array();
$d['auth'] = array('username' => $fair['username'],
'password' => $fair['password']);
$str = json_encode(array_merge($d, $data));
break;
case 'ysc':
if($ysc_url == '')
case 'ysf':
if($ysf_url == '')
$url = $fair['url'];
else
$url = $ysc_url;
$url = $ysf_url;
$var = 'xml';
$output="";
xmlCreateRecurse($data);
$str = $output;
break;
default:
echo "Unknown fair type {$fair['type']}";
break;
}
// debug_("Curl Send: (type:{$fair['type']}=>$url ysc_url=>$ysc_url) $str");
echo "<pre>Curl Send: $str</pre>";
$ch = curl_init(); /// initialize a cURL session
curl_setopt ($ch, CURLOPT_URL, $url);
@ -101,51 +67,20 @@
$datastream = curl_exec ($ch); /// execute the curl session and return the output to a variable $datastream
curl_close ($ch); /// close the curl session
// debug_("Server Returned: ".urldecode($datastream));
// echo "<pre>Server Returned: ".urldecode($datastream)."</pre>";
switch($fair['type']) {
case 'sfiab':
$ret=json_decode(urldecode($datastream), true);
break;
case 'ysc':
case 'ysf':
$datastream = str_replace(" standalone=\"yes\"","",$datastream);
/* Return is XML, make a return array */
$response=xml_parsexml($datastream);
if(!is_array($response)) {
$ret['message']=$datastream;
$ret['error']=0;
return $ret;
}
/* De-array everything */
xml_dearray($response);
$key = array_keys($response);
// echo "<pre>";print_r($response);echo "</pre>";
switch($key[0]) {
case 'awardresponse':
/* Full response */
$ret = $response['awardresponse'];
/* Undo variable to array */
$ret['awards'] = $ret['awards']['award'];
foreach($ret['awards'] as &$a)
$a['prizes'] = $a['prizes']['prize'];
$ret['error'] = 0;
$ret['message'] = '';
break;
case 'awardwinnersresponse':
/* Parse return */
$ret['error'] = ($response['awardwinnersresponse']['status'] == 'failed') ? 1 : 0;
$ret['message'] = $response['awardwinnersresponse']['statusmessage'];
break;
}
/* Return is plaintext, make a return array */
$ret['error'] = 0;
$ret['message'] = $datastream;
break;
}
//n debug_("Returning: ".print_r($ret, true));
echo "<pre>Server Returned: ";print_r($ret);echo "</pre><br>";
return $ret;
}
?>

View File

@ -28,11 +28,11 @@ include "xml.inc.php";
{
global $config;
$winners=array();
$winners_ids=array();
$q=mysql_query("SELECT * FROM award_awards WHERE cwsfaward='1' AND conferences_id='".$conference['id']."'");
while($award=mysql_fetch_object($q))
$q=mysql_query("SELECT * FROM award_awards WHERE cwsfaward='1' AND year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q)==1)
{
$award=mysql_fetch_object($q);
$pq=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$award->id'");
while($prize=mysql_fetch_object($pq))
{
@ -51,16 +51,11 @@ include "xml.inc.php";
WHERE
winners.projects_id=projects.id AND
awards_prizes_id='$prize->id' AND
winners.conferences_id='".$conference['id']."'");
winners.year='".$config['FAIRYEAR']."'");
echo mysql_error();
while($project=mysql_fetch_object($wq))
{
if(array_key_exists($project->id, $winners_ids)) {
continue;
} else {
$winners_ids[$project->id] = true;
}
$sq=mysql_query("SELECT * FROM students WHERE registrations_id='$project->registrations_id' AND conferences_id='".$conference['id']."'");
$sq=mysql_query("SELECT * FROM students WHERE registrations_id='$project->registrations_id' AND year='".$config['FAIRYEAR']."'");
$students=array();
$cwsf_agecategory=0;
while($s=mysql_fetch_object($sq))
@ -122,7 +117,7 @@ include "xml.inc.php";
<?
require("../common.inc.php");
require("../projects.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
send_header("One-Click CWSF Registration",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
@ -158,56 +153,49 @@ include "xml.inc.php";
// echo "curl close <br />";
curl_close ($ch); /// close the curl session
echo i18n("The YSC Registration Server said:")."<br />";
echo i18n("The YSF Registration Server said:")."<br />";
echo notice($datastream);
}
else
{
echo error("CURL Support Missing");
echo i18n("Your PHP installation does not support CURL. You will need to login to the YSC system as the regional coodinator and upload the XML data manually");
echo i18n("Your PHP installation does not support CURL. You will need to login to the YSF system as the regional coodinator and upload the XML data manually");
}
send_footer();
exit;
}
/* Load the YSC fair */
$q = mysql_query("SELECT * FROM fairs WHERE abbrv='YSC'");
if(mysql_num_rows($q) < 1) {
echo error(i18n("You have not defined the YSC upstream fair in the Science Fair Management area."));
$ok = false;
} else {
$f = mysql_fetch_assoc($q);
$ysc_region_id = $f['username'];
$ysc_region_password = $f['password'];
}
$ok=true;
//make sure we have the ysc_region_id and ysc_region_password
if($ysc_region_id == '') {
echo error(i18n("You have not yet specified a username for YSC (your Region ID). Go to the <a href=\"sciencefairs.php\">Science Fair Management</a> page to set it"));
//make sure we have the ysf_region_id and ysf_region_password
if(!$config['ysf_region_id'])
{
echo error(i18n("You have not yet specified your YSF Region ID. Go to the Configuration Variables page to set it"));
$ok=false;
}
if($ysc_region_password == '') {
echo error(i18n("You have not yet specified a password for YSC (your Region Password). Go to the <a href=\"sciencefairs.php\">Science Fair Management</a> page to set it"));
if(!$config['ysf_region_password'])
{
echo error(i18n("You have not yet specified your YSF Region Password. Go to the Configuration Variables page to set it"));
$ok=false;
}
if($ok)
{
$q=mysql_query("SELECT * FROM award_awards WHERE cwsfaward='1' AND conferences_id='".$conference['id']."'");
$q=mysql_query("SELECT * FROM award_awards WHERE cwsfaward='1' AND year='".$config['FAIRYEAR']."'");
if(!mysql_num_rows($q))
{
echo error(i18n("Cannot find an award that is specified as the Canada-Wide Science Fair Award"));
echo i18n("Please go to the awards manager and select which award identifies your CWSF students");
}
else if(mysql_num_rows($q)>1)
{
echo error(i18n("There is more than one award that is identified as your Canada-Wide Science Fair award."));
echo i18n("Please go to the awards manager and choose only one award that identifies your CWSF students");
}
else
{
echo "<b>".i18n("CWSF Awards").":</b> <br />";
echo "<ul>";
while($award=mysql_fetch_object($q)) {
echo "<li>{$award->name}</li>";
}
echo "</ul>";
echo i18n("Please review the list of winning projects/students below. If it is all correct then you can click the 'Register for CWSF' button at the bottom of the page to send the information to YSC");
$award=mysql_fetch_object($q);
echo "<b>".i18n("CWSF Award").":</b> ".$award->name."<br />";
echo i18n("Please review the list of winning projects/students below. If it is all correct then you can click the 'Register for CWSF' button at the bottom of the page to send the information to YSF");
echo "<br />";
echo "<br />";
$winners=get_cwsf_award_winners();
@ -215,10 +203,10 @@ include "xml.inc.php";
echo "<br />";
$error=false;
echo "<form method=\"post\" action=\"cwsfregister.php\">";
echo "<table class=\"tableview\"><thead>";
echo "<table class=\"viewtable\">";
echo "<tr><th>".i18n("Project Information")."</th>";
echo "<th>".i18n("Project Division / CWSF Project Division")."</th>";
echo "</tr></thead>";
echo "</tr>";
foreach($winners AS $winner)
{
@ -262,7 +250,7 @@ include "xml.inc.php";
echo "</td><td>";
$t=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='".$conference['id']."' AND id='".$winner['projectdivisions_id']."'");
$t=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' AND id='".$winner['projectdivisions_id']."'");
$tr=mysql_fetch_object($t);
echo $tr->division;
echo "<br />";
@ -297,8 +285,8 @@ include "xml.inc.php";
if(!$error)
{
$reg=array("registration"=>array(
"ysf_region_id"=>$ysc_region_id,
"ysf_region_password"=>$ysc_region_password,
"ysf_region_id"=>$config['ysf_region_id'],
"ysf_region_password"=>$config['ysf_region_password'],
"projects"=>$winners
)
);
@ -307,7 +295,7 @@ include "xml.inc.php";
xmlCreateRecurse($reg);
$xmldata=$output;
echo "<h3>".i18n("The following data will be sent to Youth Science Canada")."</h3>";
echo "<h3>".i18n("The following data will be sent to YSF")."</h3>";
echo "<form method=\"post\" action=\"cwsfregister.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"register\">";
echo "<textarea rows=\"15\" cols=\"80\" name=\"xml\">";
@ -315,7 +303,7 @@ include "xml.inc.php";
echo "</textarea>";
echo "<br />";
echo "<br />";
echo i18n("Warning! You can only use this feature once, and it will send whatever data is listed above. If you try to submit this data a second time to YSC it will not work. So please make sure everything is correct before submitting!");
echo i18n("Warning! You can only use this feature once, and it will send whatever data is listed above. If you try to submit this data a second time to YSF it will not work. So please make sure everything is correct before submitting!");
echo "<br />";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Register for CWSF")."\">";

View File

@ -23,12 +23,12 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
$q=mysql_query("SELECT * FROM documents WHERE id='".$_GET['id']."'");
if($r=mysql_fetch_object($q))
{
header("Content-type: ".trim(exec("file -bi ../data/documents/$r->filename")));
header("Content-disposition: inline; filename=\"".$r->filename."\"");
header("Content-disposition: inline; filename=$r->filename");
header("Content-length: ".filesize("../data/documents/$r->filename"));
readfile("../data/documents/$r->filename");
}

View File

@ -31,7 +31,7 @@
if(!file_exists("../data/documents/.htaccess"))
file_put_contents("../data/documents/.htaccess","Order Deny,Allow\r\nDeny From All\r\n");
user_auth_required('admin');
user_auth_required('committee', 'admin');
send_header("Internal Document Manager",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),

File diff suppressed because it is too large Load Diff

View File

@ -1,124 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2008 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
echo "<br />\n";
//$q=mysql_query("SELECT * FROM award_sponsors WHERE year='".$config['FAIRYEAR']."' ORDER BY organization");
//we want to show all years, infact that year field probably shouldnt even be there.
$sql="";
if($_POST['search']) $sql.=" AND organization LIKE '%".mysql_real_escape_string($_POST['search'])."%' ";
if(count($_POST['donortype'])) {
$sql.=" AND (0 ";
foreach($_POST['donortype'] AS $d) {
$sql.=" OR donortype='$d'";
}
$sql.=") ";
}
$query="SELECT * FROM sponsors WHERE 1 $sql ORDER BY organization";
// echo "query=$query";
$q=mysql_query($query);
$thisyear=$config['FISCALYEAR'];
$lastyear=$config['FISCALYEAR']-1;
$rows=array();
while($r=mysql_fetch_object($q))
{
$cq=mysql_query("SELECT SUM(value) AS total FROM fundraising_donations WHERE sponsors_id='$r->id' AND status='received' AND fiscalyear='$thisyear'");
$cr=mysql_fetch_object($cq);
$thisyeartotal=$cr->total;
$cq=mysql_query("SELECT SUM(value) AS total FROM fundraising_donations WHERE sponsors_id='$r->id' AND status='received' AND fiscalyear='$lastyear'");
$cr=mysql_fetch_object($cq);
$lastyeartotal=$cr->total;
if($lastyeartotal)
$change=round(($thisyeartotal-$lastyeartotal)/$lastyeartotal*100);
else
$change="N/A";
$rows[]=array("id"=>$r->id, "name"=>$r->organization, "thisyeartotal"=>$thisyeartotal, "lastyeartotal"=>$lastyeartotal, "change"=>$change);
}
$thisyearsort=array();
if(!$_POST['order']) {
//if order is not given, lets order by donation amount this year
foreach($rows AS $key=>$val) {
$thisyearsort[$key]=$val['thisyeartotal'];
}
array_multisort($thisyearsort,SORT_DESC,$rows);
}
if($_POST['limit']) {
$limit=$_POST['limit'];
}
else {
$limit=10;
echo "<h4>".i18n("Top 10 donors this year")."</h4>";
}
echo "<table class=\"tableview\">";
echo "<thead>";
echo "<tr>";
echo " <th>".i18n("Donor/Sponsor")."</th>";
echo " <th>".i18n("Total $ this year")."</th>";
echo " <th>".i18n("Total $ last year")."</th>";
echo " <th>".i18n("% change")."</th>";
echo "</tr>";
echo "</thead>\n";
$x=0;
foreach($rows AS $r) {
echo "<tr>\n";
$eh="style=\"cursor:pointer;\" onclick=\"open_editor({$r['id']});\"";
echo " <td $eh>{$r['name']}</td>\n";
echo " <td style=\"text-align: right;\">";
echo format_money($r['thisyeartotal']);
echo "</td>\n";
echo " <td style=\"text-align: right;\">";
echo format_money($r['lastyeartotal']);
echo "</td>\n";
if(is_numeric($r['change'])) {
$n=$r['change']/2+50;
if($n<0) $n=0;
if($n>100) $n=100;
$col="color: ".colour_to_percent($n);
$sign="%";
}
else{
$col=""; $sign=""; }
echo " <td style=\"text-align: center; $col\">";
echo $r['change'].$sign;
echo "</td>\n";
echo "</tr>\n";
$x++;
if($x==$limit)
break;
}
echo "</table>\n";
?>

View File

@ -1,91 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require("../tableeditor.class.php");
require_once("../user.inc.php");
user_auth_required('admin');
send_header("Events Management",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Events & Scheduling' => 'admin/eventsscheduling.php'),
"events_scheduling" );
echo "<br />";
$editor = new TableEditor('events',
array(
"name" => "Event Name",
"eventtype" => "Type",
"suggested_grades" => "Suggested Grades",
),
array(
"name" => "Event Name",
"eventtype" => "Type",
"summary" => "Summary",
"website" => "Link to Description",
"suggested_grades" => "Suggested Grades",
"default_min_teams" => "Minimum Number of Teams",
"default_max_teams" => "Maximum Number of Teams",
"default_min_team_size" => "Minimum Team Size",
"default_max_team_size" => "Maximum Team Size",
"default_min_judges" => "Minimum Number of Judges",
"default_max_judges" => "Maximum Number of Judges",
"default_min_volunteers" => "Minimum Number of Volunteers",
"default_max_volunteers" => "Maximum Number of Volunteers"
),
array(
"conferences_id" => $conference['id']
)
);
$eventtypes=array( array('key'=>"general", 'val'=>"General"),
array('key'=>"scienceolympic", 'val'=>"Science Olympics Activity"),
array('key'=>"sciencefairjudging", 'val'=>"Science Fair Judging"),
array('key'=>"tour", 'val'=>"Tour")
);
$editor->setFieldOptions("eventtype",$eventtypes);
$editor->setPrimaryKey("id");
$editor->setRecordType("Event");
$editor->setDefaultSortField("eventtype,name");
$editor->filterList("conferences_id", $conference['id']);
$editor->setFieldDefaultValue("default_min_teams",1);
$editor->setFieldDefaultValue("default_max_teams",4);
$editor->setFieldDefaultValue("default_min_team_size",1);
$editor->setFieldDefaultValue("default_max_team_size",6);
$editor->setFieldDefaultValue("default_min_judges",1);
$editor->setFieldDefaultValue("default_max_judges",2);
$editor->setFieldDefaultValue("default_min_volunteers",1);
$editor->setFieldDefaultValue("default_max_volunteers",5);
$editor->execute();
send_footer();
?>

View File

@ -1,41 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
send_header("Events &amp; Scheduling",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
"events_scheduling" );
echo "<br />";
echo "<a href=\"locations.php\">".i18n('Event Locations')."</a><br />";
echo "<a href=\"events.php\">".i18n('Event Management')."</a><br />";
echo "<a href=\"schedule.php\">".i18n('Schedule Management')."</a><br />";
send_footer();
?>

View File

@ -1,672 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2010 David Grant <dave@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require_once('../common.inc.php');
require_once('judges.inc.php'); /* for getJudgingEligibilityCode() */
require_once('anneal.inc.php');
if($_SERVER['SERVER_ADDR']) {
echo "This script must be run from the command line";
exit;
}
$action = '';
switch($argv[1]) {
case '--images':
$action = 'images';
break;
case '--pn':
$action = 'pn';
break;
}
//function TRACE() { }
//function TRACE_R() { }
function TRACE($str) { print($str); }
function TRACE_R($array) { print_r($array); }
function point_rotate($x, $y, $deg)
{
/* Use - orienttaiotn because rotation is always done from dest->src */
$r = deg2rad(-$deg);
return array(round($x*cos($r) - $y*sin($r), 6), round($x*sin($r) + $y*cos($r), 6));
}
function point_translate($x, $y, $dx, $dy)
{
return array ($x+$dx, $y+$dy);
}
function is_point_in_object($x, $y, $o)
{
/* Translate the point to the object origin */
list($x, $y) = point_translate($x, $y, -$o['x'], -$o['y']);
/* Rotate the point to the object's frame of reference*/
list($x, $y) = point_rotate($x, $y, -$o['orientation']);
/* Is it within the object now ? */
if(abs($x) <= $o['w2'] && abs($y) <= $o['h2'])
return true;
return false;
}
function queue_new()
{
return array('head' => NULL, 'tail' => NULL);
}
function grid_path_cmp($a, $b)
{
/* This must return an integer! Strange-things(tm) happen if it doesn't */
if($a['distance'] == $b['distance']) return 0;
return ($a['distance'] < $b['distance']) ? -1 : 1;
}
function grid_path_check(&$i_eh, &$queue, &$loc, &$end, $ix, $iy)
{
$next_loc =& $i_eh[$ix][$iy];
// TRACE("Checking next loc($ix,$iy) ({$next_loc['x']},{$next_loc['y']})\n");
/* Don't revisit anything */
if($next_loc['visited'] == true) {
// TRACE(" Already Visited.\n");
return false;
}
$next_loc['visited'] = true;
if(count($next_loc['ids']) != 0) {
// TRACE(" Object occupying this gridloc.\n");
/* There's something here, can't do anything */
return false;
}
$next_loc['distance'] = distance($next_loc['x'], $next_loc['y'], $end['x'], $end['y']);
$next_loc['path_length'] = $loc['path_length'] + 1;
// TRACE(" distance={$next_loc['distance']}, path_length={$next_loc['path_length']}\n");
/* Add to processing queue in order */
array_push($queue, $next_loc);
}
function grid_path($src, $dst)
{
global $exhibithall;
$i_eh = &$exhibithall[$src['exhibithall_id']];
$start = &$i_eh[$src['front_grid_ix']][$src['front_grid_iy']];
$end = &$i_eh[$dst['front_grid_ix']][$dst['front_grid_iy']];
// TRACE("Path ({$start['x']},{$start['y']}) -> ({$end['x']},{$end['y']})\n");
/* Clean out temp data */
for($x=0;$x<$i_eh['grid_w']; $x++) {
for($y=0;$y<$i_eh['grid_h']; $y++) {
$i_eh[$x][$y]['visited'] = false;
}
}
// print_r($i_eh);
/* Seed the exploration queue */
$queue = array();
$start['distance'] = distance($start['x'], $start['y'], $end['x'], $end['y']);
$start['path_length'] = 0;
$start['visited'] = true;
array_push($queue, $start);
while(1) {
if(count($queue) == 0) break;
// print_r($queue);
/* Dequeue head */
$loc = array_shift($queue);
/* Cut it off after a long walk */
if($loc['path_length'] > 25) break;
// TRACE("Dequeue: ({$loc['x']},{$loc['y']})\n");
/* Is this our destionation ? */
if($loc['x'] == $end['x'] && $loc['y'] == $end['y']) {
// TRACE("Found destination, path_length={$loc['path_length']}\n");
return $loc['path_length'];
}
/* All 4 directions */
if($loc['ix'] > 0) grid_path_check($i_eh, $queue,$loc, $end, $loc['ix']-1, $loc['iy']);
if($loc['ix'] < $i_eh['grid_w']-1) grid_path_check($i_eh, $queue, $loc, $end, $loc['ix']+1, $loc['iy']);
if($loc['iy'] > 0) grid_path_check($i_eh, $queue, $loc, $end, $loc['ix'], $loc['iy']-1);
if($loc['iy'] < $i_eh['grid_h']-1) grid_path_check($i_eh, $queue, $loc, $end, $loc['ix'], $loc['iy']+1);
usort($queue, 'grid_path_cmp');
}
// TRACE("No path found\n");
// exit;
return 100;
}
TRACE("<pre>\n");
/* Load exhibit halls */
$exhibithall = array();
$q = mysql_query("SELECT * FROM exhibithall WHERE type='exhibithall'");
TRACE("Loading exhibit halls...\n");
while(($r = mysql_fetch_assoc($q))) {
$r['divs'] = unserialize($r['divs']);
$r['cats'] = unserialize($r['cats']);
$exhibithall[$r['id']] = $r;
TRACE(" - {$r['name']}\n");
}
/* Load objects */
$objects = array();
$q = mysql_query("SELECT * FROM exhibithall WHERE type='wall' OR type='project'");
TRACE("Loading objects...\n");
while(($r = mysql_fetch_assoc($q))) {
$r['divs'] = unserialize($r['divs']);
$r['cats'] = unserialize($r['cats']);
$objects[$r['id']] = $r;
}
TRACE(count($objects)." objects loaded.\n");
/* Compute stuff */
foreach($objects as $oid=>$o) {
$objects[$oid]['w2'] = $o['w']/2;
$objects[$oid]['h2'] = $o['h']/2;
}
/* The grid size is the smallest object dimension */
$grid_size = 100;
foreach($objects as $oid=>$o) {
if($grid_size > $o['w']) $grid_size = $o['w'];
if($grid_size > $o['h']) $grid_size = $o['h'];
}
$grid_size /= 2;
TRACE("Grid size: {$grid_size}m\n");
//print_r($exhibithall);
//print_r($objects);
$div = array();
TRACE("Loading Project Divisions...\n");
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='{$conference['id']}' ORDER BY id");
while($r=mysql_fetch_object($q))
{
$divshort[$r->id]=$r->division_shortform;
$div[$r->id]=$r->division;
TRACE(" {$r->id} - {$div[$r->id]}\n");
}
TRACE("Loading Project Age Categories...\n");
$cat = array();
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='{$conference['id']}' ORDER BY id");
while($r=mysql_fetch_object($q)) {
$catshort[$r->id]=$r->category_shortform;
$cat[$r->id]=$r->category;
TRACE(" {$r->id} - {$r->category}\n");
}
TRACE("Loading Projects...\n");
$projects = array();
$q = mysql_query("SELECT projects.* FROM projects, registrations
WHERE
projects.conferences_id='{$conference['id']}'
AND registrations.id = projects.registrations_id
".getJudgingEligibilityCode());
while($p = mysql_fetch_object($q)) {
$qq = mysql_query("SELECT grade,schools_id FROM students WHERE registrations_id='{$p->registrations_id}'");
$num_students = mysql_num_rows($qq);
$grade = 0;
$schools_id = 0;
while($s = mysql_fetch_assoc($qq)) {
if($s['grade'] > $grade) {
$grade = $s['grade'];
$schools_id = $s['schools_id'];
}
}
$projects[$p->id] = array(
'projects_id' => $p->id,
'div' => $p->projectdivisions_id,
'cat' => $p->projectcategories_id,
'grade' => $grade,
'schools_id' => $schools_id,
'req_electricity' => $p->req_electricity,
'projectnumber' => $p->projectnumber,
'floornumber' => $p->floornumber,
'num_students' => $num_students);
}
TRACE(count($projects)." projects loaded.\n");
if($action == 'pn') {
TRACE("Generating Project Numbers from Floor Locations...\n");
foreach($projects as $p) {
$c = $catshort[$p['cat']];
$d = $divshort[$p['div']];
$n = sprintf("%03d", $p['floornumber']);
$pn = "$c $n $d";
TRACE("Project {$p['projects_id']} at loc {$p['floornumber']}: $pn\n");
mysql_query("UPDATE projects SET projectnumber='$pn' WHERE id='{$p['projects_id']}'");
}
TRACE("Done.\n");
exit;
}
/* Assign objects to grid locations */
foreach($exhibithall as &$i_eh) {
TRACE("Assigning objects to grid locations for {$i_eh['name']}...\n");
$ix = 0;
$i_eh['grid_w'] = 0;
$i_eh['grid_h'] = 0;
for($x=0;$x<=$i_eh['w'];$x+=$grid_size,$ix++) {
if($ix <= $i_eh['grid_w']) $i_eh['grid_w'] = $ix+1;
$iy = 0;
for($y=0;$y<=$i_eh['h'];$y+=$grid_size,$iy++) {
if($iy <= $i_eh['grid_h']) $i_eh['grid_h'] = $iy+1;
/* Initialize element if required */
if(!is_array($i_eh[$ix][$iy])) {
$i_eh[$ix][$iy] = array( 'x' => $x, 'ix' => $ix,
'y' => $y, 'iy' => $iy,
'ids' => array(),
'project_front' => 0);
}
/* Scan all objects */
foreach($objects as $oid=>$o) {
if($o['exhibithall_id'] != $i_eh['id']) continue;
if(is_point_in_object($x, $y, $o)) {
$i_eh[$ix][$iy]['ids'][] = $oid;
}
}
}
}
TRACE("Grid locations: {$i_eh['grid_w']}x{$i_eh['grid_h']}\n");
}
TRACE("Done.\n");
function distance($x1,$y1,$x2,$y2)
{
return sqrt( ($x1-$x2)*($x1-$x2)+($y1-$y2)*($y1-$y2) );
}
TRACE("Computing gridlocation of front of projects...\n");
foreach($objects as $oid=>$o) {
if($o['type'] != 'project') continue;
/* Get a pointer to the exhibit hall */
$i_eh = &$exhibithall[$o['exhibithall_id']];
/* Compute the xy of the front (that's the bottom edge of the unrotate project) */
$fx = 0;
$fy = $o['h2'];
// TRACE("Front orig: ($fx,$fy)\n");
/* Rotate the point */
list($fx, $fy) = point_rotate($fx, $fy, $o['orientation']);
// TRACE("Front rotate by {$o['orientation']}: ($fx,$fy) \n");
/* Translate it to the proper position of the object */
list($fx, $fy) = point_translate($fx, $fy, $o['x'], $o['y']);
// TRACE("Front: ($fx,$fy) $grid_size\n");
/* Snap to grid offsets */
$gx = intval($fx / $grid_size); //* $grid_size;
$gy = intval($fy / $grid_size); //* $grid_size;
// TRACE("Search grid around $gx, $gy\n");
/* Search around that grid for a free spot, closest to $fx,$fy,
* with no objects and no object_front */
$smallest_d = $i_eh['w'];
$smallest_ix = 0;
$smallest_iy = 0;
$found = false;
for($x = $gx - 1; $x <= $gx + 1; $x++) {
for($y = $gy - 1; $y <= $gy + 1; $y++) {
// TRACE("At ($x, $y) :\n");
// print_r($i_eh[$x][$y]);
if(count($i_eh[$x][$y]['ids'])) continue;
if($i_eh[$x][$y]['project_front'] > 0) continue;
/* Check distance */
$d = distance($i_eh[$x][$y]['x'], $i_eh[$x][$y]['y'], $fx, $fy);
if($d < $smallest_d) {
$smallest_d = $d;
$smallest_ix = $x;
$smallest_iy = $y;
$found = true;
}
}
}
if($found == false) {
echo "ERROR: couldn't find project front for:\n";
print_r($o);
exit;
}
$i_eh[$smallest_ix][$smallest_iy]['project_front'] = $oid;
$objects[$oid]['front_x'] = $fx;
$objects[$oid]['front_y'] = $fy;
$objects[$oid]['front_grid_ix'] = $smallest_ix;
$objects[$oid]['front_grid_iy'] = $smallest_iy;
}
TRACE("Done.\n");
switch($action) {
case 'images':
exhibithall_images();
exit;
}
/* Compute closest projects to each project */
$project_distance = 100 / $grid_size;
foreach($objects as $oid=>$o) {
if($o['type'] != 'project') continue;
TRACE("Computing paths for {$o['name']}...\n");
/* Get a pointer to the exhibit hall */
$i_eh = &$exhibithall[$o['exhibithall_id']];
/* Starting grid location */
$grid_start = &$i_eh[$o['front_grid_ix']][$o['front_grid_iy']];
/* Path to all other objects in the same exhibit hall */
foreach($objects as $d_oid=>$d_o) {
if($d_oid == $oid) continue;
if($o['exhibithall_id'] != $d_o['exhibithall_id']) continue;
$d = grid_path($o, $d_o);
$objects[$oid]['nearby_projects'][] = array('distance' => $d, 'id'=>$d_oid);
if($d < $project_distance) $project_distance = $d;
}
/* Use the grid_path_cmp to sort the projects based on 'distance' */
usort($objects[$oid]['nearby_projects'], 'grid_path_cmp');
}
TRACE("Project Distance: {$project_distance} hops\n");
/* Compute project distances */
foreach($objects as $oid=>$o) {
if($o['type'] != 'project') continue;
foreach($objects[$oid]['nearby_projects'] as &$nearby_project) {
$nearby_project['project_distance'] = $nearby_project['distance'] / $project_distance;
}
}
/* Build a list of floor objects for the annealer*/
$floor_objects = array();
$x = 0;
foreach($objects as $oid=>$o) {
if($o['type'] != 'project') continue;
$objects[$oid]['floor_object_offset'] = $x; /* The same as the annealer bucket id */
$floor_objects[$x++] = &$objects[$oid];
}
/* Project floor location cost:
* - Keep divisions together
* - keep grades together
* - a project should have one of the same school nearby or adjacent, but not a lot nearby
*/
function project_cost(&$annealer, $bucket_id, $ids)
{
global $floor_objects, $projects, $exhibithall, $objects;
$cost = 0;
/* Get the floor object */
$o = &$floor_objects[$bucket_id];
/* The exhibit hall */
$eh = &$exhibithall[$o['exhibithall_id']];
if(count($ids) == 0) {
// TRACE("No items in bucket, returning 0.\n");
return 0;
}
if(count($ids) > 1) {
echo "More than one item in bucket! Bug somewhere.\n";
exit;
}
/* Get the project info */
$p = &$projects[$ids[0]];
$school_match = 0;
$div_match = 0;
$grade_match = 0;
$x = 0;
// TRACE("Cost for bucket $bucket_id...\n");
$min = $p['grade'];
$max = $p['grade'];
foreach($o['nearby_projects'] as &$n) {
/* Get the nearby project object*/
$nearby_o = &$objects[$n['id']];
// TRACE(" Scanning nearby location {$n['id']} (distance={$n['distance']})\n");
// print_r($nearby_o);
$nearby_bucket_id = $nearby_o['floor_object_offset'];
$nearby_bkt = &$annealer->bucket[$nearby_bucket_id];
// TRACE(" Bucket id: {$nearby_bucket_id} with ".count($nearby_bkt)." items\n");
if(count($nearby_bkt) == 0) continue;
$nearby_p = &$projects[$nearby_bkt[0]];
/* Only consider closest 5 projects for school */
if($nearby_p['schools_id'] == $p['schools_id']) {
if($x < 5) $school_match++;
}
/* Closest 5 projects for divs */
if($nearby_p['div'] == $p['div']) {
if($x < 5) $div_match++;
}
/* Closest 10 for grade variance */
if($x < 10) {
if($nearby_p['grade'] < $min) $min = $nearby_p['grade'];
if($nearby_p['grade'] > $max) $max = $nearby_p['grade'];
}
$x++;
if($x == 10) break;
}
if($school_match == 0) {
// TRACE(" No school nearby\n");
$cost += 5;
}
if($school_match > 2) {
// TRACE(" Too many schools bunched up\n");
$cost += 2 * ($school_match-1);
}
if($div_match < 2) {
// TRACE(" No divs nearby\n");
$cost += 20;
}
if($div_match > 4) {
// TRACE(" Divs bunching up\n");
$cost += 10 * ($div_match - 4);
}
if($max - $min > 0) {
/* Don't want bunching up grades eitehr */
// TRACE(" Grades too spread out\n");
$cost += 50 * ($max-$min);
}
/* Make sure this project is allowed in this exhibit hall */
if(!in_array($p['div'], $eh['divs']))
$cost += 1000;
if(!in_array($p['cat'], $eh['cats']))
$cost += 1000;
/* Make sure this project is allowed in this floor object too */
if(count($o['divs']) > 0 && !in_array($p['div'], $o['divs']))
$cost += 1000;
if(count($o['cats']) > 0 && !in_array($p['cat'], $o['cats']))
$cost += 1000;
/* Match electricity */
if($p['req_electricity'] == 'yes' && $o['has_electricity'] == 'no') {
$cost += 1000;
}
// TRACE("Cost for bucket $bucket_id = $cost\n");
return $cost;
}
function project_bucket_ids($annealer, $bucket_id)
{
global $floor_objects, $objects;
$recompute_ids = array($bucket_id);
/* Get the floor object */
$o = &$floor_objects[$bucket_id];
/* Find the 10 closest projects */
$x = 0;
foreach($o['nearby_projects'] as &$n) {
$nearby_o = &$objects[$n['id']];
$recompute_ids[] = $nearby_o['floor_object_offset'];
$x++;
if($x == 15) break;
}
return $recompute_ids;
}
$e = 10 * ($config['effort'] / 1000) * pow(count($projects), 1.3333);
$project_ids = array_keys($projects);
//array_splice($project_ids, 20);
$a = new annealer(count($floor_objects), 125, $e, 0.9,
project_cost, $project_ids);
$a->set_max_items_per_bucket(1);
//$a->set_delta_cost_bucket_ids_callback(project_bucket_ids);
$a->anneal();
for($x=0;$x<$a->num_buckets; $x++) {
$bkt = $a->bucket[$x];
if(count($bkt) > 1) {
TRACE("Assigned more than one project to bucket $x\n");
exit;
}
if(count($bkt) == 0) continue;
/* Get the project id in this bucket */
$projects_id = array_shift($bkt);
echo "p:$projects_id, n:{$floor_objects[$x]['floornumber']}\n";
/* Get the floor object for the same bucket and floor number */
$projects[$projects_id]['floornumber'] = $floor_objects[$x]['floornumber'];
}
print_r($projects);
/* Assign floor numbers */
mysql_query("UPDATE projects SET floornumber=0 WHERE conferences_id='{$conference['id']}'");
foreach($projects as $pid=>$p) {
mysql_query("UPDATE projects SET floornumber='{$p['floornumber']}' WHERE id='$pid'");
TRACE("Project $pid => Floor number {$p['floornumber']}\n");
}
TRACE("</pre>");
function exhibithall_images()
{
global $exhibithall, $objects, $projects;
/* Assign project IDs to objects */
foreach($objects as $oid=>$o) {
foreach($projects as $pid=>$p) {
if($p['floornumber'] == $o['floornumber']) {
$objects[$oid]['projects_id'] = $pid;
break;
}
}
}
foreach($exhibithall as &$i_eh) {
$i = imagecreatetruecolor($i_eh['w']*100, $i_eh['h']*100);
$c_grey = imagecolorallocate($i, 128, 128, 128);
$c_white = imagecolorallocate($i, 255, 255, 255);
$c_black = imagecolorallocate($i, 0, 0, 0);
// Fill the background with the color selected above.
imagefill($i, 0, 0, $c_white);
imagerectangle($i, 0, 0, $i_eh['w']*100 - 1, $i_eh['h']*100 - 1, $c_black);
for($ix=0;$ix<=$i_eh['grid_w'];$ix++) {
for($iy=0;$iy<=$i_eh['grid_h'];$iy++) {
$l = $i_eh[$ix][$iy];
if(count($l['ids']) > 0) {
imageellipse($i, $l['x']*100, $l['y']*100, 1, 1, $c_black);
} else {
imageellipse($i, $l['x']*100, $l['y']*100, 1, 1, $c_grey);
}
}
}
foreach($objects as $oid=>$o) {
if($o['exhibithall_id'] != $i_eh['id']) continue;
list($x1,$y1) = point_rotate(-$o['w2'], -$o['h2'], $o['orientation']);
list($x2,$y2) = point_rotate($o['w2'], $o['h2'], $o['orientation']);
imagerectangle($i, ($o['x']+$x1)*100, ($o['y']+$y1)*100, ($o['x']+$x2)*100, ($o['y']+$y2)*100, $c_black);
$p = $projects[$o['projects_id']];
imagestring($i, 4, $o['x']*100 - 30, $o['y']*100 - 35, "{$o['floornumber']} ({$p['projects_id']})", $c_black);
imagestring($i, 4, $o['x']*100 - 30, $o['y']*100 - 20, "gr:{$p['grade']} ", $c_black);
$d = $divshort[$p['div']];
imagestring($i, 4, $o['x']*100 - 30, $o['y']*100 - 5, "d:$d ({$p['div']})", $c_black);
imagestring($i, 4, $o['x']*100 - 30, $o['y']*100 + 10, "s:{$p['schools_id']}", $c_black);
imagestring($i, 4, $o['x']*100 - 30, $o['y']*100 + 25, "e:{$p['req_electricity']}", $c_black);
}
imagepng($i, "./eh-{$i_eh['id']}.png");
}
}
?>

View File

@ -24,16 +24,16 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
require("../lpdf.php");
$catq=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' AND id='".$_GET['cat']."'");
$catq=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' AND id='".$_GET['cat']."'");
if($catr=mysql_fetch_object($catq))
{
$pdf=new lpdf( i18n($config['fairname']),
i18n("Checkin List")." - ".i18n($catr->category),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']-logo-200.gif"
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
);
$pdf->newPage();
@ -48,7 +48,7 @@ if($catr=mysql_fetch_object($catq))
registrations
left outer join projects on projects.registrations_id=registrations.id
WHERE
registrations.conferences_id='".$conference['id']."'
registrations.year='".$config['FAIRYEAR']."'
AND ( registrations.status='complete' OR registrations.status='paymentpending' )
AND projects.projectcategories_id='$catr->id'
ORDER BY
@ -74,7 +74,7 @@ if($catr=mysql_fetch_object($catq))
}
while($r=mysql_fetch_object($q))
{
$divq=mysql_query("SELECT division,division_shortform FROM projectdivisions WHERE conferences_id='".$conference['id']."' AND id='".$r->projectdivisions_id."'");
$divq=mysql_query("SELECT division,division_shortform FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' AND id='".$r->projectdivisions_id."'");
$divr=mysql_fetch_object($divq);
$sq=mysql_query("SELECT students.firstname,

View File

@ -24,23 +24,15 @@
<?
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('admin');
user_auth_required('committee', 'admin');
require_once('xml.inc.php');
require_once('stats.inc.php');
require_once('curl.inc.php');
/* Hack so we can jump right to YSC stats */
if($_GET['abbrv'] == 'YSC') {
$q = mysql_query("SELECT id FROM fairs WHERE abbrv='YSC'");
$r = mysql_fetch_assoc($q);
$_GET['id'] = $r['id'];
}
function stats_to_ysc($fair, $stats)
function stats_to_ysf($fair, $stats)
{
if($fair['type'] == 'ysc') {
/* Map data into YSC tags */
if($fair['type'] == 'ysf') {
/* Map data into YSF tags */
$y=array();
$y["numschoolstotal"]=$stats['schools_total'];
$y["numschoolsactive"]=$stats['schools_active'];
@ -65,24 +57,24 @@
}
send_header("Upload Fair Statistics and Information",
send_header("Fair Stats",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
"fair_stats"
"one-click_ysf_affiliation_stats"
);
echo "<br />";
/* SFIAB config options server side */
$server_config = array();
$server_config['participation'] = false;
$server_config['schools_ext'] = false;
$server_config['minorities'] = false;
$server_config['guests'] = false;
$server_config['sffbc_misc'] = false;
$server_config['info'] = false;
$server_config['next_chair'] = false;
$server_config['scholarships'] = false;
$server_config['delegates'] = false;
$server_config['fair_stats_participation'] = 'no';
$server_config['fair_stats_schools_ext'] = 'no';
$server_config['fair_stats_minorities'] = 'no';
$server_config['fair_stats_guests'] = 'no';
$server_config['fair_stats_sffbc_misc'] = 'no';
$server_config['fair_stats_info'] = 'no';
$server_config['fair_stats_next_chair'] = 'no';
$server_config['fair_stats_scholarships'] = 'no';
$server_config['fair_stats_delegates'] = 'no';
if($_GET['year']) $year=intval($_GET['year']);
else $year=$config['FAIRYEAR'];
@ -103,8 +95,8 @@
$stats[$k] = $_POST[$k];
}
$stats['year'] = $year;
if($fair['type'] == 'ysc') {
$st = stats_to_ysc($fair, $stats);
if($fair['type'] == 'ysf') {
$st = stats_to_ysf($fair, $stats);
$req = array('affiliation' => array(
"ysf_region_id"=>$fair['username'],
"ysf_region_password"=>$fair['password'],
@ -126,7 +118,7 @@
// $year = $config['FAIRYEAR'];
} else {
echo error("CURL Support Missing");
echo i18n("Your PHP installation does not support CURL. You will need to login to the YSC system as the regional coodinator and upload the XML data manually");
echo i18n("Your PHP installation does not support CURL. You will need to login to the YSF system as the regional coodinator and upload the XML data manually");
send_footer();
exit;
}
@ -134,17 +126,16 @@
echo "<form name=\"fairselect\" action=\"$PHPSELF\" method=\"get\">";
$q=mysql_query("SELECT * FROM fairs WHERE `type`='sfiab' OR `type`='ysc' AND enable_stats='yes'");
echo "<select name=\"id\">";
echo "<option value=\"\">".i18n("Choose a destination")."</option>\n";
$q=mysql_query("SELECT * FROM fairs WHERE `type`='sfiab' OR `type`='ysf'");
echo "<select name=\"id\" \">";
echo "<option value=\"\">".i18n("Choose a fair")."</option>\n";
while($r=mysql_fetch_object($q)) {
if($fairs_id==$r->id) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"{$r->id}\">{$r->name} ({$r->abbrv})</option>\n";
}
echo "</select>\n";
$q=mysql_query("SELECT DISTINCT(year) AS year FROM config WHERE year>0 ORDER BY year");
echo "<select name=\"year\">";
echo "<select name=\"year\" >";
echo "<option value=\"\">".i18n("Choose a year")."</option>\n";
while($r=mysql_fetch_object($q)) {
if($year==$r->year) $sel="selected=\"selected\""; else $sel="";
@ -157,25 +148,14 @@
echo "<hr />";
if($fairs_id == -1) {
echo i18n('Statistics will be shown below this line before being sent. Please select a destination and year first.');
echo i18n('Statistics will be shown below this line before being sent. Please select a fair and year first.');
/* Wait for them to select somethign before generating stats */
send_footer();
exit;
}
$ok = true;
if(trim($fair['username']) == '') {
echo error(i18n("You have not yet specified a username for this server. Go to the <a href=\"sciencefairs.php\">Science Fair Management</a> page to set it"));
$ok=false;
}
if(trim($fair['password']) == '') {
echo error(i18n("You have not yet specified a password for this server. Go to the <a href=\"sciencefairs.php\">Science Fair Management</a> page to set it"));
$ok=false;
}
if($fair['type'] == 'ysc') {
$data['statconfig'] = array('participation');
if($fair['type'] == 'ysf') {
$data['statconfig'] = array('fair_stats_participation');
} else {
echo notice(i18n('Getting stats request and downloading existing stats from server %1', array($fair['url'])));
/* Query the server to see what stats we need */
@ -194,8 +174,8 @@
echo i18n('This server has requested the following stats for your %1 fair:', array($year));
echo '<br /><br />';
foreach($data['statconfig'] as $k) {
$server_config[$k] = true;
foreach($server_config as $k=>$v) {
$server_config[$k] = $data['statconfig'][$k];
}
/* Gather all stats, then we'll decide what to send */
@ -299,26 +279,21 @@
}
$q=mysql_query("SELECT COUNT(users.id) AS num FROM users
JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.roles_id
WHERE roles.type = 'committee'
AND users.conferences_id = '{$conference['id']}'
AND users.deleted = 'no'");
$q=mysql_query("SELECT COUNT(id) AS num FROM users
LEFT JOIN users_committee ON users_committee.users_id=users.id
WHERE types LIKE '%committee%'
AND year='$year'
AND users_committee.committee_active='yes'
AND deleted='no'");
$r = mysql_fetch_object($q);
$stats['committee_members'] = $r->num;
$q=mysql_query("
SELECT COUNT(users.id) AS num FROM users
JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.roles_id
WHERE users.conferences_id = '{$conference['id']}'
AND users.deleted = 'no'
AND roles.type = 'judge'
AND user_roles.complete='yes'
AND user_roles.active='yes'");
$q=mysql_query("SELECT COUNT(id) AS num FROM users LEFT JOIN users_judge ON users_judge.users_id=users.id
WHERE users.year='$year'
AND users.types LIKE '%judge%'
AND users.deleted='no'
AND users_judge.judge_complete='yes'
AND users_judge.judge_active='yes'");
$r=mysql_fetch_object($q);
$stats['judges'] = $r->num;
@ -330,7 +305,7 @@
echo "<form method=\"POST\" action=\"$PHPSELF\">";
echo "<input type=\"hidden\" name=\"action\" value=\"sendstats\" />";
if($server_config['info']) {
if($server_config['fair_stats_info'] == 'yes') {
echo '<h3>'.i18n('%1 Fair information', array($year)).'</h3>';
echo '<table>';
echo '<tr><td>'.i18n('Fair Start Date').':</td>';
@ -341,7 +316,7 @@
echo '<td><textarea name="address" rows="4" cols="60">'.htmlspecialchars($stats['address']).'</textarea></td>';
echo '<tr><td>'.i18n('Fair Budget').':</td>';
echo "<td>$<input type=text name=\"budget\" value=\"{$stats['budget']}\"></td></tr>";
echo '<tr><td>'.i18n('Youth Science Canada Affiliation Complete').'?</td>';
echo '<tr><td>'.i18n('YSF Affiliation Complete').'?</td>';
echo '<td><select name="ysf_affiliation_complete">';
$sel = $stats['ysf_affiliation_complete'] == 'N' ? 'selected="selected"' : '';
echo " <option value=\"N\" $sel >No</option>";
@ -356,26 +331,26 @@
}
if($server_config['next_chair']) {
if($server_config['fair_stats_next_chair'] == 'yes') {
echo '<h3>'.i18n('%1 - %2 Chairperson (if known)', array($year, $year+1)).'</h3>';
echo '<table>';
echo '<tr><td>'.i18n('Name').': </td>';
echo "<td><input type=text name=\"next_chair_name\" value=\"{$stats['next_chair_name']}\"></td>";
echo "<td><input type=text name=\"chair_name\" value=\"{$stats['name']}\"></td>";
echo '<td>'.i18n('Email').': </td>';
echo "<td><input type=text name=\"next_chair_email\" value=\"{$stats['next_chair_email']}\"></td></tr>";
echo "<td><input type=text name=\"chair_email\" value=\"{$stats['email']}\"></td></tr>";
echo '<tr><td>'.i18n('Tel. Bus').': </td>';
echo "<td><input type=text name=\"next_chair_bphone\" value=\"{$stats['next_chair_bphone']}\"></td>";
echo "<td><input type=text name=\"chair_bphone\" value=\"{$stats['bphone']}\"></td>";
echo '<td>'.i18n('Tel. Home').': </td>';
echo "<td><input type=text name=\"next_chair_hphone\" value=\"{$stats['next_chair_hphone']}\"></td></tr>";
echo "<td><input type=text name=\"chair_hphone\" value=\"{$stats['hphone']}\"></td></tr>";
echo '<tr><td>'.i18n('Fax').': </td>';
echo "<td><input type=text name=\"next_chair_fax\" value=\"{$stats['next_chair_fax']}\"></td>";
echo "<td><input type=text name=\"chair_fax\" value=\"{$stats['fax']}\"></td>";
echo '</tr>';
echo '</table>';
echo '<br /><br />';
}
if($server_config['delegates']) {
if($server_config['fair_stats_delegates'] == 'yes') {
echo '<h3>'.i18n('%1 CWSF Delegates and Alternatives', array($year)).'</h3>';
echo '<table>';
echo '<tr><td>'.i18n('Delegate Name(s)').'</td><td>'.i18n('Email').'</td><td>'.i18n('Jacket Size').'<td></tr>';
@ -396,14 +371,14 @@
echo '<br /><br />';
}
if($server_config['scholarships']) {
if($server_config['fair_stats_scholarships'] == 'yes') {
echo '<h3>'.i18n('%1 Scholarships', array($year)).'</h3>';
echo 'How many university/college scholarships are available at your fair? (use a format like: <br /><b>6 - University of British Columbia - Entrance Scholarships</b><br />';
echo '<textarea name="scholarships" rows="4\" cols="80">'.htmlspecialchars($stats['scholarships']).'</textarea>';
echo '<br /><br />';
}
if($server_config['participation']) {
if($server_config['fair_stats_participation'] == 'yes') {
$rangemap = array(1=>'1-3', 4=>'4-6', 7=>'7-8', 9=>'9-10', 11=>'11-12');
echo '<h3>'.i18n('%1 Fair participation', array($year)).'</h3>';
echo '<br />';
@ -436,7 +411,7 @@
echo '<br />';
}
if($server_config['schools_ext']) {
if($server_config['fair_stats_schools_ext'] == 'yes') {
echo '<h3>'.i18n('%1 Extended School/Participant data', array($year)).'</h3>';
echo '<br />';
echo i18n('Public schools: <b>%1</b> (<b>%2</b> students).',array(
@ -454,18 +429,20 @@
echo '<br />';
echo '<br />';
}
if($server_config['minorities']) {
if($server_config['fair_stats_minorities'] != '') {
echo '<h3>'.i18n('%1 Data on minority groups', array($year)).'</h3>';
echo '<br />';
echo '<table>';
echo '<tr><td>'.i18n('Number of First Nations students');
echo ": </td><td><input type=\"text\" name=\"firstnations\" value=\"{$stats['firstnations']}\" size=\"5\" />";
echo '</td></tr>';
if(strstr('firstnations',$server_config['fair_stats_minorities']) != false) {
echo '<tr><td>'.i18n('Number of First Nations students');
echo ": </td><td><input type=\"text\" name=\"firstnations\" value=\"{$stats['firstnations']}\" size=\"5\" />";
echo '</td></tr>';
}
echo '</table>';
echo '<br />';
echo '<br />';
}
if($server_config['guests'] ) {
if($server_config['fair_stats_guests'] == 'yes' ) {
echo '<h3>'.i18n('%1 Guests visiting the fair', array($year)).'</h3>';
echo '<br />';
echo '<table>';
@ -480,7 +457,7 @@
echo '<br />';
}
if($server_config['sffbc_misc']) {
if($server_config['fair_stats_sffbc_misc'] == 'yes') {
echo '<h3>'.i18n('%1 Misc. SFFBC Questions', array($year)).'</h3>';
echo '<br />';
echo '<table>';
@ -503,15 +480,34 @@
echo "<input type=\"hidden\" name=\"$k\" value=\"{$stats[$k]}\" />";
}
$d = ($ok == true) ? '' : 'disabled="disabled"';
echo "<input type=\"submit\" value=\"".i18n('Send stats to')." {$fair['name']}\" $d />";
echo "<input type=\"submit\" value=\"".i18n('Send stats to')." {$fair['name']}\">";
echo '</form>';
echo "<br />";
echo "<br />";
debug_("Fair Info: ".print_r($fair, true));
debug_("Server Config: ".print_r($server_config, true));
debug_("Stats: ".print_r($stats, true));
/* Format XML output, and print it, last chance for the user to edit it */
/*
$xml = stats_to_xml($fair, $stats);
echo '<hr />';
echo "<h3>".i18n("The following data will be sent to")." {$fair['name']}</h3>";
echo "<form method=\"post\" action=\"$PHPSELF\">";
echo "<input type=\"hidden\" name=\"action\" value=\"sendstats\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$fairs_id\">";
echo "<textarea rows=\"15\" cols=\"80\" name=\"xml\">";
echo $xml;
echo "</textarea>";
echo "<br />";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Send stats to")." {$fair['name']}\">";
echo "</form>";
*/
echo "<hr /><pre>";
print_r($fair);
print_r($server_config);
print_r($stats);
echo "</pre>";
send_footer();
?>

View File

@ -1,109 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2009 David Grant <dave@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require_once('../common.inc.php');
require_once('../user.inc.php');
require_once('../fair.inc.php');
$fair_type = array('feeder' => 'Feeder Fair', 'sfiab' => 'SFIAB Upstream', 'ysc' => 'YSC/CWSF Upstream');
$stats = array('participation' => 'Particpation Numbers',
'schools_ext' => 'Extra school participation data, number of public/private school students',
'minorities' => 'Data on minority group participation',
'guests' => 'Number of student, public guests',
'sffbc_misc' => 'Number of teachers supporting science, number of students interested in careers in science',
'info' => 'Fair address, dates, budget, charity info',
'next_chair' => 'The chair of the regional fair next year',
'scholarships' => 'Information about scholarships available to be won',
'delegates' => 'Delegate information/jacket size for CWSF',
);
user_auth_required('admin');
switch($_GET['action']) {
case 'save':
print_r($_POST);
$id = intval($_POST['fairs_id']);
if(!is_array($_POST['stats'])) $_POST['stats'] = array();
foreach($_POST['stats'] as $k=>$s) {
if(!array_key_exists($s, $stats)) {
echo "Undefined stat $s, abort.\n";
exit;
}
}
$s = join(',', $_POST['stats']);
$q = mysql_query("UPDATE fairs SET gather_stats='$s' WHERE id='$id'");
echo mysql_error();
echo "UPDATE fairs SET gather_stats='$s' WHERE id='$id'";
happy_("Saved");
exit;
}
/* Load the user we're editting */
$u = user_load($_SESSION['embed_edit_id']);
/* Load the fair attached to the user */
$q = mysql_query("SELECT * FROM fairs WHERE id={$u['fairs_id']}");
$f = mysql_fetch_assoc($q);
?>
<h4><?=i18n('Fair Stats Gathering')?></h3>
<script type="text/javascript">
function stats_save()
{
$("#debug").load("fair_stats_select.php?action=save", $("#gather_stats").serializeArray());
return 0;
}
</script>
<?
if($f['type'] == 'feeder') {
echo '<p>'.i18n('Select which statistics to request from the feeder fair').'</p>';
} else {
echo '<p>'.i18n('Not supported for upstream fairs').'</p>';
exit;
}
?>
<form id="gather_stats">
<input type="hidden" name="fairs_id" value="<?=$f['id']?>" />
<table class="editor">
<?
$selected_stats = explode(',', $f['gather_stats']);
foreach($stats as $s=>$d) {
$ch = in_array($s, $selected_stats) ? 'checked="checked"' : '';
echo "<tr><td class=\"left\"><input type=\"checkbox\" id=\"stats_$s\" name=\"stats[]\" value=\"$s\" $ch /></td>";
echo "<td class=\"right\">".i18n($d)."</td></tr>";
}
?>
</table>
<br />
<input type="submit" onClick="stats_save();return false;" value="Save" />
</form>

View File

@ -3,7 +3,7 @@
require_once("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
$q = mysql_query("SELECT * FROM judges WHERE passwordexpiry IS NULL");
while($i = mysql_fetch_object($q)) {

View File

@ -3,7 +3,7 @@
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2009 James Grant <james@lightbox.org>
Copyright (C) 2008 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
@ -22,281 +22,117 @@
?>
<?
require("../common.inc.php");
require("../tableeditor.class.php");
require_once("../user.inc.php");
user_auth_required('admin');
if($_GET['action']=="refresh") {
?>
<h3><?=i18n("Fundraising Purposes and Progress Year to Date")?></h3>
<?
$q=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY deadline");
?>
<table class="tableview">
<thead>
<tr>
<th><?=i18n("Purpose")?></th>
<th><?=i18n("Goal")?></th>
<th><?=i18n("Amount Received")?></th>
<th><?=i18n("% to Budget")?></th>
<th><?=i18n("Deadline")?></th>
</tr>
</thead>
<?
while($r=mysql_fetch_object($q)) {
//lookup all donations made towards this goal
$recq=mysql_query("SELECT SUM(value) AS received FROM fundraising_donations WHERE fundraising_goal='$r->goal' AND fiscalyear='{$config['FISCALYEAR']}' AND status='received'");
echo mysql_error();
$recr=mysql_fetch_object($recq);
$received=$recr->received;
if($r->budget)
$percent=round($received/$r->budget*100,1);
else
$percent=0;
echo "<tr><td>$r->name</td>";
echo "<td style=\"text-align: right;\">".format_money($r->budget,false)."</td>";
echo "<td style=\"text-align: right;\">".format_money($received,false)."</td>";
$col=colour_to_percent($percent);
echo "<td style=\"text-align: center; background-color: $col;\">{$percent}%</td>";
echo "<td>".format_date($r->deadline)."</td></tr>\n";
}
?>
</table>
<br />
<h3><?=i18n("Current Appeals")?></h3>
<table class="tableview">
<thead>
<tr>
<th><?=i18n("Name")?></th>
<th><?=i18n("Type")?></th>
<th><?=i18n("Start Date")?></th>
<th><?=i18n("End Date")?></th>
<th><?=i18n("Target($)")?></th>
<th><?=i18n("Received")?></th>
<th><?=i18n("% to Budget")?></th>
<th><?=i18n("Purpose")?></th>
</tr>
</thead>
<?
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}'");
while($r=mysql_fetch_object($q)) {
$goalq=mysql_query("SELECT * FROM fundraising_goals WHERE goal='{$r->fundraising_goal}' AND fiscalyear='{$config['FISCALYEAR']}'");
$goalr=mysql_fetch_object($goalq);
$recq=mysql_query("SELECT SUM(value) AS received FROM fundraising_donations WHERE fundraising_campaigns_id='$r->id' AND fiscalyear='{$config['FISCALYEAR']}' AND status='received'");
echo mysql_error();
$recr=mysql_fetch_object($recq);
$received=$recr->received;
if($r->target)
$percent=round($received/$r->target*100,1);
else
$percent=0;
$col=colour_to_percent($percent);
echo "<tr style=\"cursor:pointer;\" onclick=\"window.location.href='fundraising_campaigns.php?manage_campaign=$r->id'\">\n";
echo " <td>$r->name</td>\n";
echo " <td>$r->type</td>\n";
echo " <td>".format_date($r->startdate)."</td>\n";
echo " <td>".format_date($r->enddate)."</td>";
echo " <td style=\"text-align: right;\">".format_money($r->target,false)."</td>\n";
echo " <td style=\"text-align: right;\">".format_money($received,false)."</td>\n";
echo " <td style=\"text-align: center; background-color: $col;\">{$percent}%</td>\n";
echo " <td>$goalr->name</td>";
echo "</tr>\n";
}
?>
</tr>
</table>
<script type="text/javascript"> $('.tableview').tablesorter();</script>
<br />
<form id="thankyouform" method="post" action="fundraising.php">
<h3><?=i18n("To Do List")?></h3>
<h4><?=i18n("Thank You's")?></h4>
<?
$q=mysql_query("SELECT id,value, thanked, status, sponsors_id, datereceived,
DATE_ADD(datereceived, INTERVAL 1 MONTH) < NOW() AS onemonth,
DATE_ADD(datereceived, INTERVAL 2 MONTH) < NOW() AS twomonth
FROM fundraising_donations
WHERE thanked='no' AND status='received'
AND fiscalyear='{$config['FISCALYEAR']}'
ORDER BY datereceived
");
echo mysql_error();
if(mysql_num_rows($q)) {
echo "<table class=\"tableview\">";
echo "<thead><tr><th>".i18n("Name")."</th>\n";
echo "<th>".i18n("Date Received")."</th>\n";
echo "<th>".i18n("Amount")."</th>\n";
echo "<th>".i18n("Generate Thank You")."</th>\n";
echo "<th>".i18n("Thanked")."</th>\n";
echo "</tr></thead>\n";
while($r=mysql_fetch_object($q)) {
$dq=mysql_query("SELECT organization AS name FROM sponsors WHERE id='$r->sponsors_id'");
$dr=mysql_fetch_object($dq);
if($r->twomonth) $s="style=\"background-color: ".colour_to_percent(0).";\"";
else if($r->onemonth) $s="style=\"background-color: ".colour_to_percent(50).";\"";
else $s="";
$u=getUserForSponsor($r->sponsors_id);
echo "<tr $s>";
echo " <td>$dr->name</td>";
echo " <td>".format_date($r->datereceived)."</td>";
echo " <td style=\"text-align: right;\">".format_money($r->value)."</td>";
echo " <td style=\"text-align: center;\">";
if($u) {
echo "<a href=\"#\" onclick=\"return opencommunicationsender('{$u['uid']}','fundraising_thankyou_template');\">".i18n("Generate Thank You")."</a></td>";
} else {
echo i18n("No contact");
}
echo "<td align=\"center\"><input style=\"padding: 0px; margin: 0px;\" type=\"checkbox\" name=\"thanked[]\" value=\"$r->id\" onclick=\"return thanked($r->id)\"></td>\n";
echo "</tr>\n";
}
echo "</table>\n";
}else {
echo i18n("No Thank You's pending");
echo "<br />\n";
}
?>
</form>
<br />
<h4><?=i18n("Receipts to Issue")?></h4>
<?
$q=mysql_query("SELECT value, receiptrequired, receiptsent, status, sponsors_id, datereceived,
DATE_ADD(datereceived, INTERVAL 1 MONTH) < NOW() AS onemonth,
DATE_ADD(datereceived, INTERVAL 2 MONTH) < NOW() AS twomonth
FROM fundraising_donations
WHERE (receiptrequired='yes' AND receiptsent='no') AND status='received'
AND fiscalyear='{$config['FISCALYEAR']}'
ORDER BY datereceived
");
echo mysql_error();
if(mysql_num_rows($q)) {
echo "<table class=\"tableview\">";
echo "<tr><th>".i18n("Name")."</th>\n";
echo "<th>".i18n("Date Received")."</th>\n";
echo "<th>".i18n("Amount")."</th>\n";
echo "<th>".i18n("Generate Receipt")."</th>\n";
echo "</tr>\n";
while($r=mysql_fetch_object($q)) {
$dq=mysql_query("SELECT organization AS name FROM sponsors WHERE id='$r->sponsors_id'");
$dr=mysql_fetch_object($dq);
if($r->twomonth) $s="style=\"background-color: ".colour_to_percent(0).";\"";
else if($r->onemonth) $s="style=\"background-color: ".colour_to_percent(50).";\"";
else $s="";
echo "<tr $s>";
echo " <td>$dr->name</td>";
echo " <td>".format_date($r->datereceived)."</td>";
echo " <td style=\"text-align: right;\">".format_money($r->value)."</td>";
echo " <td style=\"text-align: center;\">";
echo "<a href=\"#\" onclick=\"return false;\">".i18n("Generate Receipt")."</a></td>";
echo "</tr>\n";
}
echo "</table>\n";
}else {
echo i18n("No Receipts pending");
echo "<br />\n";
}
?>
<br />
<h4><?=i18n("Appeal Follow-Ups")?></h4>
<?
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE followupdate>=NOW() ORDER BY followupdate LIMIT 5");
echo mysql_error();
if(mysql_num_rows($q)) {
echo "<table class=\"tableview\">";
echo "<thead><tr>";
echo " <th>".i18n("Appeal")."</th>\n";
echo " <th>".i18n("Start Date")."</th>\n";
echo " <th>".i18n("Follow-Up Date")."</th>\n";
echo "</tr></thead>\n";
while($r=mysql_fetch_object($q)) {
echo "<tr><td>$r->name</td><td>".format_date($r->startdate)."</td><td>".format_date($r->followupdate)."</td></tr>\n";
}
echo "</table>\n";
} else {
echo i18n("No appeal follow-ups");
echo "<br />\n";
}
?>
<br />
<h4>Upcoming Proposals</h4>
<?
$q=mysql_query("SELECT * FROM sponsors WHERE fundingselectiondate>=NOW() OR proposalsubmissiondate>=NOW() ORDER BY fundingselectiondate LIMIT 5");
echo mysql_error();
if(mysql_num_rows($q)) {
echo "<table class=\"tableview\">";
echo "<tr>";
echo " <th>".i18n("Name")."</th>\n";
echo " <th>".i18n("Proposal Submission Date")."</th>\n";
echo " <th>".i18n("Funding Selection Date")."</th>\n";
echo "</tr>\n";
while($r=mysql_fetch_object($q)) {
echo "<tr><td>$r->organization</td>";
echo "<td>".format_date($r->proposalsubmissiondate)."</td>";
echo "<td>".format_date($r->fundingselectiondate)."</td>";
echo "</tr>\n";
}
echo "</table>\n";
} else {
echo i18n("No proposals upcoming");
}
exit;
}
else if (count($_POST['thanked'])) {
foreach($_POST['thanked'] AS $t) {
mysql_query("UPDATE fundraising_donations SET thanked='yes' WHERE id='$t'");
}
}
user_auth_required('committee', 'admin');
send_header("Fundraising",
include ("fundraising_sponsorship_handler.inc.php");
include ("fundraising_types_handler.inc.php");
send_header("Fundraising",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Fundraising' => 'admin/fundraising.php'),
'Administration' => 'admin/index.php'),
"fundraising"
);
?>
<script type="text/javascript">
$(document).ready(function() {
refreshDashboard();
});
function refreshDashboard() {
$("#dashboard").load("fundraising.php?action=refresh");
}
require_once("../dialog.inc.php");
function thanked() {
$.post("fundraising.php",$("#thankyouform").serializeArray(),function() {
refreshDashboard();
});
}
//first, insert any defaults
$q=mysql_query("SELECT * FROM fundraising WHERE year='".$config['FAIRYEAR']."'");
if(!mysql_num_rows($q)) {
$q=mysql_query("SELECT * FROM fundraising WHERE year='-1'");
while($r=mysql_fetch_object($q)) {
mysql_query("INSERT INTO fundraising (`type`,`name`,`description`,`system`,`goal`,`year`) VALUES ('$r->type','".mysql_real_escape_string($r->name)."','".mysql_real_escape_string($r->description)."','$r->system','$r->goal','".$config['FAIRYEAR']."')");
}
}
//key is initial or followup
//start is either 'new' to start with a blank, or 'existing' to load an existing email to start from
function opencommunicationsender(uid,template) {
$("#debug").load("communication.php?action=dialog_sender&uid="+uid+"&template=fundraising_thankyou_template",null,function() {
});
return false;
}
//this table is eventually going to be massive, and probably not in a tableview format, it'll show goals as well as all ongoing fund pledges, probabilities, etc as well as over/under, etc, all prettily colour coded.. basically a good overview of the total fundraising status of the fair.
$q=mysql_query("SELECT * FROM fundraising WHERE year='{$config['FAIRYEAR']}' ORDER BY system DESC,type");
echo "<table class=\"fundraisingtable\">";
</script>
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo "<th><a title=\"".i18n("Edit fund details")."\" onclick=\"return SFIABDialog(event,'fundraising_types.php?id=$r->id',400,250)\" href=\"#\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
if($r->system=="no") {
echo "<a title=\"".i18n("Remove Fund")."\" onclick=\"return confirmClick('Are you sure you want to remove this fund and all sponsorships inside it?')\" href=\"fundraising.php?action=funddelete&delete=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
}
<div id="dashboard"></div>
echo "</th>\n";
echo "<th colspan=\"5\">".i18n($r->name)."</th>\n";
echo "<th style=\"text-align: right\">".format_money($r->goal)."</th>\n";
echo "</tr>\n";
if($r->type=="general")
$orsql.="OR fundraising_type IS NULL";
$typetotal=0;
$sq=mysql_query("SELECT sponsorships.id, sponsors.organization, sponsorships.value, sponsorships.status, sponsorships.probability
FROM sponsorships
JOIN sponsors ON sponsorships.sponsors_id=sponsors.id
WHERE (sponsorships.fundraising_type='$r->type' $orsql)
AND sponsorships.year='{$config['FAIRYEAR']}'
ORDER BY status DESC, probability DESC, organization");
while($sr=mysql_fetch_object($sq)) {
echo "<tr id=\"sponsorships_$sr->id\" class=\"fundraising{$sr->status}\">";
echo "<td><a title=\"".i18n("Edit sponsorship details")."\" onclick=\"return SFIABDialog(event,'fundraising_sponsorship.php?id=$sr->id&fundraising_type=$r->type',400,250)\" href=\"#\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
echo "<a title=\"".i18n("Remove sponsorship")."\" onclick=\"return confirmClick('Are you sure you want to remove this sponsorship?')\" href=\"fundraising.php?action=sponsorshipdelete&delete=$sr->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "</td>";
echo "<td>$sr->organization</td>\n";
/*
echo "<a href=\"communication.php?action=edit&edit=$r->id\"><img border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\"></a>";
//only user emails can be deleted, system ones are required and cannot be removed
if($r->type=="user")
{
echo "&nbsp;";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove email?')\" href=\"communication.php?action=delete&delete=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "&nbsp;";
echo "<a href=\"communication.php?action=send&send=$r->id\">Send</a>";
}
*/
echo "<td>$sr->status</td>";
echo "<td>";
if($sr->status=="pending")
{
echo "$sr->probability%";
echo "</td>";
echo "<td>".format_money($sr->value)."</td>";
}
else
echo "</td><td></td>\n";
$probval=$sr->probability/100*$sr->value;
echo "<td style=\"text-align: right\">".format_money($probval)."</td>";
echo "<td></td>\n";
echo "</tr>\n";
$typetotal+=$probval;
}
echo "<tr>";
echo "<td><a onclick=\"return SFIABDialog(event,'fundraising_sponsorship.php?fundraising_type=$r->type',400,250)\" href=\"#\">add</a></td>";
echo "<td colspan=\"4\" style=\"text-align: right; font-weight: bold;\">".i18n("%1 Total",array($r->name),array("Fundraising type total, eg) Award Sponsorship Total"))."</td>\n";
echo "<td style=\"font-weight: bold; text-align: right;\">".format_money($typetotal)."</td>\n";
$typediff=$typetotal-$r->goal;
echo "<td style=\"font-weight: bold; text-align: right;\">".format_money($typediff)."</td>\n";
echo "</tr>\n";
$totalgoal+=$r->goal;
$totaldiff+=$typediff;
echo "<tr><td colspan=\"7\">&nbsp;</td></tr>\n";
}
echo "<tr>";
echo "<td colspan=\"2\"><a onclick=\"return SFIABDialog(event,'fundraising_types.php',400,250)\" href=\"#\">add fund type</a></td>";
echo "<td colspan=\"4\" style=\"font-weight: bold; text-align: right;\">".i18n("Total Net Position")."</td><td style=\"text-align: right; font-weight: bold;\">".format_money($totaldiff)."</td></tr>\n";
echo "</table>\n";
echo "<br />\n";
echo "<br />\n";
echo "<a href=\"sponsorship_levels.php\">Manage Sponsorship Levels</a>\n";
echo "<br />\n";
echo "<a href=\"sponsors.php\">Manage Sponsors</a>\n";
echo "<br />\n";
<?
send_footer();
?>

View File

@ -1,836 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2009 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
require("fundraising_common.inc.php");
switch($_GET['action']){
case "campaigninfo_save":
save_campaign_info();
exit;
break;
case "modify":
echo "<div id=\"campaignaccordion\" style=\"width: 780px;\">\n";
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY name");
while($r=mysql_fetch_object($q)) {
echo "<h3 id=\"campaigntitle_{$r->id}\"><a href=\"#\">".htmlspecialchars($r->name)."</a></h3>\n";
echo "<div id=\"campaign_{$r->id}\">\n";
echo "<table>\n";
echo "<form id=\"campaigninfo_{$r->id}\" method=\"post\" action=\"{$_SERVER['PHP_SELF']}\" onsubmit=\"return campaigninfo_save($r->id)\">\n";
echo "<input type=\"hidden\" name=\"campaign_id\" value=\"{$r->id}\" />\n";
display_campaign_form($r);
?>
<tr><td colspan="6" style="text-align: center;">
<br />
<input type="submit" value="<?=i18n("Save Appeal")?>"></td>
</tr>
</form>
<tr><td colspan="6" style="text-align: center;">
<br />
<?php
echo "<form id=\"campaignremove_{$r->id}\" method=\"post\" action=\"{$_SERVER['PHP_SELF']}\" onsubmit=\"return campaigninfo_remove($r->id)\">\n";
echo "<input type=\"hidden\" name=\"campaign_id\" value=\"{$r->id}\" />\n";
?>
<br />
<input type="submit" value="<?=i18n("Delete Appeal")?>"></td>
</form>
</td></tr>
</table>
</div>
<?
}
?>
<h3><a href="#"><?=i18n("Create New Appeal")?></a></h3>
<div id="campaign_new">
<form id="campaigninfo_new" method="post" action="<?=$_SERVER['PHP_SELF']?>" onsubmit="return campaigninfo_save(-1)">
<input type="hidden" name="campaign_id" value="-1" />
<table>
<?
display_campaign_form();
?>
<tr><td colspan="6" style="text-align: center;">
<br />
<input type="submit" value="<?=i18n("Create Appeal")?>"></td>
</tr>
</table>
</form>
</div>
</div>
<?
exit;
break;
case "managelist":
echo i18n("Select an appeal");
?>
<table class="tableview">
<thead>
<tr>
<th><?=i18n("Name")?></th>
<th><?=i18n("Type")?></th>
<th><?=i18n("Start Date")?></th>
<th><?=i18n("End Date")?></th>
<th><?=i18n("Target($)")?></th>
<th><?=i18n("Received")?></th>
<th><?=i18n("% to Budget")?></th>
<th><?=i18n("Purpose")?></th>
</tr>
</thead>
<?
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}'");
while($r=mysql_fetch_object($q)) {
$goalq=mysql_query("SELECT * FROM fundraising_goals WHERE goal='{$r->fundraising_goal}' AND fiscalyear='{$config['FISCALYEAR']}'");
$goalr=mysql_fetch_object($goalq);
$recq=mysql_query("SELECT SUM(value) AS received FROM fundraising_donations WHERE fundraising_campaigns_id='$r->id' AND fiscalyear='{$config['FISCALYEAR']}' AND status='received'");
echo mysql_error();
$recr=mysql_fetch_object($recq);
$received=$recr->received;
if($r->target)
$percent=round($received/$r->target*100,1);
else
$percent=0;
$col=colour_to_percent($percent);
echo "<tr style=\"cursor:pointer;\" onclick=\"return managecampaign($r->id)\">\n";
echo " <td>$r->name</td>\n";
echo " <td>$r->type</td>\n";
echo " <td>".format_date($r->startdate)."</td>\n";
echo " <td>".format_date($r->enddate)."</td>";
echo " <td style=\"text-align: right;\">".format_money($r->target,false)."</td>\n";
echo " <td style=\"text-align: right;\">".format_money($received,false)."</td>\n";
echo " <td style=\"text-align: center; background-color: $col;\">{$percent}%</td>\n";
echo " <td>$goalr->name</td>";
echo "</tr>\n";
}
?>
</table>
<script type="text/javascript"> $('.tableview').tablesorter();</script>
<br />
<?
exit;
break;
case "manage":
if(!$_GET['id']) {
error_("Missing campaign to manage");
exit;
}
$id=intval($_GET['id']);
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE id='$id'");
$campaign=mysql_fetch_object($q);
echo "<h3>$campaign->name</h3>\n";
?>
<div id="campaign_tabs">
<ul>
<li><a href="#campaign_tab_overview"><span><?=i18n('Overview')?></span></a></li>
<li><a href="#campaign_tab_donations"><span><?=i18n('Donations/Sponsorships')?></span></a></li>
<li><a href="#campaign_tab_prospects"><span><?=i18n('Prospects')?></span></a></li>
<li><a href="#campaign_tab_communications"><span><?=i18n('Communications')?></span></a></li>
</ul>
<div id="campaign_tab_overview">
overview tab
</div>
<div id="campaign_tab_donations">
donations tab
</div>
<div id="campaign_tab_prospects">
prospects tab
</div>
<div id="campaign_tab_communications">
communications tab
</div>
</div>
<?
exit;
break;
case "manage_tab_overview":
$campaign_id=intval($_GET['id']);
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE id='$campaign_id' AND fiscalyear='{$config['FISCALYEAR']}'");
if($r=mysql_fetch_object($q)) {
$goalr=getGoal($r->fundraising_goal);
$recq=mysql_query("SELECT SUM(value) AS received FROM fundraising_donations WHERE fundraising_campaigns_id='$r->id' AND fiscalyear='{$config['FISCALYEAR']}' AND status='received'");
echo mysql_error();
$recr=mysql_fetch_object($recq);
$received=$recr->received;
if($r->target)
$percent=round($received/$r->target*100,1);
else
$percent=0;
$col=colour_to_percent($percent);
echo "<table cellspacing=\"3\" cellpadding=\"3\">";
echo "<tr>\n";
echo " <td>".i18n("Type")."</td><td>$r->type</td></tr>\n";
echo " <td>".i18n("Start Date")."</td><td>".format_date($r->startdate)."</td>\n";
echo "</tr>\n";
echo " <td>".i18n("Follow-Up Date")."</td><td>".format_date($r->followupdate)."</td>";
echo "</tr>\n";
echo " <td>".i18n("End Date")."</td><td>".format_date($r->enddate)."</td>";
echo "</tr>\n";
echo " <td>".i18n("Default Purpose")."</td><td>$goalr->name</td>";
echo "</tr>\n";
echo " <td>".i18n("Target")."</td><td>".format_money($r->target,false)."</td>\n";
echo "</tr>\n";
echo " <td>".i18n("Received")."</td><td>".format_money($received,false)."</td>\n";
echo "</tr>\n";
echo " <td>".i18n("% to Budget")."</td><td style=\"color: $col;\">{$percent}%</td>\n";
echo "</tr>\n";
echo "</table>\n";
}
exit;
break;
case "manage_tab_donations":
$campaign_id=intval($_GET['id']);
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE id='$campaign_id' AND fiscalyear='{$config['FISCALYEAR']}'");
if($campaign=mysql_fetch_object($q)) {
echo "<table class=\"tableview\">";
echo "<thead>";
echo "<tr>";
echo " <th>".i18n("Date")."</th>\n";
echo " <th>".i18n("Donor/Sponsor")."</th>\n";
echo " <th>".i18n("Purpose")."</th>\n";
echo " <th>".i18n("Amount")."</th>\n";
echo " <th>".i18n("Type of Support")."</th>\n";
echo "</tr>";
echo "</thead>\n";
$q=mysql_query("SELECT * FROM fundraising_donations WHERE fundraising_campaigns_id='$campaign_id'
AND status='received' ORDER BY datereceived DESC");
while($r=mysql_fetch_object($q)) {
$goal=getGoal($r->fundraising_goal);
$sq=mysql_query("SELECT * FROM sponsors WHERE id='{$r->sponsors_id}'");
$sponsor=mysql_fetch_object($sq);
echo "<tr><td>".format_date($r->datereceived)."</td>\n";
echo " <td>".$sponsor->organization."</td>\n";
echo " <td>".$goal->name."</td>\n";
echo " <td>".format_money($r->value)."</td>\n";
echo " <td>".i18n($r->supporttype)."</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
}
exit;
break;
case "manage_tab_prospects":
$donationhistorylist=array("never"=>"Never donated/sponsored", "past"=>"Donated/sponsored in the past", "lastyear"=>"Donated/sponsored last year", "thisyear"=>"Donated/sponsored this year");
$emailaddresslist=array("available"=>"Available", "notavaialble"=>"Not Available");
$rolelist=array(
"judge"=>"Judge",
"teacher"=>"Teacher",
"sciencehead"=>"School Science Head",
"principal"=>"School Principal",
"parent"=>"Parent",
"committee"=>"Committee",
"volunteer"=>"Volunteer",
"alumni"=>"Alumni (not implemented)",
"mentor"=>"Mentor (not implemented)",
);
$campaign_id=intval($_GET['id']);
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE id='$campaign_id' AND fiscalyear='{$config['FISCALYEAR']}'");
$campaign=mysql_fetch_object($q);
if($campaign->filterparameters) {
echo "<h4>".i18n("User List")."</h4>\n";
$params=unserialize($campaign->filterparameters);
echo "<table class=\"tableedit\">";
echo "<tr><td>".i18n("Donor Type")."</td><td>".i18n(ucfirst($params['donortype']))."</td></tr>\n";
if(is_array($params['donationhistory'])) {
echo "<tr><td>".i18n("Donation History")."</td><td>";
foreach($params['donationhistory'] AS $d) {
echo i18n($donationhistorylist[$d])."<br />\n";
}
echo "</td></tr>\n";
}
// echo "<tr><td>".i18n("Donation Level")."</td><td>";
// echo "</td></tr>\n";
if(is_array($params['emailaddress'])) {
echo "<tr><td>".i18n("Email Address")."</td><td>";
foreach($params['emailaddress'] AS $e) {
echo i18n($emailaddresslist[$e])."<br />\n";
}
echo "</td></tr>\n";
}
if($params['donortype']=="individual" && is_array($params['individual_type'])) {
echo "<tr><td>".i18n("Role")."</td><td>";
foreach($params['individual_type'] AS $e) {
echo i18n($rolelist[$e])."<br />\n";
}
echo "</td></tr>\n";
} else if( is_array($params['contacttype'])) {
echo "<tr><td>".i18n("Role")."</td><td>";
foreach($params['contacttype'] AS $e) {
echo i18n(ucfirst($e))."<br />";
}
echo "</td></tr>\n";
}
echo "</table>\n";
//params: individual/org
// donation history
// donation level
// email address
// role ind
// role org
echo "<br />";
echo "<form id=\"prospectremoveform\" onsubmit=\"return removeselectedprospects()\">\n";
echo "<input type=\"hidden\" name=\"fundraising_campaigns_id\" value=\"$campaign_id\" />\n";
$q=mysql_query("SELECT * FROM fundraising_campaigns_users_link WHERE fundraising_campaigns_id='$campaign_id'");
while($r=mysql_fetch_object($q)) {
$u=user_load_by_uid($r->users_uid);
//hopefully this never returns false, but who knows..
if($u) {
echo "<label>";
echo "<input type=\"checkbox\" name=\"prospectremovefromlist[]\" value=\"{$u['uid']}\" />";
if($u['sponsor']['donortype']=="organization") {
echo $u['sponsor']['organization']." - ";
}
echo $u['firstname']." " .$u['lastname'];
if($u['email']) echo " &lt;{$u['email']}&gt;";
echo "</label>\n";
echo "<br />";
}
}
echo "<br />";
echo "<br />";
echo "<table><tr><td>";
echo "<input onclick=\"return prospect_removeselected()\" type=\"button\" value=\"".i18n("Remove selected prospects from list")."\">\n";
echo "</td><td>";
echo "<input onclick=\"return prospect_removeall()\" type=\"button\" value=\"".i18n("Remove all prospects from list")."\">\n";
// echo "</td><td>";
// echo "<input type=\"button\" value=\"".i18n("Finalize prospect list")."\">\n";
echo "</td></tr></table>\n";
}
else {
?>
<h4><?=i18n("Choose Prospects")?></h4>
<form id="prospectform" onsubmit="return prospect_generatelist()">
<input type="hidden" name="fundraising_campaigns_id" value="<?=$campaign_id?>" />
<table>
<tr><td style="width: 130px;"><?=i18n("Type")?>:</td><td>
<label><input type="radio" name="donortype" value="organization" onchange="donortypechange()" ><?=i18n("Organization")?></label><br />
<label><input type="radio" name="donortype" value="individual" onchange="donortypechange()" ><?=i18n("Individual")?></label><br />
</td></tr>
</table>
<div id="prospect_common" style="display: none;">
<hr />
<table>
<tr><td style="width: 130px;"><?=i18n("Donation History")?>:</td><td>
<?
foreach($donationhistorylist AS $k=>$v) {
echo "<label><input onchange=\"return prospect_search()\" type=\"checkbox\" name=\"donationhistory[]\" value=\"$k\">".i18n($v)."</label><br />\n";
}
?>
</td></tr>
<tr><td><?=i18n("Donation Level")?>:</td><td>
<?
$q=mysql_query("SELECT * FROM fundraising_donor_levels WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY min");
while($r=mysql_fetch_object($q)) {
echo "<label><input onchange=\"return prospect_search()\" disabled=\"disabled\" type=\"checkbox\" name=\"donationlevel[]\" value=\"$r->level\" >".i18n($r->level)." (".format_money($r->min,false)." - ".format_money($r->max,false).")</label><br />\n";
}
echo "(disabled until the logic requirements can be established)";
?>
</td></tr>
<tr><td><?=i18n("Email Address")?>:</td><td>
<?
foreach($emailaddresslist AS $k=>$v) {
echo "<label><input onchange=\"return prospect_search()\" type=\"checkbox\" name=\"emailaddress[]\" value=\"$k\">".i18n($v)."</label><br />\n";
}
?>
</td></tr>
</table>
</div>
<div id="prospect_individual" style="display: none;">
<table>
<tr><td style="width: 130px;"><?=i18n("Role")?>:</td><td>
<?
foreach($rolelist AS $k=>$v) {
echo "<label><input onchange=\"return prospect_search()\" type=\"checkbox\" name=\"individual_type[]\" value=\"$k\">".i18n($v)."</label><br />\n";
}
?>
</td></tr></table>
</div>
<div id="prospect_organization" style="display: none;">
<table>
<tr><td style="width: 130px;"><?=i18n("Role")?>:</td><td>
<label><input onchange="return prospect_search()" type="checkbox" name="contacttype[]" value="primary"><?=i18n("Primary contacts")?></label><br />
<label><input onchange="return prospect_search()" type="checkbox" name="contacttype[]" value="secondary"><?=i18n("Secondary contacts")?></label><br />
</td></tr></table>
</div>
<hr />
<div id="prospectsearchresults"></div>
</form>
<?
}
exit;
break;
case "manage_tab_communications":
$campaign_id=intval($_GET['id']);
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE id='$campaign_id' AND fiscalyear='{$config['FISCALYEAR']}'");
if($r=mysql_fetch_object($q)) {
}
$communications=array("initial"=>"Initial Communication",
"followup"=>"Follow-Up Communication");
foreach($communications as $key=>$name) {
echo "<h4>".i18n($name)."</h4>\n";
//check if they have one in the emails database
$q=mysql_query("SELECT * FROM emails WHERE fundraising_campaigns_id='$campaign_id' AND val='$key'");
if($email=mysql_fetch_object($q)) {
echo "<div style=\"float: right; margin-right: 15px;\">";
echo "<a title=\"Edit\" href=\"#\" onclick=\"return opencommunicationeditor(null,$email->id,$campaign_id)\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/edit.".$config['icon_extension']."\" border=0></a>";
echo "&nbsp;&nbsp;";
echo "<a title=\"Remove\" onClick=\"return removecommunication($email->id);\" href=\"\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=0></a>";
echo "</div>";
echo "<table cellspacing=0 cellpadding=3 border=1 style=\"margin-left: 30px; margin-right: 30px; width: 700px;\">";
echo "<tr><td>".i18n("Subject")."</td><td>".htmlspecialchars($email->subject)."</td></tr>\n";
echo "<tr><td>".i18n("From")."</td><td>".htmlspecialchars($email->from)."</td></tr>\n";
echo "<tr><td colspan=\"2\">".$email->bodyhtml."</td></tr>\n";
echo "<tr><td colspan=\"2\">";
echo "<table style=\"width: 100%;\"><tr>";
echo "<td style=\"text-align: center;\">";
//we let them always send it again for now... might change this back later, but i think just notifying them of when it was last sent is enough and keeps teh form more consistent
echo "<input type=\"button\" onclick=\"return opensendemaildialog($campaign_id,$email->id)\" value=\"".i18n("Send as email")."\" />";
echo "<br />\n";
if($email->lastsent) {
list($date,$time)=explode(" ",$email->lastsent);
echo i18n("Last Sent");
echo "<br />".format_date($date);
echo "<br />".format_time($time);
}
echo "</td>\n";
echo "<td style=\"text-align: center;\"><input type=\"button\" onclick=\"return opensendmaildialog($campaign_id,'$key')\" value=\"".i18n("Generate PDF for mailing")."\" /></td>\n";
echo "<td style=\"text-align: center;\"><input type=\"button\" onclick=\"return opensendlabelsdialog(47,$campaign_id)\" value=\"".i18n("Generate mailing labels")."\" /></td>\n";
echo "</tr></table>\n";
echo "</td></tr>\n";
echo "</table>\n";
}
else {
echo "<ul>\n";
echo " <li><a href=\"#\" onclick=\"return opencommunicationchooser('$key');\">".i18n("Start from an existing communication")."</a></li>\n";
echo " <li><a href=\"#\" onclick=\"return opencommunicationeditor('$key',null,$campaign_id);\">".i18n("Create a new communication")."</a></li>\n";
echo "</ul>\n";
}
echo "<br />";
}
exit;
break;
case "prospect_removeselected":
$campaignid=intval($_POST['fundraising_campaigns_id']);
print_r($_POST);
if(is_array($_POST['prospectremovefromlist'])) {
$uidlist=implode(",",$_POST['prospectremovefromlist']);
$query="DELETE FROM fundraising_campaigns_users_link WHERE fundraising_campaigns_id='$campaignid' AND users_uid IN ($uidlist)";
mysql_query($query);
echo mysql_error();
}
//if theres nobody left in the list we need to reset the filter params as well
$q=mysql_query("SELECT COUNT(*) AS num FROM fundraising_campaigns_users_link WHERE fundraising_campaigns_id='$campaignid'");
$r=mysql_fetch_object($q);
if($r->num==0) {
mysql_query("UPDATE fundraising_campaigns SET filterparameters=NULL WHERE id='$campaignid'");
}
happy_("Selected users removed from list");
exit;
break;
case "prospect_removeall":
$campaignid=intval($_POST['fundraising_campaigns_id']);
mysql_query("DELETE FROM fundraising_campaigns_users_link WHERE fundraising_campaigns_id='$campaignid'");
mysql_query("UPDATE fundraising_campaigns SET filterparameters=NULL WHERE id='$campaignid'");
happy_("All users removed from list");
exit;
break;
case "communication_remove":
$emails_id=$_POST['id'];
//check if its been sent, if so, it cannot be deleted, sorry!
$q=mysql_query("SELECT * FROM emails WHERE id='$emails_id'");
$e=mysql_fetch_object($q);
if($e->lastsent) {
error_("Cannot remove an email that has already been sent");
}
else {
mysql_query("DELETE FROM emails WHERE id='$emails_id'");
happy_("Communicaton removed");
}
exit;
break;
case "campaign_remove":
$campaign_id = $_POST['campaign_id'];
if(is_numeric($campaign_id)) {
mysql_query("DELETE FROM fundraising_campaigns WHERE
(SELECT COUNT(*) FROM fundraising_donations WHERE fundraising_campaigns_id = $campaign_id) = 0 AND
(SELECT count(*) FROM emails WHERE fundraising_campaigns_id = $campaign_id) = 0 AND
id = $campaign_id");
if(mysql_affected_rows() == 0) {
error_("Cannot delete campaign. It is in use.");
} else {
mysql_query("DELETE FROM fundraising_campaigns_users_link WHERE fundraising_campaigns_id = $campaign_id");
mysql_query("DELETE FROM fundraising_donations WHERE fundraising_campaigns_id = $campaign_id");
mysql_query("DELETE FROM fundraising_donor_logs WHERE fundraising_campaigns_id = $campaign_id");
mysql_query("DELETE FROM emailqueue WHERE fundraising_campaigns_id = $campaign_id");
mysql_query("DELETE FROM emails WHERE fundraising_campaigns_id = $campaign_id");
happy_("Campaign removed");
echo "<script type=\"text/javascript\">";
echo " $('#campaigntitle_$campaign_id').remove();";
echo " $('#campaign_$campaign_id').remove();";
echo "</script>";
}
} else {
error_("Invalid Campaign ID");
}
exit;
break;
}
function save_campaign_info(){
global $config;
if(!$_POST['name']){
error_("Appeal Name is required");
return;
}
if(!$_POST['startdate']) $startdate=date("Y-m-d"); else $startdate=$_POST['startdate'];
if(!$_GET['id']) {
$query = "INSERT INTO fundraising_campaigns (name,fiscalyear) VALUES (
'".mysql_real_escape_string(stripslashes($_POST['name']))."','{$config['FISCALYEAR']}')";
mysql_query($query);
$id = mysql_insert_id();
happy_("Appeal Created");
}else{
$id = $_GET["id"];
happy_("Appeal Saved");
}
mysql_query("UPDATE fundraising_campaigns SET
name='".mysql_real_escape_string(stripslashes($_POST['name']))."',
`type`='".mysql_real_escape_string($_POST['type'])."',
startdate='".mysql_real_escape_string($startdate)."',
followupdate='".mysql_real_escape_string($_POST['followupdate'])."',
enddate='".mysql_real_escape_string($_POST['enddate'])."',
target='".mysql_real_escape_string($_POST['target'])."',
fundraising_goal='".mysql_real_escape_string($_POST['fundraising_goal'])."'
WHERE id='$id'");
}
send_header("Appeal Management",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Fundraising' => 'admin/fundraising.php'),
"fundraising"
);
?>
<script type="text/javascript">
$(document).ready(function() {
<?
if($_GET['manage_campaign']) {
echo "managecampaign(".intval($_GET['manage_campaign']).");\n";
}
else {
echo "managecampaigns();\n";
}
?>
});
function modifycampaigns() {
$("#campaigndiv").show();
$("#campaigndiv").load("<?$_SERVER['PHP_SELF']?>?action=modify", null, function() {modifycampaignsfinish();});
}
function managecampaigns() {
$("#campaigndiv").show();
$("#campaigndiv").load("<?$_SERVER['PHP_SELF']?>?action=managelist", null, function() {managecampaignsfinish();});
}
var currentcampaignid;
function managecampaign(id) {
$("#campaigndiv").show();
$("#campaigndiv").load("<?$_SERVER['PHP_SELF']?>?action=manage&id="+id, null, function() {managecampaignfinish();});
currentcampaignid=id;
}
function modifycampaignsfinish(){
$("#campaignaccordion").accordion();
// create the date pickers for our form
$(".date").datepicker({
dateFormat: 'yy-mm-dd'
});
}
function managecampaignsfinish() {
}
function managecampaignfinish() {
$("#campaign_tabs").tabs({
show: function(event, ui) {
switch(ui.panel.id) {
case 'campaign_tab_overview':
update_tab_overview();
break;
case 'campaign_tab_donations':
update_tab_donations();
break;
case 'campaign_tab_prospects':
update_tab_prospects();
break;
case 'campaign_tab_communications':
update_tab_communications();
break;
}
},
selected: 0
});
}
function campaigninfo_save(id) {
//if we're creating we need to do the post, and get the id it returns, so we can re-open the popup window with that id
if(id==-1) {
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=campaigninfo_save", $("#campaigninfo_new").serializeArray(), function() { modifycampaigns(); });
} else {
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=campaigninfo_save&id="+id, $("#campaigninfo_"+id).serializeArray(), function() { modifycampaigns(); });
}
return false;
}
function campaigninfo_remove(id) {
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=campaign_remove", $("#campaignremove_"+id).serializeArray());
return false;
}
function update_tab_overview() {
$("#campaign_tab_overview").load("<?$_SERVER['PHP_SELF']?>?action=manage_tab_overview&id="+currentcampaignid);
}
function update_tab_donations() {
$("#campaign_tab_donations").load(
"<?$_SERVER['PHP_SELF']?>?action=manage_tab_donations&id="+currentcampaignid,
null,
function(){$('.tableview').tablesorter();}
);
}
function update_tab_prospects() {
$("#campaign_tab_prospects").load("<?$_SERVER['PHP_SELF']?>?action=manage_tab_prospects&id="+currentcampaignid);
}
function update_tab_communications() {
$("#campaign_tab_communications").load("<?$_SERVER['PHP_SELF']?>?action=manage_tab_communications&id="+currentcampaignid);
}
function donortypechange() {
if($("input[@name='donortype']:checked").val()=="organization") {
$("#prospect_common").show('slow');
$("#prospect_organization").show('slow');
$("#prospect_individual").hide('slow');
}
else if($("input[@name='donortype']:checked").val()=="individual") {
$("#prospect_common").show('slow');
$("#prospect_organization").hide('slow');
$("#prospect_individual").show('slow');
}
else {
$("#prospect_common").hide('slow');
}
prospect_search();
}
function prospect_search() {
$("#prospectsearchresults").load("fundraising_campaigns_prospecting.php",$("#prospectform").serializeArray());
return false;
}
function prospect_generatelist() {
$("#prospectsearchresults").load("fundraising_campaigns_prospecting.php?generatelist=true",$("#prospectform").serializeArray(), function() {
update_tab_prospects();
});
return false;
}
function prospect_removeselected() {
$("#debug").load("fundraising_campaigns.php?action=prospect_removeselected",$("#prospectremoveform").serializeArray(),function() {
update_tab_prospects();
});
return false;
}
function prospect_removeall() {
$("#debug").load("fundraising_campaigns.php?action=prospect_removeall",$("#prospectremoveform").serializeArray(),function() {
update_tab_prospects();
});
return false;
}
var comm_chooser_key = null;
function opencommunicationchooser(key) {
comm_chooser_key = key;
$("#dialog").empty();
$("#dialog").load("communication.php?action=dialog_choose&type=fundraising",null,function() {
});
}
function removecommunication(id) {
$("#debug").load("fundraising_campaigns.php?action=communication_remove",{id:id},function() {
update_tab_communications();
});
return false;
}
function comm_dialog_choose_select(id) {
// alert('im back with email id: '+id);
//get rid of hte html
var key = comm_chooser_key;
$("#dialog").empty();
$("#dialog").load("communication.php?action=dialog_edit&cloneid="+id+"&key="+key+"&fundraising_campaigns_id="+currentcampaignid,null,function() {
});
}
function comm_dialog_choose_cancel() {
// alert('im cancelled');
}
function comm_dialog_edit_save(id) {
// alert("saved!");
update_tab_communications();
}
function comm_dialog_edit_cancel() {
// alert("cancelled!");
}
function opensendlabelsdialog(reports_id,fcid) {
$("#dialog").empty();
var args = "action=dialog_gen&sid="+reports_id+"&filter[0][field]=fundraising_campaigns_id&filter[0][x]=0&filter[0][value]="+fcid;
$("#dialog").load("reports_gen.php?"+args,null,function() {
});
}
function opensendmaildialog(fcid,key) {
var dlargs = "fundraising_campaigns_id="+fcid+"&key="+key;
var dlurl = "<?=$config['SFIABDIRECTORY']?>/admin/reports_appeal_letters.php?"+dlargs;
window.location.href = dlurl;
// $('#content').attr('src',dlurl);
return false;
}
function opensendemaildialog(fcid,emails_id) {
$("#dialog").empty();
$("#dialog").load("communication.php?action=dialog_send&type=fundraising&fundraising_campaigns_id="+fcid+"&emails_id="+emails_id,null,function() {
});
}
</script>
<?
function display_campaign_form($r=null) {
global $config;
global $campaign_types;
?>
<tr>
<td><?=i18n("Name")?></td>
<td colspan="3"><input size="40" type="text" name="name" value="<?=$r->name?>"></td>
<td><?=i18n("Type")?></td><td>
<select name="type">
<option value=""><?=i18n("Choose")?></option>
<?
foreach($campaign_types AS $ct) {
if($r->type==$ct) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$ct\">".i18n($ct)."</option>\n";
}
?>
</select>
</td>
</tr>
<?
if($r->startdate) $sd=$r->startdate;
else $sd=date("Y-m-d");
?>
<tr>
<td><?=i18n("Start Date")?></td><td><input type="text" name="startdate" class="date" value="<?=$sd?>" /></td>
<td><?=i18n("Follow-Up Date")?></td><td><input type="text" name="followupdate" class="date" value="<?=$r->followupdate?>" /></td>
<td><?=i18n("End Date")?></td><td><input type="text" name="enddate" class="date" value="<?=$r->enddate?>" /></td>
</tr>
<tr>
<td><?=i18n("Target")?></td><td>$<input type="text" id="target" name="target" size="10" value="<?=$r->target?>" /></td>
<td><?=i18n("Default Purpose")?></td><td colspan="3">
<?
$fgq=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY name");
echo "<select name=\"fundraising_goal\">";
echo "<option value=\"\">".i18n("Choose Default Purpose")."</option>\n";
while($fgr=mysql_fetch_object($fgq)) {
if($r->fundraising_goal==$fgr->goal) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$fgr->goal\">".i18n($fgr->name)."</option>\n";
}
echo "</select>\n";
?>
</td>
</tr>
<?
}
?>
<table cellspacing=2 width=740 border=0>
<tr><td>
<a href="#" onclick="modifycampaigns()">Create/Modify Appeals</a>
</td><td>
<a href="#" onclick="managecampaigns()">Appeal Management</a>
</td></tr></table>
<hr />
<div id="campaigndiv" style="width: 780px; display: none;"></div>
<div id="dialog" style="width: 780px; display: none;"></div>
<?
send_footer();
?>

View File

@ -1,242 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2009 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
require("fundraising_common.inc.php");
$userslist=array();
$otherlist=array();
if($_POST['donortype']=="organization") {
$q=mysql_query("SELECT id, organization AS name, address, address2, city, province_code, postalcode FROM sponsors ORDER BY name");
echo mysql_error();
if(!$_POST['contacttype'])
$contacttype=array("primary","secondary");
else
$contacttype=$_POST['contacttype'];
$primary="";
while($r=mysql_fetch_object($q)) {
foreach($contacttype AS $ct) {
switch($ct) {
case "primary":
$primary="yes";
break;
case "secondary":
$primary="no";
break;
}
$cq = mysql_query("SELECT *,MAX(year) FROM users LEFT JOIN users_sponsor ON users_sponsor.users_id=users.id
WHERE
sponsors_id='" . $r->id . "'
AND `primary`='$primary'
AND types LIKE '%sponsor%'
GROUP BY uid
HAVING deleted='no'
ORDER BY users_sponsor.primary DESC,lastname,firstname
");
echo mysql_error();
while($cr=mysql_fetch_object($cq)) {
if(!$userslist[$cr->uid])
$userslist[$cr->uid]=user_load($cr->users_id);
}
}
}
}
else if($_POST['donortype']=="individual") {
if(!$_POST['individual_type'])
$individual_type=array("judge","teacher","sciencehead","principal","parent","mentor","committee","volunteer","students");
else
$individual_type=$_POST['individual_type'];
foreach($individual_type AS $t) {
$query="SELECT *,MAX(year) FROM users WHERE types LIKE '%$t%' GROUP BY uid HAVING deleted='no' ORDER BY lastname,firstname";
$q=mysql_query($query);
echo mysql_error();
while($r=mysql_fetch_object($q)) {
if(!$userslist[$r->uid])
$userslist[$r->uid]=user_load_by_uid($r->uid);
}
}
}
//okie dokie, now we need to filter ou the list on the other criteria
if($_POST['emailaddress']) {
$emailaddress=$_POST['emailaddress'];
}
else {
$emailaddress=array("available","not available");
}
if(count($emailaddress)==1) {
$emailavailablelist=array();
$emailnotavailablelist=array();
foreach($userslist AS $uid=>$u) {
if($u['email'])
$emailavailablelist[$uid]=$u;
else
$emailnotavailablelist[$uid]=$u;
}
if($emailaddress[0]=="available") {
$userslist=$emailavailablelist;
} else {
$userslist=$emailnotavailablelist;
}
}
if($_POST['donationhistory']) {
$donationhistory=$_POST['donationhistory'];
}
else {
$donationhistory=array("never","past","lastyear","thisyear");
}
/*
FIXME: put this back in as it would eliminate a lot of processing
if(in_array('never',$donationhistory) && in_array('past',$donationhistory)) {
//these cancel eachother out basically, so include everyone
unset($donationhistory[array_search("never",$donationhistory)]);
unset($donationhistory[array_search("past",$donationhistory)]);
}
*/
$neverlist=$userslist;
$pastlist=$userslist;
$lastyearlist=$userslist;
$thisyearlist=$userslist;
//if they dont have a sponsors id, then they,ve never donated for sure, so keep them
//if they DO have a sponsors id, we need to check if tere is a donation record for them
//and if so, remove them if there is because tey have donated in the past
foreach($neverlist AS $uid=>$u) {
if($u['sponsors_id']) {
$q=mysql_query("SELECT * FROM fundraising_donations WHERE status='received' AND sponsors_id='{$u['sponsors_id']}'");
if(mysql_num_rows($q)) {
// echo "removing $uid because they have donated in the past <br />";
unset($neverlist[$uid]);
}
}
}
//if they dont have a sponsors id, then they,ve never donated for sure, get rid of them
//if they DO have a sponsors id, we need to check if tere is a donation record for them
//and if not remove them if there is because tey have not donated in the past
foreach($pastlist AS $uid=>$u) {
if($u['sponsors_id']) {
$q=mysql_query("SELECT * FROM fundraising_donations WHERE status='received' AND sponsors_id='{$u['sponsors_id']}'");
if(!mysql_num_rows($q)) {
// echo "removing $uid because they have NOT donated in the past <br />";
unset($pastlist[$uid]);
}
}
else {
// echo "removing $uid because they have NOT donated in the past <br />";
unset($pastlist[$uid]);
}
}
$lastyear=$config['FISCALYEAR']-1;
foreach($lastyearlist AS $uid=>$u) {
if($u['sponsors_id']) {
$q=mysql_query("SELECT * FROM fundraising_donations WHERE status='received' AND sponsors_id='{$u['sponsors_id']}' AND fiscalyear='$lastyear'");
if(!mysql_num_rows($q)) {
// echo "removing $uid because they have NOT donated last year <br />";
unset($lastyearlist[$uid]);
}
}
else {
// echo "removing $uid because they have NOT donated last year <br />";
unset($lastyearlist[$uid]);
}
}
foreach($thisyearlist AS $uid=>$u) {
if($u['sponsors_id']) {
$q=mysql_query("SELECT * FROM fundraising_donations WHERE status='received' AND sponsors_id='{$u['sponsors_id']}' AND fiscalyear='{$config['FISCALYEAR']}'");
if(!mysql_num_rows($q)) {
// echo "removing $uid because they have NOT donated this year <br />";
unset($thisyearlist[$uid]);
}
}
else {
// echo "removing $uid because they have NOT donated this year <br />";
unset($thisyearlist[$uid]);
}
}
/*
echo "neverlist:".count($neverlist)."<br />";
echo "pastlist:".count($pastlist)."<br />";
echo "lastyearlist:".count($lastyearlist)."<br />";
echo "thisyearlist:".count($thisyearlist)."<br />";
*/
$userslist=array();
foreach($donationhistory AS $dh) {
$arr=$dh."list";
foreach($$arr AS $uid=>$u) {
$userslist[$uid]=$u;
}
}
if($_GET['generatelist']) {
$campaignid=$_POST['fundraising_campaigns_id'];
$params=serialize($_POST);
echo "params=$params";
mysql_query("UPDATE fundraising_campaigns SET filterparameters='{$params}' WHERE id='$campaignid'");
$uids=array_keys($userslist);
foreach($uids AS $u) {
mysql_query("INSERT INTO fundraising_campaigns_users_link (fundraising_campaigns_id, users_uid) VALUES ('$campaignid','$u')");
}
echo "List created";
}
else {
//just show the results
$usersnum=count($userslist);
echo i18n("%1 users match the given criteria",array($usersnum))." <br />";
echo "<input type=\"submit\" value=\"".i18n("Generate List")."\">\n";
//print_r($userslist);
//print_r($otherlist);
}
echo "<br /><br />";
echo nl2br(print_r($_POST,true));
?>

View File

@ -1,10 +0,0 @@
<?
$campaign_types=array("Mail","Email","Phone","Personal Visit","Event","Other");
function getGoal($goal) {
global $config;
$q=mysql_query("SELECT * FROM fundraising_goals WHERE goal='$goal' AND fiscalyear='{$config['FISCALYEAR']}' LIMIT 1");
return mysql_fetch_object($q);
}
?>

View File

@ -1,65 +0,0 @@
<?
if($_POST['action']=="funddelete" && $_POST['delete']) {
//first lookup all the sponsorships inside the fund
$id=intval($_POST['delete']);
$q=mysql_query("SELECT * FROM fundraising_goals WHERE id='$id' AND year='".$config['FISCALYEAR']."'");
$f=mysql_fetch_object($q);
//hold yer horses, no deleting system funds!
if($f) {
if($f->system=="no") {
mysql_query("DELETE FROM fundraising_donations WHERE fundraising_goal='".mysql_real_escape_string($f->type)."' AND fiscalyear='".$config['FISCALYEAR']."'");
mysql_query("DELETE FROM fundraising_goals WHERE id='$id'");
if(mysql_affected_rows())
happy_("Successfully removed fund %1",array($f->name));
}
else {
error_("Cannot remove system fund");
}
}
exit;
}
if($_POST['action']=="fundedit" || $_POST['action']=="fundadd") {
$fundraising_id=intval($_POST['fundraising_id']);
if($fundraising_id) {
$q=mysql_query("SELECT * FROM fundraising_goals WHERE id='$fundraising_id'");
$f=mysql_fetch_object($q);
$system=$f->system;
}
$name=mysql_real_escape_string($_POST['name']);
$goal=mysql_real_escape_string($_POST['goal']);
$description=mysql_real_escape_string($_POST['description']);
$budget=intval($_POST['budget']);
}
if($_POST['action']=="fundedit") {
if( ($system=="yes" && $budget) || ($system=="no" && $budget && $goal && $name) ) {
if($system=="yes") {
mysql_query("UPDATE fundraising SET budget='$budget', description='$description' WHERE id='$fundraising_id'");
}
else {
mysql_query("UPDATE fundraising SET budget='$budget', description='$description', goal='$goal', name='$name' WHERE id='$fundraising_id'");
}
if(mysql_error())
error_("MySQL Error: %1",array(mysql_error()));
else
happy_("Saved fund changes");
}
else {
error_("Required fields were missing, please try again");
}
exit;
}
if($_POST['action']=="fundadd") {
if( $goal && $type && $name) {
mysql_query("INSERT INTO fundraising_goals (goal,name,description,system,budget,fiscalyear) VALUES ('$goal','$name','$description','no','$budget','{$config['FISCALYEAR']}')");
happy_("Added new fund");
}
else
error_("Required fields were missing, please try again");
if(mysql_error())
error_("MySQL Error: %1",array(mysql_error()));
exit;
}
?>

View File

@ -1,115 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2009 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
require("fundraising_common.inc.php");
send_header("Fundraising Reports",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Fundraising' => 'admin/fundraising.php'),
"fundraising"
);
?>
<script type="text/javascript">
$(document).ready( function(){
$("#standardreportsaccordion").accordion();
});
</script>
<h3>Standard Reports</h3>
<div id="standardreportsaccordion" style="width: 600px;">
<h3><a a href="#">List of Prospects by Appeal</a></h3>
<div>
<table><tr><td>
Choose an appeal:
</td><td>
<form method=get action="fundraising_reports_std.php">
<input type="hidden" name="id" value="1">
<select name="fundraising_campaigns_id">
<option value="">All appeals</option>
<?
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY name");
while($r=mysql_fetch_object($q)) {
echo "<option value=\"$r->id\">$r->name</option>\n";
}
?>
</select>
</td></tr>
<tr><td>
Report Type:
</td><td>
<select name="type">
<option value="pdf">PDF</option>
<option value="csv">CSV</option>
</select>
</td></tr>
<tr><td colspan="2" style="text-align: center;">
<input type="submit" value="Generate Report">
</td></tr></table>
</form>
</div>
<h3><a href="#">Results of Appeal by Purpose</a></h3>
<div>
<form method=get action="fundraising_reports_std.php">
<input type="hidden" name="id" value="2">
<table><tr><td>
Choose a Purpose:
</td><td>
<select name="goal">
<option value="">All purposes</option>
<?
$q=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY name");
while($r=mysql_fetch_object($q)) {
echo "<option value=\"$r->goal\">$r->name</option>\n";
}
?>
</select>
</td></tr>
<tr><td>
Report Type:
</td><td>
<select name="type">
<option value="pdf">PDF</option>
<option value="csv">CSV</option>
</select>
</td></tr>
<tr><td colspan="2" style="text-align: center;">
<input type="submit" value="Generate Report">
</td></tr></table>
</form>
</div>
</div>
<br />
<br />
<h3>Custom Reports</h3>
<ul>
<li><a href="#">(custom reports will be here)</a></li>
</ul>
<?
send_footer();
?>

View File

@ -1,174 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2009 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
require("fundraising_common.inc.php");
require_once("../lpdf.php");
require_once("../lcsv.php");
$id=intval($_GET['id']);
$type=$_GET['type'];
if($id && $type) {
switch($id) {
case 1:
if($type=="csv") {
$rep=new lcsv($config['FAIRNAME']);
} else if($type=="pdf") {
$rep=new lpdf( i18n($config['fairname']),
i18n("List of Prospects By Appeal"),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif"
);
$rep->newPage();
$rep->setFontSize(8);
}
$sql="SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}' ";
if($_GET['fundraising_campaigns_id']) {
$sql.=" AND id='".intval($_GET['fundraising_campaigns_id'])."'";
}
$sql.=" ORDER BY name";
$q=mysql_query($sql);
echo mysql_error();
while($r=mysql_fetch_object($q)) {
$rep->heading($r->name);
$table=array();
$table['header']=array("Name","Contact","Phone","Address","$ appeal","$ this year","$ last year","%chg");
$table['widths']=array(1.5,1,1,1,0.9,0.9,0.9,0.5);
$table['dataalign']=array("left","left","left","left","right","right","right","center");
$thisyear=$config['FISCALYEAR'];
$lastyear=$config['FISCALYEAR']-1;
$pq=mysql_query("SELECT * FROM fundraising_campaigns_users_link WHERE fundraising_campaigns_id='$r->id'");
while($pr=mysql_fetch_object($pq)) {
$u=user_load_by_uid($pr->users_uid);
//hopefully this never returns false, but who knows..
if($u) {
//we only want the primaries, yea, i know... we have this werid confusing between a USER being linked to a sponsor and then a sponsor having multiple users
//and then only getting the primary contact for the sponsor even if it might not be the user thats in teh campaign... my brain hurts
// if($u['primary']=="no")
// continue;
//gah i dont know what the heck to do here
if($u['sponsors_id']) {
$cq=mysql_query("SELECT SUM(value) AS total FROM fundraising_donations WHERE sponsors_id='{$u['sponsors_id']}' AND fundraising_campaigns_id='$r->id' AND status='received' AND fiscalyear='$thisyear'");
$cr=mysql_fetch_object($cq);
$thisappeal=$cr->total;
$cq=mysql_query("SELECT SUM(value) AS total FROM fundraising_donations WHERE sponsors_id='{$u['sponsors_id']}' AND status='received' AND fiscalyear='$thisyear'");
$cr=mysql_fetch_object($cq);
$thisyeartotal=$cr->total;
$cq=mysql_query("SELECT SUM(value) AS total FROM fundraising_donations WHERE sponsors_id='{$u['sponsors_id']}' AND status='received' AND fiscalyear='$lastyear'");
$cr=mysql_fetch_object($cq);
$lastyeartotal=$cr->total;
if($lastyeartotal)
$change=round(($thisyeartotal-$lastyeartotal)/$lastyeartotal*100);
else
$change="N/A";
$name=$u['sponsor']['organization'];
}
else {
$name=$u['firstname']." " .$u['lastname'];
$thisappeal=0;
$thisyeartotal=0;
$lastyeartotal=0;
$change=0;
}
$table['data'][]=array(
$name,
$u['firstname']." " .$u['lastname'],
$u['phonework'],
$u['address']." ".$u['address2'],
$thisappeal,
$thisyeartotal,
$lastyeartotal,
$change
);
}
}
$rep->addTable($table);
}
break;
case 2:
if($type=="csv") {
$rep=new lcsv($config['FAIRNAME'],'Results of Appeal by Purpose',"");
} else if($type=="pdf") {
$rep=new lpdf( i18n($config['fairname']),
i18n("Results of Appeal by Purpose"),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif"
);
$rep->newPage();
$rep->setFontSize(8);
}
$sql="SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISCALYEAR']}' ";
if($_GET['goal']) {
$sql.=" AND goal='".mysql_real_escape_string($_GET['goal'])."'";
}
$sql.=" ORDER BY name";
$q=mysql_query($sql);
echo mysql_error();
while($r=mysql_fetch_object($q)) {
$rep->heading($r->name)." (".$r->budget.")";
$table=array();
$table['header']=array("Appeal Name","Target","Received","% to Budget","# of Prospects","# of Donors/Sponsors","Rate of Response","Average Amount Given");
$table['widths']=array(1.5,0.5,0.5,0.75,0.9,0.9,0.9,0.5);
$table['dataalign']=array("left","right","right","center","center","center","center","right");
$cq=mysql_query("SELECT * FROM fundraising_campaigns WHERE fundraising_goal='$r->goal' AND fiscalyear='{$config['FISCALYEAR']}'");
while($cr=mysql_fetch_object($cq)) {
$table['data'][]=array(
$cr->name,
$cr->target,
$received,
$percenttobudget,
$numprospects,
$numdonors,
$rate,
$avgamount);
}
$rep->addTable($table);
}
break;
}
$rep->output();
}
else
header("Location: fundraising_reports.php");
?>

View File

@ -1,434 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2009 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
//first, insert any default fundraising donor levels
$q=mysql_query("SELECT * FROM fundraising_donor_levels WHERE fiscalyear='".$config['FISCALYEAR']."'");
if(!mysql_num_rows($q)) {
$q=mysql_query("SELECT * FROM fundraising_donor_levels WHERE fiscalyear='-1'");
while($r=mysql_fetch_object($q)) {
mysql_query("INSERT INTO fundraising_donor_levels (`level`,`min`,`max`,`description`,`fiscalyear`) VALUES (
'".mysql_real_escape_string($r->level)."',
'".mysql_real_escape_string($r->min)."',
'".mysql_real_escape_string($r->max)."',
'".mysql_real_escape_string($r->description)."',
'".$config['FISCALYEAR']."')");
}
}
//first, insert any default fundraising goals
$q=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='".$config['FISCALYEAR']."'");
if(!mysql_num_rows($q)) {
$q=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='-1'");
while($r=mysql_fetch_object($q)) {
mysql_query("INSERT INTO fundraising_goals (`goal`,`name`,`description`,`system`,`budget`,`fiscalyear`) VALUES (
'".mysql_real_escape_string(stripslashes($r->goal))."',
'".mysql_real_escape_string(stripslashes($r->name))."',
'".mysql_real_escape_string(stripslashes($r->description))."',
'".mysql_real_escape_string($r->system)."',
'".mysql_real_escape_string($r->budget)."',
'".$config['FISCALYEAR']."')");
}
}
switch($_GET['gettab']) {
case "levels":
$q=mysql_query("SELECT * FROM fundraising_donor_levels WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY max");
echo "<div id=\"levelaccordion\" style=\"width: 75%;\">\n";
while($r=mysql_fetch_object($q)) {
echo "<h3><a href=\"#\">$r->level (".format_money($r->min,false)." to ".format_money($r->max,false).")</a></h3>\n";
echo "<div id=\"level_$r->id\">\n";
echo "<form id=\"level_form_$r->id\" onsubmit=\"return level_save($r->id)\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"$r->id\">\n";
echo "<table style=\"width: 100%;\">";
echo "<tr><td>";
echo i18n("Level Name").":</td><td><input type=\"text\" size=\"40\" name=\"level\" value=\"".htmlspecialchars($r->level)."\"></td></tr>\n";
echo "<tr><td>";
echo i18n("Value Range").":</td><td>\$<input size=\"5\" type=\"text\" name=\"min\" value=\"$r->min\"> to \$<input size=\"5\" type=\"text\" name=\"max\" value=\"$r->max\"><br />\n";
echo "</td></tr>\n";
echo "<tr><td colspan=\"2\">";
echo i18n("Description/Benefits").":<br /><textarea name=\"description\" rows=\"4\" style=\"width: 100%;\">".htmlspecialchars($r->description)."</textarea>";
echo "</td></tr>\n";
echo "</table>\n";
echo "<table style=\"width: 100%;\"><tr><td style=\"width: 50%; text-align: center;\">";
echo "<input type=\"submit\" value=\"".i18n("Save Level")."\" >";
echo "</td><td style=\"width: 50%; text-align: right;\">";
echo "<input type=\"button\" value=\"".i18n("Delete Level")."\" onclick=\"return level_delete($r->id)\" >";
echo "</td></tr></table>\n";
echo "</form>";
echo "</div>\n";
}
echo "<h3><a href=\"#\">Create New Level</a></h3>\n";
echo "<div id=\"level_new\">\n";
echo "<form id=\"level_form\" onsubmit=\"return level_save()\">\n";
echo "<table style=\"width: 100%;\">";
echo "<tr><td>";
echo i18n("Level Name").":</td><td><input type=\"text\" size=\"40\" name=\"level\"></td></tr>\n";
echo "<tr><td>";
echo i18n("Value Range").":</td><td>\$<input size=\"5\" type=\"text\" name=\"min\"> to \$<input size=\"5\" type=\"text\" name=\"max\"><br />\n";
echo "</td></tr>\n";
echo "<tr><td colspan=\"2\">";
echo i18n("Description/Benefits").":<br /><textarea name=\"description\" rows=\"4\" style=\"width: 100%;\"></textarea>";
echo "</td></tr>\n";
echo "</table>\n";
echo "<table style=\"width: 100%;\"><tr><td style=\"width: 50%; text-align: center;\">";
echo "<input type=\"submit\" value=\"".i18n("Create Level")."\">";
echo "</td><td style=\"width: 50%; text-align: right;\">";
echo "</td></tr></table>\n";
echo "</form>\n";
echo "</div>\n";
echo "</div>\n";
exit;
break;
case "goals":
$q=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY name");
echo "<div id=\"goalaccordion\" style=\"width: 75%;\">\n";
while($r=mysql_fetch_object($q)) {
echo "<h3><a href=\"#\">$r->name (".format_money($r->budget,false).") Deadline: ".format_date($r->deadline)."</a></h3>\n";
echo "<div id=\"goal_$r->id\">\n";
echo "<form id=\"goal_form_$r->id\" onsubmit=\"return goal_save($r->id)\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"$r->id\">\n";
echo "<table style=\"width: 100%;\">";
echo "<tr><td>";
echo i18n("Purpose").":</td><td><input type=\"text\" size=\"40\" name=\"name\" value=\"".htmlspecialchars($r->name)."\"></td></tr>\n";
echo "<tr><td>";
echo i18n("Budget Amount").":</td><td>\$<input size=\"5\" type=\"text\" name=\"budget\" value=\"$r->budget\"></td></tr>";
echo "<tr><td>";
echo i18n("Deadline").":</td><td><input size=\"9\" type=\"text\" name=\"deadline\" value=\"$r->deadline\"></td></tr>";
echo "<tr><td colspan=\"2\">";
echo i18n("Description").":<br /><textarea name=\"description\" rows=\"4\" style=\"width: 100%;\">".htmlspecialchars($r->description)."</textarea>";
echo "</td></tr>\n";
echo "</table>\n";
echo "<table style=\"width: 100%;\"><tr><td style=\"width: 50%; text-align: center;\">";
echo "<input type=\"submit\" value=\"".i18n("Save Purpose")."\" >";
echo "</td><td style=\"width: 50%; text-align: right;\">";
echo "<input type=\"button\" value=\"".i18n("Delete Purpose")."\" onclick=\"return goal_delete($r->id)\" >";
echo "</td></tr></table>\n";
echo "</form>";
echo "</div>\n";
}
echo "<h3><a href=\"#\">Create New Purpose</a></h3>\n";
echo "<div id=\"goal_new\">\n";
echo "<form id=\"goal_form\" onsubmit=\"return goal_save()\">\n";
echo "<table style=\"width: 100%;\">";
echo "<tr><td>";
echo i18n("Purpose Name").":</td><td><input type=\"text\" size=\"40\" name=\"name\"></td></tr>\n";
echo "<tr><td>";
echo i18n("Budget Amount").":</td><td>\$<input size=\"5\" type=\"text\" name=\"budget\"></td></tr>";
echo "<tr><td>";
echo i18n("Deadline").":</td><td><input size=\"9\" type=\"text\" name=\"deadline\"></td></tr>";
echo "<tr><td colspan=\"2\">";
echo i18n("Description").":<br /><textarea name=\"description\" rows=\"4\" style=\"width: 100%;\"></textarea>";
echo "</td></tr>\n";
echo "</table>\n";
echo "<table style=\"width: 100%;\"><tr><td style=\"width: 50%; text-align: center;\">";
echo "<input type=\"submit\" value=\"".i18n("Create Purpose")."\">";
echo "</td><td style=\"width: 50%; text-align: right;\">";
echo "</td></tr></table>\n";
echo "</form>\n";
echo "</div>\n";
echo "</div>\n";
exit;
break;
case "setup":
echo "<form id=\"setup_form\" onsubmit=\"return setup_save()\">";
echo "<table cellspacing=3 cellpadding=3>";
echo "<tr><td>".i18n("Current Fiscal Year")."</td><td>";
echo $config['FISCALYEAR'];
echo "</td></tr>\n";
echo "<tr><td>".i18n("Fiscal Year End")."</td><td>";
list($month,$day)=explode("-",$config['fiscal_yearend']);
emit_month_selector("fiscalendmonth",$month);
emit_day_selector("fiscalendday",$day);
echo "</td></tr>\n";
echo "<tr><td>".i18n("Is your organization a registered charity?")."</td>";
echo "<td>";
if($config['registered_charity']=="yes") $ch="checked=\"checked\""; else $ch="";
echo "<label><input $ch type=\"radio\" name=\"registeredcharity\" value=\"yes\" id=\"registeredcharity_yes\" onchange=\"charitychange()\">".i18n("Yes")."</label>";
echo "&nbsp;&nbsp;&nbsp;";
if($config['registered_charity']=="no") $ch="checked=\"checked\""; else $ch="";
echo "<label><input $ch type=\"radio\" name=\"registeredcharity\" value=\"no\" id=\"registeredcharity_no\" onchange=\"charitychange()\">".i18n("No")."</label>";
echo "</td></tr>\n";
echo "<tr>";
echo "<td>".i18n("Charity Registration Number")."</td><td><input type=\"text\" name=\"charitynumber\" id=\"charitynumber\" value=\"{$config['charity_number']}\"></td>";
echo "</tr>";
echo "<tr><td colspan=\"2\" style=\"text-align: center;\"><input type=\"submit\" value=\"".i18n("Save")."\"></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
exit;
break;
}
switch($_GET['action']) {
case "level_save":
$id=$_POST['id'];
if(! ($_POST['level'] && $_POST['min'] && $_POST['max'])) {
error_("Level name, minimum and maximum value range are required");
exit;
}
if($_POST['min']>=$_POST['max']) {
error_("Value range minimum must be smaller than range maximum");
exit;
}
if($id) {
mysql_query("UPDATE fundraising_donor_levels SET
min='".mysql_real_escape_string($_POST['min'])."',
max='".mysql_real_escape_string($_POST['max'])."',
level='".mysql_real_escape_string(stripslashes($_POST['level']))."',
description='".mysql_real_escape_string(stripslashes($_POST['description']))."'
WHERE id='$id' AND fiscalyear='{$config['FISCALYEAR']}'
");
happy_("Level Saved");
}
else {
mysql_query("INSERT INTO fundraising_donor_levels (`level`,`min`,`max`,`description`,`fiscalyear`) VALUES (
'".mysql_real_escape_string($_POST['level'])."',
'".mysql_real_escape_string($_POST['min'])."',
'".mysql_real_escape_string($_POST['max'])."',
'".mysql_real_escape_string($_POST['description'])."',
'{$config['FISCALYEAR']}')");
happy_("Level Created");
}
exit;
break;
case "level_delete":
$id=$_POST['id'];
mysql_query("DELETE FROM fundraising_donor_levels WHERE id='$id' AND fiscalyear='{$config['FISCALYEAR']}'");
happy_("Level Deleted");
exit;
break;
case "goal_save":
$id=$_POST['id'];
if(! ($_POST['name'] && $_POST['budget'])) {
error_("Purpose name and budget are required");
exit;
}
if($id) {
mysql_query("UPDATE fundraising_goals SET
budget='".mysql_real_escape_string($_POST['budget'])."',
deadline='".mysql_real_escape_string($_POST['deadline'])."',
name='".mysql_real_escape_string(stripslashes($_POST['name']))."',
description='".mysql_real_escape_string(stripslashes($_POST['description']))."'
WHERE id='$id' AND fiscalyear='{$config['FISCALYEAR']}'
");
happy_("Purpose Saved");
}
else {
$goal=strtolower($_POST['name']);
$goal=ereg_replace("[^a-z]","",$goal);
$q=mysql_query("SELECT * FROM fundraising_goals WHERE goal='$goal' AND fiscalyear='{$config['FISCALYEAR']}'");
echo mysql_error();
if(mysql_num_rows($q)) {
error_("The automatically generated purpose key (%1) generated from (%2) is not unique. Please try a different Purpose Name",array($goal,$_POST['name']));
exit;
}
mysql_query("INSERT INTO fundraising_goals (`goal`,`name`,`budget`,`deadline`,`description`,`fiscalyear`) VALUES (
'".mysql_real_escape_string($goal)."',
'".mysql_real_escape_string($_POST['name'])."',
'".mysql_real_escape_string($_POST['budget'])."',
'".mysql_real_escape_string($_POST['deadline'])."',
'".mysql_real_escape_string($_POST['description'])."',
'{$config['FISCALYEAR']}')");
happy_("Purpose Created");
}
exit;
break;
case "goal_delete":
$id=$_POST['id'];
//they cant delete system ones
$q=mysql_query("SELECT * FROM fundraising_goals WHERE id='$id' AND fiscalyear='{$config['FISCALYEAR']}'");
if(!$r=mysql_fetch_object($q)) {
error_("Invalid goal to delete");
exit;
}
if($r->system=="yes") {
error_("Fundraising goals created automatically and used by the system cannot be deleted");
exit;
}
$q=mysql_query("SELECT * FROM fundraising_donations WHERE fundraising_goal='$r->goal' AND fiscalyear='{$config['FISCALYEAR']}'");
if(mysql_num_rows($q)) {
error_("This goal already has donations assigned to it, it cannot be deleted");
exit;
}
mysql_query("DELETE FROM fundraising_goals WHERE id='$id' AND fiscalyear='{$config['FISCALYEAR']}'");
happy_("Purpose Deleted");
exit;
break;
case "setup_save":
$fye=sprintf("%02d-%02d",intval($_POST['fiscalendmonth']),intval($_POST['fiscalendday']));
mysql_query("UPDATE config SET val='$fye' WHERE var='fiscal_yearend' AND conferences_id='{$conference['id']}'");
mysql_query("UPDATE config SET val='".mysql_real_escape_string($_POST['registeredcharity'])."' WHERE var='registered_charity' AND conferences_id='{$conference['id']}'");
mysql_query("UPDATE config SET val='".mysql_real_escape_string($_POST['charitynumber'])."' WHERE var='charity_number' AND conferences_id='{$conference['id']}'");
happy_("Fundraising module setup saved");
exit;
break;
}
send_header("Fundraising Setup",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Fundraising' => 'admin/fundraising.php')
);
?>
<script type="text/javascript">
/* Setup the popup window */
$(document).ready(function() {
$("#editor_tabs").tabs({
show: function(event, ui) {
switch(ui.panel.id) {
case 'editor_tab_levels':
update_levels();
break;
case 'editor_tab_goals':
update_goals();
break;
break;
case 'editor_tab_setup':
update_setup();
break;
break;
}
},
selected: 0
});
// $("#organizationinfo_fundingselectiondate").datepicker({ dateFormat: 'yy-mm-dd', showOn: 'button', buttonText: "<?=i18n("calendar")?>" });
});
function update_levels() {
$("#editor_tab_levels").load("fundraising_setup.php?gettab=levels",null,
function() {
$("#levelaccordion").accordion();
}
);
}
function level_save(id) {
if(id) var f=$("#level_form_"+id);
else var f=$("#level_form");
$("#debug").load("fundraising_setup.php?action=level_save",f.serializeArray(), function() { update_levels(); });
return false;
}
function level_delete(id) {
if(confirmClick('Are you sure you want to delete this fundraising level?')) {
var f=$("#level_form_"+id);
$("#debug").load("fundraising_setup.php?action=level_delete",f.serializeArray(), function() { update_levels(); });
}
return false;
}
function update_goals() {
$("#editor_tab_goals").load("fundraising_setup.php?gettab=goals",null,
function() {
$("#goalaccordion").accordion();
$("[name=deadline]").datepicker({ dateFormat: 'yy-mm-dd'});
}
);
}
function update_setup() {
$("#editor_tab_setup").load("fundraising_setup.php?gettab=setup",null,function() { charitychange(); });
}
function setup_save() {
$("#debug").load("fundraising_setup.php?action=setup_save",$("#setup_form").serializeArray(), function() { update_setup(); });
return false;
}
function goal_save(id) {
if(id) var f=$("#goal_form_"+id);
else var f=$("#goal_form");
$("#debug").load("fundraising_setup.php?action=goal_save",f.serializeArray(), function() { update_goals(); });
return false;
}
function goal_delete(id) {
if(confirmClick('Are you sure you want to delete this fundraising goal?')) {
var f=$("#goal_form_"+id);
$("#debug").load("fundraising_setup.php?action=goal_delete",f.serializeArray(), function() { update_goals(); });
}
return false;
}
function charitychange() {
if($("input[@name='registeredcharity']:checked").val()=="yes") {
$("#charitynumber").attr("disabled","");
}
else {
$("#charitynumber").attr("disabled","disabled");
}
}
</script>
<div id="setup" style="width: 780px;">
<div id="editor_tabs">
<ul>
<li><a href="#editor_tab_setup"><span><?=i18n('Module Setup')?></span></a></li>
<li><a href="#editor_tab_levels"><span><?=i18n('Fundraising Levels')?></span></a></li>
<li><a href="#editor_tab_goals"><span><?=i18n('Fundraising Purposes')?></span></a></li>
</ul>
<div id="editor_tab_setup">
</div>
<div id="editor_tab_levels">
</div>
<div id="editor_tab_goals">
</div>
</div>
</div>
<?
send_footer();
?>

View File

@ -0,0 +1,105 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2008 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
if($_GET['id']) {
$id=intval($_GET['id']);
$q=mysql_query("SELECT sponsorships.*, sponsors.organization FROM sponsorships,sponsors WHERE sponsorships.id='$id' AND sponsorships.sponsors_id=sponsors.id");
echo "<h2>Edit Sponsorship</h2>";
$sponsorship=mysql_fetch_object($q);
$formaction="sponsorshipedit";
}
else
{
echo "<h2>Create New Sponsorship</h2>";
$formaction="sponsorshipadd";
$fundraising_type=$_GET['fundraising_type'];
}
echo "<input type=\"hidden\" name=\"action\" value=\"$formaction\">";
echo "<input type=\"hidden\" name=\"sponsorships_id\" value=\"$id\">";
echo "<table cellspacing=0 cellpadding=0 class=\"SFIABDialogTable\">";
echo "<tr><th>".i18n("Sponsor")."</th>";
echo "<td>";
if($formaction=="sponsorshipadd") {
$q=mysql_query("SELECT * FROM sponsors ORDER BY organization");
echo mysql_error();
echo "<select name=\"sponsors_id\">";
echo "<option value=\"\">".i18n("Choose")."</option>\n";
while($r=mysql_fetch_object($q)) {
if($r->id==$sponsorship->sponsors_id) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$r->id\">$r->organization</option>\n";
}
echo "</select>&nbsp;<a href=\"sponsors.php?action=add\">".i18n("Add")."</a>\n";
}
else {
echo $sponsorship->organization;
}
echo "</td></tr>\n";
echo "<tr><th>".i18n("Type")."</th>";
echo "<td>";
$q=mysql_query("SELECT * FROM fundraising WHERE year='{$config['FAIRYEAR']}' ORDER BY name");
echo mysql_error();
echo "<select name=\"fundraising_type\">";
echo "<option value=\"\">".i18n("Choose")."</option>\n";
while($r=mysql_fetch_object($q)) {
if($r->type==$sponsorship->fundraising_type || $r->type==$fundraising_type) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$r->type\">$r->name</option>\n";
}
echo "</select>\n";
echo "</td></tr>\n";
echo "<tr><th>".i18n("Amount")."</th><td><input type=\"text\" name=\"value\" value=\"$sponsorship->value\"></td></tr>\n";
echo "<tr><th>".i18n("Status")."</th>";
echo "<td>";
echo "<select name=\"status\">";
echo "<option value=\"\">".i18n("Choose")."</option>\n";
$statuses=array("pending","confirmed","received");
foreach($statuses AS $status) {
if($sponsorship->status==$status) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$status\">".i18n(ucfirst($status))."</option>\n";
}
echo "</select>\n";
echo "</td></tr>\n";
echo "<tr><th>".i18n("Probability")."</th>";
echo "<td>";
echo "<select name=\"probability\">";
echo "<option value=\"\">".i18n("Choose")."</option>\n";
$probs=array("25","50","75","90","95","99","100");
foreach($probs AS $prob) {
if($sponsorship->probability==$prob) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$prob\">$prob%</option>\n";
}
echo "</select>\n";
echo "</td></tr>\n";
echo "</table>\n";
?>

View File

@ -1,14 +1,13 @@
<?
if($_POST['action']=="sponsorshipdelete") {
mysql_query("DELETE FROM fundraising_donations WHERE id='".intval($_POST['delete'])."'");
if($_GET['action']=="sponsorshipdelete") {
mysql_query("DELETE FROM sponsorships WHERE id='".intval($_GET['delete'])."'");
if(mysql_affected_rows())
happy_("Successfully removed sponsorship");
exit;
message_push(happy(i18n("Successfully removed sponsorship")));
}
if($_POST['action']=="sponsorshipedit" || $_POST['action']=="sponsorshipadd") {
$sponsors_id=intval($_POST['sponsors_id']);
$fundraising_donations_id=intval($_POST['fundraising_donations_id']);
$sponsorships_id=intval($_POST['sponsorships_id']);
$fundraising_type=mysql_real_escape_string($_POST['fundraising_type']);
$value=mysql_real_escape_string($_POST['value']);
@ -20,9 +19,8 @@ if($_POST['action']=="sponsorshipedit" || $_POST['action']=="sponsorshipadd") {
}
if($_POST['action']=="sponsorshipedit") {
if($fundraising_donations_id && $fundraising_type && $value) {
$q=mysql_query("SELECT * FROM fundraising_donations WHERE id='$fundraising_donations_id'");
if($sponsorships_id && $fundraising_type && $value) {
$q=mysql_query("SELECT * FROM sponsorships WHERE id='$sponsorships_id'");
$current=mysql_fetch_object($q);
unset($log);
@ -40,10 +38,10 @@ if($_POST['action']=="sponsorshipedit") {
$log[]="Changed sponsorship probability from $current->probability to $probability";
if(count($log)) {
mysql_query("UPDATE fundraising_donations SET fundraising_type='$fundraising_type', value='$value', status='$status', probability='$probability' WHERE id='$fundraising_donations_id'");
mysql_query("UPDATE sponsorships SET fundraising_type='$fundraising_type', value='$value', status='$status', probability='$probability' WHERE id='$sponsorships_id'");
foreach($log AS $l) {
mysql_query("INSERT INTO fundraising_donor_logs (sponsors_id,dt,users_id,log) VALUES (
mysql_query("INSERT INTO sponsors_logs (sponsors_id,dt,users_id,log) VALUES (
'$current->sponsors_id',
NOW(),
'".$_SESSION['users_id']."',
@ -51,33 +49,32 @@ if($_POST['action']=="sponsorshipedit") {
}
if(mysql_error())
echo error_(mysql_error());
message_push(error(mysql_error()));
else
echo happy_("Saved sponsorship changes");
message_push(happy(i18n("Saved sponsorship changes")));
}
else
echo error_("No changes were made");
message_push(happy(i18n("No changes were made")));
}
else {
echo error_("Required fields were missing, please try again".print_r($_POST,true));
message_push(error(i18n("Required fields were missing, please try again")));
}
exit;
}
if($_POST['action']=="sponsorshipadd") {
if($sponsors_id && $fundraising_type && $value) {
mysql_query("INSERT INTO fundraising_donations (sponsors_id,fundraising_type,value,status,probability,fiscalyear) VALUES ('$sponsors_id','$fundraising_type','$value','$status','$probability','{$config['FISCALYEAR']}')");
mysql_query("INSERT INTO fundraising_donor_logs (sponsors_id,dt,users_id,log) VALUES (
mysql_query("INSERT INTO sponsorships (sponsors_id,fundraising_type,value,status,probability,year) VALUES ('$sponsors_id','$fundraising_type','$value','$status','$probability','{$config['FAIRYEAR']}')");
mysql_query("INSERT INTO sponsors_logs (sponsors_id,dt,users_id,log) VALUES (
'$sponsors_id',
NOW(),
'".$_SESSION['users_id']."',
'".mysql_real_escape_string("Created sponsorship: type=$fundraising_type, value=\$$value, status=$status, probability=$probability%")."')");
happy_("Added new sponsorship");
message_push(happy(i18n("Added new sponsorship")));
}
else
error_("Required fields were missing, please try again");
message_push(error(i18n("Required fields were missing, please try again")));
if(mysql_error())
error_(mysql_error());
exit;
message_push(error(mysql_error()));
}
?>

View File

@ -24,24 +24,24 @@
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
if($_GET['id']) {
$id=intval($_GET['id']);
$q=mysql_query("SELECT * FROM fundraising WHERE id='$id'");
// echo "<h2>Edit Fund</h2>";
echo "<h2>Edit Fund</h2>";
$fund=mysql_fetch_object($q);
$formaction="fundedit";
}
else {
// echo "<h2>Create New Fund</h2>";
echo "<h2>Create New Fund</h2>";
$formaction="fundadd";
}
echo "<form id=\"fundraisingfundraising\">";
echo "<input type=\"hidden\" name=\"action\" value=\"$formaction\">";
echo "<input type=\"hidden\" name=\"fundraising_id\" value=\"$id\">";
echo "<table class=\"tableedit\" style=\"width: 90%;\">";
echo "<table class=\"SFIABDialogTable\">";
if($fund->system=="yes") {
echo "<tr><th>".i18n("Type")."</th><td>".i18n("System (non-editable)")."</td></tr>\n";
echo "<tr><th>".i18n("Name")."</th><td>".htmlspecialchars($fund->name)."</td></tr>\n";
@ -55,6 +55,5 @@
echo "<tr><th>".i18n("Description")."</th><td><textarea style=\"width: 100%; height: 4em;\" name=\"description\">".htmlspecialchars($fund->description)."</textarea></td></tr>\n";
echo "<tr><th>".i18n("Goal")."</th><td><input type=\"text\" size=\"8\" name=\"goal\" value=\"$fund->goal\"></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
?>

View File

@ -0,0 +1,62 @@
<?
if($_GET['action']=="funddelete" && $_GET['delete']) {
//first lookup all the sponsorships inside the fund
$id=intval($_GET['delete']);
$q=mysql_query("SELECT * FROM fundraising WHERE id='$id' AND year='".$config['FAIRYEAR']."'");
$f=mysql_fetch_object($q);
//hold yer horses, no deleting system funds!
if($f) {
if($f->system=="no") {
mysql_query("DELETE FROM sponsorships WHERE fundraising_type='".mysql_real_escape_string($f->type)."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM fundraising WHERE id='$id'");
if(mysql_affected_rows())
message_push(happy(i18n("Successfully removed fund %1",array($f->name))));
}
else {
message_push(error(i18n("Cannot remove system fund")));
}
}
}
if($_POST['action']=="fundedit" || $_POST['action']=="fundadd") {
$fundraising_id=intval($_POST['fundraising_id']);
if($fundraising_id) {
$q=mysql_query("SELECT * FROM fundraising WHERE id='$fundraising_id'");
$f=mysql_fetch_object($q);
$system=$f->system;
}
$name=mysql_real_escape_string($_POST['name']);
$type=mysql_real_escape_string($_POST['type']);
$description=mysql_real_escape_string($_POST['description']);
$goal=intval($_POST['goal']);
}
if($_POST['action']=="fundedit") {
if( ($system=="yes" && $goal) || ($system=="no" && $goal && $type && $name) ) {
if($system=="yes") {
mysql_query("UPDATE fundraising SET goal='$goal', description='$description' WHERE id='$fundraising_id'");
}
else {
mysql_query("UPDATE fundraising SET goal='$goal', description='$description', type='$type', name='$name' WHERE id='$fundraising_id'");
}
if(mysql_error())
message_push(error(mysql_error()));
else
message_push(happy(i18n("Saved fund changes")));
}
else {
message_push(error(i18n("Required fields were missing, please try again")));
}
}
if($_POST['action']=="fundadd") {
if( $goal && $type && $name) {
mysql_query("INSERT INTO fundraising (type,name,description,system,goal,year) VALUES ('$type','$name','$description','no','$goal','{$config['FAIRYEAR']}')");
message_push(happy(i18n("Added new fund")));
}
else
message_push(error(i18n("Required fields were missing, please try again")));
if(mysql_error())
message_push(error(mysql_error()));
}
?>

View File

@ -23,16 +23,18 @@
?>
<?
include "../common.inc.php";
require_once("../user.inc.php");
user_auth_required('admin');
$ret=array();
foreach($config['languages'] AS $l=>$ln) {
if($l==$config['default_language']) continue;
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
foreach($config['languages'] AS $l=>$ln)
{
if($l=="en") continue;
$q=mysql_query("SELECT * FROM translations WHERE lang='$l' AND strmd5='".md5($_GET['str'])."'");
if($r=mysql_fetch_object($q))
$ret[$l]=$r->val;
echo "$l:$r->val\n";
else
$ret[$l]="";
echo "$l:\n";
}
echo json_encode($ret);
?>

View File

@ -26,121 +26,68 @@
require_once("../user.inc.php");
require_once("../committee.inc.php");
user_auth_required('admin');
user_auth_required('committee','admin');
send_header("Administration",
array('Committee Main' => 'committee_main.php'),
"administration");
if($conference['type']=='sciencefair') {
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
echo " <td><a href=\"registration.php\">".theme_icon("participant_registration")."<br />".i18n("Participant Registration")."</a></td>";
echo " <td><a href=\"committees.php\">".theme_icon("committee_management")."<br />".i18n("Committee Management")."</a></td>";
echo " <td><a href=\"judges.php\">".theme_icon("judging_management")."<br />".i18n("Judging Management")."</a></td>";
echo " <td><a href=\"account_list.php\">".theme_icon("account_management")."<br />".i18n("Account Management")."</a></td>";
echo " <td>";
if($config['volunteer_enable'] == 'yes')
echo "<a href=\"volunteers.php\">".theme_icon("volunteer_management")."<br />".i18n("Volunteer Management")."</a>";
else
echo theme_icon("volunteer_management")."<br />".i18n("Volunteer Management")."<br /><i>(".i18n("disabled").")</i>";
echo "</td></tr>";
echo "</table>\n";
echo "<hr />";
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
echo " <td><a href=\"awards.php\">".theme_icon("awards_management")."<br />".i18n("Awards Management")."</a></td>";
echo " <td><a href=\"schools.php\">".theme_icon("schools_management")."<br />".i18n("Schools Management")."</a></td>";
echo " <td>";
if($config['tours_enable'] == 'yes')
echo "<a href=\"tours.php\">".theme_icon("tour_management")."<br />".i18n("Tour Management")."</a>";
else
echo theme_icon("tour_management")."<br />".i18n("Tour Management")."<br /><i>(".i18n("disabled").")</i>";
echo "</td>";
echo " <td>";
if($config['participant_regfee_items_enable'] == 'yes')
echo "<a href=\"regfee_items_manager.php\">".theme_icon("registration_fee_items_management")."<br />".i18n("Registration Fee Items Management")."</a>";
else
echo theme_icon("registration_fee_items_management")."<br />".i18n("Registration Fee Items Management")."<br /><i>(".i18n("disabled").")</i>";
echo "</td>";
echo " </tr>\n";
echo " <tr>";
echo " <td><a href=\"reports.php\">".theme_icon("print/export_reports")."<br />".i18n("Print / Export Reports")."</a></td>";
echo " <td><a href=\"reports_ceremony.php\">".theme_icon("print_awards_ceremony_scripts")."<br />".i18n("Print Award Ceremony Scripts")."</a></td>";
echo " <td><a href=\"reports_editor.php\">".theme_icon("report_management")."<br />".i18n("Report Management")."</a></td>";
echo " <td><a href=\"translations.php\">".theme_icon("translations_management")."<br />".i18n("Translations Management")."</a></td>";
echo " <td>";
echo "</td>";
echo " </tr>\n";
echo " <tr>";
echo "<td></td><td></td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<hr />";
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
if($config['score_entry_enable'] == 'yes') {
echo "<td><a href=\"judging_score_entry.php\">".theme_icon("judging_score_entry")."<br />".i18n("Judging Score Entry")."</a></td>";
}
echo " <td><a href=\"winners.php\">".theme_icon("enter_winning_projects")."<br />".i18n("Enter Winning Projects")."</a></td>";
echo " <td><a href=\"cwsfregister.php\">".theme_icon("one-click_cwsf_registration")."<br />".i18n("One-Click CWSF Registration")."</a></td>";
echo " <td><a href=\"fair_stats.php\">".theme_icon("fair_stats")."<br />".i18n("Upload Fair Statistics")."</a></td>";
echo " <td><a href=\"user_list.php?show_types[]=fair\">".theme_icon("sciencefair_management")."<br />".i18n("Feeder/Upstream Fair Management")."</a></td>";
echo " </tr>\n";
echo "</table>\n";
}
else {
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
echo " <td><a href=\"eventsscheduling.php\">".theme_icon("events_management")."<br />".i18n("Events & Scheduling")."</a></td>";
echo " <td><a href=\"registration.php\">".theme_icon("participant_registration")."<br />".i18n("Participant Registration")."</a></td>";
echo " <td><a href=\"committees.php\">".theme_icon("committee_management")."<br />".i18n("Committee Management")."</a></td>";
echo " <td><a href=\"judges.php\">".theme_icon("judging_management")."<br />".i18n("Judging Management")."</a></td>";
echo " <td>";
if($config['volunteer_enable'] == 'yes')
echo "<a href=\"volunteers.php\">".theme_icon("volunteer_management")."<br />".i18n("Volunteer Management")."</a>";
else
echo theme_icon("volunteer_management")."<br />".i18n("Volunteer Management")."<br /><i>(".i18n("disabled").")</i>";
echo "</td></tr>";
echo "</table>\n";
echo "<hr />";
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
echo " <td><a href=\"awards.php\">".theme_icon("awards_management")."<br />".i18n("Awards Management")."</a></td>";
echo " <td><a href=\"schools.php\">".theme_icon("schools_management")."<br />".i18n("Schools Management")."</a></td>";
echo " <td>";
if($config['tours_enable'] == 'yes')
echo "<a href=\"tours.php\">".theme_icon("tour_management")."<br />".i18n("Tour Management")."</a>";
else
echo theme_icon("tour_management")."<br />".i18n("Tour Management")."<br /><i>(".i18n("disabled").")</i>";
echo "</td>";
echo " <td>";
if($config['participant_regfee_items_enable'] == 'yes')
echo "<a href=\"regfee_items_manager.php\">".theme_icon("registration_fee_items_management")."<br />".i18n("Registration Fee Items Management")."</a>";
else
echo theme_icon("registration_fee_items_management")."<br />".i18n("Registration Fee Items Management")."<br /><i>(".i18n("disabled").")</i>";
echo "</td>";
echo " </tr>\n";
echo " <tr>";
echo " <td><a href=\"reports.php\">".theme_icon("print/export_reports")."<br />".i18n("Print / Export Reports")."</a></td>";
echo " <td><a href=\"reports_ceremony.php\">".theme_icon("print_awards_ceremony_scripts")."<br />".i18n("Print Award Ceremony Scripts")."</a></td>";
echo " <td><a href=\"reports_editor.php\">".theme_icon("report_management")."<br />".i18n("Report Management")."</a></td>";
echo " <td><a href=\"translations.php\">".theme_icon("translations_management")."<br />".i18n("Translations Management")."</a></td>";
echo " <td>";
echo "</td>";
echo " </tr>\n";
echo " <tr>";
echo "<td></td><td></td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<hr />";
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
echo " <td><a href=\"winners.php\">".theme_icon("enter_winning_projects")."<br />".i18n("Enter Winners")."</a></td>";
echo " </tr>\n";
echo "</table>\n";
}
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
echo " <td><a href=\"registration.php\">".theme_icon("participant_registration")."<br />".i18n("Participant Registration")."</a></td>";
echo " <td><a href=\"committees.php\">".theme_icon("committee_management")."<br />".i18n("Committee Management")."</a></td>";
echo " <td><a href=\"judges.php\">".theme_icon("judging_management")."<br />".i18n("Judging Management")."</a></td>";
echo " <td>";
if($config['volunteer_enable'] == 'yes')
echo "<a href=\"volunteers.php\">".theme_icon("volunteer_management")."<br />".i18n("Volunteer Management")."</a>";
else
echo theme_icon("volunteer_management")."<br />".i18n("Volunteer Management")."<br /><i>(".i18n("disabled").")</i>";
echo '</td></tr><tr>';
echo " <td><a href=\"sciencefairs.php\">".theme_icon("sciencefair_management")."<br />".i18n("Science Fair Management")."</a></td>";
echo '<td></td>';
echo '<td></td>';
echo '<td></td></tr>';
echo "</table>\n";
echo "<hr />";
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
echo " <td><a href=\"awards.php\">".theme_icon("awards_management")."<br />".i18n("Awards Management")."</a></td>";
echo " <td><a href=\"schools.php\">".theme_icon("schools_management")."<br />".i18n("Schools Management")."</a></td>";
echo " <td>";
if($config['tours_enable'] == 'yes')
echo "<a href=\"tours.php\">".theme_icon("tour_management")."<br />".i18n("Tour Management")."</a>";
else
echo theme_icon("tour_management")."<br />".i18n("Tour Management")."<br /><i>(".i18n("disabled").")</i>";
echo "</td>";
echo " <td>";
if($config['participant_regfee_items_enable'] == 'yes')
echo "<a href=\"regfee_items_manager.php\">".theme_icon("registration_fee_items_management")."<br />".i18n("Registration Fee Items Management")."</a>";
else
echo theme_icon("registration_fee_items_management")."<br />".i18n("Registration Fee Items Management")."<br /><i>(".i18n("disabled").")</i>";
echo "</td>";
echo " </tr>\n";
echo " <tr>";
echo " <td><a href=\"reports.php\">".theme_icon("print/export_reports")."<br />".i18n("Print / Export Reports")."</a></td>";
echo " <td><a href=\"reports_ceremony.php\">".theme_icon("print_awards_ceremony_scripts")."<br />".i18n("Print Award Ceremony Scripts")."</a></td>";
echo " <td><a href=\"reports_editor.php\">".theme_icon("report_management")."<br />".i18n("Report Management")."</a></td>";
echo " <td><a href=\"translations.php\">".theme_icon("translations_management")."<br />".i18n("Translations Management")."</a></td>";
echo " <td>";
echo "</td>";
echo " </tr>\n";
echo " <tr>";
echo "<td></td><td></td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<hr />";
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
echo " <td><a href=\"winners.php\">".theme_icon("enter_winning_projects")."<br />".i18n("Enter Winning Projects")."</a></td>";
echo " <td><a href=\"cwsfregister.php\">".theme_icon("one-click_cwsf_registration")."<br />".i18n("One-Click CWSF Registration")."</a></td>";
echo " <td><a href=\"ysfstats.php\">".theme_icon("one-click_ysf_affiliation_stats")."<br />".i18n("One-Click YSF Affiliation Stats")."</a></td>";
echo " <td></td>";
echo " </tr>\n";
echo "</table>\n";
echo "<hr />";
echo "<table class=\"adminconfigtable\">";
echo " <tr>";

View File

@ -1,7 +1,7 @@
<?
function getJudgingTeams()
{
global $config, $conference;
global $config;
$q=mysql_query("SELECT judges_teams.id,
judges_teams.num,
@ -9,7 +9,7 @@ function getJudgingTeams()
FROM
judges_teams
WHERE
judges_teams.conferences_id='".$conference['id']."'
judges_teams.year='".$config['FAIRYEAR']."'
ORDER BY
num,name
");
@ -26,22 +26,6 @@ function getJudgingTeams()
$lastteamid=$r->id;
$lastteamnum=$r->num;
/* Load timeslots */
$rounds = array();
$tq = mysql_query("SELECT * FROM judges_teams_timeslots_link
LEFT JOIN judges_timeslots ON judges_timeslots.id=judges_teams_timeslots_link.judges_timeslots_id
WHERE judges_teams_timeslots_link.judges_teams_id='{$r->id}'");
$teams[$r->id]['timeslots'] = array();
$teams[$r->id]['rounds'] = array();
while($ts = mysql_fetch_assoc($tq)) {
$teams[$r->id]['timeslots'][] = $ts;
$rounds[$ts['round_id']] = $ts['round_id'];
}
foreach($rounds as $round_id) {
$tq = mysql_query("SELECT * FROM judges_timeslots WHERE id='{$round_id}'");
$teams[$r->id]['rounds'][] = mysql_fetch_assoc($tq);
}
//get the members for this team
$mq=mysql_query("SELECT
users.id AS judges_id,
@ -62,43 +46,19 @@ function getJudgingTeams()
echo mysql_error();
$teamlangs=array();
while($mr=mysql_fetch_object($mq))
{
$u = user_load($mr->judges_id, false);
$judgelangs = join('/', $u['languages']);
foreach($u['languages'] AS $l) {
if(!in_array($l,$teamlangs))
$teamlangs[]=$l;
}
$teams[$lastteamid]['members'][]=array(
"id"=>$mr->judges_id,
"firstname"=>$mr->firstname,
"lastname"=>$mr->lastname,
"captain"=>$mr->captain,
"languages"=>$judgelangs,
"languages_array"=>$u['languages']
"languages"=>$judgelangs
);
}
$teams[$r->id]['languages_members']=$teamlangs;
//we also need to add all the languages that the team must JUDGE to the teams languages.
$lq=mysql_query("SELECT projects.language
FROM judges_teams_timeslots_projects_link
LEFT JOIN projects ON judges_teams_timeslots_projects_link.projects_id=projects.id
WHERE judges_teams_timeslots_projects_link.conferences_id='{$conference['id']}' AND
judges_teams_id='$r->id' ");
echo mysql_error();
$projectlangs=array();
while($lr=mysql_fetch_object($lq)) {
if(!in_array($lr->language,$projectlangs))
$projectlangs[]=$lr->language;
if(!in_array($lr->language,$teamlangs))
$teamlangs[]=$lr->language;
}
$teams[$r->id]['languages_projects']=$projectlangs;
$teams[$r->id]['languages']=$teamlangs;
//get the awards for this team
$aq=mysql_query("SELECT award_awards.id,
@ -114,7 +74,7 @@ function getJudgingTeams()
judges_teams_awards_link.award_awards_id=award_awards.id
AND judges_teams_awards_link.judges_teams_id='$r->id'
AND award_awards.award_types_id=award_types.id
AND award_types.conferences_id='{$conference['id']}'
AND award_types.year='{$config['FAIRYEAR']}'
ORDER BY
name
");
@ -143,7 +103,7 @@ function getJudgingTeam($teamid)
FROM
judges_teams
WHERE
judges_teams.conferences_id='".$conference['id']."' AND
judges_teams.year='".$config['FAIRYEAR']."' AND
judges_teams.id='$teamid'
ORDER BY
num,
@ -203,7 +163,7 @@ function getJudgingTeam($teamid)
judges_teams_awards_link.award_awards_id=award_awards.id
AND judges_teams_awards_link.judges_teams_id='$r->id'
AND award_awards.award_types_id=award_types.id
AND award_types.conferences_id='{$conference['id']}'
AND award_types.year='{$config['FAIRYEAR']}'
ORDER BY
name
");
@ -239,28 +199,19 @@ function getJudgingEligibilityCode() {
}
}
function teamMemberToName($member)
{
return $member["firstname"] . " " . $member["lastname"];
}
function judges_load_all()
{
global $config;
$ret = array();
$r = mysql_query("
SELECT users.id FROM users JOIN user_roles ur ON ur.users_id = users.id
JOIN roles ON roles.id = ur.roles_id WHERE roles.type = 'judge'
AND conferences_id='{$conference['id']}'
AND deleted='no'
ORDER BY lastname, firstname
");
$query = "SELECT id FROM users WHERE types LIKE '%judge%'
AND year='{$config['FAIRYEAR']}'
AND deleted='no'";
$r = mysql_query($query);
while($i = mysql_fetch_assoc($r)) {
$u = user_load($i['id']);
if($u['judge_complete'] == 'no') continue;
if($u['judge_active'] == 'no') continue;
$ret[$i['id']] = $u;
}

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
send_header("Judges",
array('Committee Main' => 'committee_main.php',

View File

@ -29,7 +29,7 @@
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
$preferencechoices=array(
-2=>"Very Low",
@ -40,200 +40,57 @@ $preferencechoices=array(
);
$id = intval($_GET['id']);
$judgeinfo = user_load($id);
echo '<div style="text-align:center; padding: 5px;">';
send_popup_header("Judge Information");
$id = intval($_GET['id']);
send_popup_header("Judge Information");
if($id < 1) {
echo error(i18n("No Judge ID passed to Judges Info"));
send_popup_footer();
exit;
}
?>
<table class="tableview" style="margin:auto; width:100%; text-align:left">
<tr>
<th><?=i18n("First Name");?></th>
<th><?=i18n("Last Name");?></th>
<th><?=i18n("Organization");?></th>
</tr>
<tr>
<td><?=$judgeinfo['firstname'];?></td>
<td><?=$judgeinfo['lastname'];?></td>
<td><?=$judgeinfo['organization'];?></td>
</tr>
</table>
$judgeinfo = user_load($id);
<table class="tableview" style="margin:auto; width:100%; margin-top: 5px; text-align:left">
<tr>
<th><?=i18n("Email Address");?>:</th>
<td><?=$judgeinfo['email'];?></td>
<th><?=i18n("City");?>:</th>
<td><?=$judgeinfo['city'];?></td>
</tr>
<tr>
<th><?=i18n("Phone (Home)");?>:</th>
<td><?=$judgeinfo['phonehome'];?></td>
<th><?=i18n("Address 1");?>:</th>
<td><?=$judgeinfo['address'];?></td>
</tr>
<tr>
<th><?=i18n("Phone (Work)");?>:</th>
<td><?=$judgeinfo['phonework'];?></td>
<th><?=i18n("Address 2");?>:</th>
<td><?=$judgeinfo['address2'];?></td>
</tr>
<tr>
<th><?=i18n("Phone (Cell)");?>:</th>
<td><?=$judgeinfo['phonecell'];?></td>
<th><?=i18n($config['provincestate']);?>:</th>
<td><?=$judgeinfo['province'];?></td>
</tr>
<tr>
<th><?=i18n("Languages");?>:</th>
<td><?=join(', ', $judgeinfo['languages']);?></td>
<th><?=i18n($config['postalzip']);?>:</th>
<td><?=$judgeinfo['postalcode'];?></td>
</tr>
</table>
send_popup_header(i18n("Judge Information - %1 %2",array($judgeinfo['firstname'],$judgeinfo['lastname'])));
<?php
echo "Complete for {$config['FAIRYEAR']}: ".(($judgeinfo['complete']=="yes") ? "Yes" : "No");
echo "<br />";
// get their availability
$availabilityText = "";
if($config['judges_availability_enable'] == 'yes'){
$q = mysql_query("SELECT * FROM judges_availability WHERE users_id=\"{$judgeinfo['id']}\" ORDER BY `start`");
$sel = array();
while($r=mysql_fetch_object($q)) {
$st = substr($r->start, 0, 5);
$end = substr($r->end, 0, 5);
$availabilityText .= "<li>$st - $end</li>";
}
if(strlen($availabilityText) > 0){
$availabilityText = '<ul>' . $availabilityText . '</ul>';
}else{
$availabilityText = i18n("Unspecified");
}
}
echo '<div style="text-align:left">';
echo "<h3>".i18n("Personal Info")."</h3>";
echo "<table class=\"viewtable\">\n";
// is their info complete?
$completeText = $judgeinfo['complete']=="yes" ? "Yes" : "No";
// find out if they've signed up for judging any special awards
$specialAwardsText = "";
if($judgeinfo['special_award_only'] == "yes"){
$query = "SELECT aa.name AS awardname FROM judges_specialaward_sel jss"
. " JOIN users ON jss.users_id = users.id"
. " JOIN award_awards aa ON aa.id = jss.award_awards_id"
. " WHERE users.id=" . $id;
$results = mysql_query($query);
while($record = mysql_fetch_array($results)){
$awardList[] = $record['awardname'];
}
$specialAwardsText .= implode(', ', $awardList);
}else{
$specialAwardsText .= i18n("None");
}
// get their preference for age category
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='{$conference['id']}'");
$catPreferenceText = mysql_error() . "<ul>";
while($r=mysql_fetch_object($q)) {
$p = intval($judgeinfo['cat_prefs'][$r->id]);
$catPreferenceText .= "<li><em>" . i18n($r->category)."</em>: {$preferencechoices[$p]}</li>";
}
$catPreferenceText .= "</ul>";
?>
<table class="tableview" style="margin:auto; width:100%; text-align:left; margin-top:5px;">
<tr><td>
<ul>
<li><strong><?="Complete for {$conference['name']}";?>: </strong>
<?=$completeText;?></li>
<li><strong><?=i18n("Special awards");?>: </strong>
<?=$specialAwardsText;?></li>
<li><strong><?=i18n("Highest post-secondary degree");?>: </strong>
<?=$judgeinfo['highest_psd'];?></li>
<li><strong><?=i18n("Age category preference");?>: </strong>
<?=$catPreferenceText;?></li>
<?php
if($availabilityText != ""){
echo "<li><strong>" . i18n("Time Availability") . ": </strong>";
echo $availabilityText . "</li>";
}
?>
</ul>
</td>
<td>
<h3><?=i18n("Areas of Expertise");?></h3>
<table class="tableview" style="margin:auto;width:100%">
<?php
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='{$conference['id']}' ORDER BY id");
$divs=array();
while($r=mysql_fetch_object($q))
{
$divs[]=$r->id;
$divnames[$r->id]=$r->division;
}
foreach($divs as $div)
{
$p = $judgeinfo['div_prefs'][$div];
echo "<tr><th align=\"right\" >".i18n($divnames[$div]).":</th>";
echo " <td>$p/5</td>";
echo "<td>";
$subq=mysql_query("SELECT * FROM projectsubdivisions WHERE
projectdivisions_id='$div' AND conferences_id='{$conference['id']}' ORDER BY subdivision");
$sd = array();
while($subr=mysql_fetch_object($subq)) {
if($u['div_prefs_sub'][$subr->id] == 1) {
$sd[] = $subdivr->subdivision;
}
}
// Only show subdiv if main div >=3
if($p >= 3) echo implode(", ",$sd);
else echo "&nbsp;";
echo "</td>";
echo "</tr>";
}
echo "<tr>\n";
echo " <th align=\"right\" valign=\"top\">".i18n("Other").":</th>";
echo " <td colspan=\"2\">{$judgeinfo['expertise_other']}<br />";
echo " </td>\n";
echo " <th align=\"right\">".i18n("First Name").": </th><td>{$judgeinfo['firstname']}</td>\n";
echo " <th align=\"right\">".i18n("Last Name").":</th><td>{$judgeinfo['lastname']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("Email Address").":</th><td>{$judgeinfo['email']}</td>\n";
echo " <th align=\"right\">".i18n("City").":</th><td>{$judgeinfo['city']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("Address 1").":</th><td>{$judgeinfo['address']}</td>\n";
echo " <th align=\"right\">".i18n($config['provincestate']).": </th><td>{$judgeinfo['province']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("Address 2").":</th><td>{$judgeinfo['address2']}</td>\n";
echo " <th align=\"right\">".i18n("Phone (Home)").":</th><td>{$judgeinfo['phonehome']}</td>\n";
echo "</tr>\n";
?>
</table>
</td></tr>
</table>
<?php
// get the judge's special award info
//print_r($judgeinfo);
echo '</div></div>';
echo "<tr>\n";
echo " <th align=\"right\">".i18n($config['postalzip']).":</th><td>{$judgeinfo['postalcode']}</td>\n";
echo " <th align=\"right\">".i18n("Phone (Work)").":</th><td>{$judgeinfo['phonework']}</td>\n";
echo "</tr>";
/*
send_popup_header("Judge Information");
*/
echo "<tr>\n";
echo " <th align=\"right\">".i18n("Organization").":</th><td>{$judgeinfo['organization']}</td>\n";
echo " <th align=\"right\">".i18n("Phone (Cell)").":</th><td>{$judgeinfo['phonecell']}</td>\n";
echo "</tr>";
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
echo "</table>";
echo "<table>";
/*
echo "<tr>\n";
echo " <th valign=\"top\" align=\"right\" colspan=\"2\">".i18n("Time Availability").":</th><td colspan=\"2\">";
$q = mysql_query("SELECT * FROM judges_availability WHERE users_id=\"{$judgeinfo['id']}\" ORDER BY `start`");
@ -245,9 +102,113 @@ while($r=mysql_fetch_object($q)) {
}
echo "</td></tr>";
echo "<tr>";
echo " <th valign=\"top\" align=\"right\" colspan=\"2\">".i18n("Age category preference").":</th><td colspan=\"2\">";
$q=mysql_query("SELECT * FROM projectcategories
WHERE year='{$config['FAIRYEAR']}'");
echo mysql_error();
while($r=mysql_fetch_object($q)) {
$p = intval($judgeinfo['cat_prefs'][$r->id]);
echo i18n($r->category).": {$preferencechoices[$p]}<br />";
}
echo "</td>\n";
echo "</tr>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\" colspan=\"2\">".i18n("Highest post-secondary degree").":</th>";
echo " <td colspan=\"2\">{$judgeinfo['highest_psd']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\" colspan=\"2\" valign=\"top\">".i18n("Languages").":</th>";
echo " <td colspan=\"2\">".join(', ', $judgeinfo['languages']). "<br />";
echo " </td>\n";
echo "</tr>\n";
//questions_print_answers('judgereg',$judgeinfo['id'], $config['FAIRYEAR']);
echo "</table>";
echo "<hr />";
echo "<br />";
echo "<h3>Areas of Expertise</h3>";
echo "<table class=\"viewtable\">";
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY id");
$divs=array();
while($r=mysql_fetch_object($q))
{
$divs[]=$r->id;
$divnames[$r->id]=$r->division;
}
/*
$subdivq=mysql_query("SELECT judges_expertise.*,
projectsubdivisions.subdivision,
projectsubdivisions.projectdivisions_id AS parent_id
FROM judges_expertise
LEFT JOIN projectsubdivisions ON judges_expertise.projectsubdivisions_id=projectsubdivisions.id
WHERE judges_id='{$judgeinfo['id']}'
AND judges_expertise.year='".$config['FAIRYEAR']."'
ORDER BY projectdivisions_id, projectsubdivisions_id");
echo mysql_error();
$judge_divs=array();
$judge_subdivs=array();
$divdata=array();
*/
/*
while($subdivr=mysql_fetch_object($subdivq))
{
if($subdivr->projectdivisions_id)
{
$judge_divs[$subdivr->projectdivisions_id]=$subdivr->val;
}
else
$judge_subdivs[$subdivr->parent_id][]=$subdivr->subdivision;
}
*/
foreach($divs as $div)
{
$p = $judgeinfo['div_prefs'][$div];
echo "<tr><th align=\"right\" >".i18n($divnames[$div]).":</th>";
echo " <td>$p/5</td>";
echo "<td>";
$subq=mysql_query("SELECT * FROM projectsubdivisions WHERE
projectdivisions_id='$div' AND year='{$config['FAIRYEAR']}' ORDER BY subdivision");
$sd = array();
while($subr=mysql_fetch_object($subq)) {
if($u['div_prefs_sub'][$subr->id] == 1) {
$sd[] = $subdivr->subdivision;
}
}
/* Only show subdiv if main div >=3 */
if($p >= 3) echo implode(", ",$sd);
else echo "&nbsp;";
echo "</td>";
echo "</tr>";
}
echo "<tr>\n";
echo " <th align=\"right\" valign=\"top\">".i18n("Other").":</th>";
echo " <td colspan=\"2\">{$judgeinfo['expertise_other']}<br />";
echo " </td>\n";
echo "</tr>\n";
echo "</table>";
//send_popup_footer();
send_popup_footer();
?>

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
include "judges.inc.php";
send_header("Invite Judges",

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
include "judges.inc.php";
send_header("Judging Division Groupings",
@ -32,9 +32,7 @@
'Administration' => 'admin/index.php',
'Judges' => 'admin/judges.php')
);
echo i18n("Instructions: The goal is to create groupings that have the least number of divisions/categories required to have at least %1 projects in the group. %1 is the number of projects that a single team can judge that you have specifed in the judge scheduler configuration. Judge division groupings indicate which divisions/categories can be judged together (by the same team of judges), so the divisons/categories should be somewhat similar to ensure there are judges that can handle judging all divisions assigned to a grouping.",array($config['max_projects_per_team']));
?>
<script language="javascript" type="text/javascript">
function addbuttonclicked(jdiv)
{
@ -56,14 +54,14 @@ function newbuttonclicked(jdivs)
$div = array();
$divshort = array();
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='".$conference['id']."' ORDER BY id");
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q)) {
$divshort[$r->id]=$r->division_shortform;
$div[$r->id]=$r->division;
}
$cat = array();
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' ORDER BY id");
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q)) {
$cat[$r->id]=$r->category;
}
@ -72,7 +70,7 @@ function newbuttonclicked(jdivs)
$ckeys = array_keys($cat);
if($config['filterdivisionbycategory']=="yes") {
$q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE conferences_id='".$conference['id']."' ORDER BY projectdivisions_id,projectcategories_id");
$q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE year='".$config['FAIRYEAR']."' ORDER BY projectdivisions_id,projectcategories_id");
$divcat=array();
while($r=mysql_fetch_object($q)) {
$divcat[]=array("c"=>$r->projectcategories_id,"d"=>$r->projectdivisions_id);
@ -97,7 +95,7 @@ function newbuttonclicked(jdivs)
function get_all_divs()
{
global $config, $conference;
global $config;
global $divshort, $div,$cat, $langr;
global $divcat;
@ -157,7 +155,7 @@ function get_all_divs()
" projectdivisions_id='{$cdl[$id]['div']}' ".
" AND projectcategories_id='{$cdl[$id]['cat']}' ".
" AND language='{$cdl[$id]['lang']}' ".
" AND registrations.conferences_id='{$conference['id']}'".
" AND registrations.year='{$config['FAIRYEAR']}'".
" AND projects.registrations_id=registrations.id".
" AND (registrations.status='complete' OR registrations.status='paymentpending')");

View File

@ -28,12 +28,7 @@
require_once('../projects.inc.php');
require_once('judges.inc.php');
require_once('anneal.inc.php');
// INFO ONLY: Re Windows OS. I have not found a test that works for both methods of starting this
// SERVER_ADDR is Always null in Windows OS IIS server
// when I launch using judges_sa_launcher_apache.php I could test using SERVER_NAME
// However when I Launch using $WshShell->run($bat_filename,0,false ); for Windows IIS it seems:
// All the $_SERVER variables are set as if were a website page so any variable I have tried will cause a bailout
// THUS.. There is no test I have found to verify this was run from the command line (or in background) for Windows
if($_SERVER['SERVER_ADDR']) {
echo "This script must be run from the command line";
exit;
@ -47,10 +42,6 @@ function TRACE_R($array) { print_r($array); }
TRACE("<pre>");
$round_divisional1 = NULL;
$round_divisional2 = NULL;
function set_status($txt)
{
@ -98,8 +89,7 @@ function judges_cost_function($annealer, $bucket_id, $ids)
{
global $config;
global $jteam;
global $judges, $round_divisional2;
global $judges;
/* Bucket ID is the team number */
/* ids are the judge ids currently in the bucket */
@ -109,12 +99,11 @@ function judges_cost_function($annealer, $bucket_id, $ids)
$cost = 0;
$have_chair = false;
$have_div2 = false;
$years_experience = 0;
if($bucket_id == 0) {
/* This is the placeholder for all judges, there's a slight
* cost for not using a judge */
$cost = count($ids) * 8;
$cost = count($ids) * 5;
// TRACE("Extra judge team cost=$cost\n");
return $cost;
}
@ -129,10 +118,6 @@ function judges_cost_function($annealer, $bucket_id, $ids)
$cost += $min * 50;
$cost += $max * 10;
//add an additional large cost above the minimum requirement cost if the team is completely empty
if($c==0)
$cost+=50;
// TRACE("Under min=$min, over max=$max\n");
/* For each judge on the team, score their preferences */
@ -144,19 +129,15 @@ function judges_cost_function($annealer, $bucket_id, $ids)
for($y=0; $y < count($t['cats']); $y++) {
$l = $t['cats'][$y];
/* Lookup the judge cat pref for this category */
$pref = -$j['cat_prefs'][$l] + 2;
$pref = -$j['catprefs'][$l] + 2;
/* $pref = 0 (best match) --- 4 (worst match) */
//but wait, if they're "indifferent" then we really dont care, so the cost for it shoudl be 0.
if($pref==2) $pref=0;
$cpref += $pref;
}
$dpref = 0;
for($y=0; $y < count($t['divs']); $y++) {
$l = $t['divs'][$y];
/* Lookup the judge cat pref for this category */
$pref = -$j['div_prefs'][$l] + 5;
$pref = -$j['divprefs'][$l] + 2;
/* $pref = 0 (best match) --- 4 (worst match) */
$dpref += $pref;
}
@ -164,10 +145,7 @@ function judges_cost_function($annealer, $bucket_id, $ids)
// TRACE("Judge {$ids[$x]}({$j['name']}) cp=$cpref, dp=$dpref\n");
$cost += 2 * $cpref;
//division matching is more important than category matching
$cost += 3 * $dpref;
// TRACE(" div/cat cost=$cost\n");
$cost += 2 * $dpref;
/* See if the judge is willing to chair a team */
if($j['willing_chair'] == 'yes') $have_chair = true;
@ -176,43 +154,20 @@ function judges_cost_function($annealer, $bucket_id, $ids)
* increase the cost */
for($y=0; $y < count($t['langs']); $y++) {
$l = $t['langs'][$y];
if(!in_array($l, $j['languages'])) $cost += 45;
if(!in_array($l, $j['languages'])) $cost += 25;
}
/* For each additional language that the judge knows that they dont need
* increase the cost, this should hopefully stop the condition where
* it uses up all the bilingual judges for english only teams
* leaving no french/bilingual judges for the french teams */
$tlangs_count=count($t['langs']);
$jlangs_count=count($j['languages']);
if($jlangs_count>$tlangs_count)
$cost+=($jlangs_count-$tlangs_count)*15;
/* If divisional round2 is enabled, make sure there is a judge
* on the team for round2 */
if($j['available_for_divisional2'] == true) $have_div2 = true;
/* Add up the years experience */
$years_experience += $j['years_school'] + $j['years_regional'] + $j['years_national'];
$years_experience_weighted += $j['years_school'] + $j['years_regional']*2 + $j['years_national']*4;
}
/* Huge penalty for a team without a willing chair, but only if the min judges per team >1 */
if(!$have_chair && $config['min_judges_per_team']>1) $cost += 40;
if(!$have_chair && $config['min_judges_per_team']>1)
$cost += 40;
/* Huge penalty for not having a round2 person on the team */
if($round_divisional2 != NULL) {
if($have_div2 == false) $cost += 40;
}
/* Small penalty for a jteam with very little experience,
* but only if there's more than 1 person on the team */
$exp_cost = 0;
if($years_experience_weighted<5 && count($ids)>1) {
$exp_cost += (5-$years_experience_weighted)*2;
}
$cost += $exp_cost;
// TRACE("Experience cost: $exp_cost\n");
if($have_div2 == false)
$cost += 40;
// TRACE("Team $bucket_id, cost is $cost\n");
@ -354,7 +309,7 @@ set_status("Loading Data From Database...");
TRACE("\n\n");
$div = array();
TRACE("Loading Project Divisions...\n");
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='".$conference['id']."' ORDER BY id");
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
{
$divshort[$r->id]=$r->division_shortform;
@ -364,7 +319,7 @@ while($r=mysql_fetch_object($q))
TRACE("Loading Project Age Categories...\n");
$cat = array();
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' ORDER BY id");
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q)) {
$cat[$r->id]=$r->category;
TRACE(" {$r->id} - {$r->category}\n");
@ -379,22 +334,14 @@ while($r=mysql_fetch_object($q)) {
}
TRACE("Loading Judging Round time data...\n");
$round_divisional1 = NULL;
$round_divisional2 = NULL;
$round_special_awards = array();
$round = array();
$q = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='0' AND `conferences_id`='{$conference['id']}'");
$q = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='0' AND `year`='{$config['FAIRYEAR']}'");
/* Loads judges_timeslots.id, .starttime, .endtime, .date, .name */
while($r = mysql_fetch_assoc($q)) {
TRACE(" id:{$r['id']} type:{$r['type']} name:{$r['name']}\n");
$qq = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='{$r['id']}'");
if(mysql_num_rows($qq) == 0) {
echo "ERROR: Round type:{$r['type']} name:{$r['name']} has no judging timeslots! Abort.\n";
exit;
}
while($rr = mysql_fetch_assoc($qq)) {
TRACE(" Timeslot: {$rr['starttime']}-{$rr['endtime']}\n");
$r['timeslots'][] = $rr;
}
$round[] = $r;
if($r['type'] == 'divisional1') $round_divisional1 = $r;
@ -428,7 +375,7 @@ foreach($keys as $jdiv_id) {
if($x > 0) TRACE("\t- ");
TRACE($cat[$d['cat']]." ".$div[$d['div']]." - ".$langr[$d['lang']]);
$qp = mysql_query("SELECT projects.* FROM projects, registrations WHERE ".
" projects.conferences_id='".$conference['id']."' AND ".
" projects.year='".$config['FAIRYEAR']."' AND ".
" projectdivisions_id='{$d['div']}' AND ".
" projectcategories_id='{$d['cat']}' AND ".
" language='{$d['lang']}' AND " .
@ -455,27 +402,27 @@ foreach($keys as $jdiv_id) {
/* Clean out the judging teams that were autocreated in a previous run */
TRACE("Deleting autocreated divisional and special award judging teams:");
$q = mysql_query("SELECT * FROM judges_teams WHERE autocreate_type_id=1 AND conferences_id={$conference['id']}");
$q = mysql_query("SELECT * FROM judges_teams WHERE autocreate_type_id=1 AND year={$config['FAIRYEAR']}");
while($r = mysql_fetch_object($q)) {
$id = $r->id;
print(" $id");
/* Clean out the judges_teams_link */
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$id' AND conferences_id={$conference['id']}");
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$id' AND year={$config['FAIRYEAR']}");
print mysql_error();
/* Awards */
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$id' AND conferences_id={$conference['id']}");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$id' AND year={$config['FAIRYEAR']}");
print mysql_error();
/* Timeslots */
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$id' AND conferences_id={$conference['id']}");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$id' AND year={$config['FAIRYEAR']}");
print mysql_error();
/* Timeslots projects */
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$id' AND conferences_id={$conference['id']}");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$id' AND year={$config['FAIRYEAR']}");
print mysql_error();
}
echo "\n";
/* Finally, delete all the autocreated judges teams */
mysql_query("DELETE FROM judges_teams WHERE autocreate_type_id=1 AND conferences_id={$conference['id']}");
mysql_query("DELETE FROM judges_teams WHERE autocreate_type_id=1 AND year={$config['FAIRYEAR']}");
print mysql_error();
/* Also delete any judges_teams_link that link to teams that dont exist, just
@ -483,7 +430,7 @@ print mysql_error();
$q=mysql_query("SELECT judges_teams_link.id, judges_teams.id AS judges_teams_id
FROM judges_teams_link
LEFT JOIN judges_teams ON judges_teams_link.judges_teams_id=judges_teams.id
WHERE judges_teams_link.conferences_id={$conference['id']}");
WHERE judges_teams_link.year={$config['FAIRYEAR']}");
$n=0;
while($r=mysql_fetch_object($q)) {
if(!$r->judges_teams_id) {
@ -499,7 +446,6 @@ set_status("Loading Judges");
$judges = judges_load_all();
foreach($judges as &$j) {
if($j['judge_active'] == 'no') {
TRACE(" {$j['name']} has their judge profile deactivated, skipping.\n");
@ -514,24 +460,23 @@ foreach($judges as &$j) {
$q = mysql_query("SELECT users_id FROM judges_teams_link WHERE
users_id='{$j['id']}'
AND conferences_id='{$conference['id']}'");
AND year='{$config['FAIRYEAR']}'");
if(mysql_num_rows($q) != 0) {
TRACE(" {$j['name']} is already on a judging team, skipping.\n");
unset($judges[$j['id']]);
continue;
}
if($config['judges_availability_enable']=="yes") {
/* Load the judge time availability */
$q = mysql_query("SELECT * FROM judges_availability WHERE users_id='{$j['id']}' ORDER BY `start`");
if(mysql_num_rows($q) == 0) {
TRACE(" {$j['name']} hasn't selected any time availability, POTENTIAL BUG (they shouldn't be marked as complete).\n");
TRACE(" Ignoring this judge.\n");
unset($judges[$j['id']]);
continue;
}
while($r = mysql_fetch_assoc($q)) {
$j['availability'][] = $r;
}
/* Load the judge time availability */
$q = mysql_query("SELECT * FROM judges_availability WHERE users_id='{$j['id']}' ORDER BY `start`");
if(mysql_num_rows($q) == 0) {
TRACE(" {$j['name']} hasn't selected any time availability, POTENTIAL BUG (they shouldn't be marked as complete).\n");
TRACE(" Ignoring this judge.\n");
unset($judges[$j['id']]);
continue;
}
while($r = mysql_fetch_assoc($q)) {
$j['availability'][] = $r;
}
/* Load special award preferences */
@ -540,7 +485,7 @@ foreach($judges as &$j) {
WHERE
award_awards.id=judges_specialaward_sel.award_awards_id
AND judges_specialaward_sel.users_id='{$j['id']}'
AND award_awards.conferences_id='{$conference['id']}'");
AND award_awards.year='{$config['FAIRYEAR']}'");
echo mysql_error();
if($j['special_award_only'] == 'yes') {
@ -567,23 +512,17 @@ foreach($judges as &$j) {
/* optimization, so the div1 cost function can try to find one
* round2 judge per team */
$j['available_for_divisional2'] = judge_available_for_round($j, $round_divisional2);
$j['available_for_divisional2'] == judge_available_for_round($j, $round_divisional2);
}
unset($j);
TRACE("Loaded ".count($judges)." judges\n");
$jteam[0]['max_judges'] = count($judges);
if(count($judges)==0) {
echo "No judges available. Aborting!\n";
set_status("Error - no judges available...");
set_percent(0);
exit;
}
/* Load the numbers for any user-defined judge teams that already exist,
* these numbers will be off-limits for auto-assigning numbers */
$q = mysql_query("SELECT * FROM judges_teams WHERE conferences_id={$conference['id']}");
$q = mysql_query("SELECT * FROM judges_teams WHERE year={$config['FAIRYEAR']}");
$used_judges_teams_numbers = array();
while($i = mysql_fetch_assoc($q)) {
$used_judges_teams_numbers[] = $i['num'];
@ -612,8 +551,8 @@ function judge_team_create($num, $name)
{
global $config;
$name = mysql_escape_string($name);
mysql_query("INSERT INTO judges_teams (num,name,autocreate_type_id,conferences_id)
VALUES ('$num','$name','1','{$conference['id']}')");
mysql_query("INSERT INTO judges_teams (num,name,autocreate_type_id,year)
VALUES ('$num','$name','1','{$config['FAIRYEAR']}')");
$id = mysql_insert_id();
return $id;
}
@ -622,10 +561,9 @@ function judge_team_add_judge($team_id, $users_id)
{
global $config, $judges;
mysql_query("INSERT INTO judges_teams_link
(users_id,judges_teams_id,captain,conferences_id)
(users_id,judges_teams_id,captain,year)
VALUES ('$users_id','$team_id','{$judges[$users_id]['willing_chair']}',
'{$conferences['id']}')");
echo mysql_error();
'{$config['FAIRYEAR']}')");
}
/****************************************************************************
@ -810,7 +748,7 @@ for($x=1;$x<count($jteam); $x++) {
award_awards_projectcategories,
award_awards_projectdivisions
WHERE
award_awards.conferences_id='{$conference['id']}'
award_awards.year='{$config['FAIRYEAR']}'
AND award_awards.id=award_awards_projectcategories.award_awards_id
AND award_awards.id=award_awards_projectdivisions.award_awards_id
AND award_awards_projectcategories.projectcategories_id='{$cfg['cat']}'
@ -821,7 +759,7 @@ for($x=1;$x<count($jteam); $x++) {
echo error(i18n("Cannot find award for %1 - %2",array($cat[$cfg['cat']],$div[$cfg['div']])));
} else {
$r=mysql_fetch_object($q);
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,conferences_id) VALUES ('$r->id','$team_id','{$conferences['id']}')");
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('$r->id','$team_id','{$config['FAIRYEAR']}')");
/* Add the award ID to the jdiv, if it's not already there */
if(!in_array($r->id, $jdiv[$t['jdiv_id']]['award_ids'])) {
$jdiv[$t['jdiv_id']]['award_ids'][] = $r->id;
@ -844,61 +782,55 @@ for($y=0; $y<count($ids); $y++) {
* - No annealing required
*
***************************************************************************/
echo "Finding round2 carry-over judges:\n";
if($round_divisional2 == NULL) {
echo "No Round 2 Divisional defined, skipping.\n";
} else {
foreach($jdiv as $jdiv_id=>$jd) {
echo "Finding round2 carry-over judges:\n";
$num = next_judges_teams_number();
$team_id = judge_team_create($num, 'Round 2 Divisional '.$jdiv_id);
foreach($jdiv as $jdiv_id=>$jd) {
TRACE("Created Round2 team id $team_id\n");
$num = next_judges_teams_number();
$team_id = judge_team_create($num, 'Round 2 Divisional '.$jdiv_id);
/* Find all the jteams in this jdiv */
for($x=1;$x<count($jteam); $x++) {
$t =& $jteam[$x];
TRACE("Created Round2 team id $team_id\n");
if($t['jdiv_id'] != $jdiv_id) continue;
/* Find all the jteams in this jdiv */
for($x=1;$x<count($jteam); $x++) {
$t =& $jteam[$x];
TRACE(" Round1 team #{$t['num']} ({$t['id']})\n");
if($t['jdiv_id'] != $jdiv_id) continue;
$rep_id = NULL;
$chair_rep = false;
TRACE(" Round1 team #{$t['num']} ({$t['id']})\n");
$rep_id = NULL;
$chair_rep = false;
/* We would like the willing_chair to be the person that sticks around
* for round2, but if that's not possible, prefer anyone on the jteam be
* around for round2 */
foreach($t['judge_ids'] as $judge_id) {
$j =& $judges[$judge_id];
if(judge_available_for_round($j, $round_divisional2)) {
if($j['willing_chair'] == true) {
$rep_id = $judge_id;
$chair_rep = true;
break;
} else if($chair_rep == false) {
$rep_id = $judge_id;
}
/* We would like the willing_chair to be the person that sticks around
* for round2, but if that's not possible, prefer anyone on the jteam be
* around for round2 */
foreach($t['judge_ids'] as $judge_id) {
$j =& $judges[$judge_id];
if(judge_available_for_round($j, $round_divisional2)) {
if($j['willing_chair'] == true) {
$rep_id = $judge_id;
$chair_rep = true;
break;
} else if($chair_rep == false) {
$rep_id = $judge_id;
}
}
if($rep_id != NULL) {
pr_judge($t, $rep_id);
/* Mark this judge as used in this round */
judge_mark_for_round($judges[$rep_id], $round_divisional2);
/* Write it to the DB */
judge_team_add_judge($team_id, $rep_id);
} else {
echo "WARNING: Team $x has no carryover judge.\n";
}
}
if($rep_id != NULL) {
pr_judge($t, $rep_id);
/* Mark this judge as used in this round */
judge_mark_for_round($judges[$rep_id], $round_divisional2);
/* Write it to the DB */
judge_team_add_judge($team_id, $rep_id);
} else {
echo "WARNING: Team $x has no carryover judge.\n";
}
}
/* Assign all the awards in this jdiv */
foreach($jd['award_ids'] as $aid) {
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,conferences_id) VALUES ('$aid','$team_id','{$conference['id']}')");
}
/* Assign all the awards in this jdiv */
foreach($jd['award_ids'] as $aid) {
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('$aid','$team_id','{$config['FAIRYEAR']}')");
}
}
@ -978,15 +910,11 @@ function judges_sa_cost_function($annealer, $bucket_id, $ids)
}
$cost += 5 * $apref;
}
// TRACE("Team $bucket_id, cost is $cost\n");
return $cost;
}
if($config['scheduler_enable_sa_scheduling'] == 'yes') {
TRACE("Finding judges for special award round(s)\n");
@ -996,14 +924,17 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
$total_judges = 0;
foreach($judges as &$j) {
TRACE(" {$j['firstname']} {$j['lastname']}\n");
foreach($round_special_awards as &$r) {
if(judge_available_for_round($j, $r) == true) {
TRACE(" {$r['name']} yes\n");
$r['available_judge_ids'][] = $j['id'];
$total_judges++;
} else {
TRACE(" {$r['name']} no\n");
if($j['special_award_only'] == 'yes') {
for($i=0;$i<count($j['special_awards']);$i++) {
$r['available_judge_ids'][] = $j['id'];
$total_judges++; /* It's ok to count the same judge twice */
}
} else {
$r['available_judge_ids'][] = $j['id'];
$total_judges++; /* It's ok to count the same judge twice */
}
}
}
}
@ -1015,10 +946,10 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
/* Load special awards */
$q = "SELECT award_awards.name,award_awards.id FROM award_awards,award_types
WHERE
award_awards.conferences_id='{$conference['id']}'
award_awards.year='{$config['FAIRYEAR']}'
AND award_types.id=award_awards.award_types_id
AND award_awards.schedule_judges='yes'
AND award_types.conferences_id='{$conference['id']}'
AND award_types.year='{$config['FAIRYEAR']}'
AND award_types.type='Special'
";
$r = mysql_query($q);
@ -1039,14 +970,15 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
/* Construct an internal team for annealing, and create
* a DB team too */
$pids = array_keys($projects);
$sa_jteam[$x]['num'] = next_judges_teams_number();
$sa_jteam[$x]['id'] = judge_team_create($sa_jteam[$x]['num'], $i->name);
/* Note, we use $x instead of the ID, because the DB id could be zero. */
$sa_jteam[$x]['projects'] = $projects;
$sa_jteam[$x]['projects'] = $pids;
$sa_jteam[$x]['round'] = NULL;
$sa_jteam[$x]['sub'] = 0;
$sa_jteam[$x]['langs'] = array();
$min = floor(count($projects) / $config['projects_per_special_award_judge']) + 1;
$min = floor(count($pids) / $config['projects_per_special_award_judge']) + 1;
$sa_jteam[$x]['min_judges'] = $min;
$sa_jteam[$x]['max_judges'] = $min;
$sa_jteam[$x]['award_ids'] = array($i->id);
@ -1055,10 +987,10 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
$required_judges += $min;
/* Link the award to this team */
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,conferences_id)
VALUES ('{$i->id}','{$sa_jteam[$x]['id']}','{$conference['id']}')");
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year)
VALUES ('{$i->id}','{$sa_jteam[$x]['id']}','{$config['FAIRYEAR']}')");
TRACE("Created Team: {$i->name}, ".count($projects)." projects => $min judges needed (db id:{$sa_jteam[$x]['id']}) \n");
TRACE("Created Team: {$i->name}, $min judges needed (db id:{$sa_jteam[$x]['id']}) \n");
$x++;
}
TRACE("Total Judges: $total_judges, Required: $required_judges\n");
@ -1111,6 +1043,7 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
}
}
}
}
/* If there are no SA-only judges, skip the pre-assignment */
@ -1131,14 +1064,6 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
$round_special_awards[$highest_offset]['assigned_judges'] += $jt['min_judges'];
TRACE("Pre-assigning Team {$jt['name']} to Round {$round_special_awards[$highest_offset]['name']}\n");
$jt['assigned'] = true;
/* If the max judges for the jteam is less than the max, update the max,
* this prevents the scheduler from trying to remove sa-only judges
* from the jteam because of the over-max cost penalty */
if($jt['max_judges'] < count($sa_judges)) {
TRACE(" Changing max_judges to ". count($sa_judges)." to accomodate all SA-only judge requests.\n");
$jt['max_judges'] = count($sa_judges);
}
}
unset($jt);
@ -1169,43 +1094,7 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
/* Assign this jteam id to the special award round */
$round_special_awards[$highest_offset]['jteam_ids'][] = $x;
$round_special_awards[$highest_offset]['assigned_judges'] += $jt['min_judges'];
TRACE("Assigned Team {$jt['name']} to Round {$round_special_awards[$highest_offset]['name']}\n");
}
unset($jt);
/* Now that teams have been assigned to rounds, search for all the
* SA only judges again, and duplicate the available judge id if they are signed
* up to judge more than one award in the round */
foreach($judges as &$j) {
if($j['special_award_only'] == 'no') continue;
foreach($round_special_awards as &$r) {
$count = 0;
if(judge_available_for_round($j, $r) == false) continue;
/* Find out how many of their special awards are in this round. */
foreach($sa_jteam as $jt_id=>&$jt) {
/* Is the team in this round? */
if(!in_array($jt_id, $r['jteam_ids'])) continue;
/* Is this SA judge requsing an award judged by this team? */
foreach($jt['award_ids'] as $aid) {
if(in_array($aid, $j['special_awards']))
$count++;
}
}
unset($jt);
while($count > 1) {
$r['available_judge_ids'][] = $j['id'];
$count--;
TRACE(" Duplicate {$j['firstname']} {$j['lastname']} for multiple SA-only request in round {$r['name']}\n");
}
}
unset($r);
}
unset($j);
/* Now, anneal in each special award round */
foreach($round_special_awards as $r) {
@ -1213,7 +1102,6 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
$current_jteam_ids = $r['jteam_ids'];
$judge_ids = $r['available_judge_ids'];
$e = $config['effort'];
$a = new annealer(count($r['jteam_ids']), 25, $e, 0.98,
judges_sa_cost_function, $judge_ids);
@ -1225,7 +1113,6 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
unset($t);
unset($tid);
foreach($r['jteam_ids'] as $tid) {
if($tid == 0) {
$x++;
@ -1245,19 +1132,6 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
print("$langstr)");*/
print("\n");
/* Do timeslot and project timeslot assignment */
mysql_query("INSERT INTO judges_teams_timeslots_link
(judges_teams_id,judges_timeslots_id,conferences_id)
VALUES ('{$t['id']}', '{$r['timeslots'][0]['id']}', '{$conference['id']}')");
echo mysql_error();
foreach($t['projects'] as $proj) {
$pid = $proj['id'];
mysql_query("INSERT INTO judges_teams_timeslots_projects_link
(judges_teams_id,judges_timeslots_id,projects_id,conferences_id)
VALUES ('{$t['id']}', '{$r['timeslots'][0]['id']}', '$pid', '{$conference['id']}')");
echo mysql_error();
}
$ids = $a->bucket[$x];
foreach($a->bucket[$x] as $jid) {
// pr_judge($t, $ids[$y]);
@ -1288,7 +1162,7 @@ $available_timeslots=array();
$q=mysql_query("SELECT * FROM judges_timeslots WHERE
round_id='{$round_divisional1['id']}'
AND conferences_id='{$conference['id']}'
AND year='{$config['FAIRYEAR']}'
AND type='timeslot'
ORDER BY date,starttime");
$x=0;
@ -1430,7 +1304,7 @@ for($k=0; $k<$keys_count; $k++) {
print_r($jteams_ids);
*/
print("Jteams ids len=".count($jteams_ids));
print("n_timeslots=$n_timeslots\n");
print("\n");
set_percent(50 + ($k / $keys_count) * 50);
@ -1457,16 +1331,16 @@ for($k=0; $k<$keys_count; $k++) {
/* if jteam_id isn't 0, instert it into the db */
mysql_query("INSERT INTO judges_teams_timeslots_link ".
" (judges_teams_id,judges_timeslots_id,conferences_id)".
" (judges_teams_id,judges_timeslots_id,year)".
" VALUES ('{$jteam[$jteam_id]['team_id']}', ".
" '{$available_timeslots[$y]['id']}', ".
" '{$conference['id']}')");
" '{$config['FAIRYEAR']}')");
mysql_query("INSERT INTO judges_teams_timeslots_projects_link ".
" (judges_teams_id,judges_timeslots_id,projects_id,conferences_id) ".
" (judges_teams_id,judges_timeslots_id,projects_id,year) ".
" VALUES ('{$jteam[$jteam_id]['team_id']}', ".
" '{$available_timeslots[$y]['id']}', ".
" '$pid', '{$conference['id']}')");
" '$pid', '{$config['FAIRYEAR']}')");
}
printf("\n");

View File

@ -1,55 +1,6 @@
<?
require_once('../common.inc.functions.php');
$logPath = get_logpath();
// Check which OS we are running
$pos = strpos(getcwd(),'/');
if($pos === false)
{
// Windows os server.
// if IIS Web Server use WScript.Shell 'run' command and.. we need a batch file to start a process and return immediately
$bat_filename = "../data/judges_sa.bat";
if(file_exists($bat_filename)){
// delete the batch file then re-create it with the current date
unlink($bat_filename);
}
$bat_file = fopen($bat_filename, "w");
if($bat_file) {
fwrite($bat_file, "ECHO OFF"."\n");
fwrite($bat_file, "START /BELOWNORMAL /B php judges_sa.php >$logPath/judge_scheduler_".date("YmdHis").".log 2>&1 &"."\n");
fwrite($bat_file, "EXIT"."\n");
fclose($bat_file);
}
$WshShell = new COM("WScript.Shell");
// next line designed for Windows os with IIS web server. It will probably fail if Windows using apache web server
try {
$oExec = $WshShell->run($bat_filename,0,false ); // THIS SHOULD WORK for windows using IIS as webserver.
}
catch (Exception $e) {
// if the wshshell-> run fails then we are perhaps running an apache server and the next might work.
// But, the call in judges_sa_launcher_apache.php does not return until completed so I use this logic
// to inform the user how to get to the status page.
// CAUTION: This path REQUIRES that php be compiled with CLI option and other things Dennis does not understand!
// This may work for some servers. NEVER use this on a shared server - you will hog it and get your account suspended.
echo " This server requires manual intervention to start the scheduler and to navigate to the Status page.<br/>";
echo " The scheduler will run at normal priority - which in some servers may present a sluggish response.<br />";
echo " Please follow these instruction exactly:<br />";
echo " 1. Click 'Start the Scheduler' link ONCE. (You will not see any change in this screen) <br />";
echo " *** DO NOT Click 'Start the Scheduler' more than once!<br />";
echo " 2. Click 'Check the Status' link and wait. (You will be taken to the Status Page. There, you should see that the scheduler is running.) <br />";
echo "<br /><a href=\"judges_sa_launcher_apache.php\">Start the Scheduler</a><br /><br />";
echo "<a href=\"judges_scheduler_status.php\">Check the Status</a><br />";
exit;
// This is the call that works - but it does not return until judges_sa is finished so... I launch it from another window
// exec("php judges_sa.php >$logPath/judge_scheduler_".date("YmdHis").".log 2>&1 &");
}
}
else{
// *nix server
//add PHP_SELF just so when we do a process listing on the server we know which fair its running for
//the argument does not get used by the script at all
exec("nice php judges_sa.php {$_SERVER['PHP_SELF']} > $logPath/judge_scheduler_".date("YmdHis").".log 2>&1 &");
}
usleep(1500000); // 1.5 second to allow the judges_sa to update the % status to 0% otherwise the status page will think its not running if it gets there too soon
exec("nice php judges_sa.php >/dev/null 2>&1 &");
usleep(1000000); // 1 second to allow the judges_sa to update the % status to 0% otherwise the status page will think its not running if it gets there too soon
header("Location: judges_scheduler_status.php");
exit;
?>

View File

@ -1,8 +0,0 @@
<?php
require_once('../common.inc.functions.php');
$logPath = get_logpath();
// In Windows OS with Apache server this exec call will start judges_sa.php as a separate process but the call to exec() does not return until the scheduler completes. Note the process runs at normal priority. Status can be checked with judges_scheduler_status.php. This is a temporary solution for Windows / Apache
exec("php judges_sa.php >$logPath/judge_scheduler_".date("YmdHis").".log 2>&1 &");
exit;
?>

View File

@ -29,6 +29,7 @@ ogram; see the file COPYING. If not, write to
'Administration' => 'admin/index.php',
'Judges' => 'admin/judges.php')
);
require_once("../ajax.inc.php");
?>
<script type="text/javascript">
@ -40,29 +41,46 @@ var avgtimeperpercent=0;
var remainingpercent=0;
var remainingtime=0;
$(document).ready(function() {
updateStatus();
});
function updateStatus() {
function updateStatus()
{
document.getElementById('updatestatus').innerHTML="Updating...";
var url="judges_scheduler_status_output.php";
$("#updatestatus").html("Updating...");
$.get(url,null,function(data) {
var obj=data.split(":");
$("#schedulerstatus").html(obj[1]);
if(obj[0]=="-1") {
$("#schedulerpercent").html("100%");
$("#updatestatus").html("Scheduling Complete");
$("#schedulereta").html("Complete");
http.open("GET",url,true);
http.readystate=0;
http.onreadystatechange=handleResponse;
http.send(null);
}
function clearUpdatingMessage()
{
document.getElementById('updatestatus').innerHTML="Waiting...";
}
function handleResponse()
{
try {
if(http.readyState==4)
{
var obj=http.responseText.split(":");
document.getElementById('schedulerstatus').innerHTML=obj[1];
if(obj[0]=="-1")
{
document.getElementById('schedulerpercent').innerHTML="100%";
document.getElementById('updatestatus').innerHTML="Scheduling Complete";
document.getElementById('schedulereta').innerHTML="Complete";
}
else {
$("#schedulerpercent").html(obj[0]+"%");
else
{
document.getElementById('schedulerpercent').innerHTML=obj[0]+"%";
setTimeout('updateStatus()',5000);
$("#updatestatus").html("Updating... Done!");
document.getElementById('updatestatus').innerHTML="Updating... Done!";
setTimeout('clearUpdatingMessage()',500);
var currentTime=new Date();
if(starttime==0) {
if(starttime==0)
{
starttime=currentTime.getTime();
startpercent=obj[0];
}
@ -72,68 +90,33 @@ function updateStatus() {
avgtimeperpercent=deltatime/deltapercent;
remainingpercent=100-obj[0];
remainingtime=remainingpercent*avgtimeperpercent;
if(remainingtime>0 && remainingtime!="Infinity" && obj[0]>0) {
$("#schedulereta").html(format_duration(Math.round(remainingtime/1000)));
}
if(remainingtime && obj[0]>0)
document.getElementById('schedulereta').innerHTML=Math.round(remainingtime/1000)+" seconds";
else
$("#schedulereta").html("Calculating...");
document.getElementById('schedulereta').innerHTML="Calculating...";
}
});
}
function clearUpdatingMessage() {
$("#updatestatus").html("Waiting...");
}
function format_duration(seconds) {
/*
'1 year|:count years' => 31536000,
'1 week|:count weeks' => 604800,
'1 day|:count days' => 86400,
'1 hour|:count hours' => 3600,
'1 min|:count min' => 60,
'1 sec|:count sec' => 1);
*/
var s=seconds;
var output='';
var pl='';
if(s>86400) {
var days=Math.floor(s/86400)
s-=days*86400;
if(days>1) pl='s'; else pl='';
output+=days+' day'+pl+' ';
}
}
if(s>3600) {
var hours=Math.floor(s/3600)
s-=hours*3600;
if(hours>1) pl='s'; else pl='';
output+=hours+' hour'+pl+' ';
catch(e)
{
alert('caught error'+e);
}
if(s>60) {
var minutes=Math.floor(s/60)
s-=minutes*60;
if(minutes>1) pl='s'; else pl='';
output+=minutes+' minute'+pl+' ';
}
if(s>1) pl='s'; else pl='';
output+=s+' second'+pl
return output;
}
</script>
<?
if($config['judge_scheduler_percent']=="-1") {
if($config['judge_scheduler_percent']=="-1")
{
echo i18n("The judge scheduler is not currently running");
echo "<br />";
echo "<br />";
echo "<a href=\"judges_schedulerconfig.php\">".i18n("Judges Scheduler Configuration")."</a>";
}
else {
else
{
echo "<table>";
echo "<tr><td>".i18n("Scheduler status").":</td><td><div id=\"schedulerstatus\" style=\"font-weight: bold;\"></div></td></tr>";
echo "<tr><td>".i18n("Scheduler percent").":</td><td><div id=\"schedulerpercent\" style=\"font-weight: bold;\"></div></td></tr>";
@ -151,7 +134,10 @@ echo "<br />";
echo "<a href=\"reports.php\">".i18n("Print/Export Reports")."</a>";
echo "<br />";
echo "<br />";
echo "Note: If you are using Windows Internet Explorer and do not see status updates do this:<br /> Click menu bar 'Tools' then 'Internet Options'.<br /> In the 'General' Tab under 'Browsing history' click 'Settings'.<br /> Under 'Check for newer versions of stored pages:'<br /> Select the option 'Every time I visit the webpage'.<br /> Click OK then OK";
P
?>
<script type="text/javascript">updateStatus()</script>
<?
}
send_footer();

View File

@ -1,6 +1,6 @@
<?
include "../data/config.inc.php";
mysql_connect($DBHOST,substr($DBUSER,0,16),$DBPASS);
mysql_connect($DBHOST,$DBUSER,$DBPASS);
mysql_select_db($DBNAME);
$q=mysql_query("SELECT val FROM config WHERE year='0' AND var='judge_scheduler_percent'");
$r=mysql_fetch_object($q);

View File

@ -26,11 +26,11 @@ ogram; see the file COPYING. If not, write to
require("../common.inc.php");
require_once("../user.inc.php");
require("../config_editor.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
require("judges.inc.php");
require("judges_schedulerconfig_check.inc.php");
$action = config_editor_handle_actions("Judge Scheduler", $conference['id'], "var");
$action = config_editor_handle_actions("Judge Scheduler", $config['FAIRYEAR'], "var");
if($action == 'update') {
header("Location: judges_schedulerconfig.php");
exit;
@ -43,7 +43,7 @@ ogram; see the file COPYING. If not, write to
'Judges' => 'admin/judges.php')
);
config_editor("Judge Scheduler", $conference['id'], "var", $_SERVER['PHP_SELF']);
config_editor("Judge Scheduler", $config['FAIRYEAR'], "var", $_SERVER['PHP_SELF']);
echo "<hr />";
if($_GET['action']=="reset")
@ -70,16 +70,6 @@ if($config['judge_scheduler_percent']=="-1")
$ok = 0;
}
if($config['scheduler_enable_sa_scheduling'] == 'yes') {
$timeslots = judges_scheduler_check_timeslots_sa();
if($timeslots > 0) {
echo happy(i18n("There are %1 timeslot(s) defined for special awards judging, good", array($timeslots)));
} else {
echo error(i18n("There are no timeslots defined for special awards judging (but the scheduler is configured to do special awards judging)"));
$ok = 0;
}
}
echo "<table class='headertable'><tr><td><h3>Awards</h3></td>";
echo "<td> - <a href=\"awards.php\">".i18n("Awards Manager")."</a>";
echo "</td></tr></table>";
@ -128,12 +118,6 @@ if($ok)
echo "<a href=\"judges_sa_launcher.php\">".i18n("Start the judging scheduler to create judging teams and judging schedule")."</a>";
}
else {
echo "<br />";
echo "<br />";
echo "<a href=\"judges_sa_launcher.php\">".i18n("Something above looks bad, but you can start the judging scheduler anyways with the understanding that results will NOT be optimal, or in fact, the scheduler may not work at all!")."</a>";
}
}
else

View File

@ -2,46 +2,25 @@
function judges_scheduler_check_timeslots()
{
global $conference;
global $config;
$q=mysql_query("SELECT * FROM judges_timeslots WHERE ".
" conferences_id='".$conference['id']."'".
" year='".$config['FAIRYEAR']."'".
" AND `type`='divisional1'" );
if(mysql_num_rows($q)) {
$round=mysql_fetch_object($q);
$q=mysql_query("SELECT * FROM judges_timeslots WHERE round_id='$round->id' AND type='timeslot'");
return mysql_num_rows($q);
}
else
return 0;
}
$rows = mysql_num_rows($q);
function judges_scheduler_check_timeslots_sa()
{
global $conference;
$rows = 0;
$q=mysql_query("SELECT * FROM judges_timeslots WHERE ".
" conferences_id='".$conference['id']."'".
" AND `type`='special'" );
if(mysql_num_rows($q)) {
while(( $round=mysql_fetch_object($q))) {
$rq=mysql_query("SELECT * FROM judges_timeslots WHERE round_id='$round->id' AND type='timeslot'");
$rows += mysql_num_rows($rq);
}
}
return $rows;
}
function judges_scheduler_check_awards()
{
global $config, $conferenece;
global $config;
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='".$conference['id']."' ORDER BY id");
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
$div[$r->id]=$r->division;
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' ORDER BY id");
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
$cat[$r->id]=$r->category;
@ -49,7 +28,7 @@ function judges_scheduler_check_awards()
$ckeys = array_keys($cat);
if($config['filterdivisionbycategory']=="yes") {
$q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE conferences_id='".$conference['id']."' ORDER BY projectdivisions_id,projectcategories_id");
$q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE year='".$config['FAIRYEAR']."' ORDER BY projectdivisions_id,projectcategories_id");
$divcat=array();
while($r=mysql_fetch_object($q)) {
$divcat[]=array("c"=>$r->projectcategories_id,"d"=>$r->projectdivisions_id);
@ -75,9 +54,9 @@ function judges_scheduler_check_awards()
award_awards_projectcategories,
award_awards_projectdivisions
WHERE
award_awards.conferences_id='{$conference['id']}'
AND award_awards_projectcategories.conferences_id='{$conference['id']}'
AND award_awards_projectdivisions.conferences_id='{$conference['id']}'
award_awards.year='{$config['FAIRYEAR']}'
AND award_awards_projectcategories.year='{$config['FAIRYEAR']}'
AND award_awards_projectdivisions.year='{$config['FAIRYEAR']}'
AND award_awards.id=award_awards_projectcategories.award_awards_id
AND award_awards.id=award_awards_projectdivisions.award_awards_id
AND award_awards_projectcategories.projectcategories_id='$c'
@ -95,6 +74,8 @@ function judges_scheduler_check_awards()
function judges_scheduler_check_jdivs()
{
global $config;
$q=mysql_query("SELECT DISTINCT jdiv_id FROM judges_jdiv ");
$rows = mysql_num_rows($q);
@ -104,7 +85,7 @@ function judges_scheduler_check_jdivs()
function judges_scheduler_check_judges()
{
global $config, $conference;
global $config;
$ok = 1;
$jdiv = array();
@ -118,7 +99,7 @@ function judges_scheduler_check_judges()
$l = $r->lang;
$qp = mysql_query("SELECT COUNT(projects.id) as cnt FROM projects, registrations WHERE ".
" projects.conferences_id='".$conference['id']."' AND ".
" projects.year='".$config['FAIRYEAR']."' AND ".
" projectdivisions_id='$d' AND ".
" projectcategories_id='$c' AND ".
" language='$l' AND " .
@ -127,120 +108,53 @@ function judges_scheduler_check_judges()
);
$qr = mysql_fetch_object($qp);
$jdiv[$r->jdiv_id]['num_projects']['total'] += $qr->cnt;
$jdiv[$r->jdiv_id]['num_projects'][$l] += $qr->cnt;
$projectlanguagetotal[$l]+=$qr->cnt;
$projecttotal+=$qr->cnt;
$jdiv[$r->jdiv_id]['num_projects'] += $qr->cnt;
}
$totalteams['total'] = 0;
echo "<table border=1 width=\"85%\"><tr><th></th>".
"<th colspan=\"".(count($config['languages'])+1)."\">".i18n("Projects")."</th>".
"<th colspan=\"".(count($config['languages'])+1)."\">".i18n("Estimated Required Teams")."</th></tr>";
$totalteams = 0;
print("<table width=75%><tr><th></th>".
"<th>".i18n("Projects")."</th>".
"<th>".i18n("Required Teams")."</th></tr>");
$keys = array_keys($jdiv);
for($k=0; $k<count($keys); $k++) {
$jdiv_id = $keys[$k];
$c = $jdiv[$jdiv_id]['num_projects'];
$t=ceil($c/$config['max_projects_per_team']*$config['times_judged']);
if($t < $config['times_judged'] && $c>0) $t = $config['times_judged'];
$jdiv[$jdiv_id]['num_jteams'] = $t;
$totalteams+=$t;
echo "<tr>";
echo "<th></th><th>".i18n("Total")."</th>";
foreach($config['languages'] AS $lkey=>$lname)
echo "<th>$lkey</th>";
echo "<th>".i18n("Total")."</th>";
foreach($config['languages'] AS $lkey=>$lname)
echo "<th>$lkey</th>";
echo "</tr>\n";
foreach($jdiv AS $jdiv_id=>$jd) {
$c = $jd['num_projects']['total'];
//total judge teams calculation
$t['total']=ceil($c/$config['max_projects_per_team']*$config['times_judged']);
if($t['total'] < $config['times_judged'] && $c>0) $t['total'] = $config['times_judged'];
$jdiv[$jdiv_id]['num_jteams']['total'] = $t['total'];
$totalteams['total']+=$t['total'];
//language teams calculation
foreach($config['languages'] AS $lkey=>$lname) {
$c = $jd['num_projects'][$lkey];
$t['total_'.$lkey]=ceil($c/$config['max_projects_per_team']*$config['times_judged']);
if($t['total_'.$lkey] < $config['times_judged'] && $c>0) $t['total_'.$lkey] = $config['times_judged'];
$jdiv[$jdiv_id]['num_jteams']['total_'.$lkey] = $t['total_'.$lkey];
$totalteams['total_'.$lkey]+=$t['total_'.$lkey];
}
echo "<tr><td>Judging Division Group $jdiv_id</td>";
echo "<td align=\"center\">$c</td>";
$langstr="";
foreach($config['languages'] AS $lkey=>$lname) {
$clang=($jd['num_projects'][$lkey]?$jd['num_projects'][$lkey]:0);
echo "<td align=\"center\">$clang</td>";
}
echo "<td align=\"center\">{$t['total']}</td>";
foreach($config['languages'] AS $lkey=>$lname) {
$clang=($jd['num_projects'][$lkey]?$jd['num_projects'][$lkey]:0);
//echo "<td align=\"center\">{$t['total']}</td>";
echo "<td align=\"center\">{$t['total_'.$lkey]}</td>";
}
echo "</tr>";
print("<tr><td>Judging Division Group $jdiv_id</td><td align=center>$c</td><td align=center>$t</td></tr>");
}
echo "</table>";
print("</table>");
echo "<br />";
echo "<b>";
echo i18n("Total judging teams required: %1",array($totalteams['total']));
echo "Total judging teams required: $totalteams";
echo "<br />";
$minjudges=($totalteams*$config['min_judges_per_team']);
$maxjudges=($totalteams*$config['max_judges_per_team']);
echo "Minimum number of judges required: $minjudges";
echo "<br />";
$minjudges['total']=($totalteams['total']*$config['min_judges_per_team']);
$maxjudges['total']=($totalteams['total']*$config['max_judges_per_team']);
echo i18n("Minimum number of judges required: %1",array($minjudges['total']))."<br />";
foreach($config['languages'] AS $lkey=>$lname) {
if($minjudges['total'] && $projecttotal)
$minjudges[$lkey]=round($totalteams['total_'.$lkey]*$config['min_judges_per_team']); //$projectlanguagetotal[$lkey]/$projecttotal*$minjudges['total']);
else
$minjudges[$lkey]=0;
echo "&nbsp;&nbsp; ".i18n("Minimum number of %1 judges required: %2",array($lname,$minjudges[$lkey]))."<br />";
}
echo i18n("Maximum number of judges needed: %1",array($maxjudges['total']));
echo "<br />";
echo "Maximum number of judges acceptable: $maxjudges";
echo "<br />";
/* $jq=mysql_query("SELECT COUNT(judges.id) AS num FROM judges,judges_years WHERE complete='yes' AND deleted='no' AND judges_years.conferences_id='{$conference['id']}' AND judges_years.judges_id=judges.id");
/* $jq=mysql_query("SELECT COUNT(judges.id) AS num FROM judges,judges_years WHERE complete='yes' AND deleted='no' AND judges_years.year='{$config['FAIRYEAR']}' AND judges_years.judges_id=judges.id");
$jr=mysql_fetch_object($jq);
$currentjudges=$jr->num;*/
/* FIXME: this his highly inefficient :), but won't be done very often */
$judges = judges_load_all();
$currentjudges = count($judges);
echo "Current number of registered judges: $currentjudges";
echo "</b>";
echo "<br />";
if($currentjudges<$minjudges['total']) {
echo error(i18n("You do not have sufficient number of total judges based on your parameters"));
$ok=false;
}
foreach($config['languages'] AS $lkey=>$lname) {
$lcount=0;
foreach($judges AS $j) {
foreach($j['languages'] AS $jlang) {
if($jlang==$lkey) $lcount++;
}
}
$currentjudges=$lcount;
echo "&nbsp;&nbsp;<b>".i18n("Current number of registered judges that can judge in %1: %2",array($lname,$currentjudges))."</b>";
echo "<br />";
if($currentjudges<$minjudges[$lkey]) {
echo error(i18n("You do not have sufficient number of %1 judges based on your parameters",array($lname)));
$ok=false;
}
}
if(!$ok) {
echo "<br />";
echo "</b>";
if($currentjudges<$minjudges)
{
echo error(i18n("You do not have sufficient number of judges based on your parameters"));
echo "&nbsp;&nbsp;";
echo "<a href=\"judges_schedulerconfig.php\">".i18n("Update Scheduler Configuration")."</a> (".i18n("or get more judges!").")";
$ok=0;
}
else
echo happy(i18n("You have a sufficient number of judges based on your parameters"));

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
include "judges.inc.php";
if($_GET['edit']) $edit=$_GET['edit'];
@ -35,11 +35,11 @@
if($action=="delete" && $_GET['delete'])
{
//ALSO DELETE: team members, timeslots, projects, awards
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='".$_GET['delete']."' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='".$_GET['delete']."' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='".$_GET['delete']."' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='".$_GET['delete']."' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams WHERE id='".$_GET['delete']."' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams WHERE id='".$_GET['delete']."' AND year='".$config['FAIRYEAR']."'");
message_push(happy(i18n("Judge team successfully removed, and all of its corresponding members, timeslots, projects and awards unlinked from team")));
}
@ -49,7 +49,7 @@
FROM
judges_teams
WHERE
conferences_id='".$conference['id']."'
year='".$config['FAIRYEAR']."'
AND autocreate_type_id='1'
");
echo mysql_error();
@ -58,11 +58,11 @@
{
//okay now we can start deleting things! whew!
//first delete any linkings to the team
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams WHERE id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams WHERE id='$r2->id' AND year='".$config['FAIRYEAR']."'");
$numdeleted++;
}
if($numdeleted)
@ -76,18 +76,18 @@
$q2=mysql_query("SELECT *
FROM judges_teams
WHERE
conferences_id='".$conference['id']."'
year='".$config['FAIRYEAR']."'
");
$numdeleted=0;
while($r2=mysql_fetch_object($q2))
{
//okay now we can start deleting things! whew!
//first delete any linkings to the team
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams WHERE id='$r2->id' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$r2->id' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams WHERE id='$r2->id' AND year='".$config['FAIRYEAR']."'");
$numdeleted++;
}
if($numdeleted)
@ -148,7 +148,7 @@
if($addaward)
{
//link up the award
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,conferences_id) VALUES ('".$_POST['award']."','$edit','".$conference['id']."')");
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('".$_POST['award']."','$edit','".$config['FAIRYEAR']."')");
message_push(happy(i18n("Award assigned to team")));
}
}
@ -171,7 +171,7 @@
if($action=="unassign")
{
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$edit' AND award_awards_id='".$_GET['unassign']."' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$edit' AND award_awards_id='".$_GET['unassign']."' AND year='".$config['FAIRYEAR']."'");
message_push(happy(i18n("Award unassigned from judge team")));
//keep editing the same team
$action="edit";
@ -180,7 +180,7 @@
if($action=="createall")
{
//first make sure we dont have any non-divisional award teams (dont want people hitting refresh and adding all the teams twice
$q=mysql_query("SELECT COUNT(*) AS c FROM judges_teams WHERE autocreate_type_id!='1' AND conferences_id='".$conference['id']."'");
$q=mysql_query("SELECT COUNT(*) AS c FROM judges_teams WHERE autocreate_type_id!='1' AND year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
if($r->c)
{
@ -198,8 +198,8 @@
award_types
WHERE
award_awards.award_types_id=award_types.id
AND award_awards.conferences_id='".$conference['id']."'
AND award_types.conferences_id='".$conference['id']."'
AND award_awards.year='".$config['FAIRYEAR']."'
AND award_types.year='".$config['FAIRYEAR']."'
AND award_types_id!='1'
ORDER BY
award_types_order,
@ -210,11 +210,11 @@
{
// print_r($r);
$name=mysql_escape_string("($r->award_type) $r->name");
mysql_query("INSERT INTO judges_teams(num,name,autocreate_type_id,conferences_id) VALUES ('$num','$name','$r->award_types_id','".$conference['id']."')");
mysql_query("INSERT INTO judges_teams(num,name,autocreate_type_id,year) VALUES ('$num','$name','$r->award_types_id','".$config['FAIRYEAR']."')");
echo mysql_error();
$team_id=mysql_insert_id();
//now link the new team to the award
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,conferences_id) VALUES ('$r->id','$team_id','".$conference['id']."')");
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year) VALUES ('$r->id','$team_id','".$config['FAIRYEAR']."')");
message_push(happy(i18n("Created team #%1: %2",array($num,$name))));
$num++;
}
@ -223,7 +223,7 @@
if($action=="add" && $_GET['num'])
{
mysql_query("INSERT INTO judges_teams(num,conferences_id) VALUES ('".$_GET['num']."','".$conference['id']."')");
mysql_query("INSERT INTO judges_teams(num,year) VALUES ('".$_GET['num']."','".$config['FAIRYEAR']."')");
echo mysql_error();
$edit=mysql_insert_id();
$action="edit";
@ -301,9 +301,9 @@ function addclicked()
award_awards,
award_types
WHERE
award_awards.conferences_id='".$conference['id']."'
award_awards.year='".$config['FAIRYEAR']."'
AND award_types.id=award_awards.award_types_id
AND award_types.conferences_id='{$conference['id']}'
AND award_types.year='{$config['FAIRYEAR']}'
ORDER BY
award_type_order,
name
@ -323,10 +323,10 @@ function addclicked()
)
LEFT JOIN judges_teams_awards_link ON award_awards.id = judges_teams_awards_link.award_awards_id
WHERE
award_awards.conferences_id='".$conference['id']."' AND
award_awards.year='".$config['FAIRYEAR']."' AND
judges_teams_awards_link.award_awards_id IS NULL
AND award_types.id=award_awards.award_types_id
AND award_types.conferences_id='{$conference['id']}'
AND award_types.year='{$config['FAIRYEAR']}'
ORDER BY
award_type_order,
name";
@ -396,14 +396,14 @@ function addclicked()
echo "</td></tr></table>";
echo "<table class=\"summarytable\">\n";
echo "<thead style=\"cursor:pointer\"><tr><th>Num</th>";
echo "<tr><th>Num</th>";
echo "<th>Team Name</th>";
echo "<th>Award(s)</th>";
echo "<th>Actions</th>";
echo "</tr></thead>";
echo "</tr>";
foreach($teams AS $team)
{
echo "<tr><td>".$team['num']."</td><td>";
echo "<tr><td>#".$team['num']."</td><td>";
echo $team['name'];
echo "</td>";
@ -433,7 +433,7 @@ function addclicked()
}
echo "</table>";
echo "<script type=\"text/javascript\">$('.summarytable').tablesorter();</script>";
echo "<br />";
}
}

View File

@ -24,7 +24,7 @@
<?
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('admin');
user_auth_required('committee', 'admin');
require_once('judges.inc.php');
send_header("Judging Team Members",
@ -41,6 +41,17 @@ function addbuttonclicked(team)
document.forms.judges.submit();
}
function openjudgeinfo(id)
{
if(id)
currentid=id;
else
currentid=document.forms.judges["judgelist[]"].options[document.forms.judges["judgelist[]"].selectedIndex].value;
window.open("judges_info.php?id="+currentid,"JudgeInfo","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
return false;
}
function switchjudgeinfo()
{
if(document.forms.judges["judgelist[]"].selectedIndex != -1)
@ -60,56 +71,14 @@ function switchjudgeinfo()
}
var mousex = 0, mousey = 0;
var selectedMemberId;
function showMemberDetails(judgeId){
if(judgeId == undefined){
judgeId = document.forms.judges["judgelist[]"].options[document.forms.judges["judgelist[]"].selectedIndex].value;
}
$('#infodiv').load("judges_info.php?id=" + judgeId,
function(){ eval('doShowMemberDetails(' + judgeId + ');'); }
);
}
function editMember(memberId){
if(memberId == undefined) memberId = selectedMemberId;
hideMemberDetails();
window.open("../user_editor_window.php?id="+memberId,"UserEditor","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
}
function hideMemberDetails(){
$('#infodiv').css("display", "none");
$('#infodivcover').css("display", "none");
}
function doShowMemberDetails(judgeId){
selectedMemberId = judgeId;
$('#infodiv').css("top", mousey + 5);
$('#infodiv').css("left", mousex + 20);
$('#infodiv').css("display", "inline");
$('#infodivcover').css("top", mousey + 5);
$('#infodivcover').css("left", mousex + 20);
$('#infodivcover').css("display", "inline");
$('#infodivcover').css("width", $('#infodiv').width());
$('#infodivcover').css("height", $('#infodiv').height());
}
jQuery(document).ready(function(){
$('#infodivcover').click(function(){ editMember(); });
$(document).mousemove(function(e){
mousex = e.pageX;
mousey = e.pageY;
});
});
</script>
<?
if($_POST['action']=="add" && $_POST['team_num'] && count($_POST['judgelist'])>0)
{
//first check if this team exists.
$q=mysql_query("SELECT id,name FROM judges_teams WHERE num='".$_POST['team_num']."' AND conferences_id='".$conference['id']."'");
$q=mysql_query("SELECT id,name FROM judges_teams WHERE num='".$_POST['team_num']."' AND year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q))
{
$r=mysql_fetch_object($q);
@ -138,7 +107,7 @@ jQuery(document).ready(function(){
else
{
//lets make the first one we add a captain, the rest, non-captains :)
mysql_query("INSERT INTO judges_teams_link (users_id,judges_teams_id,captain,conferences_id) VALUES ('$selectedjudge','$team_id','$captain','".$conference['id']."')");
mysql_query("INSERT INTO judges_teams_link (users_id,judges_teams_id,captain,year) VALUES ('$selectedjudge','$team_id','$captain','".$config['FAIRYEAR']."')");
$added++;
}
//if this is alreayd no, then who cares, but if its the first one that is going into the new team, then
@ -155,11 +124,11 @@ jQuery(document).ready(function(){
if($_GET['action']=="del" && $_GET['team_num'] && $_GET['team_id'] && $_GET['users_id'])
{
mysql_query("DELETE FROM judges_teams_link WHERE users_id='".$_GET['users_id']."' AND judges_teams_id='".$_GET['team_id']."' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_link WHERE users_id='".$_GET['users_id']."' AND judges_teams_id='".$_GET['team_id']."' AND year='".$config['FAIRYEAR']."'");
echo happy(i18n("Removed judge from team #%1 (%2)",array($_GET['team_num'],$_GET['team_name'])));
//if there is still members left in the team, make sure we have a captain still
$q=mysql_query("SELECT * FROM judges_teams_link WHERE judges_teams_id='".$_GET['team_id']."' AND conferences_id='".$conference['id']."'");
$q=mysql_query("SELECT * FROM judges_teams_link WHERE judges_teams_id='".$_GET['team_id']."' AND year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q))
{
//make sure the team still has a captain!
@ -183,7 +152,7 @@ jQuery(document).ready(function(){
if(!$gotcaptain)
{
//make the first judge the captain
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_GET['team_id']."' AND users_id='$firstjudge' AND conferences_id='".$conference['id']."'");
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_GET['team_id']."' AND users_id='$firstjudge' AND year='".$config['FAIRYEAR']."'");
echo notice(i18n("Team captain was removed. A new team captain has been automatically assigned"));
}
}
@ -191,7 +160,7 @@ jQuery(document).ready(function(){
if($_GET['action']=="empty" && $_GET['team_num'] && $_GET['team_id'])
{
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='".$_GET['team_id']."' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='".$_GET['team_id']."' AND year='".$config['FAIRYEAR']."'");
echo happy(i18n("Emptied all judges from team #%1 (%2)",array($_GET['team_num'],$_GET['team_name'])));
}
@ -247,7 +216,7 @@ jQuery(document).ready(function(){
echo "<tr>";
echo "<th>".i18n("Judges List");
echo "<br />";
echo "<input disabled=\"true\" name=\"judgeinfobutton\" id=\"judgeinfobutton\" onclick=\"showMemberDetails()\" type=\"button\" value=\"".i18n("Judge Info")."\">";
echo "<input disabled=\"true\" name=\"judgeinfobutton\" id=\"judgeinfobutton\" onclick=\"openjudgeinfo()\" type=\"button\" value=\"".i18n("Judge Info")."\">";
echo "</th>";
echo "<th>".i18n("Judge Teams")."</th>";
echo "</tr>";
@ -272,14 +241,14 @@ jQuery(document).ready(function(){
/* Load all the teams */
$teams = array();
$q = mysql_query("SELECT * FROM judges_teams WHERE conferences_id='{$conference['id']}'");
$q = mysql_query("SELECT * FROM judges_teams WHERE year='{$config['FAIRYEAR']}'");
while($i = mysql_fetch_assoc($q)) {
$teams[$i['id']] = $i;
}
/* And the links */
$links = array();
$q = mysql_query("SELECT * FROM judges_teams_link WHERE conferences_id='{$conference['id']}'");
$q = mysql_query("SELECT * FROM judges_teams_link WHERE year='{$config['FAIRYEAR']}'");
while($i = mysql_fetch_assoc($q)) {
$judgelist[$i['users_id']]['teams_links'][] = $i;
}
@ -304,7 +273,7 @@ jQuery(document).ready(function(){
foreach($jlist as $jid) {
$u = &$judgelist[$jid];
if($u['firstname'] && $u['lastname'])
echo "<option value=\"$jid\">{$u['firstname']} {$u['lastname']} (" . implode(' ', $u['languages']) . ")</option>\n";
echo "<option value=\"$jid\">{$u['firstname']} {$u['lastname']}</option>\n";
}
unset($u);
@ -326,47 +295,35 @@ jQuery(document).ready(function(){
echo "<tr><th colspan=\"2\" align=\"left\">#".$team['num'].": ";
echo $team['name'];
echo "</th></tr>\n";
echo "<tr><td colspan=\"2\">";
foreach($team['rounds'] as $ts) {
echo "{$ts['name']}: ".format_time($ts['starttime'])." - ".format_time($ts['endtime'])."<br />";
}
echo "</td></tr>";
if(count($team['members'])) {
foreach($team['members'] AS $member) {
if(count($team['members']))
{
foreach($team['members'] AS $member)
{
$j = &$judgelist[$member['id']];
echo "<tr><td>";
$langerr=false;
foreach($team['languages'] AS $teamlang) {
if(!in_array($teamlang,$j['languages'])) {
$langerr=true;
break;
}
}
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this judge from this team?')\" href=\"judges_teams_members.php?action=del&team_id=".$team['id']."&team_num=".$team['num']."&users_id=".$member['id']."&team_name=".rawurlencode($team['name'])."\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "</td><td width=\"100%\">";
if($langerr) echo "<span class=\"error\" style=\"width: 100%; display: block;\">";
if($member['captain']=="yes") {
if($member['captain']=="yes")
{
echo "<a title=\"Captain - Click to remove captain status\" href=\"judges_teams_members.php?action=removecaptain&team_id=".$team['id']."&judge_id=".$member['id']."\">";
echo "<img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/bookmark.".$config['icon_extension']."\">";
echo "</a>&nbsp;";
}
else {
else
{
echo "<a title=\"Non-Captain - Click to make a team captain\" href=\"judges_teams_members.php?action=addcaptain&team_id=".$team['id']."&judge_id=".$member['id']."\">";
echo "<img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/bookmark_disabled.".$config['icon_extension']."\">";
echo "</a>&nbsp;";
}
echo "<a onclick=\"showMemberDetails(" . $member['id'] . ");\">";
echo "<a href=\"\" onclick=\"return openjudgeinfo(".$member['id'].");\">";
echo $member['firstname']." ".$member['lastname'];
if(is_array($j['languages']))
$l = is_array($j['languages']) ? join(' ',$j['languages']) : '';
echo "</a>&nbsp;<span style=\"font-size: 1.0em;\">($l)</span>\n";
if($langerr) echo "</span>\n";
echo "</a> (<font size=-1>$l</font>)";
echo "</td></tr>";
}
@ -394,19 +351,6 @@ jQuery(document).ready(function(){
echo "</td></tr>";
echo "</table>";
echo "</form>";
echo '<div id="infodiv" style="background-color: #DDF; border:solid;'
. ' border-width:1px;'
. ' border-color: #000;'
. ' position:absolute;'
. ' top: 0px; left:0px;'
. ' overflow:hidden; display:none;"'
. '></div>';
echo '<div id="infodivcover" style="'
. ' position:absolute;'
. ' display:none;"'
. ' onmouseout="hideMemberDetails();"'
. '></div>';
send_footer();

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
require("judges.inc.php");
require("../projects.inc.php");
@ -87,11 +87,11 @@ if($_GET['action']=="delete" && $_GET['delete'] && $_GET['edit'])
if($_POST['action']=="assign" && $_POST['edit'] && $_POST['timeslot'] && $_POST['project_id'])
{
mysql_query("INSERT INTO judges_teams_timeslots_projects_link (judges_teams_id,judges_timeslots_id,projects_id,conferences_id) VALUES ('".$_POST['edit']."','".$_POST['timeslot']."','".$_POST['project_id']."','".$conference['id']."')");
mysql_query("INSERT INTO judges_teams_timeslots_projects_link (judges_teams_id,judges_timeslots_id,projects_id,year) VALUES ('".$_POST['edit']."','".$_POST['timeslot']."','".$_POST['project_id']."','".$config['FAIRYEAR']."')");
echo happy(i18n("Project assigned to team timeslot"));
}
$q=mysql_query("SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE conferences_id='".$conference['id']."'");
$q=mysql_query("SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q)>1)
$show_date=true;
else
@ -209,10 +209,10 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
projects,
registrations
WHERE
projectnumber is not null
" . getJudgingEligibilityCode(). " AND
projectnumber is not null AND
registrations.status='complete' AND
projects.registrations_id=registrations.id AND
projects.conferences_id='".$conference['id']."'
projects.year='".$config['FAIRYEAR']."'
ORDER BY
projectnumber";
}
@ -228,11 +228,11 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
LEFT JOIN judges_teams_timeslots_projects_link ON projects.id = judges_teams_timeslots_projects_link.projects_id,
registrations
WHERE
projectnumber is not null
" . getJudgingEligibilityCode(). " AND
projectnumber is not null AND
registrations.status='complete' AND
projects.registrations_id=registrations.id AND
judges_teams_timeslots_projects_link.projects_id IS NULL AND
projects.conferences_id='".$conference['id']."'
projects.year='".$config['FAIRYEAR']."'
ORDER BY
projectnumber";
}
@ -247,22 +247,26 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
$numprojects=0;
echo "<select name=\"project_id\">";
echo "<option value=\"\">".i18n("Choose Project to Assign to Timeslot")."</option>\n";
while($pr=mysql_fetch_object($pq)) {
if($_SESSION['viewstate']['judges_projects_list_eligible']=='true') {
if(in_array($pr->projectnumber,$eligibleprojectsnumbers)) {
echo "<option value=\"\">Choose Project to Assign to Timeslot</option>\n";
while($pr=mysql_fetch_object($pq))
{
if($_SESSION['viewstate']['judges_projects_list_eligible']=='true')
{
if(in_array($pr->projectnumber,$eligibleprojectsnumbers))
{
echo "<option value=\"$pr->id\">$pr->projectnumber - $pr->title</option>\n";
$numprojects++;
}
}
else {
else
{
echo "<option value=\"$pr->id\">$pr->projectnumber - $pr->title</option>\n";
$numprojects++;
}
}
echo "</select>";
echo "</td><td>";
echo i18n("%1 projects listed",array($numprojects));
echo "$numprojects projects listed";
echo "</td></tr>";
echo "</table>";
@ -271,20 +275,21 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
echo "<table class=\"summarytable\">";
echo "<tr>";
echo "<th>".i18n("Timeslot")."</th>";
echo "<th>".i18n("Project")."</th>";
echo "<th>Timeslot</th>";
echo "<th>Project</th>";
echo "</tr>";
while($r=mysql_fetch_object($q)) {
while($r=mysql_fetch_object($q))
{
echo "<tr><td>";
echo "<nobr>";
if($show_date)
echo format_date($r->date)."&nbsp;";
echo format_time($r->starttime);
echo "$r->date ";
echo substr($r->starttime,0,-3);
echo " - ";
echo format_time($r->endtime);
echo substr($r->endtime,0,-3);
echo "</nobr>";
echo "</td><td>";
@ -300,62 +305,62 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
judges_teams_timeslots_projects_link.judges_timeslots_id='$r->id' AND
judges_teams_timeslots_projects_link.judges_teams_id='".$team['id']."' AND
judges_teams_timeslots_projects_link.projects_id=projects.id AND
judges_teams_timeslots_projects_link.conferences_id='".$conference['id']."'
judges_teams_timeslots_projects_link.year='".$config['FAIRYEAR']."'
ORDER BY
projectnumber
");
echo mysql_Error();
while($proj=mysql_fetch_object($projq)) {
while($proj=mysql_fetch_object($projq))
{
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this project from this team timeslot?')\" href=\"judges_teams_projects.php?action=delete&delete=".$proj->link_id."&edit=".$team['id']."\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "$proj->projectnumber - $proj->title <br />";
}
echo "<input name=\"assignbtn[$r->id]\" type=\"button\" onclick=\"assign('$r->id')\" value=\"".i18n("Assign")."\">";
echo "<input name=\"assignbtn[$r->id]\" type=\"button\" onclick=\"assign('$r->id')\" value=\"Assign\">";
echo "</td></tr>";
}
echo "</table>";
}
else {
else
{
echo error(i18n("Team has no timeslots assigned to it. <a href=\"judges_teams_timeslots.php\">Assign Timeslots Here</a>"));
}
echo "</form>";
}
else {
else
{
echo "<input type=\"hidden\" name=\"action\" value=\"assign\">";
echo "<table class=\"tableview\">";
echo "<thead><tr>";
echo "<table class=\"summarytable\">";
echo "<tr>";
echo "<th>".i18n("Team")."</th>";
echo "<th>".i18n("Timeslots and Projects")."</th>";
echo "</tr></thead>";
echo "</tr>";
$teams=getJudgingTeams();
foreach($teams AS $team) {
foreach($teams AS $team)
{
echo "<tr>";
echo "<td width=\"200\">";
echo "<b>".$team['name']." (#".$team['num'].")</b><br />";
$memberlist="";
if(count($team['members'])) {
foreach($team['members'] AS $member) {
if(count($team['members']))
{
foreach($team['members'] AS $member)
{
echo "&nbsp;&nbsp;";
$err=false;
foreach($team['languages_projects'] AS $projectlang) {
if(!in_array($projectlang, $member['languages_array'])) {
$err=true;
break;
}
}
if($err) echo "<span class=\"error\">";
if($member['captain']=="yes")
echo "<i>";
echo $member['firstname']." ".$member['lastname']." (".$member['languages'].")<br />";
echo $member['firstname']." ".$member['lastname']."<br />";
if($member['captain']=="yes")
echo "</i>";
if($err) echo "</span>";
}
}
echo "</td>";
@ -379,27 +384,28 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
");
$numslots=mysql_num_rows($q);
echo "<a href=\"judges_teams_projects.php?action=edit&edit=".$team['id']."\">".i18n("Edit team project assignments")."</a>";
echo "<a href=\"judges_teams_projects.php?action=edit&edit=".$team['id']."\">Edit team project assignments</a>";
echo "<table class=\"tableview\" style=\"margin-left: 0px; width: 100%; font-size: 1.0em;\">";
echo "<table class=tableview style=\"margin-left: 0px; width: 100%;\">";
while($r=mysql_fetch_object($q)) {
while($r=mysql_fetch_object($q))
{
echo "<tr><td width=\"100\" align=\"center\">";
echo "<nobr>";
if($show_date)
echo format_date($r->date)."&nbsp;";
echo format_time($r->starttime);
echo "$r->date ";
echo substr($r->starttime,0,-3);
echo " - ";
echo format_time($r->endtime);
echo substr($r->endtime,0,-3);
echo "</nobr>";
echo "</td><td>";
$projq=mysql_query("SELECT
projects.projectnumber,
projects.id,
projects.title,
projects.language
projects.title
FROM
projects,
judges_teams_timeslots_projects_link
@ -407,22 +413,18 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
judges_teams_timeslots_projects_link.judges_timeslots_id='$r->id' AND
judges_teams_timeslots_projects_link.judges_teams_id='".$team['id']."' AND
judges_teams_timeslots_projects_link.projects_id=projects.id AND
judges_teams_timeslots_projects_link.conferences_id='".$conference['id']."'
judges_teams_timeslots_projects_link.year='".$config['FAIRYEAR']."'
ORDER BY
projectnumber
");
echo mysql_error();
while($proj=mysql_fetch_object($projq)) {
if(!in_array($proj->language,$team['languages_members']))
echo "<span class=\"error\">";
echo "$proj->projectnumber - $proj->title ($proj->language)";
if(!in_array($proj->language,$team['languages']))
echo "</span>\n";
echo "<br />";
echo mysql_Error();
while($proj=mysql_fetch_object($projq))
{
echo "$proj->projectnumber - $proj->title <br />";
}
echo "</td></tr>";
}
echo "</table>";
@ -431,7 +433,7 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
echo "</tr>";
}
echo "</table>";
echo "</table>";
}

View File

@ -24,7 +24,7 @@
<?
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('admin');
user_auth_required('committee', 'admin');
require_once('judges.inc.php');
$round_str = array('timeslot' => 'Judging Timeslot',
@ -56,8 +56,8 @@
if(count($_POST['teams']) && count($_POST['timeslots'])) {
foreach($_POST['teams'] AS $tm) {
foreach($_POST['timeslots'] AS $ts) {
mysql_query("INSERT INTO judges_teams_timeslots_link (judges_teams_id,judges_timeslots_id,conferences_id)
VALUES ('$tm','$ts','{$conference['id']}')");
mysql_query("INSERT INTO judges_teams_timeslots_link (judges_teams_id,judges_timeslots_id,year)
VALUES ('$tm','$ts','{$config['FAIRYEAR']}')");
}
}
@ -126,7 +126,7 @@ function checkinvert(what)
echo "<a href=\"\" onclick=\"return checkinvert('timeslots')\">invert selection</a>";
$q=mysql_query("SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE conferences_id='".$conference['id']."'");
$q=mysql_query("SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q)>1)
$show_date=true;
else
@ -141,7 +141,7 @@ function checkinvert(what)
echo "</tr>\n";
$q=mysql_query("SELECT * FROM judges_timeslots
WHERE conferences_id='{$conference['id']}'
WHERE year='{$config['FAIRYEAR']}'
AND round_id='0' ORDER BY date,starttime");
while($r=mysql_fetch_object($q)) {
echo "<tr>";
@ -152,9 +152,9 @@ function checkinvert(what)
while($rr = mysql_fetch_object($qq)) {
echo "<tr>";
echo "<td><input type=\"checkbox\" name=\"timeslots[]\" value=\"{$rr->id}\" /></td>";
if($show_date) echo "<td>".format_date($r->date)."</td>";
echo "<td align=\"center\">".format_time($rr->starttime)."</td>";
echo "<td align=\"center\">".format_time($rr->endtime)."</td>";
if($show_date) echo "<td>{$r->date}</td>";
echo "<td align=\"center\">".substr($rr->starttime,0,-3)."</td>";
echo "<td align=\"center\">".substr($rr->endtime,0,-3)."</td>";
echo "</tr>\n";
}
}
@ -224,10 +224,10 @@ function checkinvert(what)
{
echo "<nobr>";
if($show_date)
echo format_date($r->date);
echo format_time($r->starttime);
echo "$r->date ";
echo substr($r->starttime,0,-3);
echo " - ";
echo format_time($r->endtime);
echo substr($r->endtime,0,-3);
echo "&nbsp;&nbsp;<a onclick=\"return confirmClick('Are you sure you want to remove this timeslot from the team?')\" href=\"judges_teams_timeslots.php?action=delete&delete=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "</nobr>";
echo "<br />";

View File

@ -24,7 +24,7 @@
<?
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('admin');
user_auth_required('committee', 'admin');
$round_str = array('timeslot' => 'Judging Timeslot',
'divisional1' => 'Divisional Round 1',
@ -81,7 +81,7 @@
if($save == true) {
if($round_id == 0) {
/* New entry */
mysql_query("INSERT INTO judges_timeslots (round_id,conferences_id) VALUES('0','{$conference['id']}')");
mysql_query("INSERT INTO judges_timeslots (round_id,year) VALUES('0','{$config['FAIRYEAR']}')");
$round_id = mysql_insert_id();
}
@ -135,8 +135,8 @@
if($save == true) {
if($timeslot_id == 0) {
/* New entry */
mysql_query("INSERT INTO judges_timeslots (round_id,date,type,conferences_id) VALUES('$round_id',
'$date','timeslot','{$conference['id']}')");
mysql_query("INSERT INTO judges_timeslots (round_id,date,type,year) VALUES('$round_id',
'$date','timeslot','{$config['FAIRYEAR']}')");
$timeslot_id = mysql_insert_id();
}
@ -173,19 +173,19 @@
DATE_ADD('$date $hr:$min:00', INTERVAL $tt MINUTE) AS startnext ");
echo mysql_error();
$r=mysql_fetch_object($q);
list($ed,$et)=explode(" ",$r->endtime);
list($nd,$nt)=explode(" ",$r->startnext);
list($ed,$et)=split(" ",$r->endtime);
list($nd,$nt)=split(" ",$r->startnext);
$starttime = sprintf("%02d:%02d:00", $hr, $min);
mysql_query("INSERT INTO judges_timeslots (date,type,round_id,starttime,endtime,conferences_id) VALUES (
mysql_query("INSERT INTO judges_timeslots (date,type,round_id,starttime,endtime,year) VALUES (
'$date','timeslot','{$round_data['id']}',
'$starttime', '$et',
'{$conference['id']}')");
'{$config['FAIRYEAR']}')");
echo mysql_error();
$date=$nd;
list($s_h,$s_m,$s_s)=explode(":",$nt);
list($e_h,$e_m,$e_s)=explode(":",$et);
list($s_h,$s_m,$s_s)=split(":",$nt);
list($e_h,$e_m,$e_s)=split(":",$et);
message_push(happy(i18n("Adding timeslot: %1",array("$date $hr:$min - $e_h:$e_m"))));
$hr=$s_h;
$min=$s_m;
@ -353,17 +353,17 @@
echo "<th>".i18n("Actions")."</th>";
echo "</tr>";
$q=mysql_query("SELECT * FROM judges_timeslots WHERE conferences_id='{$conference['id']}' AND `type`!='timeslot' ORDER BY date,starttime");
$q=mysql_query("SELECT * FROM judges_timeslots WHERE year='{$config['FAIRYEAR']}' AND `type`!='timeslot' ORDER BY date,starttime");
while($r=mysql_fetch_object($q)) {
echo "<tr>";
$qq = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='{$r->id}' ORDER BY `date`,`starttime`");
$c = mysql_num_rows($qq) +1;
echo "<td rowspan=\"$c\"><b>".format_date($r->date)."</b></td>";
echo "<td align=\"center\"><b>".format_time($r->starttime)."</b><br/>";
echo "<td rowspan=\"$c\"><b>$r->date</b></td>";
echo "<td align=\"center\"><b>".substr($r->starttime,0,-3)."</b><br/>";
echo "</td>";
echo "<td align=\"center\"><b>".format_time($r->endtime)."</b></td>";
echo "<td align=\"center\"><b>".substr($r->endtime,0,-3)."</b></td>";
echo "<td align=\"center\"><b>{$r->name} (".i18n($round_str[$r->type]).")</b></td>";
echo " <td align=\"center\">";
echo "<a href=\"judges_timeslots.php?action=editround&round_id={$r->id}\"><img border=\"0\" src=\"{$config['SFIABDIRECTORY']}/images/16/edit.{$config['icon_extension']}\"></a>";
@ -379,8 +379,8 @@
while($rr = mysql_fetch_object($qq)) {
echo "<tr>";
// echo "<td></td>";
echo "<td align=\"right\">".format_time($rr->starttime)."</td>";
echo "<td align=\"right\">".format_time($rr->endtime)."</td>";
echo "<td align=\"right\">".substr($rr->starttime,0,-3)."</td>";
echo "<td align=\"right\">".substr($rr->endtime,0,-3)."</td>";
echo "<td align=\"center\">".i18n($round_str[$rr->type])."</td>";

View File

@ -1,121 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005-2006 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005-2006 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
require_once("judges.inc.php");
user_auth_required('admin');
send_header("Judging Score Entry - Update",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Judging Score Entry' => 'admin/judging_score_entry.php')
);
$project_id = NULL;
if($_GET['projectid']) {
$project_id = $_GET['projectid'];
} else if($_POST['projectid']) {
$project_id = $_POST['projectid'];
$curr_team = $_POST['score_count'];
while($curr_team > 0) {
if($_POST["team_" . $curr_team . "_score"] != "") {
$score = $_POST["team_" . $curr_team . "_score"];
if($score == 0) {
$score = "NULL";
} else {
$score = mysql_real_escape_string($score);
}
mysql_query("UPDATE judges_teams_timeslots_projects_link
SET score=" . $score .
" WHERE judges_teams_id = " . mysql_real_escape_string($_POST["team_" . $curr_team . "_id"]) .
" and projects_id =$project_id and conferences_id={$conference['id']}");
echo mysql_error();
}
$curr_team--;
}
}
?>
<?
if($project_id) {
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='{$conference['id']} ORDER BY id");
while($r=mysql_fetch_object($q))
$cats[$r->id]=$r->category;
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='{$conference['id']} ORDER BY id");
$q=mysql_query("SELECT judges_teams_timeslots_projects_link.judges_teams_id,
score,
judges_teams.num
FROM judges_teams_timeslots_projects_link,
judges_teams
WHERE judges_teams_timeslots_projects_link.judges_teams_id = judges_teams.id
AND projects_id = ".mysql_real_escape_string($project_id)." ORDER BY judges_teams_id"
);
echo mysql_error();
echo "<form action=\"judging_score_edit.php\" method=\"post\">";
echo "<input type=\"hidden\" name=\"score_count\" value=\"" . mysql_num_rows($q) . "\"/>";
echo "<input type=\"hidden\" name=\"projectid\" value=\"$project_id\"/>";
echo "<table class=\"tableview\">";
echo "<tr>";
echo "<th>".i18n("Team Number")."</th>";
echo "<th>".i18n("Judges")."</th>";
echo "<th>".i18n("Score")."</th>";
echo "<th>".i18n("New Score")."</th>";
echo "</tr>";
$i = 1;
while($r=mysql_fetch_object($q)) {
$team=getJudgingTeam($r->judges_teams_id);
$teamNames=array_map("teamMemberToName", $team['members']);
echo "<tr>\n";
echo "<td style=\"vertical-align: middle\">\n";
echo $r->num;
echo "<input type=\"hidden\" name=\"team_" . $i. "_id\" value=\"$r->judges_teams_id\"/>\n";
echo "</td>\n";
echo "<td style=\"vertical-align: middle\">";
echo implode(", ", $teamNames);
echo "</td>\n";
echo "<td style=\"vertical-align: middle; text-align: center\">\n";
if($r->score) {
echo $r->score;
} else {
echo "None";
}
echo "\n</td>\n";
echo "<td style=\"vertical-align: middle; text-align: center\">\n";
echo "<input type=\"text\" size=\"3\" maxlength=\"3\" name=\"team_" . $i . "_score\" value=\"$r->score\"/>\n";
echo "</td>\n";
echo "</tr>\n";
$i++;
}
echo "</table>\n";
echo "<input type=\"submit\" />\n";
echo "</form>\n";
} else {
echo i18n("Invalid Project ID.");
}

View File

@ -1,182 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005-2006 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005-2006 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
require_once("judges.inc.php");
user_auth_required('admin');
if($_GET['conferences_id']) $conferences_id=$_GET['conferences_id'];
else $conferences_id=$conference['id'];
if($_GET['csv'] == 'yes') {
header("Content-type: text/csv");
header("Cache-Control: no-cache");
header("Content-disposition: inline; filename=judging_scores.csv");
} else {
send_header("Judging Score Entry",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php')
);
}
?>
<?
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id = '$conferences_id' ORDER BY id");
while($r=mysql_fetch_object($q))
$cats[$r->id]=$r->category;
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id = '$conferences_id' ORDER BY id");
while($r=mysql_fetch_object($q))
$divs[$r->id]=$r->division;
$ORDERBY="projects.projectcategories_id, projects.projectdivisions_id, projects.projectnumber";
$q=mysql_query("SELECT registrations.id AS reg_id,
registrations.num AS reg_num,
projects.id as projectid,
projects.title,
projects.projectnumber,
projects.projectcategories_id,
projects.projectdivisions_id,
judges_teams_id as res_team_id,
count(score) as score_count,
count((SELECT count(*) FROM judges_teams_timeslots_projects_link WHERE
projectid=judges_teams_timeslots_projects_link.projects_id)) as score_total_count,
avg(score) as score,
avg(score + (SELECT 70-avg(score)
FROM judges_teams_timeslots_projects_link
WHERE judges_teams_id = res_team_id))
AS norm_score
FROM
registrations
left outer join projects on projects.registrations_id=registrations.id
left outer join judges_teams_timeslots_projects_link on projects.id=judges_teams_timeslots_projects_link.projects_id
WHERE
registrations.conferences_id='$conferences_id' "
. getJudgingEligibilityCode() . "
GROUP BY projectid
ORDER BY
$ORDERBY
");
echo mysql_error();
if($_GET['csv'] != 'yes') {
?>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$("#div-cat-best").click(function() {
// set sorting column and direction, this will sort on the first and third column the column index starts at zero
var sorting = [[2,0],[3,0],[5,1]];
// sort on the first column
$(".tableview").trigger("sorton",[sorting]);
// return false to stop default link action
return false;
});
$("#overall-best").click(function() {
// set sorting column and direction, this will sort on the first and third column the column index starts at zero
var sorting = [[5,1]];
// sort on the first column
$(".tableview").trigger("sorton",[sorting]);
// return false to stop default link action
return false;
});
});
</script>
<?php
echo "<a href='judging_score_entry.php?csv=yes'>" . i18n("Generate CSV Report") . "</a>\n";
echo "<br /><a href='#' id='div-cat-best'>" . i18n("Sort By Best in Division/Category") . "</a>\n";
echo "<br /><a href='#' id='overall-best'>" . i18n("Sort By Best Overall") . "</a>\n";
echo "<table class=\"tableview\">";
echo "<thead>";
echo "<tr>";
echo "<th>".i18n("Proj Num")."</th>";
echo "<th>".i18n("Project Title")."</th>";
echo "<th>".i18n("Age Category")."</th>";
echo "<th>".i18n("Division")."</th>";
echo "<th>".i18n("Score")."</th>";
echo "<th>".i18n("Normalized Score")."</th>";
echo "<th>".i18n("Judgings")."</th>";
echo "<th>".i18n("Action")."</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
} else {
echo "Project #\tTitle\tCategory\tDivision\tScore\tNormalized Scores\tJudge Name\tJudges Score\n";
}
while($r=mysql_fetch_object($q))
{
if($_GET['csv'] == 'yes') {
echo "$r->projectnumber \t $r->title \t" . $cats[$r->projectcategories_id] . "\t" . $divs[$r->projectdivisions_id] . " \t $r->score \t $r->norm_score ";
$p=mysql_query("SELECT judges_teams_timeslots_projects_link.judges_teams_id,
score,
judges_teams.num
FROM judges_teams_timeslots_projects_link,
judges_teams
WHERE judges_teams_timeslots_projects_link.judges_teams_id = judges_teams.id
AND projects_id = ".mysql_real_escape_string($r->projectid)." ORDER BY judges_teams_id"
);
echo mysql_error();
while($s=mysql_fetch_object($p)) {
$team=getJudgingTeam($s->judges_teams_id);
$teamNames=array_map("teamMemberToName", $team['members']);
echo "\t " . implode(", ", $teamNames) . " \t $s->score";
}
echo "\n";
} else {
echo "<tr>";
echo "<td>$r->projectnumber</td>\n";
echo "<td>$r->title</td>\n";
echo "<td>".i18n($cats[$r->projectcategories_id])."</td>\n";
echo "<td>".i18n($divs[$r->projectdivisions_id])."</td>\n";
echo "<td class='judging_score'>" . number_format($r->score, 2) . "</td>\n";
echo "<td class='judging_score'><strong>" . number_format($r->norm_score, 2) . "</strong></td>\n";
if ($r->score_count == $r->score_total_count) {
echo "<td>";
} else if ($r->score_count == 0) {
echo "<td class='caution'>";
} else {
echo "<td class='error'>";
}
echo number_format($r->score_count, 0) . "/" . number_format($r->score_total_count, 0) . "</td>\n";
echo "<td align=\"center\">";
if($conferences_id == $conference['id']){
echo "<a href=\"judging_score_edit.php?projectid=$r->projectid\">";
echo i18n("Edit Scores");
echo "</a>";
}
echo "</td>\n";
echo "</tr>\n";
}
}
if($_GET['csv'] != 'yes') {
echo "</tbody>";
echo "</table>\n";
echo "<br />";
send_footer();
}
?>

View File

@ -1,59 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require("../tableeditor.class.php");
require_once("../user.inc.php");
user_auth_required('admin');
send_header("Event Locations",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Events & Scheduling' => 'admin/eventsscheduling.php'),
"events_scheduling" );
echo "<br />";
$editor = new TableEditor("locations",
array(
"name" => "Location Name"
),
array(
"name" => "Location Name"
),
array(
"conferences_id" => $conference['id']
)
);
$editor->filterList("conferences_id", $conference['id']);
$editor->setPrimaryKey("id");
$editor->setRecordType("Location");
$editor->setDefaultSortField("name");
$editor->execute();
send_footer();
?>

View File

@ -22,150 +22,134 @@
*/
?>
<?
require_once('../common.inc.php');
require_once('../user.inc.php');
require_once('../register_participants.inc.php');
require("../common.inc.php");
require_once("../user.inc.php");
require("../register_participants.inc.php");
user_auth_required('committee', 'admin');
//send the header
send_header("Project Editor",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Participant Registration' => 'admin/registration.php',
'Registration List and Statistics' => 'admin/registration_list.php')
);
$auth_type = user_auth_required(array(), array('fair','admin'));
echo "<br />";
$registrations_id=intval($_GET['id']);
$action = $_GET['action'];
/* Extra restrictions for auth_type = fair */
if($auth_type == 'fair') {
$fairs_id = $_SESSION['fairs_id'];
if($registrations_id == -1 && ($action=='registration_load' || $action == 'registration_save')) {
/* we can't check the project it hasn't been created. */
} else {
/* Make sure they have permission to laod this student, check
the master copy of the fairs_id in the project */
$q=mysql_query("SELECT * FROM projects WHERE
registrations_id='$registrations_id'
AND conferences_id='{$conference['id']}'
AND fairs_id=$fairs_id");
if(mysql_num_rows($q) != 1) {
echo "permission denied.";
exit;
}
/* Ok, they have permission */
}
}
if($_POST['registration_id']) $registration_id=$_POST['registration_id'];
else if($_GET['registration_id']) $registration_id=$_GET['registration_id'];
switch($action) {
case 'project_load':
project_load2();
break;
case 'project_regenerate_number':
/* Save first */
project_save();
/* Now generate */
$q=mysql_query("SELECT id FROM projects WHERE registrations_id='{$registrations_id}' AND conferences_id='{$conference['id']}'");
$i=mysql_fetch_assoc($q);
$id = $i['id'];
if($_POST['action']=="genprojnum") {
$id = intval($_POST['id']);
mysql_query("UPDATE projects SET projectnumber=NULL,projectsort=NULL,
projectnumber_seq='0',projectsort_seq='0'
WHERE id='$id'");
echo mysql_error();
list($pn,$ps,$pns,$pss) = generateProjectNumber($registrations_id);
list($pn,$ps,$pns,$pss) = generateProjectNumber($registration_id);
// print("Generated Project Number [$pn]");
mysql_query("UPDATE projects SET projectnumber='$pn',projectsort='$ps',
projectnumber_seq='$pns',projectsort_seq='$pss'
WHERE id='$id'");
happy_("Generated and Saved Project Number: $pn");
break;
echo mysql_error();
}
case 'project_save':
project_save();
break;
default:
break;
}
if($_POST['action']=="save")
{
// {
//first, lets make sure this project really does belong to them
$q=mysql_query("SELECT * FROM projects WHERE id='".$_POST['id']."' AND registrations_id='".$registration_id."' AND year='".$config['FAIRYEAR']."'");
if($projectinfo=mysql_fetch_object($q))
{
$summarywords=preg_split("/[\s,]+/",$_POST['summary']);
$summarywordcount=count($summarywords);
if($summarywordcount>$config['participant_project_summary_wordmax'])
$summarycountok=0;
else
$summarycountok=1;
exit;
if($config['participant_project_title_charmax'] && strlen(stripslashes($_POST['title']))>$config['participant_project_title_charmax']) //0 for no limit, eg 255 database field limit
{
$title=substr(stripslashes($_POST['title']),0,$config['participant_project_title_charmax']);
echo error(i18n("Project title truncated to %1 characters",array($config['participant_project_title_charmax'])));
}
else
$title=stripslashes($_POST['title']);
function project_save()
{
global $registrations_id, $config, $conference;
mysql_query("UPDATE projects SET ".
"title='".mysql_escape_string($title)."', ".
"projectdivisions_id='".$_POST['projectdivisions_id']."', ".
"language='".mysql_escape_string(stripslashes($_POST['language']))."', ".
"req_table='".mysql_escape_string(stripslashes($_POST['req_table']))."', ".
"req_electricity='".mysql_escape_string(stripslashes($_POST['req_electricity']))."', ".
"req_special='".mysql_escape_string(stripslashes($_POST['req_special']))."', ".
"summary='".mysql_escape_string(stripslashes($_POST['summary']))."', ".
"summarycountok='$summarycountok',".
"projectsort='".mysql_escape_string(stripslashes($_POST['projectsort']))."'".
"WHERE id='".$_POST['id']."'");
echo mysql_error();
echo notice(i18n("Project information successfully updated"));
//first, lets make sure this project really does belong to them
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='{$registrations_id}' AND conferences_id='{$conference['id']}'");
$projectinfo=mysql_fetch_object($q);
if(!projectinfo) {
echo error(i18n("Invalid project to update"));
}
$summarywords=preg_split("/[\s,]+/",$_POST['summary']);
$summarywordcount=count($summarywords);
if($summarywordcount>$config['participant_project_summary_wordmax'])
$summarycountok=0;
else
$summarycountok=1;
if($config['participant_project_title_charmax'] && strlen(stripslashes($_POST['title']))>$config['participant_project_title_charmax']) { //0 for no limit, eg 255 database field limit
$title=substr(stripslashes($_POST['title']),0,$config['participant_project_title_charmax']);
error_("Project title truncated to %1 characters",array($config['participant_project_title_charmax']));
} else
$title=stripslashes($_POST['title']);
mysql_query("UPDATE projects SET ".
"title='".mysql_escape_string($title)."', ".
"projectdivisions_id='".intval($_POST['projectdivisions_id'])."', ".
"language='".mysql_escape_string(stripslashes($_POST['language']))."', ".
"req_table='".mysql_escape_string(stripslashes($_POST['req_table']))."', ".
"req_electricity='".mysql_escape_string(stripslashes($_POST['req_electricity']))."', ".
"req_special='".mysql_escape_string(stripslashes($_POST['req_special']))."', ".
"summary='".mysql_escape_string(stripslashes($_POST['summary']))."', ".
"summarycountok='$summarycountok',".
"projectsort='".mysql_escape_string(stripslashes($_POST['projectsort']))."'".
"WHERE id='".intval($_POST['id'])."'");
echo mysql_error();
happy_('Project Information Saved');
//check if they changed the project number
if($_POST['projectnumber']!=$projectinfo->projectnumber) {
//check if hte new one is available
$q=mysql_query("SELECT * FROM projects WHERE conferences_id='".$conference['id']."' AND projectnumber='".$_POST['projectnumber']."'");
if(mysql_num_rows($q)) {
error_("Could not change project number. %1 is already in use",array($_POST['projectnumber']));
} else {
mysql_query("UPDATE projects SET
projectnumber='".$_POST['projectnumber']."'
WHERE id='".$_POST['id']."'");
happy_("Project number successfully changed to %1",array($_POST['projectnumber']));
//check if they changed the project number
if($_POST['projectnumber']!=$projectinfo->projectnumber)
{
//check if hte new one is available
$q=mysql_query("SELECT * FROM projects WHERE year='".$config['FAIRYEAR']."' AND projectnumber='".$_POST['projectnumber']."'");
if(mysql_num_rows($q))
{
echo error(i18n("Could not change project number. %1 is already in use",array($_POST['projectnumber'])));
}
else
{
mysql_query("UPDATE projects SET
projectnumber='".$_POST['projectnumber']."'
WHERE id='".$_POST['id']."'");
echo happy(i18n("Project number successfully changed to %1",array($_POST['projectnumber'])));
}
}
}
else
{
echo error(i18n("Invalid project to update"));
}
//}
}
//now lets find out their MAX grade, so we can pre-set the Age Category
$q=mysql_query("SELECT MAX(grade) AS maxgrade FROM students WHERE registrations_id='".$registration_id."'");
$gradeinfo=mysql_fetch_object($q);
//now lets grab all the age categories, so we can choose one based on the max grade
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
{
//save these in an array, just incase we need them later (FIXME: remove this array if we dont need it)
$agecategories[$r->id]['category']=$r->category;
$agecategories[$r->id]['mingrade']=$r->mingrade;
$agecategories[$r->id]['maxgrade']=$r->maxgrade;
if($gradeinfo->maxgrade >= $r->mingrade && $gradeinfo->maxgrade <= $r->maxgrade)
{
$projectcategories_id=$r->id;
}
}
}
//now select their project info
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$registration_id."' AND year='".$config['FAIRYEAR']."'");
//check if it exists, if we didnt find any record, lets insert one
$projectinfo=mysql_fetch_object($q);
//make sure that if they changed their grade on the student page, we update their projectcategories_id accordingly
if($projectcategories_id && $projectinfo->projectcategories_id!=$projectcategories_id)
{
echo notice(i18n("Age category changed, updating to %1",array($agecategories[$projectcategories_id]['category'])));
mysql_query("UPDATE projects SET projectcategories_id='$projectcategories_id' WHERE id='$projectinfo->id'");
}
function project_load2()
{
global $registrations_id, $config, $conference;
$projectcategories_id=getProjectCategory($registrations_id);
//now select their project info
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$registrations_id."' AND conferences_id='".$conference['id']."'");
//check if it exists, if we didnt find any record, lets insert one
$projectinfo=mysql_fetch_object($q);
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' ORDER BY id");
while($r=mysql_fetch_object($q)) {
//save these in an array, so we can use them below
$agecategories[$r->id]['category']=$r->category;
$agecategories[$r->id]['mingrade']=$r->mingrade;
$agecategories[$r->id]['maxgrade']=$r->maxgrade;
}
//make sure that if they changed their grade on the student page, we update their projectcategories_id accordingly
if($projectcategories_id && $projectinfo->projectcategories_id!=$projectcategories_id) {
echo notice(i18n("Age category changed, updating to %1",array($agecategories[$projectcategories_id]['category'])));
mysql_query("UPDATE projects SET projectcategories_id='$projectcategories_id' WHERE id='$projectinfo->id'");
}
//output the current status
//output the current status
?>
<script language="javascript" type="text/javascript">
@ -188,95 +172,87 @@ function countwords()
}
</script>
<?
if($projectinfo)
{
if(!$projectinfo) {
echo error(i18n("Invalid project to edit"));
exit;
echo "<form name=\"projectform\" method=\"post\" action=\"project_editor.php\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"$projectinfo->id\">\n";
echo "<input type=\"hidden\" name=\"registration_id\" value=\"$registration_id\">\n";
echo "<table>\n";
echo "<tr><td>".i18n("Project Title").": </td><td><input type=\"text\" name=\"title\" size=\"50\" value=\"".htmlspecialchars($projectinfo->title)."\" />".REQUIREDFIELD;
if($config['participant_project_title_charmax'])
echo i18n("(Max %1 characters)",array($config['participant_project_title_charmax']));
echo "</td></tr>\n";
echo "<tr><td>".i18n("Project Number").": </td><td><input type=\"text\" name=\"projectnumber\" size=\"10\" value=\"$projectinfo->projectnumber\" />";
echo "<tr><td>".i18n("Project Sort").": </td><td><input type=\"text\" name=\"projectsort\" size=\"10\" value=\"$projectinfo->projectsort\" />";
echo "<tr><td>".i18n("Age Category").": </td><td>";
echo i18n($agecategories[$projectcategories_id]['category']);
echo " (".i18n("Grades %1-%2",array($agecategories[$projectcategories_id]['mingrade'],$agecategories[$projectcategories_id]['maxgrade'])).")";
echo "</td></tr>";
echo "<tr><td>".i18n("Division").": </td><td>";
//###### Feature Specific - filtering divisions by category
if($config['filterdivisionbycategory']=="yes"){
$q=mysql_query("SELECT projectdivisions.* FROM projectdivisions,projectcategoriesdivisions_link WHERE projectdivisions.id=projectdivisions_id AND projectcategories_id=".$projectcategories_id." AND projectdivisions.year='".$config['FAIRYEAR']."' AND projectcategoriesdivisions_link.year='".$config['FAIRYEAR']."' ORDER BY division");
echo mysql_error();
//###
}else
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY division");
echo "<select name=\"projectdivisions_id\">";
echo "<option value=\"\">".i18n("Select a division")."</option>\n";
while($r=mysql_fetch_object($q))
{
if($r->id == $projectinfo->projectdivisions_id) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$r->id\">".htmlspecialchars(i18n($r->division))."</option>\n";
}
echo "</select>".REQUIREDFIELD;
if($config['usedivisionselector']=="yes")
{
?>
<script language="javascript" type="text/javascript">
function openDivSelWindow()
{
divselwin=window.open('register_participants_project_divisionselector.php','divsel','width=500,height=220,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no')
if(divselwin.opener==null) divselwin.opener=self;
return false;
}
?>
<form id="project_form">
<input type="hidden" name="id" value="<?=$projectinfo->id?>">
<table>
<tr> <td><?=i18n("Project Title")?>: </td>
<td><input type="text" name="title" size="50" value="<?=htmlspecialchars($projectinfo->title)?>" /><?=REQUIREDFIELD?>
<?
if($config['participant_project_title_charmax'])
echo i18n("(Max %1 characters)",array($config['participant_project_title_charmax']));
?>
</td>
</tr><tr>
<td><?=i18n("Project Number")?>: </td>
<td><input type="text" name="projectnumber" size="10" value="<?=$projectinfo->projectnumber?>" />
<input type="button" id="project_regenerate_number" value="<?=i18n("Re-Generate Project Number")?>" />
</td>
</tr><tr>
<td><?=i18n("Project Sort")?>: </td>
<td><input type="text" name="projectsort" size="10" value="<?=$projectinfo->projectsort?>" /></td>
</tr><tr>
<td><?=i18n("Age Category")?>: </td>
<td><?=i18n($agecategories[$projectcategories_id]['category'])?> (<?=i18n("Grades %1-%2",array($agecategories[$projectcategories_id]['mingrade'],$agecategories[$projectcategories_id]['maxgrade']))?>)</td>
</tr><tr>
<td><?=i18n("Division")?>: </td>
<td>
<?
//###### Feature Specific - filtering divisions by category
if($config['filterdivisionbycategory']=="yes"){
$q=mysql_query("SELECT projectdivisions.* FROM projectdivisions,projectcategoriesdivisions_link WHERE projectdivisions.id=projectdivisions_id AND projectcategories_id=".$projectcategories_id." AND projectdivisions.conferences_id='".$conference['id']."' AND projectcategoriesdivisions_link.conferences_id='".$conference['id']."' ORDER BY division");
echo mysql_error();
//###
} else
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='".$conference['id']."' ORDER BY division");
echo "<select name=\"projectdivisions_id\">";
echo "<option value=\"\">".i18n("Select a division")."</option>\n";
while($r=mysql_fetch_object($q)) {
if($r->id == $projectinfo->projectdivisions_id) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$r->id\">".htmlspecialchars(i18n($r->division))."</option>\n";
}
echo "</select>".REQUIREDFIELD;
if($config['usedivisionselector']=="yes") {
?>
<script language="javascript" type="text/javascript">
function openDivSelWindow()
{
divselwin=window.open('register_participants_project_divisionselector.php','divsel','width=500,height=220,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no')
if(divselwin.opener==null) divselwin.opener=self;
return false;
}
</script>
</script>
<?
}
}
echo "<br />";
echo i18n("WARNING! If you change the division you must manually change the project number too! It will NOT be assigned a new number automatically");
echo "</td></tr>";
echo "<br />";
echo i18n("WARNING! If you change the division you must manually change the project number too! It will NOT be assigned a new number automatically");
echo "</td></tr>";
echo "<tr><td>".i18n("Language").": </td><td>";
echo "<select name=\"language\">\n";
echo "<tr><td>".i18n("Language").": </td><td>";
echo "<select name=\"language\">\n";
if($projectinfo->language)
$currentlang=$projectinfo->language;
else
$currentlang=$_SESSION['lang'];
if($projectinfo->language)
$currentlang=$projectinfo->language;
else
$currentlang=$_SESSION['lang'];
foreach($config['languages'] AS $key=>$val)
{
if($currentlang==$key) $selected="selected=\"selected\""; else $selected="";
foreach($config['languages'] AS $key=>$val) {
if($currentlang==$key) $selected="selected=\"selected\""; else $selected="";
echo "<option $selected value=\"$key\">$val</option>";
}
echo "</select>".REQUIREDFIELD;
echo "</td></tr>";
echo "<option $selected value=\"$key\">$val</option>";
}
echo "</select>".REQUIREDFIELD;
echo "</td></tr>";
echo "<tr><td>".i18n("Requirements").": </td><td>";
echo "<tr><td>".i18n("Requirements").": </td><td>";
echo "<table>";
if($config['participant_project_table']=="no") {
if($config['participant_project_table']=="no")
{
//if we arent asking them if they want a table or not, then we set it to 'yes' assuming everyone will get a table
echo " <input type=\"hidden\" name=\"req_table\" value=\"yes\" />";
} else {
}
else
{
echo "<tr>";
echo " <td>".i18n("Table").REQUIREDFIELD."</td>";
if($projectinfo->req_table=="yes") $check="checked=\"checked\""; else $check="";
@ -311,26 +287,43 @@ function countwords()
echo "</table>";
echo "</td></tr>";
echo "</td></tr>";
echo "<tr><td>".i18n("Summary").": </td><td><textarea onchange='countwords()' onkeypress='countwords()' cols=\"60\" rows=\"12\" id=\"summary\" name=\"summary\">".htmlspecialchars($projectinfo->summary)."</textarea>".REQUIREDFIELD."<br />";
echo "<tr><td>".i18n("Summary").": </td><td><textarea onchange='countwords()' onkeypress='countwords()' cols=\"60\" rows=\"12\" id=\"summary\" name=\"summary\">".htmlspecialchars($projectinfo->summary)."</textarea>".REQUIREDFIELD."<br />";
$summarywords=preg_split("/[\s,]+/",$projectinfo->summary);
$summarywordcount=count($summarywords);
if($summarywordcount>$config['participant_project_summary_wordmax'])
echo "<div id=\"wordcountmessage\" class=\"incomplete\">";
else
echo "<div id=\"wordcountmessage\" class=\"complete\">";
$summarywords=preg_split("/[\s,]+/",$projectinfo->summary);
$summarywordcount=count($summarywords);
if($summarywordcount>$config['participant_project_summary_wordmax'])
echo "<div id=\"wordcountmessage\" class=\"incomplete\">";
else
echo "<div id=\"wordcountmessage\" class=\"complete\">";
echo "<span id=\"wordcount\">$summarywordcount</span>/";
echo i18n("%1 words maximum",array($config['participant_project_summary_wordmax']));
echo "</div>";
echo "<span id=\"wordcount\">$summarywordcount</span>/";
echo i18n("%1 words maximum",array($config['participant_project_summary_wordmax']));
echo "</div>";
?>
</td></tr>
</table>
<input type="button" id="project_save" value="<?=i18n("Save Project Information")?>" />
</form>
<?
echo "</td></tr>";
echo "</table>";
echo "<input type=\"submit\" value=\"".i18n("Save Project Information")."\" />\n";
echo "</form>";
echo ("<br /><br /><h3>".i18n("Other Actions")."</h3><br />");
echo "<form name=\"projectform\" method=\"post\" action=\"project_editor.php\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"genprojnum\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"$projectinfo->id\">\n";
echo "<input type=\"hidden\" name=\"registration_id\" value=\"$registration_id\">\n";
echo "<input type=\"submit\" value=\"".i18n("Re-Generate Project Number")."\" />\n";
echo "</form>";
}
else
{
echo error(i18n("Invalid project to edit"));
}
send_footer();
?>

View File

@ -25,7 +25,7 @@
require("../tableeditor.class.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
send_header("Registration Fee Items Manager",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
@ -38,7 +38,7 @@
'cost' => 'Cost',
'per' => 'Cost Per',
), null,
array('conference' => $conference['name'])
array('year' => $config['FAIRYEAR'])
);
$editor->setPrimaryKey("id");
@ -48,7 +48,7 @@
array('key' => 'project', 'val' => "Project")
) );
$editor->setFieldInputType("per", 'select');
$editor->filterList('conference',$conference['name']);
$editor->filterList('year',$config['FAIRYEAR']);
$editor->execute();

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
send_header("Participant Registration",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
@ -32,8 +32,7 @@
);
echo "<br />";
echo "<a href=\"registration_receivedforms.php\">".i18n("Input Received Signature Forms")."</a> <br />";
echo "<a href=\"registration_list.php\">".i18n("Registration List and Student/Project Editor")."</a> <br />";
echo "<a href=\"registration_stats.php\">".i18n("Registration Statistics")."</a> <br />";
echo "<a href=\"registration_list.php\">".i18n("Registration List and Statistics")."</a> <br />";
echo "<a href=\"registration_webconsent.php\">".i18n("Website Consent")."</a> <br />";

View File

@ -22,380 +22,92 @@
*/
?>
<?
require_once('../common.inc.php');
require_once('../user.inc.php');
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
require("../register_participants.inc.php");
$auth_type = user_auth_required(array(), array('fair', 'admin'));
if($_GET['year']) $year=$_GET['year'];
else $year=$config['FAIRYEAR'];
//require_once('../register_participants.inc.php');
if($_GET['conference_id']) $conference_id=intval($_GET['conference_id']);
else $conference_id=$conference['id'];
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='{$conference['id']}' ORDER BY id");
while($r=mysql_fetch_object($q))
$cats[$r->id]=$r->category;
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='{$conference['id']}' ORDER BY id");
while($r=mysql_fetch_object($q))
$divs[$r->id]=$r->division;
$action=$_GET['action'];
switch($action) {
case 'load_row':
$id = intval($_GET['id']);
$q = list_query($conference_id, '', $id);
$r = mysql_fetch_object($q);
print_row($r);
exit;
case 'delete':
$regid = intval($_GET['id']);
$q = mysql_query("SELECT * FROM projects WHERE registrations_id='$regid'");
if(mysql_num_rows($q)) {
$p = mysql_fetch_assoc($q);
mysql_query("DELETE FROM winners WHERE projects_id='{$p['id']}'");
}
mysql_query("DELETE FROM registrations WHERE id='$regid' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM users WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM projects WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM safety WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'");
// mysql_query("DELETE FROM questions_answers WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM mentors WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM emergencycontact WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'");
happy_("Registration and all related data successfully deleted");
exit;
}
if($auth_type == 'committee') {
send_header("Registration Management",
send_header("Registration List and Statistics",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Participant Registration' => 'admin/registration.php')
);
} else {
send_header("Student/Project Management",
array('Fair Main' => 'fair_main.php') );
}
?>
<div id="student_editor" title="Student/Project Editor" style="display: none">
<div id="editor_tabs" >
<ul>
<li><a href="#editor_tab_reg"><span><?=i18n('Registration')?></span></a></li>
<li><a href="#editor_tab_students"><span><?=i18n('Students')?></span></a></li>
<li><a href="#editor_tab_project"><span><?=i18n('Project')?></span></a></li>
</ul>
<div id="editor_tab_reg">Loading...</div>
<div id="editor_tab_students">Loading...</div>
<div id="editor_tab_project">Loading...</div>
</div>
</div>
<script language="javascript" type="text/javascript">
<script language="javascript" type="text/javascript">
var registrations_id = 0;
var registrations_new = 0;
function popup_editor(id, open_tab)
function openstudentinfo(id)
{
var w = (document.documentElement.clientWidth * 0.9);
var h = (document.documentElement.clientHeight * 0.9);
registrations_id = id;
registrations_new = 0;
if(id == -1) {
open_tab = 'reg';
registrations_new = 1;
}
/* Force no tabs to be selected, need to set collapsible
* to true first */
$('#editor_tabs').tabs('option', 'collapsible', true);
$('#editor_tabs').tabs('option', 'selected', -1);
/* Then we'll select a tab to force a reload */
switch(open_tab) {
case 'reg':
/* If we open on the reg tab, disable the others until a save */
$('#editor_tabs').tabs('option', 'disabled', [1,2]);
$('#editor_tabs').tabs('select', 0);
break;
case 'project':
$('#editor_tabs').tabs('option', 'disabled', []);
$('#editor_tabs').tabs('select', 2);
break;
default:
$('#editor_tabs').tabs('option', 'disabled', []);
$('#editor_tabs').tabs('select', 1);
break;
}
/* Don't let anything collapse */
$('#editor_tabs').tabs('option', 'collapsible', false);
/* Show the dialog */
$('#student_editor').dialog('option', 'width', w);
$('#student_editor').dialog('option', 'height', h);
$("#student_editor").dialog('open');
return true;
}
function update_students(numstudents)
{
var id = registrations_id;
var req = "action=students_load&id="+id;
if(numstudents != 0 && numstudents != undefined) req = req+"&numstudents="+numstudents;
$("#editor_tab_students").load("student_editor.php?"+req, '',
function(responseText, textStatus, XMLHttpRequest) {
/* Attach to events we care about */
$("#students_num").change(function() {
var num = $("#students_num").val();
update_students(num);
});
$("#students_save").click(function() {
var id = registrations_id;
$("#debug").load("student_editor.php?action=students_save&id="+id, $("#students_form").serializeArray());
});
$(".students_remove_button").click(function() {
var id = registrations_id;
var sid = $("#"+this.id +"_students_id").val();
var conf = confirmClick('<?=i18n("Are you sure you want to remove this student from the project?")?>');
if(conf == false) return false;
$("#debug").load("student_editor.php?action=student_remove&id="+id+"&students_id="+sid, '',
function(responseText, textStatus, XMLHttpRequest) {
update_students();
});
return false;
});
}
);
window.open("students_info.php?id="+id,"StudentInfo","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
return false;
}
function update_project()
{
var id = registrations_id;
$("#editor_tab_project").load("project_editor.php?action=project_load&id="+id, '',
function(responseText, textStatus, XMLHttpRequest) {
/* Attach to regenerate button */
$("#project_regenerate_number").click(function() {
var id = registrations_id;
/* Call for regen, and when that's done reload the project screen (and rebind everything),
* pass all the form data in, because regen does a save first */
$("#debug").load("project_editor.php?action=project_regenerate_number&id="+id,$("#project_form").serializeArray(),
function(responseText, textStatus, XMLHttpRequest) {
update_project();
});
});
/* Attach to save button */
$("#project_save").click(function() {
var id = registrations_id;
$("#debug").load("project_editor.php?action=project_save&id="+id, $("#project_form").serializeArray());
});
}
);
return false;
}
function delete_registration(id)
{
registrations_id=id;
var conf = confirmClick('<?=i18n("Are you sure you want to completely delete this registration?")?>');
if(conf == false) return false;
$("#debug").load("<?=$_SERVER['PHP_SELF']?>?action=delete&id="+id,{},
function(responseText, textStatus, XMLHttpRequest) {
var id = registrations_id;
$("#row_"+id).remove();
});
}
function update_reg()
{
var id = registrations_id;
$("#editor_tab_reg").load("student_editor.php?action=registration_load&id="+id, '',
function(responseText, textStatus, XMLHttpRequest) {
/* Attach to save button */
$("#registration_save").click(function() {
var id = registrations_id;
$('#debug').load("student_editor.php?action=registration_save&id="+id, $("#registration_form").serializeArray());
/* Enable the other tabs now after a save, FIXME: should be
* after a successful save, but we should use on-the-fly form
* validation to disable the save button, so the extra callback/error
* check isn't needed */
$('#editor_tabs').tabs('option', 'disabled', []);
return false;
});
}
);
return false;
}
$(document).ready(function() {
$("#student_editor").dialog({
bgiframe: true, autoOpen: false,
modal: true, resizable: false,
draggable: false,
buttons: {
/* "<?=i18n('Cancel')?>": function() {
$(this).dialog("close");
},
"<?=i18n('Save')?>": function() {
save_report();
$(this).dialog("close"); */
"<?=i18n('Close')?>": function() {
// save_report();
$(this).dialog("close");
}
},
close: function() {
/* Reload the row after the dialog close in case the info has changed */
var id = registrations_id;
if(registrations_new == true) {
/* Create a row before loading it */
$("#registration_list").append("<tr id=\"row_"+id+"\"></tr>");
}
$("#row_"+id).load("<?$_SERVER['PHP_SELF']?>?action=load_row&id="+id);
$("#row_"+id).effect('highlight',{},500);
}
});
$("#editor_tabs").tabs({
show: function(event, ui) {
switch(ui.panel.id) {
case 'editor_tab_students':
update_students();
break;
case 'editor_tab_project':
update_project();
break;
case 'editor_tab_reg':
update_reg();
break;
default:
break;
}
},
selected: -1
});
/*
$("#newproject").click(function() {
popup_editor(-1);
}
);
*/
});
</script>
<br />
<table style="width: 500px;">
<tr><td>
<form name="statuschangerform" method="get" action="registration_list.php">
<?=i18n("Choose Status")?>:
<select name="showstatus" onchange="document.forms.statuschangerform.submit()">
<?
if($_GET['action']=="delete" && $_GET['delete'])
{
$regid=$_GET['delete'];
mysql_query("DELETE FROM registrations WHERE id='$regid' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM students WHERE registrations_id='$regid' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM projects WHERE registrations_id='$regid' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM safety WHERE registrations_id='$regid' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM questions_answers WHERE registrations_id='$regid' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM mentors WHERE registrations_id='$regid' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM emergencycontact WHERE registrations_id='$regid' AND year='".$config['FAIRYEAR']."'");
echo happy(i18n("Registration and all related data successfully deleted"));
}
echo "<br />";
echo i18n("Choose Status").":";
echo "<form name=\"statuschangerform\" method=\"get\" action=\"registration_list.php\">";
echo "<select name=\"showstatus\" onchange=\"document.forms.statuschangerform.submit()\">";
$status_str = array();
$status_str[''] = i18n("Any Status");
$status_str['complete'] = i18n("Complete");
//if there is no reg fee, then we dont need to show this status, because nobody will ever be in this status
$status_str = array('' => 'Any Status', 'complete' => 'Complete',
'paymentpending' => ($config['regfee']>0) ? 'Payment Pending' : '',
'completeorpaymentpending' => ($config['regfee']>0) ? 'Complete or Payment Pending' : '',
'open' => 'Open', 'new' => 'New');
if($config['regfee']>0) $status_str['paymentpending'] = i18n("Payment Pending");
$status_str['open'] = i18n("Open");
$status_str['new'] = i18n("New");
$showstatus = $_GET['showstatus'];
foreach($status_str as $s=>$str) {
if($str == '') continue;
$sel = ($showstatus == $s) ? "selected=\"selected\"" : '';
echo "<option $sel value=\"$s\">".i18n($str)."</option>\n";
$sel = ($showstatus == $s) ? "selected=\"selected\"" : '';
echo "<option $sel value=\"$s\">$str</option>\n";
}
?>
</select></form></td>
<?
// echo <td align=\"right\"><button id=\"newproject\">".i18n("Create New Project")."</button></td>\n";
?>
</tr></table>
<?
echo "</select>";
echo "</form>";
if($showstatus) {
switch($showstatus) {
case "complete": $wherestatus="AND status='complete' "; break;
case "paymentpending": $wherestatus="AND status='paymentpending' "; break;
case "completeorpaymentpending": $wherestatus="AND (status='complete' OR status='paymentpending') "; break;
case "open": $wherestatus="AND status='open' "; break;
case "new": $wherestatus="AND status='new' "; break;
default: $wherestatus="";
}
}
$q=mysql_query("SELECT * FROM projectcategories WHERE year='$year' ORDER BY id");
while($r=mysql_fetch_object($q))
$cats[$r->id]=$r->category;
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='$year' ORDER BY id");
while($r=mysql_fetch_object($q))
$divs[$r->id]=$r->division;
if($showstatus) $wherestatus="AND status='$showstatus' ";
else $wherestatus="";
switch($_GET['sort'])
{
case 'status': $ORDERBY="registrations.status DESC, projects.title"; break;
case 'num': $ORDERBY="registrations.num"; break;
case 'projnum': $ORDERBY="projects.projectsort, projects.projectnumber"; break;
case 'title': $ORDERBY="projects.title, registrations.status DESC"; break;
case 'cat': $ORDERBY="projects.projectcategories_id, projects.title"; break;
case 'div': $ORDERBY="projects.projectdivisions_id, projects.title"; break;
default: $ORDERBY="registrations.status DESC, projects.title"; break;
$q = list_query($conference_id, $wherestatus, false);
echo "<table id=\"registration_list\" class=\"tableview\">";
echo "<thead><tr>";
if($showstatus) $stat="&showstatus=".$showstatus;
echo "<th>".i18n("Status")."</th>";
echo "<th>".i18n("Reg Num")."</th>";
echo "<th>".i18n("Proj Num")."</th>";
echo "<th>".i18n("Project Title")."</th>";
echo "<th>".i18n("Age Category")."</th>";
echo "<th>".i18n("Division")."</th>";
echo "<th>".i18n("Participant Details")."</th>";
echo "<th>".i18n("Action")."</th>";
echo "</tr></thead>";
echo "<tbody>";
while($r=mysql_fetch_object($q)) {
echo "<tr id=\"row_{$r->reg_id}\">";
print_row($r);
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "<br/><br/>The statistics have moved here: <a href=\"registration_stats.php\">Registration Statistics</a><br/><br/>";
send_footer();
/* Now some helper fucntions we call more than once */
function list_query($conference_id, $wherestatus, $reg_id)
{
global $auth_type;
$reg = '';
if($reg_id != false)
$reg = "AND registrations.id='$reg_id'";
$fair = '';
if($auth_type == 'fair') {
$fair = "AND projects.fairs_id='{$_SESSION['fairs_id']}'";
}
$q=mysql_query("SELECT registrations.id AS reg_id,
registrations.num AS reg_num,
registrations.status,
registrations.email,
projects.title,
projects.projectnumber,
projects.projectcategories_id,
@ -405,107 +117,203 @@ function list_query($conference_id, $wherestatus, $reg_id)
left outer join projects on projects.registrations_id=registrations.id
WHERE
1
AND registrations.conferences_id='$conference_id'
AND registrations.year='$year'
$wherestatus
$reg $fair
ORDER BY
registrations.status DESC, projects.title
$ORDERBY
");
echo mysql_error();
return $q;
}
echo mysql_error();
echo "<table class=\"tableview\">";
echo "<tr>";
if($showstatus) $stat="&showstatus=".$showstatus;
echo "<th><a href=\"registration_list.php?sort=status$stat\">".i18n("Status")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=email\">".i18n("Email Address")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=num$stat\">".i18n("Reg Num")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=projnum$stat\">".i18n("Proj Num")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=title$stat\">".i18n("Project Title")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=cat$stat\">".i18n("Age Category")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=div$stat\">".i18n("Division")."</a></th>";
echo "<th>".i18n("School(s)")."</th>";
echo "<th>".i18n("Student(s)")."</th>";
echo "<th>".i18n("Action")."</th>";
echo "</tr>";
$stats_totalprojects=0;
$stats_totalstudents=0;
$stats_divisions=array();
$stats_categories=array();
$stats_students_catdiv=array();
$stats_projects_catdiv=array();
$stats_students_schools=array();
$stats_projects_schools=array();
$schools_names=array();
while($r=mysql_fetch_object($q))
{
$stats_totalprojects++;
$stats_divisions[$r->projectdivisions_id]++;
$stats_categories[$r->projectcategories_id]++;
$stats_projects_catdiv[$r->projectcategories_id][$r->projectdivisions_id]++;
function print_row($r)
{
global $cats, $divs, $config, $conference_id, $conference;
switch($r->status) {
case "new": $status_text="New"; break;
case "open": $status_text="Open"; break;
case "paymentpending": $status_text="Payment Pending"; break;
case "complete": $status_text="Complete"; break;
}
$status_text=i18n($status_text);
$scl = "style=\"cursor:pointer;\" onclick=\"popup_editor('{$r->reg_id}','');\"";
$pcl = "style=\"cursor:pointer;\" onclick=\"popup_editor('{$r->reg_id}','project');\"";
echo "<td $scl>{$status_text}</td>";
// echo "<td $scl>{$r->email}</td>";
echo "<td $scl>{$r->reg_num}</td>";
$pn = str_replace(' ', '&nbsp;', $r->projectnumber);
echo "<td $scl>$pn</td>";
echo "<td $pcl>{$r->title}</td>";
echo "<td $scl>".i18n($cats[$r->projectcategories_id])."</td>";
echo "<td $scl>".i18n($divs[$r->projectdivisions_id])."</td>";
echo "<td>";
$sq=mysql_query("SELECT users.firstname,
users.lastname,
users.id,
schools.school,
schools.board,
schools.id AS schools_id,
accounts.username,
accounts.email,
accounts.pendingemail
FROM
users
JOIN accounts ON users.accounts_id=accounts.id
LEFT JOIN schools ON users.schools_id=schools.id
WHERE
users.registrations_id='$r->reg_id'
");
echo mysql_error();
$studnum=1;
$schools="";
$students="";
$scl = "style=\"cursor:pointer;\" onclick=\"popup_editor('{$r->reg_id}','');\"";
//if theres more than 1, we should show some headings between the tables
if(mysql_num_rows($sq)>1) $showheadings=true;
while($studentinfo=mysql_fetch_object($sq)) {
if($studentinfo->email) $e=$studentinfo->email;
else if($studentinfo->pendingemail) $e=$studentinfo->pendingemail;
else $e="";
if($showheadings)
echo "<b>Participant #$studnum</b><br />";
echo "<table style=\"cursor:pointer; border-collapse: collapse;\" onclick=\"popup_editor('{$r->reg_id}','');\">";
echo "<tr><th>Name</th><td>$studentinfo->firstname $studentinfo->lastname</td></tr>\n";
echo "<tr><th>Username</th><td>$studentinfo->username</td></tr>\n";
if($e && $studentinfo->username!=$e) {
echo "<tr><th>Email</th><td>$e</td></tr>\n";
switch($r->status)
{
case "new": $status_text="New"; break;
case "open": $status_text="Open"; break;
case "paymentpending": $status_text="Payment Pending"; break;
case "complete": $status_text="Complete"; break;
}
echo "<tr><th>School</th><td>$studentinfo->school</td></tr>\n";
echo "</table>\n";
$studnum++;
$status_text=i18n($status_text);
echo "<tr>";
echo "<td>$status_text</td>";
echo "<td>$r->email</td>";
echo "<td>$r->reg_num</td>";
echo "<td>$r->projectnumber</td>";
echo "<td><a title=\"".i18n("Click to edit")."\" href=\"project_editor.php?registration_id=$r->reg_id\">$r->title</a></td>";
echo "<td>".i18n($cats[$r->projectcategories_id])."</td>";
echo "<td>".i18n($divs[$r->projectdivisions_id])."</td>";
$sq=mysql_query("SELECT students.firstname,
students.lastname,
students.id,
schools.school,
schools.board,
schools.id AS schools_id
FROM
students,schools
WHERE
students.registrations_id='$r->reg_id'
AND
students.schools_id=schools.id
");
echo mysql_error();
$studnum=1;
$schools="";
$students="";
while($studentinfo=mysql_fetch_object($sq))
{
$students.="<a href=\"student_editor.php?registration_id=$r->reg_id\">$studentinfo->firstname $studentinfo->lastname </a><br />";
$schools.="$studentinfo->school <br />";
$stats_totalstudents++;
$stats_students_catdiv[$r->projectcategories_id][$r->projectdivisions_id]++;
$stats_students_schools[$r->projectcategories_id][$studentinfo->schools_id]++;
$schools_names[$studentinfo->schools_id]=$studentinfo->school." ($studentinfo->board)";
$lastschoolid=$studentinfo->schools_id;
}
//this really isnt right, its only taking the school from the last student in the project to count towards the school's project totals
//but there's really no other way
$stats_projects_schools[$r->projectcategories_id][$lastschoolid]++;
echo "<td>$schools</td>";
echo "<td>$students</td>";
echo "<td align=\"center\">";
if($year==$config['FAIRYEAR']) {
echo "<a href=\"registration_list.php?action=delete&delete=$r->reg_id\" onclick=\"return confirmClick('".i18n("Are you sure you want to completely delete this registration?")."');\">";
echo "<img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=0>";
echo "</a>";
}
echo "</td>";
echo "</tr>";
}
echo "</td>";
echo "<td align=\"center\" >";
if($conference_id==$conference['id']) {
echo "<a title=\"".i18n("Delete this registration")."\" href=\"#\" onClick=\"delete_registration({$r->reg_id});return false\" >";
echo "<img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=0>";
echo "</a>";
/*
echo "<form target=\"_blank\" method=\"post\" action=\"../register_participants.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"continue\">";
echo "<input type=\"hidden\" name=\"email\" value=\"$r->email\">";
echo "<input type=\"hidden\" name=\"regnum\" value=\"$r->reg_num\">";
echo "<input type=\"submit\" value=\"".i18n("Login")."\">";
echo "</form>";
*/
echo "</table>\n";
echo "<br />";
echo "<table style=\"margin-left: 50px;\">";
echo "<tr><td colspan=\"2\"><h3>{$status_str[$showstatus]} - ".i18n("Students / projects per age category / division")."</h3></td></tr>";
echo "<tr><td colspan=\"2\">";
echo "<table class=\"tableview\" width=\"100%\">";
echo "<tr><td width=\"50%\"></td>";
foreach($cats AS $c=>$cn) {
echo "<th>$cn<br /><nobr>".i18n("Stud | Proj")."</nobr></th>";
}
echo "</td>";
echo "<th>".i18n("Total")."<br /><nobr>".i18n("Stud | Proj")."</th>";
echo "</tr>";
foreach($divs AS $d=>$dn) {
echo "<tr><td>$dn</td>";
$tstud=0;
$tproj=0;
foreach($cats AS $c=>$cn)
{
echo "<td align=\"center\">";
echo ($stats_students_catdiv[$c][$d]?$stats_students_catdiv[$c][$d]:0);
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo ($stats_projects_catdiv[$c][$d]?$stats_projects_catdiv[$c][$d]:0);
echo "</td>";
$tstud+=$stats_students_catdiv[$c][$d];
$tproj+=$stats_projects_catdiv[$c][$d];
}
$tstudcat[$c]+=$stats_students_catdiv[$c][$d];
$tprojcat[$c]+=$stats_projects_catdiv[$c][$d];
}
echo "<td align=\"center\"><b>";
echo ($tstud?$tstud:0);
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo ($tproj?$tproj:0);
echo "</b></td>";
echo "</tr>";
}
echo "<tr><td><b>".i18n("Total")."</b></td>";
$tstud=0;
$tproj=0;
foreach($cats AS $c=>$cn) {
echo "<td align=\"center\"><b>";
echo ($tstudcat[$c]?$tstudcat[$c]:0);
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo ($tprojcat[$c]?$tprojcat[$c]:0);
echo "</b></td>";
$tstud+=$tstudcat[$c];
$tproj+=$tprojcat[$c];
}
echo "<td align=\"center\"><b>";
echo ($tstud);
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo ($tproj);
echo "</b></td>";
echo "</tr>";
echo "</table>";
echo "</td></tr>";
echo "<tr><td colspan=\"2\"><br /></td></tr>";
echo "<tr><td colspan=\"2\"><h3>{$status_str[$showstatus]} - ".i18n("Students / projects per age category / school")."</h3></td></tr>";
echo "<tr><td colspan=\"2\">";
echo "<table class=\"tableview\" width=\"100%\">";
echo "<tr><td width=\"50%\"></td>";
foreach($cats AS $c=>$cn) {
echo "<th>$cn<br /><nobr>".i18n("Stud | Proj")."</nobr></th>";
}
echo "<th>".i18n("Total")."<br /><nobr>".i18n("Stud | Proj")."</nobr></th>";
echo "</tr>";
asort($schools_names);
foreach($schools_names AS $id=>$sn)
{
echo "<tr><td>$sn</td>";
$tstud=0;
$tproj=0;
foreach($cats AS $c=>$cn) {
echo "<td align=\"center\">".($stats_students_schools[$c][$id]?$stats_students_schools[$c][$id]:0);
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo ($stats_projects_schools[$c][$id]?$stats_projects_schools[$c][$id]:0)."</td>";
$tstud+=$stats_students_schools[$c][$id];
$tproj+=$stats_projects_schools[$c][$id];
}
echo "<td align=\"center\"><b>".($tstud?$tstud:0);
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo ($tproj?$tproj:0)."</b></td>";
echo "</tr>";
}
echo "</table>";
echo i18n("%1 schools total",array(count($schools_names)));
echo "</td></tr>";
echo "</table>";
echo "<br />";
echo i18n("Note: statistics reflect the numbers of the current 'Status' selected at the top of the page");
echo "<br />";
echo "<br />";
send_footer();
?>

View File

@ -22,10 +22,10 @@
*/
?>
<?
require_once("../common.inc.php");
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
require_once("../register_participants.inc.php");
user_auth_required('committee', 'admin');
require("../register_participants.inc.php");
send_header("Input Received Signature Forms",
array('Committee Main' => 'committee_main.php',
@ -37,7 +37,7 @@
$showformatbottom=true;
if($_POST['action']=="received" && $_POST['registration_number'])
{
$q=mysql_query("SELECT * FROM registrations WHERE num='".$_POST['registration_number']."' AND conferences_id='".$conference['id']."'");
$q=mysql_query("SELECT * FROM registrations WHERE num='".$_POST['registration_number']."' AND year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q)==1)
{
$r=mysql_fetch_object($q);
@ -45,13 +45,14 @@ $showformatbottom=true;
$reg_num=$r->num;
$reg_status=$r->status;
if($r->status=='new') {
if($r->status=='new')
{
echo error(i18n("Invalid Registration Status (%1 is New). Cannot receive an empty form.",array($_POST['registration_number'])));
}
else
{
//make sure all of the statuses are correct
$statusstudent=studentsStatus($reg_id);
$statusstudent=studentStatus($reg_id);
$statusemergencycontact=emergencycontactStatus($reg_id);
$statusproject=projectStatus($reg_id);
if($config['participant_mentor']=="yes")
@ -77,10 +78,10 @@ $showformatbottom=true;
projects,projectcategories,projectdivisions
WHERE
projects.registrations_id='$reg_id'
AND projects.projectcategories_id=projectcategories.id
AND projects.projectdivisions_id=projectdivisions.id
AND projectcategories.conferences_id=projects.conferences_id
AND projectdivisions.conferences_id=projects.conferences_id
AND
projects.projectcategories_id=projectcategories.id
AND
projects.projectdivisions_id=projectdivisions.id
");
echo mysql_Error();
@ -99,15 +100,15 @@ echo mysql_Error();
echo "<tr><td><b>".i18n("Project Title")."</b></td><td>$projectinfo->title</td></tr>";
echo "<tr><td><b>".i18n("Category / Division")."</b></td><td>$projectinfo->category / $projectinfo->division</td></tr>";
$q=mysql_query("SELECT users.firstname,
users.lastname,
$q=mysql_query("SELECT students.firstname,
students.lastname,
schools.school
FROM
users,schools
students,schools
WHERE
users.registrations_id='$reg_id'
students.registrations_id='$reg_id'
AND
users.schools_id=schools.id
students.schools_id=schools.id
");
$studnum=1;
@ -124,7 +125,8 @@ echo mysql_Error();
echo "</table>\n";
echo "<br />";
if($r->status!='complete') {
if($r->status!='complete')
{
echo "<table style=\"margin-left: 30px;\">";
echo "<tr><td colspan=\"3\">";
echo i18n("Is this the correct form to register?");
@ -135,28 +137,30 @@ echo mysql_Error();
echo "<form method=\"post\" action=\"registration_receivedforms.php\">";
echo "<input type=\"hidden\" name=\"registration_number\" value=\"$reg_num\" />";
echo "<input type=\"hidden\" name=\"action\" value=\"receivedno\" />";
echo "<input type=submit value=\"".i18n("No, this is the wrong form")."\" style=\"width: 400px; height: 40px; margin: 10px;\"/>";
echo "<input type=submit value=\"".i18n("No, this is the wrong form")."\" style=\"width: 400px;\"/>";
echo "</form>";
if($config['regfee']>0) {
if($config['regfee']>0)
{
echo "<form method=\"post\" action=\"registration_receivedforms.php\">";
echo "<input type=\"hidden\" name=\"registration_number\" value=\"$reg_num\" />";
echo "<input type=\"hidden\" name=\"action\" value=\"receivedyes\" />";
echo "<input type=submit value=\"".i18n("Yes, right form with registration fee")."\" style=\"width: 400px; height: 40px; margin: 10px;\"/>";
echo "<input type=submit value=\"".i18n("Yes, right form with registration fee")."\" style=\"width: 400px;\"/>";
echo "</form>";
echo "<form method=\"post\" action=\"registration_receivedforms.php\">";
echo "<input type=\"hidden\" name=\"registration_number\" value=\"$reg_num\" />";
echo "<input type=\"hidden\" name=\"action\" value=\"receivedyesnocash\" />";
echo "<input type=submit value=\"".i18n("Yes, right form without registration fee")."\" style=\"width: 400px; height: 40px; margin: 10px;\"/>";
echo "<input type=submit value=\"".i18n("Yes, right form without registration fee")."\" style=\"width: 400px;\"/>";
echo "</form>";
}
else {
else
{
echo "<form method=\"post\" action=\"registration_receivedforms.php\">";
echo "<input type=\"hidden\" name=\"registration_number\" value=\"$reg_num\" />";
echo "<input type=\"hidden\" name=\"action\" value=\"receivedyes\" />";
echo "<input type=submit value=\"".i18n("Yes, this is the right form")."\" style=\"width: 400px; height: 40px; margin: 10px;\"/>";
echo "<input type=submit value=\"".i18n("Yes, this is the right form")."\" style=\"width: 400px;\"/>";
echo "</form>";
@ -168,7 +172,8 @@ echo mysql_Error();
echo "</table>";
$showformatbottom=false;
}
else {
else
{
echo i18n("This form has already been received. Registration is complete");
echo "<br />";
echo "<a href=\"registration_receivedforms.php?action=unregister&registration_number=$reg_num\">".i18n("Click here to unregister this project")."</a>";
@ -178,16 +183,9 @@ echo mysql_Error();
}
else {
else
{
echo error(i18n("All registration sections are not complete. Cannot register incomplete form"));
$reg=getRegistration($reg_id);
echo "<table class=\"tableview\">";
echo "<b>Registration Number: {$reg['registration_number']}</b><br />\n";
foreach($reg['status'] AS $k=>$v) {
echo "<tr><th>$k</td><td>".outputStatus($v)."</td></tr>\n";
}
echo "</table>\n";
echo "<br /><br />\n";
}
}
}
@ -206,11 +204,11 @@ echo mysql_Error();
FROM projects, registrations
WHERE projects.registrations_id = registrations.id
AND num='$regnum'
AND registrations.conferences_id='{$conference['id']}'");
AND registrations.year='{$config['FAIRYEAR']}'");
$checkNumResults=mysql_fetch_object($checkNumQuery);
$projectnum=$checkNumResults->projectnumber;
$q=mysql_query("SELECT id FROM registrations WHERE num='$regnum' AND conferences_id='{$conference['id']}'");
$q=mysql_query("SELECT id FROM registrations WHERE num='$regnum' AND year='{$config['FAIRYEAR']}'");
$r=mysql_fetch_object($q);
$reg_id = $r->id;
@ -219,7 +217,7 @@ echo mysql_Error();
list($projectnumber,$ps,$pns,$pss) = generateProjectNumber($reg_id);
mysql_query("UPDATE projects SET projectnumber='$projectnumber',
projectsort='$ps',projectnumber_seq='$pns',projectsort_seq='$pss'
WHERE registrations_id='$reg_id' AND conferences_id='{$conference['id']}'");
WHERE registrations_id='$reg_id' AND year='{$config['FAIRYEAR']}'");
echo happy(i18n("Assigned Project Number: %1",array($projectnumber)));
}
else
@ -228,22 +226,27 @@ echo mysql_Error();
//get all students with this registration number
$recipients=getEmailRecipientsForRegistration($reg_id);
if($_POST['action']=="receivedyes") {
if($_POST['action']=="receivedyes")
{
//actually set it to 'complete'
mysql_query("UPDATE registrations SET status='complete' WHERE num='$regnum' AND conferences_id='{$conference['id']}'");
mysql_query("UPDATE registrations SET status='complete' WHERE num='$regnum' AND year='{$config['FAIRYEAR']}'");
foreach($recipients AS $recip) {
$subsub=array();
$to=$recip['to'];
$subsub=array(
"FAIRNAME"=>$config['fairname']
);
$subbod=array(
"TO"=>$recip['to'],
"EMAIL"=>$recip['email'],
"FIRSTNAME"=>$recip['firstname'],
"LASTNAME"=>$recip['lastname'],
"USERNAME"=>$recip['username'],
"NAME"=>$recip['firstname']." ".$recip['lastname'],
"REGNUM"=>$regnum,
"PROJECTNUMBER"=>$projectnumber,
"FAIRNAME"=>$config['fairname']
);
$res=email_send("register_participants_received",$recip['email'],$subsub,$subbod);
email_send("register_participants_received",$to,$subsub,$subbod);
}
echo happy(i18n("Registration of form %1 successfully completed",array($regnum)));
@ -251,40 +254,46 @@ echo mysql_Error();
else if($_POST['action']=="receivedyesnocash")
{
//actually set it to 'paymentpending'
mysql_query("UPDATE registrations SET status='paymentpending' WHERE num='$regnum' AND conferences_id='{$conference['id']}'");
mysql_query("UPDATE registrations SET status='paymentpending' WHERE num='$regnum' AND year='{$config['FAIRYEAR']}'");
foreach($recipients AS $recip) {
$subsub=array();
$to=$recip['to'];
$subsub=array(
"FAIRNAME"=>$config['fairname']
);
$subbod=array(
"TO"=>$recip['to'],
"EMAIL"=>$recip['email'],
"FIRSTNAME"=>$recip['firstname'],
"LASTNAME"=>$recip['lastname'],
"USERNAME"=>$recip['username'],
"NAME"=>$recip['firstname']." ".$recip['lastname'],
"REGNUM"=>$regnum,
"PROJECTNUMBER"=>$projectnumber,
"FAIRNAME"=>$config['fairname']
);
email_send("register_participants_paymentpending",$recip['email'],$subsub,$subbod);
email_send("register_participants_paymentpending",$to,$subsub,$subbod);
}
echo happy(i18n("Registration of form %1 marked as payment pending",array($regnum)));
}
}
else if($_POST['action']=="receivedno" && $_POST['registration_number']) {
else if($_POST['action']=="receivedno" && $_POST['registration_number'])
{
echo notice(i18n("Registration of form %1 cancelled",array($_POST['registration_number'])));
}
else if($_GET['action']=="unregister" && $_GET['registration_number']) {
$reg_num=intval(trim($_GET['registration_number']));
$q=mysql_query("SELECT registrations.id AS reg_id, projects.id AS proj_id FROM projects,registrations WHERE projects.registrations_id=registrations.id AND registrations.conferences_id='{$conference['id']}' AND registrations.num='$reg_num'");
$q=mysql_query("SELECT registrations.id AS reg_id, projects.id AS proj_id FROM projects,registrations WHERE projects.registrations_id=registrations.id AND registrations.year='{$config['FAIRYEAR']}' AND registrations.num='$reg_num'");
$r=mysql_fetch_object($q);
mysql_query("UPDATE projects SET projectnumber=null, projectsort=null, projectnumber_seq=0, projectsort_seq=0 WHERE id='$r->proj_id' AND conferences_id='{$conference['id']}'");
mysql_query("UPDATE registrations SET status='open' WHERE id='$r->reg_id' AND conferences_id='{$conference['id']}'");
mysql_query("UPDATE projects SET projectnumber=null, projectsort=null, projectnumber_seq=0, projectsort_seq=0 WHERE id='$r->proj_id' AND year='{$config['FAIRYEAR']}'");
mysql_query("UPDATE registrations SET status='open' WHERE id='$r->reg_id' AND year='{$config['FAIRYEAR']}'");
echo happy(i18n("Successfully unregistered project"));
}
if($showformatbottom) {
if($showformatbottom)
{
echo "<form id=\"inputform\" method=\"post\" action=\"registration_receivedforms.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"received\" />";
echo i18n("Enter the registration number from the signature form: ")."<br />";

View File

@ -1,340 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005-2006 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005-2006 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require_once("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
require_once("../register_participants.inc.php");
if($_GET['conferences_id']) $conferences_id=$_GET['conferences_id'];
else $conferences_id=$conference['id'];
send_header("Registration Statistics",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Participant Registration' => 'admin/registration.php')
);
echo "<br />";
echo i18n("Choose Status").":";
echo "<form name=\"statuschangerform\" method=\"get\" action=\"registration_stats.php\">";
echo "<select name=\"showstatus\" onchange=\"document.forms.statuschangerform.submit()\">";
$status_str = array();
$status_str[''] = i18n("Any Status");
$status_str['complete'] = i18n("Complete");
//if there is no reg fee, then we dont need to show this status, because nobody will ever be in this status
if($config['regfee']>0) {
$status_str['paymentpending'] = i18n("Payment Pending");
$status_str['completeorpaymentpending'] = i18n("Complete or Payment Pending");
}
$status_str['open'] = i18n("Open");
$status_str['new'] = i18n("New");
$showstatus = $_GET['showstatus'];
foreach($status_str as $s=>$str) {
$sel = ($showstatus == $s) ? "selected=\"selected\"" : '';
echo "<option $sel value=\"$s\">$str</option>\n";
}
echo "</select>";
echo "</form>";
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='$conferences_id' ORDER BY id");
while($r=mysql_fetch_object($q))
$cats[$r->id]=$r->category;
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='$conferences_id' ORDER BY id");
while($r=mysql_fetch_object($q))
$divs[$r->id]=$r->division;
if($showstatus) {
switch($showstatus) {
case "complete": $wherestatus="AND status='complete' "; break;
case "paymentpending": $wherestatus="AND status='paymentpending' "; break;
case "completeorpaymentpending": $wherestatus="AND (status='complete' OR status='paymentpending') "; break;
case "open": $wherestatus="AND status='open' "; break;
case "new": $wherestatus="AND status='new' "; break;
default: $wherestatus="";
}
}
else $wherestatus="";
switch($_GET['sort']) {
case 'status': $ORDERBY="registrations.status DESC, projects.title"; break;
case 'num': $ORDERBY="registrations.num"; break;
case 'projnum': $ORDERBY="projects.projectsort, projects.projectnumber"; break;
case 'title': $ORDERBY="projects.title, registrations.status DESC"; break;
case 'cat': $ORDERBY="projects.projectcategories_id, projects.title"; break;
case 'div': $ORDERBY="projects.projectdivisions_id, projects.title"; break;
default: $ORDERBY="registrations.status DESC, projects.title"; break;
}
$q=mysql_query("SELECT registrations.id AS reg_id,
registrations.num AS reg_num,
registrations.status,
registrations.email,
projects.title,
projects.projectnumber,
projects.projectcategories_id,
projects.projectdivisions_id,
projects.language
FROM
registrations
left outer join projects on projects.registrations_id=registrations.id
WHERE
1
AND registrations.conferences_id='$conferences_id'
$wherestatus
ORDER BY
$ORDERBY
");
echo mysql_error();
$stats_totalprojects=0;
$stats_totalstudents=0;
$stats_divisions=array();
$stats_categories=array();
$stats_students_catdiv=array();
$stats_projects_catdiv=array();
$stats_students_schools=array();
$stats_projects_schools=array();
$stats_projects_lang=array();
$schools_names=array();
$languages=array();
while($r=mysql_fetch_object($q))
{
$stats_totalprojects++;
$stats_divisions[$r->projectdivisions_id]++;
$stats_categories[$r->projectcategories_id]++;
$stats_projects_catdiv[$r->projectcategories_id][$r->projectdivisions_id]++;
$stats_projects_lang[$r->projectcategories_id][$r->projectdivisions_id][$r->language]++;
$languages[$r->language]++;
switch($r->status)
{
case "new": $status_text="New"; break;
case "open": $status_text="Open"; break;
case "paymentpending": $status_text="Payment Pending"; break;
case "complete": $status_text="Complete"; break;
}
$status_text=i18n($status_text);
$sq=mysql_query("SELECT users.firstname,
users.lastname,
users.id,
schools.school,
schools.board,
schools.id AS schools_id
FROM
users,schools
WHERE
users.registrations_id='$r->reg_id'
AND
users.schools_id=schools.id
");
echo mysql_error();
$studnum=1;
$schools="";
$students="";
while($studentinfo=mysql_fetch_object($sq))
{
$stats_totalstudents++;
$stats_students_catdiv[$r->projectcategories_id][$r->projectdivisions_id]++;
$stats_students_schools[$r->projectcategories_id][$studentinfo->schools_id]++;
$schools_names[$studentinfo->schools_id]=$studentinfo->school." ($studentinfo->board)";
$lastschoolid=$studentinfo->schools_id;
}
//this really isnt right, its only taking the school from the last student in the project to count towards the school's project totals
//but there's really no other way
$stats_projects_schools[$r->projectcategories_id][$lastschoolid]++;
}
echo "<table style=\"margin-left: 50px;\">";
echo "<tr><td colspan=\"2\"><h3>{$status_str[$showstatus]} - ".i18n("Students / projects per age category / division")."</h3></td></tr>";
echo "<tr><td colspan=\"2\">";
echo "<table class=\"tableview\" width=\"100%\">";
echo "<thead><tr><td width=\"50%\"></td>";
foreach($cats AS $c=>$cn) {
echo "<th>$cn<br /><nobr>".i18n("Stud | Proj")."</nobr></th>";
}
echo "<th>".i18n("Total")."<br /><nobr>".i18n("Stud | Proj")."</th>";
echo "</tr></thead>";
echo "<tbody>";
foreach($divs AS $d=>$dn) {
echo "<tr><td>$dn</td>";
$tstud=0;
$tproj=0;
foreach($cats AS $c=>$cn)
{
echo "<td align=\"center\">";
echo ($stats_students_catdiv[$c][$d]?$stats_students_catdiv[$c][$d]:0);
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo ($stats_projects_catdiv[$c][$d]?$stats_projects_catdiv[$c][$d]:0);
echo "</td>";
$tstud+=$stats_students_catdiv[$c][$d];
$tproj+=$stats_projects_catdiv[$c][$d];
$tstudcat[$c]+=$stats_students_catdiv[$c][$d];
$tprojcat[$c]+=$stats_projects_catdiv[$c][$d];
}
echo "<td align=\"center\"><b>";
echo ($tstud?$tstud:0);
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo ($tproj?$tproj:0);
echo "</b></td>";
echo "</tr>";
}
echo "<tr><td><b>".i18n("Total")."</b></td>";
$tstud=0;
$tproj=0;
foreach($cats AS $c=>$cn) {
echo "<td align=\"center\"><b>";
echo ($tstudcat[$c]?$tstudcat[$c]:0);
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo ($tprojcat[$c]?$tprojcat[$c]:0);
echo "</b></td>";
$tstud+=$tstudcat[$c];
$tproj+=$tprojcat[$c];
}
echo "<td align=\"center\"><b>";
echo ($tstud);
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo ($tproj);
echo "</b></td>";
echo "</tr>";
echo "</tbody>";
echo "</table>";
echo "</td></tr>";
echo "<tr><td colspan=\"2\"><br /></td></tr>";
echo "<tr><td colspan=\"2\"><h3>{$status_str[$showstatus]} - ".i18n("Students / projects per age category / school")."</h3></td></tr>";
echo "<tr><td colspan=\"2\">";
echo "<table class=\"tableview\" width=\"100%\">";
echo "<thead><tr><td width=\"50%\"></td>";
foreach($cats AS $c=>$cn) {
echo "<th>$cn<br /><nobr>".i18n("Stud | Proj")."</nobr></th>";
}
echo "<th>".i18n("Total")."<br /><nobr>".i18n("Stud | Proj")."</nobr></th>";
echo "</tr></thead>";
echo "<tbody>";
asort($schools_names);
foreach($schools_names AS $id=>$sn) {
echo "<tr><td>$sn</td>";
$tstud=0;
$tproj=0;
foreach($cats AS $c=>$cn) {
echo "<td align=\"center\">".($stats_students_schools[$c][$id]?$stats_students_schools[$c][$id]:0);
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo ($stats_projects_schools[$c][$id]?$stats_projects_schools[$c][$id]:0)."</td>";
$tstud+=$stats_students_schools[$c][$id];
$tproj+=$stats_projects_schools[$c][$id];
}
echo "<td align=\"center\"><b>".($tstud?$tstud:0);
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo ($tproj?$tproj:0)."</b></td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo i18n("%1 schools total",array(count($schools_names)));
echo "</td></tr>";
echo "<tr><td colspan=\"2\"><br /></td></tr>";
echo "<tr><td colspan=\"2\"><h3>{$status_str[$showstatus]} - ".i18n("Projects per age category / division / language")."</h3></td></tr>";
echo "<tr><td colspan=\"2\">";
echo "<table class=\"tableview\" width=\"100%\">";
echo "<thead><tr><th rowspan='2' width=\"50%\"></th>";
foreach($cats AS $c=>$cn) {
echo "<th colspan='".count($languages)."'>$cn</th>";
}
echo "<th colspan='".count($languages)."'>".i18n("Total")."</nobr></th>";
echo "</tr><tr>";
ksort($languages);
$tprojcat = array();
foreach($cats AS $c=>$cn) {
foreach($languages AS $l=>$ln) {
echo "<th>$l</th>";
}
}
foreach($languages AS $l=>$ln) {
echo "<th>$l</th>";
}
echo "</tr></thead>";
echo "<tbody>";
foreach($divs AS $d=>$dn) {
echo "<tr><td>$dn</td>";
$tproj=array();
foreach($cats AS $c=>$cn) {
foreach($languages AS $l=>$ln) {
echo "<td align=\"center\">";
echo ($stats_projects_lang[$c][$d][$l]?$stats_projects_lang[$c][$d][$l]:0);
echo "</td>";
$tproj[$l]+=$stats_projects_lang[$c][$d][$l];
$tprojcat[$c][$l]+=$stats_projects_lang[$c][$d][$l];
}
}
foreach($tproj AS $l=>$ln) {
echo "<td align=\"center\"><b>";
echo ($ln?$ln:0);
echo "</b></td>";
}
echo "</tr>";
}
echo "<tr><td><b>".i18n("Total")."</b></td>";
$tproj=array();
foreach($cats AS $c=>$cn) {
foreach($languages AS $l=>$ln) {
echo "<td align=\"center\"><b>";
echo ($tprojcat[$c][$l]?$tprojcat[$c][$l]:0);
echo "</b></td>";
$tproj[$l]+=$tprojcat[$c][$l];
}
}
foreach($tproj AS $l=>$ln) {
echo "<td align=\"center\"><b>";
echo ($ln);
echo "</b></td>";
}
echo "</tr>";
echo "</tbody>";
echo "</table>";
echo "</td></tr>";
echo "</table>";
echo "<br />";
echo i18n("Note: statistics reflect the numbers of the current 'Status' selected at the top of the page");
echo "<br />";
echo "<br />";
send_footer();
?>

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
send_header("Web Consent",
array('Committee Main' => 'committee_main.php',
@ -34,15 +34,18 @@
echo "<br />";
if(is_array($_POST['changed'])) {
if(is_array($_POST['changed']))
{
$numchanged=0;
foreach($_POST['changed'] AS $id=>$val) {
if($val==1) {
foreach($_POST['changed'] AS $id=>$val)
{
if($val==1)
{
$numchanged++;
$webfirst=$_POST['webfirst'][$id]=="yes"?"yes":"no";
$weblast=$_POST['weblast'][$id]=="yes"?"yes":"no";
$webphoto=$_POST['webphoto'][$id]=="yes"?"yes":"no";
mysql_query("UPDATE users SET
mysql_query("UPDATE students SET
webfirst='$webfirst',
weblast='$weblast',
webphoto='$webphoto'
@ -68,38 +71,37 @@
<?
$sq=mysql_query("SELECT users.firstname,
users.lastname,
users.id,
$sq=mysql_query("SELECT students.firstname,
students.lastname,
students.id,
projects.projectnumber,
users.webfirst,
users.weblast,
users.webphoto
students.webfirst,
students.weblast,
students.webphoto
FROM
users,
students,
registrations,
projects
WHERE
users.registrations_id=registrations.id
students.registrations_id=registrations.id
AND ( registrations.status = 'complete' OR registrations.status='paymentpending' )
AND projects.registrations_id=registrations.id
AND registrations.conferences_id='".$conference['id']."'
AND projects.conferences_id='".$conference['id']."'
AND users.conferences_id='".$conference['id']."'
AND registrations.year='".$config['FAIRYEAR']."'
AND projects.year='".$config['FAIRYEAR']."'
AND students.year='".$config['FAIRYEAR']."'
ORDER BY projectnumber
");
echo mysql_error();
echo "<form method=\"post\" action=\"registration_webconsent.php\">";
echo "<table class=\"tableview\">";
echo "<thead><tr>";
echo "<tr>";
echo " <th>".i18n("Proj #")."</th>";
echo " <th>".i18n("Student Name")."</th>";
echo " <th>".i18n("First")."</th>";
echo " <th>".i18n("Last")."</th>";
echo " <th>".i18n("Photo")."</th>";
echo "</tr></thead>";
echo "<tbody>";
echo "</tr>";
while($r=mysql_fetch_object($sq))
{
echo "<tr>";
@ -113,7 +115,6 @@
echo "<td><input $ch type=\"checkbox\" name=\"webphoto[$r->id]\" value=\"yes\" onchange=\"changed($r->id)\"></td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "<input type=\"submit\" value=\"".i18n("Save Changes")."\">";
echo "</form>";

View File

@ -3,7 +3,7 @@
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2008 James Grant <james@lightbox.org>
Copyright (C) 2007 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
@ -19,13 +19,27 @@
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
$theme['name']="Classic";
$theme['description']="A classic colour scheme";
$theme['author']="James Grant <james@lightbox.org>";
$theme['css']=array(
"sfiab.css",
"jquery-ui-1.7.2.custom.css"
);
?>
<?
require_once("../common.inc.php");
require_once("../user.inc.php");
require_once("reports.inc.php");
user_auth_required('committee');
if($_GET['reports_id'])
$reports_id=$_GET['reports_id'];
if($reports_id > 0) {
$report = report_load($reports_id);
echo $report['option']['type']."\n";
echo $report['option']['stock']."\n";
echo $report['desc']."\n";
// echo json_encode($report);
}
else
{
echo "\n\n\n";
// echo json_encode(array());
}
?>

View File

@ -28,12 +28,9 @@
require_once("reports_volunteers.inc.php"); /* $report_volunteers_fields */
require_once("reports_schools.inc.php");
require_once("reports_tours.inc.php");
require_once("reports_fairs.inc.php");
require_once("reports_fundraising.inc.php");
require_once('../lpdf.php');
require_once('../lcsv.php');
require_once('../tcpdf.inc.php');
$filter_ops = array( 0 => '=',
1 => '<=',
@ -49,7 +46,7 @@
$report_options = array();
$report_options['type'] = array('desc' => 'Report Format',
'values' => array('pdf' => 'PDF', 'label'=>'Label', 'csv'=>'CSV (for Excel)', 'text'=>'Coming Soon: Text (Plain text in columns)', 'html'=>'Coming Soon: HTML (Browser Renderable)' )
'values' => array('pdf'=>'PDF', 'csv'=>'CSV', 'label'=>'Label')
);
$report_options['group_new_page'] = array('desc' => 'Start each new grouping on a new page',
'values' => array('no'=>'No', 'yes'=>'Yes')
@ -66,14 +63,14 @@
$report_options['field_box'] = array('desc' => 'Draw a box around each text field on the label',
'values' => array('no'=>'No', 'yes'=>'Yes')
);
$report_options['default_font_size'] = array('desc' => 'Default font size to use in the report',
'values' => array(
'10'=>'10',
'11'=>'11', '12'=>'12',
'13'=>'13', '14'=>'14', '15'=>'15', '16'=>'16', '18'=>'18',
'20'=>'20', '22'=>'22', '24'=>'24'
)
$report_options['label_fairname'] = array('desc' => 'Print the fair name at the top of each label',
'values' => array('no'=>'No', 'yes'=>'Yes')
);
$report_options['label_logo'] = array('desc' => 'Print the fair logo at the top of each label',
'values' => array('no'=>'No', 'yes'=>'Yes')
);
/*
@ -90,137 +87,149 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */
/* FIXME: put these in a databse */
/* All dimensions are in millimeters */
$report_stock = array();
$report_stock['fullpage'] = array('name' => 'Letter 8.5 x 11 (3/4" margin)',
'page_format' => 'LETTER',
'page_orientation' => 'P',
'label_width' => 177.8,
'label_height' => 241.3,
'page_width' => 8.5,
'page_height' => 11,
'label_width' => 7,
'x_spacing' => 0,
'y_spacing' => 0,
'cols' => 1,
'label_height' => 9.5,
'y_spacing' => 0,
'rows' => 1,
);
$report_stock['fullpage_landscape'] = array('name' => 'Letter 8.5 x 11 Landscape (3/4" margin)',
'page_format' => 'LETTER',
'page_orientation' => 'L',
'label_width' => 241.3,
'label_height' => 177.8,
'page_width' => 11,
'page_height' => 8.5,
'label_width' => 9.5,
'x_spacing' => 0,
'y_spacing' => 0,
'cols' => 1,
'label_height' => 7,
'y_spacing' => 0,
'rows' => 1,
);
$report_stock['fullpage_full'] = array('name' => 'Letter 8.5 x 11 (no margin)',
'page_format' => 'LETTER',
'page_orientation' => 'P',
'label_width' => 215.9,
'label_height' => 279.4,
'page_width' => 8.5,
'page_height' => 11,
'label_width' => 8.5,
'x_spacing' => 0,
'y_spacing' => 0,
'cols' => 1,
'label_height' => 11,
'y_spacing' => 0,
'rows' => 1,
);
$report_stock['fullpage_landscape_full'] = array('name' => 'Letter 8.5 x 11 Landscape (no margin)',
'page_format' => 'LETTER',
'page_orientation' => 'L',
'label_width' => 279.4,
'label_height' => 215.9,
'page_width' => 11,
'page_height' => 8.5,
'label_width' => 11,
'x_spacing' => 0,
'y_spacing' => 0,
'cols' => 1,
'label_height' => 8.5,
'y_spacing' => 0,
'rows' => 1,
);
$report_stock['5161'] = array('name' => 'Avery 5161/5261/5961/8161, G&T 99189 (1"x4")',
'page_format' => 'LETTER',
'page_orientation' => 'P',
'label_width' => 101.6,
'label_height' => 25.4,
'x_spacing' => 3.81,
'y_spacing' => 0.00,
'page_width' => 8.5,
'page_height' => 11,
'label_width' => 4,
'x_spacing' => 0.15,
'cols' => 2,
'label_height' => 1,
'y_spacing' => 0.00,
'y_padding' => 0.05,
'rows' => 10,
);
$report_stock['5162'] = array('name' => 'Avery 5162/5262/5962/8162/8462, G&T 99190 (1 1/3"x4")',
'page_format' => 'LETTER',
'page_orientation' => 'P',
'label_width' => 101.35,
'label_height' => 33.6804,
'x_spacing' => 4.7498,
'y_spacing' => 0.00,
'page_width' => 8.5,
'page_height' => 11,
'label_width' => 4,
'x_spacing' => 0.187,
'cols' => 2,
'label_height' => 1 + 0.33,
'y_spacing' => 0.00,
'y_padding' => 0.80,
'rows' => 7,
);
$report_stock['5163'] = array('name' => 'Avery 5163/5263/5963/8163/8463, G&T 99181 (2"x4")',
'page_format' => 'LETTER',
'page_orientation' => 'P',
'label_width' => 101.6,
'label_height' => 50.8,
'x_spacing' => 4.3663,
'y_spacing' => 0.00,
'page_width' => 8.5,
'page_height' => 11,
'label_width' => 4,
'x_spacing' => 0.1719,
'cols' => 2,
'label_height' => 2,
'y_spacing' => 0.00,
'rows' => 5,
);
$report_stock['5164'] = array('name' => 'Avery 5164/5264/5964/8164, G&T 99763 (4"x3 1/3")',
'page_format' => 'LETTER', /* tcpdf format */
'page_orientation' => 'P', /* tcpdf orientation */
'label_width' => 101.6,
'label_height' => 84.6667,
'x_spacing' => 4.7625,
'y_spacing' => 0,
/* This is combined with 5161
$report_stock['5961'] = array('name' => 'Avery 5961, G&T 99189 (1"x4")',
'page_width' => 8.5,
'page_height' => 11,
'label_width' => 4,
'x_spacing' => 0.08,
'cols' => 2,
'rows' => 3,
'label_height' => 1,
'y_spacing' => 0.08,
'rows' => 10,
);
*/
$report_stock['5164'] = array('name' => 'Avery 5164/5264/5964/8164, G&T 99763 (4"x3 1/3")',
'page_width' => 8.5,
'page_height' => 11,
'label_width' => 4,
'x_spacing' => 3/16,
'cols' => 2,
'label_height' => 3 + 1/3,
'y_spacing' => 0,
'rows' => 3,
);
$report_stock['nametag'] = array('name' => 'Cards 4"x3"',
'page_format' => 'LETTER',
'page_orientation' => 'P',
'label_width' => 101.6,
'label_height' => 76.2,
'page_width' => 8.5,
'page_height' => 11,
'label_width' => 4,
'x_spacing' => 0,
'y_spacing' => 0,
'cols' => 2,
'label_height' => 3,
'y_spacing' => 0,
'rows' => 3,
);
$report_stock['letter_4up'] = array('name' => 'Fullpage, 4up',
'page_format' => 'LETTER',
'page_orientation' => 'P',
'label_width' => 101.6,
'label_height' => 127.0,
'page_width' => 8.5,
'page_height' => 11,
'label_width' => 4,
'x_spacing' => 0.25,
'y_spacing' => 0.25,
'cols' => 2,
'label_height' => 5,
'y_spacing' => 0.25,
'rows' => 2,
);
$report_stock['ledger'] = array('name' => 'Ledger/Tabloid 11 x 17',
'page_format' => 'TABLOID',
'page_orientation' => 'P',
'label_width' => 279.4,
'label_height' => 431.8,
'page_width' => 11,
'page_height' => 17,
'label_width' => 11,
'x_spacing' => 0,
'y_spacing' => 0,
'cols' => 1,
'label_height' => 17,
'y_spacing' => 0,
'rows' => 1,
);
$report_stock['ledger_landscape'] = array('name' => 'Ledger/Tabloid 11 x 17 Landscape',
'page_format' => 'TABLOID',
'page_orientation' => 'L',
'label_width' => 431.8,
'label_height' => 279.4,
'page_width' => 17,
'page_height' => 11,
'label_width' => 17,
'x_spacing' => 0,
'y_spacing' => 0,
'cols' => 1,
'label_height' => 11,
'y_spacing' => 0,
'rows' => 1,
);
@ -256,11 +265,6 @@ foreach($report_stock as $n=>$v) {
'custom_url' => 'admin/reports_judges.php?type=csv',
'creator' => 'The Grant Brothers');
$x++;
$report_custom[$x] = array('id' => $x, 'name' => 'Custom -- Judges List (CSV) -- ALL YEARS',
'desc' => 'Judges List - All Years',
'custom_url' => 'admin/reports_judges_allyears.php?type=csv',
'creator' => 'The Grant Brothers');
$x++;
$report_custom[$x] = array('id' => $x, 'name' => 'Custom -- Judging Teams Project Assignments (PDF)',
'desc' => 'Judging Teams Project Assignments',
'custom_url' => 'admin/reports_judges_teams_projects.php?type=pdf',
@ -291,8 +295,8 @@ foreach($report_stock as $n=>$v) {
global $allow_options;
global $report_students_fields, $report_judges_fields, $report_awards_fields;
global $report_committees_fields, $report_schools_fields;
global $report_volunteers_fields, $report_fairs_fields;
global $report_tours_fields, $report_fundraisings_fields;
global $report_volunteers_fields;
global $report_tours_fields;
$fieldvar = "report_{$report['type']}s_fields";
@ -310,27 +314,24 @@ foreach($report_stock as $n=>$v) {
$x = 0;
foreach($report[$type] as $k=>$v) {
if($type == 'option') {
/* field, value, x, y, w, h, align, valign, fn, fs, fsize, overflow */
$vals = "'$k','$v','0','0','0','0','','','','','0','truncate'";
/* field, value, x, y, w, h, lines, face, align */
$vals = "'$k','$v','0','0','0','0','0','',''";
} else {
$fs = is_array($v['fontstyle']) ? implode(',',$v['fontstyle']) : '';
if($v['lines'] == 0) $v['lines'] =1;
$opts = "{$v['align']} {$v['valign']}";
$vals = "'{$v['field']}','{$v['value']}',
'{$v['x']}','{$v['y']}','{$v['w']}','{$v['h']}',
'{$v['align']}','{$v['valign']}',
'{$v['fontname']}','$fs','{$v['fontsize']}',
'{$v['on_overflow']}'";
'{$v['x']}','{$v['y']}','{$v['w']}',
'{$v['h']}','{$v['lines']}','{$v['face']}',
'$opts'";
}
if($q != '') $q .= ',';
$q .= "({$report['id']}, '$type','$x',$vals)";
$x++;
}
mysql_query("INSERT INTO reports_items(`reports_id`,`type`,`ord`,
`field`,`value`,`x`, `y`, `w`, `h`,
`align`,`valign`,
`fontname`,`fontstyle`,`fontsize`,`on_overflow`)
`lines`, `face`, `align`)
VALUES $q;");
echo mysql_error();
}
@ -340,8 +341,7 @@ foreach($report_stock as $n=>$v) {
global $allow_options, $report_students_fields, $report_judges_fields;
global $report_committees_fields, $report_awards_fields;
global $report_schools_fields, $report_volunteers_fields;
global $report_tours_fields, $report_fairs_fields;
global $report_fundraisings_fields;
global $report_tours_fields;
$report = array();
@ -395,16 +395,24 @@ foreach($report_stock as $n=>$v) {
}
/* Pull out all the data */
$val = array();
$col_fields = array('field', 'x', 'y', 'w', 'h', 'align', 'valign', 'value', 'fontname','fontsize','on_overflow');
$col_fields = array('field', 'x', 'y', 'w', 'h', 'lines', 'face', 'align', 'value');
foreach($col_fields as $lf) $val[$lf] = $a[$lf];
$val['fontstyle'] = explode(',', $a['fontstyle']);
if($val['lines'] == 0) $val['lines'] = 1;
$opts = explode(" ", $val['align']);
$align_opts = array ('left', 'right', 'center');
$valign_opts = array ('vtop', 'vbottom', 'vcenter');
$style_opts = array ('bold');
foreach($opts as $o) {
if(in_array($o, $align_opts)) $val['align'] = $o;
if(in_array($o, $valign_opts)) $val['valign'] = $o;
if(in_array($o, $valign_opts)) $val['face'] = $o;
}
$report[$t][$a['ord']] = $val;
break;
}
}
//`int_r($report);
return $report;
}
@ -431,7 +439,9 @@ foreach($report_stock as $n=>$v) {
}
/* print("<pre>");
/*
print("<pre>");
print_r($_POST);
print_r($report);
print("</pre>");
@ -494,10 +504,8 @@ foreach($report_stock as $n=>$v) {
{
global $config, $report_students_fields, $report_judges_fields, $report_awards_fields, $report_schools_fields;
global $report_stock, $report_committees_fields, $report_volunteers_fields;
global $report_tours_fields, $report_fairs_fields;
global $report_fundraisings_fields;
global $report_tours_fields;
global $filter_ops;
global $conference;
//print_r($report);
$fieldvar = "report_{$report['type']}s_fields";
@ -507,7 +515,9 @@ foreach($report_stock as $n=>$v) {
$fieldname = array();
$thead = array();
$table['col']=array();
$table['header']=array();
$table['widths']=array();
$table['dataalign']=array();
$table['option']=array();
$table['total']=0;
@ -524,40 +534,31 @@ foreach($report_stock as $n=>$v) {
$rep=new lcsv(i18n($report['name']));
$gen_mode = 'table';
break;
case 'label':
/* Label */
$label_stock = $report_stock[$report['option']['stock']];
$show_box = ($report['option']['label_box'] == 'yes') ? true : false;
$rep=new pdf($report['name'], $label_stock['page_format'], $label_stock['page_orientation']);
$rep->setup_for_labels($show_box, $show_fair, $show_logo,
$label_stock['label_width'], $label_stock['label_height'],
$label_stock['x_spacing'], $label_stock['y_spacing'],
$label_stock['rows'], $label_stock['cols']);
$rep=new lpdf( i18n($config['fairname']),
i18n($report['name']),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo.gif");
$rep->setPageStyle("labels");
$rep->newPage($label_stock['page_width'], $label_stock['page_height']);
$rep->setFontSize(11);
$rep->setLabelDimensions($label_stock['label_width'], $label_stock['label_height'],
$label_stock['x_spacing'], $label_stock['y_spacing'],11,$label_stock['y_padding']);
$gen_mode = 'label';
break;
case 'pdf': case '':
/* FIXME: handle landscape pages in here */
$label_stock = $report_stock[$report['option']['stock']];
if($report['option']['allow_multiline'] == 'yes')
$on_overflow = 'nothing';
else
$on_overflow = '...';
$rep=new pdf($report['name'], $label_stock['page_format'], $label_stock['page_orientation']);
$rep->setup_for_tables($show_box, $show_fair, $show_logo,
$label_stock['label_width'], $label_stock['label_height'],
$label_stock['x_spacing'], $label_stock['y_spacing'],
$label_stock['rows'], $label_stock['cols']);
$rep=new lpdf( i18n($config['fairname']),
i18n($report['name']),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo.gif");
$rep->newPage($label_stock['page_width'], $label_stock['page_height']);
$rep->setFontSize(11);
$gen_mode = 'table';
if($report['option']['allow_multiline'] == 'yes')
$table['option']['allow_multiline'] = true;
break;
case 'text':
echo "Not implemented [{$report['option']['type']}]";
exit;
default:
echo "Invalid type [{$report['option']['type']}]";
exit;
@ -576,47 +577,28 @@ foreach($report_stock as $n=>$v) {
* ones are scalable, just in case */
foreach($report['col'] as $o=>$d) {
$f = $d['field'];
if($d['w'] != 0) {
/* Always 0 on old reports, so we never get in here */
$total_width += $d['w'];
/* For the rest of the computation, this field is
* not scalable */
/* FIXME! */
} else {
$total_width += $fields[$f]['width'];
if($fields[$f]['scalable'] == true)
$scale_width += $fields[$f]['width'];
}
$total_width += $fields[$f]['width'];
if($fields[$f]['scalable'] == true)
$scale_width += $fields[$f]['width'];
}
/* Determine the scale factor (use the label width so
* we can enforce margins) */
if($report['option']['fit_columns'] == 'yes') { // && $total_width > $label_stock['label_width']) {
if($report['option']['fit_columns'] == 'yes' && $total_width > $label_stock['label_width']) {
$static_width = $total_width - $scale_width;
if($scale_width)
$scale_factor = ($label_stock['label_width'] - $static_width) / $scale_width;
else
$scale_factor = 1.0;
$scale_factor = ($label_stock['label_width'] - $static_width) / $scale_width;
//echo "$scale_factor;
} else {
$scale_factor = 1.0;
}
/* Select columns to display */
foreach($report['col'] as $o=>$d) {
$f = $d['field'];
/* If width is specificed, use that, else compute based on default field width */
if($d['w'] == 0)
$width = $fields[$f]['width'] * (($fields[$f]['scalable'] == true) ? $scale_factor : 1.0);
else
$width = $d['w'];
$col = array( 'header' => i18n($fields[$f]['header']),
'width' => $width,
'align' => 'left',
'on_overflow' => $on_overflow);
$table['col'][] = $col;
$table['header'][] = i18n($fields[$f]['header']);
$sf = ($fields[$f]['scalable'] == true) ? $scale_factor : 1.0;
$table['widths'][] = $fields[$f]['width'] * $sf;
$table['dataalign'][] = 'left';
$sel[] = "{$fields[$f]['table']} AS C$x";
$fieldname[$f] = "C$x";
/* We want to add these to group by, but AFTER all the other group bys */
@ -638,7 +620,7 @@ foreach($report_stock as $n=>$v) {
$fieldname[$f] = "G$o";
}
if(isset($fields[$f]['able_sort']))
if(isset($fields[$f]['table_sort']))
$order[] = $fields[$f]['table_sort'];
else
$order[] = $fieldname[$f];
@ -692,8 +674,8 @@ foreach($report_stock as $n=>$v) {
$order = implode(",", $order);
if(!isset($report['conferences_id'])){
$report['conferences_id'] = $conference['id'];
if(!isset($report['year'])) {
$report['year'] = $config['FAIRYEAR'];
}
$group_by = array_merge($group_by, $post_group_by);
@ -713,10 +695,6 @@ foreach($report_stock as $n=>$v) {
$q = "SELECT $sel $q $filter_query $group_query ORDER BY $order";
$r = mysql_query($q);
// print_r($report);
// print_r($report['filter']);
// echo "$q";
if($r == false) {
echo "The report database query has failed. This is
unfortunate but not your fault. Please send the following to
@ -729,14 +707,13 @@ foreach($report_stock as $n=>$v) {
echo "</pre>";
exit;
}
echo mysql_error();
$ncols = count($report['col']);
$n_groups = count($report['group']);
$last_group_data = array();
// echo "<pre>";print_r($rep);
while($i = mysql_fetch_assoc($r)) {
if($n_groups > 0) {
@ -744,16 +721,9 @@ foreach($report_stock as $n=>$v) {
/* See if any of the "group" fields have changed */
foreach($report['group'] as $x=>$g) {
$c = $fieldname[$g['field']];
if($fields[$g['field']]['exec_function'])
$i_c=call_user_func_array($fields[$g['field']]['exec_function'], array($report,$f,$i[$c]));
else
$i_c=$i[$c];
if($last_group_data[$c] != $i_c)
if($last_group_data[$c] != $i[$c])
$group_change = true;
$last_group_data[$c] = $i_c;
$last_group_data[$c] = $i[$c];
}
if($group_change) {
@ -761,36 +731,41 @@ foreach($report_stock as $n=>$v) {
if(count($table['data'])) {
// print_r($table);
$rep->addTable($table);
$rep->nextLine();
$table['data'] = array();
$table['total'] = 0;
/* Start a new page AFTER a table is
* dumped, so the first page doesn't
* end up blank */
if($report['option']['group_new_page'] == 'yes') {
$rep->addpage();
$rep->newPage();
} else {
$rep->hr();
$rep->vspace(-0.1);
}
}
/* Construct a new header */
$h = implode(" -- ", $last_group_data);
$rep->heading($h);
$rep->nextLine();
}
}
$data = array();
if($gen_mode == 'label') {
$rep->label_new();
$show_box = ($report['option']['label_box'] == 'yes') ? true : false;
$show_fair = ($report['option']['label_fairname'] == 'yes') ? true : false;
$show_logo = ($report['option']['label_logo'] == 'yes') ? true : false;
$rep->newLabel($show_box, $show_fair, $show_logo);
}
foreach($report['col'] as $o=>$d) {
$f = $d['field'];
if(is_array($fields[$f]['value_map'])) {
$v = $fields[$f]['value_map'][$i["C$o"]];
} else if(is_callable($fields[$f]['exec_function'])) {
$v = call_user_func_array($fields[$f]['exec_function'], array($report, $f, $i["C$o"]));
$v = call_user_func_array($fields[$f]['exec_function'], array($report, $i["C$o"]));
// } else if(isset($fields[$f]['exec_code'])) {
// Somethign like this, how do we pass $i["C$o"] in?
// $v = exec($fields[$f]['exec_code']);
@ -800,43 +775,27 @@ foreach($report_stock as $n=>$v) {
if($gen_mode == 'table') {
$data[] = $v;
} else if($gen_mode == 'label') {
/* Setup additional options */
$show_box = ($report['option']['field_box'] == 'yes') ? true : false;
$opt = array();
if($d['face'] == 'bold') $opt[] = 'bold';
$opt[] = $d['align'];
$opt[] = $d['valign'];
if($report['option']['field_box'] == 'yes')
$opt[] = 'field_box';
// echo "<pre>"; print_r($d);
switch($f) {
case 'static_box':
$rep->label_rect($d['x'], $d['y'], $d['w'], $d['h']);
break;
case 'conference_logo':
$rep->label_fair_logo($d['x'], $d['y'], $d['w'], $d['h'], $show_box);
break;
case "projectbarcode":
$style = array(
'border' => 2,
'vpadding' => 'auto',
'hpadding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => false, //array(255,255,255)
'module_width' => 3, // width of a single module in points
'module_height' => 3 // height of a single module in points
);
$rep->label_barcode($v, 'QRCODE,H', $d['x'], $d['y'], $d['w'], $d['h'], $style, 'N');
break;
default:
if($f == 'static_text')
$v = $d['value'];
/* Special column, draw a box */
if($f == 'static_box') {
$rep->addLabelBox($d['x'], $d['y'], $d['w'],
$d['h']);
} else {
/* Special column, override result with static text */
if($f == 'static_text') $v = $d['value'];
$rep->label_text($d['x'], $d['y'], $d['w'], $d['h'],
$v, $show_box, $d['align'], $d['valign'],
$d['fontname'],$d['fontstyle'],$d['fontsize'],
$d['on_overflow']);
break;
$lh = ($d['lines'] == 0) ? 0 : $d['h']/$d['lines'];
$rep->addLabelText2($d['x'], $d['y'], $d['w'],
$d['h'], $lh,
$v, $opt);
}
}
if($fields[$f]['total'] == true)
@ -847,8 +806,6 @@ foreach($report_stock as $n=>$v) {
if(count($table['data'])) {
$rep->addTable($table);
}
$rep->output();
}

View File

@ -23,346 +23,395 @@
*/
?>
<?
require_once('../common.inc.php');
require_once('../user.inc.php');
require_once('reports.inc.php');
require_once("../common.inc.php");
require_once("../user.inc.php");
require_once("reports.inc.php");
user_auth_required('committee');
$option_keys = array('type','stock');
/* Load the user's volunteer position selections */
$edit_mode = array_key_exists('edit', $_GET);
switch($_GET['action']) {
case 'remove_report':
$action = $_GET['action'];
if($action=='') $action = $_POST['action'];
if($action == 'unlink') {
$id = intval($_GET['id']);
mysql_query("DELETE FROM reports_committee WHERE
users_id='{$_SESSION['accounts_id']}' AND id='$id'");
happy_('Report successfully removed');
users_id='{$_SESSION['users_uid']}' AND id='$id'");
$_SESSION['messages'][] = 'unlinked';
header("Location: reports.php?edit=1");
exit;
case 'reload':
}
$reports_id = 0;
if($action == 'reload') {
$edit_mode = true;
$reports_id = intval($_POST['reports_id']);
exit;
}
case 'load_report':
$id = intval($_GET['id']);
/* Load report */
if($id == -1) {
$reports_id = intval($_GET['reports_id']);
$report = report_load($reports_id);
$ret['id'] = -1;
$ret['reports_id'] = $reports_id;
$ret['type'] = $report['option']['type'];
$ret['stock'] = $report['option']['stock'];
$ret['comment'] = $report['desc'];
$ret['name'] = $report['name'];
$ret['category'] = '';
} else {
$q = mysql_query("SELECT * FROM reports_committee WHERE id='$id'");
$ret = mysql_fetch_assoc($q);
$ret['type'] = $ret['format'];
}
/* Load available categories */
$q = mysql_query("SELECT DISTINCT category FROM reports_committee
WHERE users_id='{$_SESSION['accounts_id']}'
ORDER BY category");
while($i = mysql_fetch_object($q))
$ret['cat'][] = $i->category;
echo json_encode($ret);
exit;
case 'save':
echo "POST: ";
print_r($_POST);
$id = intval($_POST['id']);
if($action == 'add') {
$reports_id = intval($_POST['reports_id']);
if($id == -1) {
/* New entry */
mysql_query("INSERT INTO `reports_committee` (`users_id`,`reports_id`)
VALUES('{$_SESSION['accounts_id']}','$reports_id');");
echo mysql_error();
$id = mysql_insert_id();
}
/* Update entry */
/* reports_id might be < 0, that's ok */
$category = $_POST['category'];
$category_exist = $_POST['category_exist'];
$comment = mysql_real_escape_string(stripslashes($_POST['comment']));
$comment = mysql_escape_string(stripslashes($_POST['comment']));
if($category_exist != '') $category = $category_exist;
$category = mysql_real_escape_string(stripslashes(trim($category)));
if($category == '') $category = 'default';
$category = mysql_escape_string(stripslashes(trim($category)));
if($category == '') {
$_SESSION['messages'][] = 'nocategory';
header("Location: reports.php?edit=1");
exit;
}
if($reports_id > 0) {
/* SFIAB report */
$type = $_POST['type'];
$stock = $_POST['stock'];
if(!array_key_exists($type, $report_options['type']['values'])) {
error_("Invalid format: type=$type");
echo "Invalid format: type=$type";
exit;
}
if(!array_key_exists($stock, $report_stock)) {
error_("Invalid stock: stock=$stock");
echo "Invalid stock: stock=$stock";
exit;
}
} else {
/* Old custom */
$type = '';
$stock = '';
}
mysql_query("UPDATE `reports_committee` SET
`category`='$category',
`comment`='$comment',
`format`='$type',
`stock`='$stock'
WHERE id='$id'");
happy_("Saved");
mysql_query("INSERT INTO `reports_committee`
(`id`, `users_id` , `reports_id` , `category` , `comment` , `format` , `stock`)
VALUES (
NULL , '{$_SESSION['users_uid']}',
'$reports_id', '$category', '$comment',
'$type', '$stock' );");
$_SESSION['messages'][] = 'added';
header("Location: reports.php?edit=1");
exit;
}
//send the header
send_header("My Reports",
array("Committee Main" => "committee_main.php"),
"print/export_reports"
);
if($edit_mode == false) {
send_header("My Reports",
array("Committee Main" => "committee_main.php"),
"print/export_reports"
);
/* Send a greeting */
echo i18n('Welcome to the new report interface. You can select and save specific reports under specific categories so you can always find the report you need without having to go through the list each time. To begin customizing this list, click on the "Edit This List" button at the bottom of this page.');
?>
<br /><br />
/* Send a greeting */
echo i18n('Welcome to the new report interface. You can select and save specific reports under specific categories so you can always find the report you need without having to go through the list each time. To begin customizing this list, click on the "Click Here to edit your Report List" link at the bottom of this page. ');
echo i18n('The old report list is still available').' <a href="reports_old.php">'.i18n('here').'</a>, but will be deleted in the summer of 2008';
echo '<br /><br />';
<script type="text/javascript">
function remove_report(id)
{
$('#debug').load("<?$_SERVER['PHP_SELF']?>?action=remove_report&id="+id);
$("#report_tr_"+id).remove();
}
} else {
send_header("Edit My Reports",
array("Committee Main" => "committee_main.php",
"My Reports" => "admin/reports.php"),
"print/export_reports"
);
}
function edit_report(id,reports_id)
{
var r = (id == -1) ? '&reports_id='+reports_id : '';
$.getJSON("<?=$_SERVER['PHP_SELF']?>?action=load_report&id="+id+r,
function(json){
$("#report_category_exist").html("<option value=\"\">-- <?=i18n('Use New Category')?> --</option>");
for(var i in json.cat ) {
var c = json.cat[i];
$("#report_category_exist").append("<option value=\""+c+"\">"+c+"</option>");
}
$("#report_id").val( (id == -1) ? -1 : json.id);
$("#report_reports_id").val(json.reports_id);
$("#report_category").val(json.category);
$("#report_stock").val(json.stock);
$("#report_format").val(json.format);
$("#report_comment").val(json.comment);
/* Update the dialog title */
$('#popup_editor').dialog('option', 'title', "<?=i18n('Report')?>: " + json.name);
require_once("../ajax.inc.php");
popup_editor(id);
});
}
function save_report()
{
$('#debug').load("<?$_SERVER['PHP_SELF']?>?action=save", $('#report_form').serializeArray(), function() {
window.location.reload();
});
}
function add_report()
{
edit_report(-1, $('#report').val());
}
function gen_report() {
report_gen($('#report').val());
return false;
}
var edit=false;
function edit_toggle()
{
if(edit == false) {
$('#edit_toggle').val("<?=i18n("Done Editing")?>");
$('#edit_info').show();
$('.edit_buttons').show();
edit = true;
} else {
$('#edit_toggle').val("<?=i18n("Edit This List")?>");
$('#edit_info').hide();
$('.edit_buttons').hide();
edit = false;
foreach($_SESSION['messages'] as $m) {
switch($m) {
case 'nocategory':
echo error(i18n("You must select a category or type a new category name to add a report to your list"));
break;
case 'added':
echo happy(i18n("Report successfully added"));
break;
case 'unlinked':
echo happy(i18n("Report successfully removed"));
break;
}
}
function popup_editor(id)
{
var w = (document.documentElement.clientWidth * 0.6);
var h = (document.documentElement.clientHeight * 0.4);
report_id = id;
/* Show the dialog */
$('#popup_editor').dialog('option', 'width', w);
$('#popup_editor').dialog('option', 'height', h);
$("#popup_editor").dialog('open');
return true;
}
/* Setup the popup window */
$(document).ready(function() {
$("#popup_editor").dialog({
bgiframe: true, autoOpen: false,
modal: true, resizable: false,
draggable: false,
buttons: {
"<?=i18n('Cancel')?>": function() {
$(this).dialog("close");
},
"<?=i18n('Save')?>": function() {
save_report();
$(this).dialog("close");
}
}
});
});
</script>
<?
}
$_SESSION['messages'] = array();
/* Load all the users reports */
$q = mysql_query("SELECT reports_committee.*,reports.name
FROM reports_committee
LEFT JOIN reports ON reports.id=reports_committee.reports_id
WHERE users_id='{$_SESSION['accounts_id']}'
WHERE users_id='{$_SESSION['users_uid']}'
ORDER BY category,id");
echo mysql_error();
if(mysql_num_rows($q) == 0) {
echo i18n('You have no reports saved');
} else {
/* List each report with info */
if($edit_mode == true) {
echo i18n('Deleting all the reports from a category will also delete the category.');
echo '<br />';
echo '<br />';
echo '<a href="reports.php">'.i18n('Click here when you are finished editing your report list').'</a>';
echo '<br />';
echo '<br />';
}
$last_category = '';
$x=0;
echo "<table class=\"tableview\" style=\"border:0px;\">";
echo "<table class=\"tableedit\">";
while($i = mysql_fetch_object($q)) {
$trclass = ($x % 2 == 0) ? "even" : "odd";
$x++;
if($last_category != $i->category) {
/* New category */
echo '<tr><td style="border:0px;" colspan="3" style="even"><h3>';
echo '<tr><td colspan=\"2\"><h3>';
if($edit_mode == true) echo i18n('Category').': ';
echo "{$i->category}</h3></td></tr>";
$last_category = $i->category;
}
if($i->reports_id > 0) {
// $url = "admin/reports_gen.php?id={$i->reports_id}&show_options=1";
$name = "<a href=\"#\" onclick=\"return report_gen({$i->reports_id})\">{$i->name}</a>";
$name = $i->name;
$url = "admin/reports_gen.php?id={$i->reports_id}&show_options=1";
} else {
$name = "<a href=\"{$config['SFIABDIRECTORY']}/{$report_custom[-$i->reports_id]['custom_url']}\">
{$report_custom[-$i->reports_id]['name']}</a>";
$name = $report_custom[-$i->reports_id]['name'];
$url = $report_custom[-$i->reports_id]['custom_url'];
}
?>
<tr id="report_tr_<?=$i->id?>">
<td style="border:0px;"><?=$name?></td>
<td style="border:0px;"><?=$i->comment?></td>
<td style="border:0px;">
<div class="edit_buttons" style="display:none">
<a title="Edit Report" onclick="edit_report(<?=$i->id?>,0);return false;" href="#">
<img border="0" src="<?=$config['SFIABDIRECTORY']?>/images/16/edit.<?=$config['icon_extension']?>" />
</a>
<a title="Remove Report" onclick="remove_report(<?=$i->id?>);return false;" href="#">
<img src="<?=$config['SFIABDIRECTORY']?>/images/16/button_cancel.<?=$config['icon_extension']?>" border="0" alt="Remove Report" />
</a>&nbsp;
</div>
</td>
</tr>
<?
if($edit_mode == false)
$name = "<a href=\"{$config['SFIABDIRECTORY']}/$url\">$name</a>";
echo "<tr class=\"$trclass\"><td>";
if($edit_mode == true)
echo "<a title=\"Remove Report\" href=\"reports.php?action=unlink&id={$i->id}\"><img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=\"0\" alt=\"Remove Report\" /></a>&nbsp;";
echo $name.'</td>';
/*
if($i->reports_id > 0) {
echo '<tr><td width=\"20px\"></td><td>';
echo '<span style=\"font-size: 0.75em;\">';
echo i18n('Format').": {$i->format}, ";
echo i18n('Paper').": {$report_stock[$i->stock]['name']}, ";
echo i18n('Year').": {$config['FAIRYEAR']}";
echo '</span>';
echo '</td></tr>';
}
*/
echo "<td><span style=\"font-size: 0.85em;\">{$i->comment}</span></td></tr>";
}
echo "</table>";
}
?>
<div id="edit_info" style="display:none;">
<p>* <?=i18n('Deleting all the reports from a category will also delete the category.')?></p>
<p>* <?=i18n('Deleting a report only unlinks it from your list, it doesn\'t delete it from the system.')?></p>
</div>
<br />
<input id="edit_toggle" type="submit" onclick="edit_toggle();return false;" value="<?=i18n("Edit This List")?>">
<br />
<br />
<?
/* Load available reports */
$reports = report_load_all();
foreach($report_custom as $id=>$r) {
$r['id'] = -$id;
$reports[-$id] = $r;
if($edit_mode == false) {
echo '<hr />';
echo '<a href="reports.php?edit=1">'.i18n('Click here to edit your Report List').'</a>';
echo '<hr />';
echo "<h3>".i18n("All Reports")."</h3>";
/* Print all the reports in a pulldown menu for generation */
echo "<form method=\"get\" name=\"reportgen\" action=\"reports_gen.php\">";
echo "<input type=\"hidden\" name=\"show_options\" value=\"1\" />";
echo "<select name=\"id\" id=\"report\">";
echo "<option value=\"0\">".i18n("Select a Report")."</option>\n";
$x=0;
foreach($reports as $r) {
echo "<option value=\"{$r['id']}\">{$r['name']}</option>\n";
}
echo "</select>";
echo "<input type=\"submit\" value=\"".i18n("Generate Report")."\"></form>";
echo "<br />";
send_footer();
exit;
}
?>
<hr />
<h4><?=i18n("All Reports")?></h3>
echo '<hr />';
<form name="reportgen" >
<select name="id" id="report">
<option value="0"><?=i18n("Select a Report")?></option>
<?
foreach($reports as $r) {
echo "<option value=\"{$r['id']}\">{$r['name']}</option>\n";
}
?>
</select><br />
<input type="submit" onclick="gen_report();return false;" value="<?=i18n("Generate Report")?>">
<input type="submit" onclick="add_report();return false;" value="<?=i18n("Add this Report to my list")?>">
</form>
<br />
?>
<script type="text/javascript">
function add_reload()
{
var url="report.ajax.php?reports_id="+document.addreport.reports_id.options[document.addreport.reports_id.selectedIndex].value;
// alert(url);
http.open("GET",url,true);
http.onreadystatechange=handleResponse;
http.send(null);
return true;
}
function handleResponse()
{
try {
if(http.readyState==4)
{
//eval the JSON to get the object if the length is big enough (custom reports return json [])
if(http.responseText.length>3) {
document.addreport.type.disabled=false;
document.addreport.stock.disabled=false;
document.addreport.type.style.display='';
document.addreport.stock.style.display='';
document.getElementById('reporttypecustom').style.display='none';
document.getElementById('reportstockcustom').style.display='none';
/* dont use JSON anymore since it adds an extra PHP-side requirement, we'll just get a 3 line response with one thing per line that we need
var obj=eval('('+http.responseText+')');
if(obj['option']['type']) {
for(i=0;i<document.addreport.type.options.length;i++) {
if(document.addreport.type.options[i].value==obj['option']['type'])
document.addreport.type.selectedIndex=i;
}
}
else
document.addreport.type.selectedIndex=0;
if(obj['option']['stock']) {
for(i=0;i<document.addreport.stock.options.length;i++) {
if(document.addreport.stock.options[i].value==obj['option']['stock'])
document.addreport.stock.selectedIndex=i;
}
}
else
document.addreport.stock.selectedIndex=0;
if(obj['desc'])
document.addreport.comment.value=obj['desc'];
*/
var lines=http.responseText.split('\n');
var reportType=lines[0];
var reportStock=lines[1];
var reportDesc=lines[2];
if(reportType) {
for(i=0;i<document.addreport.type.options.length;i++) {
if(document.addreport.type.options[i].value==reportType)
document.addreport.type.selectedIndex=i;
}
}
else
document.addreport.type.selectedIndex=0;
if(reportStock) {
for(i=0;i<document.addreport.stock.options.length;i++) {
if(document.addreport.stock.options[i].value==reportStock)
document.addreport.stock.selectedIndex=i;
}
}
else
document.addreport.stock.selectedIndex=0;
if(reportDesc);
document.addreport.comment.value=reportDesc;
}
else
{
document.addreport.type.disabled=true;
document.addreport.stock.disabled=true;
document.addreport.type.style.display='none';
document.addreport.stock.style.display='none';
document.getElementById('reporttypecustom').style.display='';
document.getElementById('reportstockcustom').style.display='';
document.addreport.comment.value='';
}
}
}
catch(e) {
alert('caught error: '+e);
}
}
</script>
<?
<?
/* Create an add report box */
?>
<div id="popup_editor" title="Report" style="display: none">
echo '<h3>'.i18n('Add a Report to your Report List').'</h3>';
echo "<form method=\"post\" name=\"addreport\"action=\"reports.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"add\">";
echo "<table class=\"tableedit\">\n";
echo '<tr><td colspan="2">';
echo "<select name=\"reports_id\" onChange=\"add_reload()\">";
echo "<option value=\"\">".i18n("Choose a report")."</option>\n";
$x=0;
foreach($reports as $r) {
$x++;
$sel = ($reports_id == $r['id']) ? 'selected="selected"' : '';
echo "<option value=\"{$r['id']}\" $sel>$x. {$r['name']}</option>";
<form id="report_form">
<input type="hidden" id="report_id" name="id" value="" />
<input type="hidden" id="report_reports_id" name="reports_id" value="" />
<br />
<table class="tableedit">
<tr>
<td><?=i18n("Category")?>:</td>
<td><?=i18n("Existing Category")?>: <select name="category_exist" id="report_category_exist" onchange="$('#report_category').val('')" >
</select><br />
<?=i18n("OR New Category")?>: <input type="text" id="report_category" name="category" onkeypress="$('#report_category_exist').val('')" >
</td>
</tr>
<?
}
$rid = -1;
foreach($report_custom as $r) {
$x++;
$sel = ($reports_id == $rid) ? 'selected="selected"' : '';
echo "<option value=\"$rid\" $sel>$x. {$r['name']}</option>";
$rid--;
}
echo "</select></td></tr>";
echo "<tr><td>".i18n("Category").":</td><td>";
$q = mysql_query("SELECT DISTINCT category FROM reports_committee
WHERE users_id='{$_SESSION['users_uid']}'
ORDER BY category");
echo i18n("Existing Category").": <select name=\"category_exist\">";
echo "<option value=\"\">-- ".i18n('Use New Category')." --</option>";
while($i = mysql_fetch_object($q)) {
echo "<option value=\"{$i->category}\">{$i->category}</option>";
}
echo "</select><br />";
echo i18n("OR New Category").": <input type=\"text\" name=\"category\">";
echo "</td></tr>";
$option_keys = array('type','stock');
foreach($report_options as $ok=>$o) {
if(!in_array($ok, $option_keys)) continue;
echo "<tr><td>{$o['desc']}:</td>";
echo "<td><select name=\"$ok\" id=\"report_$ok\">";
echo "<td><select name=\"$ok\" id=\"$ok\">";
foreach($o['values'] as $k=>$v) {
echo "<option value=\"$k\">$v</option>\n";
}
echo "</select><span id=\"report{$ok}custom\" style=\"display: none;\">".i18n("Custom")."</span></td></tr>";
}
?>
<tr>
<td><?=i18n("Comments")?>:</td>
<td><textarea rows="3" cols="40" name="comment" id="report_comment"></textarea></td>
</tr>
</table>
</form>
</div>
echo "<tr><td>".i18n("Comments").":</td><td>";
echo "<textarea rows=\"3\" cols=\"60\" name=\"comment\"></textarea></td></tr>";
echo "<tr><td colspan=\"2\"><input type=\"submit\" value=\"".i18n("Add Report to My Reports")."\" /></td></tr>";
<?
echo '</table></form>';
echo '<hr />';
echo '<h3>Descriptions for All Reports</h3>';
echo i18n('Click on the report number to try the report with the default report options before you add it to your Report List');
echo '<br /><br />';
echo "<table class=\"tableedit\">\n";
$x=0;
foreach(array_merge($reports, $report_custom) as $r) {
$trclass = ($x % 2 == 0) ? "even" : "odd";
$x++;
echo "<tr class=\"$trclass\">";
if($r['custom_url'] == '') {
$url = "admin/reports_gen.php?id={$r['id']}";
} else {
$url = $r['custom_url'];
}
echo "<td><a href=\"{$config['SFIABDIRECTORY']}/$url\">$x.</a></td>";
echo "<td><table cellspacing=0 cellpadding=0 width=\"100%\"><tr>";
echo "<td><b>{$r['name']}</b></td>";
echo "<td align=\"right\">Created By: {$r['creator']}</td></tr>";
echo "<tr><td colspan=\"2\">{$r['desc']}</td></tr>";
echo "</table></tr>";
}
echo "</table>";
echo "<br />";
send_footer();
?>

View File

@ -1,21 +1,12 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
require("../lpdf.php");
require("../lcsv.php");
if($_GET['foryear']){
// backwards compatability
$r = mysql_fetch_assoc(mysql_query("SELECT id FROM conferences WHERE year = " . $_GET['foryear']));
if(is_array($r)){
$forconference = $r['id'];
}else{
$forconference = $conference['id'];
}
}
if($_GET['conference']) $forconference=$_GET['conference'];
else $forconference=$conference['id'];
if($_GET['year']) $foryear=$_GET['year'];
else $foryear=$config['FAIRYEAR'];
if($_GET['awardtype']=="All") $awardtype="";
else if($_GET['awardtype']) $awardtype=" AND award_types.type='".mysql_escape_string($_GET['awardtype'])."'";
@ -28,37 +19,33 @@
else $show_unawarded_prizes="no";
$show_pronunciation= ($_GET['show_pronunciation'] == 'on') ? TRUE : FALSE;
$group_by_prize= ($_GET['group_by_prize'] == 'on') ? true : false;
if(is_array($_GET['show_category'])) {
$show_category = array();
foreach($_GET['show_category'] as $id=>$val) {
$show_category[] = "award_awards_projectcategories.projectcategories_id='$id'";
$show_category[] = "projects.projectcategories_id='$id'";
}
$and_categories = join(' OR ', $show_category);
} else {
$and_categories = '1';
}
$show_criteria = ($_GET['show_criteria']=='on') ? true : false;
$type=$_GET['type'];
if(!$type) $type="pdf";
$scriptformat=$_GET['scriptformat'];
if(!$scriptformat) $scriptformat="default";
if($type=="pdf")
{
if($type=="pdf") {
$rep=new lpdf( i18n($config['fairname']),
i18n("Awards Ceremony Script"),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif"
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
);
$rep->newPage();
if($scriptformat=="default") $rep->setFontSize(12);
if($scriptformat=="formatted") $rep->setFontSize(14);
$rep->setFontSize(11);
}
else if($type=="csv") {
else if($type=="csv")
{
$rep=new lcsv(i18n("Awards Ceremony Script"));
}
$q=mysql_query("SELECT
@ -66,38 +53,29 @@ if(!$scriptformat) $scriptformat="default";
award_awards.name,
award_awards.presenter,
award_awards.description,
award_awards.criteria,
award_awards.order AS awards_order,
award_types.type,
sponsors.organization
FROM
award_awards,
award_types,
sponsors,
award_awards_projectcategories
sponsors
WHERE
award_awards.conferences_id='$forconference'
AND award_types.conferences_id='$forconference'
award_awards.year='$foryear'
AND award_types.year='$foryear'
AND award_awards.award_types_id=award_types.id
AND award_awards.sponsors_id=sponsors.id
AND award_awards.id=award_awards_projectcategories.award_awards_id
AND award_awards.excludefromac='0'
AND ($and_categories)
$awardtype
GROUP BY award_awards.id
ORDER BY awards_order");
echo mysql_error();
// echo "<pre>";
if(!mysql_num_rows($q)) {
$rep->output();
exit;
}
$awards = array();
while($r=mysql_fetch_object($q)) {
$pq=mysql_query("SELECT
if(mysql_num_rows($q))
{
while($r=mysql_fetch_object($q))
{
$pq=mysql_query("SELECT
award_prizes.prize,
award_prizes.number,
award_prizes.id,
@ -113,104 +91,50 @@ if(!$scriptformat) $scriptformat="default";
LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id
LEFT JOIN projects ON projects.id=winners.projects_id
WHERE
award_awards_id='{$r->id}'
AND award_prizes.conferences_id='$forconference'
award_awards_id='$r->id'
AND award_prizes.year='$foryear'
AND award_prizes.excludefromac='0'
AND ($and_categories)
ORDER BY
`order`,
projects.projectnumber");
`order`");
echo mysql_error();
$r->winners = array();
$r->awarded_count = 0;
while($w = mysql_fetch_object($pq)) {
if($w->projects_id)
if($show_unawarded_awards=="no")
{
$r->awarded_count++;
}
if($r->type == 'Divisional' && $group_by_prize==true) {
/* Search awards for an award name that matches this prize */
$found = false;
foreach($awards as &$p_award) {
if($p_award->name == $w->prize) {
/* Match! Set the prize name to the award name,
* and add the prize to the award */
$w->prize = $r->name;
$p_award->winners[] = $w;
$found = true;
// echo "Add to award {$p_award->name}: "; print_r($w);
$skipAward=true;
while($pr=mysql_fetch_object($pq))
{
if($pr->projectnumber)
{
$skipAward=false;
break;
}
}
if($found == false) {
/* Make a new award and set it equal to the prize name */
$n = $r->name;
$new_award = clone($r);
$new_award->name = $w->prize;
/* Now add the prize with the award's name */
$w->prize = $n;
$new_award->winners[] = $w;
$awards[] = $new_award;
// echo "Create Award:"; print_r($new_award);
if($skipAward)
{
continue;
}
} else {
// echo "Add non-div winner\n";
$r->winners[] = $w;
mysql_data_seek($pq, 0);
}
}
if($show_unawarded_awards=="no" && $r->awarded_count == 0) {
/* No winners */
continue;
}
if($r->type == 'Divisional' && $group_by_prize == true) {
/* Do nothing */
} else {
$awards[] = $r;
}
}
// echo '<pre>'; print_r($awards);
foreach($awards as $r) {
if($scriptformat=="formatted")
$rep->newPage();
if($scriptformat=="default")
$rep->heading("$r->name ($r->type)");
if($scriptformat=="formatted") {
$rep->setFontBold();
$rep->addText("$r->name ($r->type)");
$rep->setFontNormal();
}
if($r->type!="Divisional")
$rep->addText(i18n("Sponsored by: %1",array($r->organization)));
if($r->presenter)
$rep->addText(i18n("Presented by: %1",array($r->presenter)));
if($r->description)
$rep->addText(i18n("Description: %1",array($r->description)));
if($show_criteria)
$rep->addText(i18n("Criteria: %1",array($r->criteria)));
if($r->type!="Divisional")
$rep->addText(i18n("Sponsored by: %1",array($r->organization)));
if($r->presenter)
$rep->addText(i18n("Presented by: %1",array($r->presenter)));
if($r->description)
$rep->addText(i18n("Description: %1",array($r->description)));
if($scriptformat=="formatted") $rep->nextline();
if($r->awarded_count == 0)
{
$rep->addText("Not awarded");
}
$prevprizeid=-1;
foreach($r->winners as $pr) {
if($pr->projectnumber || $show_unawarded_prizes=="yes") {
if($prevprizeid!=$pr->id) {
$prevprizeid=-1;
while($pr=mysql_fetch_object($pq))
{
if($pr->projectnumber || $show_unawarded_prizes=="yes")
{
if($prevprizeid!=$pr->id)
{
$prizetext=$pr->prize;
if($pr->cash || $pr->scholarship) {
if($pr->cash || $pr->scholarship)
{
$prizetext.=" (";
if($pr->cash && $pr->scholarship)
$prizetext.="\$$pr->cash cash / \$$pr->scholarship scholarship";
@ -221,77 +145,53 @@ if(!$scriptformat) $scriptformat="default";
$prizetext.= ")";
}
if($scriptformat=="default")
$rep->addText($prizetext);
if($scriptformat=="formatted") {
$rep->setFontBold();
$rep->addText($prizetext);
$rep->setFontNormal();
$rep->nextline();
}
$rep->addText($prizetext);
$prevprizeid=$pr->id;
}
if($pr->projectnumber) {
if($scriptformat=="default")
$rep->addText( " ($pr->projectnumber) $pr->title");
if($pr->projectnumber)
{
$rep->addText( " ($pr->projectnumber) $pr->title");
$sq=mysql_query("SELECT users.firstname,
users.lastname,
users.pronunciation,
users.schools_id,
$sq=mysql_query("SELECT students.firstname,
students.lastname,
students.pronunciation,
students.schools_id,
schools.school
FROM
users,
students,
schools
WHERE
users.registrations_id='$pr->reg_id'
AND users.schools_id=schools.id
students.registrations_id='$pr->reg_id'
AND students.schools_id=schools.id
");
$students=" Students: ";
$studnum=0;
$pronounce = "";
$rawpronounce = "";
while($studentinfo=mysql_fetch_object($sq)) {
while($studentinfo=mysql_fetch_object($sq))
{
if($studnum>0) $students.=", ";
$students.="$studentinfo->firstname $studentinfo->lastname";
if($studentinfo->pronunciation) {
$students .= " (Pronounced \"{$studentinfo->pronunciation}\")";
}
if($studnum>0) $pronounce .= ", ";
$pronounce .= "\"{$studentinfo->pronunciation}\"";
$student_winner[$studnum] = "$studentinfo->firstname $studentinfo->lastname";
$student_win_pronunc[$studnum] = "$studentinfo->pronunciation";
$student_school[$studnum] = $studentinfo->school;
$studnum++;
//we will assume that they are coming from the same school, so lets just grab the last students school
//and use it.
$school=$studentinfo->school;
}
if($scriptformat=="default") {
$rep->addText($students);
$rep->addText(" School: {$student_school[0]}");
}
if($scriptformat=="formatted") {
$rep->addTextX("$pr->projectnumber",0.5);
for($x=0; $x<$studnum; $x++) {
$rep->addTextX($student_winner[$x],1.4);
$rep->addTextX($student_school[$x],5.5);
if($show_pronunciation == TRUE && $student_win_pronunc[$x]) {
$rep->nextline();
$rep->addTextX("({$student_win_pronunc[$x]})",2.0);
}
if($type=="pdf")
$rep->nextline();
}
if(($studnum==1) && ($type == "csv")) $rep->addTextX("");
if(($studnum==1) && ($type == "csv")) $rep->addTextX("");
$rep->addText($pr->title,'left', 1.4);
if($type=="pdf") $rep->nextline();
$rep->nextline();
}
$rep->addText($students);
if(trim($pronounce) != '' && $show_pronunciation == TRUE)
$rep->addText("Pronunciation: $pronounce");
$rep->addText(" School: $school");
}
else {
else
{
$rep->addText(" Prize not awarded");
}
}
@ -299,5 +199,6 @@ if(!$scriptformat) $scriptformat="default";
$rep->nextLine();
}
}
$rep->output();
?>

View File

@ -1,104 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('admin');
require_once('../tcpdf/tcpdf_sfiab_config.php');
require_once('../tcpdf/tcpdf.php');
$fcid = intval($_GET['fundraising_campaigns_id']);
$key = mysql_real_escape_string($_GET['key']);
/* Start an output PDF */
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator('SFIAB');
$pdf->SetAuthor('SFIAB');
$pdf->SetTitle($config['fairname']);
$pdf->SetSubject('Fundraising Appeal Letters');
$pdf->SetKeywords('');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setPrintFooter(false);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
//$pdf->setLanguageArray($l);
/* Load the users */
$users = array();
$q = mysql_query("SELECT * FROM fundraising_campaigns_users_link WHERE fundraising_campaigns_id='$fcid'");
while($l = mysql_fetch_assoc($q)) {
$uid = $l['users_uid'];
$users[$uid] = user_load_by_uid($uid);
}
/* Grab all the emails */
$q = mysql_query("SELECT * FROM emails WHERE fundraising_campaigns_id='$fcid' AND val='$key'");
while($e = mysql_fetch_assoc($q)) {
foreach($users as $uid=>&$u) {
$subject = communication_replace_vars($e['subject'], $u);
$body = communication_replace_vars($e['bodyhtml'], $u);
/* these dont' need substitutions */
$to = $u['name'];
$date = date("F j, Y");
$html = "<table><tr><td align=\"right\" width=\"25\%\"><b>Attn: </b></td><td>$to</td></tr>
<tr><td align=\"right\" width=\"25\%\"><b>Subject: </b></td><td>$subject</td></tr>
<tr><td align=\"right\" width=\"25\%\"><b>Date: </b></td><td>$date</td></tr>
</table>
<hr />";
$pdf->AddPage();
$pdf->writeHTML($html);
$pdf->writeHTML($body);
$pdf->lastPage();
}
}
$pdf->Output('report.pdf','I');
?>

View File

@ -20,341 +20,204 @@
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
$report_awards_fields = array(
'name' => array(
'start_option_group' => 'Award Information',
'name' => 'Award -- Name',
'header' => 'Award Name',
'width' => 76.2 /*mm*/,
'width' => 3.0,
'table' => 'award_awards.name' ),
'criteria' => array(
'name' => 'Award -- Criteria',
'header' => 'Award Criteria',
'width' => 76.2 /*mm*/,
'width' => 3.0,
'table' => 'award_awards.criteria' ),
'presenter' => array(
'name' => 'Award -- Presenter',
'header' => 'Award Presenter',
'width' => 38.1 /*mm*/,
'width' => 1.5,
'table' => 'award_awards.presenter' ),
'order' => array(
'name' => 'Award -- Order',
'header' => 'Award Order',
'width' => 12.7 /*mm*/,
'width' => 0.5,
'table' => 'award_awards.order' ),
'cwsfaward' => array(
'name' => 'Award -- CWSF Award',
'header' => 'CWSF',
'width' => 12.7 /*mm*/,
'width' => 0.5,
'table' => 'award_awards.cwsfaward',
'value_map' => array ('0' => 'No', '1' => 'Yes')),
'type' => array(
'name' => 'Award -- Type',
'header' => 'Award Type',
'width' => 25.4 /*mm*/,
'width' => 1.0,
'table' => 'award_types.type' ),
'empty_winner_box' => array(
'name' => 'Award -- Empty Winner Box (for hand entry on printed reports)',
'header' => 'Winner',
'width' => 25.4 /*mm*/,
'table' => "CONCAT('')" ),
'sponsor_organization' => array(
'start_option_group' => 'Sponsor Information',
'name' => 'Sponsor -- Organization',
'header' => 'Sponsor Organization',
'width' => 50.8 /*mm*/,
'width' => 2.0,
'table' => 'sponsors.organization' ),
'sponsor_phone' => array(
'name' => 'Sponsor -- Phone',
'header' => 'Sp. Phone',
'width' => 25.4 /*mm*/,
'width' => 1,
'table' => 'sponsors.phone' ),
'sponsor_fax' => array(
'name' => 'Sponsor -- Fax',
'header' => 'Sp. Fax',
'width' => 25.4 /*mm*/,
'width' => 1,
'table' => 'sponsors.fax' ),
'sponsor_address' => array(
'name' => 'Sponsor -- Street Address',
'header' => 'Sponsor Address',
'width' => 50.8 /*mm*/,
'width' => 2.0,
'table' => 'sponsors.address'),
'sponsor_city' => array(
'name' => 'Sponsor -- City',
'header' => 'Sp. City',
'width' => 38.1 /*mm*/,
'width' => 1.5,
'table' => 'sponsors.city' ),
'sponsor_province' => array(
'name' => 'Sponsor -- '.$config['provincestate'],
'header' => 'Sp. '.$config['provincestate'],
'width' => 19.05 /*mm*/,
'width' => 0.75,
'table' => 'sponsors.province_code' ),
'sponsor_postal' => array(
'name' => 'Sponsor -- '.$config['postalzip'],
'header' => 'Sp. '.$config['postalzip'],
'width' => 19.05 /*mm*/,
'width' => 0.75,
'table' => 'sponsors.postalcode' ),
'sponsor_notes' => array(
'name' => 'Sponsor -- Notes',
'header' => 'Sponsor Notes',
'width' => 76.2 /*mm*/,
'width' => 3,
'table' => 'sponsors.notes' ),
'sponsorship_status' => array(
'name' => 'Sponsorship -- Status',
'header' => 'Sp. Status',
'width' => 12.7 /*mm*/,
'width' => .5,
'table' => 'sponsorships.status',
'value_map' => array ('pending' => 'Pending', 'confirmed' => 'Confirmed'), "received"=>"Received"),
'pcontact_salutation' => array(
'start_option_group' => 'Sponsor Primary Contact',
'name' => 'Primary Contact -- Salutation',
'header' => 'Cnct. Salutation',
'width' => 25.4 /*mm*/,
'width' => 1.0,
'table' => 'PRIMARYCONTACTUSER.salutation' ),
'pcontact_last_name' => array(
'name' => 'Primary Contact -- Last Name',
'header' => 'Cnct. Last Name',
'width' => 25.4 /*mm*/,
'width' => 1.0,
'table' => 'PRIMARYCONTACTUSER.lastname' ),
'pcontact_first_name' => array(
'name' => 'Primary Contact -- First Name',
'header' => 'Cnct. First Name',
'width' => 25.4 /*mm*/,
'width' => 1.0,
'table' => 'PRIMARYCONTACTUSER.firstname' ),
'pcontact_name' => array(
'name' => 'Primary Contact -- Full Name (last, first)',
'header' => 'Contact Name',
'width' => 44.45 /*mm*/,
'width' => 1.75,
'table' => "CONCAT(PRIMARYCONTACTUSER.lastname, ', ', PRIMARYCONTACTUSER.firstname)",
'table_sort'=> 'PRIMARYCONTACTUSER.lastname' ),
'pcontact_namefl' => array(
'name' => 'Primary Contact -- Full Name (salutation first last)',
'header' => 'Contact Name',
'width' => 44.45 /*mm*/,
'width' => 1.75,
'table' => "CONCAT(PRIMARYCONTACTUSER.salutation, ' ', PRIMARYCONTACTUSER.firstname, ' ', PRIMARYCONTACTUSER.lastname)",
'table_sort'=> 'PRIMARYCONTACTUSER.lastname' ),
'pcontact_position' => array(
'name' => 'Primary Contact -- Position',
'header' => 'Cnct. Position',
'width' => 31.75 /*mm*/,
'width' => 1.25,
'table' => 'PRIMARYCONTACT.position'),
'pcontact_email' => array(
'name' => 'Primary Contact -- Email',
'header' => 'Cnct. Email',
'width' => 50.8 /*mm*/,
'width' => 2.0,
'table' => 'PRIMARYCONTACTUSER.email'),
'pcontact_hphone' => array(
'name' => 'Primary Contact -- Home Phone',
'header' => 'Cnct. Home',
'width' => 25.4 /*mm*/,
'width' => 1,
'table' => 'PRIMARYCONTACTUSER.phonehome' ),
'pcontact_wphone' => array(
'name' => 'Primary Contact -- Work Phone',
'header' => 'Cnct. Work',
'width' => 25.4 /*mm*/,
'width' => 1,
'table' => 'PRIMARYCONTACTUSER.phonework' ),
'pcontact_cphone' => array(
'name' => 'Primary Contact -- Cell Phone',
'header' => 'Cnct. Cell',
'width' => 25.4 /*mm*/,
'width' => 1,
'table' => 'PRIMARYCONTACTUSER.phonecell' ),
'pcontact_fax' => array(
'name' => 'Primary Contact -- Fax',
'header' => 'Cnct. Fax',
'width' => 25.4 /*mm*/,
'width' => 1,
'table' => 'PRIMARYCONTACTUSER.fax' ),
'pcontact_notes' => array(
'name' => 'Primary Contact -- Notes',
'header' => 'Contact Notes',
'width' => 76.2 /*mm*/,
'table' => 'PRIMARYCONTACT.notes' ),
'pcontact_address' => array(
'name' => 'Primary Contact Address -- Street',
'header' => 'Address',
'width' => 50.8 /*mm*/,
'table' => "CONCAT(PRIMARYCONTACTUSER.address, ' ', PRIMARYCONTACTUSER.address2)"),
'pcontact_city' => array(
'name' => 'Primary Contact Address -- City',
'header' => 'City',
'width' => 38.1 /*mm*/,
'table' => 'PRIMARYCONTACTUSER.city'),
'pcontact_province' => array(
'name' => 'Primary Contact Address -- '.$config['provincestate'],
'header' => $config['provincestate'],
'width' => 19.05 /*mm*/,
'table' => 'PRIMARYCONTACTUSER.province'),
'pcontact_postal' => array(
'name' => 'Primary Contact Address -- '.$config['postalzip'],
'header' => $config['postalzip'],
'width' => 19.05 /*mm*/,
'table' => 'PRIMARYCONTACTUSER.postalcode' ),
'pcontact_city_prov' => array(
'name' => 'Primary Contact Address -- City, '.$config['provincestate'].' (for mailing)',
'header' => 'City',
'width' => 38.1 /*mm*/,
'table' => "CONCAT(PRIMARYCONTACTUSER.city, ', ', PRIMARYCONTACTUSER.province)"),
'width' => 3,
'table' => 'PRIMARYCONTACTUSER.notes' ),
'judgeteamname' => array(
'start_option_group' => 'Judging Team',
'components' => array('judgingteam'),
'name' => 'Judging Team -- Name',
'header' => 'Judging Team',
'width' => 76.2 /*mm*/,
'width' => 3.0,
'table' => 'judges_teams.name'),
'judgeteamnum' => array(
'components' => array('judgingteam'),
'name' => 'Judging Team -- Number',
'header' => 'Team',
'width' => 12.7 /*mm*/,
'width' => 0.5,
'table' => 'judges_teams.num'),
'judgeteammembers_name' => array(
'components' => array('judgingteam', 'judgingteammembers'),
'name' => 'Judging Team -- Judge Name',
'header' => 'Judge Name',
'width' => 38.1 /*mm*/,
'width' => 1.5,
'table' => "CONCAT(judges.firstname, ' ', judges.lastname)"),
'judgeteammembers' => array(
'components' => array('judgingteam', 'judgingteammembers'),
'name' => 'Judging Team -- Members (REQUIRES MySQL 5.0)',
'header' => 'Team Members',
'width' => 76.2 /*mm*/,
'width' => 3.0,
'table' => "GROUP_CONCAT(judges.firstname, ' ', judges.lastname ORDER BY judges.lastname SEPARATOR ', ')",
'group_by' => array('award_awards.id', 'judges_teams.num') ),
'prize_name' => array(
'start_option_group' => 'Prize Info (Duplicates award data for each prize, omits awards with no prizes)',
'name' => 'Prize -- Name',
'header' => 'Prize Name',
'width' => 50.8 /*mm*/,
'table' => 'award_prizes.prize',
'components' => array('prizes')),
'prize_cash' => array(
'name' => 'Prize -- Cash Amount',
'header' => 'Cash',
'width' => 12.7 /*mm*/,
'table' => 'award_prizes.cash',
'components' => array('prizes')),
'prize_scholarship' => array(
'name' => 'Prize -- Scholarship Amount',
'header' => 'Scholarship',
'width' => 19.05 /*mm*/,
'table' => 'award_prizes.scholarship',
'components' => array('prizes')),
'prize_value' => array(
'name' => 'Prize -- Value Amount',
'header' => 'Value',
'width' => 12.7 /*mm*/,
'table' => 'award_prizes.value',
'components' => array('prizes')),
/* Don't have projectcategories and projectdivisions
'prize_fullname' => array(
'name' => 'Prize -- Name, Category, Division',
'header' => 'Prize Name',
'width' => 101.6 /*mm,
'table' => "CONCAT(award_prizes.prize,' in ',projectcategories.category,' ', projectdivisions.division)",
'table_sort' => 'award_prizes.order',
'components' => array('prizes')),
*/
'prize_trophy_any' => array(
'name' => 'Prize -- Trophy (\'Yes\' if the award has a trophy)',
'header' => 'Trophy',
'width' => 12.7 /*mm*/,
'table' => "IF ( award_prizes.trophystudentkeeper=1
OR award_prizes.trophystudentreturn=1
OR award_prizes.trophyschoolkeeper=1
OR award_prizes.trophyschoolreturn=1, 'Yes', 'No')",
'components' => array('prizes')),
'prize_trophy_return' => array(
'name' => 'Prize -- Annual Trophy (\'Yes\' if the award has a school or student trophy that isn\'t a keeper)',
'header' => 'Trophy',
'width' => 12.7 /*mm*/,
'table' => "IF ( award_prizes.trophystudentreturn=1
OR award_prizes.trophyschoolreturn=1, 'Yes', 'No')",
'components' => array('prizes')),
'prize_trophy_return_student' => array(
'name' => 'Prize -- Annual Student Trophy (\'Yes\' if the award has astudent trophy that isn\'t a keeper)',
'header' => 'Ind.',
'width' => 12.7 /*mm*/,
'table' => "IF ( award_prizes.trophystudentreturn=1, 'Yes', 'No')",
'components' => array('prizes')),
'prize_trophy_return_school' => array(
'name' => 'Prize -- Annual School Trophy (\'Yes\' if the award has a school trophy that isn\'t a keeper)',
'header' => 'Sch.',
'width' => 12.7 /*mm*/,
'table' => "IF ( award_prizes.trophyschoolreturn=1, 'Yes', 'No')",
'components' => array('prizes')),
'prize_all' => array(
'name' => 'Prize -- Lists all prize data (name, cash, scholarship, value, trophies)',
'header' => 'Prize',
'width' => 50.8 /*mm*/,
'table' => "CONCAT(
IF(award_prizes.prize != '', CONCAT(award_prizes.prize,'\n', ''),''),
IF(award_prizes.cash != '', CONCAT('$',award_prizes.cash,'\n'), ''),
IF(award_prizes.scholarship != '', CONCAT('$',award_prizes.scholarship,' scholarship\n'), ''),
IF(award_prizes.value != '', CONCAT('$',award_prizes.value,' value\n'), ''),
IF(award_prizes.trophystudentkeeper != '', CONCAT('Student Keeper Trophy\n'), ''),
IF(award_prizes.trophystudentreturn != '', CONCAT('Student Annual-Return Trophy\n'), ''),
IF(award_prizes.trophyschoolkeeper != '', CONCAT('School Keeper Trophy\n'), ''),
IF(award_prizes.trophyschoolreturn != '', CONCAT('School Annual-Return Trophy\n'), '')
)",
'components' => array('prizes')),
/* The label system depends on each report type having conference_name and conference_logo */
'conference_name' => array(
'start_option_group' => 'Conference Information',
'name' => 'Conference -- Name',
'header' => 'Conference Name',
'width' => 76.2 /*mm*/,
'table' => "'".mysql_escape_string($conference['name'])."'"),
'conference_logo' => array(
'name' => 'Conference -- Logo (for Labels only)',
'header' => '',
'width' => 1 /*mm*/,
'table' => "CONCAT(' ')"),
);
@ -363,15 +226,15 @@ $report_awards_fields = array(
global $config, $report_awards_fields;
$fields = $report_awards_fields;
$conferenceId = $report['conference_id'];
$year = $report['year'];
$judges_join = '';
$judges_where = '';
if(in_array('judgingteam', $components)) {
$judges_join = 'LEFT JOIN judges_teams_awards_link ON judges_teams_awards_link.award_awards_id=award_awards.id
LEFT JOIN judges_teams ON judges_teams.id=judges_teams_awards_link.judges_teams_id';
$judges_where = "AND judges_teams_awards_link.conferences_id='$conferenceId'
AND judges_teams.conferences_id='$conferenceId'";
$judges_where = "AND judges_teams_awards_link.year='$year'
AND judges_teams.year='$year'";
}
$judges_members_join = '';
@ -380,14 +243,7 @@ $report_awards_fields = array(
$judges_members_join = 'LEFT JOIN judges_teams_link ON judges_teams_link.judges_teams_id=judges_teams.id
LEFT JOIN judges ON judges.id=judges_teams_link.judges_id';
$judges_members_where = "AND judges_teams_link.conferences_id='$conferenceId'";
}
$prizes_join = '';
if(in_array('prizes', $components)) {
$prizes_join = 'LEFT JOIN award_prizes ON award_prizes.award_awards_id=award_awards.id';
/* Don't need a where filter, the prize is attached by unique ID to an award
* that is already from the correct conference. */
$judges_members_where = "AND judges_teams_link.year='$year'";
}
@ -402,14 +258,14 @@ $report_awards_fields = array(
PRIMARYCONTACT.users_id=PRIMARYCONTACTUSER.id)
$judges_join
$judges_members_join
$prizes_join
WHERE
award_awards.conferences_id='$conferenceId'
AND award_types.conferences_id='$conferenceId'
award_awards.year='$year'
AND award_types.year='$year'
$judges_where
$judges_members_where
";
return $q;
}
?>

View File

@ -25,9 +25,9 @@
require("../common.inc.php");
require_once("../user.inc.php");
require_once('reports.inc.php');
user_auth_required('admin');
user_auth_required('committee', 'admin');
send_header("Award Ceremony Scripts",
array('Main' => 'user_main.php',
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
"print_awards_ceremony_scripts"
);
@ -38,12 +38,7 @@
echo "<tr><td><b>".i18n("Year").":</b></td><td>";
//get the year information, use fairname since it should be there for all years[right?]
/* Find our conference oid */
$q = mysql_query("SELECT oid FROM conferences WHERE id='{$_SESSION['conferences_id']}'");
$c = mysql_fetch_assoc($q);
$conferences_oid = $c['oid'];
$results = mysql_query("SELECT year FROM conferences WHERE oid='$conferences_oid' AND year > 0 ORDER BY year DESC");
$results = mysql_query("SELECT year FROM config WHERE var='fairname' AND year > 0 ORDER BY year DESC");
echo "<select name=\"year\" size=1>";
while($r=mysql_fetch_object($results)) {
@ -61,48 +56,31 @@
<option value=\"csv\">CSV</option>
</select></td>";
echo "</td></tr>\n";
echo "<tr>";
//list award subsets to output
echo "<td><b>".i18n("Award Type").":</b></td> <td> <select name=\"awardtype\" size=1>";
$results = mysql_query("SELECT type FROM award_types WHERE conferences_id=".$conference['id']." ORDER BY type");
$results = mysql_query("SELECT type FROM award_types WHERE year=".$config['FAIRYEAR']." ORDER BY type");
echo "<option value=\"All\">".i18n("All")."</option>";
while($r=mysql_fetch_object($results)) {
echo "<option value=\"$r->type\">".i18n("$r->type")."</option>";
}
echo "</select></td>";
echo "</td></tr>\n";
echo "<tr>";
echo "</select></td></tr>";
//list award formats to output
echo "<td>
<b>".i18n("Script Format").":</b>
</td>
<td>
<select name=\"scriptformat\" size=1>
<option value=\"default\">Default</option>
<option value=\"formatted\">Formatted</option>
</select></td></tr>";
echo "<tr><td ><b>".i18n("Show awards without winners").":</b></td>";
echo "<tr><td colspan=3><b>".i18n("Show awards without winners").":</b></td>";
echo "<td><input name=\"show_unawarded_awards\" type=\"checkbox\" ".($config['reports_show_unawarded_awards'] == 'yes' ? "checked" : "")."/></td></tr>";
echo "<tr><td ><b>".i18n("Show prizes without winners").":</b></td>";
echo "<tr><td colspan=3><b>".i18n("Show prizes without winners").":</b></td>";
echo "<td><input name=\"show_unawarded_prizes\" type=\"checkbox\" ".($config['reports_show_unawarded_prizes'] == 'yes' ? "checked" : "")."/></td></tr>";
echo "<tr><td ><b>".i18n("Show criteria for each award").":</b></td>";
echo "<td><input name=\"show_criteria\" type=\"checkbox\" ".($config['reports_show_criteria'] == 'yes' ? "checked" : "")." value=\"on\"/></td></tr>";
echo "<tr><td ><b>".i18n("Show student name pronunciation").":</b></td>";
echo "<tr><td colspan=3><b>".i18n("Show student name pronunciation").":</b></td>";
echo "<td><input name=\"show_pronunciation\" type=\"checkbox\" /></td></tr>";
echo "<tr><td width=\"30%\"><b>".i18n("Group divisional results by Prize (instead of Award Name). This groups all the honourable mentions in all divisions together, all the bronzes together, etc."). ":</b></td>";
echo "<td><input name=\"group_by_prize\" type=\"checkbox\" /></td></tr>";
echo "<tr><td><b>".i18n("Include the following age categories").":</b></td>";
echo "<tr><td colspan=\"3\"><b>".i18n("Include the following age categories").":</b></td>";
echo "<td>";
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='{$conference['id']}' ORDER BY id");
$q=mysql_query("SELECT * FROM projectcategories WHERE year='{$config['FAIRYEAR']}' ORDER BY id");
while($r=mysql_fetch_object($q)) {
echo "<input name=\"show_category[{$r->id}]\" type=\"checkbox\" checked=\"checked\" />";
echo "".i18n($r->category)."<br />";
}
echo "</table>";
echo "<input type=\"submit\" value=\"".i18n("Generate Script")."\" />";
echo "</form>";

View File

@ -23,117 +23,97 @@
$report_committees_fields = array(
'name' => array(
'start_option_group' => 'Committee Member Name',
'name' => 'Committee Member -- Full Name ',
'header' => 'Name',
'width' => 44.45 /*mm*/,
'width' => 1.75,
'table' => "CONCAT(users.firstname, ' ', users.lastname)",
'table_sort' => 'users.lastname'),
'last_name' => array(
'name' => 'Committee Member -- Last Name',
'header' => 'Last Name',
'width' => 25.4 /*mm*/,
'width' => 1.0,
'table' => 'users.lastname' ),
'first_name' => array(
'name' => 'Committee Member -- First Name',
'header' => 'First Name',
'width' => 25.4 /*mm*/,
'width' => 1.0,
'table' => 'users.firstname' ),
'email' => array(
'start_option_group' => 'Committee Member Contact Information',
'name' => 'Committee Member -- Email',
'header' => 'Email',
'width' => 50.8 /*mm*/,
'table' => 'accounts.email'),
'width' => 2.0,
'table' => 'users.email'),
'phone_home' => array(
'name' => 'Committee Member -- Phone (Home)',
'header' => 'Phone(Home)',
'width' => 25.4 /*mm*/,
'width' => 1,
'table' => 'users.phonehome'),
'phone_work' => array(
'name' => 'Committee Member -- Phone (Work)',
'header' => 'Phone(Work)',
'width' => 31.75 /*mm*/,
'width' => 1.25,
'table' => 'users.phonework'),
'phone_cel' => array(
'name' => 'Committee Member -- Phone (Cell)',
'header' => 'Phone(Cell)',
'width' => 25.4 /*mm*/,
'name' => 'Committee Member -- Phone (Cel)',
'header' => 'Phone(Cel)',
'width' => 1,
'table' => 'users.phonecell'),
'address' => array(
'name' => 'Committee Member -- Address Street',
'header' => 'Address',
'width' => 50.8 /*mm*/,
'width' => 2.0,
'table' => "CONCAT(users.address, ' ', users.address2)"),
'city' => array(
'name' => 'Committee Member -- Address City',
'header' => 'City',
'width' => 38.1 /*mm*/,
'width' => 1.5,
'table' => 'users.city' ),
'province' => array(
'name' => 'Committee Member -- Address '.$config['provincestate'],
'header' => $config['provincestate'],
'width' => 19.05 /*mm*/,
'width' => 0.75,
'table' => 'users.province' ),
'postal' => array(
'name' => 'Committee Member -- Address '.$config['postalzip'],
'header' => $config['postalzip'],
'width' => 19.05 /*mm*/,
'width' => 0.75,
'table' => 'users.postalcode' ),
'organization' => array(
'start_option_group' => 'Committee Member Misc.',
'name' => 'Committee Member -- Organization',
'header' => 'Organization',
'width' => 50.8 /*mm*/,
'width' => 2,
'table' => 'users.organization'),
'firstaid' => array(
'name' => 'Committee Member -- First Aid Training',
'header' => 'F.Aid',
'width' => 12.7 /*mm*/,
'width' => 0.5,
'table' => 'users.firstaid',
'value_map' =>array ('no' => 'no', 'yes' => 'YES')),
'cpr' => array(
'name' => 'Committee Member -- CPR Training',
'header' => 'CPR',
'width' => 12.7 /*mm*/,
'width' => 0.5,
'table' => 'users.cpr',
'value_map' =>array ('no' => 'no', 'yes' => 'YES')),
/* The label system depends on each report type having conference_name and conference_logo */
'conference_name' => array(
'start_option_group' => 'Conference Information',
'name' => 'Conference -- Name',
'header' => 'Conference Name',
'width' => 76.2 /*mm*/,
'table' => "'".mysql_escape_string($conference['name'])."'"),
'conference_logo' => array(
'name' => 'Conference -- Logo (for Labels only)',
'header' => '',
'width' => 1 /*mm*/,
'table' => "CONCAT(' ')"),
'static_text' => array(
'start_option_group' => 'Special Fields',
'name' => 'Static Text (useful for labels)',
'header' => '',
'width' => 2.54 /*mm*/,
'width' => 0.1,
'table' => "CONCAT(' ')"),
);
function report_committees_fromwhere($report, $components)
@ -141,10 +121,9 @@ $report_committees_fields = array(
global $config, $report_committees_fields;
$fields = $report_committees_fields;
/*
// if this gets unremarked for future use, then the year references will need to be updated to use conferences instead
$year = $report['year'];
/*
$teams_from = '';
$teams_where = '';
if(in_array('teams', $components)) {
@ -155,11 +134,10 @@ $report_committees_fields = array(
AND committees_teams.year='$year'";
}
*/
$q = " FROM users
LEFT JOIN user_roles on user_roles.users_id=users.id
LEFT JOIN accounts ON accounts.id=users.accounts_id
$q = " FROM
users
WHERE
user_role.type='committee'
users.types LIKE '%committee%'
";
return $q;

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
require_once('reports_students.inc.php');
require_once('reports_judges.inc.php');
@ -33,30 +33,20 @@
require_once('reports_schools.inc.php');
require_once('reports_volunteers.inc.php');
require_once('reports_tours.inc.php');
require_once('reports_fairs.inc.php');
require_once('reports_fundraising.inc.php');
require_once('reports.inc.php');
require_once('../tcpdf.inc.php');
$fields = array();
$locs = array('X' => 'x', 'Y' => 'y', 'W' => 'w', 'H' => 'h');
$locs = array('X' => 'x', 'Y' => 'y', 'W' => 'w', 'H' => 'h', 'Lines' => 'lines');
function field_selector($name, $id, $selected)
{
global $fields;
$in_optgroup = false;
echo "<select name=\"$name\" id=\"$id\">";
echo "<option value=\"\" />-- None --</option>";
foreach($fields as $k=>$f) {
if($f['editor_disabled'] == true) continue;
if(array_key_exists('start_option_group', $f)) {
if($in_optgroup) echo '</optgroup>';
echo '<optgroup label="'.i18n($f['start_option_group']).'">';
}
$sel = ($selected == $k) ? 'selected=\"selected\"': '' ;
echo "<option value=\"$k\" $sel >{$f['name']}</option>";
}
if($in_optgroup) echo '</optgroup>';
echo "</select>";
}
@ -96,7 +86,7 @@
exit;
}
} else if($l == 'valign') {
$aligns = array('vtop', 'vbottom', 'vcenter', 'top','middle','bottom');
$aligns = array('vtop', 'vbottom', 'vcenter');
if(!in_array($v, $aligns)) {
echo "Invalid valignment $v";
exit;
@ -175,7 +165,7 @@
}
send_header("Report Management",
send_header("Reports Editor",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php'),
"report_management"
@ -193,33 +183,30 @@ function reportReload()
var canvasWidth=0;
var canvasHeight=0;
var canvasObjectIndex=0;
var labelWidth=0;
var labelHeight=0;
function initCanvas(w,h,lw,lh) {
function initCanvas(w,h) {
canvasWidth=w;
canvasHeight=h;
labelWidth=lw;
labelHeight=lh;
}
function createData(x,y,w,h,align,valign,fontname,fontstyle,fontsize,value) {
function createData(x,y,w,h,l,face,align,valign,value) {
var canvas=document.getElementById('layoutcanvas');
var newdiv=document.createElement('div');
if(valign=="vcenter") verticalAlign="middle";
else if(valign=="vtop") verticalAlign="top";
else if(valign=="vbottom") verticalAlign="bottom";
else verticalAlign="top";
// alert(verticalAlign);
var dx = Math.round(x * canvasWidth / labelWidth);
var dy = Math.round(y * canvasHeight / labelHeight);
var dw = Math.round(w * canvasWidth / labelWidth);
var dh = Math.round(h * canvasHeight / labelHeight);
//convert x,y,w,h from % to absolute
var fontheight=(fontsize * 25.4 / 72) * canvasHeight / labelHeight;
var l = Math.floor(h/fontheight);
if(fontheight == 0) fontheight=10;
if(l==0) l=1;
var dx=Math.round(x*canvasWidth/100);
var dy=Math.round(y*canvasHeight/100);
var dw=Math.round(w*canvasWidth/100);
var dh=Math.round(h*canvasHeight/100);
// alert(dx+','+dy+','+dw+','+dh);
// alert(dh + ", fh="+fontheight);
var fontheight=Math.round(dh/l);
newdiv.setAttribute('id','o_'+canvasObjectIndex);
newdiv.style.display="table-cell";
@ -229,26 +216,26 @@ function createData(x,y,w,h,align,valign,fontname,fontstyle,fontsize,value) {
newdiv.style.left=dx+"px";
newdiv.style.top=dy+"px";
newdiv.style.textAlign=align;
newdiv.style.verticalAlign=valign;
newdiv.style.verticalAlign=verticalAlign;
newdiv.style.padding="0 0 0 0";
newdiv.style.margin="0 0 0 0";
// newdiv.style.vertical-align=valign;
newdiv.style.border="1px solid blue";
newdiv.style.fontSize=fontheight+"px";
newdiv.style.lineHeight=fontheight+"px";
newdiv.style.fontFamily=fontname;
newdiv.style.fontFamily="Verdana";
newdiv.style.fontSizeAdjust=0.65;
var maxlength=Math.floor(dw/(fontheight*0.7))*l;
if(value.length>maxlength) value=value.substring(0,maxlength);
newdiv.innerHTML=value;
newdiv.innerHTML=value; //"Maple Test xxxx"; //value;
canvas.appendChild(newdiv);
canvasObjectIndex++;
}
canvasObjectIndex++;
}
</script>
<?
@ -291,9 +278,9 @@ function createData(x,y,w,h,align,valign,fontname,fontstyle,fontsize,value) {
$x++;
}
/* Do the fields */
$fs = array('col', 'group', 'sort', 'distinct', 'filter');
$fields = array('col', 'group', 'sort', 'distinct', 'filter');
$first = true;
foreach($fs as $f) {
foreach($fields as $f) {
foreach($report[$f] as $x=>$v) {
$k = $v['field'];
$vx = intval($v['x']);
@ -365,8 +352,7 @@ function createData(x,y,w,h,align,valign,fontname,fontstyle,fontsize,value) {
selector('type', array('student' => 'Student Report', 'judge' => 'Judge Report',
'award' => 'Award Report', 'committee' => 'Committee Member Report',
'school' => 'School Report', 'volunteer' => 'Volunteer Report',
'tour' => 'Tour Report', 'fair' => 'Feeder Fair Report',
'fundraising' => 'Fundraising Report'),
'tour' => 'Tour Report'),
$report['type'],
"onChange=\"reportReload();\"");
echo "<input type=\"hidden\" name=\"reloadaction\" value=\"\">";
@ -404,91 +390,71 @@ function createData(x,y,w,h,align,valign,fontname,fontstyle,fontsize,value) {
echo "</td></tr>";
echo "</table>\n";
$doCanvasSample = false;
echo "<h4>Label Data Locations</h4>";
$l_w=$report_stock[$report['option']['stock']]['label_width'];
$l_h=$report_stock[$report['option']['stock']]['label_height'];
if($l_w && $l_h && $report['option']['type']=='label') {
echo "<h4>Label Data Locations</h4>";
if($l_w && $l_h) {
$doCanvasSample=true;
$ratio=$l_h/$l_w;
$canvaswidth=600;
$canvasheight=round($canvaswidth*$ratio);
echo "<div id=\"layoutcanvas\" style=\"border: 1px solid red; position: relative; width: {$canvaswidth}px; height: {$canvasheight}px;\">";
echo "</div>\n";
echo "<script type=\"text/javascript\">initCanvas($canvaswidth,$canvasheight,$l_w,$l_h)</script>\n";
echo "<script type=\"text/javascript\">initCanvas($canvaswidth,$canvasheight)</script>\n";
}
echo "<table>";
$x=0;
if($report['option']['type'] == 'label') {
$fontlist = array('' => 'Default');
$fl = PDF::getFontList();
foreach($fl as $f) $fontlist[$f] = $f;
// print_r($fl);
foreach($report['col'] as $o=>$d) {
$f = $d['field'];
echo "<b>{$fields[$d['field']]['name']}: </b><br/>";
echo "<tr><td align=\"right\">Loc ".($o+1).": </td>";
echo "<td>";
$script="";
foreach($locs as $k=>$v) {
echo "$k=<input type=\"text\" size=\"5\" name=\"col[$x][$v]\" value=\"{$d[$v]}\">";
echo "$k=<input type=\"text\" size=\"3\" name=\"col[$x][$v]\" value=\"{$d[$v]}\">";
$script.="{$d[$v]},";
}
echo 'Face=';
selector("col[$x][face]", array('' => '', 'bold' => 'Bold'), $d['face']);
echo 'Align';
selector("col[$x][align]", array('center' => 'Center', 'left' => 'Left', 'right' => 'Right'),
$d['align']);
echo 'vAlign';
selector("col[$x][valign]", array('middle' => 'Middle', 'top' => 'Top', 'bottom' => 'Bottom'),
selector("col[$x][valign]", array('vcenter' => 'Center', 'vtop' => 'Top', 'vbottom' => 'Bottom'),
$d['valign']);
echo '<br/>';
echo 'Font=';
selector("col[$x][fontname]", $fontlist, $d['fontname']);
selector("col[$x][fontstyle]", array('' => '', 'bold' => 'Bold'), $d['fontstyle']);
echo "<input type=\"text\" size=\"3\" name=\"col[$x][fontsize]\" value=\"{$d['fontsize']}\">";
echo 'pt ';
echo 'OnOverflow=';
selector("col[$x][on_overflow]", array('nothing'=>'Nothing (overflow the box)', 'truncate'=>'Truncate','...'=>'Truncate and add ellipses (...)', 'scale'=>'Scale'), $d['on_overflow']);
if($f == 'static_text') {
echo "<br />Text=<input type=\"text\" size=\"40\" name=\"col[$x][value]\" value=\"{$d['value']}\">";
} else {
echo "<input type=\"hidden\" name=\"col[$x][value]\" value=\"\">";
}
if($doCanvasSample)
echo "<script type=\"text/javascript\">createData({$script}'{$d['align']}','{$d['valign']}','{$d['fontname']}','{$d['fontstyle']}','{$d['fontsize']}','{$canvasLabels[$x]}')</script>\n";
echo "<script type=\"text/javascript\">createData({$script}'{$d['face']}','{$d['align']}','{$d['valign']}','{$canvasLabels[$x]}')</script>\n";
$x++;
echo '<br/><br/>';
}
for(;$x<$n_columns;$x++) {
echo "<b>New Column ".($x+1).": </b><br/> ";
echo "<tr><td align=\"right\">Loc ".($x+1).": </td>";
echo "<td>";
foreach($locs as $k=>$v) {
echo "$k=<input type=\"text\" size=\"5\" name=\"col[$x][$v]\" value=\"0\">";
echo "$k=<input type=\"text\" size=\"3\" name=\"col[$x][$v]\" value=\"0\">";
}
echo 'Face=';
selector("col[$x][face]", array('' => '', 'bold' => 'Bold'), '');
echo 'Align';
selector("col[$x][align]", array('center' => 'Center', 'left' => 'Left', 'right' => 'Right'),
'center');
echo 'vAlign';
selector("col[$x][valign]", array('middle' => 'Middle', 'top' => 'Top', 'bottom' => 'Bottom'), 'middle');
echo '<br/>';
echo 'Font=';
selector("col[$x][fontname]", $fontlist, '');
selector("col[$x][fontstyle]", array('' => '', 'bold' => 'Bold'), '');
echo "<input type=\"text\" size=\"3\" name=\"col[$x][fontsize]\" value=\"\">";
echo 'pt ';
echo 'OnOverflow=';
selector("col[$x][on_overflow]", array('nothing'=>'Nothing (overflow the box)', 'truncate'=>'Truncate','...'=>'Truncate and add ellipses (...)', 'scale'=>'Scale'),'truncate');
selector("col[$x][valign]", array('vcenter' => 'Center', 'vtop' => 'Top', 'vbottom' => 'Bottom'),
'top');
echo "<input type=\"hidden\" name=\"col[$x][value]\" value=\"\">";
echo "<br/><br/>";
echo "</td></tr>";
}
}
echo "</table>\n";
echo "<h4>Grouping</h4>";
for($x=0;$x<2;$x++) {
echo "Group By".($x + 1).": ";

View File

@ -1,441 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 David Grant <dave@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
$parts = explode('-', $config['dates']['fairdate']);
$fairYear = $parts[0];
$report_fairs_fields = array(
'fairinfo_name' => array(
'start_option_group' => 'Fair Information',
'name' => 'Fair -- Fair Name',
'header' => 'Name',
'width' => 38.1 /*mm*/,
'table' => 'fairs.name'),
'fairstats_year' => array (
'start_option_group' => 'Fair Statistics',
'name' => 'Fair Stats -- Year',
'header' => 'Year',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.year',
'components' => array('fairs_stats')),
'fairstats_year' => array (
'name' => 'Fair Stats -- Year',
'header' => 'Year',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.year',
'components' => array('fairs_stats')),
'fairstats_start_date' => array (
'name' => 'Fair Stats -- Fair Start',
'header' => 'Fair Start',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.start_date',
'components' => array('fairs_stats')),
'fairstats_end_date' => array (
'name' => 'Fair Stats -- Fair End',
'header' => 'Fair End',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.end_date',
'components' => array('fairs_stats')),
'fairstats_budget' => array (
'name' => 'Fair Stats -- Budget',
'header' => 'Budget',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.budget',
'components' => array('fairs_stats')),
'fairstats_address' => array (
'name' => 'Fair Stats -- Fair Location',
'header' => 'Fair Location',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.address',
'components' => array('fairs_stats')),
'fairstats_ysf_affiliation_complete' => array (
'name' => 'Fair Stats -- YSC Affilitation Complete',
'header' => 'YSC Affilitation Complete',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.ysf_affiliation_complete',
'components' => array('fairs_stats')),
'fairstats_charity' => array (
'name' => 'Fair Stats -- Charity Number/Info',
'header' => 'Charity Number/Info',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.charity',
'components' => array('fairs_stats')),
'fairstats_scholarships' => array (
'name' => 'Fair Stats -- Scholarship Info',
'header' => 'Scholarship Info',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.scholarships',
'components' => array('fairs_stats')),
'fairstats_male_1' => array (
'name' => 'Fair Stats -- Males Grade 1-3',
'header' => 'Males Grade 1-3',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.male_1',
'components' => array('fairs_stats')),
'fairstats_male_4' => array (
'name' => 'Fair Stats -- Males Grade 4-6',
'header' => 'Males Grade 4-6',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.male_4',
'components' => array('fairs_stats')),
'fairstats_male_7' => array (
'name' => 'Fair Stats -- Males Grade 7-8',
'header' => 'Males Grade 7-8',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.male_7',
'components' => array('fairs_stats')),
'fairstats_male_9' => array (
'name' => 'Fair Stats -- Males Grade 9-10',
'header' => 'Males Grade 9-10',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.male_9',
'components' => array('fairs_stats')),
'fairstats_male_11' => array (
'name' => 'Fair Stats -- Males Grade 11-12',
'header' => 'Males Grade 11-12',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.male_11',
'components' => array('fairs_stats')),
'fairstats_female_1' => array (
'name' => 'Fair Stats -- Females Grade 1-3',
'header' => 'Females Grade 1-3',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.female_1',
'components' => array('fairs_stats')),
'fairstats_female_4' => array (
'name' => 'Fair Stats -- Females Grade 4-6',
'header' => 'Females Grade 4-6',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.female_4',
'components' => array('fairs_stats')),
'fairstats_female_7' => array (
'name' => 'Fair Stats -- Females Grade 7-8',
'header' => 'Females Grade 7-8',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.female_7',
'components' => array('fairs_stats')),
'fairstats_female_9' => array (
'name' => 'Fair Stats -- Females Grade 9-10',
'header' => 'Females Grade 9-10',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.female_9',
'components' => array('fairs_stats')),
'fairstats_female_11' => array (
'name' => 'Fair Stats -- Females Grade 11-12',
'header' => 'Females Grade 11-12',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.female_11',
'components' => array('fairs_stats')),
'fairstats_projects_1' => array (
'name' => 'Fair Stats -- Projects Grade 1-3',
'header' => 'Projects Grade 1-3',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.projects_1',
'components' => array('fairs_stats')),
'fairstats_projects_4' => array (
'name' => 'Fair Stats -- Projects Grade 4-6',
'header' => 'Projects Grade 4-6',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.projects_4',
'components' => array('fairs_stats')),
'fairstats_projects_7' => array (
'name' => 'Fair Stats -- Projects Grade 7-8',
'header' => 'Projects Grade 7-8',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.projects_7',
'components' => array('fairs_stats')),
'fairstats_projects_9' => array (
'name' => 'Fair Stats -- Projects Grade 9-10',
'header' => 'Projects Grade 9-10',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.projects_9',
'components' => array('fairs_stats')),
'fairstats_projects_11' => array (
'name' => 'Fair Stats -- Projects Grade 11-12',
'header' => 'Projects Grade 11-12',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.projects_11',
'components' => array('fairs_stats')),
'fairstats_firstnations' => array (
'name' => 'Fair Stats -- First Nations Students',
'header' => 'First Nations Students',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.firstnations',
'components' => array('fairs_stats')),
'fairstats_students_atrisk' => array (
'name' => 'Fair Stats -- Inner City Students',
'header' => 'Inner City Students',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.students_atrisk',
'components' => array('fairs_stats')),
'fairstats_schools_atrisk' => array (
'name' => 'Fair Stats -- Inner City Schools',
'header' => 'Inner City Schools',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.schools_atrisk',
'components' => array('fairs_stats')),
'fairstats_students_total' => array (
'name' => 'Fair Stats -- Total Participants',
'header' => 'Total Participants',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.students_total',
'components' => array('fairs_stats')),
'fairstats_schools_total' => array (
'name' => 'Fair Stats -- Total Schools',
'header' => 'Total Schools',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.schools_total',
'components' => array('fairs_stats')),
'fairstats_schools_active' => array (
'name' => 'Fair Stats -- Active Schools',
'header' => 'Active Schools',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.schools_active',
'components' => array('fairs_stats')),
'fairstats_students_public' => array (
'name' => 'Fair Stats -- Participants from Public',
'header' => 'Participants from Public',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.students_public',
'components' => array('fairs_stats')),
'fairstats_schools_public' => array (
'name' => 'Fair Stats -- Public Schools',
'header' => 'Public Schools',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.schools_public',
'components' => array('fairs_stats')),
'fairstats_students_private' => array (
'name' => 'Fair Stats -- Participants from Independent',
'header' => 'Participants from Independent',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.students_private',
'components' => array('fairs_stats')),
'fairstats_schools_private' => array (
'name' => 'Fair Stats -- Independent Schools',
'header' => 'Independent Schools',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.schools_private',
'components' => array('fairs_stats')),
'fairstats_schools_districts' => array (
'name' => 'Fair Stats -- School Districts',
'header' => 'School Districts',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.schools_districts',
'components' => array('fairs_stats')),
'fairstats_studentsvisiting' => array (
'name' => 'Fair Stats -- Students Visiting',
'header' => 'Students Visiting',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.studentsvisiting',
'components' => array('fairs_stats')),
'fairstats_publicvisiting' => array (
'name' => 'Fair Stats -- Public Guests Visting',
'header' => 'Public Guests Visting',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.publicvisiting',
'components' => array('fairs_stats')),
'fairstats_teacherssupporting' => array (
'name' => 'Fair Stats -- Teachers Supporting Projects',
'header' => 'Teachers Supporting Projects',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.teacherssupporting',
'components' => array('fairs_stats')),
'fairstats_increasedinterest' => array (
'name' => 'Fair Stats -- Students Increased Interest in Science',
'header' => 'Students Increased Interest in Science',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.increasedinterest',
'components' => array('fairs_stats')),
'fairstats_consideringcareer' => array (
'name' => 'Fair Stats -- Students Considering Career in Science',
'header' => 'Students Considering Career in Science',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.consideringcareer',
'components' => array('fairs_stats')),
'fairstats_committee_members' => array (
'name' => 'Fair Stats -- Committee Members',
'header' => 'Committee Members',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.committee_members',
'components' => array('fairs_stats')),
'fairstats_judges' => array (
'name' => 'Fair Stats -- Judges',
'header' => 'Judges',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.judges',
'components' => array('fairs_stats')),
'fairstats_next_chair_name' => array (
'name' => 'Fair Stats -- Regional Chairperson Name',
'header' => 'Regional Chairperson Name',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.next_chair_name',
'components' => array('fairs_stats')),
'fairstats_next_chair_email' => array (
'name' => 'Fair Stats -- Email',
'header' => 'Email',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.next_chair_email',
'components' => array('fairs_stats')),
'fairstats_next_chair_hphone' => array (
'name' => 'Fair Stats -- Home Phone',
'header' => 'Home Phone',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.next_chair_hphone',
'components' => array('fairs_stats')),
'fairstats_next_chair_bphone' => array (
'name' => 'Fair Stats -- Business Phone',
'header' => 'Business Phone',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.next_chair_bphone',
'components' => array('fairs_stats')),
'fairstats_next_chair_fax' => array (
'name' => 'Fair Stats -- Fax',
'header' => 'Fax',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.next_chair_fax',
'components' => array('fairs_stats')),
'fairstats_delegate1' => array (
'name' => 'Fair Stats -- Delegate 1',
'header' => 'Delegate 1',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.delegate1',
'components' => array('fairs_stats')),
'fairstats_delegate2' => array (
'name' => 'Fair Stats -- Delegate 2',
'header' => 'Delegate 2',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.delegate2',
'components' => array('fairs_stats')),
'fairstats_delegate3' => array (
'name' => 'Fair Stats -- Delegate 3',
'header' => 'Delegate 3',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.delegate3',
'components' => array('fairs_stats')),
'fairstats_delegate4' => array (
'name' => 'Fair Stats -- Delegate 4',
'header' => 'Delegate 4',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.delegate4',
'components' => array('fairs_stats')),
'fairstats_delegate1_email' => array (
'name' => 'Fair Stats -- Delegate 1 Email',
'header' => 'Delegate 1 Email',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.delegate1_email',
'components' => array('fairs_stats')),
'fairstats_delegate2_email' => array (
'name' => 'Fair Stats -- Delegate 2 Email',
'header' => 'Delegate 2 Email',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.delegate2_email',
'components' => array('fairs_stats')),
'fairstats_delegate3_email' => array (
'name' => 'Fair Stats -- Delegate 3 Email',
'header' => 'Delegate 3 Email',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.delegate3_email',
'components' => array('fairs_stats')),
'fairstats_delegate4_email' => array (
'name' => 'Fair Stats -- Delegate 4 Email',
'header' => 'Delegate 4 Email',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.delegate4_email',
'components' => array('fairs_stats')),
'fairstats_delegate1_size' => array (
'name' => 'Fair Stats -- Delegate 1 Jacket Size',
'header' => 'Delegate 1 Jacket Size',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.delegate1_size',
'components' => array('fairs_stats')),
'fairstats_delegate2_size' => array (
'name' => 'Fair Stats -- Delegate 2 Jacket Size',
'header' => 'Delegate 2 Jacket Size',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.delegate2_size',
'components' => array('fairs_stats')),
'fairstats_delegate3_size' => array (
'name' => 'Fair Stats -- Delegate 3 Jacket Size',
'header' => 'Delegate 3 Jacket Size',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.delegate3_size',
'components' => array('fairs_stats')),
'fairstats_delegate4_size' => array (
'name' => 'Fair Stats -- Delegate 4 Jacket Size',
'header' => 'Delegate 4 Jacket Size',
'width' => 25.4 /*mm*/,
'table' => 'fairs_stats.delegate4_size',
'components' => array('fairs_stats')),
/* The label system depends on each report type having conference_name and conference_logo */
'conference_name' => array(
'start_option_group' => 'Local Conference Information',
'name' => 'Conference -- Name',
'header' => 'Conference Name',
'width' => 76.2 /*mm*/,
'table' => "'".mysql_escape_string($conference['name'])."'"),
'conference_logo' => array(
'name' => 'Conference -- Logo (for Labels only)',
'header' => '',
'width' => 1 /*mm*/,
'table' => "CONCAT(' ')"),
'static_text' => array (
'name' => 'Static Text (useful for labels)',
'header' => '',
'width' => 2.54 /*mm*/,
'table' => "CONCAT(' ')"),
);
function report_fairs_fromwhere($report, $components)
{
global $config, $report_fairs_fields;
$fields = $report_fairs_fields;
$conferences_id = $report['conferences_id'];
if(in_array('fairs_stats', $components)) {
$fs_from = 'LEFT JOIN fairs_stats ON fairs_stats.fairs_id=fairs.id';
$fs_where = "fairs_stats.conferences_id='$conferences_id' AND";
}
$q = " FROM fairs
$fs_from
WHERE
$fs_where
1
";
return $q;
}
?>

View File

@ -1,220 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* Take the language array in users_fundraising, unserialize it, and join it
* with a space */
function report_fundraisings_languages(&$report, $field, $text)
{
$l = unserialize($text);
return join(' ', $l);
}
/* Components: */
/* Yes, fundraisings, the generator takes the report type (also the user.type in many cases) and
* just adds an 's' to find the fields and the functions. */
$report_fundraisings_fields = array(
'fundraising_campaigns_id' => array(
'start_option_group' => 'Campaign ID',
'name' => 'Fundraising Campaign numerical ID',
'header' => 'ID',
'width' => 6.35 /*mm*/,
'table' => "fundraising_campaigns.id"),
'salutation' => array(
'start_option_group' => 'Contact Information',
'name' => 'Contact -- Salutation (Mr., Mrs., etc.)',
'header' => 'Sal',
'width' => 12.7 /*mm*/,
'table' => "users.salutation",
'components' => array('users') ),
'namefl' => array(
'name' => 'Contact -- Full Name (first last)',
'header' => 'Name',
'width' => 44.45 /*mm*/,
'table' => "CONCAT(users.firstname, ' ', users.lastname)",
'table_sort'=> 'users.lastname',
'components' => array('users') ),
'email' => array(
'name' => 'Contact -- Email',
'header' => 'Email',
'width' => 50.8 /*mm*/,
'table' => 'users.email',
'components' => array('users') ),
'phone_home' => array(
'name' => 'Contact -- Phone (Home)',
'header' => 'Phone(Home)',
'width' => 25.4 /*mm*/,
'table' => 'users.phonehome',
'components' => array('users') ),
'phone_work' => array(
'name' => 'Contact -- Phone (Work)',
'header' => 'Phone(Work)',
'width' => 31.75 /*mm*/,
'table' => "users.phonework",
'components' => array('users') ),
'organization' => array(
'name' => 'Contact -- Organization',
'header' => 'Organization',
'width' => 50.8 /*mm*/,
'table' => 'users.organization',
'components' => array('users') ),
'position' => array(
'name' => 'Contact -- Position',
'header' => 'Position',
'width' => 50.8 /*mm*/,
'table' => 'users_sponsor.position',
'components' => array('users') ),
'address' => array(
'start_option_group' => 'Contact Address',
'name' => 'Contact Address -- Street',
'header' => 'Address',
'width' => 50.8 /*mm*/,
'table' => "CONCAT(users.address, ' ', users.address2)",
'components' => array('users') ),
'city' => array(
'name' => 'Contact Address -- City',
'header' => 'City',
'width' => 38.1 /*mm*/,
'table' => 'users.city',
'components' => array('users') ),
'province' => array(
'name' => 'Contact Address -- '.$config['provincestate'],
'header' => $config['provincestate'],
'width' => 19.05 /*mm*/,
'table' => 'users.province',
'components' => array('users') ),
'postal' => array(
'name' => 'Contact Address -- '.$config['postalzip'],
'header' => $config['postalzip'],
'width' => 19.05 /*mm*/,
'table' => 'users.postalcode' ,
'components' => array('users') ),
'city_prov' => array(
'name' => 'Contact Address -- City, '.$config['provincestate'].' (for mailing)',
'header' => 'City',
'width' => 38.1 /*mm*/,
'table' => "CONCAT(users.city, ', ', users.province)",
'components' => array('users') ),
/* // FIXME - not sure what to do with these options, converting from years to conferences
'year' => array(
'start_option_group' => 'Miscellaneous',
'name' => 'Contact -- Year',
'header' => 'Year',
'width' => 12.7 //mm,
'table' => 'users.year',
'components' => array('users') ),
'user_filter' => array(
'name' => 'User Filter by MAX(year)',
'header' => '',
'width' => 2.54 //mm,
'table' => 'MAX(users.year)',
'group_by' => array('users.accounts_id'),
'components' => array('users') ),
*/
'static_text' => array(
'name' => 'Static Text (useful for labels)',
'header' => '',
'width' => 2.54 /*mm*/,
'table' => "CONCAT(' ')"),
/* The label system depends on each report type having conference_name and conference_logo */
'conference_name' => array(
'start_option_group' => 'Conference Information',
'name' => 'Conference -- Name',
'header' => 'Conference Name',
'width' => 76.2 /*mm*/,
'table' => "'".mysql_escape_string($conference['name'])."'"),
'conference_logo' => array(
'name' => 'Conference -- Logo (for Labels only)',
'header' => '',
'width' => 1 /*mm*/,
'table' => "CONCAT(' ')"),
);
function report_fundraisings_fromwhere($report, $components)
{
global $config, $report_fundraisings_fields;
$fields = $report_fundraisings_fields;
// $conferences_id = $report['conferences_id'];
if(in_array('users', $components)) {
$users_from = 'LEFT JOIN fundraising_campaigns_users_link ON fundraising_campaigns.id=fundraising_campaigns_users_link.fundraising_campaigns_id
LEFT JOIN users ON users.accounts_id=fundraising_campaigns_users_link.users_uid
LEFT JOIN users_sponsor ON users_sponsor.users_id=users.id';
$users_where = "users.deleted!='yes' AND";
}
/*
// this chunk of code was already remarked when updating the system to use conferences
// instead of fair years. If it gets re-used however, then it will need to be updated
// accordingly. Not sure as I write this comment how the fundraising years will link
// to the conferences, rather than to the fair years that were previously used.
$teams_from = '';
$teams_where = '';
if(in_array('teams', $components)) {
$teams_from = "LEFT JOIN fundraisings_teams_link ON judges_teams_link.users_id=users.id
LEFT JOIN fundraisings_teams ON judges_teams.id=judges_teams_link.judges_teams_id";
$teams_where = "AND fundraisings_teams_link.year='$year'
AND fundraisings_teams.year='$year'";
}
$projects_from='';
$projects_where='';
if(in_array('projects', $components)) {
$projects_from = "LEFT JOIN fundraisings_teams_timeslots_projects_link ON
fundraisings_teams_timeslots_projects_link.judges_teams_id=judges_teams.id
LEFT JOIN projects ON projects.id=fundraisings_teams_timeslots_projects_link.projects_id
LEFT JOIN fundraisings_timeslots ON judges_timeslots.id=judges_teams_timeslots_projects_link.judges_timeslots_id";
$projects_where = "AND fundraisings_teams_timeslots_projects_link.year='$year'
AND projects.year='$year'";
}
*/
$q = " FROM fundraising_campaigns
$users_from
WHERE
$users_where
1
";
return $q;
}
?>

View File

@ -22,260 +22,114 @@
*/
?>
<?
require_once("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
require_once('reports.inc.php');
require_once("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
require_once('reports.inc.php');
$id = intval($_GET['id']);
$sid = intval($_GET['sid']);
$type = stripslashes($_GET['type']);
$stock = stripslashes($_GET['stock']);
$year = intval($_GET['year']);
$show_options = array_key_exists('show_options', $_GET);
if($year < 1000) $year = $config['FAIRYEAR'];
$id = intval($_GET['id']);
$type = $_GET['type'];
$stock = $_GET['stock'];
if(array_key_exists('conferences_id', $_GET)){
$conferences_id = intval($_GET['conferences_id']);
$result = mysql_result(mysql_query("SELECT COUNT(*) FROM conferences WHERE id = $conferences_id"), 0);
if($result != 1) $conferences_id = $conference['id'];
}else{
$conferences_id = $conference['id'];
}
$include_incomplete_registrations = ($_GET['include_incomplete_registrations'] == 'yes') ? 'yes' : '';
$show_options = array_key_exists('show_options', $_GET);
/* If it's a system report, turn that into the actual report id */
if(array_key_exists('sid', $_GET)) {
$sid = intval($_GET['sid']);
$q = mysql_query("SELECT id FROM reports WHERE system_report_id='$sid'");
/* If it's a system report, turn that into the actual report id */
if($sid > 0) {
$q = mysql_query("SELECT id FROM reports WHERE system_report_id='$sid'");
$r = mysql_fetch_assoc($q);
$id = $r['id'];
}
}
$report = report_load($id);
/* Add a custom filter if specified */
$filter_args = '';
if(is_array($_GET['filter'])) {
foreach($_GET['filter'] as $f=>$v) {
$report['filter'][] = array('field'=>$v['field'],'x'=>$v['x'],'value'=>$v['value']);
$filter_args.="&filter[$f][field]={$v['field']}&filter[$f][x]={$v['x']}&filter[$f][value]={$v['value']}";
}
}
switch($_GET['action']) {
case 'dialog_gen':
if($id < 0) {
$u = "{$config['SFIABDIRECTORY']}/{$report_custom[-$id]['custom_url']}";
?>
<script type="text/javascript">
window.location.href="<?=$u?>";
</script>
<?
exit;
}
?>
<div id="report_dialog_gen" title="Generate Report" style="display: none">
<div id="report_gen_tabs">
<ul><li><a href="#report_gen_tab_info"><span><?=i18n('Report Information')?></span></a></li>
<li><a href="#report_gen_tab_advanced"><span><?=i18n('Advanced Options')?></span></a></li>
</ul>
<form id="report_dialog_form" >
<div id="report_gen_tab_info">
<input type="hidden" name="id" value="<?=$id?>" />
<table class="editor" style="width:95%"><tr>
<td colspan="2"><br /><h3><?=i18n('Report Information')?></h3><br /></td>
</tr><tr>
<td class="label"><b><?=i18n("Report Name")?></b>:</td>
<td class="input"><?=$report['name']?></b></td>
</tr><tr>
<td class="label"><b><?=i18n("Description")?></b>:</td>
<td class="input"><?=$report['desc']?></b></td>
</tr><tr>
<td class="label"><b><?=i18n("Created By")?></b>:</td>
<td class="input"><?=$report['creator']?></td>
</tr><tr>
<?
/* See if the report is in this committee member's list */
$q = mysql_query("SELECT * FROM reports_committee
WHERE users_id='{$_SESSION['accounts_id']}'
AND reports_id='{$report['id']}'");
if(mysql_num_rows($q) > 0) {
$i = mysql_fetch_assoc($q);
?>
<td colspan="2"><hr /><h3><?=i18n('My Reports Info')?></h3></td>
</tr><tr>
<td class="label"><b><?=i18n("Category")?></b>:</td>
<td class="input"><?=$i['category']?></b></td>
</tr><tr>
<td class="label"><b><?=i18n("Comment")?></b>:</td>
<td class="input"><?=$i['comment']?></b></td>
</tr><tr>
<? } ?>
<td colspan="2"><br /><hr /><h3><?=i18n('Report Options')?></h3><br /></td>
</tr>
<?
$format = $report['options']['type'];
$stock = $report['options']['stock'];
$conferences_id = $conference['id'];
/* Out of all the report optins, we really only want these ones */
$option_keys = array('type','stock');
foreach($report_options as $ok=>$o) {
if(!in_array($ok, $option_keys)) continue;
echo "<tr><td class=\"label\"><b>{$o['desc']}</b>:</td>";
echo "<td class=\"input\"><select name=\"$ok\" id=\"$ok\">";
foreach($o['values'] as $k=>$v) {
$sel = ($report['option'][$ok] == $k) ? 'selected="selected"' : '';
echo "<option value=\"$k\" $sel>".htmlspecialchars($v)."</option>";
}
echo "</select></td></tr>\n";
}
// Find all conferences
$q = mysql_query("SELECT conferences.name, conferences.id, dates.date FROM conferences JOIN dates on dates.conferences_id = conferences.id WHERE dates.name='fairdate' ORDER BY dates.date DESC");
echo "<tr><td class=\"label\"><b>".i18n('Conference')."</b>:</td>";
echo "<td class=\"input\"><select name=\"conferences_id\" id=\"conferences_id\">";
while($row = mysql_fetch_assoc($q)){
$parts = explode(' ', $row['date']);
$date = $parts[0];
$sel = ($row['id'] == $conferences_id) ? 'selected="selected"' : '';
echo "<option value=\"{$row['id']}\" $sel>{$row['name']} ($date)</option>";
}
echo "</select></td></tr>\n";
?>
</table>
</div>
<div id="report_gen_tab_advanced">
<table class="editor" style="width:95%"><tr>
<td colspan="2"><br /><h4><?=i18n('Advanced Options')?></h4><br /></td>
</tr><tr>
<td class="label"><input type="checkbox" name="include_incomplete_registrations" value="yes" /></td>
<td class="input"><?=i18n('Include student and project data from incomplete registrations. The registration only needs to have a division and category selected.')?></td>
</table>
</div>
</form>
</div></div>
<script type="text/javascript">
$("#report_gen_tabs").tabs();
$("#report_dialog_gen").dialog({
bgiframe: true, autoOpen: true,
modal: true, resizable: false,
draggable: false,
width: 800, //(document.documentElement.clientWidth * 0.8);
height: 600, //(document.documentElement.clientHeight * 0.7),
close: function() {
$(this).dialog('destroy');
$('#report_dialog_gen').remove();
},
buttons: { "<?=i18n("Cancel")?>": function() {
$('#report_dialog_gen').dialog("close");
return false;
},
"<?=i18n("Download Report")?>": function() {
var dlargs = $('#report_dialog_form').serialize()+"<?=$filter_args?>";
var dlurl = "<?=$config['SFIABDIRECTORY']?>/admin/reports_gen.php?"+dlargs;
$('#debug').html(dlurl);
// alert(dlurl);
// $('#content').attr('src',dlurl);
window.location.href=dlurl;
$('#report_dialog_gen').dialog("close");
return false;
}
}
});
</script>
<?
exit;
}
if($show_options == false) {
if($id && $conferences_id) {
$report['conferences_id'] = $conferences_id;
if($show_options == false) {
if($id && $year) {
$report = report_load($id);
$report['year'] = $year;
if($type != '') $report['option']['type'] = $type;
if($stock != '') $report['option']['stock'] = $stock;
if($include_incomplete_registrations != '') $report['option']['include_incomplete_registrations'] = 'yes';
report_gen($report);
} else {
exit;
header("Location: reports.php");
header("Location: reports.php");
}
exit;
}
}
$report = report_load($id);
send_header('Report Options', array(
'Committee Main' => 'committee_main.php',
send_header('Report Options', array(
'Committee Main' => 'committee_main.php',
'My Reports' => 'admin/reports.php'));
echo '<form method=\"get\" action="reports_gen.php">';
echo "<input type=\"hidden\" name=\"id\" value=\"$id\">";
echo '<table class="tableedit">';
echo "<tr><td><b>".i18n('Report&nbsp;Name')."</b>:</td>";
echo "<td>{$report['name']}</td></tr>";
echo "<tr><td><b>".i18n('Description')."</b>:</td>";
echo "<td>{$report['desc']}</td></tr>";
echo "<tr><td><b>".i18n('Created By')."</b>:</td>";
echo "<td>{$report['creator']}</td></tr>";
echo '<table class="tableedit">';
echo "<tr><td><b>".i18n('Report&nbsp;Name')."</b>:</td>";
echo "<td>{$report['name']}</td></tr>";
echo "<tr><td><b>".i18n('Description')."</b>:</td>";
echo "<td>{$report['desc']}</td></tr>";
echo "<tr><td><b>".i18n('Created By')."</b>:</td>";
echo "<td>{$report['creator']}</td></tr>";
echo '<tr><td colspan="2"><hr /></td></tr>';
/* See if the report is in this committee member's list */
$q = mysql_query("SELECT * FROM reports_committee
WHERE users_id='{$_SESSION['accounts_id']}'
echo '<tr><td colspan="2"><hr /></td></tr>';
/* See if the report is in this committee member's list */
$q = mysql_query("SELECT * FROM reports_committee
WHERE users_id='{$_SESSION['users_uid']}'
AND reports_id='{$report['id']}'");
echo "<tr><td colspan=\"2\"><h3>".i18n('My Reports Info')."</h3></td></tr>";
if(mysql_num_rows($q) > 0) {
/* Yes, it is */
echo "<tr><td colspan=\"2\"><h4>".i18n('My Reports Info')."</h4></td></tr>";
if(mysql_num_rows($q) > 0) {
/* Yes, it is */
$i = mysql_fetch_object($q);
echo "<tr><td><b>".i18n('Category')."</b>:</td>";
echo "<td>{$i->category}</td></tr>";
echo "<tr><td><b>".i18n('Comment')."</b>:</td>";
echo "<td>{$i->comment}</td></tr>";
} else {
echo "<tr><td></td><td>".i18n('This report is NOT in your \'My Reports\' list.')."</td></tr>";
}
echo '<tr><td colspan="2"><hr /></td></tr>';
echo "<tr><td colspan=\"2\"><h3>".i18n('Report Options')."</h3></td></tr>";
} else {
echo "<tr><td colspan=\"2\">".i18n('This report is NOT in your \'My Reports\' list.')."</td></tr>";
}
$format = $report['options']['type'];
$stock = $report['options']['stock'];
$conferences_id = $conference['id'];
echo "</table>";
echo '<hr />';
echo "<h3>".i18n('Report Options')."</h3>";
/* Out of all the report optoins, we really only want these ones */
$option_keys = array('type','stock');
foreach($report_options as $ok=>$o) {
if(!in_array($ok, $option_keys)) continue;
echo "<tr><td><b>{$o['desc']}</b>:</td>";
echo '<form method=\"get\" action="reports_gen.php">';
echo "<input type=\"hidden\" name=\"id\" value=\"$id\">";
echo "<table class=\"tableedit\">";
$format = $report['options']['type'];
$stock = $report['options']['stock'];
$year = $config['FAIRYEAR'];
/* Out of all the report optoins, we really only want these ones */
$option_keys = array('type','stock');
foreach($report_options as $ok=>$o) {
if(!in_array($ok, $option_keys)) continue;
echo "<tr><td><b>{$o['desc']}</b>:</td>";
echo "<td><select name=\"$ok\" id=\"$ok\">";
foreach($o['values'] as $k=>$v) {
$sel = ($report['option'][$ok] == $k) ? 'selected="selected"' : '';
$sel = ($report['option'][$ok] == $k) ? 'selected=\"selected\"' : '';
echo "<option value=\"$k\" $sel>$v</option>";
}
echo "</select></td></tr>";
}
}
/* Find all the years */
$q = mysql_query("SELECT DISTINCT year FROM config WHERE year>1000");
echo "<tr><td><b>".i18n('Year')."</b>:</td>";
echo "<td><select name=\"year\" id=\"year\">";
while($i = mysql_fetch_assoc($q)) {
$y = $i['year'];
$sel = ($config['FAIRYEAR'] == $y) ? 'selected=\"selected\"' : '';
echo "<option value=\"$y\" $sel>$y</option>";
}
echo "</select></td></tr>";
// Find all conferences
$q = mysql_query("SELECT conferences.name, conferences.id, dates.date FROM conferences JOIN dates on dates.conferences_id = conferences.id WHERE dates.name='fairdate' ORDER BY dates.date DESC");
echo "<tr><td class=\"label\"><b>".i18n('Conference')."</b>:</td>";
echo "<td class=\"input\"><select name=\"conferences_id\" id=\"conferences_id\">";
while($row = mysql_fetch_assoc($q)){
$parts = explode(' ', $row['date']);
$date = $parts[0];
$sel = ($row['id'] == $conferences_id) ? 'selected="selected"' : '';
echo "<option value=\"{$row['id']}\" $sel>{$row['name']} ($date)</option>";
}
echo "</select></td></tr>\n";
echo "</table>";
echo "</table>";
echo '<br />';
echo "<input type=\"submit\" value=\"".i18n('Generate Report')."\" />";
echo '</form>';
send_footer();
echo '<br />';
echo "<input type=\"submit\" value=\"".i18n('Generate Report')."\" />";
echo '</form>';
send_footer();
?>

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
require("../lpdf.php");
require("../lcsv.php");
require("../questions.inc.php");
@ -36,7 +36,7 @@ if($type=="pdf")
{
$rep=new lpdf( i18n($config['fairname']),
i18n("Judge List"),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif"
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
);
$rep->newPage();
@ -48,9 +48,7 @@ else if($type=="csv")
}
$table=array();
$table['header']=array(
i18n("ID"),
i18n("Unique ID"),
$table['header']=array( i18n("ID"),
i18n("Last Name"),
i18n("First Name"),
i18n("Email"),
@ -70,7 +68,7 @@ $table['header']=array(
i18n("Expertise Other"));
/* Append headers for all the custom questions */
$qs=questions_load_questions('judgereg', $conference['id']);
$qs=questions_load_questions('judgereg', $config['FAIRYEAR']);
$keys = array_keys($qs);
foreach($keys as $qid) {
$table['header'][] = i18n($qs[$qid]['db_heading']);
@ -78,7 +76,7 @@ foreach($keys as $qid) {
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' ORDER BY id");
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
$numcats=mysql_num_rows($q);
$catheadings=array();
while($r=mysql_fetch_object($q))
@ -87,7 +85,7 @@ while($r=mysql_fetch_object($q))
$catheadings[]="$r->category (out of 5)";
}
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='".$conference['id']."' ORDER BY id");
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
$divheadings=array();
while($r=mysql_fetch_object($q))
{
@ -105,46 +103,99 @@ $table['widths']=array();
$table['dataalign']=array();
$q=mysql_query("SELECT
users.*
judges.*
FROM
users
JOIN user_roles ON user_roles.users_id = users.id
JOIN roles ON roles.id = user_roles.roles_id
WHERE
roles.type = 'judge' AND
users.deleted='no' AND
users.conferences_id='".$conference['id']."'
judges,
judges_years
WHERE
judges.complete='yes' AND
judges_years.year='".$config['FAIRYEAR']."' AND
judges.id=judges_years.judges_id
ORDER BY
lastname,
firstname");
echo mysql_error();
while($r=mysql_fetch_object($q)) {
$u=user_load($r->id);
while($r=mysql_fetch_object($q))
{
$expertise_other=str_replace("\n"," ",$r->expertise_other);
$expertise_other=str_replace("\r","",$expertise_other);
$subdivq=mysql_query("SELECT judges_expertise.*,
projectsubdivisions.subdivision,
projectsubdivisions.projectdivisions_id AS parent_id
FROM judges_expertise
LEFT JOIN projectsubdivisions ON judges_expertise.projectsubdivisions_id=projectsubdivisions.id
WHERE
judges_id='$r->id' AND
judges_expertise.year='".$config['FAIRYEAR']."'
ORDER BY
projectdivisions_id,
projectsubdivisions_id");
if(isset($judge_divs)) unset($judge_divs); $judge_divs=array();
if(isset($judge_subdivs)) unset($judge_subdivs); $judge_subdivs=array();
if(isset($divdata)) unset($divdata); $divdata=array();
if(isset($catdata)) unset($catdata); $catdata=array();
while($subdivr=mysql_fetch_object($subdivq))
{
if($subdivr->projectdivisions_id)
{
$judge_divs[$subdivr->projectdivisions_id]=$subdivr->val;
}
else
$judge_subdivs[$subdivr->parent_id][]=$subdivr->subdivision;
}
foreach($divs as $div)
{
$divdata[]=$judge_divs[$div];
if(count($judge_subdivs[$div]))
$divdata[]=implode(",",$judge_subdivs[$div]);
else
$divdata[]="";
}
$catprefq=mysql_query("SELECT judges_catpref.rank, projectcategories.category
FROM judges_catpref,
projectcategories
WHERE
projectcategories.year='".$config['FAIRYEAR']."' AND
judges_catpref.year='".$config['FAIRYEAR']."' AND
judges_catpref.judges_id='".$r->id."' AND
judges_catpref.projectcategories_id=projectcategories.id
ORDER BY
judges_catpref.projectcategories_id");
if(mysql_num_rows($catprefq)!=$numcats)
{
//somethings messed up, we're missing data or have too much, so we really cant draw any conclusions from the data we have
//so instead, we will simply blank these out to 0
for($x=0;$x<$numcats;$x++)
$catdata[]=0;
}
else
{
while($cr=mysql_fetch_object($catprefq))
{
//this is stored in teh db as -2 ... +2 so if we add 2 we get a nice 0 ... 5
$catdata[]=$cr->rank+2;
}
}
$languages="";
foreach($u['cat_prefs'] AS $c) {
$catdata[]=$c+2;
}
foreach($u['div_prefs'] AS $d) {
$divdata[]=$d;
//FIXME: 2010-01-22 - James - get the sub divisions for now we use a placeholder
$divdata[]="";
}
foreach($u['languages'] AS $k=>$v) {
$languages.="$v/";
}
//and finally, grab their languages
$langq=mysql_query("SELECT * FROM judges_languages WHERE judges_id='".$r->id."' ORDER BY languages_lang");
while($langr=mysql_fetch_object($langq))
$languages.=$langr->languages_lang."/";
//stip off the last /
$languages=substr($languages,0,-1);
// print_r($judge_divs);
// print_r($judge_subdivs);
$qarray = array();
$qans = questions_load_answers('judgereg', $r->id, $conference['id']);
$qans = questions_load_answers('judgereg', $r->id, $config['FAIRYEAR']);
$keys = array_keys($qans);
foreach($keys as $qid) {
$qarray[] = $qans[$qid];
@ -152,7 +203,6 @@ while($r=mysql_fetch_object($q)) {
$tmp=array(
$r->id,
$r->uid,
$r->lastname,
$r->firstname,
$r->email,

View File

@ -1,185 +0,0 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
require("../lpdf.php");
require("../lcsv.php");
require("../questions.inc.php");
if(!$_GET['type']) $type="csv";
else $type=$_GET['type'];
if($type=="pdf")
{
$rep=new lpdf( i18n($config['fairname']),
i18n("Judge List"),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
);
$rep->newPage();
$rep->setFontSize(11);
}
else if($type=="csv")
{
$rep=new lcsv(i18n("Judge List"));
}
$table=array();
$table['header']=array(
i18n("ID"),
i18n("Unique ID"),
i18n("Year"),
i18n("Last Name"),
i18n("First Name"),
i18n("Email"),
i18n("Phone Home"),
i18n("Phone Work"),
i18n("Phone Work Ext"),
i18n("Phone Cell"),
i18n("Languages"),
i18n("Organization"),
i18n("Address 1"),
i18n("Address 2"),
i18n("City"),
i18n($config['provincestate']),
i18n($config['postalzip']),
i18n("Highest PostSecDeg"),
i18n("Professional Quals"),
i18n("Expertise Other"));
/* Append headers for all the custom questions */
$qs=questions_load_questions('judgereg', $config['FAIRYEAR']);
$keys = array_keys($qs);
foreach($keys as $qid) {
$table['header'][] = i18n($qs[$qid]['db_heading']);
}
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
$numcats=mysql_num_rows($q);
$catheadings=array();
while($r=mysql_fetch_object($q))
{
$cats[]=$r->id;
$catheadings[]="$r->category (out of 5)";
}
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
$divheadings=array();
while($r=mysql_fetch_object($q))
{
$divs[]=$r->id;
$divheadings[]="$r->division (out of 5)";
$divheadings[]="$r->division subdivisions";
}
//now append the arrays together
$table['header']=array_merge($table['header'],array_merge($catheadings,$divheadings));
//fill these in if we ever make this PDFable
$table['widths']=array();
$table['dataalign']=array();
$q=mysql_query("SELECT
users.*,
users_judge.*
FROM
users
JOIN users_judge ON users.id=users_judge.users_id
WHERE
users.deleted='no'
AND users.types LIKE '%judge%'
ORDER BY
lastname,
firstname,
year");
echo mysql_error();
while($r=mysql_fetch_object($q)) {
$u=user_load($r->id);
$expertise_other=str_replace("\n"," ",$r->expertise_other);
$expertise_other=str_replace("\r","",$expertise_other);
if(isset($divdata)) unset($divdata); $divdata=array();
if(isset($catdata)) unset($catdata); $catdata=array();
$languages="";
foreach($u['cat_prefs'] AS $c) {
$catdata[]=$c+2;
}
foreach($u['div_prefs'] AS $d) {
$divdata[]=$d;
//FIXME: 2010-01-22 - James - get the sub divisions for now we use a placeholder
$divdata[]="";
}
foreach($u['languages'] AS $k=>$v) {
$languages.="$v/";
}
$languages=substr($languages,0,-1);
$qarray = array();
$qans = questions_load_answers('judgereg', $r->id, $config['FAIRYEAR']);
$keys = array_keys($qans);
foreach($keys as $qid) {
$qarray[] = $qans[$qid];
}
$tmp=array(
$r->id,
$r->uid,
$r->year,
$r->lastname,
$r->firstname,
$r->email,
$r->phonehome,
$r->phonework,
$r->phoneworkext,
$r->phonecell,
$languages,
$r->organization,
$r->address,
$r->address2,
$r->city,
$r->province,
$r->postalcode,
$r->highest_psd,
$r->professional_quals,
$expertise_other
);
$tmp = array_merge($tmp, $qarray);
$extradata=array_merge($catdata,$divdata);
$table['data'][]=array_merge($tmp,$extradata);
}
$rep->addTable($table);
$rep->output();
?>

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
require("../lpdf.php");
require("../lcsv.php");
require("judges.inc.php");
@ -36,7 +36,7 @@
$rep=new lpdf( i18n($config['fairname']),
i18n("Judging Team Project Assignments"),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif"
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
);
$rep->newPage();
@ -49,7 +49,7 @@
$teams=getJudgingTeams();
$q=mysql_query("SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE conferences_id='".$conference['id']."'");
$q=mysql_query("SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q)>1)
$show_date=true;
else
@ -60,7 +60,7 @@
$table=array();
$table['header']=array(i18n("Timeslot"),i18n("Proj #"),i18n("Project Title"));
if($show_date)
$table['widths']=array( 2.25, 0.75, 4.00);
$table['widths']=array( 2.0, 0.75, 4.25);
else
$table['widths']=array( 1.5, 0.75, 4.75);
@ -91,7 +91,7 @@
$rep->addText(i18n("Criteria").": ".$award['criteria']);
//get category eligibility
$q=mysql_query("SELECT projectcategories.category FROM projectcategories, award_awards_projectcategories WHERE award_awards_projectcategories.projectcategories_id=projectcategories.id AND award_awards_projectcategories.award_awards_id='{$award['id']}' AND award_awards_projectcategories.conferences_id='{$conference['id']}' AND projectcategories.conferences_id='{$conference['id']}' ORDER BY category");
$q=mysql_query("SELECT projectcategories.category FROM projectcategories, award_awards_projectcategories WHERE award_awards_projectcategories.projectcategories_id=projectcategories.id AND award_awards_projectcategories.award_awards_id='{$award['id']}' AND award_awards_projectcategories.year='{$config['FAIRYEAR']}' AND projectcategories.year='{$config['FAIRYEAR']}' ORDER BY category");
echo mysql_error();
$cats="";
while($r=mysql_fetch_object($q))
@ -103,7 +103,7 @@
//get division eligibility
$q=mysql_query("SELECT projectdivisions.division_shortform FROM projectdivisions, award_awards_projectdivisions WHERE award_awards_projectdivisions.projectdivisions_id=projectdivisions.id AND award_awards_projectdivisions.award_awards_id='{$award['id']}' AND award_awards_projectdivisions.conferences_id='{$conference['id']}' AND projectdivisions.conferences_id='{$conference['id']}' ORDER BY division_shortform");
$q=mysql_query("SELECT projectdivisions.division_shortform FROM projectdivisions, award_awards_projectdivisions WHERE award_awards_projectdivisions.projectdivisions_id=projectdivisions.id AND award_awards_projectdivisions.award_awards_id='{$award['id']}' AND award_awards_projectdivisions.year='{$config['FAIRYEAR']}' AND projectdivisions.year='{$config['FAIRYEAR']}' ORDER BY division_shortform");
echo mysql_error();
$divs="";
while($r=mysql_fetch_object($q))
@ -143,7 +143,7 @@
$timeslot=$r->date." ";
else
$timeslot="";
$timeslot.=format_time($r->starttime)." - ".format_time($r->endtime);
$timeslot.=substr($r->starttime,0,-3)." - ".substr($r->endtime,0,-3);
$projq=mysql_query("SELECT
projects.projectnumber,
@ -156,7 +156,7 @@
judges_teams_timeslots_projects_link.judges_timeslots_id='$r->id' AND
judges_teams_timeslots_projects_link.judges_teams_id='".$team['id']."' AND
judges_teams_timeslots_projects_link.projects_id=projects.id AND
judges_teams_timeslots_projects_link.conferences_id='".$conference['id']."'
judges_teams_timeslots_projects_link.year='".$config['FAIRYEAR']."'
ORDER BY
projectnumber
");

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
send_header("Mailing Label Generator",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
require("../lpdf.php");
require("../lcsv.php");
@ -49,9 +49,9 @@ if($report)
if($_GET['fontsize']) $fontsize=$_GET['fontsize'];
if($_GET['toppadding']) $toppadding=$_GET['toppadding'];
$rep=new lpdf( i18n($conference['name']),
$rep=new lpdf( i18n($config['fairname']),
"$reportname Mailing Labels",
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif"
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
);
$rep->setPageStyle("labels");
@ -77,7 +77,7 @@ if($report)
FROM
schools
WHERE
conferences_id='{$conference['id']}'
year='{$config['FAIRYEAR']}'
ORDER BY
school
");
@ -107,26 +107,25 @@ if($report)
break;
case "judges":
$q = mysql_query("
SELECT
CONCAT(users.firstname, ' ', users.lastname) AS name,
IF(users.address2=\"\",
users.address,
CONCAT(users.address,' ',users.address2)
) AS address,
'' AS co,
users.city AS city,
users.province AS province,
users.postalcode AS postalcode
FROM users
JOIN user_roles ON users.id = user_roles.users_id
JOIN roles ON roles.id = user_roles.roles_id
WHERE
roles.type = 'judge'
AND users.conferences_id='{$conference['id']}'
ORDER BY
firstname, lastname
");
$q=mysql_query("SELECT
CONCAT(judges.firstname,' ',judges.lastname) AS name,
IF(judges.address2=\"\",
judges.address,
CONCAT(judges.address,' ',judges.address2)
) AS address,
'' AS co,
judges.city AS city,
judges.province AS province,
judges.postalcode AS postalcode
FROM
judges,
judges_years
WHERE
judges_years.judges_id=judges.id
AND judges_years.year='{$config['FAIRYEAR']}'
ORDER BY
lastname,firstname
");
break;
}

View File

@ -25,7 +25,7 @@
require("../common.inc.php");
require_once("../user.inc.php");
require_once('reports.inc.php');
user_auth_required('admin');
user_auth_required('committee', 'admin');
send_header("Reports",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php')

View File

@ -1,7 +1,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
require("../lpdf.php");
require("../lcsv.php");
@ -13,7 +13,7 @@
$rep=new lpdf( i18n($config['fairname']),
i18n("Program Awards"),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif"
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
);
$rep->newPage();
@ -34,8 +34,8 @@
award_awards,
award_types
WHERE
award_awards.conferences_id='".$conference['id']."'
AND award_types.conferences_id='".$conference['id']."'
award_awards.year='".$config['FAIRYEAR']."'
AND award_types.year='".$config['FAIRYEAR']."'
AND award_awards.award_types_id=award_types.id
AND award_awards.excludefromac='0'
AND (award_types.type='special' OR award_types.type='grand')
@ -50,7 +50,7 @@
$rep->heading(i18n($r->name));
//get teh age categories
$acq=mysql_query("SELECT projectcategories.category FROM projectcategories, award_awards_projectcategories WHERE projectcategories.conferences_id='".$conference['id']."' AND award_awards_projectcategories.conferences_id='".$conference['id']."' AND award_awards_projectcategories.award_awards_id='$r->id' AND award_awards_projectcategories.projectcategories_id=projectcategories.id ORDER BY projectcategories.id");
$acq=mysql_query("SELECT projectcategories.category FROM projectcategories, award_awards_projectcategories WHERE projectcategories.year='".$config['FAIRYEAR']."' AND award_awards_projectcategories.year='".$config['FAIRYEAR']."' AND award_awards_projectcategories.award_awards_id='$r->id' AND award_awards_projectcategories.projectcategories_id=projectcategories.id ORDER BY projectcategories.id");
echo mysql_error();
$cats="";
while($acr=mysql_fetch_object($acq))
@ -70,7 +70,7 @@
award_prizes
WHERE
award_awards_id='$r->id'
AND award_prizes.conferences_id='".$conference['id']."'
AND award_prizes.year='".$config['FAIRYEAR']."'
AND award_prizes.excludefromac='0'
ORDER BY
`order`");

View File

@ -24,18 +24,19 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
require("../lpdf.php");
require("../lcsv.php");
require("judges.inc.php");
$type=$_GET['type'];
if($type=="pdf") {
if($type=="pdf")
{
$rep=new lpdf( i18n($config['fairname']),
i18n("Project Details"),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif"
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
);
$rep->newPage();
@ -46,9 +47,6 @@
$rep=new lcsv(i18n("Project Details"));
}
// $regstatus=" AND ( registrations.status='complete' OR registrations.status='paymentpending' ) ";
$regstatus="";
$projq=mysql_query("SELECT
registrations.id AS reg_id,
registrations.num AS reg_num,
@ -71,10 +69,11 @@ $regstatus="";
LEFT JOIN projectcategories ON projectcategories.id=projects.projectcategories_id
WHERE
projects.conferences_id='".$conference['id']."'
AND projectdivisions.conferences_id='".$conference['id']."'
AND projectcategories.conferences_id='".$conference['id']."'
$regstatus
projects.year='".$config['FAIRYEAR']."'
AND projectdivisions.year='".$config['FAIRYEAR']."'
AND projectcategories.year='".$config['FAIRYEAR']."'
AND ( registrations.status='complete'
OR registrations.status='paymentpending' )
ORDER BY
projects.projectnumber
");
@ -86,12 +85,12 @@ $regstatus="";
while($proj=mysql_fetch_object($projq))
{
$projectcount++;
$sq=mysql_query("SELECT users.firstname,
users.lastname
$sq=mysql_query("SELECT students.firstname,
students.lastname
FROM
users
students
WHERE
users.registrations_id='$proj->reg_id'
students.registrations_id='$proj->reg_id'
");
$students="";
@ -103,6 +102,7 @@ $regstatus="";
$studnum++;
}
$rep->heading(i18n("Project Information"));
$rep->nextline();
$table=array();
// $table['header']=array(i18n("Timeslot"),i18n("Judging Team"));
@ -121,43 +121,27 @@ $regstatus="";
unset($table);
$q=mysql_query("SELECT * FROM mentors WHERE registrations_id='".$proj->reg_id."'");
$rep->nextline();
$rep->heading(i18n("Mentor Information"));
if(mysql_num_rows($q)) {
while($r=mysql_fetch_object($q))
{
$rep->addText(i18n("%1 %2 from %3",array($r->firstname,$r->lastname,$r->organization)));
$rep->addText(i18n("Phone: %1 Email: %2",array($r->phone,$r->email)));
}
$rep->nextline();
if(mysql_num_rows($q))
{
while($r=mysql_fetch_object($q))
{
$rep->addText(i18n("%1 %2 from %3",array($r->firstname,$r->lastname,$r->organization)));
$rep->addText(i18n("Phone: %1 Email: %2",array($r->phone,$r->email)));
}
else {
}
else
{
$rep->addText(i18n("No mentors"));
}
$rep->nextline();
$rep->heading(i18n("Project Summary"));
$rep->addText($proj->summary);
$q=mysql_query("SELECT safetyquestions.question,
safety.answer
FROM safetyquestions
JOIN safety ON safetyquestions.id=safety.safetyquestions_id
WHERE safety.registrations_id='".$proj->reg_id."'
ORDER BY safetyquestions.ord");
$rep->nextline();
$rep->heading(i18n("Safety Questions"));
$table=array();
// $table['header']=array(i18n("Timeslot"),i18n("Judging Team"));
$table['widths']=array( 6.25, 0.5);
$table['dataalign']=array("left","left");
while($r=mysql_fetch_object($q)) {
$table['data'][]=array(i18n($r->question),$r->answer);
}
$rep->addTable($table);
unset($table);
$rep->addText($proj->summary);
if($projectcount!=$totalprojects)
$rep->newPage();

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('admin');
user_auth_required('committee', 'admin');
require("../lpdf.php");
require("../lcsv.php");
require("judges.inc.php");
@ -36,7 +36,7 @@
$rep=new lpdf( i18n($config['fairname']),
i18n("Project Judging Team Assignments"),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif"
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
);
$rep->newPage();
@ -49,7 +49,7 @@
$teams=getJudgingTeams();
$q=mysql_query("SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE conferences_id='".$conference['id']."'");
$q=mysql_query("SELECT DISTINCT(date) AS d FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q)>1)
$show_date=true;
else
@ -73,9 +73,9 @@
LEFT JOIN projectcategories ON projectcategories.id=projects.projectcategories_id
WHERE
projects.conferences_id='".$conference['id']."'
AND projectdivisions.conferences_id='".$conference['id']."'
AND projectcategories.conferences_id='".$conference['id']."'
projects.year='".$config['FAIRYEAR']."'
AND projectdivisions.year='".$config['FAIRYEAR']."'
AND projectcategories.year='".$config['FAIRYEAR']."'
AND ( registrations.status='complete'
OR registrations.status='paymentpending' )
ORDER BY
@ -110,7 +110,7 @@
$table=array();
$table['header']=array(i18n("Timeslot"),i18n("Judging Team"));
if($show_date)
$table['widths']=array( 2.25, 4.75);
$table['widths']=array( 2.0, 5.00);
else
$table['widths']=array( 1.5, 5.50);
@ -128,7 +128,7 @@
LEFT JOIN judges_teams ON judges_teams_timeslots_projects_link.judges_teams_id=judges_teams.id
WHERE
judges_teams_timeslots_projects_link.projects_id='$proj->id'
AND judges_teams_timeslots_projects_link.conferences_id='".$conference['id']."'
AND judges_teams_timeslots_projects_link.year='".$config['FAIRYEAR']."'
ORDER BY
date,starttime
");
@ -137,10 +137,10 @@
while($r=mysql_fetch_object($q))
{
if($show_date)
$timeslot=format_date($r->date)." ";
$timeslot=$r->date." ";
else
$timeslot="";
$timeslot.=format_time($r->starttime)." - ".format_time($r->endtime);
$timeslot.=substr($r->starttime,0,-3)." - ".substr($r->endtime,0,-3);
$table['data'][]=array($timeslot, $r->name);
}

Some files were not shown because too many files have changed in this diff Show More