+ $companionship_changed = 0;
+
+ // get current companion list
+ $sql = "SELECT * FROM tc_companion_sandbox AS tc JOIN tc_individual AS ti WHERE tc.companionship=$companionship AND tc.individual=ti.individual";
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $companion_names = "";
+ while ($this->db2->next_record()) {
+ if ($companion_names == "") {
+ $companion_names .= $this->db2->f('name');
+ } else {
+ $companion_names .= " / " . $this->db2->f('name');
+ }
+ }
+
+ // list removed companions
+ $sql = "SELECT * FROM tc_companion AS tc JOIN tc_individual AS ti WHERE tc.companionship=$tc_companionship AND tc.individual=ti.individual AND tc.individual NOT IN (SELECT individual FROM tc_companion_sandbox WHERE companionship=$companionship)";
+ $this->db2->query($sql,__LINE__,__FILE__);
+ while ($this->db2->next_record()) {
+ if ($companionship_changed == 0) {
+ $companionship_changed = 1;
+ $email_contents .= "\t$companion_names\r\n";
+ }
+ $name = $this->db2->f('name');
+ $email_contents .= "\t\tremoved $name as a companion\r\n";
+ }
+
+ // list added companions
+ $sql = "SELECT * FROM tc_companion_sandbox AS tcs JOIN tc_individual AS ti WHERE tcs.companionship=$companionship AND tcs.individual=ti.individual AND tcs.individual NOT IN (SELECT individual FROM tc_companion WHERE companionship=$tc_companionship)";
+ $this->db2->query($sql,__LINE__,__FILE__);
+ while ($this->db2->next_record()) {
+ if ($companionship_changed == 0) {
+ $companionship_changed = 1;
+ $email_contents .= "\t$companion_names\r\n";
+ }
+ $name = $this->db2->f('name');
+ $email_contents .= "\t\tadded $name as a companion\r\n";
+ }