diff --git a/admin/donors.php b/admin/donors.php
index cd81595..5d1cdd7 100644
--- a/admin/donors.php
+++ b/admin/donors.php
@@ -13,7 +13,7 @@
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.
+ 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
@@ -27,74 +27,72 @@
user_auth_required('committee', 'admin');
switch($_GET['action']) {
- case 'organizationinfo_load':
- $id=intval($_GET['id']);
- $q=mysql_query("SELECT * FROM sponsors WHERE id='$id'");
- $ret=mysql_fetch_assoc($q);
- echo json_encode($ret);
- exit;
- break;
+ case 'organizationinfo_load':
+ $id=intval($_GET['id']);
+ $q=mysql_query("SELECT * FROM sponsors WHERE id='$id'");
+ $ret=mysql_fetch_assoc($q);
+ echo json_encode($ret);
+ exit;
+ break;
- case 'organizationinfo_save':
- $id=intval($_POST['sponsor_id']);
- if($id==-1) {
+ case 'organizationinfo_save':
+ $id=intval($_POST['sponsor_id']);
+ if($id==-1) {
$q=mysql_query("INSERT INTO sponsors (year) VALUES ('".$config['FAIRYEAR']."')");
$id=mysql_insert_id();
- echo json_encode(array("id"=>$id));
- }
+ echo json_encode(array("id"=>$id));
+ }
- if($id) {
- $exec="UPDATE sponsors SET ".
- "organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ".
- "address='".mysql_escape_string(stripslashes($_POST['address']))."', ".
- "city='".mysql_escape_string(stripslashes($_POST['city']))."', ".
- "province_code='".mysql_escape_string(stripslashes($_POST['province_code']))."', ".
- "postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."', ".
- "phone='".mysql_escape_string(stripslashes($_POST['phone']))."', ".
- "tollfree='".mysql_escape_string(stripslashes($_POST['tollfree']))."', ".
- "fax='".mysql_escape_string(stripslashes($_POST['fax']))."', ".
- "email='".mysql_escape_string(stripslashes($_POST['email']))."', ".
- "website='".mysql_escape_string(stripslashes($_POST['website']))."', ".
- "notes='".mysql_escape_string(stripslashes($_POST['notes']))."', ".
- "donationpolicyurl='".mysql_escape_string(stripslashes($_POST['donationpolicyurl']))."', ".
- "fundingselectiondate='".mysql_escape_string(stripslashes($_POST['fundingselectiondate']))."', ".
- "waiveraccepted='".mysql_escape_string(stripslashes($_POST['waiveraccepted']))."', ".
- "taxreceiptrequired='".mysql_escape_string(stripslashes($_POST['taxreceiptrequired']))."' ".
- "WHERE id='$id'";
- mysql_query($exec);
+ if($id) {
+ $exec="UPDATE sponsors SET ".
+ "organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ".
+ "address='".mysql_escape_string(stripslashes($_POST['address']))."', ".
+ "city='".mysql_escape_string(stripslashes($_POST['city']))."', ".
+ "province_code='".mysql_escape_string(stripslashes($_POST['province_code']))."', ".
+ "postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."', ".
+ "phone='".mysql_escape_string(stripslashes($_POST['phone']))."', ".
+ "tollfree='".mysql_escape_string(stripslashes($_POST['tollfree']))."', ".
+ "fax='".mysql_escape_string(stripslashes($_POST['fax']))."', ".
+ "email='".mysql_escape_string(stripslashes($_POST['email']))."', ".
+ "website='".mysql_escape_string(stripslashes($_POST['website']))."', ".
+ "notes='".mysql_escape_string(stripslashes($_POST['notes']))."', ".
+ "donationpolicyurl='".mysql_escape_string(stripslashes($_POST['donationpolicyurl']))."', ".
+ "fundingselectiondate='".mysql_escape_string(stripslashes($_POST['fundingselectiondate']))."', ".
+ "waiveraccepted='".mysql_escape_string(stripslashes($_POST['waiveraccepted']))."', ".
+ "taxreceiptrequired='".mysql_escape_string(stripslashes($_POST['taxreceiptrequired']))."' ".
+ "WHERE id='$id'";
+ mysql_query($exec);
- //FIXME accept the logo
- //"logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ".
+ //FIXME accept the logo
+ //"logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ".
- }
- exit;
- break;
+ }
+ exit;
+ break;
- case 'sponsorshipinfo_load':
- $id=intval($_GET['id']);
- $ret=array();
- echo json_encode($ret);
- exit;
- break;
-
- case 'contactsinfo_load':
- // make sure a donor id has been selected
- if($_GET['id']){
-// $sql = "SELECT
- draw_contactsinfo_form();
- }
- exit;
- break;
+ case 'sponsorshipinfo_load':
+ $id=intval($_GET['id']);
+ $ret=array();
+ echo json_encode($ret);
+ exit;
+ break;
+
+ case 'contactsinfo_load':
+ // make sure a donor id has been selected
+ if($_GET['id']){
+ draw_contactsinfo_form();
+ }
+ exit;
+ break;
- case 'contactsinfo_save':
- save_contact();
-
-// draw_contactsinfo_form();
- exit;
- break;
- case 'contactsinfo_delete':
- delete_contact();
- break;
+ case 'contactsinfo_save':
+ save_contact();
+ exit;
+ break;
+ case 'contactsinfo_delete':
+ delete_contact();
+ exit;
+ break;
}
send_header("Donor/Sponsor Management",
@@ -103,9 +101,13 @@
'Fundraising' => 'admin/fundraising.php')
);
-// #FIXME should delete the contact who has been submitted in _POST
+//delete the contact who has been submitted in _POST
function delete_contact(){
- error_("Not Implemented");
+ if(array_key_exists('userid', $_POST)){
+ $uid = $_POST['userid'];
+ user_delete($uid);
+ happy_("User with ID #" . $uid . " deleted");
+ }
}
// save the contact info
@@ -123,7 +125,7 @@ function save_contact(){
}else if($_POST['recordtype'] == 'existing'){
// this is an existing record being updated. Load the user.
- $successMessage = i18n("Contact updated successfully: " . $_POST['userid']);
+ $successMessage = i18n("Contact updated successfully");
$u = user_load($_POST['userid']);
$id = intval($_POST['userid']);
@@ -135,13 +137,13 @@ function save_contact(){
if($p == 'no') {
/* Make sure this sponsor ($sponsor_id) has a primary */
$query = "SELECT users_id
- FROM users_sponsor, users
- WHERE
- users_sponsor.users_id=users.id
- AND sponsors_id='$sponsor_id'
- AND `primary`='yes'
- AND year='".$config['FAIRYEAR']."'
- AND users_id!='$id'";
+ FROM users_sponsor, users
+ WHERE
+ users_sponsor.users_id=users.id
+ AND sponsors_id='$sponsor_id'
+ AND `primary`='yes'
+ AND year='".$config['FAIRYEAR']."'
+ AND users_id!='$id'";
$q = mysql_query($query);
if(mysql_num_rows($q) == 0) {
/* This has to be the primary since there isn't one already */
@@ -216,7 +218,8 @@ function draw_contactsinfo_form($contact = null){
WHERE year='" . $config['FAIRYEAR'] . "'
AND sponsors_id='" . $sponsor_id . "'
AND deleted='no'
- ORDER BY lastname,firstname");
+ ORDER BY users_sponsor.primary DESC,lastname,firstname");
+
while($contact = mysql_fetch_array($query)){
// draw a header for this user
echo "
+
+
@@ -286,159 +310,169 @@ function draw_contact_form($sponsor_id, $contact = null){
/* Setup the popup window */
$(document).ready(function() {
/*`
- $("#open_editor").dialog({
- bgiframe: true, autoOpen: false,
- modal: true, resizable: false,
- draggable: false
- });
+ $("#open_editor").dialog({
+ bgiframe: true, autoOpen: false,
+ modal: true, resizable: false,
+ draggable: false
+ });
*/
- $("#editor_tabs").tabs({
- show: function(event, ui) {
- switch(ui.panel.id) {
- case 'editor_tab_organization':
- update_organizationinfo();
- break;
- case 'editor_tab_sponsorship':
- update_sponsorshipinfo();
- break;
- case 'editor_tab_contacts':
- update_contactsinfo();
- break;
- case 'editor_tab_activity':
- update_activityinfo();
- break;
- }
- },
- selected: 0,
- });
+ $("#editor_tabs").tabs({
+ show: function(event, ui) {
+ switch(ui.panel.id) {
+ case 'editor_tab_organization':
+ update_organizationinfo();
+ break;
+ case 'editor_tab_sponsorship':
+ update_sponsorshipinfo();
+ break;
+ case 'editor_tab_contacts':
+ update_contactsinfo();
+ break;
+ case 'editor_tab_activity':
+ update_activityinfo();
+ break;
+ }
+ },
+ selected: 0,
+ });
- $("#organizationinfo_fundingselectiondate").datepicker({ dateFormat: 'yy-mm-dd', showOn: 'button', buttonText: "=i18n("calendar")?>" });
+ $("#organizationinfo_fundingselectiondate").datepicker({ dateFormat: 'yy-mm-dd', showOn: 'button', buttonText: "=i18n("calendar")?>" });
});
var sponsor_id=0;
function open_editor(id) {
- sponsor_id=id;
- $("#donor_editor").show();
- $("#searchbrowse").hide();
- $("#searchresults").hide();
+ sponsor_id=id;
+ $("#donor_editor").show();
+ $("#searchbrowse").hide();
+ $("#searchresults").hide();
- if(id==-1) {
- $('#editor_tabs').tabs('option', 'selected', 0);
- $('#editor_tabs').tabs('option', 'disabled', [1,2,3]);
+ if(id==-1) {
+ $('#editor_tabs').tabs('option', 'selected', 0);
+ $('#editor_tabs').tabs('option', 'disabled', [1,2,3]);
- }
- else {
- $('#editor_tabs').tabs('option', 'selected', 0);
- $('#editor_tabs').tabs('option', 'disabled', []);
- }
+ }
+ else {
+ $('#editor_tabs').tabs('option', 'selected', 0);
+ $('#editor_tabs').tabs('option', 'disabled', []);
+ }
- update_organizationinfo();
- return false;
+ update_organizationinfo();
+ return false;
}
function open_search() {
- $("#donor_editor").hide();
- $("#searchbrowse").show();
+ $("#donor_editor").hide();
+ $("#searchbrowse").show();
}
function update_organizationinfo()
{
- var id=sponsor_id;
- if(!sponsor_id)
- return false;
- if(sponsor_id==-1) {
- $("#sponsor_id").val(-1);
- return false;
- }
+ var id=sponsor_id;
+ if(!sponsor_id)
+ return false;
+ if(sponsor_id==-1) {
+ $("#sponsor_id").val(-1);
+ return false;
+ }
- $.getJSON("=$_SERVER['PHP_SELF']?>?action=organizationinfo_load&id="+id,
- function(json){
- $("#sponsor_id").val(json.id);
- $("#organizationinfo_organization").val(json.organization);
- $("#organizationinfo_address").val(json.address);
- $("#organizationinfo_city").val(json.city);
- $("#organizationinfo_province_code").val(json.province_code);
- $("#organizationinfo_postalcodd").val(json.postalcode);
- $("#organizationinfo_phone").val(json.phone);
- $("#organizationinfo_tollfree").val(json.tollfree);
- $("#organizationinfo_fax").val(json.fax);
- $("#organizationinfo_email").val(json.email);
- $("#organizationinfo_website").val(json.website);
- $("#organizationinfo_donationpolicyurl").val(json.donationpolicyurl);
- $("#organizationinfo_fundingselectiondate").val(json.fundingselectiondate);
- $("#organizationinfo_notes").val(json.notes);
- // For some reason, with checkboxes, these have to be arrays
- $("[name=waiveraccepted]").val([json.waiveraccepted]);
- $("[name=taxreceiptrequired]").val([json.taxreceiptrequired]);
- });
+ $.getJSON("=$_SERVER['PHP_SELF']?>?action=organizationinfo_load&id="+id,
+ function(json){
+ $("#sponsor_id").val(json.id);
+ $("#organizationinfo_organization").val(json.organization);
+ $("#organizationinfo_address").val(json.address);
+ $("#organizationinfo_city").val(json.city);
+ $("#organizationinfo_province_code").val(json.province_code);
+ $("#organizationinfo_postalcodd").val(json.postalcode);
+ $("#organizationinfo_phone").val(json.phone);
+ $("#organizationinfo_tollfree").val(json.tollfree);
+ $("#organizationinfo_fax").val(json.fax);
+ $("#organizationinfo_email").val(json.email);
+ $("#organizationinfo_website").val(json.website);
+ $("#organizationinfo_donationpolicyurl").val(json.donationpolicyurl);
+ $("#organizationinfo_fundingselectiondate").val(json.fundingselectiondate);
+ $("#organizationinfo_notes").val(json.notes);
+ // For some reason, with checkboxes, these have to be arrays
+ $("[name=waiveraccepted]").val([json.waiveraccepted]);
+ $("[name=taxreceiptrequired]").val([json.taxreceiptrequired]);
+ });
}
function organizationinfo_save() {
- //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($("#sponsor_id").val()==-1) {
- $.post("$_SERVER['PHP_SELF']?>?action=organizationinfo_save", $("#organizationinfo").serializeArray(),
- function(json) {
- open_editor(json.id);
- },
- "json");
- }
- else
- $("#debug").load("$_SERVER['PHP_SELF']?>?action=organizationinfo_save", $("#organizationinfo").serializeArray());
- return false;
+ //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($("#sponsor_id").val()==-1) {
+ $.post("$_SERVER['PHP_SELF']?>?action=organizationinfo_save", $("#organizationinfo").serializeArray(),
+ function(json) {
+ open_editor(json.id);
+ },
+ "json");
+ }
+ else
+ $("#debug").load("$_SERVER['PHP_SELF']?>?action=organizationinfo_save", $("#organizationinfo").serializeArray());
+ return false;
}
function update_sponsorshipinfo()
{
- var id=sponsor_id;
- $.getJSON("=$_SERVER['PHP_SELF']?>?action=sponsorshipinfo_load&id="+id,
- function(json){
- $("#sponsor_id").val(json.id);
- });
+ var id=sponsor_id;
+ $.getJSON("=$_SERVER['PHP_SELF']?>?action=sponsorshipinfo_load&id="+id,
+ function(json){
+ $("#sponsor_id").val(json.id);
+ });
}
function sponsorshipinfo_save() {
- $("#debug").load("$_SERVER['PHP_SELF']?>?action=sponsorshipinfo_save", $("#sponsorshipinfo").serializeArray());
- return false;
+ $("#debug").load("$_SERVER['PHP_SELF']?>?action=sponsorshipinfo_save", $("#sponsorshipinfo").serializeArray());
+ return false;
}
function update_contactsinfo()
{
- var id=sponsor_id;
- $("#editor_tab_contacts").load("=$_SERVER['PHP_SELF']?>?action=contactsinfo_load&id="+id, null,
+ var id=sponsor_id;
+ $("#editor_tab_contacts").load("=$_SERVER['PHP_SELF']?>?action=contactsinfo_load&id="+id, null,
function() {
$("#levelaccordion").accordion();
}
- );
+ );
}
-function contactsinfo_save(id) {
- $("#debug").load("$_SERVER['PHP_SELF']?>?action=contactsinfo_save", $("#contact_" + id).serializeArray());
- return false;
+function contactsinfo_save(uid) {
+ var id=sponsor_id;
+ $("#debug").load("$_SERVER['PHP_SELF']?>?action=contactsinfo_save&id="+id, $("#contact_" + uid).serializeArray(),
+ function() {
+ $("#levelaccordion").accordion();
+ update_contactsinfo();
+ });
+ return false;
}
-function contactsinfo_delete(id) {
- $("#debug").load("$_SERVER['PHP_SELF']?>?action=contactsinfo_delete", $("#contact_" + id).serializeArray());
- return false;
+function contactsinfo_delete(uid) {
+ var id=sponsor_id;
+ $("#debug").load("$_SERVER['PHP_SELF']?>?action=contactsinfo_delete&id="+id, $("#contact_" + uid).serializeArray(),
+ function() {
+ $("#levelaccordion").accordion();
+ update_contactsinfo();
+ });
+ return false;
}
function update_activityinfo()
{
- var id=sponsor_id;
- $.getJSON("=$_SERVER['PHP_SELF']?>?action=activityinfo_load&id="+id,
- function(json){
- $("#sponsor_id").val(json.id);
- });
+ var id=sponsor_id;
+ $.getJSON("=$_SERVER['PHP_SELF']?>?action=activityinfo_load&id="+id,
+ function(json){
+ $("#sponsor_id").val(json.id);
+ });
}
function activityinfo_save() {
- $("#debug").load("$_SERVER['PHP_SELF']?>?action=activityinfo_save", $("#activityinfo").serializeArray());
- return false;
+ $("#debug").load("$_SERVER['PHP_SELF']?>?action=activityinfo_save", $("#activityinfo").serializeArray());
+ return false;
}
function donorsearch() {
@@ -471,61 +505,61 @@ echo "
";
?>
-
-
+
+
-
+
+
+
+
+ activity
+
+