convertArrayToSqlString($contactIDs); $sql = "select ph.contact_id, ph.phone , ph.is_primary, lt.display_name as location_type_label, ov.label as phone_type_label FROM civicrm_phone ph LEFT JOIN civicrm_location_type lt ON ph.location_type_id = lt.id , civicrm_option_value ov , civicrm_option_group og WHERE ph.contact_id IN ( ".$sql_cids." ) AND ph.phone_type_id = ov.value AND ov.option_group_id = og.id AND og.name = 'phone_type' ORDER BY ph.contact_id" ; // print "\n\n

sql: ".$sql; $dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ; $first = true; $prev_cid = ""; while($dao->fetch()){ //print "\n\n
Inside while loop"; $cid = $dao->contact_id ; $phone = $dao->phone; $is_primary = $dao->is_primary; $location_type_label = $dao->location_type_label; $phone_type_label = $dao->phone_type_label; if(strcmp( $is_primary, '1') == 0 ){ $is_primary_formatted = 'Yes'; }else{ $is_primary_formatted = 'No'; } if( strcmp($cid, $prev_cid ) <> 0 ){ // First phone for this contact $values[$cid][$token_needed] = ""; // wrap up token for prev. cid if( strcmp( $prev_cid, "") <> 0){ $values[$prev_cid][$token_needed] = $values[$prev_cid][$token_needed]."
Number Is Primary?LocationPhone Type
"; } } // add the data for this child to this parent's token $values[$cid][$token_needed] = $values[$cid][$token_needed]."$phone". "$is_primary_formatted$location_type_label$phone_type_label"; $prev_cid = $cid; } $dao->free(); if( strcmp( $prev_cid, "") <> 0){ $values[$prev_cid][$token_needed] = $values[$prev_cid][$token_needed].""; } } function getTableOfEmails(&$contactIDs, &$values, &$token_needed){ require_once('utils/CustomSearchTools.php'); $tmp = new CustomSearchTools(); $sql_cids = $tmp->convertArrayToSqlString($contactIDs); $sql = "select em.contact_id, em.email , em.is_primary, lt.display_name as location_type_label FROM civicrm_email em LEFT JOIN civicrm_location_type lt ON em.location_type_id = lt.id WHERE em.contact_id IN ( ".$sql_cids." ) ORDER BY em.contact_id" ; // print "\n\n

sql: ".$sql; $dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ; $first = true; $prev_cid = ""; while($dao->fetch()){ //print "\n\n
Inside while loop"; $cid = $dao->contact_id ; $email = $dao->email; $is_primary = $dao->is_primary; $location_type_label = $dao->location_type_label; if(strcmp( $is_primary, '1') == 0 ){ $is_primary_formatted = 'Yes'; }else{ $is_primary_formatted = 'No'; } if( strcmp($cid, $prev_cid ) <> 0 ){ // First phone for this contact $values[$cid][$token_needed] = ""; // wrap up token for prev. cid if( strcmp( $prev_cid, "") <> 0){ $values[$prev_cid][$token_needed] = $values[$prev_cid][$token_needed]."
Email Is Primary?Location
"; } } // add the data for this child to this parent's token $values[$cid][$token_needed] = $values[$cid][$token_needed]."$email". "$is_primary_formatted$location_type_label"; $prev_cid = $cid; } $dao->free(); if( strcmp( $prev_cid, "") <> 0){ $values[$prev_cid][$token_needed] = $values[$prev_cid][$token_needed].""; } } }