It will avoid crash and invalid data when creating/updating a
subscription.
This could have been done with a AJAX query but seems more convenient
this way.
Test plan:
- Create or update a subscription
- In the "Vendor" input try an empty string, a valid vendor's id, and
invalid one.
=> With an empty string you get the existing alert message
=> With a valid id you do not get any messages
=> With an invalid id you are not allowed to go to page 2
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
[% USE raw %]
+[% USE To %]
[% USE Asset %]
[% USE KohaDates %]
[% USE Branches %]
var MSG_MANA_SHOW_DETAILS = _("Show Mana results");
var MSG_MANA_NO_SUBSCRIPTION_FOUND = _("No subscription found on Mana Knowledge Base");
var MSG_MANA_SHARE_PATTERN = _("Please feel free to share your pattern with all others librarians once you are done");
+
+ var BOOKSELLER_IDS = [% To.json( bookseller_ids ) || '[]' | $raw %];
</script>
[% Asset.js("js/subscription-add.js") | $raw %]
[% Asset.js("js/showpredictionpattern.js") | $raw %]
}
function Check_page1() {
- if ( $("#aqbooksellerid").val().length == 0) {
+ var bookseller_id = $("#aqbooksellerid").val();
+ if ( bookseller_id.length == 0) {
input_box = confirm( MSG_LINK_TO_VENDOR );
if (input_box==false) {
return false;
}
+ } else {
+ var bookseller_ids = BOOKSELLER_IDS;
+ if ( $.inArray(Number(bookseller_id), bookseller_ids) == -1 ) {
+ alert ("The vendor does not exist");
+ return false;
+ }
}
var biblionumber = $("#biblionumber").val()
$template->param( locales => $languages );
+ my @bookseller_ids = Koha::Acquisition::Booksellers->search->get_column('id');
+ $template->param( bookseller_ids => \@bookseller_ids );
+
output_html_with_http_headers $query, $cookie, $template->output;
}