- switch ($type) {
- case 'textrange' {
- my %temp;
- $temp{'name'} = $value;
- $temp{'from'} = "from_" . $value;
- $temp{'to'} = "to_" . $value;
- $temp{'textrange'} = 1;
- $temp{'description'} = $column_defs->{$value};
- push @criteria_array, \%temp;
- }
-
- case 'date' {
- my %temp;
- $temp{'name'} = $value;
- $temp{'date'} = 1;
- $temp{'description'} = $column_defs->{$value};
- push @criteria_array, \%temp;
- }
-
- case 'daterange' {
- my %temp;
- $temp{'name'} = $value;
- $temp{'from'} = "from_" . $value;
- $temp{'to'} = "to_" . $value;
- $temp{'daterange'} = 1;
- $temp{'description'} = $column_defs->{$value};
- push @criteria_array, \%temp;
- }
-
- else {
- my $query =
- "SELECT distinct($column) as availablevalues FROM $table";
- my $sth = $dbh->prepare($query);
- $sth->execute();
- my @values;
- # push the runtime choosing option
- my $list;
- $list='branches' if $column eq 'branchcode' or $column eq 'holdingbranch' or $column eq 'homebranch';
- $list='categorycode' if $column eq 'categorycode';
- $list='itemtype' if $column eq 'itype';
- $list='ccode' if $column eq 'ccode';
- # TODO : improve to let the librarian choose the description at runtime
- push @values, { availablevalues => "<<$column".($list?"|$list":'').">>" };
- while ( my $row = $sth->fetchrow_hashref() ) {
- push @values, $row;
- if ($row->{'availablevalues'} eq '') { $row->{'default'} = 1 };
- }
- $sth->finish();
+ if ($type eq 'textrange') {
+ my %temp;
+ $temp{'name'} = $value;
+ $temp{'from'} = "from_" . $value;
+ $temp{'to'} = "to_" . $value;
+ $temp{'textrange'} = 1;
+ $temp{'description'} = $column_defs->{$value};
+ push @criteria_array, \%temp;
+ }
+ elsif ($type eq 'date') {
+ my %temp;
+ $temp{'name'} = $value;
+ $temp{'date'} = 1;
+ $temp{'description'} = $column_defs->{$value};
+ push @criteria_array, \%temp;
+ }
+ elsif ($type eq 'daterange') {
+ my %temp;
+ $temp{'name'} = $value;
+ $temp{'from'} = "from_" . $value;
+ $temp{'to'} = "to_" . $value;
+ $temp{'daterange'} = 1;
+ $temp{'description'} = $column_defs->{$value};
+ push @criteria_array, \%temp;
+ }
+ else {
+ my $query =
+ "SELECT distinct($column) as availablevalues FROM $table";
+ my $sth = $dbh->prepare($query);
+ $sth->execute();
+ my @values;
+ # push the runtime choosing option
+ my $list;
+ $list='branches' if $column eq 'branchcode' or $column eq 'holdingbranch' or $column eq 'homebranch';
+ $list='categorycode' if $column eq 'categorycode';
+ $list='itemtype' if $column eq 'itype';
+ $list='ccode' if $column eq 'ccode';
+ # TODO : improve to let the librarian choose the description at runtime
+ push @values, { availablevalues => "<<$column".($list?"|$list":'').">>" };
+ while ( my $row = $sth->fetchrow_hashref() ) {
+ push @values, $row;
+ if ($row->{'availablevalues'} eq '') { $row->{'default'} = 1 };
+ }
+ $sth->finish();