use Koha::Database;
use Koha::DateUtils qw( dt_from_string );
use Koha::Exceptions;
+use Koha::Acquisition::Bookseller;
use base qw(Koha::Object);
return Koha::ERM::EHoldings::Package::Agreements->_new_from_dbic($packages_agreements_rs);
}
+=head3 vendor
+
+Return the vendor for this agreement
+
+=cut
+
+sub vendor {
+ my ( $self ) = @_;
+ my $vendor_rs = $self->_result->vendor;
+ return unless $vendor_rs;
+ return Koha::Acquisition::Bookseller->_new_from_dbic($vendor_rs);
+}
+
=head2 Internal methods
=head3 _type
use base qw(Koha::Object);
+use Koha::Acquisition::Bookseller;
+
=head1 NAME
Koha::ERM::License - Koha ERM License Object class
=cut
+=head3 vendor
+
+Return the vendor for this license
+
+=cut
+
+sub vendor {
+ my ( $self ) = @_;
+ my $vendor_rs = $self->_result->vendor;
+ return unless $vendor_rs;
+ return Koha::Acquisition::Bookseller->_new_from_dbic($vendor_rs);
+}
+
=head2 Internal methods
=head3 _type
description: documents
items:
$ref: erm_agreement_document.yaml
+ vendor:
+ description: Information about the vendor
+ type:
+ - object
+ - "null"
additionalProperties: false
required:
type: integer
description: internally assigned license identifier
readOnly: true
+ vendor_id:
+ description: foreign key to aqbooksellers
+ type:
+ - integer
+ - "null"
name:
description: name of the license
type: string
- "null"
format: date
description: End of the license
+ vendor:
+ description: Information about the vendor
+ type:
+ - object
+ - "null"
+
additionalProperties: false
required:
- license_id
name: license_id
required: false
type: integer
+ - description: Case insensitive search on agreement vendor_id
+ in: query
+ name: vendor_id
+ required: false
+ type: integer
- description: Case insensitive search on license name
in: query
name: name
$dbh->do(q{
CREATE TABLE `erm_licenses` (
`license_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
+ `vendor_id` INT(11) DEFAULT NULL COMMENT 'foreign key to aqbooksellers',
`name` VARCHAR(255) NOT NULL COMMENT 'name of the license',
`description` LONGTEXT DEFAULT NULL COMMENT 'description of the license',
`type` VARCHAR(80) NOT NULL COMMENT 'type of the license',
`status` VARCHAR(80) NOT NULL COMMENT 'current status of the license',
`started_on` DATE COMMENT 'start of the license',
`ended_on` DATE COMMENT 'end of the license',
+ CONSTRAINT `erm_licenses_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
PRIMARY KEY(`license_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
});
`physical_location` VARCHAR(80) DEFAULT NULL COMMENT 'physical location of the license',
`notes` mediumtext DEFAULT NULL COMMENT 'notes about this license',
`uri` varchar(255) DEFAULT NULL COMMENT 'URI of the license',
- CONSTRAINT `erm_licenses_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `erm_licenses_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `erm_agreement_licenses_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `erm_agreement_licenses_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY(`agreement_license_id`),
UNIQUE KEY `erm_agreement_licenses_uniq` (`agreement_id`, `license_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
DROP TABLE IF EXISTS `erm_licenses`;
CREATE TABLE `erm_licenses` (
`license_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
+ `vendor_id` INT(11) DEFAULT NULL COMMENT 'foreign key to aqbooksellers',
`name` VARCHAR(255) NOT NULL COMMENT 'name of the license',
`description` LONGTEXT DEFAULT NULL COMMENT 'description of the license',
`type` VARCHAR(80) NOT NULL COMMENT 'type of the license',
`status` VARCHAR(80) NOT NULL COMMENT 'current status of the license',
`started_on` DATE COMMENT 'start of the license',
`ended_on` DATE COMMENT 'end of the license',
+ CONSTRAINT `erm_licenses_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
PRIMARY KEY(`license_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
`physical_location` VARCHAR(80) DEFAULT NULL COMMENT 'physical location of the license',
`notes` mediumtext DEFAULT NULL COMMENT 'notes about this license',
`uri` varchar(255) DEFAULT NULL COMMENT 'URI of the license',
- CONSTRAINT `erm_licenses_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `erm_licenses_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `erm_agreement_licenses_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `erm_agreement_licenses_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY(`agreement_license_id`),
UNIQUE KEY `erm_agreement_licenses_uniq` (`agreement_id`, `license_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
apiUrl += '/' + agreement.agreement_id
}
delete agreement.agreement_id
+ delete agreement.vendor
agreement.is_perpetual = agreement.is_perpetual ? true : false
if (agreement.vendor_id == "") {
<a
:href="`/cgi-bin/koha/acqui/booksellers.pl?booksellerid=${agreement.vendor_id}`"
>
- {{
- vendors.find(
- (e) => e.id == agreement.vendor_id
- ).name
- }}</a
- >
+ {{ agreement.vendor.name }}
+ </a>
</span>
</li>
<li>
</template>
<script>
-import { useVendorStore } from "../../stores/vendors"
import { useAVStore } from "../../stores/authorised_values"
import { fetchAgreement } from "../../fetch"
-import { storeToRefs } from "pinia"
export default {
setup() {
const format_date = $date
const patron_to_html = $patron_to_html
- const vendorStore = useVendorStore()
- const { vendors } = storeToRefs(vendorStore)
-
const AVStore = useAVStore()
const { get_lib_from_av } = AVStore
format_date,
patron_to_html,
get_lib_from_av,
- vendors,
}
},
data() {
<span class="required">{{ $t("Required") }}</span>
</li>
<li>
+ <label for="license_vendor_id"
+ >{{ $t("Vendor") }}:</label
+ >
+ <select
+ id="license_vendor_id"
+ v-model="license.vendor_id"
+ >
+ <option value=""></option>
+ <option
+ v-for="vendor in vendors"
+ :key="vendor.vendor_id"
+ :value="vendor.id"
+ :selected="
+ vendor.id == license.vendor_id
+ ? true
+ : false
+ "
+ >
+ {{ vendor.name }}
+ </option>
+ </select>
+ </li>
+
+ <li>
<label for="license_description"
>{{ $t("Description") }}:
</label>
<script>
import flatPickr from 'vue-flatpickr-component'
+import { useVendorStore } from "../../stores/vendors"
import { useAVStore } from "../../stores/authorised_values"
import { setMessage, setError } from "../../messages"
import { fetchLicense } from '../../fetch'
export default {
setup() {
+ const vendorStore = useVendorStore()
+ const { vendors } = storeToRefs(vendorStore)
const AVStore = useAVStore()
const {
av_license_types,
} = storeToRefs(AVStore)
return {
+ vendors,
av_license_types,
av_license_statuses,
}
license: {
license_id: null,
name: '',
+ vendor_id: null,
description: '',
type: '',
status: '',
apiUrl += '/' + license.license_id
}
delete license.license_id
+ delete license.vendor
+
+ if (license.vendor_id == "") {
+ license.vendor_id = null
+ }
license.started_on = license.started_on ? $date_to_rfc3339(license.started_on) : null
license.ended_on = license.ended_on ? $date_to_rfc3339(license.ended_on) : null
<script>
import Toolbar from "./LicensesToolbar.vue"
import { createVNode, render } from 'vue'
+import { useVendorStore } from "../../stores/vendors"
import { useAVStore } from "../../stores/authorised_values"
import { storeToRefs } from "pinia"
import { fetchLicenses } from "../../fetch"
export default {
setup() {
+ const vendorStore = useVendorStore()
+ const { vendors } = storeToRefs(vendorStore)
+
const AVStore = useAVStore()
const { get_lib_from_av, map_av_dt_filter } = AVStore
useDataTable(table_id)
return {
+ vendors,
get_lib_from_av,
map_av_dt_filter,
table_id,
let default_search = this.$route.query.q
let table_id = this.table_id
+ window['vendors'] = this.vendors.map(e => {
+ e['_id'] = e['id']
+ e['_str'] = e['name']
+ return e
+ })
+ let vendors_map = this.vendors.reduce((map, e) => {
+ map[e.id] = e
+ return map
+ }, {})
let avs = ['av_license_types', 'av_license_statuses']
avs.forEach(function (av_cat) {
window[av_cat] = map_av_dt_filter(av_cat)
}
},
{
+ title: __("Vendor"),
+ data: "vendor_id",
+ searchable: true,
+ orderable: true,
+ render: function (data, type, row, meta) {
+ return row.vendor_id != undefined ? escape_str(vendors_map[row.vendor_id].name) : ""
+ }
+ },
+
+ {
title: __("Description"),
data: "description",
searchable: true,
})
},
preDrawCallback: function (settings) {
- $("#" + table_id).find("thead th").eq(2).attr('data-filter', 'av_license_types')
- $("#" + table_id).find("thead th").eq(3).attr('data-filter', 'av_license_statuses')
+ $("#" + table_id).find("thead th").eq(1).attr('data-filter', 'vendors')
+ $("#" + table_id).find("thead th").eq(3).attr('data-filter', 'av_license_types')
+ $("#" + table_id).find("thead th").eq(4).attr('data-filter', 'av_license_statuses')
}
}, license_table_settings, 1)
</span>
</li>
<li>
+ <label>{{ $t("Vendor") }}:</label>
+ <span v-if="license.vendor_id">
+ <a
+ :href="`/cgi-bin/koha/acqui/booksellers.pl?booksellerid=${license.vendor_id}`"
+ >
+ {{ license.vendor.name }}
+ </a>
+ </span>
+ </li>
+ <li>
<label>{{ $t("Description") }}:</label>
<span>
{{ license.description }}
<script>
import { useAVStore } from "../../stores/authorised_values"
-import { storeToRefs } from "pinia"
import { fetchLicense } from "../../fetch"
export default {
license: {
license_id: null,
name: '',
+ vendor_id: null,
+ vendor: null,
description: '',
type: '',
status: '',
await fetch(apiUrl, {
headers: {
"x-koha-embed":
- "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents,agreement_packages,agreement_packages.package",
+ "periods,user_roles,user_roles.patron,agreement_licenses,agreement_licenses.license,agreement_relationships,agreement_relationships.related_agreement,documents,agreement_packages,agreement_packages.package,vendor",
},
})
.then(checkError)
if (!license_id) return;
const apiUrl = "/api/v1/erm/licenses/" + license_id;
let license;
- await fetch(apiUrl)
+ await fetch(apiUrl, {
+ headers: {
+ "x-koha-embed": "vendor",
+ },
+ })
.then(checkError)
.then(
(result) => {
export const fetchLicenses = async function () {
const apiUrl = "/api/v1/erm/licenses";
let licenses;
- await fetch(apiUrl)
+ await fetch(apiUrl, {
+ headers: {
+ "x-koha-embed": "vendor.name",
+ },
+ })
.then(checkError)
.then(
(result) => {