Merge branch 'master' of git@github.com:apippin/tc
authorAlan Pippin <apippin@pippins.net>
Mon, 11 Oct 2010 18:33:32 +0000 (12:33 -0600)
committerAlan J. Pippin <ajp@pippins.net>
Mon, 11 Oct 2010 18:33:32 +0000 (12:33 -0600)
1  2 
inc/class.tc.inc.php
templates/default/ppi_sched.tpl

diff --combined inc/class.tc.inc.php
index f07b9b936a2f0d12ca5b4f19ae71170ebe06fd33,b87659f9364913279bd5d2436baae07e33630768..7f2700edac40282d17acb9c66432d995ac87c036
@@@ -35,6 -35,7 +35,7 @@@ class t
        var $script_path;
        var $max_appointments;
        var $max_presidency_members;
+       var $ppi_frequency_label;
  
        var $public_functions = array
        (
                $this->current_month = $this->current_month-0; // Make it numeric
                $this->current_year = `date '+%Y'`;
                $this->current_year = $this->current_year-0; // Make it numeric
+               
+               if ($this->ppi_frequency == 12) {
+                       $this->ppi_frequency_label = "Annual";
+               } else if ($this->ppi_frequency == 6) {
+                       $this->ppi_frequency_label = "Semi-Annual";
+               } else if ($this->ppi_frequency == 3) {
+                       $this->ppi_frequency_label = "Quarterly";
+               } else if ($this->ppi_frequency == 1) {
+                       $this->ppi_frequency_label = "Monthly";
+               } else {
+                       $this->ppi_frequency_label = "Periodic";
+               }
  
                echo parse_navbar();
                $this->display_app_header();    
                $this->t->set_var('assignment_data',$assignment_data);
  
                // Create individual selection boxes
-               $sql = "SELECT * FROM tc_individual WHERE steward='$this->default_stewardship'";
+               $sql = "SELECT * FROM tc_individual";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {
                $this->t->set_var('lang_reset','Clear Changes');
  
                $this->t->set_var('ppi_link',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ppi_view'));
-               $this->t->set_var('ppi_link_title','Yearly PPIs');
+               $this->t->set_var('ppi_link_title',$this->ppi_frequency_label . ' PPIs');
  
                $this->t->set_var('schedule_ppi_link',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ppi_sched'));
-               $this->t->set_var('schedule_ppi_link_title','Schedule Yearly PPIs');
+               $this->t->set_var('schedule_ppi_link_title','Schedule ' . $this->ppi_frequency_label . ' PPIs');
  
                $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ppi_sched&action=save'));
-               $this->t->set_var('title','Yearly PPI Scheduler');
+               $this->t->set_var('title',$this->ppi_frequency_label . ' PPI Scheduler');
  
                $indiv_width=500; $phone_width=25; $pri_width=10; $notes_width=128; $ppi_date_width=20;
                $table_width=$indiv_width + $phone_width + $pri_width + $notes_width + $ppi_date_width;
                $table_data=""; $completed_data=""; $totals_data="";
  
                $year = date('Y');
+               $month = date('m');
+               $period = intval(($month-1)/$this->ppi_frequency) + 1;
+               $start_of_period = ($period-1)*$this->ppi_frequency + 1;
+               $end_of_period = $period * $this->ppi_frequency;
  
                if($action == 'save') {
                        // Save any changes made to the appointment table
                  // Display a scheduling table for this presidency member
                  $district_number = '*';
                  $district_name = $presidency_name;
-                 $table_title = "District ".$district_number.": ".$district_name.": All indivs with Yearly PPI Not Completed";
-                 $appt_table_title = "District ".$district_number.": ".$district_name.": Yearly PPI Appointment Slots";
-                 $this->t->set_var('table_title',$table_title);
+                 $not_completed_table_title = "District ".$district_number.": ".$district_name.": All indivs with " . $this->ppi_frequency_label . " PPI Not Completed";
+                 $appt_table_title = "District ".$district_number.": ".$district_name.": ".$this->ppi_frequency_label." PPI Appointment Slots";
+                 $this->t->set_var('not_completed_table_title',$not_completed_table_title);
                  $this->t->set_var('appt_table_title',$appt_table_title);
  
                  // query the database for all the appointments
                  $this->t->set_var('appt_table_data',$appt_table_data);
                  $this->t->set_var('appt_header_row',$appt_header_row);
                  $this->t->set_var('appt_table_width',$appt_table_width);
 +                        $this->t->set_var('lang_save','Save Appts for ' . $presidency_name);
 +
                  $this->t->fp('apptlist','appt_list',True);
                }
                
                }
  
                $max = count($individual);
+               
                for($i=0; $i < $max; $i++) {
                        $id = $individual[$i];
                        $name = $indiv_name[$i];
                        $priority = $indiv_priority[$id];
                        $notes = $indiv_notes[$id];
  
-                       // If this individual has had a yearly PPI this year, don't show him on the schedule list
-                       $year_start = $year - 1 . "-12-31"; $year_end = $year + 1 . "-01-01";
-                       $sql = "SELECT * FROM tc_interview WHERE date > '$year_start' AND date < '$year_end' ".
+                       // If this individual has had a PPI this period, don't show him on the schedule list
+                       $year_start = $year . "-" . $start_of_period . "-01";
+                       $year_end = $year . "-" . $end_of_period . "-31";
+                       $sql = "SELECT * FROM tc_interview WHERE date >= '$year_start' AND date <= '$year_end' ".
                               "AND individual=" . $id . " AND interview_type='ppi' ORDER BY date DESC";
                        $this->db2->query($sql,__LINE__,__FILE__);
  
                        }
                } // End for individuals Loop
  
+               $completed_table_title = "District ".$district_number.": ".$district_name.": All indivs with " . $this->ppi_frequency_label . " PPI Completed";
                $name_width=175; $phone_width=100; $date_width=100; $notes_width=300;
                $completed_table_width=$name_width + $phone_width + $date_width + $notes_width;
                $completed_header_row = "<th width=$name_width><font size=-2>Individual</th>";
                $completed_header_row.= "<th width=$date_width><font size=-2>Date</th>";
                $completed_header_row.= "<th width=$notes_width><font size=-2>PPI Notes</th>";
  
+               $this->t->set_var('completed_table_title',$completed_table_title);
                $this->t->set_var('table_width',$table_width);
                $this->t->set_var('header_row',$header_row);
                $this->t->set_var('table_data',$table_data);
                $this->t->set_var('completed_header_row',$completed_header_row);
                $this->t->set_var('completed_table_width',$completed_table_width);
                $this->t->set_var('completed',$completed_data);
 +              $this->t->set_var('lang_save','Save Pri / Notes'); 
                $this->t->fp('indivlist','individual_list',True); 
  
                $indivs_width=300; $totals_width=100;
                $totals_header_row = "<th width=$indivs_width><font size=-2>Individuals</th>";
                $totals_header_row.= "<th width=$totals_width><font size=-2>$year</th>";
                $totals_data.= "<tr bgcolor=". $this->t->get_var('tr_color') .">";
-               $totals_data.= "<td align=left><font size=-2><b>Total Individuals with yearly PPIs completed:</b></font></td>";
+               $totals_data.= "<td align=left><font size=-2><b>Total Individuals with " . $this->ppi_frequency_label . " PPIs completed:</b></font></td>";
                $totals_data.= "<td align=center><font size=-2><b>$indivs_with_yearly_ppi / $total_indivs</b></font></td>";
                $percent = ceil(($indivs_with_yearly_ppi / $total_indivs)*100);
                $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
                $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ppi_view'));
  
                $this->t->set_var('ppi_link',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ppi_view'));
-               $this->t->set_var('ppi_link_title','Yearly PPIs'); 
+               $this->t->set_var('ppi_link_title',$this->ppi_frequency_label . ' PPIs'); 
  
                $this->t->set_var('schedule_ppi_link',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ppi_sched'));
-               $this->t->set_var('schedule_ppi_link_title','Schedule Yearly PPIs');
+               $this->t->set_var('schedule_ppi_link_title','Schedule ' . $this->ppi_frequency_label . ' PPIs');
  
-               $this->t->set_var('title','Yearly PPIs');
+               $this->t->set_var('title',$this->ppi_frequency_label . ' PPIs');
                $num_months = get_var('num_months',array('GET','POST'));
                if($num_months == '') { $num_months = $this->default_ppi_num_years; }
                $this->t->set_var('num_months',$num_months);
                $this->t->set_var('schedule_int_link_title','Schedule Hometeaching Interviews');
  
                $this->t->set_var('schedule_ppi_link',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ppi_sched'));
-               $this->t->set_var('schedule_ppi_link_title','Schedule Yearly PPIs');
+               $this->t->set_var('schedule_ppi_link_title','Schedule ' . $this->ppi_frequency_label . ' PPIs');
  
                $date_width=160; $time_width=220; $indiv_width=170; $family_width=180; $location_width=100;
                $table_width=$date_width + $time_width + $indiv_width + $family_width + $location_width;
index 191a9a2aa76cb7c87157cda9c1b321429a6e4c1b,5a54af0713fbb7ae545c19dfc0e3f3b182b1869c..f694d4fd89d17fd3cb5c3ac8f1cfea5cf50722ee
@@@ -1,4 -1,5 +1,4 @@@
  <center>
 -      <form action="{actionurl}" method="POST">
        <table border="0" width="{table_width}" cellspacing="2" cellpadding="2">
                <tr>
                        <td align="center" bgcolor="#c9c9c9"><font face="{font}"><b>{title}</b></font></td>
        <a href="{schedule_ppi_link}">{schedule_ppi_link_title}</a>
        <br><br>
  
 -
 +<hr>
  <!-- BEGIN appt_list -->
        <form action="{actionurl}" method="POST">
                <input type=hidden name=presidency_location value={presidency_location}>
 -        <hr>
          <table border="0" width="{appt_table_width}" cellspacing="2" cellpadding="2">
                <tr>
                        <td align="center" bgcolor="#c9c9c9" colspan=20>
                        <font face="{font}"><input type="submit" name="save" value="{lang_save}"></font>
                        &nbsp; &nbsp;
                        <font face="{font}"><input type="reset" name="reset" value="{lang_reset}"></font>
 -                      </form>
                </td>
                </tr>
        </table>
 +      </form>
  <!-- END appt_list -->
 -
 +<hr>
  <!-- BEGIN individual_list -->
 +        <form action="{actionurl}" method="POST">
        <table border="0" width="{table_width}" cellspacing="2" cellpadding="2">
 +                      <tr>
 +                      <td colspan=5 height="50" align="right">
 +                              <font face="{font}"><input type="submit" name="save" value="{lang_save}"></font>
 +                              &nbsp; &nbsp;
 +                              <font face="{font}"><input type="reset" name="reset" value="{lang_reset}"></font>
 +                      </td>
 +              </tr>
                <tr>
                        <td align="center" bgcolor="#c9c9c9" colspan=20>
-                               <font face="{font}"><b>{table_title}</b></font>
+                               <font face="{font}"><b>{not_completed_table_title}</b></font>
                        </td>
                </tr>
                <tr bgcolor="#c9c9c9"><font face="{font}">{header_row}</tr>
                        <font face="{font}"><input type="submit" name="save" value="{lang_save}"></font>
                        &nbsp; &nbsp;
                        <font face="{font}"><input type="reset" name="reset" value="{lang_reset}"></font>
 -                      </form>
                </td>
                </tr>
        </table>
 +        </form>
  <!-- END individual_list -->
        <hr>
        <table border="0" width="{completed_table_width}" cellspacing="2" cellpadding="2">
                <tr>
                        <td align="center" bgcolor="#c9c9c9" colspan=20>
-                       <font face="{font}"><b>All Individuals with Yearly PPI Completed</b></font>
+                       <font face="{font}"><b>{completed_table_title}</b></font>
                        </td>
                </tr>
                <tr bgcolor="#c9c9c9"><font face="{font}">{completed_header_row}</tr>