function action_array($action_KEY) { global $db; $sql = 'select * from action where action_KEY =' . $action_KEY; $A = $db->Execute($sql) or die($sql . $db->errorMsg()); $a = $A->FetchRow(); $added_fields = process_action_fields($action_KEY); $a = array_merge($a, $added_fields); $sql = 'select * from action_content where action_KEY = ' . $action_KEY; $AC = $db->Execute($sql) or die($sql . $db->errorMsg()); $ac = $AC->FetchRow(); if ($ac['action_content_KEY']) { $sql = 'select * from action_content_detail where action_content_KEY =' . $ac['action_content_KEY']; $ACD = $db->Execute($sql) or die($sql . $db->errorMsg()); $acd = $ACD->FetchRow(); $a['action_content_detail_KEY'] = $acd['action_content_detail_KEY']; $a['Recommended_Subject'] = $acd['Recommended_Subject']; $a['Recommended_Content'] = $acd['Recommended_Content']; } $sql = 'select * from action_target where action_KEY = ' . $action_KEY; $AT = $db->Execute($sql) or die($sql . $db->errorMsg()); $at = $AT->GetArray(); $a['action_target'] = $at; foreach ($at as $i) { if ($i['target_KEYS']) { $recipiant_KEYS = explode(',', $i['target_KEYS']); } } if ($recipiant_KEYS) { foreach ($recipiant_KEYS as $i) { $sql = 'select * from recipient where recipient_KEY= ' . $i; $REC = $db->Execute($sql) or die($sql . $db->errorMsg()); $rec = $REC->GetArray(); $a['recipiant'] = $rec; } } if ($a['email_trigger_KEYS']) { $email_trigger_KEYS = explode(',', $a['email_trigger_KEYS']); $x = 0; foreach ($email_trigger_KEYS as $i) { if ($i != '0') { $sql = 'select * from email_trigger where email_trigger_KEY= ' . $i; $ET = $db->Execute($sql) or die($sql . $db->errorMsg()); $et = $ET->FetchRow(); $a['email_trigger'][$x] = $et; $x++; } } } if ($a['add_to_groups_KEYS']) { $add_to_groups_KEYS = explode(',', $a['add_to_groups_KEYS']); $x = 0; foreach ($add_to_groups_KEYS as $i) { if ($i != '0' and $i != NULL) { $sql = 'select * from groups where groups_KEY= ' . $i; $G = $db->Execute($sql) or die($sql . $db->errorMsg() . $sql); $g = $G->FetchRow(); $a['groups'][$x] = $g; $x++; } } } if ($a['tell_a_friend_KEY']) { $sql = 'select * from tell_a_friend where tell_a_friend_KEY =' . $a['tell_a_friend_KEY']; $TAF = $db->Execute($sql) or die($sql . $db->errorMsg()); $taf = $TAF->FetchRow(); $a['tell_a_friend'] = $taf; } $a['referrer'] = action_referrer($action_KEY); $a['partners'] = action_partners($action_KEY); $a['emails'] = action_emails($action_KEY); ## TO DO # add details for triggers ## return $a; }
function action_detail($key) { global $db; $sql = 'select * from action where action_KEY =' . $key; $A = $db->CacheExecute($sql) or die($db->errorMsg()); $a = $A->FetchRow(); echo '<h2>' . $a['Reference_Name'] . '</h2>'; echo '<div class="row">'; echo '<div class="span3">'; echo 'Unique Actions Taken: ' . action_count_distinct($key) . '<br>'; echo 'Actions Taken: ' . action_count($key) . '<br>'; echo '</div>'; echo '<div class="span3">'; $options['slug'] = $a['campaign_slug']; echo 'New Supporters: ' . action_new_supporters($key) . '<br>'; echo 'New Supporters Deliverable: ' . action_new_supporters_deliverable($key) . '<br>'; echo 'Supporter Referrals: ' . action_referrer_supporter($key, $options) . '<br>'; echo '</div>'; echo '<div class="span3">'; echo 'Actions This Week: ' . action_count($key) . '<br>'; echo 'New This Week: ' . action_new_supporters_date($key, LAST_WEEK) . '<br>'; echo 'New Deliverable This Week: ' . action_new_supporters_deliverable_date($key, LAST_WEEK) . '<br>'; echo '</div>'; echo '</div>'; $emails = action_emails($key); $emails_count = action_emails_count($key); $ref = action_referrer($key); $partners = action_partners($key); if ($emails) { $email_blast_options = array('where' => ' and e.email_blast_KEY in (' . $emails . ') '); include '../partials/_email_blast_list.php'; } echo '<h3>Action Sources</h3><div class="row">'; echo '<div class="span4">'; echo '<h4>Codes</h4>'; echo '<table class="table">'; if ($ref) { foreach ($ref as $i) { echo '<tr>'; echo '<td>' . $i['referrer'] . '</td>'; echo '<td>' . $i['count'] . '</td>'; echo '</tr>'; } } echo '</table>'; echo '</div>'; echo '<div class="span4">'; echo '<h4>Emails</h4>'; echo '<table class="table">'; if ($emails_count) { foreach ($emails_count as $i) { echo '<tr>'; echo '<td><a href="../object.php?object=email_blast&key=' . $i['email_blast_KEY'] . '">' . get_email_blasts_name($i['email_blast_KEY']) . '</a></td>'; echo '<td>' . $i['count'] . '</td>'; echo '</tr>'; } } echo '</table>'; echo '</div>'; if ($partners) { echo '<div class="span4">'; echo '<h4>Partners</h4><br>'; echo '<table class="table">'; foreach ($partners as $i) { if ($i['partner_code']) { echo '<tr>'; echo '<td>' . $i['partner_code'] . '</td>'; echo '<td>' . $i['count'] . '</td>'; echo '</tr>'; } } echo '</table>'; echo '</div>'; } echo '</div>'; $tell_a_friend_options['where'] = ' where action_KEY = "' . $key . '" '; include '../partials/_tell_a_friend_list.php'; $sql = 'select supporter_KEY, count(supporter_KEY) as count from supporter_action where referrer_supporter_KEY >0 and supporter_KEY != referrer_supporter_KEY and action_KEY = ' . $key . ' group by supporter_KEY order by count desc'; $Rec = $db->CacheExecute($sql) or die($db->errorMsg()); $rec = $Rec->GetArray(); echo '<h3>Recuritment</h3>'; foreach ($rec as $i) { echo $i['count'] . ' <a href="/supporter.php?supporter_KEY=' . $i['supporter_KEY'] . '">' . get_supporter_name($i['supporter_KEY']) . '</a> ' . '<br>'; } echo '<h3>Action Links</h3>'; action_links($a['campaign_slug']); $sql = "select count(distinct supporter_KEY) as count from supporter_action where personal_petition=1 and action_KEY =" . $key; $Per = $db->CacheExecute($sql) or die($db->errorMsg() . $sql); $per = $Per->FetchRow(); $sql = "select count(distinct personal_petition_supporter_KEY) as count from supporter_action where personal_petition_supporter_KEY >0 and action_KEY =" . $key; $Per_Ct = $db->CacheExecute($sql) or die($db->errorMsg() . $sql); $per_ct = $Per_Ct->FetchRow(); if ($per['count'] > 0) { echo '<h3>Personal Petitions</h3>'; echo '<strong>Petitions Started:</strong>: ' . $per['count']; echo '<strong>Petitions Signatures Generated:</strong>: ' . $per_ct['count']; $sql = "select distinct supporter_KEY from supporter_action where personal_petition=1 and action_KEY =" . $key; $Pet = $db->CacheExecute($sql) or die($db->errorMsg() . $sql); $pet = $Pet->FetchRow(); foreach ($pet as $i) { #echo '<td><a href="'.ACTION_URL.$a['campaign_slug'].'/">'.$i['supporter_KEY'].'</a></td>'; } } }