forked from science-ation/science-ation
Updates to donor manager, auto populate individual contacts and disable fields that shouldnt be used for individuals
This commit is contained in:
parent
f6fcb2d728
commit
9a62fbc26d
126
admin/donors.php
126
admin/donors.php
@ -43,10 +43,14 @@ switch($_GET['action']) {
|
||||
$q=mysql_query("INSERT INTO sponsors (year) VALUES ('".$config['FAIRYEAR']."')");
|
||||
$id=mysql_insert_id();
|
||||
echo json_encode(array("id"=>$id));
|
||||
save_activityinfo("Created donor/sponsor", $id, $_SESSION['users_uid'],"System");
|
||||
$createnew=true;
|
||||
}
|
||||
else $createnew=false;
|
||||
|
||||
if($id) {
|
||||
$exec="UPDATE sponsors SET ".
|
||||
"donortype='".mysql_escape_string(stripslashes($_POST['donortype']))."', ".
|
||||
"organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ".
|
||||
"address='".mysql_escape_string(stripslashes($_POST['address']))."', ".
|
||||
"address2='".mysql_escape_string(stripslashes($_POST['address2']))."', ".
|
||||
@ -61,16 +65,17 @@ switch($_GET['action']) {
|
||||
"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']))."' ".
|
||||
"waiveraccepted='".mysql_escape_string(stripslashes($_POST['waiveraccepted']))."' ".
|
||||
"WHERE id='$id'";
|
||||
mysql_query($exec);
|
||||
|
||||
//FIXME accept the logo
|
||||
//"logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ".
|
||||
//($comment , $donorId, $userId, $type, $campaign_id=null){
|
||||
save_activityinfo("Updated donor/sponsor details", $id, $_SESSION['users_uid'],"System");
|
||||
happy_("Donor/Sponsor Details saved");
|
||||
if(!$createnew) {
|
||||
save_activityinfo("Updated donor/sponsor details", $id, $_SESSION['users_uid'],"System");
|
||||
happy_("Donor/Sponsor Details saved");
|
||||
}
|
||||
}
|
||||
exit;
|
||||
break;
|
||||
@ -319,7 +324,7 @@ function delete_contact(){
|
||||
$data = mysql_query("SELECT CONCAT_WS(' ', users.firstname, users.lastname) AS name FROM users WHERE id=" . $uid);
|
||||
$namedata = mysql_fetch_array($data);
|
||||
$name = trim($namedata['name']);
|
||||
user_delete($uid);
|
||||
user_delete($uid,"sponsor");
|
||||
happy_("Deleted contact %1", array($name));
|
||||
|
||||
//($comment , $donorId, $userId, $type, $campaign_id=null){
|
||||
@ -332,12 +337,13 @@ function addexisting_contact() {
|
||||
$sponsors_id=intval($_POST['id']);
|
||||
echo "Linking uid=$uid to sponsors_id=$sponsors_id <br />";
|
||||
|
||||
$u=user_load_by_uid($uid);
|
||||
echo "uid $uid has users.id {$u['id']}";
|
||||
|
||||
$u=user_load_by_uid($uid);
|
||||
$u['sponsors_id']=$sponsors_id;
|
||||
$u['types'][]="sponsor";
|
||||
user_save($u);
|
||||
|
||||
save_activityinfo("Existing user (".$u['firstname']." ".$u['lastname'].") linked to donor/sponsor",$sponsors_id,$_SESSION['users_uid'],'System');
|
||||
happy_("Added existing user to donor/sponsor");
|
||||
|
||||
@ -454,6 +460,7 @@ function draw_contactsinfo_form($contact = null){
|
||||
$query = mysql_query("SELECT *,MAX(year) FROM users LEFT JOIN users_sponsor ON users_sponsor.users_id=users.id
|
||||
WHERE
|
||||
sponsors_id='" . $sponsor_id . "'
|
||||
AND types LIKE '%sponsor%'
|
||||
GROUP BY uid
|
||||
HAVING deleted='no'
|
||||
ORDER BY users_sponsor.primary DESC,lastname,firstname
|
||||
@ -476,6 +483,8 @@ function draw_contactsinfo_form($contact = null){
|
||||
echo "<h3><a href=\"#\">New Contact";
|
||||
echo "</a></h3>\n";
|
||||
echo "<div>\n";
|
||||
|
||||
//and do the blank one
|
||||
echo "<div id=\"newcontactsearch\"></div>";
|
||||
draw_contact_form($sponsor_id);
|
||||
echo "</div>\n";
|
||||
@ -488,11 +497,36 @@ function draw_contactsinfo_form($contact = null){
|
||||
// draw a form in which to enter information about the various contacts
|
||||
function draw_contact_form($sponsor_id, $contact = null){
|
||||
global $salutations;
|
||||
global $config;
|
||||
|
||||
//grab the sponsor details, so we can do diff things for individual vs organization
|
||||
$q=mysql_query("SELECT * FROM sponsors WHERE id='$sponsor_id'");
|
||||
$sponsor=mysql_fetch_object($q);
|
||||
|
||||
if($contact != null){
|
||||
$id = $contact["id"];
|
||||
}else{
|
||||
$id = "new";
|
||||
}
|
||||
$id = "new";
|
||||
if($sponsor->donortype=="individual") {
|
||||
list($firstname,$lastname)=split(" ",$sponsor->organization,2);
|
||||
$contact['firstname']=$firstname;
|
||||
$contact['lastname']=$lastname;
|
||||
$contact['email']=$sponsor->email;
|
||||
$contact['phonehome']=$sponsor->phone;
|
||||
}
|
||||
else {
|
||||
$contact['phonework']=$sponsor->phone;
|
||||
}
|
||||
|
||||
$contact['fax']=$sponsor->fax;
|
||||
$contact['address']=$sponsor->address;
|
||||
$contact['address2']=$sponsor->address2;
|
||||
$contact['city']=$sponsor->city;
|
||||
$contact['province']=$sponsor->province_code;
|
||||
$contact['postalcode']=$sponsor->postalcode;
|
||||
|
||||
}
|
||||
|
||||
echo "<form id=\"contact_" . $id . "\" method=\"post\" action=\"donors.php?action=contactsinfo_save\">\n";
|
||||
echo "<input type=\"hidden\" name=\"sponsor_id\" value=\"$sponsor_id\">\n";
|
||||
if($id == "new"){
|
||||
@ -519,14 +553,25 @@ function draw_contact_form($sponsor_id, $contact = null){
|
||||
</select>
|
||||
</td>
|
||||
<td><?=i18n("Position"); ?></td>
|
||||
<td><input type="text" name="position" value = "<?=htmlspecialchars($contact['position'])?>"></td>
|
||||
<?
|
||||
if($sponsor->donortype=="organization") {
|
||||
$d="disabled=\"disabled\"";
|
||||
}
|
||||
else $d="";
|
||||
?>
|
||||
|
||||
<td><input type="text" name="position" <?=$d?> value = "<?=htmlspecialchars($contact['position'])?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=i18n("First Name"); ?></td>
|
||||
<td><?=i18n("First Name"); ?></td>
|
||||
<td><input <?=$newcontactsearch?> type="text" name="firstname" value = "<?=htmlspecialchars($contact['firstname'])?>"></td>
|
||||
<td><?=i18n("Last Name"); ?></td>
|
||||
<td><input <?=$newcontactsearch?> type="text" name="lastname" value = "<?=htmlspecialchars($contact['lastname'])?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=i18n("Email"); ?></td>
|
||||
<td colspan="3"><input <?=$newcontactsearch?> type="text" name="email" size="60" value = "<?=htmlspecialchars($contact['email'])?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=i18n("Phone (Work)"); ?></td>
|
||||
<td><input type="text" name="phonework" value = "<?=htmlspecialchars($contact['phonework'])?>"></td>
|
||||
@ -539,10 +584,16 @@ function draw_contact_form($sponsor_id, $contact = null){
|
||||
<td><?=i18n("Fax"); ?></td>
|
||||
<td><input type="text" name="fax" value = "<?=htmlspecialchars($contact['fax'])?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?=i18n("Email"); ?></td>
|
||||
<td colspan="3"><input <?=$newcontactsearch?> type="text" name="email" size="60" value = "<?=htmlspecialchars($contact['email'])?>"></td>
|
||||
</tr>
|
||||
|
||||
<tr><td><?=i18n("Address 1")?></td><td colspan="3"><input type="text" name="address" size="60" maxlength="64" value="<?=htmlspecialchars($contact['address'])?>" /></td></tr>
|
||||
<tr><td><?=i18n("Address 2")?></td><td colspan="3"><input type="text" name="address2" size="60" maxlength="64" value="<?=htmlspecialchars($contact['address2'])?>" /></td></tr>
|
||||
<tr><td><?=i18n("City")?></td><td><input id="city" type="text" name="city" size="16" maxlength="32" /></td>
|
||||
<td><?=i18n($config['provincestate'])?></td><td>
|
||||
<? emit_province_selector("province_code",$contact['province']); ?>
|
||||
</td></tr>
|
||||
<tr><td><?=i18n($config['postalzip'])?></td><td colspan="3"><input type="text" name="postalcode" size="8" maxlength="7" value="<?=htmlspecialchars($contact['postalcode'])?>" /></td></tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td><?=i18n("Notes"); ?></td>
|
||||
<td colspan="3"><textarea name="notes" cols="60" rows="4"><?=htmlspecialchars($contact['notes'])?></textarea></td>
|
||||
@ -690,6 +741,7 @@ $(document).ready(function() {
|
||||
|
||||
$("#organizationinfo_fundingselectiondate").datepicker({ dateFormat: 'yy-mm-dd'});
|
||||
//, showOn: 'button', buttonText: "<?=i18n("calendar")?>" });
|
||||
open_search();
|
||||
|
||||
});
|
||||
|
||||
@ -720,6 +772,9 @@ function open_editor(id) {
|
||||
$("#organizationinfo_fundingselectiondate").val("");
|
||||
$("#organizationinfo_notes").val("");
|
||||
|
||||
$("#organizationinfo_save_button").attr('disabled','disabled');
|
||||
$("[name=donortype]").attr('checked','');
|
||||
|
||||
}
|
||||
else {
|
||||
$('#editor_tabs').tabs('option', 'selected', 0);
|
||||
@ -766,7 +821,9 @@ function update_organizationinfo()
|
||||
$("#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]);
|
||||
$("[name=donortype]").val([json.donortype]);
|
||||
|
||||
donortypechange();
|
||||
});
|
||||
}
|
||||
|
||||
@ -782,6 +839,7 @@ function organizationinfo_save() {
|
||||
}
|
||||
else
|
||||
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=organizationinfo_save", $("#organizationinfo").serializeArray());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -880,8 +938,27 @@ function togglefulldonationhistory() {
|
||||
}
|
||||
|
||||
function campaignchange() {
|
||||
|
||||
}
|
||||
|
||||
function donortypechange() {
|
||||
if($("input[@name='donortype']:checked").val()=="organization") {
|
||||
$("#organizationinfo_logo").attr("disabled","");
|
||||
$("#organizationinfo_donationpolicyurl").attr("disabled","");
|
||||
$("#organizationinfo_fundingselectiondate").attr("disabled","");
|
||||
$("#organizationinfo_proposalsubmissiondate").attr("disabled","");
|
||||
}
|
||||
else if($("input[@name='donortype']:checked").val()=="individual") {
|
||||
$("#organizationinfo_logo").attr("disabled","disabled");
|
||||
$("#organizationinfo_donationpolicyurl").attr("disabled","disabled");
|
||||
$("#organizationinfo_fundingselectiondate").attr("disabled","disabled");
|
||||
$("#organizationinfo_proposalsubmissiondate").attr("disabled","disabled");
|
||||
}
|
||||
else {
|
||||
}
|
||||
$("#organizationinfo_save_button").attr('disabled','');
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<?
|
||||
|
||||
@ -909,8 +986,8 @@ echo "<hr />";
|
||||
<div id="editor_tabs">
|
||||
<ul>
|
||||
<li><a href="#editor_tab_organization"><span><?=i18n('Donor/Sponsor Details')?></span></a></li>
|
||||
<li><a href="#editor_tab_sponsorship"><span><?=i18n('Donations/Sponsorships')?></span></a></li>
|
||||
<li><a href="#editor_tab_contacts"><span><?=i18n('Contacts')?></span></a></li>
|
||||
<li><a href="#editor_tab_sponsorship"><span><?=i18n('Donations/Sponsorships')?></span></a></li>
|
||||
<li><a href="#editor_tab_activity"><span><?=i18n('Activity Log')?></span></a></li>
|
||||
</ul>
|
||||
|
||||
@ -919,8 +996,8 @@ echo "<hr />";
|
||||
<input type="hidden" name="sponsor_id" id="sponsor_id" value="0">
|
||||
<table class="tableedit" border=0>
|
||||
<tr><td><?=i18n("Donor Type")?></td><td colspan="5">
|
||||
<input id="donortype_individual" type="radio" name="donortype" value="individual" /><label for="donortype_individual"><?=i18n("Individual")?></label>
|
||||
<input id="donortype_organization" type="radio" name="donortype" value="organization" checked="checked"/><label for="donortype_organization"><?=i18n("Organization")?></label>
|
||||
<input id="donortype_individual" type="radio" name="donortype" value="individual" onchange="return donortypechange()" /><label for="donortype_individual"><?=i18n("Individual")?></label>
|
||||
<input id="donortype_organization" type="radio" name="donortype" value="organization" onchange="return donortypechange()" /><label for="donortype_organization"><?=i18n("Organization")?></label>
|
||||
</td></tr>
|
||||
<tr><td><?=i18n("Name")?></td><td colspan="5"><input class="translatable" type="text" id="organizationinfo_organization" name="organization" size="60" maxlength="128" /></td></tr>
|
||||
<tr><td><?=i18n("Address 1")?></td><td colspan="5"><input id="organizationinfo_address" type="text" name="address" size="60" maxlength="64" /></td></tr>
|
||||
@ -938,8 +1015,9 @@ echo "<hr />";
|
||||
<tr><td><?=i18n("Website")?></td><td colspan="5"><input type="text" id="organizationinfo_website" name="website" size="60" maxlength="128" /></td>
|
||||
</tr>
|
||||
<tr><td><?=i18n("Donation Policy")?></td><td colspan="5"><input id="organizationinfo_donationpolicyurl" type="file" name="donationpolicyurl" size="30" maxlength="128" /></td></tr>
|
||||
<tr><td><?=i18n("Logo")?></td><td colspan="5"><input type="file" name="logo" size="30" /></td></tr>
|
||||
<tr><td><?=i18n("Funding Selection Date")?></td><td colspan="5"><input id="organizationinfo_fundingselectiondate" type="text" name="fundingselectiondate" size="10" maxlength="10" /></td>
|
||||
<tr><td><?=i18n("Logo")?></td><td colspan="5"><input type="file" id="organizationinfo_logo" name="logo" size="30" /></td></tr>
|
||||
<tr><td><?=i18n("Funding Selection Date")?></td><td><input id="organizationinfo_fundingselectiondate" type="text" name="fundingselectiondate" size="10" maxlength="10" /></td>
|
||||
<td><?=i18n("Proposal Submission Date")?></td><td colspan="3"><input id="organizationinfo_proposalsubmissiondate" type="text" name="proposalsubmissiondate" size="10" maxlength="10" /></td>
|
||||
</tr>
|
||||
<?
|
||||
/*
|
||||
@ -961,7 +1039,7 @@ echo "<hr />";
|
||||
?>
|
||||
<tr><td><?=i18n("Notes")?></td><td colspan="5"><textarea id="organizationinfo_notes" name="notes" rows="4" cols="60"></textarea></td></tr>
|
||||
</table>
|
||||
<input type="submit" value="Save" onClick="return organizationinfo_save()" />
|
||||
<input id="organizationinfo_save_button" type="submit" value="<?=i18n("Save")?>" onClick="return organizationinfo_save()" />
|
||||
</form>
|
||||
</div>
|
||||
<div id="editor_tab_sponsorship">
|
||||
@ -979,8 +1057,8 @@ echo "<hr />";
|
||||
<div id="searchbrowse" style="display: none;">
|
||||
<form id="searchform" method="post" action="donors.php" onsubmit="return donorsearch()">
|
||||
<?=i18n("Search")?>: <input type="text" name="search" />
|
||||
<input id="donortype_individual" type="checkbox" name="donortype[]" value="individual" checked="checked" /><label for="donortype_individual"><?=i18n("Individual")?></label>
|
||||
<input id="donortype_organization" type="checkbox" name="donortype[]" value="organization" checked="checked"/><label for="donortype_organization"><?=i18n("Organization")?></label>
|
||||
<input id="search_donortype_individual" type="checkbox" name="donortype[]" value="individual" checked="checked" /><label for="search_donortype_individual"><?=i18n("Individual")?></label>
|
||||
<input id="search_donortype_organization" type="checkbox" name="donortype[]" value="organization" checked="checked"/><label for="search_donortype_organization"><?=i18n("Organization")?></label>
|
||||
<input type="submit" value="<?=i18n("Browse")?>" />
|
||||
</form>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user