Add a date class for all date entry boxes to use

Update fundraising dashboard to pull all To-Do list items from the corresponding database tables/fields
Update donor contacts code to not be crazy
Update donor organization info page as per carolyn's suggestions
This commit is contained in:
james 2009-10-07 17:58:11 +00:00
parent 511562b5b7
commit f01eac5b7b
5 changed files with 222 additions and 86 deletions

View File

@ -65,7 +65,8 @@ switch($_GET['action']) {
//FIXME accept the logo
//"logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ".
save_activityinfo("Updated organization info for " . mysql_escape_string(stripslashes($_POST['organization'])), $id);
//($comment , $donorId, $userId, $type, $campaign_id=null){
save_activityinfo("Updated organization info for {$_POST['organization']}", $id, $_SESSION['user_uid'],"System");
}
exit;
break;
@ -100,7 +101,14 @@ switch($_GET['action']) {
exit;
break;
case 'activityinfo_save':
if(save_activityinfo()){
//($comment , $donorId, $userId, $type, $campaign_id=null){
if(save_activityinfo(
$_POST['comment'],
$_GET['id'],
$_SESSION['users_uid'],
$_POST['type'],
$_POST['fundraising_campaigns_id']
)){
happy_("Activity Logged");
}else{
error_("Unable to save activity log");
@ -125,7 +133,8 @@ function delete_contact(){
user_delete($uid);
happy_("Deleted contact %1", array($name));
save_activityinfo("Deleted contact \"" . $name . "\"");
//($comment , $donorId, $userId, $type, $campaign_id=null){
save_activityinfo("Deleted contact \"$name\"",$_GET['id'],$_SESSION['users_uid'],'System' );
}
}
@ -170,11 +179,12 @@ function save_contact(){
} else {
/* Unset all other primaries */
mysql_query("UPDATE users_sponsor SET `primary`='no'
WHERE sponsors_id='$sponsor_id'");
WHERE sponsors_id='$sponsor_id' AND users_id != '$id'");
}
// we now know whether or not they're the primary user. Update them with that,
// along with all of the user info that's been submitted.
echo "setting primary $p";
$u['primary']=$p;
$u['salutation']=$_POST['salutation'];
$u['firstname']=$_POST['firstname'];
@ -189,7 +199,8 @@ function save_contact(){
$u['sponsors_id']=$sponsor_id;
user_save($u);
$name = trim($u['firstname'] . ' ' . $u['lastname']);
save_activityinfo($successLog . '"' . $name . '"');
//($comment , $donorId, $userId, $type, $campaign_id=null){
save_activityinfo($successLog . '"' . $name . '"',$sponsor_id,$_SESSION['users_uid'],'System');
happy_($successMessage);
}else{
// something's wrong with the user data submitted. Should flag the fields where
@ -223,7 +234,7 @@ function draw_contactsinfo_form($contact = null){
}
// start our accordion
echo "<div id=\"levelaccordion\" style=\"width: 75%;\">\n";
echo "<div id=\"contactaccordion\" style=\"width: 740px;\">\n";
// loop through each contact and draw a form with their data in it.
@ -273,10 +284,10 @@ function draw_contact_form($sponsor_id, $contact = null){
echo "<input type=\"hidden\" name=\"userid\" value=\"" . $id . "\">\n";
}
?>
<table>
<table class="tableedit">
<tr>
<td><?=i18n("Salutation"); ?></td>
<td><input type="text" name="salutation" value = "<?=htmlspecialchars($contact['salutation'])?>"></td>
<td><input type="text" name="salutation" size="4" value = "<?=htmlspecialchars($contact['salutation'])?>"></td>
<td><?=i18n("Position"); ?></td>
<td><input type="text" name="position" value = "<?=htmlspecialchars($contact['position'])?>"></td>
</tr>
@ -327,78 +338,98 @@ function draw_contact_form($sponsor_id, $contact = null){
function draw_activityinfo_form(){
global $config;
$sponsorid = $_GET['id'];
// we'll start by drawing the table header
?>
<form id="activityinfo">
<table class="tableview" style="width:90%">
<table class="tableview" style="width:99%">
<thead><tr>
<th>Date</th>
<th>User</th>
<!--th>Contact Type</th>
<th>Campaign name</th-->
<th>Contact Type</th>
<th>Campaign</th>
<th>Notes</th>
</tr></thead>
<tbody>
<tr>
<td align="center" ><input type="submit" value="<?=i18n("Add Log")?>" onClick="return activityinfo_save()" /></td>
<td align="center"><?=$_SESSION['name']?></td>
<td align="center">
<?
echo "<select name=\"type\">";
echo "<option value=\"\">".i18n("Choose Type")."</option>\n";
$logtypes=array("Campaign","Phone Call","Email","Personal Visit","Other");
foreach($logtypes AS $lt) {
echo "<option value=\"$lt\">".i18n($lt)."</option>\n";
}
echo "</select>\n";
?>
</td>
<td align="center">
<?
$q=mysql_query("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY name");
echo "<select name=\"fundraising_campaigns_id\">";
echo "<option value=\"\">".i18n("Choose Campaign")."</option>\n";
while($r=mysql_fetch_object($q)) {
echo "<option value=\"$r->id\">$r->name</option>\n";
}
echo "</select>\n";
?>
</td>
<td><input type="text" name="comment" style="width: 99%;"/></td>
</tr>
<?php
$query = "SELECT CONCAT_WS('&nbsp;', users.firstname, users.lastname) AS name, fdl.dt, fdl.log
$query = "SELECT CONCAT_WS('&nbsp;', users.firstname, users.lastname) AS name, fdl.dt, fdl.log, fdl.type,
fundraising_campaigns.name AS campaignname
FROM fundraising_donor_logs AS fdl
JOIN users ON fdl.users_id=users.id
WHERE sponsors_id=" . $sponsorid;
LEFT JOIN fundraising_campaigns ON fdl.fundraising_campaigns_id=fundraising_campaigns.id
WHERE sponsors_id=" . $sponsorid. " ORDER BY dt DESC";
//echo "<tr><td colspan=\"3\">" . $query . "</td></tr>";
$results = mysql_query($query);
$row = mysql_fetch_array($results);
if($row){
do{
echo "<tr><td>" . $row["dt"];
echo "</td><td>" . $row["name"];
echo "</td><td>" . $row["log"];
echo "</td></tr>\n";
}while($row = mysql_fetch_array($results));
$q = mysql_query($query);
echo mysql_error();
if(mysql_num_rows($q)) {
while($r = mysql_fetch_array($q)) {
echo "<tr><td>" . $r["dt"] . "</td>";
echo "<td>" . $r["name"] . "</td>";
echo "<td>" . $r["type"] . "</td>";
echo "<td>" . $r["campaignname"] . "</td>";
echo "<td>" . $r["log"] . "</td>";
echo "</tr>\n";
}
}else{
echo "<tr><td colspan=\"3\" style=\"text-align:center\">" . i18n("No records") . "</td></tr>";
echo "<tr><td colspan=\"5\" style=\"text-align:center\">" . i18n("No records") . "</td></tr>";
}
?>
<tr>
<td align="center" width="10%"><input type="submit" value="<?=i18n("Save")?>" onClick="return activityinfo_save()" /></td>
<td align="center" width="10%"><?=$_SESSION['name']?></td>
<td><input type="text" name="comment" style="width:100%"/></td>
</tr>
</tbody></table>
</form>
<?php
}
// Save an activity info log. Returns true on success, false on failure.
// if arguments are omitted, we try try to get them from the environment
function save_activityinfo($comment = null, $donorId = null, $userId = null){
function save_activityinfo($comment, $donorId, $userId, $type, $campaign_id=null){
$returnval = false;
// grab the values from our environment if they're not passed as arguments
if($comment == null) $comment = getValue('comment');
if($donorId == null) $donorId = getValue('id');
if($userId == null) $userId = getValue('users_id');
if($campaign_id) $cid="'$campaign_id'"; else $cid="NULL";
// if all is good, add a record
if($comment != null && $donorId != null && $userId != null){
$query = "INSERT INTO fundraising_donor_logs (sponsors_id, dt, users_id, log) ";
$query .= "VALUES (" . $donorId . ",NOW()," . $userId . ",'" . $comment . "')";
if(mysql_query($query)){
$returnval = true;
}
}
$query = "INSERT INTO fundraising_donor_logs (sponsors_id, dt, users_id, log, `type`, fundraising_campaigns_id)
VALUES ($donorId,
NOW(),
$userId,
'".mysql_real_escape_string($comment)."',
'".mysql_real_escape_string($type)."',
$cid)";
if(mysql_query($query)){
$returnval = true;
}
return $returnval;
}
// attempts to grab the desired index from _GET, _POST, and _SESSION in that order,
// and returns it's value on success. returnl null on failure.
function getValue($index){
if(array_key_exists($index, $_GET)) return $_GET[$index];
if(array_key_exists($index, $_POST)) return $_POST[$index];
if(array_key_exists($index, $_SESSION)) return $_SESSION[$index];
return null;
}
?>
<script type="text/javascript">
/* Setup the popup window */
@ -431,7 +462,8 @@ $(document).ready(function() {
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")?>" });
});
@ -447,6 +479,21 @@ function open_editor(id) {
$('#editor_tabs').tabs('option', 'selected', 0);
$('#editor_tabs').tabs('option', 'disabled', [1,2,3]);
$("#organizationinfo_organization").val("");
$("#organizationinfo_address").val("");
$("#organizationinfo_address2").val("");
$("#organizationinfo_city").val("");
$("#organizationinfo_province_code").val("");
$("#organizationinfo_postalcode").val("");
$("#organizationinfo_phone").val("");
$("#organizationinfo_tollfree").val("");
$("#organizationinfo_fax").val("");
$("#organizationinfo_email").val("");
$("#organizationinfo_website").val("");
$("#organizationinfo_donationpolicyurl").val("");
$("#organizationinfo_fundingselectiondate").val("");
$("#organizationinfo_notes").val("");
}
else {
$('#editor_tabs').tabs('option', 'selected', 0);
@ -529,7 +576,7 @@ function update_contactsinfo()
var id=sponsor_id;
$("#editor_tab_contacts").load("<?=$_SERVER['PHP_SELF']?>?action=contactsinfo_load&id="+id, null,
function() {
$("#levelaccordion").accordion();
$("#contactaccordion").accordion();
}
);
}
@ -538,7 +585,7 @@ function contactsinfo_save(uid) {
var id=sponsor_id;
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_save&id="+id, $("#contact_" + uid).serializeArray(),
function() {
$("#levelaccordion").accordion();
$("#contactaccordion").accordion();
update_contactsinfo();
});
return false;
@ -548,7 +595,7 @@ function contactsinfo_delete(uid) {
var id=sponsor_id;
$("#debug").load("<?$_SERVER['PHP_SELF']?>?action=contactsinfo_delete&id="+id, $("#contact_" + uid).serializeArray(),
function() {
$("#levelaccordion").accordion();
$("#contactaccordion").accordion();
update_contactsinfo();
});
return false;
@ -607,7 +654,7 @@ echo "</tr></table>";
echo "<hr />";
?>
<div id="donor_editor" title="Donor/Sponsor Editor" style="display: none">
<div id="donor_editor" title="Donor/Sponsor Editor" style="display: none; width: 770px;">
<div id="editor_tabs">
<ul>
<li><a href="#editor_tab_organization"><span><?=i18n('Donor/Sponsor Details')?></span></a></li>
@ -620,7 +667,7 @@ echo "<hr />";
<form enctype="multipart/form-data" id="organizationinfo">
<input type="hidden" name="sponsor_id" id="sponsor_id" value="0">
<table class="tableedit" border=0>
<tr><td><?=i18n("Donor Type")?></td><td>
<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>
</td></tr>
@ -635,20 +682,32 @@ echo "<hr />";
<tr><td><?=i18n("Phone")?></td><td><input type="text" id="organizationinfo_phone" name="phone" size="16" maxlength="32" /></td>
<td><?=i18n("Toll Free")?></td><td><input type="text" id="organizationinfo_tollfree" name="tollfree" size="16" maxlength="32" /></td>
<td><?=i18n("Fax")?></td><td><input type="text" id="organizationinfo_fax" name="fax" size="16" maxlength="32" /></td></tr>
<tr><td><?=i18n("Email")?></td><td><input type="text" id="organizationinfo_email" name="email" size="16" maxlength="128" /></td>
<td><?=i18n("Website")?></td><td><input type="text" id="organizationinfo_website" name="website" size="16" maxlength="128" /></td>
<td><?=i18n("Donation Policy")?></td><td><input id="organizationinfo_donationpolicyurl" type="text" name="donationpolicyurl" size="16" maxlength="128" /></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("Logo")?></td><td colspan="3"><input type="file" name="logo" size="16" /></td></tr>
<tr><td><?=i18n("Email")?></td><td colspan="5"><input type="text" id="organizationinfo_email" name="email" size="60" maxlength="128" /></td>
</tr>
<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>
<?
/*
<tr><td><?=i18n("Waiver Accepted")?></td><td>
<input type="radio" id="organizationinfo_waiveraccepted_no" name="waiveraccepted" value="no"><label for="organizationinfo_waiveraccepted_no"><?=i18n("No")?></label> &nbsp;&nbsp;
<input type="radio" id="organizationinfo_waiveraccepted_yes" name="waiveraccepted" value="yes"><label for="organizationinfo_waiveraccepted_yes"><?=i18n("Yes")?></label> &nbsp;&nbsp;
</td>
<td><?=i18n("Tax Receipt Required")?></td><td colspan="3">
<td><?=i18n("Tax Receipt Requested")?></td><td>
<input type="radio" id="organizationinfo_taxreceiptrequired_no" name="taxreceiptrequired" value="no"><label for="organizationinfo_taxreceiptrequired_no"><?=i18n("No")?></label> &nbsp;&nbsp;
<input type="radio" id="organizationinfo_taxreceiptrequired_yes" name="taxreceiptrequired" value="yes"><label for="organizationinfo_taxreceiptrequired_yes"><?=i18n("Yes")?></label> &nbsp;&nbsp;
</td></tr>
</td>
<td><?=i18n("Marketing Receipt Requested")?></td><td colspan="3">
<input type="radio" id="organizationinfo_marketingreceiptrequired_no" name="marketingreceiptrequired" value="no"><label for="organizationinfo_marketingreceiptrequired_no"><?=i18n("No")?></label> &nbsp;&nbsp;
<input type="radio" id="organizationinfo_marketingreceiptrequired_yes" name="marketingreceiptrequired" value="yes"><label for="organizationinfo_marketingreceiptrequired_yes"><?=i18n("Yes")?></label> &nbsp;&nbsp;
</td></tr>
*/
?>
<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()" />

View File

@ -46,8 +46,8 @@
echo "<table class=\"tableview\">";
echo "<tr>";
echo " <th>Organization</th>";
echo " <th># of Sponsorships</th>";
echo " <th># of Awards</th>";
// echo " <th># of Sponsorships</th>";
// echo " <th># of Awards</th>";
echo " <th># of Contacts</th>";
// echo " <th>Action</th>";
echo "</tr>\n";
@ -73,6 +73,7 @@
// $numcontacts=$numr->num;
/*
echo " <td align=\"center\" valign=\"top\">";
echo "$numsponsorships &nbsp;";
echo "<a href=\"fundraising.php?sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
@ -82,6 +83,7 @@
echo "$numawards &nbsp;";
echo "<a href=\"award_awards.php?sponsors_id=$r->id\"><img alt=\"view\" border=\"0\" src=\"".$config['SFIABDIRECTORY']."/images/16/viewmag.".$config['icon_extension']."\"></a>";
echo "</td>";
*/
echo " <td align=\"center\" valign=\"top\">";
echo "$numcontacts &nbsp;";

View File

@ -123,15 +123,87 @@ $q=mysql_query("SELECT * FROM fundraising_goals WHERE fiscalyear='{$config['FISC
<h3><?=i18n("To Do List")?></h3>
<h4>Thank You's</h4>
<input type="checkbox"> Donor xyz - $300<br />
<input type="checkbox"> Donor abc - $100<br />
<?
$q=mysql_query("SELECT value, thanked, status, users_uid, sponsors_id, datereceived
FROM fundraising_donations
WHERE thanked='no' AND status='received'
AND fiscalyear='{$config['FISCALYEAR']}
ORDER BY datereceived'
");
//AND (users.year IS NULL OR users.year='{$config['FISCALYEAR']}')
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 Thank You")."</th>\n";
echo "</tr>\n";
while($r=mysql_fetch_object($q)) {
if($r->users_uid) {
$dq=mysql_query("SELECT CONCAT(firstname,' ',lastname) AS name FROM users WHERE uid='$r->users_uid' ORDER BY fairyear DESC LIMIT 1");
}
else if ($r->sponsors_id) {
$dq=mysql_query("SELECT organization AS name FROM sponsors WHERE id='$r->sponsors_id'");
}
$dr=mysql_fetch_object($dq);
echo "<tr>";
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 Thank You")."</a></td>";
echo "</tr>\n";
}
echo "</table>\n";
}else {
echo i18n("No Thank You's pending");
echo "<br />\n";
}
?>
<br />
<h4>Campaign Follow-Ups</h4>
<input type="checkbox"> Parents. Started December 1 2009, Followup By January 15 2010, Ends March 31 2010<br />
<br />
<h4>Prospects by Month</h4>
<input type="checkbox"> Carolyn - what is this?
<?
$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 "<tr>";
echo " <th>".i18n("Campaign Name")."</th>\n";
echo " <th>".i18n("Start Date")."</th>\n";
echo " <th>".i18n("Follow-Up Date")."</th>\n";
echo "</tr>\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 campaign follow-ups");
echo "<br />\n";
}
?>
<br />
<h4>Upcoming Proposals</h4>
<?
$q=mysql_query("SELECT * FROM sponsors WHERE fundingselectiondate>=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("Funding Selection Date")."</th>\n";
echo "</tr>\n";
while($r=mysql_fetch_object($q)) {
echo "<tr><td>$r->organization</td><td>".format_date($r->fundingselectiondate)."</td></tr>\n";
}
echo "</table>\n";
} else {
echo i18n("No proposals upcoming");
}
send_footer();
?>

View File

@ -47,20 +47,19 @@ function save_campaign_info(){
// now we need to create some default data to fill the record
$type = ""; //FIXME - these need more sensible and controlled values
$active = "no";
$active = "yes";
$target = 0;
$goal_id = "";
$fiscalyear = -1;
$fiscalyear = $config['FISCALYEAR'];
$query = "INSERT INTO fundraising_campaigns (name, type, startdate, enddate, active, target, fundraising_goal, fiscalyear) VALUES(";
$query .= '"' . $campagin_name . '",';
$query .= '"' . $type . '",';
$query .= '"' . $startdate . '",';
$query .= '"' . $enddate . '",';
$query .= '"' . $active . '",';
$query .= $target . ',';
$query .= '"' . $goal_id . '",';
$query .= $fiscalyear . ')';
$query = "INSERT INTO fundraising_campaigns (name, type, startdate, enddate, followupdate, active, target, fundraising_goal, fiscalyear) VALUES (
'$campagin_name,'$type','$startdate',
'$enddate',
DATE_ADD('$startdate', INTERVAL 1 MONTH),
'$active',
'$target',
'$goal_id',
'$fiscalyear')";
mysql_query($query);
@ -149,9 +148,9 @@ function open_editor(id) {
<td><?=i18n("Campaign Name")?></td>
<td><input type="text" name="name"></td>
<td><?=i18n("Start Date")?></td>
<td><input type="text" id="startdate" name="startdate" style="border-width:1px;background-color:#DDD;width:68px"/></td>
<td><input type="text" id="startdate" name="startdate" class="date" value="<?=date("Y-m-d")?>"/></td>
<td><?=i18n("End Date")?></td>
<td><input type="text" id="enddate" name="enddate" style="border-width:1px;background-color:#DDD;width:68px"/></td>
<td><input type="text" id="enddate" name="enddate" class="date"/></td>
<td><input type="submit" value="<?=i18n("add");?>"></td>
</tr>
</table>

View File

@ -353,6 +353,11 @@ div.notice_area div.happy {
background-color: green;
}
.date {
width: 80px;
}
/* The popup windows created with jquery-ui use the following classes:
* div.ui-dialog
* div.ui-dialog-titlebar - includes the next 2 items in the div
@ -410,7 +415,6 @@ div.ui-tabs ul.ui-tabs-nav {
font-weight: bold;
}
.ui-datepicker {
z-index: 1003;
}