Fixed initialization issue with unique_companionships array
[eq/.git] / inc / class.eq.inc.php
index 9b59778a16192a093c58ed19d00f7b3c79536323..c7601008cc1bcb0f13c2cba2fcc2598999e22d81 100644 (file)
@@ -235,12 +235,11 @@ class eq
        $this->t->set_var('district_number',$districts[$i]['district']);
        $this->t->set_var('district_name',$districts[$i]['name']);      
        $supervisor = $districts[$i]['supervisor'];
-       $unique_companionships='';
                
        // Select all the unique companionship numbers for this district
        $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $districts[$i]['district'];
        $this->db->query($sql,__LINE__,__FILE__);
-       $j=0;
+       $j=0; $unique_companionships = '';
        while ($this->db->next_record())
          {
            $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
@@ -418,7 +417,7 @@ class eq
          // Get a list of all the companionships in this district
          $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $district;
          $this->db->query($sql,__LINE__,__FILE__);
-         $j=0;
+         $j=0; $unique_companionships = '';
          while ($this->db->next_record())
            {
              $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
@@ -485,7 +484,7 @@ class eq
       // Select all the unique companionship numbers for this district
       $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $district;
       $this->db->query($sql,__LINE__,__FILE__);
-      $j=0; $unique_companionships='';
+      $j=0; $unique_companionships = '';
       while ($this->db->next_record())
        {
          $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
@@ -1921,7 +1920,7 @@ class eq
       // Select all the unique companionship numbers for this district
       $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $districts[$d]['district'];
       $this->db->query($sql,__LINE__,__FILE__);
-      $j=0;
+      $j=0; $unique_companionships = '';
       while ($this->db->next_record())
        {
          $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
@@ -2554,15 +2553,22 @@ class eq
       $date = get_var('date',array('GET','POST'));
       $notes = get_var('notes',array('GET','POST'));
       $eqpresppi = get_var('eqpresppi',array('GET','POST'));
-      
-      $sql = "SELECT * FROM eq_elder WHERE elder=" . $interviewer;
+     
+      $sql = "SELECT * FROM eq_presidency where valid=1 and (president=1 or counselor=1 or secretary=1)";
       $this->db2->query($sql,__LINE__,__FILE__);
-      $this->db2->next_record();
-      $interviewer_name = $this->db2->f('name');
-      $this->t->set_var('interviewer',$interviewer . ' selected');
-      $this->t->set_var('interviewer_name',$interviewer_name);
-      $this->t->set_var('eqpresppi_checked','');
-      $this->t->fp('int_list','interviewer_list',True);
+      while ($this->db2->next_record())
+      {
+        $elder = $this->db2->f('elder');
+       $interviewer_name = $this->db2->f('name');
+        if($elder == $interviewer) { 
+          $this->t->set_var('interviewer',$interviewer . ' selected');
+        } else {
+         $this->t->set_var('interviewer',$interviewer);
+       }
+        $this->t->set_var('interviewer_name',$interviewer_name);
+        $this->t->set_var('eqpresppi_checked','');
+        $this->t->fp('int_list','interviewer_list',True);
+      }
     
       if($action == 'save')
        {
@@ -2728,13 +2734,11 @@ class eq
        $this->t->set_var('district_number',$districts[$i]['district']);
        $this->t->set_var('district_name',$districts[$i]['name']);      
        $supervisor = $districts[$i]['supervisor'];
-       $unique_companionships='';
                
        // Select all the unique companionship numbers for this district
        $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $districts[$i]['district'];
-
        $this->db->query($sql,__LINE__,__FILE__);
-       $j=0;
+       $j=0; $unique_companionships = '';
        while ($this->db->next_record())
          {
            $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
@@ -2886,25 +2890,21 @@ class eq
       $date = get_var('date',array('GET','POST'));
       $notes = get_var('notes',array('GET','POST'));
       $eqpresppi = get_var('eqpresppi',array('GET','POST'));
-      
-      $sql = "SELECT * FROM eq_district where valid=1 ORDER BY district ASC";
-      $this->db->query($sql,__LINE__,__FILE__);
-      while ($this->db->next_record())
-       {
-         $supervisor = $this->db->f('supervisor');
-         $sql = "SELECT * FROM eq_elder WHERE elder=" . $supervisor;
-         $this->db2->query($sql,__LINE__,__FILE__);
-         $this->db2->next_record();
-         $interviewer_name = $this->db2->f('name');
-         
-         if($supervisor == $interviewer) { 
-           $this->t->set_var('interviewer',$supervisor . ' selected');
-         } else {
-           $this->t->set_var('interviewer',$interviewer);
-         }
-         $this->t->set_var('interviewer_name',$interviewer_name);
-         $this->t->fp('int_list','interviewer_list',True);
-       }
+
+      $sql = "SELECT * FROM eq_presidency where valid=1 and (president=1 or counselor=1 or secretary=1 or district!=0)";
+      $this->db2->query($sql,__LINE__,__FILE__);
+      while ($this->db2->next_record())
+      {
+        $elder = $this->db2->f('elder');
+        $interviewer_name = $this->db2->f('name');
+        if($elder == $interviewer) {
+          $this->t->set_var('interviewer',$interviewer . ' selected');
+        } else {
+          $this->t->set_var('interviewer',$interviewer);
+        }
+        $this->t->set_var('interviewer_name',$interviewer_name);
+        $this->t->fp('int_list','interviewer_list',True);
+      }
       
       if($action == 'save')
        {
@@ -4050,6 +4050,12 @@ class eq
            if(!move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
              $uploadstatus = "<b><font color=red> -E- Unable to move the uploaded file to ";
              $uploadstatus.= "the target path (check the path and permissions) of: $target_path</font></b>";
+             $uploadstatus = "<b>The following file was uploaded successfully: </b><br><br>";
+             $uploadstatus.= "Tmp Filename : " . $_FILES['uploadedfile']['tmp_name'] . "<br>";
+             $uploadstatus.= "Filename     : " . $_FILES['uploadedfile']['name'] . "<br>";
+             $uploadstatus.= "Type         : " . $_FILES['uploadedfile']['type'] . "<br>";
+             $uploadstatus.= "Size         : " . $_FILES['uploadedfile']['size'] . "<br>";
+             $uploadstatus.= "Error        : " . $_FILES['uploadedfile']['error'] . "<br>";     
              $this->t->set_var('uploadstatus',$uploadstatus);
              $this->t->pfp('uploadhandle','upload',True);
              return 0;