Koha-clms/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt

654 lines
41 KiB
Plaintext

[% USE raw %]
[% USE Koha %]
[% USE Asset %]
[% USE AuthorisedValues %]
[% USE KohaDates %]
[% USE Branches %]
[% USE Price %]
[% SET footerjs = 1 %]
[% PROCESS 'i18n.inc' %]
[% INCLUDE 'doc-head-open.inc' %]
<title
>[% FILTER collapse %]
[% t("Invoices") | html %]
&rsaquo; [% t("Acquisitions") | html %] &rsaquo; [% t("Koha") | html %]
[% END %]</title
>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="acq_invoices" class="acq">
[% WRAPPER 'header.inc' %]
[% INCLUDE 'acquisitions-search.inc' %]
[% END %]
[% WRAPPER 'sub-header.inc' %]
[% WRAPPER breadcrumbs %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
[% END %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
<span>Invoices</span>
[% END %]
[% END #/ WRAPPER breadcrumbs %]
[% END #/ WRAPPER sub-header.inc %]
<div class="main container-fluid">
<div class="row">
<div class="col-md-10 order-md-2 order-sm-2">
<main>
[% INCLUDE 'messages.inc' %]
<h1>Invoices</h1>
[% IF ( do_search ) %]
[% IF invoices %]
[% BLOCK invoices_table %]
[% IF closed %]
[% SET tab = 'closed' %]
[% ELSE %]
[% SET tab = 'opened' %]
[% END %]
<input type="checkbox" style="vertical-align: middle;" id="show_only_subscription_[% tab | html %]" class="show_only_subscription" data-tableid="[% tab | html %]resultst" />
<label for="show_only_subscription_[% tab | html %]"> Show only subscriptions </label>
<p
><a id="CheckAll[% tab | html %]table" data-cb="[% tab | html %]" class="checkall" href="#"><i class="fa fa-check"></i> Select all</a> |
<a id="UncheckAll[% tab | html %]table" data-cb="[% tab | html %]" class="uncheckall" href="#"><i class="fa fa-times"></i> Clear all</a></p
>
<table id="[% tab | html %]resultst" class="result">
<thead>
<tr>
[% IF CAN_user_acquisition_merge_invoices %]
<th>&nbsp;</th>
[% END %]
<th class="no-sort">&nbsp;</th>
<th>Invoice number</th>
<th>Vendor</th>
<th>Shipment date</th>
<th>Billing date</th>
<th>Received bibliographic records</th>
<th>Received items</th>
<th>Total</th>
<th>Status</th>
<th class="no-sort">&nbsp;</th>
</tr>
</thead>
<tbody>
[% FOREACH invoice IN invoices %]
<tr
data-invoiceid="[% invoice.invoiceid | html %]"
data-booksellerid="[% invoice.booksellerid | html %]"
data-shipmentdate="[% invoice.shipmentdate | html %]"
data-billingdate="[% invoice.billingdate | html %]"
data-shipmentcost="[% invoice.shipmentcost | html %]"
data-shipment_budgetid="[% invoice.shipmentcost_budgetid | html %]"
data-closedate="[% invoice.closedate | html %]"
>
[% IF CAN_user_acquisition_merge_invoices %]
<td>[% invoice.is_linked_to_subscriptions | html %]</td>
[% END %]
<td><input type="checkbox" class="select-invoice" value="[% invoice.invoiceid | html %]" /></td>
<td><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | uri %]">[% invoice.invoicenumber | html %]</a></td>
<td><a href="/cgi-bin/koha/acquisition/vendors/[% invoice.booksellerid | uri %]">[% invoice.suppliername | html %]</a></td>
<td data-order="[% invoice.shipmentdate | html %]"> [% invoice.shipmentdate | $KohaDates %] </td>
<td data-order="[% invoice.billingdate | html %]"> [% invoice.billingdate | $KohaDates %] </td>
<td>[% invoice.receivedbiblios | html %]</td>
<td>[% invoice.receiveditems | html %]</td>
<td>
[% IF invoice.invoiceincgst %]
[% invoice.total_tax_included + invoice.total_adj + invoice.shipmentcost | $Price %]
[% ELSE %]
[% invoice.total_tax_excluded + invoice.total_adj + invoice.shipmentcost | $Price %]
[% END %]
</td>
<td>
[% IF invoice.closedate %]
<span>Closed on [% invoice.closedate | $KohaDates %]</span>
[% ELSE %]
<span>Open</span>
[% END %]
</td>
<td>
<div class="btn-group dropup">
<a class="btn btn-default btn-xs dropdown-toggle" id="invoiceactions[% invoice.invoiceid | html %]" role="button" data-bs-toggle="dropdown" href="#"> Actions </a>
<ul class="dropdown-menu dropdown-menu-end" role="menu" aria-labelledby="invoiceactions[% invoice.invoiceid | html %]">
<li
><a class="dropdown-item" href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | uri %]"><i class="fa fa-search"></i> Details</a></li
>
[% IF invoice.closedate %]
[% IF CAN_user_acquisition_reopen_closed_invoices %]
<li
><a
class="dropdown-item submit-form-link"
data-action="invoice.pl"
data-op="cud-reopen"
data-invoiceid="[% invoice.invoiceid | uri %]"
data-referer="/cgi-bin/koha/acqui/invoices.pl?op=do_search&invoicenumber=[% invoicenumber | uri %]&supplier=[% booksellerid | uri %]&shipmentdatefrom=[% shipmentdatefrom | uri %]&shipmentdateto=[% shipmentdateto | uri %]&billingdatefrom=[% billingdatefrom | uri %]&billingdateto=[% billingdateto | uri %]&isbneanissn=[% isbneanissn | uri %]&title=[% title | uri %]&author=[% author | uri %]&publisher=[% publisher | uri %]&publicationyear=[% publicationyear | uri %]&branch=[% branch | uri %]"
data-method="post"
><i class="fa-solid fa-rotate"></i> Reopen</a
></li
>
[% END %]
[% ELSE %]
[% IF CAN_user_acquisition_edit_invoices %]
<li
><a
class="dropdown-item submit-form-link"
data-action="invoice.pl"
data-op="cud-close"
data-invoiceid="[% invoice.invoiceid | html %]"
data-referer="/cgi-bin/koha/acqui/invoices.pl?op=do_search&invoicenumber=[% invoicenumber | uri %]&supplier=[% booksellerid | uri %]&shipmentdatefrom=[% shipmentdatefrom | uri %]&shipmentdateto=[% shipmentdateto | uri %]&billingdatefrom=[% billingdatefrom | uri %]&billingdateto=[% billingdateto | uri %]&isbneanissn=[% isbneanissn | uri %]&title=[% title | uri %]&author=[% author | uri %]&publisher=[% publisher | uri %]&publicationyear=[% publicationyear | uri %]&branch=[% branch | uri %]"
data-method="post"
><i class="fa fa-times-circle"></i> Close</a
></li
>
[% END %]
[% END # /IF invoice.closedate %]
[% UNLESS invoice.receivedbiblios || invoice.receiveditems %]
[% IF CAN_user_acquisition_delete_invoices %]
<li
><a
class="dropdown-item submit-form-link"
data-action="invoice.pl"
data-op="cud-delete"
data-confirmation-msg="[% t("Are you sure you want to delete this invoice?") | html %]"
data-invoiceid="[% invoice.invoiceid | html %]"
data-referer="/cgi-bin/koha/acqui/invoices.pl?op=do_search&invoicenumber=[% invoicenumber | uri %]&supplier=[% booksellerid | uri %]&shipmentdatefrom=[% shipmentdatefrom | uri %]&shipmentdateto=[% shipmentdateto | uri %]&billingdatefrom=[% billingdatefrom | uri %]&billingdateto=[% billingdateto | uri %]&isbneanissn=[% isbneanissn | uri %]&title=[% title | uri %]&author=[% author | uri %]&publisher=[% publisher | uri %]&publicationyear=[% publicationyear | uri %]&branch=[% branch | uri %]"
data-method="post"
><i class="fa fa-trash-can"></i> Delete</a
></li
>
[% END %]
[% END %]
</ul>
</div>
<!-- /.btn-group dropup -->
</td>
</tr>
[% END # /FOREACH invoice %]
</tbody>
</table>
<!-- /#[% tab | html %]resultst -->
[% IF CAN_user_acquisition_merge_invoices %]
[% IF tab == 'closed' %]
<a class="btn btn-default merge" id="merge_closed" href="#merge_invoices" data-table="closedresultst"><i class="fa fa-compress"></i> Merge selected invoices</a>
<a
class="submit-form-link btn btn-default"
id="open_sel"
data-table="closedresultst"
data-op="cud-reopen"
data-action="invoice.pl"
data-method="post"
data-referer="/cgi-bin/koha/acqui/invoices.pl?op=do_search&invoicenumber=[% invoicenumber | uri %]&supplier=[% booksellerid | uri %]&shipmentdatefrom=[% shipmentdatefrom | uri %]&shipmentdateto=[% shipmentdateto | uri %]&billingdatefrom=[% billingdatefrom | uri %]&billingdateto=[% billingdateto | uri %]&isbneanissn=[% isbneanissn | uri %]&title=[% title | uri %]&author=[% author | uri %]&publisher=[% publisher | uri %]&publicationyear=[% publicationyear | uri %]&branch=[% branch | uri %]"
><i class="fa-solid fa-rotate"></i> Reopen selected invoices</a
>
[% ELSE %]
<a class="btn btn-default merge" id="merge_open" href="#merge_invoices" data-table="openedresultst"><i class="fa fa-compress"></i> Merge selected invoices</a>
<a
class="submit-form-link btn btn-default"
id="close_sel"
data-table="openedresultst"
data-op="cud-close"
data-action="invoice.pl"
data-method="post"
data-referer="/cgi-bin/koha/acqui/invoices.pl?op=do_search&invoicenumber=[% invoicenumber | uri %]&supplier=[% booksellerid | uri %]&shipmentdatefrom=[% shipmentdatefrom | uri %]&shipmentdateto=[% shipmentdateto | uri %]&billingdatefrom=[% billingdatefrom | uri %]&billingdateto=[% billingdateto | uri %]&isbneanissn=[% isbneanissn | uri %]&title=[% title | uri %]&author=[% author | uri %]&publisher=[% publisher | uri %]&publicationyear=[% publicationyear | uri %]&branch=[% branch | uri %]"
><i class="fa fa-times-circle"></i> Close selected invoices</a
>
[% END # /IF tab == 'closed' %]
[% END # /IF CAN_user_acquisition_merge_invoices %]
[% END # /BLOCK invoices_table %]
[% WRAPPER tabs id= "invoicestabs" %]
[% WRAPPER tabs_nav %]
[% WRAPPER tab_item tabname= "opened" bt_active= 1 %]
<span>Open invoices</span> ([% openedinvoices.size || 0 | html %])
[% END %]
[% WRAPPER tab_item tabname= "closed" %]
<span>Closed invoices</span> ([% closedinvoices.size || 0 | html %])
[% END %]
[% END %]
[% WRAPPER tab_panels %]
[% WRAPPER tab_panel tabname="opened" bt_active= 1 %]
[% IF openedinvoices %]
[% INCLUDE invoices_table invoices = openedinvoices %]
[% ELSE %]
<div class="alert alert-info">
<p>Your search returned no open invoices.</p>
</div>
[% END %]
[% END # /#opened %]
[% WRAPPER tab_panel tabname="closed" %]
[% IF closedinvoices %]
[% INCLUDE invoices_table invoices = closedinvoices closed = 1 %]
[% ELSE %]
<div class="alert alert-info">
<p>Your search returned no closed invoices.</p>
</div>
[% END %]
[% END # /#closed %]
[% END # /tab_panels %]
[% END # /#invoicestabs %]
<div id="merge_invoices">
<form id="merge_invoice_form" class="validated" action="/cgi-bin/koha/acqui/invoice.pl" method="post">
[% INCLUDE 'csrf-token.inc' %]
<fieldset class="rows">
<ol>
<li><h2>Merge invoices</h2></li>
<li>
<table id="merge_table">
<thead>
<tr>
<th>Invoice number</th>
<th>Shipment date</th>
<th>Billing date</th>
<th>Shipment cost</th>
</tr>
</thead>
<tbody> </tbody>
</table>
</li>
<li>
<label for="merge_invoicenumber" class="required">Invoice number:</label>
<input type="text" size="10" id="merge_invoicenumber" name="invoicenumber" value="" class="required" required="required" />
<span class="required">Required</span>
</li>
<li>
<label for="merge_shipmentdate">Shipment date:</label>
<input type="text" size="10" id="merge_shipmentdate" name="shipmentdate" value="" class="flatpickr" />
<div class="hint">[% INCLUDE 'date-format.inc' %]</div>
</li>
<li>
<label for="merge_billingdate">Billing date:</label>
<input type="text" size="10" id="merge_billingdate" name="billingdate" value="" class="flatpickr" />
<div class="hint">[% INCLUDE 'date-format.inc' %]</div>
</li>
<li>
<label for="merge_shipmentcost">Shipment cost:</label>
<input class="decimal" type="text" size="10" id="merge_shipmentcost" name="shipmentcost" value="" />
</li>
<li>
<label for="merge_shipment_budgetid">Fund:</label>
<select id="merge_shipment_budgetid" name="shipment_budget_id">
<option value="">No fund</option>
[% FOREACH budget IN budgets_loop %]
<option value="[% budget.budget_id | html %]">[% budget.budget_name | html %]</option>
[% END %]
</select>
</li>
<li> <span class="label">Status:</span> <span id="merge_status"></span> </li>
<li>
<input type="submit" class="btn btn-primary" value="Merge" />
</li>
</ol>
<input type="hidden" name="op" value="cud-mod" />
<input type="hidden" id="merge_invoiceid" name="invoiceid" value="" />
</fieldset>
<!-- /.rows -->
</form>
<!-- /#merge_invoice_form -->
</div>
<!-- /#merge_invoices -->
[% ELSE # IF invoices %]
<p>Sorry, but there are no results for your search.</p>
<div
>Search was:
<ul>
[% IF ( invoicenumber ) %]
<li>Invoice number: [% invoicenumber | html %]</li>
[% END %]
[% IF booksellerid %]
<li>Vendor: [% suppliername | html %]</li>
[% END %]
[% IF shipmentdatefrom %]
<li>
<span>Shipment date:</span>
[% IF shipmentdateto %]
<span>From [% shipmentdatefrom | $KohaDates %]</span>
<span>To [% shipmentdateto | $KohaDates %]</span>
[% ELSE %]
<span>All since [% shipmentdatefrom | $KohaDates %]</span>
[% END %]
</li>
[% ELSE %]
[% IF shipmentdateto %]
<li> Shipment date: All until [% shipmentdateto | $KohaDates %] </li>
[% END %]
[% END %]
[% IF billingdatefrom %]
<li>
<span>Billing date:</span>
[% IF billingdateto %]
<span>From [% billingdatefrom | $KohaDates %]</span>
<span>To [% billingdateto | $KohaDates %]</span>
[% ELSE %]
<span>All since [% billingdatefrom | $KohaDates %]</span>
[% END %]
</li>
[% ELSE %]
[% IF billingdateto %]
<li> Billing date: All until [% billingdateto | $KohaDates %] </li>
[% END %]
[% END %]
[% IF ( isbneanissn ) %]
<li>ISBN/EAN/ISSN: [% isbneanissn | html %]</li>
[% END %]
[% IF ( title ) %]
<li>Title: [% title | html %]</li>
[% END %]
[% IF ( author ) %]
<li>Author: [% author | html %]</li>
[% END %]
[% IF ( publisher ) %]
<li>Publisher: [% publisher | html %]</li>
[% END %]
[% IF ( publicationyear ) %]
<li>Publication year: [% publicationyear | html %]</li>
[% END %]
[% IF ( branch ) %]
<li>Library: [% Branches.GetName( branch ) | html %]</li>
[% END %]
</ul>
</div>
[% END # /IF invoices %]
[% ELSE %]
<p>Use the search form on the left to find invoices.</p>
[% END %]<!-- do_search -->
</main>
</div>
<!-- /.col-md-10.order-md-2 -->
<div class="col-md-2 order-sm-2 order-md-1">
<aside>
<form action="" method="get">
<fieldset class="sidebar brief">
<h3>Search filters</h3>
<ol>
<li>
<label for="invoicenumber">Invoice number</label>
<input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber | html %]" class="focus" />
</li>
<li>
<label for="supplier">Vendor:</label>
<select id="supplierid" name="supplierid">
[% IF ( supplier ) %]
<option selected="selected" value="[% supplier.id | html %]">[% supplier.name | html %]</option>
[% END %]
</select>
</li>
<li>
<fieldset class="brief">
<legend>Shipment date</legend>
<ol>
<li>
<label for="shipmentdatefrom">From:</label>
<input type="text" id="shipmentdatefrom" name="shipmentdatefrom" size="10" value="[% shipmentdatefrom | html %]" class="flatpickr" data-date_to="shipmentdateto" />
<div class="hint">[% INCLUDE 'date-format.inc' %]</div>
</li>
<li>
<label for="shipmentdateto">To:</label>
<input type="text" id="shipmentdateto" name="shipmentdateto" size="10" value="[% shipmentdateto | html %]" class="flatpickr" />
<div class="hint">[% INCLUDE 'date-format.inc' %]</div>
</li>
</ol>
</fieldset>
</li>
<li>
<fieldset class="brief">
<legend>Billing date</legend>
<ol>
<li>
<label for="billingdatefrom">From:</label>
<input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom | html %]" class="flatpickr" data-date_to="billingdateto" />
<div class="hint">[% INCLUDE 'date-format.inc' %]</div>
</li>
<li>
<label for="billingdateto">To:</label>
<input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto | html %]" class="flatpickr" />
<div class="hint">[% INCLUDE 'date-format.inc' %]</div>
</li>
</ol>
</fieldset>
</li>
<li>
<label for="isbneanissn">ISBN / EAN / ISSN:</label>
<input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn | html %]" />
</li>
<li>
<label for="title">Title:</label>
<input type="text" id="title" name="title" value="[% title | html %]" />
</li>
<li>
<label for="author">Author:</label>
<input type="text" id="author" name="author" value="[% author | html %]" />
</li>
<li>
<label for="publisher">Publisher:</label>
<input type="text" id="publisher" name="publisher" value="[% publisher | html %]" />
</li>
<li>
<label for="publicationyear">Publication year:</label>
<input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear | html %]" />
</li>
<li>
<label for="branch">Library:</label>
<select id="branch" name="branch">
<option value="">All</option>
[%# FIXME Should not we filter the libraries %]
[% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
</select>
</li>
[%# FIXME additional-fields.entry.inc should/could be considered here %]
[% FOR field IN additional_fields_for_invoice %]
<li>
<label for="additional_field_[% field.id | html %]ID"> [% field.name | html %]: </label>
[% IF field.authorised_value_category %]
<select id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]">
<option value="">All</option>
[% FOREACH av IN AuthorisedValues.GetAuthValueDropbox(field.authorised_value_category) %]
[% IF av.authorised_value == additional_field_filters.${field.id} %]
<option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option>
[% ELSE %]
<option value="[% av.authorised_value | html %]">[% av.lib | html %]</option>
[% END %]
[% END %]
</select>
[% ELSE %]
<input id="additional_field_[% field.id | html %]" type="text" value="[% additional_field_filters.${field.id} | html %]" name="additional_field_[% field.id | html %]" />
[% END %]
</li>
[% END %]
</ol>
</fieldset>
<!-- /.sidebar.brief -->
<fieldset class="action">
<input type="submit" class="btn btn-primary" value="Search" />
</fieldset>
<input type="hidden" name="op" id="op" value="do_search" />
</form>
[% INCLUDE 'acquisitions-menu.inc' %]
</aside>
</div>
<!-- /.col-md-2.order-md-1 -->
</div>
<!-- /.row -->
</div>
<!-- /.main.container-fluid -->
[% MACRO jsinclude BLOCK %]
[% Asset.js("js/acquisitions-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'select2.inc' %]
[% INCLUDE 'js-date-format.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function () {
$('[id^="CheckAll"]').click(function () {
var table_id = "#" + $(this).attr("data-cb") + "resultst";
$(table_id)
.find('.select-invoice[type="checkbox"]')
.each(function () {
$(this).prop("checked", true);
});
});
$('[id^="UncheckAll"]').click(function () {
var table_id = "#" + $(this).attr("data-cb") + "resultst";
$(table_id)
.find('.select-invoice[type="checkbox"]')
.each(function () {
$(this).prop("checked", false);
});
});
var resultst = $("table.result").kohaTable({
paging: false,
columnDefs: [{ visible: false, targets: [0] }],
autoWidth: false,
});
$(".show_only_subscription").prop("checked", false);
$(".show_only_subscription").click(function () {
var table_id = $(this).attr("data-tableid");
if ($(this).prop("checked")) {
$("#" + table_id)
.DataTable()
.columns(0)
.search(1, true)
.draw();
} else {
$("#" + table_id)
.DataTable()
.columns(0)
.search("")
.draw();
}
});
$("#open_sel,#close_sel").click(function () {
var table = $(this).data("table");
var invoice_ids = "";
if ($("#" + table + " .select-invoice:checked").length) {
$("#" + table + " .select-invoice:checked").each(function () {
var row = $(this).parents("tr");
invoice_ids = invoice_ids + "," + $(row).attr("data-invoiceid");
});
$(this).attr("data-invoiceid", invoice_ids);
} else {
alert("Please select at least one invoice.");
}
});
$(".merge").click(function (ev) {
var booksellerid;
var mismatch;
var invoices = [];
var table = $(this).data("table");
if ($("#" + table + " .select-invoice:checked").size() < 2) {
alert(_("You must select at least two invoices to merge."));
return false;
}
$("#" + table + " .select-invoice:checked").each(function () {
var row = $(this).parents("tr");
booksellerid = booksellerid || $(row).attr("data-booksellerid");
if (booksellerid !== $(row).attr("data-booksellerid")) {
mismatch = true;
}
invoices.push({
invoiceid: $(row).attr("data-invoiceid"),
invoicenumber: $(row).find("td:nth-child(2) a").text(),
shipmentdate: $(row).attr("data-shipmentdate"),
billingdate: $(row).attr("data-billingdate"),
shipmentcost: $(row).attr("data-shipmentcost"),
shipment_budgetid: $(row).attr("data-shipment_budgetid"),
closedate: $(row).attr("data-closedate"),
});
$("#merge_invoice_form").append('<input type="hidden" name="merge" value="' + $(row).attr("data-invoiceid") + '" />');
});
if (mismatch) {
alert(_("All invoices for merging must be from the same vendor"));
} else {
$("#merge_table tbody").empty();
$.each(invoices, function (idx, invoice) {
var row = $(
'<tr data-invoiceid="' +
invoice.invoiceid +
'"><td>' +
invoice.invoicenumber +
"</td><td>" +
$date(invoice.shipmentdate) +
"</td><td>" +
$date(invoice.billingdate) +
"</td><td>" +
invoice.shipmentcost +
"</td></tr>"
);
$(row).appendTo("#merge_table tbody");
$(row).click(function () {
$("#merge_table tbody tr").removeClass("active");
$(this).addClass("active");
$.each(["invoiceid", "shipmentdate", "billingdate", "shipmentcost", "shipment_budgetid", "invoicenumber"], function (idx, prop) {
$("#merge_" + prop).val(invoice[prop]);
});
if (invoice.closedate) {
$("#merge_status").text(_("Closed on %s").format(invoice.closedate));
} else {
$("#merge_status").text(_("Open"));
}
});
});
$("#merge_table tbody tr:first").click();
$("#merge_invoices").show();
}
});
function display_vendor(vendor) {
var $text;
$text = $("<span>" + vendor.text + "</span>");
return $text;
}
$("#supplierid").kohaSelect({
width: "100%",
allowClear: true,
ajax: {
url: "/api/v1/acquisitions/vendors",
delay: 300, // wait 300 milliseconds before triggering the request
cache: true,
dataType: "json",
data: function (params) {
var search_term = params.term === undefined ? "" : params.term;
var query = {
q: JSON.stringify({ name: { "-like": "%" + search_term + "%" } }),
_order_by: "name",
_page: params.page,
};
return query;
},
processResults: function (data) {
var results = [];
data.results.forEach(function (vendor) {
results.push({
id: vendor.id,
text: vendor.name.escapeHtml(),
});
});
return { results: results, pagination: { more: data.pagination.more } };
},
},
templateResult: display_vendor,
templateSelection: display_vendor,
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]