View | Details | Raw Unified | Return to bug 11023
Collapse All | Expand All

(-)a/C4/Items.pm (-3 / +45 lines)
Lines 2945-2950 sub columns { Link Here
2945
    return @data;
2945
    return @data;
2946
}
2946
}
2947
2947
2948
=head2 biblioitems_columns
2949
2950
  my @columns = C4::Items::biblioitems_columns();
2951
2952
Returns an array of biblioitems' table columns on success,
2953
and an empty array on failure.
2954
2955
=cut
2956
2957
sub biblioitems_columns {
2958
    # Pure ANSI SQL goodness.
2959
    my $sql = 'SELECT * FROM biblioitems WHERE 1=0;';
2960
2961
    # Get the database handle.
2962
    my $dbh = C4::Context->dbh;
2963
2964
    # Run the SQL statement to load STH's readonly properties.
2965
    my $sth = $dbh->prepare($sql);
2966
    my $rv = $sth->execute();
2967
2968
    # This only fails if the table doesn't exist.
2969
    # This will always be called AFTER an install or upgrade,
2970
    # so borrowers will exist!
2971
    my @data;
2972
    if ($sth->{NUM_OF_FIELDS}>0) {
2973
        @data = @{$sth->{NAME}};
2974
    }
2975
    else {
2976
        @data = ();
2977
    }
2978
    return @data;
2979
}
2980
2948
sub ToggleNewStatus {
2981
sub ToggleNewStatus {
2949
    my ( $params ) = @_;
2982
    my ( $params ) = @_;
2950
    my @rules = @{ $params->{rules} };
2983
    my @rules = @{ $params->{rules} };
Lines 2952-2958 sub ToggleNewStatus { Link Here
2952
2985
2953
    my $dbh = C4::Context->dbh;
2986
    my $dbh = C4::Context->dbh;
2954
    my @errors;
2987
    my @errors;
2955
    my @items_columns = C4::Items::columns;
2988
    my @item_columns = map { "items.$_" } C4::Items::columns;
2989
    my @biblioitem_columns = map { "biblioitems.$_" } C4::Items::biblioitems_columns;
2956
    my $report;
2990
    my $report;
2957
    for my $rule ( @rules ) {
2991
    for my $rule ( @rules ) {
2958
        my $duration = $rule->{duration};
2992
        my $duration = $rule->{duration};
Lines 2960-2968 sub ToggleNewStatus { Link Here
2960
        my $substitutions = $rule->{substitutions};
2994
        my $substitutions = $rule->{substitutions};
2961
        my @params;
2995
        my @params;
2962
2996
2963
        my $query = q|SELECT biblionumber, itemnumber FROM items WHERE 1 |;
2997
        my $query = q|
2998
            SELECT items.biblionumber, items.itemnumber
2999
            FROM items
3000
            LEFT JOIN biblioitems ON items.biblioitemnumber = items.itemnumber
3001
            WHERE 1
3002
        |;
2964
        for my $condition ( @$conditions ) {
3003
        for my $condition ( @$conditions ) {
2965
            if ( grep {/^$condition->{field}$/} @items_columns ) {
3004
            if (
3005
                 grep {/^$condition->{field}$/} @item_columns
3006
              or grep {/^$condition->{field}$/} @biblioitem_columns
3007
            ) {
2966
                if ( $condition->{value} =~ /\|/ ) {
3008
                if ( $condition->{value} =~ /\|/ ) {
2967
                    my @values = split /\|/, $condition->{value};
3009
                    my @values = split /\|/, $condition->{value};
2968
                    $query .= qq| AND $condition->{field} IN (|
3010
                    $query .= qq| AND $condition->{field} IN (|
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/toggle_new_status.tt (-10 / +10 lines)
Lines 155-165 Link Here
155
                        <div class="block">
155
                        <div class="block">
156
                          <select name="condition_field_[% id %]">
156
                          <select name="condition_field_[% id %]">
157
                            <option value="">Choose a field name</option>
157
                            <option value="">Choose a field name</option>
158
                            [% FOR field IN item_fields %]
158
                            [% FOR field IN fields %]
159
                              [% IF condition.field == field %]
159
                              [% IF condition.field == field %]
160
                                <option value="[% field %]" selected="selected">items.[% field %]</option>
160
                                <option value="[% field %]" selected="selected">[% field %]</option>
161
                              [% ELSE %]
161
                              [% ELSE %]
162
                                <option value="[% field %]">items.[% field %]</option>
162
                                <option value="[% field %]">[% field %]</option>
163
                              [% END %]
163
                              [% END %]
164
                            [% END %]
164
                            [% END %]
165
                          </select>
165
                          </select>
Lines 176-186 Link Here
176
                        <div class="block">
176
                        <div class="block">
177
                          <select name="substitution_field_[% id %]">
177
                          <select name="substitution_field_[% id %]">
178
                            <option value="">Choose a field name</option>
178
                            <option value="">Choose a field name</option>
179
                            [% FOR field IN item_fields %]
179
                            [% FOR field IN fields %]
180
                              [% IF substitution.field == field %]
180
                              [% IF substitution.field == field %]
181
                                <option value="[% field %]" selected="selected">items.[% field %]</option>
181
                                <option value="[% field %]" selected="selected">[% field %]</option>
182
                              [% ELSE %]
182
                              [% ELSE %]
183
                                <option value="[% field %]">items.[% field %]</option>
183
                                <option value="[% field %]">[% field %]</option>
184
                              [% END %]
184
                              [% END %]
185
                            [% END %]
185
                            [% END %]
186
                          </select>
186
                          </select>
Lines 217-224 Link Here
217
              <div class="block">
217
              <div class="block">
218
                <select name="condition_field">
218
                <select name="condition_field">
219
                  <option value="">Choose a field name</option>
219
                  <option value="">Choose a field name</option>
220
                  [% FOR field IN item_fields %]
220
                  [% FOR field IN fields %]
221
                    <option value="[% field %]">items.[% field %]</option>
221
                    <option value="[% field %]">[% field %]</option>
222
                  [% END %]
222
                  [% END %]
223
                </select>
223
                </select>
224
                =
224
                =
Lines 232-239 Link Here
232
              <div class="block">
232
              <div class="block">
233
                <select name="substitution_field">
233
                <select name="substitution_field">
234
                  <option value="">Choose a field name</option>
234
                  <option value="">Choose a field name</option>
235
                  [% FOR field IN item_fields %]
235
                  [% FOR field IN fields %]
236
                    <option value="[% field %]">items.[% field %]</option>
236
                    <option value="[% field %]">[% field %]</option>
237
                  [% END %]
237
                  [% END %]
238
                </select>
238
                </select>
239
                =
239
                =
(-)a/tools/toggle_new_status.pl (-2 / +3 lines)
Lines 106-115 if ( $@ ) { Link Here
106
    exit;
106
    exit;
107
}
107
}
108
108
109
my @item_fields = map { "items.$_" } C4::Items::columns;
110
my @biblioitem_fields = map { "biblioitems.$_" } C4::Items::biblioitems_columns;
109
$template->param(
111
$template->param(
110
    op => $op,
112
    op => $op,
111
    messages => \@messages,
113
    messages => \@messages,
112
    item_fields => [ C4::Items::columns ],
114
    fields => [ @item_fields, @biblioitem_fields ],
113
    rules => $rules,
115
    rules => $rules,
114
);
116
);
115
117
116
- 

Return to bug 11023