+ " AND companionship=".$unique_companionships[$j]['companionship'].
+ " AND family=". $family_id;
+ $query_id = $this->db2->query($sql,__LINE__,__FILE__);
+ if($this->db2->num_rows($query_id) == 0) {
+ // We did not find any visits made by the currently assigned companionship,
+ // look for visits made by any other companionship other than 0. (0 == EQ Presidency Visit)
+ $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ".
+ " AND companionship!=0".
+ " AND family=". $family_id;
+ $query_id = $this->db2->query($sql,__LINE__,__FILE__);
+ }