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

(-)a/C4/Serials/Frequency.pm (+30 lines)
Lines 35-40 BEGIN { Link Here
35
      &AddSubscriptionFrequency
35
      &AddSubscriptionFrequency
36
      &ModSubscriptionFrequency
36
      &ModSubscriptionFrequency
37
      &DelSubscriptionFrequency
37
      &DelSubscriptionFrequency
38
39
      &GetSubscriptionsWithFrequency
38
    );
40
    );
39
}
41
}
40
42
Lines 244-249 sub DelSubscriptionFrequency { Link Here
244
    $sth->execute($frequencyid);
246
    $sth->execute($frequencyid);
245
}
247
}
246
248
249
=head3 GetSubscriptionsWithFrequency
250
251
    my @subs = GetSubscriptionsWithFrequency($frequencyid);
252
253
Returns all subscriptions that are using a particular frequency
254
255
=cut
256
257
sub GetSubscriptionsWithFrequency {
258
    my ($frequencyid) = @_;
259
260
    return unless $frequencyid;
261
262
    my $dbh = C4::Context->dbh;
263
    my $query = qq{
264
        SELECT *
265
        FROM subscription
266
          LEFT JOIN biblio ON subscription.biblionumber = biblio.biblionumber
267
        WHERE periodicity = ?
268
    };
269
    my $sth = $dbh->prepare($query);
270
    my @results;
271
    if ($sth->execute($frequencyid)) {
272
        @results = @{ $sth->fetchall_arrayref({}) };
273
    }
274
    return @results;
275
}
276
247
1;
277
1;
248
278
249
__END__
279
__END__
(-)a/C4/Serials/Numberpattern.pm (+28 lines)
Lines 38-43 BEGIN { Link Here
38
        &ModSubscriptionNumberpattern
38
        &ModSubscriptionNumberpattern
39
        &DelSubscriptionNumberpattern
39
        &DelSubscriptionNumberpattern
40
40
41
        &GetSubscriptionsWithNumberpattern
41
    );
42
    );
42
}
43
}
43
44
Lines 253-258 sub DelSubscriptionNumberpattern { Link Here
253
    $sth->execute($numberpatternid);
254
    $sth->execute($numberpatternid);
254
}
255
}
255
256
257
=head3 GetSubscriptionsWithNumberpattern
258
259
    my @subs = GetSubscriptionsWithNumberpattern($numberpatternid);
260
261
Returns all subscriptions that are using a particular numbering pattern
262
263
=cut
264
265
sub GetSubscriptionsWithNumberpattern {
266
    my ($numberpatternid) = @_;
267
268
    return unless $numberpatternid;
269
270
    my $dbh = C4::Context->dbh;
271
    my $query = qq{
272
        SELECT *
273
        FROM subscription
274
          LEFT JOIN biblio ON subscription.biblionumber = biblio.biblionumber
275
        WHERE numberpattern = ?
276
    };
277
    my $sth = $dbh->prepare($query);
278
    my @results;
279
    if ($sth->execute($numberpatternid)) {
280
        @results = @{ $sth->fetchall_arrayref({}) };
281
    }
282
    return @results;
283
}
256
284
257
285
258
1;
286
1;
(-)a/installer/data/mysql/kohastructure.sql (-2 / +2 lines)
Lines 1927-1934 CREATE TABLE `subscription` ( Link Here
1927
  `graceperiod` int(11) NOT NULL default '0',
1927
  `graceperiod` int(11) NOT NULL default '0',
1928
  `enddate` date default NULL,
1928
  `enddate` date default NULL,
1929
  PRIMARY KEY  (`subscriptionid`),
1929
  PRIMARY KEY  (`subscriptionid`),
1930
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id),
1930
  CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
1931
  CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id)
1931
  CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
1932
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1932
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1933
1933
1934
--
1934
--
(-)a/installer/data/mysql/updatedatabase.pl (-14 / +39 lines)
Lines 5677-5682 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5677
        VALUES
5677
        VALUES
5678
            (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
5678
            (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
5679
    |);
5679
    |);
5680
    my $check_numberpatterns_sth = $dbh->prepare(qq|
5681
        SELECT * FROM subscription_numberpatterns
5682
        WHERE add1 = ? AND add2 = ? AND add3 = ?
5683
          AND every1 = ? AND every2 = ? AND every3 = ?
5684
          AND whenmorethan1 = ? AND whenmorethan2 = ? AND whenmorethan3 = ?
5685
          AND setto1 = ? AND setto2 = ? AND setto3 = ?
5686
          AND numberingmethod = ?
5687
        LIMIT 1
5688
    |);
5680
    my $update_subscription_sth = $dbh->prepare(qq|
5689
    my $update_subscription_sth = $dbh->prepare(qq|
5681
        UPDATE subscription
5690
        UPDATE subscription
5682
        SET numberpattern = ?,
5691
        SET numberpattern = ?,
Lines 5686-5705 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5686
5695
5687
    my $i = 1;
5696
    my $i = 1;
5688
    while(my $sub = $sth->fetchrow_hashref) {
5697
    while(my $sub = $sth->fetchrow_hashref) {
5689
        # Create a new numbering pattern for each subscription
5698
        $check_numberpatterns_sth->execute(
5690
        my $ok = $insert_numberpatterns_sth->execute(
5699
            $sub->{add1}, $sub->{add2}, $sub->{add3},
5691
            "Backup pattern $i", 4+$i, "Automatically created pattern by updatedatabase", $sub->{numberingmethod},
5700
            $sub->{every1}, $sub->{every2}, $sub->{every3},
5692
            "X", $sub->{add1}, $sub->{every1}, $sub->{whenmorethan1}, $sub->{setto1}, undef,
5701
            $sub->{whenmorethan1}, $sub->{whenmorethan2}, $sub->{whenmorethan3},
5693
            "Y", $sub->{add2}, $sub->{every2}, $sub->{whenmorethan2}, $sub->{setto2}, undef,
5702
            $sub->{setto1}, $sub->{setto2}, $sub->{setto3},
5694
            "Z", $sub->{add3}, $sub->{every3}, $sub->{whenmorethan3}, $sub->{setto3}, undef
5703
            $sub->{numberingmethod}
5695
        );
5704
        );
5696
        if($ok) {
5705
        my $p = $check_numberpatterns_sth->fetchrow_hashref;
5697
            my $id = $dbh->last_insert_id(undef, undef, 'subscription_numberpatterns', undef);
5706
        if (defined $p) {
5698
            # Link to subscription_numberpatterns and subscription_frequencies
5707
            # Pattern already exists, link to it
5699
            $update_subscription_sth->execute($id,
5708
            $update_subscription_sth->execute($p->{id},
5700
                $frequencies_mapping->{$sub->{periodicity}}, $sub->{subscriptionid});
5709
                $frequencies_mapping->{$sub->{periodicity}},
5710
                $sub->{subscriptionid});
5711
        } else {
5712
            # Create a new numbering pattern for this subscription
5713
            my $ok = $insert_numberpatterns_sth->execute(
5714
                "Backup pattern $i", 4+$i, "Automatically created pattern by updatedatabase", $sub->{numberingmethod},
5715
                "X", $sub->{add1}, $sub->{every1}, $sub->{whenmorethan1}, $sub->{setto1}, undef,
5716
                "Y", $sub->{add2}, $sub->{every2}, $sub->{whenmorethan2}, $sub->{setto2}, undef,
5717
                "Z", $sub->{add3}, $sub->{every3}, $sub->{whenmorethan3}, $sub->{setto3}, undef
5718
            );
5719
            if($ok) {
5720
                my $id = $dbh->last_insert_id(undef, undef, 'subscription_numberpatterns', undef);
5721
                # Link to subscription_numberpatterns and subscription_frequencies
5722
                $update_subscription_sth->execute($id,
5723
                    $frequencies_mapping->{$sub->{periodicity}},
5724
                    $sub->{subscriptionid});
5725
            }
5726
            $i++;
5701
        }
5727
        }
5702
        $i++;
5703
    }
5728
    }
5704
5729
5705
    # Remove now useless columns
5730
    # Remove now useless columns
Lines 5724-5731 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5724
        ADD COLUMN countissuesperunit INTEGER NOT NULL DEFAULT 1 AFTER periodicity,
5749
        ADD COLUMN countissuesperunit INTEGER NOT NULL DEFAULT 1 AFTER periodicity,
5725
        ADD COLUMN skip_serialseq BOOLEAN NOT NULL DEFAULT 0 AFTER irregularity,
5750
        ADD COLUMN skip_serialseq BOOLEAN NOT NULL DEFAULT 0 AFTER irregularity,
5726
        ADD COLUMN locale VARCHAR(80) DEFAULT NULL AFTER numberpattern,
5751
        ADD COLUMN locale VARCHAR(80) DEFAULT NULL AFTER numberpattern,
5727
        ADD CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id),
5752
        ADD CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
5728
        ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id)
5753
        ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
5729
    |);
5754
    |);
5730
5755
5731
    print "Upgrade to $DBversion done (Add subscription_frequencies and subscription_numberpatterns tables)\n";
5756
    print "Upgrade to $DBversion done (Add subscription_frequencies and subscription_numberpatterns tables)\n";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-11 / +46 lines)
Lines 212-217 function modifyAdvancedPattern() { Link Here
212
    $("#advancedpredictionpatternt input").each(function() {
212
    $("#advancedpredictionpatternt input").each(function() {
213
        $(this).attr("readonly", false);
213
        $(this).attr("readonly", false);
214
    });
214
    });
215
    $("#advancedpredictionpatternt select").each(function() {
216
        $(this).attr("disabled", false);
217
    });
215
218
216
    $("#restoreadvancedpatternbutton").show();
219
    $("#restoreadvancedpatternbutton").show();
217
    $("#saveadvancedpatternbutton").show();
220
    $("#saveadvancedpatternbutton").show();
Lines 234-239 function restoreAdvancedPattern() { Link Here
234
            $(this).val(unescape(globalnumpatterndata[id]));
237
            $(this).val(unescape(globalnumpatterndata[id]));
235
        }
238
        }
236
    });
239
    });
240
    $("#advancedpredictionpatternt select").each(function() {
241
        $(this).attr("disabled", true);
242
        var id = $(this).attr('id');
243
        $(this).val(unescape(globalnumpatterndata[id]));
244
    });
237
245
238
    $("#restoreadvancedpatternbutton").hide();
246
    $("#restoreadvancedpatternbutton").hide();
239
    $("#saveadvancedpatternbutton").hide();
247
    $("#saveadvancedpatternbutton").hide();
Lines 310-315 function testPredictionPattern() { Link Here
310
}
318
}
311
319
312
function saveAdvancedPattern() {
320
function saveAdvancedPattern() {
321
    if ($("#patternname").val().length == 0) {
322
        alert(_("Please enter a name for this pattern"));
323
        return false;
324
    }
325
313
    // Check if patternname already exists, and modify pattern
326
    // Check if patternname already exists, and modify pattern
314
    // instead of creating it if so
327
    // instead of creating it if so
315
    var found = 0;
328
    var found = 0;
Lines 321-327 function saveAdvancedPattern() { Link Here
321
    });
334
    });
322
    var cnfrm = 1;
335
    var cnfrm = 1;
323
    if(found){
336
    if(found){
324
        cnfrm = confirm(_("This pattern already exists. Do you want to modify it"));
337
        var msg = _("This pattern name already exists. Do you want to modify it?")
338
            + "\n" + _("Warning: it will modify the pattern for all subscriptions")
339
            + _("that are using it.");
340
        cnfrm = confirm(msg);
325
    }
341
    }
326
342
327
    if(cnfrm) {
343
    if(cnfrm) {
Lines 343-353 function saveAdvancedPattern() { Link Here
343
            "/cgi-bin/koha/serials/create-numberpattern.pl",
359
            "/cgi-bin/koha/serials/create-numberpattern.pl",
344
            ajaxData,
360
            ajaxData,
345
            function(data){
361
            function(data){
346
                if(found == 0){
362
                if (data.numberpatternid) {
347
                    $("#numberpattern").append("<option value=\""+data.numberpatternid+"\">"+$("#patternname").val()+"</option>");
363
                    if(found == 0){
364
                        $("#numberpattern").append("<option value=\""+data.numberpatternid+"\">"+$("#patternname").val()+"</option>");
365
                    }
366
                    $("#numberpattern").val(data.numberpatternid);
367
                    numberpatternload();
368
                } else {
369
                    alert(_("Something went wrong. Unable to create a new numbering pattern."));
348
                }
370
                }
349
                $("#numberpattern").val(data.numberpatternid);
350
                numberpatternload();
351
            }
371
            }
352
        );
372
        );
353
    }
373
    }
Lines 660-666 $(document).ready(function() { Link Here
660
                                        <input type="text" size="10" id="to" name="enddate" value="[% enddate | $KohaDates %]" class="datepickerto" readonly="readonly"/>
680
                                        <input type="text" size="10" id="to" name="enddate" value="[% enddate | $KohaDates %]" class="datepickerto" readonly="readonly"/>
661
                                    </li>
681
                                    </li>
662
                                    <li>
682
                                    <li>
663
                                        <label for="numberpattern"> Numbering pattern:</label>
683
                                        <label for="numberpattern">Numbering pattern:</label>
664
                                        <select name="numbering_pattern" size="1" id="numberpattern">
684
                                        <select name="numbering_pattern" size="1" id="numberpattern">
665
                                            <option value="">-- please choose --</option>
685
                                            <option value="">-- please choose --</option>
666
                                            [% FOREACH numberpattern IN numberpatterns %]
686
                                            [% FOREACH numberpattern IN numberpatterns %]
Lines 670-676 $(document).ready(function() { Link Here
670
                                    </li>
690
                                    </li>
671
                                    <li>
691
                                    <li>
672
                                        <label for="locale">Locale</label>
692
                                        <label for="locale">Locale</label>
673
                                        <input type="text" id="locale" name="locale" value="[% locale %]" />
693
                                        <select id="locale" name="locale">
694
                                            <option value=""></option>
695
                                            [% FOREACH locale IN locales %]
696
                                                <option value="[% locale %]">
697
                                                    [% locale %]
698
                                                </option>
699
                                            [% END %]
700
                                        </select>
674
                                        <span class="hint">If empty, system locale is used</span>
701
                                        <span class="hint">If empty, system locale is used</span>
675
                                    </li>
702
                                    </li>
676
                                    <li id="more_options">
703
                                    <li id="more_options">
Lines 771-780 $(document).ready(function() { Link Here
771
                                                    <td><input type="text" readonly="readonly" id="innerloop3" name="innerloop3" /></td>
798
                                                    <td><input type="text" readonly="readonly" id="innerloop3" name="innerloop3" /></td>
772
                                                </tr>
799
                                                </tr>
773
                                                <tr>
800
                                                <tr>
774
                                                    <td>Numbering</td>
801
                                                    [% BLOCK numbering_select %]
775
                                                    <td><input type="text" readonly="readonly" id="numbering1" name="numbering1" /></td>
802
                                                        <select disabled="disabled" id="[% name %]" name="[% name %]" />
776
                                                    <td><input type="text" readonly="readonly" id="numbering2" name="numbering2" /></td>
803
                                                            <option value=""></option>
777
                                                    <td><input type="text" readonly="readonly" id="numbering3" name="numbering3" /></td>
804
                                                            <option value="dayname">Name of day</option>
805
                                                            <option value="monthname">Name of month</option>
806
                                                            <option value="season">Name of season</option>
807
                                                        </select>
808
                                                    [% END %]
809
                                                    <td>Formatting</td>
810
                                                    <td>[% PROCESS numbering_select name="numbering1" %]</td>
811
                                                    <td>[% PROCESS numbering_select name="numbering2" %]</td>
812
                                                    <td>[% PROCESS numbering_select name="numbering3" %]</td>
778
                                                </tr>
813
                                                </tr>
779
                                            </tbody>
814
                                            </tbody>
780
                                        </table>
815
                                        </table>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-frequencies.tt (-2 / +32 lines)
Lines 44-49 function check_form() { Link Here
44
    return false;
44
    return false;
45
}
45
}
46
46
47
function show_blocking_subs() {
48
    $("#blocking_subs").show();
49
}
50
47
$(document).ready(function() {
51
$(document).ready(function() {
48
    $("#issuesperunit").change(function() {
52
    $("#issuesperunit").change(function() {
49
        var value = $(this).val();
53
        var value = $(this).val();
Lines 140-149 $(document).ready(function() { Link Here
140
          </fieldset>
144
          </fieldset>
141
        </form>
145
        </form>
142
      [% ELSE %]
146
      [% ELSE %]
147
        <h1>Frequencies</h1>
148
        [% IF still_used %]
149
            <div class="dialog">
150
                <p>
151
                    This frequency is still used by [% subscriptions.size %]
152
                    subscription(s). Do you still want to delete it?
153
                </p>
154
                <p><a href="#" onclick="show_blocking_subs(); return false;">Show subscriptions</a></p>
155
                <ul id="blocking_subs" style="display:none">
156
                    [% FOREACH sub IN subscriptions %]
157
                        <li style="list-style-type:none">
158
                            <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% sub.subscriptionid %]">[% sub.title %]</a>
159
                        </li>
160
                    [% END %]
161
                </ul>
162
163
                <form action="" method="get">
164
                    <input type="hidden" name="op" value="del" />
165
                    <input type="hidden" name="confirm" value="1" />
166
                    <input type="hidden" name="frequencyid" value="[% frequencyid %]" />
167
                    <input type="submit" class="approve" value="Yes, delete" />
168
                </form>
169
                <form action="" method="get">
170
                    <input type="submit" class="deny" value="No, don't delete" />
171
                </form>
172
            </div>
173
        [% END %]
143
        <a href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=new">New frenquency</a>
174
        <a href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=new">New frenquency</a>
144
175
145
        [% IF (frequencies_loop.size) %]
176
        [% IF (frequencies_loop.size) %]
146
          <h1>Frenquencies</h1>
147
          <table id="frequenciest">
177
          <table id="frequenciest">
148
            <thead>
178
            <thead>
149
              <tr>
179
              <tr>
Lines 165-171 $(document).ready(function() { Link Here
165
                  <td>[% frequency.displayorder %]</td>
195
                  <td>[% frequency.displayorder %]</td>
166
                  <td>
196
                  <td>
167
                    <a href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=modify&frequencyid=[% frequency.id %]">Modify</a> |
197
                    <a href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=modify&frequencyid=[% frequency.id %]">Modify</a> |
168
                    <a href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=del&frequencyid=[% frequency.id %]" onclick="return confirmDelete();">Delete</a>
198
                    <a href="/cgi-bin/koha/serials/subscription-frequencies.pl?op=del&frequencyid=[% frequency.id %]">Delete</a>
169
                  </td>
199
                  </td>
170
                </tr>
200
                </tr>
171
              [% END %]
201
              [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt (-17 / +61 lines)
Lines 53-58 Link Here
53
      });
53
      });
54
  }
54
  }
55
[% END %]
55
[% END %]
56
57
function show_blocking_subs() {
58
    $("#blocking_subs").show();
59
}
56
//]]>
60
//]]>
57
</script>
61
</script>
58
</head>
62
</head>
Lines 158-167 Link Here
158
                    <td><input type="text" id="whenmorethan3" name="whenmorethan3" value="[% whenmorethan3 %]" /></td>
162
                    <td><input type="text" id="whenmorethan3" name="whenmorethan3" value="[% whenmorethan3 %]" /></td>
159
                  </tr>
163
                  </tr>
160
                  <tr>
164
                  <tr>
161
                    <td>Numbering</td>
165
                    [% BLOCK numbering_select %]
162
                    <td><input type="text" id="numbering1" name="numbering1" value="[% numbering1 %]" /></td>
166
                      <select id="[% name %]" name="[% name %]" />
163
                    <td><input type="text" id="numbering2" name="numbering2" value="[% numbering2 %]" /></td>
167
                        <option value=""></option>
164
                    <td><input type="text" id="numbering3" name="numbering3" value="[% numbering3 %]" /></td>
168
                        [% IF (value == "dayname") %]
169
                            <option selected="selected" value="dayname">Name of day</option>
170
                        [% ELSE %]
171
                            <option value="dayname">Name of day</option>
172
                        [% END %]
173
                        [% IF (value == "monthname") %]
174
                            <option selected="selected" value="monthname">Name of month</option>
175
                        [% ELSE %]
176
                            <option value="monthname">Name of month</option>
177
                        [% END %]
178
                        [% IF (value == "season") %]
179
                            <option selected="selected" value="season">Name of season</option>
180
                        [% ELSE %]
181
                            <option value="season">Name of season</option>
182
                        [% END %]
183
                      </select>
184
                    [% END %]
185
                    <td>Fromatting</td>
186
                    <td>[% PROCESS numbering_select name="numbering1" value=numbering1 %]</td>
187
                    <td>[% PROCESS numbering_select name="numbering2" value=numbering2 %]</td>
188
                    <td>[% PROCESS numbering_select name="numbering3" value=numbering3 %]</td>
165
                  </tr>
189
                  </tr>
166
                </tbody>
190
                </tbody>
167
              </table>
191
              </table>
Lines 188-205 Link Here
188
                </li>
212
                </li>
189
                <li>
213
                <li>
190
                  <label for="firstacquidate">First issue publication date</label>
214
                  <label for="firstacquidate">First issue publication date</label>
191
                  <input type="text" id="firstacquidate" size="10" />
215
                  <input type="text" id="firstacquidate" class="datepicker" size="10" />
192
                  <img src="[% themelang %]/lib/calendar/cal.gif" id="firstacquidatebutton" style="cursor:pointer" alt="Show Calendar" title="Show Calendar" />
193
                  <script type="text/javascript">
194
                    //<![CDATA[
195
                    Calendar.setup({
196
                      inputField: "firstacquidate",
197
                      ifFormat: "[% DHTMLcalendar_dateformat %]",
198
                      button: "firstacquidatebutton",
199
                      align: "Tl"
200
                    });
201
                    //]]>
202
                  </script>
203
                </li>
216
                </li>
204
                <li>
217
                <li>
205
                  <label for="sublength">Subscription length:</label>
218
                  <label for="sublength">Subscription length:</label>
Lines 212-218 Link Here
212
                </li>
225
                </li>
213
                <li>
226
                <li>
214
                  <label for="locale">Locale:</label>
227
                  <label for="locale">Locale:</label>
215
                  <input type="text" id="locale" name="locale" />
228
                  <select id="locale" name="locale">
229
                      <option value=""></option>
230
                      [% FOREACH locale IN locales %]
231
                        <option value="[% locale %]">[% locale %]</option>
232
                      [% END %]
233
                    </select>
216
                  <span class="hint">If empty, system locale is used</span>
234
                  <span class="hint">If empty, system locale is used</span>
217
                </li>
235
                </li>
218
              </ol>
236
              </ol>
Lines 249-254 Link Here
249
        </div>
267
        </div>
250
      [% ELSE %]
268
      [% ELSE %]
251
        <h1>Number patterns</h1>
269
        <h1>Number patterns</h1>
270
        [% IF still_used %]
271
            <div class="dialog">
272
                <p>
273
                    This pattern is still used by [% subscriptions.size %]
274
                    subscription(s). Do you still want to delete it?
275
                </p>
276
                <p><a href="#" onclick="show_blocking_subs(); return false;">Show subscriptions</a></p>
277
                <ul id="blocking_subs" style="display:none">
278
                    [% FOREACH sub IN subscriptions %]
279
                        <li style="list-style-type:none">
280
                            <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% sub.subscriptionid %]">[% sub.title %]</a>
281
                        </li>
282
                    [% END %]
283
                </ul>
284
285
                <form action="" method="get">
286
                    <input type="hidden" name="op" value="del" />
287
                    <input type="hidden" name="confirm" value="1" />
288
                    <input type="hidden" name="id" value="[% id %]" />
289
                    <input type="submit" class="approve" value="Yes, delete" />
290
                </form>
291
                <form action="" method="get">
292
                    <input type="submit" class="deny" value="No, don't delete" />
293
                </form>
294
            </div>
295
        [% END %]
252
        <a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=new">New numbering pattern</a>
296
        <a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=new">New numbering pattern</a>
253
        [% IF (numberpatterns_loop.size) %]
297
        [% IF (numberpatterns_loop.size) %]
254
          <table id="numberpatternst">
298
          <table id="numberpatternst">
(-)a/serials/subscription-add.pl (+10 lines)
Lines 210-215 if ($op eq 'addsubscription') { Link Here
210
    }
210
    }
211
    $template->param(numberpatterns => \@numberpatternloop);
211
    $template->param(numberpatterns => \@numberpatternloop);
212
212
213
    # Get installed locales
214
    # FIXME this will not work with all environments.
215
    # If call to locale fails, @locales will be an empty array, which is fine.
216
    my @locales = map {
217
        chomp;
218
        # we don't want POSIX and C locales
219
        /^C|^POSIX$/ ? () : $_
220
    } `locale -a`;
221
    $template->param(locales => \@locales);
222
213
    output_html_with_http_headers $query, $cookie, $template->output;
223
    output_html_with_http_headers $query, $cookie, $template->output;
214
}
224
}
215
225
(-)a/serials/subscription-frequencies.pl (-1 / +17 lines)
Lines 92-98 if($op && ($op eq 'savenew' || $op eq 'savemod')) { Link Here
92
} elsif($op && $op eq 'del') {
92
} elsif($op && $op eq 'del') {
93
    my $frequencyid = $input->param('frequencyid');
93
    my $frequencyid = $input->param('frequencyid');
94
94
95
    DelSubscriptionFrequency($frequencyid);
95
    if ($frequencyid) {
96
        my $confirm = $input->param('confirm');
97
        if ($confirm) {
98
            DelSubscriptionFrequency($frequencyid);
99
        } else {
100
            my @subs = GetSubscriptionsWithFrequency($frequencyid);
101
            if (@subs) {
102
                $template->param(
103
                    frequencyid => $frequencyid,
104
                    still_used => 1,
105
                    subscriptions => \@subs
106
                );
107
            } else {
108
                DelSubscriptionFrequency($frequencyid);
109
            }
110
        }
111
    }
96
}
112
}
97
113
98
114
(-)a/serials/subscription-numberpatterns.pl (-3 / +22 lines)
Lines 104-113 if($op && ($op eq 'new' || $op eq 'modify')) { Link Here
104
    my @frequencies = GetSubscriptionFrequencies();
104
    my @frequencies = GetSubscriptionFrequencies();
105
    my @subtypes;
105
    my @subtypes;
106
    push @subtypes, { value => $_ } for (qw/ issues weeks months /);
106
    push @subtypes, { value => $_ } for (qw/ issues weeks months /);
107
    my @locales = map {
108
        chomp;
109
        /^C|^POSIX$/ ? () : $_
110
    } `locale -a`;
111
107
    $template->param(
112
    $template->param(
108
        $op => 1,
113
        $op => 1,
109
        frequencies_loop => \@frequencies,
114
        frequencies_loop => \@frequencies,
110
        subtypes_loop => \@subtypes,
115
        subtypes_loop => \@subtypes,
116
        locales => \@locales,
111
        DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
117
        DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
112
    );
118
    );
113
    output_html_with_http_headers $input, $cookie, $template->output;
119
    output_html_with_http_headers $input, $cookie, $template->output;
Lines 116-123 if($op && ($op eq 'new' || $op eq 'modify')) { Link Here
116
122
117
if($op && $op eq 'del') {
123
if($op && $op eq 'del') {
118
    my $id = $input->param('id');
124
    my $id = $input->param('id');
119
    if(defined $id) {
125
    if ($id) {
120
        DelSubscriptionNumberpattern($id);
126
        my $confirm = $input->param('confirm');
127
        if ($confirm) {
128
            DelSubscriptionNumberpattern($id);
129
        } else {
130
            my @subs = GetSubscriptionsWithNumberpattern($id);
131
            if (@subs) {
132
                $template->param(
133
                    id => $id,
134
                    still_used => 1,
135
                    subscriptions => \@subs
136
                );
137
            } else {
138
                DelSubscriptionNumberpattern($id);
139
            }
140
        }
121
    }
141
    }
122
}
142
}
123
143
124
- 

Return to bug 7688