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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc (-1 / +1 lines)
Lines 1-7 Link Here
1
[% IF ( booksellerid ) %]
1
[% IF ( booksellerid ) %]
2
<div id="menu">
2
<div id="menu">
3
    <ul>
3
    <ul>
4
        [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/vendors/[% booksellerid | uri %]/baskets">Baskets</a></li>[% END %]
4
        [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/acqui/booksellers.pl?booksellerid=[% booksellerid | uri %]">Baskets</a></li>[% END %]
5
        [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | uri %]">Basket groups</a></li>[% END %]
5
        [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | uri %]">Basket groups</a></li>[% END %]
6
        [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid | uri %]">Contracts</a></li>[% END %]
6
        [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid | uri %]">Contracts</a></li>[% END %]
7
        [% IF ( CAN_user_acquisition_issue_manage ) %]<li><a href="/cgi-bin/koha/acqui/vendor_issues.pl?booksellerid=[% booksellerid | uri %]">Vendor issues</a></li>[% END %]
7
        [% IF ( CAN_user_acquisition_issue_manage ) %]<li><a href="/cgi-bin/koha/acqui/vendor_issues.pl?booksellerid=[% booksellerid | uri %]">Vendor issues</a></li>[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Islands/VendorMenu.vue (-3 / +4 lines)
Lines 7-15 Link Here
7
                    isUserPermitted('CAN_user_acquisition_order_manage')
7
                    isUserPermitted('CAN_user_acquisition_order_manage')
8
                "
8
                "
9
            >
9
            >
10
                <a :href="`/cgi-bin/koha/vendors/${vendorId}/baskets`">{{
10
                <a
11
                    $__("Baskets")
11
                    :href="`/cgi-bin/koha/acqui/booksellers.pl?booksellerid=${vendorId}`"
12
                }}</a>
12
                    >{{ $__("Baskets") }}</a
13
                >
13
            </li>
14
            </li>
14
            <li
15
            <li
15
                v-if="
16
                v-if="
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorBaskets.vue (-263 lines)
Lines 1-263 Link Here
1
<template>
2
    <div id="vendor_baskets">
3
        <div v-if="parseInt(basketCount) > 0" class="page-section">
4
            <KohaTable
5
                ref="table"
6
                v-bind="tableOptions"
7
                @addToBasket="addToBasket"
8
                @closeBasket="closeBasket"
9
                @uncertainPrices="uncertainPrices"
10
            ></KohaTable>
11
        </div>
12
        <div v-else class="alert alert-info">
13
            {{ $__("There are no baskets defined") }}
14
        </div>
15
    </div>
16
</template>
17
18
<script>
19
import { inject, ref } from "vue"
20
import { storeToRefs } from "pinia"
21
import KohaTable from "../KohaTable.vue"
22
23
export default {
24
    setup() {
25
        const patronToHTML = $patron_to_html
26
        const formatDate = $date
27
28
        const vendorStore = inject("vendorStore")
29
        const { vendors } = storeToRefs(vendorStore)
30
31
        const { setConfirmationDialog, setMessage } = inject("mainStore")
32
33
        const table = ref()
34
35
        return {
36
            vendors,
37
            table,
38
            setConfirmationDialog,
39
            setMessage,
40
            escape_str,
41
            patronToHTML,
42
            formatDate,
43
        }
44
    },
45
    data() {
46
        return {
47
            fp_config: flatpickr_defaults,
48
            initialized: false,
49
            tableOptions: {
50
                columns: this.getTableColumns(),
51
                options: { embed: "orders,creator,basket_group" },
52
                url: () => this.tableURL(),
53
                add_filters: true,
54
                actions: {
55
                    "-1": [
56
                        {
57
                            addToBasket: {
58
                                text: this.$__("Add to basket"),
59
                                icon: "fa fa-plus",
60
                            },
61
                        },
62
                        {
63
                            closeBasket: {
64
                                text: this.$__("Close basket"),
65
                                icon: "fa fa-close",
66
                                should_display: row =>
67
                                    row.orders.length > 0 && !row.standing,
68
                            },
69
                        },
70
                        {
71
                            uncertainPrices: {
72
                                text: this.$__("Uncertain prices"),
73
                                icon: "fa fa-question",
74
                                should_display: row =>
75
                                    row.orders.filter(o => o.uncertain_price)
76
                                        .length > 0,
77
                            },
78
                        },
79
                    ],
80
                },
81
            },
82
        }
83
    },
84
    methods: {
85
        addToBasket({ basket_id }, dt, event) {
86
            event.preventDefault()
87
            location.href =
88
                "/cgi-bin/koha/acqui/basket.pl?basketno=" + basket_id
89
        },
90
        closeBasket({ basket_id }, dt, event) {
91
            event.preventDefault()
92
            location.href =
93
                "/cgi-bin/koha/acqui/basket.pl?basketno=" + basket_id
94
        },
95
        uncertainPrices({ basket_id }, dt, event) {
96
            event.preventDefault()
97
            location.href =
98
                "/cgi-bin/koha/acqui/uncertainprice.pl?booksellerid=" +
99
                basket_id +
100
                "&owner=1"
101
        },
102
        tableURL() {
103
            let url =
104
                "/api/v1/acquisitions/baskets?q=" +
105
                JSON.stringify({ "me.vendor_id": this.vendorId })
106
            return url
107
        },
108
        getTableColumns() {
109
            const escape_str = this.escape_str
110
            const patronToHTML = this.patronToHTML
111
            const formatDate = this.formatDate
112
113
            return [
114
                {
115
                    title: __("Name"),
116
                    data: "me.name:me.basket_id",
117
                    searchable: true,
118
                    orderable: true,
119
                    render(data, type, row, meta) {
120
                        const name = row.name ? row.name : __("Unnamed basket")
121
                        return (
122
                            '<a href="/cgi-bin/koha/acqui/basket.pl?basketno=' +
123
                            row.basket_id +
124
                            '" class="show">' +
125
                            escape_str(`${name} (#${row.basket_id})`) +
126
                            "</a>"
127
                        )
128
                    },
129
                },
130
                {
131
                    title: __("Item count"),
132
                    data: "name",
133
                    searchable: false,
134
                    orderable: true,
135
136
                    render(data, type, row, meta) {
137
                        let count = row.orders.length
138
                        const cancelledOrders = row.orders.filter(
139
                            o => o.status == "cancelled"
140
                        ).length
141
                        if (cancelledOrders) {
142
                            count +=
143
                                " (" + cancelledOrders + __(" cancelled") + ")"
144
                        }
145
                        return count
146
                    },
147
                },
148
                {
149
                    title: __("Bibliographic record count"),
150
                    data: "name",
151
                    searchable: false,
152
                    orderable: true,
153
                    render(data, type, row, meta) {
154
                        const recordCount = row.orders.reduce(
155
                            (acc, order) => {
156
                                if (
157
                                    !acc.cancelledBibs.includes(
158
                                        order.biblio_id
159
                                    ) &&
160
                                    order.status == "cancelled"
161
                                ) {
162
                                    acc.cancelledBibs.push(order.biblio_id)
163
                                }
164
                                if (acc.bibNumbers.includes(order.biblio_id)) {
165
                                    return acc
166
                                }
167
                                acc.bibNumbers.push(order.biblio_id)
168
                                return acc
169
                            },
170
                            {
171
                                bibNumbers: [],
172
                                cancelledBibs: [],
173
                            }
174
                        )
175
                        let count = recordCount.bibNumbers.length
176
                        if (recordCount.cancelledBibs.length) {
177
                            count +=
178
                                " (" +
179
                                recordCount.cancelledBibs.length +
180
                                __(" cancelled") +
181
                                ")"
182
                        }
183
                        return count
184
                    },
185
                },
186
                {
187
                    title: __("Items expected"),
188
                    data: "name",
189
                    searchable: false,
190
                    orderable: true,
191
                    render(data, type, row, meta) {
192
                        return row.orders.filter(
193
                            o => !o.date_received && !o.cancellation_date
194
                        ).length
195
                    },
196
                },
197
                {
198
                    title: __("Created by"),
199
                    data: "creator_id",
200
                    searchable: false,
201
                    orderable: true,
202
                    render(data, type, row, meta) {
203
                        return patronToHTML(row.creator)
204
                    },
205
                },
206
                {
207
                    title: __("Date"),
208
                    data: "creation_date",
209
                    searchable: false,
210
                    orderable: true,
211
                    render(data, type, row, meta) {
212
                        return formatDate(row.creation_date)
213
                    },
214
                },
215
                {
216
                    title: __("Basket group"),
217
                    data: "basket_group_id",
218
                    searchable: false,
219
                    orderable: true,
220
                    render(data, type, row, meta) {
221
                        return row.basket_group ? row.basket_group.name : ""
222
                    },
223
                },
224
                {
225
                    title: __("Internal note"),
226
                    data: "note",
227
                    searchable: false,
228
                    orderable: true,
229
                },
230
                {
231
                    title: __("Closed"),
232
                    data: "close_date",
233
                    searchable: false,
234
                    orderable: true,
235
                    render(data, type, row, meta) {
236
                        return formatDate(row.close_date)
237
                    },
238
                },
239
            ]
240
        },
241
    },
242
    components: { KohaTable },
243
    props: {
244
        basketCount: {
245
            type: String,
246
            default: "0",
247
        },
248
        vendorId: {
249
            type: Number,
250
        },
251
    },
252
    name: "VendorBaskets",
253
    emits: ["select-vendor", "close"],
254
}
255
</script>
256
257
<style scoped>
258
.filters > label[for="by_mine_filter"],
259
.filters > input[type="checkbox"],
260
.filters > input[type="button"] {
261
    margin-left: 1rem;
262
}
263
</style>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue (-2 / +2 lines)
Lines 238-246 export default { Link Here
238
                    orderable: false,
238
                    orderable: false,
239
                    render(data, type, row, meta) {
239
                    render(data, type, row, meta) {
240
                        return row.baskets.length
240
                        return row.baskets.length
241
                            ? '<a href="/cgi-bin/koha/vendors/' +
241
                            ? '<a href="/cgi-bin/koha/acqui/booksellers.pl?booksellerid=' +
242
                                  row.id +
242
                                  row.id +
243
                                  '/baskets" class="show">' +
243
                                  '" class="show">' +
244
                                  escape_str(
244
                                  escape_str(
245
                                      `${row.baskets.length} basket(s)`
245
                                      `${row.baskets.length} basket(s)`
246
                                  ) +
246
                                  ) +
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorShow.vue (-50 / +20 lines)
Lines 47-82 Link Here
47
        <h1>
47
        <h1>
48
            {{ vendor.name }}
48
            {{ vendor.name }}
49
        </h1>
49
        </h1>
50
        <template v-if="!basketView">
50
        <div class="row">
51
            <div class="row">
51
            <div class="col-sm-6">
52
                <div class="col-sm-6">
52
                <VendorDetails :vendor="vendor" :display="true" />
53
                    <VendorDetails :vendor="vendor" :display="true" />
53
                <VendorOrderingInformation :vendor="vendor" :display="true" />
54
                    <VendorOrderingInformation
54
                <VendorInterfaces
55
                        :vendor="vendor"
55
                    :vendor="vendor"
56
                        :display="true"
56
                    v-if="vendor.interfaces.length > 0"
57
                    />
57
                    :display="true"
58
                    <VendorInterfaces
58
                />
59
                        :vendor="vendor"
60
                        v-if="vendor.interfaces.length > 0"
61
                        :display="true"
62
                    />
63
                </div>
64
                <div class="col-sm-6">
65
                    <VendorContacts :vendor="vendor" :display="true" />
66
                    <VendorSubscriptions :vendor="vendor" />
67
                </div>
68
            </div>
59
            </div>
69
            <div
60
            <div class="col-sm-6">
70
                class="page-section rows"
61
                <VendorContacts :vendor="vendor" :display="true" />
71
                v-if="vendor.contracts && vendor.contracts.length > 0"
62
                <VendorSubscriptions :vendor="vendor" />
72
            >
73
                <VendorContracts :vendor="vendor" />
74
            </div>
63
            </div>
75
        </template>
64
        </div>
76
        <template v-if="basketView">
65
        <div
77
            <h2>{{ $__("Baskets") }}</h2>
66
            class="page-section rows"
78
            <VendorBaskets :basketCount="basketCount" :vendorId="vendor.id" />
67
            v-if="vendor.contracts && vendor.contracts.length > 0"
79
        </template>
68
        >
69
            <VendorContracts :vendor="vendor" />
70
        </div>
80
    </div>
71
    </div>
81
</template>
72
</template>
82
73
Lines 91-97 import VendorInterfaces from "./VendorInterfaces.vue" Link Here
91
import VendorContacts from "./VendorContacts.vue"
82
import VendorContacts from "./VendorContacts.vue"
92
import VendorSubscriptions from "./VendorSubscriptions.vue"
83
import VendorSubscriptions from "./VendorSubscriptions.vue"
93
import VendorContracts from "./VendorContracts.vue"
84
import VendorContracts from "./VendorContracts.vue"
94
import VendorBaskets from "./VendorBaskets.vue"
95
import DropdownButtons from "../DropdownButtons.vue"
85
import DropdownButtons from "../DropdownButtons.vue"
96
86
97
export default {
87
export default {
Lines 107-126 export default { Link Here
107
        return {
97
        return {
108
            vendor: null,
98
            vendor: null,
109
            initialized: false,
99
            initialized: false,
110
            basketView: false,
111
            basketCount: null,
112
        }
100
        }
113
    },
101
    },
114
    beforeRouteEnter(to, from, next) {
102
    beforeRouteEnter(to, from, next) {
115
        next(vm => {
103
        next(vm => {
116
            if (to.path.includes("basket")) {
104
            vm.getVendor(to.params.vendor_id)
117
                vm.basketView = true
118
                vm.getVendor(to.params.vendor_id).then(() =>
119
                    vm.getBasketCount(to.params.vendor_id)
120
                )
121
            } else {
122
                vm.getVendor(to.params.vendor_id)
123
            }
124
        })
105
        })
125
    },
106
    },
126
    methods: {
107
    methods: {
Lines 134-149 export default { Link Here
134
                error => {}
115
                error => {}
135
            )
116
            )
136
        },
117
        },
137
        async getBasketCount(booksellerid) {
138
            const client = APIClient.acquisition
139
            await client.baskets.count({ booksellerid }).then(
140
                count => {
141
                    this.basketCount = count
142
                    this.initialized = true
143
                },
144
                error => {}
145
            )
146
        },
147
    },
118
    },
148
    components: {
119
    components: {
149
        Toolbar,
120
        Toolbar,
Lines 155-161 export default { Link Here
155
        VendorContacts,
126
        VendorContacts,
156
        VendorSubscriptions,
127
        VendorSubscriptions,
157
        VendorContracts,
128
        VendorContracts,
158
        VendorBaskets,
159
    },
129
    },
160
    name: "VendorShow",
130
    name: "VendorShow",
161
}
131
}
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/acquisitions.js (-8 lines)
Lines 52-64 export const routes = [ Link Here
52
                        component: markRaw(VendorFormAdd),
52
                        component: markRaw(VendorFormAdd),
53
                        title: $__("Edit vendor"),
53
                        title: $__("Edit vendor"),
54
                    },
54
                    },
55
                    {
56
                        path: ":vendor_id/baskets",
57
                        name: "VendorShowBaskets",
58
                        component: markRaw(VendorShow),
59
                        title: $__("Baskets"),
60
                        alternateLeftMenu: "VendorMenu",
61
                    },
62
                ],
55
                ],
63
            },
56
            },
64
        ],
57
        ],
65
- 

Return to bug 38010