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

(-)a/C4/ClassSource.pm (-2 / +10 lines)
Lines 112-123 sub GetClassSources { Link Here
112
sub AddClassSource {
112
sub AddClassSource {
113
113
114
    my ($cn_source, $description, $used, $class_sort_rule) = @_;
114
    my ($cn_source, $description, $used, $class_sort_rule) = @_;
115
    my $exists = GetClassSource($cn_source);
116
    if ($exists) {
117
        return 0;
118
    }
115
    my $dbh = C4::Context->dbh;
119
    my $dbh = C4::Context->dbh;
116
    my $sth = $dbh->prepare("INSERT INTO `class_sources`
120
    my $sth = $dbh->prepare("INSERT INTO `class_sources`
117
                                           (`cn_source`, `description`, `used`, `class_sort_rule`)
121
                                           (`cn_source`, `description`, `used`, `class_sort_rule`)
118
                                           VALUES (?, ?, ?, ?)");
122
                                           VALUES (?, ?, ?, ?)");
119
    $sth->execute($cn_source, $description, $used, $class_sort_rule);
123
    $sth->execute($cn_source, $description, $used, $class_sort_rule);
120
  
124
    return 1;
121
}
125
}
122
126
123
=head2 GetClassSource
127
=head2 GetClassSource
Lines 224-235 sub GetClassSortRules { Link Here
224
sub AddClassSortRule {
228
sub AddClassSortRule {
225
229
226
    my ($class_sort_rule, $description, $sort_routine) = @_;
230
    my ($class_sort_rule, $description, $sort_routine) = @_;
231
    my $exists = GetClassSortRule($class_sort_rule);
232
    if ($exists) {
233
        return 0;
234
    }
227
    my $dbh = C4::Context->dbh;
235
    my $dbh = C4::Context->dbh;
228
    my $sth = $dbh->prepare("INSERT INTO `class_sort_rules`
236
    my $sth = $dbh->prepare("INSERT INTO `class_sort_rules`
229
                                           (`class_sort_rule`, `description`, `sort_routine`)
237
                                           (`class_sort_rule`, `description`, `sort_routine`)
230
                                           VALUES (?, ?, ?)");
238
                                           VALUES (?, ?, ?)");
231
    $sth->execute($class_sort_rule, $description, $sort_routine);
239
    $sth->execute($class_sort_rule, $description, $sort_routine);
232
  
240
    return 1;
233
}
241
}
234
242
235
=head2 GetClassSortRule
243
=head2 GetClassSortRule
(-)a/admin/classsources.pl (-4 / +12 lines)
Lines 118-125 sub add_class_source_form { Link Here
118
118
119
sub add_class_source {
119
sub add_class_source {
120
    my ($template, $source_code, $description, $used, $sort_rule) = @_;
120
    my ($template, $source_code, $description, $used, $sort_rule) = @_;
121
    AddClassSource($source_code, $description, $used, $sort_rule);
121
    my $success = AddClassSource($source_code, $description, $used, $sort_rule);
122
    $template->param(added_source => $source_code);
122
    if ($success > 0) {
123
        $template->param(added_source => $source_code);
124
    } else {
125
        $template->param(failed_add_source => $source_code);
126
    }
123
}
127
}
124
128
125
sub edit_class_source_form {
129
sub edit_class_source_form {
Lines 189-196 sub add_class_sort_rule_form { Link Here
189
193
190
sub add_class_sort_rule {
194
sub add_class_sort_rule {
191
    my ($template, $rule_code, $description, $sort_routine) = @_;
195
    my ($template, $rule_code, $description, $sort_routine) = @_;
192
    AddClassSortRule($rule_code, $description, $sort_routine);
196
    my $success = AddClassSortRule($rule_code, $description, $sort_routine);
193
    $template->param(added_rule => $rule_code);
197
    if ($success > 0) {
198
        $template->param(added_rule => $rule_code);
199
    } else {
200
        $template->param(failed_add_rule => $rule_code);
201
    }
194
}
202
}
195
203
196
sub delete_sort_rule_form {
204
sub delete_sort_rule_form {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/classsources.tt (-1 / +6 lines)
Lines 199-204 Link Here
199
[% IF ( deleted_source ) %]
199
[% IF ( deleted_source ) %]
200
<div class="dialog message">Deleted classification source [% deleted_source %]</div>
200
<div class="dialog message">Deleted classification source [% deleted_source %]</div>
201
[% END %]
201
[% END %]
202
[% IF ( failed_add_source ) %]
203
<div class="dialog message">Failed to add classification source [% failed_add_source %]. Perhaps the code already exists?</div>
204
[% END %]
202
<table>
205
<table>
203
  <tr>
206
  <tr>
204
    <th>Code</th>
207
    <th>Code</th>
Lines 231-236 Link Here
231
[% IF ( deleted_rule ) %]
234
[% IF ( deleted_rule ) %]
232
<div class="dialog message">Deleted filing rule [% deleted_rule %]</div>
235
<div class="dialog message">Deleted filing rule [% deleted_rule %]</div>
233
[% END %]
236
[% END %]
237
[% IF ( failed_add_rule ) %]
238
<div class="dialog message">Failed to add filing rule [% failed_add_rule %]. Perhaps the code already exists?</div>
239
[% END %]
234
<table>
240
<table>
235
  <tr>
241
  <tr>
236
    <th>Code</th>
242
    <th>Code</th>
237
- 

Return to bug 17208