$sth->finish();
}
+# EQ_CALLING
+#+--------------+------------------+------+-----+---------+-------+
+#| Field | Type | Null | Key | Default | Extra |
+#+--------------+------------------+------+-----+---------+-------+
+#| indiv_id | int(16) unsigned | YES | | NULL | |
+#| name | varchar(30) | YES | | NULL | |
+#| organization | varchar(30) | YES | | NULL | |
+#| position | varchar(30) | YES | | NULL | |
+#| sequence | int(16) unsigned | YES | | NULL | |
+#| sustained | date | YES | | NULL | |
+#+--------------+------------------+------+-----+---------+-------+
+sub update_eq_calling_table()
+{
+ print "-> Updating eq_calling table\n";
+
+ #print "-> Organization Data Dump\n\n";
+ #&print_hash(\%organization_data);
+
+ # Delete all records from the calling table. We have no history to
+ # save here. Just re-populate with the latest calling information.
+ $sth = $dbh->prepare("delete from eq_calling ");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+
+ foreach $index (keys %organization_data)
+ {
+ $indiv_id = $organization_data{$index}{'Indiv ID'};
+ $name = $organization_data{$index}{'Indiv Name'};
+ $name =~ s/\'/\\'/g; #'
+ $organization = $organization_data{$index}{'Organization'};
+ $position = $organization_data{$index}{'Position'};
+ $sequence = $organization_data{$index}{'Org Seq'};
+ $sustained = $organization_data{$index}{'Sustained'};
+ $sustained =~ /(\S+) (\d+)/; $month=$1; $year=$2;
+ if($name eq "") { next; }
+ print " Adding new Calling: $name -> $position\n";
+ $sth = $dbh->prepare("insert into eq_calling values ('$indiv_id','$name','$organization','$position','$sequence','$month $year')");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+ }
+}
+
# EQ_DISTRICT
#+------------+------------------+------+-----+---------+-------+
#| Field | Type | Null | Key | Default | Extra |
#| family | int(16) unsigned | YES | | NULL | |
#| name | varchar(30) | YES | | NULL | |
#| birthday | date | YES | | NULL | |
+#| phone | varchar(12) | YES | | NULL | |
+#| address | varchar(255) | YES | | NULL | |
+#| indiv_id | int(16) unsigned | YES | UNI | NULL | |
#| valid | tinyint(1) | YES | | NULL | |
#+----------+------------------+------+-----+---------+-------+
sub update_eq_parent_table
$birthday = $membership_data{$index}{'Birth'};
$birthday =~ /(\d+) (\S+) (\d+)/; $day=$1; $month=$monthname2num{$2}; $year=$3;
$hofh_id = $membership_data{$index}{'HofH ID'};
+ $id = $membership_data{$index}{'Indiv ID'};
$phone = $membership_data{$index}{'Phone 1'};
if($phone =~ /(\d\d\d-\d\d\d\d)/) { $phone = "970-$1"; }
if($phone =~ /^\(\d\d\d\) (\d\d\d-\d\d\d\d)/) { $phone = "$1-$2"; }
if($rows == 0) {
# No existing records found for this parent, make a new entry
print " Adding new Parent: $parent_name\n";
- $sth = $dbh->prepare("insert into eq_parent values (NULL,$family_id,'$parent_name','$year-$month-$day','$phone','$address',1)");
+ $sth = $dbh->prepare("insert into eq_parent values (NULL,$family_id,'$parent_name','$year-$month-$day','$phone','$address','$id',1)");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
} elsif($rows == 1) {
# An existing record was found for this parent, update it
$sth->execute or die "-E- DB error: $DBI::errstr\n";
$sth = $dbh->prepare("update eq_parent set valid=1 where name='$parent_name'");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
+ $sth = $dbh->prepare("update eq_parent set indiv_id='$id' where name='$parent_name'");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
} else {
# More than one record was found. Error! This shouldn't happen.
print " -E- More than one record found with same parent name: $parent_name\n";
#| family | int(16) unsigned | YES | | NULL | |
#| name | varchar(30) | YES | | NULL | |
#| birthday | date | YES | | NULL | |
+#| indiv_id | int(16) unsigned | YES | UNI | NULL | |
#| valid | tinyint(1) | YES | | NULL | |
#+----------+------------------+------+-----+---------+-------+
sub update_eq_child_table
if($rows == 0) {
# No existing records found for this child, make a new entry
print " Adding new Child: $child_name\n";
- $sth = $dbh->prepare("insert into eq_child values (NULL,$family_id,'$child_name','$year-$month-$day',1)");
+ $sth = $dbh->prepare("insert into eq_child values (NULL,$family_id,'$child_name','$year-$month-$day','$id',1)");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
} elsif($rows == 1) {
# An existing record was found for this child, update it
$sth->execute or die "-E- DB error: $DBI::errstr\n";
$sth = $dbh->prepare("update eq_child set valid=1 where name='$child_name'");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
+ $sth = $dbh->prepare("update eq_child set indiv_id='$id' where name='$child_name'");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
} else {
# More than one record was found. Error! This shouldn't happen.
print " -E- More than one record found ($rows) with same child name: $child_name\n";
# Parse Ward Data Files
&csv_to_hash("$datadir/Membership.csv",\%membership_data);
&csv_to_hash("$datadir/HomeTeaching.csv",\%hometeaching_data);
+&csv_to_hash("$datadir/Organization.csv",\%organization_data);
if($opt_v) {
print "-> Membership Data Dump\n\n";
&print_hash(\%membership_data);
print "-> HomeTeaching Data Dump\n\n";
&print_hash(\%hometeaching_data);
+ print "-> Organization Data Dump\n\n";
+ &print_hash(\%organization_data);
}
if($opt_s) { $dbh->disconnect(); exit; }
&update_eq_family_table();
&update_eq_parent_table();
&update_eq_child_table();
+&update_eq_calling_table();
###################################################
# Disconnect from the database
'vis_update' => True,
'att_view' => True,
'att_update' => True,
- 'dir_view' => True
+ 'dir_view' => True,
+ 'org_view' => True
);
function eq()
$link_data['menuaction'] = 'eq.eq.dir_view';
$this->t->set_var('link_dir',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
$this->t->set_var('lang_dir','Directory');
+ $link_data['menuaction'] = 'eq.eq.org_view';
+ $this->t->set_var('link_org',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
+ $this->t->set_var('lang_org','Callings');
$this->t->pparse('out','eq_header');
}
$this->save_sessiondata();
}
+ function org_view()
+ {
+ $this->t->set_file(array('org_view_t' => 'org_view.tpl'));
+ $this->t->set_block('org_view_t','calling_list','list1');
+ $this->t->set_block('org_view_t','org_list','list2');
+
+ # Display a list ordered alphabetically
+ $sql = "SELECT * FROM eq_calling ORDER BY name ASC";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $i=0;
+ while ($this->db->next_record())
+ {
+ $calling[$i]['id'] = $this->db->f('indiv_id');
+ $calling[$i]['name'] = $this->db->f('name');
+ $calling[$i]['position'] = $this->db->f('position');
+ $calling[$i]['sustained'] = $this->db->f('sustained');
+ $calling[$i]['organization'] = $this->db->f('organization');
+ $i++;
+ }
+ for ($i=0; $i < count($calling); $i++)
+ {
+ $name = $calling[$i]['name'];
+ $position = $calling[$i]['position'];
+ $sustained = $calling[$i]['sustained'];
+ $organization = $calling[$i]['organization'];
+ $this->t->set_var('name', $name);
+ $this->t->set_var('position', $position);
+ $this->t->set_var('sustained', $sustained);
+ $this->t->set_var('organization', $organization);
+ $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
+ $this->t->set_var('tr_color',$tr_color);
+ $this->t->fp('list1','calling_list',True);
+ }
+
+ # Display a list ordered by organization
+ $sql = "SELECT * FROM eq_calling ORDER BY sequence ASC";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $i=0;
+ while ($this->db->next_record())
+ {
+ $calling[$i]['id'] = $this->db->f('indiv_id');
+ $calling[$i]['name'] = $this->db->f('name');
+ $calling[$i]['position'] = $this->db->f('position');
+ $calling[$i]['sustained'] = $this->db->f('sustained');
+ $calling[$i]['organization'] = $this->db->f('organization');
+ $i++;
+ }
+ for ($i=0; $i < count($calling); $i++)
+ {
+ $name = $calling[$i]['name'];
+ $position = $calling[$i]['position'];
+ $sustained = $calling[$i]['sustained'];
+ $organization = $calling[$i]['organization'];
+ $this->t->set_var('name', $name);
+ $this->t->set_var('position', $position);
+ $this->t->set_var('sustained', $sustained);
+ $this->t->set_var('organization', $organization);
+ $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
+ $this->t->set_var('tr_color',$tr_color);
+ $this->t->fp('list2','org_list',True);
+ }
+
+ $this->t->pfp('out','org_view_t');
+ $this->save_sessiondata();
+ }
+
}
?>
--- /dev/null
+<center>
+ <table border="0" width="80%" cellspacing="2" cellpadding="2">
+ <tr>
+ <td align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Ward Callings</b></font></td>
+ </tr>
+ </table>
+ <br><h2>By Name</h2>
+
+ <table border="0" width=80% cellspacing="2" cellpadding="2">
+ <tr>
+ <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Name</b></font></td>
+ <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Calling</b></font></td>
+ <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Date Sustained</b></font></td>
+ </tr>
+<!-- BEGIN calling_list -->
+ <tr bgcolor="{tr_color}">
+ <td align="left" width=25%><font face="{font}">{name}</font></td>
+ <td align="left" width=25%><font face="{font}">{position}</font></td>
+ <td align="left" width=25%><font face="{font}">{sustained}</font></td>
+ </tr>
+<!-- END calling_list -->
+ </table>
+
+ <br><h2>By Organization</h2>
+ <table border="0" width=80% cellspacing="2" cellpadding="2">
+ <tr>
+ <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Organization</b></font></td>
+ <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Name</b></font></td>
+ <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Calling</b></font></td>
+ <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Date Sustained</b></font></td>
+ </tr>
+<!-- BEGIN org_list -->
+ <tr bgcolor="{tr_color}">
+ <td align="left" width=25%><font face="{font}">{organization}</font></td>
+ <td align="left" width=25%><font face="{font}">{name}</font></td>
+ <td align="left" width=25%><font face="{font}">{position}</font></td>
+ <td align="left" width=25%><font face="{font}">{sustained}</font></td>
+ </tr>
+<!-- END org_list -->
+
+ </table>
+</center>