@@ -, +, @@ ROADTYPE AV - adds a new AV category 'ROADTYPE' (created from the roadtype table content). - remove the roadtype table. - remove the .pl and .tt file admin/roadtype - remove the 2 routines C4::Members::GetRoadTypes and C4::Members::GetRoadTypeDetails circ/circulation.pl members/memberentry.pl members/moremember.pl members/routing-lists.pl --- C4/Members.pm | 67 --------- admin/roadtype.pl | 129 ----------------- circ/circulation.pl | 2 +- installer/data/mysql/updatedatabase.pl | 32 +++++ .../intranet-tmpl/prog/en/includes/admin-menu.inc | 1 - .../prog/en/modules/admin/admin-home.tt | 3 - .../prog/en/modules/admin/roadtype.tt | 147 -------------------- .../prog/en/modules/members/memberentrygen.tt | 14 +- .../prog/en/modules/members/moremember.tt | 4 +- members/memberentry.pl | 15 +- members/moremember.pl | 4 +- members/routing-lists.pl | 4 +- 12 files changed, 51 insertions(+), 371 deletions(-) delete mode 100755 admin/roadtype.pl delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/roadtype.tt --- a/C4/Members.pm +++ a/C4/Members.pm @@ -70,8 +70,6 @@ BEGIN { &GetAge &GetCities - &GetRoadTypes - &GetRoadTypeDetails &GetSortDetails &GetTitles @@ -1857,48 +1855,6 @@ EOF return 0; } -=head2 GetRoadTypes (OUEST-PROVENCE) - - ($idroadtypearrayref, $roadttype_hashref) = &GetRoadTypes(); - -Looks up the different road type . Returns two -elements: a reference-to-array, which lists the id_roadtype -codes, and a reference-to-hash, which maps the road type of the road . - -=cut - -sub GetRoadTypes { - my $dbh = C4::Context->dbh; - my $query = qq| -SELECT roadtypeid,road_type -FROM roadtype -ORDER BY road_type|; - my $sth = $dbh->prepare($query); - $sth->execute(); - my %roadtype; - my @id; - - # insert empty value to create a empty choice in cgi popup - - while ( my $data = $sth->fetchrow_hashref ) { - - push @id, $data->{'roadtypeid'}; - $roadtype{ $data->{'roadtypeid'} } = $data->{'road_type'}; - } - -#test to know if the table contain some records if no the function return nothing - my $id = @id; - if ( $id eq 0 ) { - return (); - } - else { - unshift( @id, "" ); - return ( \@id, \%roadtype ); - } -} - - - =head2 GetTitles (OUEST-PROVENCE) ($borrowertitle)= &GetTitles(); @@ -1998,29 +1954,6 @@ sub GetHideLostItemsPreference { return $hidelostitems; } -=head2 GetRoadTypeDetails (OUEST-PROVENCE) - - ($roadtype) = &GetRoadTypeDetails($roadtypeid); - -Returns the description of roadtype -C<&$roadtype>return description of road type -C<&$roadtypeid>this is the value of roadtype s - -=cut - -sub GetRoadTypeDetails { - my ($roadtypeid) = @_; - my $dbh = C4::Context->dbh; - my $query = qq| -SELECT road_type -FROM roadtype -WHERE roadtypeid=?|; - my $sth = $dbh->prepare($query); - $sth->execute($roadtypeid); - my $roadtype = $sth->fetchrow; - return ($roadtype); -} - =head2 GetBorrowersToExpunge $borrowers = &GetBorrowersToExpunge( --- a/admin/roadtype.pl +++ a/admin/roadtype.pl @@ -1,129 +0,0 @@ -#! /usr/bin/perl - -# Copyright 2006 SAN OUEST-PROVENCE et Paul POULAIN -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -use strict; -use warnings; - -use CGI; -use C4::Context; -use C4::Output; -use C4::Auth; - - -sub StringSearch { - my $sth = C4::Context->dbh->prepare("Select * from roadtype where (road_type like ?) ORDER BY road_type"); - $sth->execute((shift || '') . '%'); - return $sth->fetchall_arrayref({}); -} - -my $input = new CGI; -my $searchfield=$input->param('road_type'); -my $script_name="/cgi-bin/koha/admin/roadtype.pl"; -my $roadtypeid=$input->param('roadtypeid'); -my $op = $input->param('op') || ''; - -my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "admin/roadtype.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => {parameters => 'parameters_remaining_permissions'}, - debug => 1, - }); - - -$template->param( script_name => $script_name, - roadtypeid => $roadtypeid , - searchfield => $searchfield); - - -################## ADD_FORM ################################## -# called by default. Used to create form to add or modify a record -if ($op eq 'add_form') { - $template->param(add_form => 1); - - #---- if primkey exists, it's a modify action, so read values to modify... - my $data; - if ($roadtypeid) { - my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select roadtypeid,road_type from roadtype where roadtypeid=?"); - $sth->execute($roadtypeid); - $data=$sth->fetchrow_hashref; - $sth->finish; - } - - $template->param( - road_type => $data->{'road_type'}, - ); -##############ICI##################### -# END $OP eq ADD_FORM -################## ADD_VALIDATE ################################# -# called by add_form, used to insert/modify data in DB -} elsif ($op eq 'add_validate') { - my $dbh = C4::Context->dbh; - my $sth; - - if ($input->param('roadtypeid') ){ - $sth=$dbh->prepare("UPDATE roadtype SET road_type=? WHERE roadtypeid=?"); - $sth->execute($input->param('road_type'),$input->param('roadtypeid')); - - } - else{ - $sth=$dbh->prepare("INSERT INTO roadtype (road_type) VALUES (?)"); - $sth->execute($input->param('road_type')); - } - $sth->finish; - print $input->redirect("/cgi-bin/koha/admin/roadtype.pl"); - exit; - -# END $OP eq ADD_VALIDATE -################## DELETE_CONFIRM ################################## -# called by default form, used to confirm deletion of data in DB -} elsif ($op eq 'delete_confirm') { - $template->param(delete_confirm => 1); - my $dbh = C4::Context->dbh; - my $sth2=$dbh->prepare("select roadtypeid,road_type from roadtype where roadtypeid=?"); - $sth2->execute($roadtypeid); - my $data=$sth2->fetchrow_hashref; - $sth2->finish; - - $template->param( - road_type => ( $data->{'road_type'}), - ); - - - # END $OP eq DELETE_CONFIRM -################## DELETE_CONFIRMED ################################## -# called by delete_confirm, used to effectively confirm deletion of data in DB -} elsif ($op eq 'delete_confirmed') { - my $dbh = C4::Context->dbh; - my $categorycode=uc($input->param('roadtypeid')); - my $sth=$dbh->prepare("delete from roadtype where roadtypeid=?"); - $sth->execute($roadtypeid); - $sth->finish; - print "Content-Type: text/html\n\n"; - exit; - # END $OP eq DELETE_CONFIRMED -} else { # DEFAULT - $template->param(else => 1); - $template->param(loop => StringSearch($searchfield)); - - -} #---- END $OP eq DEFAULT -output_html_with_http_headers $input, $cookie, $template->output; --- a/circ/circulation.pl +++ a/circ/circulation.pl @@ -686,7 +686,7 @@ if($bor_messages_loop){ $template->param(flagged => 1 ); } # Computes full borrower address my @fulladdress; push @fulladdress, $borrower->{'streetnumber'} if ( $borrower->{'streetnumber'} ); -push @fulladdress, &GetRoadTypeDetails( $borrower->{'streettype'} ) if ( $borrower->{'streettype'} ); +push @fulladdress, C4::Koha::GetAuthorisedValueByCode( 'ROADTYPE', $borrower->{'streettype'} ) if ( $borrower->{'streettype'} ); push @fulladdress, $borrower->{'address'} if ( $borrower->{'address'} ); my $fast_cataloging = 0; --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -7330,6 +7330,38 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } + +$DBversion = "3.13.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->{AutoCommit} = 0; + $dbh->{RaiseError} = 1; + + my $av_added = $dbh->do(q| + INSERT INTO authorised_values(category, authorised_value, lib, lib_opac) + SELECT 'ROADTYPE', roadtypeid, road_type, road_type + FROM roadtype; + |); + + my $rt_deleted = $dbh->do(q| + DELETE FROM roadtype + |); + + if ( $av_added == $rt_deleted or $rt_deleted eq "0E0" ) { + $dbh->do(q| + DROP TABLE roadtype; + |); + $dbh->commit; + print "Upgrade to $DBversion done (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values)\n"; + SetVersion($DBversion); + } else { + print "Upgrade to $DBversion failed (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values.\nTransaction aborted because $@\n)"; + $dbh->rollback; + } + + $dbh->{AutoCommit} = 1; + $dbh->{RaiseError} = 0; +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc @@ -33,7 +33,6 @@
  • Transport cost matrix
  • Item circulation alerts
  • Cities and towns
  • -
  • Road types
  • Catalog
    --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt @@ -56,9 +56,6 @@
    Define rules for check-in and checkout notifications for combinations of libraries, patron categories, and item types
    Cities and towns
    Define cities and towns that your patrons live in.
    -
    Road types -
    -
    Define road types (street, avenue, way, etc.). Road types display as authorized values when adding/editing patrons and can be used in geographic statistics.
    --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/roadtype.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/roadtype.tt @@ -1,147 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Koha › Administration › [% IF ( add_form ) %]Road types › [% IF ( roadtypeid ) %] Modify road type[% ELSE %] New road type[% END %][% ELSE %][% IF ( delete_confirm ) %]Road types › Confirm deletion of road type[% ELSE %] Road type[% END %][% END %] -[% INCLUDE 'doc-head-close.inc' %] - - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'roadtype-admin-search.inc' %] - - -
    - -
    -
    -
    - -[% IF ( add_form ) %] - [% IF ( roadtypeid ) %] -

    Modify road type

    - [% ELSE %] -

    New road type

    - [% END %] - -
    - - - - -
      -[% IF ( roadtypeid ) %] -
    1. - Road type: [% roadtypeid %] -
    2. -[% END %] -
    3. - - -
    - -
    - Cancel -
    -
    -[% END %] - -[% IF ( delete_confirm ) %] -

    Delete road type "[% road_type %]?"

    - - - - - - - -
    Road type id: [% roadtypeid %]
    Road type: [% road_type %] -
    - -
    -
    -[% END %] - -[% IF ( else ) %] - - - -

    Road type

    - [% IF ( searchfield ) %] - Search on [% searchfield %] - [% END %] - -[% IF ( loop ) %] - - - - - [% FOREACH loo IN loop %] - [% UNLESS ( loop.odd ) %] - - [% ELSE %] - - [% END %] - - - - - [% END %] -
    Road type 
    [% loo.road_type %]EditDelete
    [% END %] -[% END %] - -
    -
    -
    -[% INCLUDE 'admin-menu.inc' %] -
    -
    -[% INCLUDE 'intranet-bottom.inc' %] - - --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -200,7 +200,6 @@ - @@ -438,7 +437,7 @@ [% END %] [% UNLESS nostreettype %] - [% IF ( road_cgipopup ) %] + [% IF roadtypes %]
  • [% IF ( mandatorystreettype ) %]
  • [% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -214,9 +214,7 @@ function validate1(date) { [% UNLESS ( I ) %][% IF ( othernames ) %]“[% othernames %]”[% END %]

    [% streetnumber %] - [% IF ( roaddetails ) %] - [% roaddetails %] - [% END %] + [% IF roadtype %][% roadtype %][% END %] [% address %]
    [% IF ( address2 ) %][% address2 %]
    [% END %] [% IF ( city ) %][% city %][% END %] --- a/members/memberentry.pl +++ a/members/memberentry.pl @@ -184,7 +184,6 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) qr/^nodouble$/, qr/^op$/, qr/^save$/, - qr/^select_roadtype$/, qr/^updtype$/, qr/^SMSnumber$/, qr/^setting_extended_patron_attributes$/, @@ -523,17 +522,8 @@ if (@{$city_arrayref} ) { } } -my $default_roadtype; -$default_roadtype=$data{'streettype'} ; -my($roadtypeid,$road_type)=GetRoadTypes(); - $template->param( road_cgipopup => 1) if ($roadtypeid ); -my $roadpopup = CGI::popup_menu(-name=>'streettype', - -id => 'streettype', - -values=>$roadtypeid, - -labels=>$road_type, - -override => 1, - -default=>$default_roadtype - ); +my $roadtypes = C4::Koha::GetAuthorisedValues( 'ROADTYPE', $data{streettype} ); +$template->param( roadtypes => $roadtypes); my $default_borrowertitle = ''; unless ( $op eq 'duplicate' ) { $default_borrowertitle=$data{'title'} } @@ -707,7 +697,6 @@ $template->param( ethcatpopup => $ethcatpopup, relshiploop => \@relshipdata, city_loop => $city_arrayref, - roadpopup => $roadpopup, borrotitlepopup => $borrotitlepopup, guarantorinfo => $guarantorinfo, flagloop => \@flagdata, --- a/members/moremember.pl +++ a/members/moremember.pl @@ -244,7 +244,7 @@ my $relissue = []; if ( @borrowernumbers ) { $relissue = GetPendingIssues(@borrowernumbers); } -my $roaddetails = &GetRoadTypeDetails( $data->{'streettype'} ); +my $roadtype = C4::Koha::GetAuthorisedValueByCode( 'ROADTYPE', $data->{streettype} ); my $today = DateTime->now( time_zone => C4::Context->tz); $today->truncate(to => 'day'); my @borrowers_with_issues; @@ -407,7 +407,7 @@ $template->param( detailview => 1, AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"), CANDELETEUSER => $candeleteuser, - roaddetails => $roaddetails, + roadtype => $roadtype, borrowernumber => $borrowernumber, othernames => $data->{'othernames'}, categoryname => $data->{'description'}, --- a/members/routing-lists.pl +++ a/members/routing-lists.pl @@ -101,8 +101,8 @@ if ($borrowernumber) { # Computes full borrower address -my (undef, $roadttype_hashref) = &GetRoadTypes(); -my $address = $borrower->{'streetnumber'}.' '.$roadttype_hashref->{$borrower->{'streettype'}}.' '.$borrower->{'address'}; +my $roadtype = C4::Koha::GetAuthorisedValueByCode( 'ROADTYPE', $borrower->{streettype} ); +my $address = $borrower->{'streetnumber'} . " $roadtype " . $borrower->{'address'}; $template->param( --