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

(-)a/C4/Items.pm (-3 / +45 lines)
Lines 2908-2913 sub columns { Link Here
2908
    return @data;
2908
    return @data;
2909
}
2909
}
2910
2910
2911
=head2 biblioitems_columns
2912
2913
  my @columns = C4::Items::biblioitems_columns();
2914
2915
Returns an array of biblioitems' table columns on success,
2916
and an empty array on failure.
2917
2918
=cut
2919
2920
sub biblioitems_columns {
2921
    # Pure ANSI SQL goodness.
2922
    my $sql = 'SELECT * FROM biblioitems WHERE 1=0;';
2923
2924
    # Get the database handle.
2925
    my $dbh = C4::Context->dbh;
2926
2927
    # Run the SQL statement to load STH's readonly properties.
2928
    my $sth = $dbh->prepare($sql);
2929
    my $rv = $sth->execute();
2930
2931
    # This only fails if the table doesn't exist.
2932
    # This will always be called AFTER an install or upgrade,
2933
    # so borrowers will exist!
2934
    my @data;
2935
    if ($sth->{NUM_OF_FIELDS}>0) {
2936
        @data = @{$sth->{NAME}};
2937
    }
2938
    else {
2939
        @data = ();
2940
    }
2941
    return @data;
2942
}
2943
2911
sub ToggleNewStatus {
2944
sub ToggleNewStatus {
2912
    my ( $params ) = @_;
2945
    my ( $params ) = @_;
2913
    my @rules = @{ $params->{rules} };
2946
    my @rules = @{ $params->{rules} };
Lines 2915-2921 sub ToggleNewStatus { Link Here
2915
2948
2916
    my $dbh = C4::Context->dbh;
2949
    my $dbh = C4::Context->dbh;
2917
    my @errors;
2950
    my @errors;
2918
    my @items_columns = C4::Items::columns;
2951
    my @item_columns = map { "items.$_" } C4::Items::columns;
2952
    my @biblioitem_columns = map { "biblioitems.$_" } C4::Items::biblioitems_columns;
2919
    my $report;
2953
    my $report;
2920
    for my $rule ( @rules ) {
2954
    for my $rule ( @rules ) {
2921
        my $duration = $rule->{duration};
2955
        my $duration = $rule->{duration};
Lines 2923-2931 sub ToggleNewStatus { Link Here
2923
        my $substitutions = $rule->{substitutions};
2957
        my $substitutions = $rule->{substitutions};
2924
        my @params;
2958
        my @params;
2925
2959
2926
        my $query = q|SELECT biblionumber, itemnumber FROM items WHERE 1 |;
2960
        my $query = q|
2961
            SELECT items.biblionumber, items.itemnumber
2962
            FROM items
2963
            LEFT JOIN biblioitems ON items.biblioitemnumber = items.itemnumber
2964
            WHERE 1
2965
        |;
2927
        for my $condition ( @$conditions ) {
2966
        for my $condition ( @$conditions ) {
2928
            if ( grep {/^$condition->{field}$/} @items_columns ) {
2967
            if (
2968
                 grep {/^$condition->{field}$/} @item_columns
2969
              or grep {/^$condition->{field}$/} @biblioitem_columns
2970
            ) {
2929
                if ( $condition->{value} =~ /\|/ ) {
2971
                if ( $condition->{value} =~ /\|/ ) {
2930
                    my @values = split /\|/, $condition->{value};
2972
                    my @values = split /\|/, $condition->{value};
2931
                    $query .= qq| AND $condition->{field} IN (|
2973
                    $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