Various fixes towards fundraising

This commit is contained in:
Armanveer Gill 2025-01-28 14:58:54 -05:00
parent 4f935e5818
commit bb807eab04
5 changed files with 44 additions and 37 deletions

View File

@ -146,6 +146,7 @@ switch(get_value_from_array($_GET, 'action')) {
$q->execute(); $q->execute();
show_pdo_errors_if_any($pdo); show_pdo_errors_if_any($pdo);
if($q->rowCount()) { if($q->rowCount()) {
echo "<table class=\"tableview\">"; echo "<table class=\"tableview\">";
echo "<thead>"; echo "<thead>";
@ -929,21 +930,11 @@ $(document).ready(function() {
*/ */
$("#editor_tabs").tabs({ $("#editor_tabs").tabs({
show: function(event, ui) { create: function( event, ui ) {
switch(ui.panel.id) { update_organizationinfo();
case 'editor_tab_organization': update_sponsorshipinfo();
update_organizationinfo(); update_contactsinfo();
break; update_activityinfo();
case 'editor_tab_sponsorship':
update_sponsorshipinfo();
break;
case 'editor_tab_contacts':
update_contactsinfo();
break;
case 'editor_tab_activity':
update_activityinfo();
break;
}
}, },
selected: 0 selected: 0
}); });
@ -982,7 +973,7 @@ function open_editor(id) {
$("#organizationinfo_proposalsubmissiondate").val(""); $("#organizationinfo_proposalsubmissiondate").val("");
$("#organizationinfo_notes").val(""); $("#organizationinfo_notes").val("");
$("#organizationinfo_save_button").attr('disabled','disabled'); $("#update_contactsinfoorganizationinfo_save_button").attr('disabled','disabled');
$("[name=donortype]").attr('checked',''); $("[name=donortype]").attr('checked','');
} }
@ -1072,7 +1063,9 @@ function update_contactsinfo()
var id=sponsor_id; var id=sponsor_id;
$("#editor_tab_contacts").load("<?=$_SERVER['PHP_SELF']?>?action=contactsinfo_load&id="+id, null, $("#editor_tab_contacts").load("<?=$_SERVER['PHP_SELF']?>?action=contactsinfo_load&id="+id, null,
function() { function() {
$("#contactaccordion").accordion(); $("#contactaccordion").accordion({
heightStyle: "content"
});
} }
); );
} }
@ -1082,7 +1075,9 @@ function contactsinfo_save(uid) {
print(id); print(id);
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_save&id="+id, $("#contact_" + uid).serializeArray(), $("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_save&id="+id, $("#contact_" + uid).serializeArray(),
function() { function() {
$("#contactaccordion").accordion(); $("#contactaccordion").accordion({
heightStyle: "content"
});
update_contactsinfo(); update_contactsinfo();
}); });
return false; return false;
@ -1092,7 +1087,9 @@ function contactsinfo_delete(uid) {
var id=sponsor_id; var id=sponsor_id;
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_delete&id="+id, $("#contact_" + uid).serializeArray(), $("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_delete&id="+id, $("#contact_" + uid).serializeArray(),
function() { function() {
$("#contactaccordion").accordion(); $("#contactaccordion").accordion({
heightStyle: "content"
});
update_contactsinfo(); update_contactsinfo();
}); });
return false; return false;

View File

@ -90,10 +90,10 @@ $q->execute();
$goalq=$pdo->prepare("SELECT * FROM fundraising_goals WHERE goal='{$r->fundraising_goal}' AND fiscalyear='{$config['FISCALYEAR']}'"); $goalq=$pdo->prepare("SELECT * FROM fundraising_goals WHERE goal='{$r->fundraising_goal}' AND fiscalyear='{$config['FISCALYEAR']}'");
$goalq->execute(); $goalq->execute();
$goalr=$goalq->fetch(PDO:FETCH_OBJ); $goalr=$goalq->fetch(PDO::FETCH_OBJ);
$recq=$pdo->prepare("SELECT SUM(value) AS received FROM fundraising_donations WHERE fundraising_campaigns_id='$r->id' AND fiscalyear='{$config['FISCALYEAR']}' AND status='received'"); $recq=$pdo->prepare("SELECT SUM(value) AS received FROM fundraising_donations WHERE fundraising_campaigns_id='$r->id' AND fiscalyear='{$config['FISCALYEAR']}' AND status='received'");
$recq->execute(); $recq->execute();
show_pdo_errors_if_any(); show_pdo_errors_if_any($pdo);
$recr=$recq->fetch(PDO::FETCH_OBJ); $recr=$recq->fetch(PDO::FETCH_OBJ);
$received=$recr->received; $received=$recr->received;
if($r->target) if($r->target)
@ -102,6 +102,11 @@ $q->execute();
$percent=0; $percent=0;
$col=colour_to_percent($percent); $col=colour_to_percent($percent);
if (!$goalr) {
$goalr = new stdClass();
$goalr->name = '';
}
echo "<tr style=\"cursor:pointer;\" onclick=\"window.location.href='fundraising_campaigns.php?manage_campaign=$r->id'\">\n"; 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->name</td>\n";
echo " <td>$r->type</td>\n"; echo " <td>$r->type</td>\n";

View File

@ -95,7 +95,6 @@ switch(get_value_from_array($_GET, 'action')){
$q=$pdo->prepare("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}'"); $q=$pdo->prepare("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}'");
$q->execute(); $q->execute();
while($r=$q->fetch(PDO::FETCH_OBJ)) { while($r=$q->fetch(PDO::FETCH_OBJ)) {
$goalq=$pdo->prepare("SELECT * FROM fundraising_goals WHERE goal='{$r->fundraising_goal}' AND fiscalyear='{$config['FISCALYEAR']}'"); $goalq=$pdo->prepare("SELECT * FROM fundraising_goals WHERE goal='{$r->fundraising_goal}' AND fiscalyear='{$config['FISCALYEAR']}'");
$goalq->execute(); $goalq->execute();
$goalr=$goalq->fetch(PDO::FETCH_OBJ); $goalr=$goalq->fetch(PDO::FETCH_OBJ);
@ -110,6 +109,11 @@ $q->execute();
$percent=0; $percent=0;
$col=colour_to_percent($percent); $col=colour_to_percent($percent);
if (!$goalr) {
$goalr = new stdClass();
$goalr->name = '';
}
echo "<tr style=\"cursor:pointer;\" onclick=\"return managecampaign($r->id)\">\n"; echo "<tr style=\"cursor:pointer;\" onclick=\"return managecampaign($r->id)\">\n";
echo " <td>$r->name</td>\n"; echo " <td>$r->name</td>\n";
echo " <td>$r->type</td>\n"; echo " <td>$r->type</td>\n";
@ -518,7 +522,7 @@ $q->execute();
} }
function save_campaign_info(){ function save_campaign_info(){
global $config; global $config, $pdo;
if(!$_POST['name']){ if(!$_POST['name']){
error_("Appeal Name is required"); error_("Appeal Name is required");
return; return;
@ -526,8 +530,8 @@ function save_campaign_info(){
if(!$_POST['startdate']) $startdate=date("Y-m-d"); else $startdate=$_POST['startdate']; if(!$_POST['startdate']) $startdate=date("Y-m-d"); else $startdate=$_POST['startdate'];
if(!$_GET['id']) { if(!$_GET['id']) {
$query = "INSERT INTO fundraising_campaigns (name,fiscalyear) VALUES ( $query = "INSERT INTO fundraising_campaigns (name, fiscalyear) VALUES ('".stripslashes($_POST['name'])."','{$config['FISCALYEAR']}')";
'".stripslashes($_POST['name'])."','{$config['FISCALYEAR']}')"; echo $query;
$stmt = $pdo->prepare($query); $stmt = $pdo->prepare($query);
$stmt->execute(); $stmt->execute();
$id = $pdo->lastInsertId(); $id = $pdo->lastInsertId();
@ -600,14 +604,12 @@ function managecampaignsfinish() {
} }
function managecampaignfinish() { function managecampaignfinish() {
$("#editor_tabs").tabs({ $("#editor_tabs").tabs({
create: function( event, ui ) { create: function( event, ui ) {
update_tab_overview(); update_tab_overview();
update_tab_donations(); update_tab_donations();
update_tab_prospects(); update_tab_prospects();
update_tab_communications(); update_tab_communications();
}, },
selected: 0 selected: 0

View File

@ -3,10 +3,10 @@ $campaign_types=array("Mail","Email","Phone","Personal Visit","Event","Other");
$salutations=array("Mr.","Mrs.","Ms","Dr.","Professor"); $salutations=array("Mr.","Mrs.","Ms","Dr.","Professor");
function getGoal($goal) { function getGoal($goal) {
global $config; global $config, $pdo;
$q=$pdo->prepare("SELECT * FROM fundraising_goals WHERE goal='$goal' AND fiscalyear='{$config['FISCALYEAR']}' LIMIT 1"); $q=$pdo->prepare("SELECT * FROM fundraising_goals WHERE goal='$goal' AND fiscalyear='{$config['FISCALYEAR']}' LIMIT 1");
$q->execute(); $q->execute();
return $q->rowCount(); return $q->fetch(PDO::FETCH_OBJ);
} }
?> ?>

View File

@ -251,7 +251,7 @@
case "goal_save": case "goal_save":
$id=$_POST['id']; $id=$_POST['id'];
if(! ($_POST['name'] && $_POST['budget'])) { if(!($_POST['name'] && $_POST['budget'])) {
error_("Purpose name and budget are required"); error_("Purpose name and budget are required");
exit; exit;
} }
@ -268,7 +268,8 @@
} }
else { else {
$goal=strtolower($_POST['name']); $goal=strtolower($_POST['name']);
$goal=ereg_replace("[^a-z]","",$goal); $goal=preg_replace("[^a-z]","",$goal);
echo "SELECT * FROM fundraising_goals WHERE goal='$goal' AND fiscalyear='{$config['FISCALYEAR']}'";
$q=$pdo->prepare("SELECT * FROM fundraising_goals WHERE goal='$goal' AND fiscalyear='{$config['FISCALYEAR']}'"); $q=$pdo->prepare("SELECT * FROM fundraising_goals WHERE goal='$goal' AND fiscalyear='{$config['FISCALYEAR']}'");
$q->execute(); $q->execute();
show_pdo_errors_if_any($pdo); show_pdo_errors_if_any($pdo);
@ -345,11 +346,9 @@ $(document).ready(function() {
$("#editor_tabs").tabs({ $("#editor_tabs").tabs({
create: function( event, ui ) { create: function( event, ui ) {
update_levels(); update_levels();
update_goals(); update_goals();
update_setup(); update_setup();
}, },
selected: 0 selected: 0
}); });
@ -380,7 +379,9 @@ $(document).ready(function() {
function update_levels() { function update_levels() {
$("#editor_tab_levels").load("fundraising_setup.php?gettab=levels",null, $("#editor_tab_levels").load("fundraising_setup.php?gettab=levels",null,
function() { function() {
$("#levelaccordion").accordion(); $("#levelaccordion").accordion({
heightStyle: "content"
});
} }
); );
} }
@ -404,7 +405,9 @@ function level_delete(id) {
function update_goals() { function update_goals() {
$("#editor_tab_goals").load("fundraising_setup.php?gettab=goals",null, $("#editor_tab_goals").load("fundraising_setup.php?gettab=goals",null,
function() { function() {
$("#goalaccordion").accordion(); $("#goalaccordion").accordion({
heightStyle: "content"
});
$("[name=deadline]").datepicker({ dateFormat: 'yy-mm-dd'}); $("[name=deadline]").datepicker({ dateFormat: 'yy-mm-dd'});
} }
); );
@ -435,7 +438,7 @@ function goal_delete(id) {
} }
function charitychange() { function charitychange() {
if($("input[@name='registeredcharity']:checked").val()=="yes") { if($("input[name='registeredcharity']:checked").val()=="yes") {
$("#charitynumber").attr("disabled",""); $("#charitynumber").attr("disabled","");
} }
else { else {