Added new elder_id field to the family table.
authorAlan Jack Pippin <ajp@pippin.(none)>
Mon, 8 Jan 2007 04:50:03 +0000 (21:50 -0700)
committerAlan J. Pippin <ajp@pippins.net>
Mon, 8 Jan 2007 04:50:03 +0000 (21:50 -0700)
Changed yearly visit search criteria on family table to only match families with elders in them.

import_ward_data
inc/class.eq.inc.php

index 423223b458721dcaf4b0f507a79087f926e23206..5d9b7546b37f2f6d6988ddc775aff87230da0306 100755 (executable)
@@ -351,6 +351,7 @@ sub update_eq_companionship_table
 #| hofh_id       | int(16) unsigned | YES  |     | NULL    |       |
 #| name          | varchar(30)      | YES  |     | NULL    |       |
 #| name_id       | varchar(30)      | YES  |     | NULL    |       |
+#| elder_id      | int(16) unsigned | YES  |     | NULL    |       |
 #| companionship | int(16) unsigned | YES  |     | NULL    |       |
 #| visit_pri     | int(10) unsigned | YES  |     | 1       |       |
 #| visit_notes   | varchar(128)     | YES  |     | NULL    |       |
@@ -386,7 +387,7 @@ sub update_eq_family_table
                if($rows == 0) {
                    # No existing records found for this family, make a new entry
                    print "   Adding new Family: $family_name\n";
-                   $sth = $dbh->prepare("insert into eq_family values (NULL,$id,'$family_name','$name_id','0',1,1,'')");
+                   $sth = $dbh->prepare("insert into eq_family values (NULL,$id,'$family_name','$name_id','0','0',1,1,'')");
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
                } elsif($rows == 1) {
                    # An existing record was found for this family, update it
@@ -399,6 +400,17 @@ sub update_eq_family_table
                    # More than one record was found. Error! This shouldn't happen.
                    print "   -E- More than one record found ($rows) for family name: $family_name\n";
                }
+
+                # Now update the elder_id field for this family
+               $sth = $dbh->prepare("select * from eq_elder WHERE name='$family_name'");
+               $sth->execute or die "-E- DB error: $DBI::errstr\n";
+               while($sqlhashref = $sth->fetchrow_hashref) {
+                   $elder_id = $sqlhashref->{elder};
+                   print "   Updating family elder_id: $family_name -> $elder_id\n";
+                   $sth = $dbh->prepare("update eq_family set elder_id=$elder_id where name_id='$name_id'");
+                   $sth->execute or die "-E- DB error: $DBI::errstr\n";
+               }
+               
                # Now update the hometeaching field for this family
                foreach $index (keys %hometeaching_data)
                {
index 8802e7565f413db6ea75cbcb1a02e27727112fd9..8058a9dd91d6886394675078f11cb6fadb8a721a 100644 (file)
@@ -1191,7 +1191,7 @@ class eq
       $appt_table_data = ""; 
 
       // create the family id -> family name mapping
-      $sql = "SELECT * FROM eq_family where valid=1 and companionship != 0 ORDER BY name ASC";
+      $sql = "SELECT * FROM eq_family where valid=1 and elder_id != 0 ORDER BY name ASC";
       $this->db->query($sql,__LINE__,__FILE__);
       $i=0;
       $family_id = NULL;
@@ -1247,7 +1247,7 @@ class eq
 
       
       // VISIT SCHEDULING TABLE
-      $sql = "SELECT * FROM eq_family where valid=1 and companionship != 0 ORDER BY visit_pri ASC";
+      $sql = "SELECT * FROM eq_family where valid=1 and elder_id != 0 ORDER BY visit_pri ASC";
       $this->db->query($sql,__LINE__,__FILE__);
 
       $total_families=0; $families_with_yearly_visit=0;
@@ -2496,7 +2496,7 @@ class eq
        }
       array_multisort($elder_name, $elder_id);
 
-      $sql = "SELECT * FROM eq_family where valid=1 and companionship != 0 ORDER BY name ASC";
+      $sql = "SELECT * FROM eq_family where valid=1 and elder_id != 0 ORDER BY name ASC";
       $this->db->query($sql,__LINE__,__FILE__);
       $i=0;
       while ($this->db->next_record())
@@ -2680,7 +2680,10 @@ class eq
        {        
          $target_path = $this->upload_target_path . basename( $_FILES['uploadedfile']['name']);
          
-         if((($_FILES['uploadedfile']['type'] == "application/zip") || ($_FILES['uploadedfile']['type'] == "application/x-zip-compressed")) &&
+         if((($_FILES['uploadedfile']['type'] == "application/zip") ||
+             ($_FILES['uploadedfile']['type'] == "application/x-zip-compressed") ||
+             ($_FILES['uploadedfile']['type'] == "application/x-zip") ||
+             ($_FILES['uploadedfile']['type'] == "application/octet-stream")) &&
             (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))) {
            $uploadstatus = "<b>The following file was uploaded successfully: </b><br><br>";
            $uploadstatus.= "Filename : " . $_FILES['uploadedfile']['name'] . "<br>";
@@ -2762,7 +2765,9 @@ class eq
            print "</pre></td></tr></table>";
            
          } else if(($_FILES['uploadedfile']['type'] != "application/zip") &&
-                   ($_FILES['uploadedfile']['type'] != "application/x-zip-compressed")) {
+                   ($_FILES['uploadedfile']['type'] != "application/x-zip-compressed") &&
+                   ($_FILES['uploadedfile']['type'] != "application/x-zip") &&
+                   ($_FILES['uploadedfile']['type'] != "application/octet-stream")) {
            $uploadstatus = "<b><font color=red>The file format must be a .zip file, please try again! </font></b>";
            $uploadstatus.= "<br><br><b>Detected file format: " . $_FILES['uploadedfile']['type'] . "</b>";
            $this->t->set_var('uploadstatus',$uploadstatus);