From: Alan Jack Pippin Date: Fri, 2 Jun 2006 06:03:50 +0000 (-0600) Subject: Added new Ward Calling display application. X-Git-Tag: release_0_1_0~50 X-Git-Url: http://git.pippins.net/embedvideo/.git/static/images//%22%22.%24thumbnail.%22/%22?a=commitdiff_plain;h=7af932f11f7025c37945987840922f1786c4de5c;p=eq%2F.git Added new Ward Calling display application. --- diff --git a/import_ward_data b/import_ward_data index ef1c7ea..c45feaf 100755 --- a/import_ward_data +++ b/import_ward_data @@ -183,6 +183,46 @@ sub update_eq_elder_table $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 | @@ -390,6 +430,9 @@ sub update_eq_family_table #| 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 @@ -414,6 +457,7 @@ 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"; } @@ -438,7 +482,7 @@ sub update_eq_parent_table 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 @@ -453,6 +497,8 @@ sub update_eq_parent_table $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"; @@ -471,6 +517,7 @@ sub update_eq_parent_table #| 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 @@ -509,7 +556,7 @@ 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 @@ -520,6 +567,8 @@ sub update_eq_child_table $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"; @@ -609,12 +658,15 @@ print "-> Processing all ward data files in $datadir\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; } @@ -627,6 +679,7 @@ 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 diff --git a/inc/class.eq.inc.php b/inc/class.eq.inc.php index aab3ffd..b1dbb23 100644 --- a/inc/class.eq.inc.php +++ b/inc/class.eq.inc.php @@ -40,7 +40,8 @@ class eq 'vis_update' => True, 'att_view' => True, 'att_update' => True, - 'dir_view' => True + 'dir_view' => True, + 'org_view' => True ); function eq() @@ -117,6 +118,9 @@ class 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'); } @@ -1782,6 +1786,72 @@ class eq $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(); + } + } ?> diff --git a/templates/default/dir_view.tpl b/templates/default/dir_view.tpl index b1adc19..e49518d 100644 --- a/templates/default/dir_view.tpl +++ b/templates/default/dir_view.tpl @@ -1,7 +1,7 @@
- +
Online Ward DirectoryWard Directory

diff --git a/templates/default/header.tpl b/templates/default/header.tpl index 4a624a1..8da3598 100644 --- a/templates/default/header.tpl +++ b/templates/default/header.tpl @@ -24,6 +24,9 @@     {lang_dir} +   +   + {lang_org} diff --git a/templates/default/org_view.tpl b/templates/default/org_view.tpl new file mode 100644 index 0000000..d1bb206 --- /dev/null +++ b/templates/default/org_view.tpl @@ -0,0 +1,42 @@ +
+ + + + +
Ward Callings
+

By Name

+ + + + + + + + + + + + + + +
NameCallingDate Sustained
{name}{position}{sustained}
+ +

By Organization

+ + + + + + + + + + + + + + + + +
OrganizationNameCallingDate Sustained
{organization}{name}{position}{sustained}
+