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

(-)a/C4/Items.pm (-3 / +45 lines)
Lines 3092-3097 sub columns { Link Here
3092
    return @data;
3092
    return @data;
3093
}
3093
}
3094
3094
3095
=head2 biblioitems_columns
3096
3097
  my @columns = C4::Items::biblioitems_columns();
3098
3099
Returns an array of biblioitems' table columns on success,
3100
and an empty array on failure.
3101
3102
=cut
3103
3104
sub biblioitems_columns {
3105
    # Pure ANSI SQL goodness.
3106
    my $sql = 'SELECT * FROM biblioitems WHERE 1=0;';
3107
3108
    # Get the database handle.
3109
    my $dbh = C4::Context->dbh;
3110
3111
    # Run the SQL statement to load STH's readonly properties.
3112
    my $sth = $dbh->prepare($sql);
3113
    my $rv = $sth->execute();
3114
3115
    # This only fails if the table doesn't exist.
3116
    # This will always be called AFTER an install or upgrade,
3117
    # so borrowers will exist!
3118
    my @data;
3119
    if ($sth->{NUM_OF_FIELDS}>0) {
3120
        @data = @{$sth->{NAME}};
3121
    }
3122
    else {
3123
        @data = ();
3124
    }
3125
    return @data;
3126
}
3127
3095
sub ToggleNewStatus {
3128
sub ToggleNewStatus {
3096
    my ( $params ) = @_;
3129
    my ( $params ) = @_;
3097
    my @rules = @{ $params->{rules} };
3130
    my @rules = @{ $params->{rules} };
Lines 3099-3105 sub ToggleNewStatus { Link Here
3099
3132
3100
    my $dbh = C4::Context->dbh;
3133
    my $dbh = C4::Context->dbh;
3101
    my @errors;
3134
    my @errors;
3102
    my @items_columns = C4::Items::columns;
3135
    my @item_columns = map { "items.$_" } C4::Items::columns;
3136
    my @biblioitem_columns = map { "biblioitems.$_" } C4::Items::biblioitems_columns;
3103
    my $report;
3137
    my $report;
3104
    for my $rule ( @rules ) {
3138
    for my $rule ( @rules ) {
3105
        my $duration = $rule->{duration};
3139
        my $duration = $rule->{duration};
Lines 3107-3115 sub ToggleNewStatus { Link Here
3107
        my $substitutions = $rule->{substitutions};
3141
        my $substitutions = $rule->{substitutions};
3108
        my @params;
3142
        my @params;
3109
3143
3110
        my $query = q|SELECT biblionumber, itemnumber FROM items WHERE 1 |;
3144
        my $query = q|
3145
            SELECT items.biblionumber, items.itemnumber
3146
            FROM items
3147
            LEFT JOIN biblioitems ON items.biblioitemnumber = items.itemnumber
3148
            WHERE 1
3149
        |;
3111
        for my $condition ( @$conditions ) {
3150
        for my $condition ( @$conditions ) {
3112
            if ( grep {/^$condition->{field}$/} @items_columns ) {
3151
            if (
3152
                 grep {/^$condition->{field}$/} @item_columns
3153
              or grep {/^$condition->{field}$/} @biblioitem_columns
3154
            ) {
3113
                if ( $condition->{value} =~ /\|/ ) {
3155
                if ( $condition->{value} =~ /\|/ ) {
3114
                    my @values = split /\|/, $condition->{value};
3156
                    my @values = split /\|/, $condition->{value};
3115
                    $query .= qq| AND $condition->{field} IN (|
3157
                    $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