Permalink
Browse files

Add Contact Count to unmatched screen, Date updates

  • Loading branch information...
1 parent 4a0e4c8 commit 96f492e71cc537cfcbeda1ac719291b40aa85a23 @stefancrain stefancrain committed Jan 24, 2013
@@ -209,12 +209,45 @@ public static function getUnmatchedMessages() {
$ids = imap_search($imap->conn(),"",SE_UID);
$headers = imap_fetch_overview($imap->conn(),implode(',',$ids),FT_UID);
+ $checked = array();
+
// Loop through the headers and check to make sure they're valid UIDs
foreach($headers as $header) {
if( in_array($header->uid,$ids)) {
// Get the message based on the UID of the header.
$email = $imap->getmsg_uid($header->uid);
$output = self::unifiedMessageInfo($email);
+
+ if($output['forwarded']['origin_email']){
+ // Don't double check email addresses
+ if(!$checked[$output['forwarded']['origin_email']] ){
+ // leaving civi here for records, it was really really slow
+ // $params = array('version' => 3, 'contact' => 'get', 'email' => $output['forwarded']['origin_email'] );
+ // $contact = civicrm_api('contact', 'get', $params);
+
+ // lets reuse the search function
+ $email = $output['forwarded']['origin_email'];
+ $Query="SELECT contact.id, email.email FROM civicrm_contact contact
+ LEFT JOIN civicrm_email email ON (contact.id = email.contact_id)
+WHERE contact.is_deleted=0
+ AND email.email LIKE '$email'
+GROUP BY contact.id
+ORDER BY contact.id ASC, email.is_primary DESC";
+
+ $result = mysql_query($Query, self::db());
+ $results = array();
+ while($row = mysql_fetch_assoc($result)) {
+ $results[] = $row;
+ }
+
+
+ $checked[$output['forwarded']['origin_email']] = count($results);
+ }
+ }else{
+ $checked[''] = 0;
+ }
+
+
if ($output['code'] == "SUCCESS"){
$returnMessage[$header->uid] = array(
'subject' => $output['forwarded']['subject'],
@@ -226,6 +259,7 @@ public static function getUnmatchedMessages() {
'from_email' => $output['forwarded']['origin_email'],
'from_name' => $output['forwarded']['origin_name'],
'forwarder_email' => $output['header']['from_email'],
+ 'match_count'=> $checked[$output['forwarded']['origin_email']],
// 'forwarder_name' => $output['header']['from_name'],
// 'forwarder_time' => $output['forwarded']['date_clean'],
'attachmentfilename' => $output['attachments'][0]['name'],
@@ -237,7 +271,7 @@ public static function getUnmatchedMessages() {
);
}else{
- $returnMessage = array('code' => 'ERROR','message'=>$header->uid." on {$name}");
+ // $returnMessage = array('code' => 'ERROR','message'=>$header->uid." on {$name}");
}
@@ -380,9 +414,9 @@ public static function cleanDate($date_string, $type){
return date("M d, Y", strtotime($date_string_short));
}else{
if ( (date("d", strtotime($date_string_short)) - date("d")) < 0 ){
- return date("M d @ h:i A", strtotime($date_string_short));
+ return date("M d h:iA", strtotime($date_string_short));
}else{
- return 'Today @ '.date("h:i A", strtotime($date_string_short));
+ return 'Today '.date("h:iA", strtotime($date_string_short));
}
}
}
@@ -94,9 +94,11 @@ a.tag-selected:hover { color: #fff!important; background-color: red; }
.imapper-address-select-box {height: 16px;width: 20px;float: left;padding: 15px 0px;}
.imapper-address-box {float: left;width: 215px;padding-left: 5px;}
.clear {clear: both;}
-.emailbubble {padding: 2px 4px;border-radius: 3px 3px 3px 3px;}
+.emailbubble,.matchbubble {padding: 2px 4px;border-radius: 3px 3px 3px 3px;}
.marginL10 {margin-left: 10px;}
-.emailbubble, .name .badge {background-color: #999999; color: #FFFFFF;display: inline-block;font-size: 11.844px;font-weight: bold; line-height: 14px;padding: 2px 4px; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); vertical-align: baseline;white-space: nowrap;}
+.emailbubble, .name .badge,.matchbubble {background-color: #999999; color: #FFFFFF;display: inline-block;font-size: 11.844px;font-weight: bold; line-height: 14px;padding: 2px 4px; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); vertical-align: baseline;white-space: nowrap;}
+.matchbubble {background-color: #457AA4; color: #FFFFFF;}
+
.imapper-message-box td { vertical-align: middle!important; }
#message_right label{float: left;display: block;}
.label_def{width: 95px;font-weight: bold;float: left;margin: 0.4em 0 0.02em;}
@@ -945,11 +945,14 @@ function buildMessageList() {
if( value.from_email != '' && value.from_email != null){
messagesHtml += '<span class="emailbubble marginL10">'+short_subject(value.from_email,15)+'</span>';
+ messagesHtml += '<span class="matchbubble marginL10" title="This email address matches '+value.match_count+' Records in bluebird ">'+value.match_count+'</span>';
}
messagesHtml +='</td>';
}else if( value.from_email != '' && value.from_email != null ){
- messagesHtml += '<td class="name"><span class="emailbubble">'+short_subject(value.from_email,25)+'</span></td>';
+ messagesHtml += '<td class="name"><span class="emailbubble">'+short_subject(value.from_email,25)+'</span>';
+ messagesHtml += '<span class="matchbubble marginL10" title="This email address matches '+value.match_count+' Records in bluebird ">'+value.match_count+'</span></td>';
+
}else {
messagesHtml += '<td class="name">N/A</td>';
}
@@ -971,7 +974,7 @@ function buildMessageList() {
messagesHtml += '<td class="forwarder"> N/A </td>';
}
- messagesHtml += '<td class="Actions"><span class="find_match"><a href="#">Find match</a></span> | <span class="delete"><a href="#">Delete</a></span></td> </tr>';
+ messagesHtml += '<td class="Actions"><span class="find_match"><a href="#">Find match </a></span> | <span class="delete"><a href="#">Delete</a></span></td> </tr>';
}
});
cj('#imapper-messages-list').html(messagesHtml);

0 comments on commit 96f492e

Please sign in to comment.