Add donor name above tabs on editor

Add fundraising module setup tab
Add select's for campaign type and for salutation
Other misc fixes
This commit is contained in:
james 2009-10-08 19:13:14 +00:00
parent 2fd187e753
commit 51191eec4f
4 changed files with 106 additions and 13 deletions

View File

@ -25,6 +25,8 @@
require("../common.inc.php"); require("../common.inc.php");
require_once("../user.inc.php"); require_once("../user.inc.php");
user_auth_required('committee', 'admin'); user_auth_required('committee', 'admin');
require_once("fundraising_common.inc.php");
switch($_GET['action']) { switch($_GET['action']) {
case 'organizationinfo_load': case 'organizationinfo_load':
@ -47,6 +49,7 @@ switch($_GET['action']) {
$exec="UPDATE sponsors SET ". $exec="UPDATE sponsors SET ".
"organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ". "organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ".
"address='".mysql_escape_string(stripslashes($_POST['address']))."', ". "address='".mysql_escape_string(stripslashes($_POST['address']))."', ".
"address2='".mysql_escape_string(stripslashes($_POST['address2']))."', ".
"city='".mysql_escape_string(stripslashes($_POST['city']))."', ". "city='".mysql_escape_string(stripslashes($_POST['city']))."', ".
"province_code='".mysql_escape_string(stripslashes($_POST['province_code']))."', ". "province_code='".mysql_escape_string(stripslashes($_POST['province_code']))."', ".
"postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."', ". "postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."', ".
@ -66,7 +69,8 @@ switch($_GET['action']) {
//FIXME accept the logo //FIXME accept the logo
//"logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ". //"logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ".
//($comment , $donorId, $userId, $type, $campaign_id=null){ //($comment , $donorId, $userId, $type, $campaign_id=null){
save_activityinfo("Updated organization info for {$_POST['organization']}", $id, $_SESSION['user_uid'],"System"); save_activityinfo("Updated donor/sponsor details", $id, $_SESSION['users_uid'],"System");
happy_("Donor/Sponsor Details saved");
} }
exit; exit;
break; break;
@ -270,6 +274,7 @@ function draw_contactsinfo_form($contact = null){
// draw a form in which to enter information about the various contacts // draw a form in which to enter information about the various contacts
function draw_contact_form($sponsor_id, $contact = null){ function draw_contact_form($sponsor_id, $contact = null){
global $salutations;
if($contact != null){ if($contact != null){
$id = $contact["id"]; $id = $contact["id"];
}else{ }else{
@ -287,7 +292,17 @@ function draw_contact_form($sponsor_id, $contact = null){
<table class="tableedit"> <table class="tableedit">
<tr> <tr>
<td><?=i18n("Salutation"); ?></td> <td><?=i18n("Salutation"); ?></td>
<td><input type="text" name="salutation" size="4" value = "<?=htmlspecialchars($contact['salutation'])?>"></td> <td>
<select name="salutation">
<option value=""><?=i18n("Choose")?></option>
<?
foreach($salutations AS $salutation) {
if($contact['salutation']==$salutation) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$salutation\">$salutation</option>\n";
}
?>
</select>
</td>
<td><?=i18n("Position"); ?></td> <td><?=i18n("Position"); ?></td>
<td><input type="text" name="position" value = "<?=htmlspecialchars($contact['position'])?>"></td> <td><input type="text" name="position" value = "<?=htmlspecialchars($contact['position'])?>"></td>
</tr> </tr>
@ -410,10 +425,8 @@ function draw_activityinfo_form(){
<?php <?php
} }
// Save an activity info log. Returns true on success, false on failure. // Save an activity info log.
function save_activityinfo($comment, $donorId, $userId, $type, $campaign_id=null){ function save_activityinfo($comment, $donorId, $userId, $type, $campaign_id=null){
$returnval = false;
if($campaign_id) $cid="'$campaign_id'"; else $cid="NULL"; if($campaign_id) $cid="'$campaign_id'"; else $cid="NULL";
$query = "INSERT INTO fundraising_donor_logs (sponsors_id, dt, users_id, log, `type`, fundraising_campaigns_id) $query = "INSERT INTO fundraising_donor_logs (sponsors_id, dt, users_id, log, `type`, fundraising_campaigns_id)
@ -423,11 +436,10 @@ function save_activityinfo($comment, $donorId, $userId, $type, $campaign_id=null
'".mysql_real_escape_string($comment)."', '".mysql_real_escape_string($comment)."',
'".mysql_real_escape_string($type)."', '".mysql_real_escape_string($type)."',
$cid)"; $cid)";
echo $query;
if(mysql_query($query)){ mysql_query($query);
$returnval = true; echo mysql_error();
}
return $returnval;
} }
?> ?>
@ -522,12 +534,14 @@ function update_organizationinfo()
$.getJSON("<?=$_SERVER['PHP_SELF']?>?action=organizationinfo_load&id="+id, $.getJSON("<?=$_SERVER['PHP_SELF']?>?action=organizationinfo_load&id="+id,
function(json){ function(json){
$("#donor_name").html("<h3>"+json.organization+"</h3>");
$("#sponsor_id").val(json.id); $("#sponsor_id").val(json.id);
$("#organizationinfo_organization").val(json.organization); $("#organizationinfo_organization").val(json.organization);
$("#organizationinfo_address").val(json.address); $("#organizationinfo_address").val(json.address);
$("#organizationinfo_address2").val(json.address2);
$("#organizationinfo_city").val(json.city); $("#organizationinfo_city").val(json.city);
$("#organizationinfo_province_code").val(json.province_code); $("#organizationinfo_province_code").val(json.province_code);
$("#organizationinfo_postalcodd").val(json.postalcode); $("#organizationinfo_postalcode").val(json.postalcode);
$("#organizationinfo_phone").val(json.phone); $("#organizationinfo_phone").val(json.phone);
$("#organizationinfo_tollfree").val(json.tollfree); $("#organizationinfo_tollfree").val(json.tollfree);
$("#organizationinfo_fax").val(json.fax); $("#organizationinfo_fax").val(json.fax);
@ -653,8 +667,8 @@ echo "</td>";
echo "</tr></table>"; echo "</tr></table>";
echo "<hr />"; echo "<hr />";
?> ?>
<div id="donor_editor" title="Donor/Sponsor Editor" style="display: none; width: 770px;"> <div id="donor_editor" title="Donor/Sponsor Editor" style="display: none; width: 770px;">
<div id="donor_name"></div>
<div id="editor_tabs"> <div id="editor_tabs">
<ul> <ul>
<li><a href="#editor_tab_organization"><span><?=i18n('Donor/Sponsor Details')?></span></a></li> <li><a href="#editor_tab_organization"><span><?=i18n('Donor/Sponsor Details')?></span></a></li>

View File

@ -24,6 +24,7 @@
require("../common.inc.php"); require("../common.inc.php");
require_once("../user.inc.php"); require_once("../user.inc.php");
user_auth_required('committee', 'admin'); user_auth_required('committee', 'admin');
require("fundraising_common.inc.php");
switch($_GET['action']){ switch($_GET['action']){
case "campaigninfo_save": case "campaigninfo_save":
@ -171,7 +172,7 @@ switch($_GET['action']){
echo mysql_error(); echo mysql_error();
$recr=mysql_fetch_object($recq); $recr=mysql_fetch_object($recq);
$received=$recr->received; $received=$recr->received;
if($r->budget) if($r->target)
$percent=round($received/$r->target*100,1); $percent=round($received/$r->target*100,1);
else else
$percent=0; $percent=0;
@ -363,11 +364,22 @@ function update_tab_communications() {
<? <?
function display_campaign_form($r=null) { function display_campaign_form($r=null) {
global $config; global $config;
global $campaign_types;
?> ?>
<tr> <tr>
<td><?=i18n("Name")?></td> <td><?=i18n("Name")?></td>
<td colspan="3"><input size="40" type="text" name="name" value="<?=$r->name?>"></td> <td colspan="3"><input size="40" type="text" name="name" value="<?=$r->name?>"></td>
<td><?=i18n("Type")?></td><td><input type="text" name="type" value="<?=$r->type?>"></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> </tr>
<? <?
if($r->startdate) $sd=$r->startdate; if($r->startdate) $sd=$r->startdate;

View File

@ -0,0 +1,5 @@
<?
$campaign_types=array("Mail","Email","Phone","Personal Visit","Event","Other");
$salutations=array("Mr.","Mrs.","Ms","Dr.","Professor");
?>

View File

@ -165,6 +165,34 @@
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)=split("-",$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; exit;
break; break;
} }
@ -269,6 +297,15 @@
exit; exit;
break; 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 year='{$config['FAIRYEAR']}'");
mysql_query("UPDATE config SET val='".mysql_real_escape_string($_POST['registeredcharity'])."' WHERE var='registered_charity' AND year='{$config['FAIRYEAR']}'");
mysql_query("UPDATE config SET val='".mysql_real_escape_string($_POST['charitynumber'])."' WHERE var='charity_number' AND year='{$config['FAIRYEAR']}'");
happy_("Fundraising module setup saved");
exit;
break;
} }
send_header("Fundraising Setup", send_header("Fundraising Setup",
@ -292,6 +329,10 @@ $(document).ready(function() {
update_goals(); update_goals();
break; break;
break; break;
case 'editor_tab_setup':
update_setup();
break;
break;
} }
}, },
selected: 0, selected: 0,
@ -334,6 +375,14 @@ function update_goals() {
); );
} }
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) { function goal_save(id) {
if(id) var f=$("#goal_form_"+id); if(id) var f=$("#goal_form_"+id);
else var f=$("#goal_form"); else var f=$("#goal_form");
@ -350,16 +399,29 @@ function goal_delete(id) {
return false; return false;
} }
function charitychange() {
if($("input[@name='registeredcharity']:checked").val()=="yes") {
$("#charitynumber").attr("disabled","");
}
else {
$("#charitynumber").attr("disabled","disabled");
}
}
</script> </script>
<div id="setup" style="width: 780px;"> <div id="setup" style="width: 780px;">
<div id="editor_tabs"> <div id="editor_tabs">
<ul> <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_levels"><span><?=i18n('Fundraising Levels')?></span></a></li>
<li><a href="#editor_tab_goals"><span><?=i18n('Fundraising Goals')?></span></a></li> <li><a href="#editor_tab_goals"><span><?=i18n('Fundraising Goals')?></span></a></li>
</ul> </ul>
<div id="editor_tab_setup">
</div>
<div id="editor_tab_levels"> <div id="editor_tab_levels">
</div> </div>
<div id="editor_tab_goals"> <div id="editor_tab_goals">