Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add targeting support

  • Loading branch information...
commit ffaba24a26261db218dfa4b2f231327ad75e868e 1 parent ddf5a1a
@jmreardo jmreardo authored
View
28 campaign-details.php
@@ -54,6 +54,24 @@
$row_donations = mysql_fetch_assoc($donations);
$totalRows_donations = mysql_num_rows($donations);
+$query_targets = "SELECT
+ contact_id,
+ contact_first,
+ contact_last,
+ contact_title,
+ contact_company
+ FROM targets
+ LEFT JOIN contacts using (contact_id)
+ WHERE campaign_id = " . $campaign['campaign_id'] ." AND
+ (SELECT COUNT(*)
+ FROM donations
+ WHERE campaign_id = " . $campaign['campaign_id'] ." AND
+ donations.contact_id = targets.contact_id
+ ) = 0";
+$targets = mysql_query($query_targets, $contacts) or die(mysql_error());
+$row_targets = mysql_fetch_assoc($targets);
+$totalRows_targets = mysql_num_rows($targets);
+
$stats = donation_stats($campaign['campaign_id']);
$title_text = "Campaign - ". $campaign['campaign_name'];
$back_track = array('title' => "Campaigns", 'url' => "campaigns.php");
@@ -131,6 +149,16 @@
</tbody>
</table>
<br />
+<?php if ($totalRows_targets > 0) { ?>
+ <h3>Other Targets</h3>
+ <ul>
+ <?php do { ?>
+ <li><a href="contact-details.php?id=<?php echo $row_targets['contact_id']; ?>">
+ <?php echo display_name($row_targets); ?>
+ </a></li>
+ <?php } while ($row_targets = mysql_fetch_assoc($targets)); ?>
+ </ul>
+<?php } ?>
</div>
<?php include('includes/right-column.php'); ?>
<br clear="all" />
View
4 contact-details.php
@@ -179,9 +179,7 @@
<label class="first unitx1">
Campaign
<select id="campaign" name="campaign">
- <?php do { ?>
- <option value="<?php echo $row_campaigns['campaign_id']; ?>"><?php echo $row_campaigns['campaign_name']; ?></option>
- <?php } while($row_campaigns = mysql_fetch_assoc($campaigns)); ?>
+ <?php echo_campaign_options(); ?>
</select>
</label>
<label class="column unitx1">
View
48 contacts.php
@@ -46,16 +46,29 @@
header('Location: contact.php');
}
-//delete multiple contacts
+//act on multiple contacts
if (isset($_POST['d'])) {
- foreach($_POST['d'] as $key => $value) {
- if ($value) {
- mysql_query("DELETE FROM contacts WHERE contact_id = ".$value."");
- }
-
- }
-set_msg('Contacts Deleted');
-header('Location: contacts.php'); die;
+ foreach($_POST['d'] as $key => $value) {
+ if (is_numeric($value)) {
+ if($_POST['action'] == "Delete") {
+ mysql_query("DELETE FROM contacts WHERE contact_id = ".$value."");
+ }
+ if($_POST['action'] == "Target" && is_numeric($_POST['campaign'])) {
+ mysql_query("INSERT INTO targets (`contact_id`, `campaign_id`) VALUES ($value, " . $_POST['campaign'] . ")");
+ }
+ if($_POST['action'] == "Untarget" && is_numeric($_POST['campaign'])) {
+ mysql_query("DELETE FROM targets WHERE contact_id = $value AND campaign_id = " . $_POST['campaign']);
+ }
+ }
+ }
+ if($_POST['action'] == "Delete") {
+ set_msg('Contacts Deleted');
+ } else if($_POST['action'] == "Untarget") {
+ set_msg('Contacts Untargeted');
+ } else if($_POST['action'] == "Target") {
+ set_msg('Contacts Targeted');
+ }
+ header('Location: contacts.php'); die;
}
//
?>
@@ -76,20 +89,23 @@
Action
<select id="action" name="action">
<option>Delete</option>
- <option>Tag</option>
+ <option>Target</option>
+ <option>Untarget</option>
</select>
</label>
- <label id="tag_value_label" style="margin-bottom: 0px; display: none;" class="column unitx1">
+ <label id="target_value_label" style="margin-bottom: 0px; display: none;" class="column unitx1">
Campaign
- <input type="text" id="tag_value" name="tag_value" value="" />
+ <select id="campaign" name="campaign">
+ <?php echo_campaign_options(); ?>
+ </select>
</label>
<script type="text/javascript">
Event.observe(window,'load',function( ) {
Event.observe('action','change', function() {
- if($("action").getValue() == "Tag") {
- $("tag_value_label").show();
- } else {
- $("tag_value_label").hide();
+ if($("action").getValue() != "Delete") {
+ $("target_value_label").show();
+ } else if($("action").getValue() == "Delete") {
+ $("target_value_label").hide();
}
});
});
View
6 donation-details.php
@@ -121,7 +121,6 @@
$query_donation = "SELECT
donation_id,
campaign_id,
- contact_id,
donation_value,
donation_status,
donation_is_cash,
@@ -129,15 +128,14 @@
donation_received_date,
donation_description,
campaign_name,
- contact_company,
- contact_first,
- contact_last
+ contacts.*
FROM donations
LEFT JOIN contacts USING (contact_id)
LEFT JOIN campaigns USING (campaign_id)
WHERE donation_id = ".$_GET['id']."";
$donation = mysql_query($query_donation, $contacts) or die(mysql_error());
$row_donation = mysql_fetch_assoc($donation);
+$row_contact = $row_donation;
$totalRows_donation = mysql_num_rows($donation);
$title_text = "Donation for Campaign " . $row_donation['campaign_name'];
View
23 includes/right-column.php
@@ -33,7 +33,7 @@ function MM_setTextOfTextfield(objName,x,newText) { //v3.0
</script>
<div class="rightcolumn">
<?php if ($row_contact) { ?>
- <h3>Contact Information</h3>
+ <h3>Contact information</h3>
<?php if ($row_contact['contact_company']) { echo $row_contact['contact_company'] ."<br>"; } ?>
<?php if ($row_contact['contact_street']) { echo $row_contact['contact_street'] ."<br>"; } ?>
<?php if ($row_contact['contact_city']) { echo $row_contact['contact_city'] .","; } ?> <?php if ($row_contact['contact_state']) { echo $row_contact['contact_state']; } ?> <?php if ($row_contact['contact_zip']) { echo $row_contact['contact_zip']; } ?></p>
@@ -53,6 +53,27 @@ function MM_setTextOfTextfield(objName,x,newText) { //v3.0
<?php if ($row_contact['contact_profile']) { ?>
<strong>Background</strong><br />
<?php echo $row_contact['contact_profile']; ?>
+<?php }
+
+$query_targets = "SELECT
+ campaign_id,
+ campaign_name
+ FROM targets
+ LEFT JOIN campaigns using (campaign_id)
+ WHERE contact_id = " . $row_contact['contact_id'];
+$targets = mysql_query($query_targets, $contacts) or die(mysql_error());
+$row_targets = mysql_fetch_assoc($targets);
+$totalRows_targets = mysql_num_rows($targets);
+
+if($totalRows_targets > 0) { ?>
+ <strong>Campaigns Targeted</strong><br />
+ <ul class="blocklist">
+ <?php do { ?>
+ <li><a href="campaign-details.php?campaign=<?php echo $row_targets['campaign_id']; ?>">
+ <?php echo $row_targets['campaign_name']; ?>
+ </a></li>
+ <?php } while ($row_targets = mysql_fetch_assoc($targets)); ?>
+ </ul>
<?php } ?>
<hr />
<?php } ?>
View
12 includes/sc-includes.php
@@ -54,6 +54,18 @@ function display_msg() {
}
//
+function echo_campaign_options($selection = 0) {
+ $query_campaigns = "SELECT campaign_id, campaign_name FROM campaigns ORDER BY campaign_id DESC";
+ $campaigns = mysql_query($query_campaigns) or die(mysql_error());
+ $row_campaigns = mysql_fetch_assoc($campaigns);
+ $totalRows_campaigns = mysql_num_rows($campaigns);
+ do { ?>
+ <option <?php if($row_campaigns['campaign_id'] == $selection) { echo "selected='selected' "; } ?> value="<?php echo $row_campaigns['campaign_id']; ?>">
+ <?php echo $row_campaigns['campaign_name']; ?>
+ </option>
+ <?php } while($row_campaigns = mysql_fetch_assoc($campaigns));
+}
+
function display_name($contact) {
if($contact['contact_company'] && $contact['contact_last']) {
return sprintf("%s (%s %s)", $contact['contact_company'], $contact['contact_first'], $contact['contact_last']);
View
10 install.php
@@ -116,13 +116,21 @@
`campaign_id` int(11) default NULL,
`donation_is_cash` BOOL NOT NULL,
`donation_value` DECIMAL(10,2) NOT NULL,
- `donation_status` ENUM('targeted', 'expected', 'pledged', 'received') default 'received',
+ `donation_status` ENUM('expected', 'pledged', 'received') default 'received',
`donation_pledge_date` DATE default NULL,
`donation_received_date` DATE default NULL,
`donation_description` text,
PRIMARY KEY (`donation_id`)
)");
+mysql_query("CREATE TABLE `targets` (
+ `target_id` int(11) NOT NULL auto_increment,
+ `contact_id` int(11) NOT NULL,
+ `campaign_id` int(11) NOT NULL,
+ PRIMARY KEY (`contact_id`, `campaign_id`),
+ UNIQUE KEY (`target_id`)
+)");
+
mysql_query("CREATE TABLE `campaigns` (
`campaign_id` int(11) NOT NULL auto_increment,
`campaign_name` varchar(255) NOT NULL,
Please sign in to comment.
Something went wrong with that request. Please try again.