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

(-)a/Koha/REST/V1/Acquisitions/Vendors.pm (-6 / +19 lines)
Lines 87-107 Controller function that handles adding a new Koha::Acquisition::Bookseller obje Link Here
87
sub add {
87
sub add {
88
    my $c = shift->openapi->valid_input or return;
88
    my $c = shift->openapi->valid_input or return;
89
89
90
    my $vendor = Koha::Acquisition::Bookseller->new_from_api( $c->req->json );
90
    my $vendor     = $c->req->json;
91
    my $contacts   = delete $vendor->{contacts};
92
    my $interfaces = delete $vendor->{interfaces};
93
    my $aliases    = delete $vendor->{aliases};
94
95
    my $vendor_to_store = Koha::Acquisition::Bookseller->new_from_api( $c->req->json );
91
96
92
    return try {
97
    return try {
93
        $vendor->store;
98
        $vendor_to_store->store;
94
        $c->res->headers->location($c->req->url->to_string . '/' . $vendor->id );
99
100
        foreach my $contact (@$contacts) {
101
            $contact->{booksellerid} = $vendor_to_store->id;
102
            Koha::Acquisition::Bookseller::Contact->new($contact)->store;
103
        }
104
        $vendor_to_store->aliases($aliases)       if scalar($aliases) > 0;
105
        $vendor_to_store->interfaces($interfaces) if scalar($interfaces) > 0;
106
107
        $c->res->headers->location( $c->req->url->to_string . '/' . $vendor_to_store->id );
95
        return $c->render(
108
        return $c->render(
96
            status  => 201,
109
            status  => 201,
97
            openapi => $c->objects->to_api($vendor),
110
            openapi => $c->objects->to_api($vendor_to_store),
98
        );
111
        );
99
    }
112
    } catch {
100
    catch {
101
        $c->unhandled_exception($_);
113
        $c->unhandled_exception($_);
102
    };
114
    };
103
}
115
}
104
116
117
105
=head3 update
118
=head3 update
106
119
107
Controller function that handles updating a Koha::Acquisition::Bookseller object
120
Controller function that handles updating a Koha::Acquisition::Bookseller object
(-)a/acqui/booksellers.pl (+1 lines)
Lines 62-67 use C4::Context; Link Here
62
62
63
use Koha::Acquisition::Booksellers;
63
use Koha::Acquisition::Booksellers;
64
use Koha::Patrons;
64
use Koha::Patrons;
65
use Koha::Acquisition::Currencies;
65
66
66
my $query = CGI->new;
67
my $query = CGI->new;
67
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
68
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/Main.vue (-1 / +8 lines)
Lines 94-104 export default { Link Here
94
94
95
        fetchConfig().then(() => {
95
        fetchConfig().then(() => {
96
            this.loaded()
96
            this.loaded()
97
            this.userPermissions = userPermissions
98
            this.vendorStore.currencies = currencies
99
            this.vendorStore.gstValues = gstValues.map(gv => {
100
                return {
101
                    label: `${(gv.option * 100).toFixed(2)}%`,
102
                    value: gv.option,
103
                }
104
            })
97
            this.initialized = true
105
            this.initialized = true
98
        })
106
        })
99
    },
107
    },
100
    data() {
108
    data() {
101
        this.userPermissions = userPermissions
102
        return {
109
        return {
103
            initialized: false,
110
            initialized: false,
104
        }
111
        }
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorContacts.vue (-1 / +204 lines)
Lines 1-5 Link Here
1
<template>
1
<template>
2
    <fieldset class="rows">
2
    <fieldset class="rows" v-if="display">
3
        <h2>
3
        <h2>
4
            {{ $__("Contact") }}
4
            {{ $__("Contact") }}
5
        </h2>
5
        </h2>
Lines 84-95 Link Here
84
            </li>
84
            </li>
85
        </ol>
85
        </ol>
86
    </fieldset>
86
    </fieldset>
87
    <fieldset class="rows" v-else>
88
        <legend>{{ $__("Contacts") }}</legend>
89
        <fieldset
90
            class="rows"
91
            v-for="(contact, i) in vendor.contacts"
92
            v-bind:key="i"
93
            :id="`contact_${i}`"
94
        >
95
            <legend>{{ $__("Contact details") }}</legend>
96
            <ol>
97
                <li>
98
                    <label :for="`contact_${i}_name`"
99
                        >{{ $__("Contact name") }}:</label
100
                    >
101
                    <input :id="`contact_${i}_name`" v-model="contact.name" />
102
                </li>
103
                <li>
104
                    <label :for="`contact_${i}_position`"
105
                        >{{ $__("Position") }}:</label
106
                    >
107
                    <input
108
                        :id="`contact_${i}_position`"
109
                        v-model="contact.position"
110
                    />
111
                </li>
112
                <li>
113
                    <label :for="`contact_${i}_phone`"
114
                        >{{ $__("Phone") }}:</label
115
                    >
116
                    <input :id="`contact_${i}_phone`" v-model="contact.phone" />
117
                </li>
118
                <li>
119
                    <label :for="`contact_${i}_altphone`"
120
                        >{{ $__("Alternative phone") }}:</label
121
                    >
122
                    <input
123
                        :id="`contact_${i}_altphone`"
124
                        v-model="contact.altphone"
125
                    />
126
                </li>
127
                <li>
128
                    <label :for="`contact_${i}_fax`">{{ $__("Fax") }}:</label>
129
                    <input :id="`contact_${i}_fax`" v-model="contact.fax" />
130
                </li>
131
                <li>
132
                    <label :for="`contact_${i}_email`"
133
                        >{{ $__("Email") }}:</label
134
                    >
135
                    <input :id="`contact_${i}_email`" v-model="contact.email" />
136
                </li>
137
                <li>
138
                    <label :for="`contact_${i}_notes`"
139
                        >{{ $__("Notes") }}:</label
140
                    >
141
                    <textarea
142
                        :id="`contact_${i}_notes`"
143
                        v-model="contact.notes"
144
                        cols="40"
145
                        rows="3"
146
                    />
147
                </li>
148
            </ol>
149
            <div style="display: flex">
150
                <div>
151
                    <fieldset class="rows">
152
                        <legend>Acquisitions options</legend>
153
                        <ol class="radio">
154
                            <li>
155
                                <label>
156
                                    <input
157
                                        v-if="contact.acqprimary"
158
                                        type="checkbox"
159
                                        :id="`contact_acqprimary_${i}`"
160
                                        class="contact_acqprimary"
161
                                        checked="checked"
162
                                        v-model="contact.acqprimary"
163
                                    />
164
                                    <input
165
                                        v-else
166
                                        type="checkbox"
167
                                        :id="`contact_acqprimary_${i}`"
168
                                        class="contact_acqprimary"
169
                                        v-model="contact.acqprimary"
170
                                    />
171
                                    {{ $__("Primary acquisitions contact") }}
172
                                </label>
173
                            </li>
174
                            <li>
175
                                <label>
176
                                    <input
177
                                        v-if="contact.orderacquisition"
178
                                        type="checkbox"
179
                                        :id="`contact_orderacquisition_${i}`"
180
                                        class="contact_orderacquisition"
181
                                        checked="checked"
182
                                        v-model="contact.orderacquisition"
183
                                    />
184
                                    <input
185
                                        v-else
186
                                        type="checkbox"
187
                                        :id="`contact_orderacquisition_${i}`"
188
                                        class="contact_orderacquisition"
189
                                        v-model="contact.orderacquisition"
190
                                    />
191
                                    {{ $__("Contact when ordering") }}
192
                                </label>
193
                            </li>
194
                            <li>
195
                                <label>
196
                                    <input
197
                                        v-if="contact.claimacquisition"
198
                                        type="checkbox"
199
                                        :id="`contact_claimacquisition_${i}`"
200
                                        class="contact_claimacquisition"
201
                                        checked="checked"
202
                                        v-model="contact.claimacquisition"
203
                                    />
204
                                    <input
205
                                        v-else
206
                                        type="checkbox"
207
                                        :id="`contact_claimacqu isition_${i}`"
208
                                        class="contact_claimacqu isition"
209
                                        v-model="contact.claimacquisition"
210
                                    />
211
                                    {{ $__("Contact about late orders") }}
212
                                </label>
213
                            </li>
214
                        </ol>
215
                    </fieldset>
216
                </div>
217
                <div>
218
                    <fieldset class="rows">
219
                        <legend>Serials options</legend>
220
                        <ol class="radio">
221
                            <li>
222
                                <label>
223
                                    <input
224
                                        v-if="contact.serialsprimary"
225
                                        type="checkbox"
226
                                        :id="`contact_serialsprimary_${i}`"
227
                                        class="contact_serialsprimary"
228
                                        checked="checked"
229
                                        v-model="contact.serialsprimary"
230
                                    />
231
                                    <input
232
                                        v-else
233
                                        type="checkbox"
234
                                        :id="`contact_serialsprimary_${i}`"
235
                                        class="contact_serialsprimary"
236
                                        v-model="contact.serialsprimary"
237
                                    />
238
                                    {{ $__("Primary serials contact") }}
239
                                </label>
240
                            </li>
241
                            <li>
242
                                <label>
243
                                    <input
244
                                        v-if="contact.claimissues"
245
                                        type="checkbox"
246
                                        :id="`contact_claimissues_${i}`"
247
                                        class="contact_claimissues"
248
                                        checked="checked"
249
                                        v-model="contact.claimissues"
250
                                    />
251
                                    <input
252
                                        v-else
253
                                        type="checkbox"
254
                                        :id="`contact_claimissues_${i}`"
255
                                        class="contact_claimissues"
256
                                        v-model="contact.claimissues"
257
                                    />
258
                                    {{ $__("Contact about late issues") }}
259
                                </label>
260
                            </li>
261
                        </ol>
262
                    </fieldset>
263
                </div>
264
            </div>
265
        </fieldset>
266
        <span class="btn btn-default" @click="addContact"
267
            ><font-awesome-icon icon="plus" />
268
            {{ $__("Add new contact") }}</span
269
        >
270
    </fieldset>
87
</template>
271
</template>
88
272
89
<script>
273
<script>
90
export default {
274
export default {
91
    props: {
275
    props: {
92
        vendor: Object,
276
        vendor: Object,
277
        display: Boolean,
278
    },
279
    methods: {
280
        addContact() {
281
            this.vendor.contacts.push({
282
                name: "",
283
                position: "",
284
                email: "",
285
                phone: "",
286
                notes: "",
287
                altphone: "",
288
                fax: "",
289
                acqprimary: false,
290
                orderacquisition: false,
291
                claimacquisition: false,
292
                serialsprimary: false,
293
                claimissues: false,
294
            })
295
        },
93
    },
296
    },
94
}
297
}
95
</script>
298
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorDetails.vue (-5 / +127 lines)
Lines 1-5 Link Here
1
<template>
1
<template>
2
    <fieldset class="rows">
2
    <fieldset class="rows" v-if="display">
3
        <h2>
3
        <h2>
4
            {{ $__("Vendor details") }}
4
            {{ $__("Vendor details") }}
5
        </h2>
5
        </h2>
Lines 7-13 Link Here
7
            <li>
7
            <li>
8
                <label>{{ $__("Type") }}:</label>
8
                <label>{{ $__("Type") }}:</label>
9
                <span>
9
                <span>
10
                    {{ get_lib_from_av("vendor_types", vendor.type) }}
10
                    {{ get_lib_from_av("av_vendor_types", vendor.type) }}
11
                </span>
11
                </span>
12
            </li>
12
            </li>
13
            <li>
13
            <li>
Lines 65-88 Link Here
65
            </li>
65
            </li>
66
        </ol>
66
        </ol>
67
    </fieldset>
67
    </fieldset>
68
    <fieldset class="rows" v-else>
69
        <legend>{{ $__("Company details") }}</legend>
70
        <ol>
71
            <li>
72
                <label for="vendor_name" class="required"
73
                    >{{ $__("Name") }}:</label
74
                >
75
                <input
76
                    id="vendor_name"
77
                    v-model="vendor.name"
78
                    :placeholder="$__('Vendor name')"
79
                    required
80
                />
81
                <span class="required">{{ $__("Required") }}</span>
82
            </li>
83
            <li>
84
                <label for="vendor_postal">{{ $__("Postal address") }}:</label>
85
                <textarea
86
                    id="vendor_postal"
87
                    v-model="vendor.postal"
88
                    cols="40"
89
                    rows="3"
90
                />
91
            </li>
92
            <li>
93
                <label for="vendor_physical"
94
                    >{{ $__("Physical address") }}:</label
95
                >
96
                <textarea
97
                    id="vendor_physical"
98
                    v-model="vendor.physical"
99
                    cols="40"
100
                    rows="3"
101
                />
102
            </li>
103
            <li>
104
                <label for="vendor_phone">{{ $__("Phone") }}:</label>
105
                <input id="vendor_phone" v-model="vendor.phone" />
106
            </li>
107
            <li>
108
                <label for="vendor_fax">{{ $__("Fax") }}:</label>
109
                <input id="vendor_fax" v-model="vendor.fax" />
110
            </li>
111
            <li>
112
                <label for="vendor_website">{{ $__("Website") }}:</label>
113
                <input id="vendor_website" v-model="vendor.url" />
114
            </li>
115
            <li>
116
                <label for="vendor_accountnumber"
117
                    >{{ $__("Account number") }}:</label
118
                >
119
                <input
120
                    id="vendor_accountnumber"
121
                    v-model="vendor.accountnumber"
122
                />
123
            </li>
124
            <li>
125
                <label for="vendor_type">{{ $__("Vendor type") }}:</label>
126
                <v-select
127
                    v-if="authorisedValues.vendor_types.length"
128
                    id="vendor_type"
129
                    v-model="vendor.type"
130
                    label="description"
131
                    :reduce="av => av.value"
132
                    :options="authorisedValues.vendor_types"
133
                />
134
                <input v-else id="vendor_type" v-model="vendor.type" />
135
            </li>
136
            <li>
137
                <label for="vendor_aliases">{{ $__("Aliases") }}:</label>
138
                <input id="vendor_aliases" v-model="newAlias" />
139
                <span class="aliasAction" @click="addAlias()"
140
                    ><i class="fa fa-plus"></i> {{ $__("Add") }}</span
141
                >
142
                <ol id="aliasList">
143
                    <li
144
                        v-for="(item, i) in vendor.aliases"
145
                        :key="`${item}${i}`"
146
                        style="display: flex"
147
                    >
148
                        <label :for="`alias${i}`"
149
                            >{{ $__("Alias") + " " + (i + 1) }}:</label
150
                        >
151
                        <span :id="`alias${i}`">{{ item.alias }}</span>
152
                        <span class="aliasAction" @click="removeAlias(item)"
153
                            ><i class="fa fa-trash"></i>
154
                            {{ $__("Remove") }}</span
155
                        >
156
                    </li>
157
                </ol>
158
            </li>
159
        </ol>
160
    </fieldset>
68
</template>
161
</template>
69
162
70
<script>
163
<script>
71
import { inject } from "vue"
164
import { inject } from "vue"
165
import { storeToRefs } from "pinia"
72
166
73
export default {
167
export default {
74
    props: {
168
    props: {
75
        vendor: Object,
169
        vendor: Object,
170
        display: Boolean,
76
    },
171
    },
77
    setup() {
172
    setup() {
78
        const AVStore = inject("AVStore")
79
        const { get_lib_from_av } = AVStore
80
173
174
        const AVStore = inject("AVStore")
175
        const { get_lib_from_av, av_vendor_types } = AVStore
81
        return {
176
        return {
82
            get_lib_from_av,
177
            get_lib_from_av,
178
            av_vendor_types,
179
        }
180
    },
181
    data() {
182
        return {
183
            newAlias: "",
83
        }
184
        }
84
    },
185
    },
186
    methods: {
187
        addAlias() {
188
            if (!this.vendor.aliases) {
189
                this.vendor.aliases = []
190
            }
191
            this.vendor.aliases.push({ alias: this.newAlias })
192
            this.newAlias = ""
193
        },
194
        removeAlias(e) {
195
            this.vendor.aliases.splice(this.vendor.aliases.indexOf(e.alias), 1)
196
        },
197
    },
85
}
198
}
86
</script>
199
</script>
87
200
88
<style></style>
201
<style scoped>
202
.aliasAction {
203
    cursor: pointer;
204
    margin-left: 5px;
205
    color: #006100;
206
}
207
#aliasList {
208
    padding-left: 5em;
209
}
210
</style>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorFormAdd.vue (+154 lines)
Line 0 Link Here
1
<template>
2
    <div v-if="!initialized">{{ $__("Loading") }}</div>
3
    <div v-else id="vendor_add">
4
        <h2 v-if="vendor.id">
5
            {{ $__("Edit vendor #%s").format(vendor.id) }}
6
        </h2>
7
        <h2 v-else>{{ $__("New vendor") }}</h2>
8
        <div>
9
            <form @submit="onSubmit($event)">
10
                <VendorDetails :vendor="vendor" />
11
                <VendorContacts :vendor="vendor" />
12
                <VendorInterfaces :vendor="vendor" />
13
                <VendorOrderingInformation :vendor="vendor" />
14
                <fieldset class="action">
15
                    <ButtonSubmit />
16
                    <router-link
17
                        :to="{ name: 'VendorList' }"
18
                        role="button"
19
                        class="cancel"
20
                        >{{ $__("Cancel") }}</router-link
21
                    >
22
                </fieldset>
23
            </form>
24
        </div>
25
    </div>
26
</template>
27
28
<script>
29
import ButtonSubmit from "../ButtonSubmit.vue"
30
import { setMessage } from "../../messages"
31
import { APIClient } from "../../fetch/api-client.js"
32
import VendorDetails from "./VendorDetails.vue"
33
import VendorContacts from "./VendorContacts.vue"
34
import VendorOrderingInformation from "./VendorOrderingInformation.vue"
35
import VendorInterfaces from "./VendorInterfaces.vue"
36
37
export default {
38
    data() {
39
        return {
40
            vendor: {
41
                id: null,
42
                name: "",
43
                address1: "",
44
                address2: "",
45
                address3: "",
46
                address4: "",
47
                phone: "",
48
                accountnumber: "",
49
                type: "",
50
                notes: "",
51
                postal: "",
52
                url: "",
53
                active: false,
54
                list_currency: null,
55
                invoice_currency: null,
56
                tax_rate: null,
57
                gst: false,
58
                list_includes_gst: false,
59
                invoice_includes_gst: false,
60
                discount: null,
61
                deliverytime: null,
62
                fax: "",
63
                external_id: "",
64
                aliases: [],
65
                contacts: [],
66
                interfaces: [],
67
            },
68
            initialized: false,
69
        }
70
    },
71
    beforeRouteEnter(to, from, next) {
72
        next(vm => {
73
            if (to.params.vendor_id) {
74
                vm.getVendor(to.params.vendor_id)
75
            } else {
76
                vm.initialized = true
77
            }
78
        })
79
    },
80
    methods: {
81
        async getVendor(vendor_id) {
82
            const client = APIClient.acquisition
83
            client.vendors.get(vendor_id).then(
84
                vendor => {
85
                    this.vendor = vendor
86
                    let physical = ""
87
                    vendor.address1 && (physical += vendor.address1 + "\n")
88
                    vendor.address2 && (physical += vendor.address2 + "\n")
89
                    vendor.address3 && (physical += vendor.address3 + "\n")
90
                    vendor.address4 && (physical += vendor.address4 + "\n")
91
                    this.vendor.physical = physical
92
                    this.initialized = true
93
                },
94
                error => {}
95
            )
96
        },
97
        onSubmit(e) {
98
            e.preventDefault()
99
100
            const vendor = JSON.parse(JSON.stringify(this.vendor))
101
102
            const vendorId = vendor.id
103
            delete vendor.id
104
105
            if (vendor.physical) {
106
                const addressLines = vendor.physical.split("\n")
107
                if (addressLines.length > 4) {
108
                    addressLines.length = 4
109
                }
110
                addressLines.forEach((line, i) => {
111
                    vendor[`address${i + 1}`] = line
112
                })
113
            }
114
            delete vendor.physical
115
116
            vendor.contacts = vendor.contacts.map(
117
                ({ id, booksellerid, ...requiredProperties }) =>
118
                    requiredProperties
119
            )
120
            vendor.interfaces = vendor.interfaces.map(
121
                ({ interface_id, vendor_id, ...requiredProperties }) =>
122
                    requiredProperties
123
            )
124
125
            const client = APIClient.acquisition
126
            if (vendorId) {
127
                client.vendors.update(vendor, vendorId).then(
128
                    success => {
129
                        setMessage(this.$__("Vendor updated"))
130
                        this.$router.push({ name: "VendorList" })
131
                    },
132
                    error => {}
133
                )
134
            } else {
135
                client.vendors.create(vendor).then(
136
                    success => {
137
                        setMessage(this.$__("Vendor created"))
138
                        this.$router.push({ name: "VendorList" })
139
                    },
140
                    error => {}
141
                )
142
            }
143
        },
144
    },
145
    components: {
146
        ButtonSubmit,
147
        VendorDetails,
148
        VendorContacts,
149
        VendorOrderingInformation,
150
        VendorInterfaces,
151
    },
152
    name: "VendorFormAdd",
153
}
154
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorInterfaces.vue (-2 / +119 lines)
Lines 1-5 Link Here
1
<template>
1
<template>
2
    <fieldset class="rows">
2
    <fieldset class="rows" v-if="display">
3
        <h2>
3
        <h2>
4
            {{ $__("Interfaces") }}
4
            {{ $__("Interfaces") }}
5
        </h2>
5
        </h2>
Lines 8-14 Link Here
8
            <li>
8
            <li>
9
                <label>{{ $__("Type") }}:</label>
9
                <label>{{ $__("Type") }}:</label>
10
                <span>
10
                <span>
11
                    {{ get_lib_from_av("vendor_interface_types", vi.type) }}
11
                    {{ get_lib_from_av("av_vendor_interface_types", vi.type) }}
12
                </span>
12
                </span>
13
            </li>
13
            </li>
14
            <li v-if="vi.uri">
14
            <li v-if="vi.uri">
Lines 43-54 Link Here
43
            </li>
43
            </li>
44
        </ol>
44
        </ol>
45
    </fieldset>
45
    </fieldset>
46
    <fieldset class="rows" v-else>
47
        <legend>{{ $__("Interfaces") }}</legend>
48
        <fieldset
49
            v-for="(vendorInterface, i) in vendor.interfaces"
50
            v-bind:key="i"
51
            class="rows"
52
            :id="`vendor_interface_${i}`"
53
        >
54
            <legend>
55
                {{ $__("Interface details") }}
56
                <a href="#" @click.prevent="deleteInterface(i)"
57
                    ><i class="fa fa-trash"></i>
58
                    {{ $__("Remove this interface") }}</a
59
                >
60
            </legend>
61
            <ol>
62
                <li>
63
                    <label :for="`vendorInterface_${i}_name`"
64
                        >{{ $__("Name") }}:</label
65
                    >
66
                    <input
67
                        :id="`vendorInterface_${i}_name`"
68
                        v-model="vendorInterface.name"
69
                    />
70
                </li>
71
                <li>
72
                    <label for="vendorInterface_type">{{ $__("Type") }}:</label>
73
                    <v-select
74
                        id="vendorInterface_type"
75
                        v-model="vendorInterface.type"
76
                        label="description"
77
                        :reduce="av => av.value"
78
                        :options="av_vendor_interface_types"
79
                    />
80
                </li>
81
                <li>
82
                    <label :for="`vendorInterface_${i}_uri`"
83
                        >{{ $__("URI") }}:</label
84
                    >
85
                    <input
86
                        :id="`vendorInterface_${i}_uri`"
87
                        v-model="vendorInterface.uri"
88
                    />
89
                </li>
90
                <li>
91
                    <label :for="`vendorInterface_${i}_login`"
92
                        >{{ $__("Login") }}:</label
93
                    >
94
                    <input
95
                        :id="`vendorInterface_${i}_login`"
96
                        v-model="vendorInterface.login"
97
                    />
98
                </li>
99
                <li>
100
                    <label :for="`vendorInterface_${i}_password`"
101
                        >{{ $__("Password") }}:</label
102
                    >
103
                    <input
104
                        :id="`vendorInterface_${i}_password`"
105
                        v-model="vendorInterface.password"
106
                    />
107
                </li>
108
                <li>
109
                    <label :for="`vendorInterface_${i}_accountemail`"
110
                        >{{ $__("Account email") }}:</label
111
                    >
112
                    <input
113
                        :id="`vendorInterface_${i}_accountemail`"
114
                        v-model="vendorInterface.account_email"
115
                    />
116
                </li>
117
                <li>
118
                    <label :for="`vendorInterface_${i}_notes`"
119
                        >{{ $__("Notes") }}:</label
120
                    >
121
                    <textarea
122
                        :id="`vendorInterface_${i}_notes`"
123
                        v-model="vendorInterface.notes"
124
                        cols="40"
125
                        rows="3"
126
                    />
127
                </li>
128
            </ol>
129
        </fieldset>
130
        <span class="btn btn-default" @click="addInterface"
131
            ><font-awesome-icon icon="plus" />
132
            {{ $__("Add new interface") }}</span
133
        >
134
    </fieldset>
46
</template>
135
</template>
47
136
48
<script>
137
<script>
138
import { inject } from "vue"
139
import { storeToRefs } from "pinia"
140
49
export default {
141
export default {
50
    props: {
142
    props: {
51
        vendor: Object,
143
        vendor: Object,
144
        display: Boolean,
145
    },
146
    setup() {
147
        const AVStore = inject("AVStore")
148
        const { get_lib_from_av, av_vendor_interface_types } = AVStore
149
        return {
150
            get_lib_from_av,
151
            av_vendor_interface_types,
152
        }
153
    },
154
    methods: {
155
        addInterface() {
156
            this.vendor.interfaces.push({
157
                type: "",
158
                name: "",
159
                uri: "",
160
                login: "",
161
                password: "",
162
                account_email: "",
163
                notes: "",
164
            })
165
        },
166
        deleteInterface(interfaceIndex) {
167
            this.vendor.interfaces.splice(interfaceIndex, 1)
168
        },
52
    },
169
    },
53
}
170
}
54
</script>
171
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue (-21 / +15 lines)
Lines 3-9 Link Here
3
    <div v-else id="vendors_list">
3
    <div v-else id="vendors_list">
4
        <Toolbar>
4
        <Toolbar>
5
            <ToolbarButton
5
            <ToolbarButton
6
                :to="{ name: 'VendorList' }"
6
                :to="{ name: 'VendorFormAdd' }"
7
                icon="plus"
7
                icon="plus"
8
                :title="$__('New vendor')"
8
                :title="$__('New vendor')"
9
            />
9
            />
Lines 28-37 Link Here
28
import flatPickr from "vue-flatpickr-component"
28
import flatPickr from "vue-flatpickr-component"
29
import Toolbar from "../Toolbar.vue"
29
import Toolbar from "../Toolbar.vue"
30
import ToolbarButton from "../ToolbarButton.vue"
30
import ToolbarButton from "../ToolbarButton.vue"
31
import { inject, ref, reactive } from "vue"
31
import { inject, ref } from "vue"
32
import { APIClient } from "../../fetch/api-client.js"
32
import { APIClient } from "../../fetch/api-client.js"
33
import { storeToRefs } from "pinia"
33
import { storeToRefs } from "pinia"
34
import { build_url } from "../../composables/datatables"
35
import KohaTable from "../KohaTable.vue"
34
import KohaTable from "../KohaTable.vue"
36
35
37
export default {
36
export default {
Lines 45-55 export default { Link Here
45
44
46
        const table = ref()
45
        const table = ref()
47
46
48
        // const filters = reactive({
49
        //     by_expired: false,
50
        //     max_expiration_date: "",
51
        //     by_mine: false,
52
        // })
53
        return {
47
        return {
54
            vendors,
48
            vendors,
55
            get_lib_from_av,
49
            get_lib_from_av,
Lines 58-64 export default { Link Here
58
            setConfirmationDialog,
52
            setConfirmationDialog,
59
            setMessage,
53
            setMessage,
60
            escape_str,
54
            escape_str,
61
            // filters,
62
        }
55
        }
63
    },
56
    },
64
    data() {
57
    data() {
Lines 69-75 export default { Link Here
69
            tableOptions: {
62
            tableOptions: {
70
                columns: this.getTableColumns(),
63
                columns: this.getTableColumns(),
71
                options: { embed: "aliases,baskets,subscriptions" },
64
                options: { embed: "aliases,baskets,subscriptions" },
72
                url: () => this.table_url(),
65
                url: () => this.tableURL(),
73
                add_filters: true,
66
                add_filters: true,
74
                filters_options: {
67
                filters_options: {
75
                    1: [
68
                    1: [
Lines 104-122 export default { Link Here
104
                error => {}
97
                error => {}
105
            )
98
            )
106
        },
99
        },
107
        doShow: function ({ id }, dt, event) {
100
        doShow({ id }, dt, event) {
108
            event.preventDefault()
101
            event.preventDefault()
109
            this.$router.push({
102
            this.$router.push({
110
                name: "VendorShow",
103
                name: "VendorShow",
111
                params: { vendor_id: id },
104
                params: { vendor_id: id },
112
            })
105
            })
113
        },
106
        },
114
        doEdit: function ({ id }, dt, event) {
107
        doEdit({ id }, dt, event) {
115
            this.$router.push({
108
            this.$router.push({
116
                name: "Home",
109
                name: "VendorFormAddEdit",
110
                params: { vendor_id: id },
117
            })
111
            })
118
        },
112
        },
119
        doDelete: function (vendor, dt, event) {
113
        doDelete(vendor, dt, event) {
120
            this.setConfirmationDialog(
114
            this.setConfirmationDialog(
121
                {
115
                {
122
                    title: this.$__(
116
                    title: this.$__(
Lines 143-157 export default { Link Here
143
                }
137
                }
144
            )
138
            )
145
        },
139
        },
146
        doSelect: function (vendor, dt, event) {
140
        doSelect(vendor, dt, event) {
147
            this.$emit("select-vendor", vendor.id)
141
            this.$emit("select-vendor", vendor.id)
148
            this.$emit("close")
142
            this.$emit("close")
149
        },
143
        },
150
        table_url: function () {
144
        tableURL() {
151
            let url = "/api/v1/acquisitions/vendors"
145
            let url = "/api/v1/acquisitions/vendors"
152
            return url
146
            return url
153
        },
147
        },
154
        getTableColumns: function () {
148
        getTableColumns() {
155
            const escape_str = this.escape_str
149
            const escape_str = this.escape_str
156
            const get_lib_from_av = this.get_lib_from_av
150
            const get_lib_from_av = this.get_lib_from_av
157
151
Lines 161-167 export default { Link Here
161
                    data: "me.name:me.id",
155
                    data: "me.name:me.id",
162
                    searchable: true,
156
                    searchable: true,
163
                    orderable: true,
157
                    orderable: true,
164
                    render: function (data, type, row, meta) {
158
                    render(data, type, row, meta) {
165
                        return (
159
                        return (
166
                            '<a href="/cgi-bin/koha/vendors/' +
160
                            '<a href="/cgi-bin/koha/vendors/' +
167
                            row.id +
161
                            row.id +
Lines 176-182 export default { Link Here
176
                    data: "active",
170
                    data: "active",
177
                    searchable: true,
171
                    searchable: true,
178
                    orderable: true,
172
                    orderable: true,
179
                    render: function (data, type, row, meta) {
173
                    render(data, type, row, meta) {
180
                        return escape_str(
174
                        return escape_str(
181
                            row.active ? __("Active") : __("Inactive")
175
                            row.active ? __("Active") : __("Inactive")
182
                        )
176
                        )
Lines 202-208 export default { Link Here
202
                    data: "baskets",
196
                    data: "baskets",
203
                    searchable: false,
197
                    searchable: false,
204
                    orderable: true,
198
                    orderable: true,
205
                    render: function (data, type, row, meta) {
199
                    render(data, type, row, meta) {
206
                        return row.baskets.length
200
                        return row.baskets.length
207
                            ? '<a href="/cgi-bin/koha/vendors/' +
201
                            ? '<a href="/cgi-bin/koha/vendors/' +
208
                                  row.id +
202
                                  row.id +
Lines 219-225 export default { Link Here
219
                    data: "subscriptions",
213
                    data: "subscriptions",
220
                    searchable: false,
214
                    searchable: false,
221
                    orderable: true,
215
                    orderable: true,
222
                    render: function (data, type, row, meta) {
216
                    render(data, type, row, meta) {
223
                        return row.subscriptions.length
217
                        return row.subscriptions.length
224
                            ? '<a href="/cgi-bin/koha/serials/serials-search.pl?bookseller_filter=' +
218
                            ? '<a href="/cgi-bin/koha/serials/serials-search.pl?bookseller_filter=' +
225
                                  row.name +
219
                                  row.name +
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorOrderingInformation.vue (-8 / +178 lines)
Lines 1-5 Link Here
1
<template>
1
<template>
2
    <fieldset class="rows">
2
    <fieldset class="rows" v-if="display">
3
        <h2>
3
        <h2>
4
            {{ $__("Ordering information") }}
4
            {{ $__("Ordering information") }}
5
        </h2>
5
        </h2>
Lines 13-43 Link Here
13
            <li>
13
            <li>
14
                <label>{{ $__("List prices are") }}:</label>
14
                <label>{{ $__("List prices are") }}:</label>
15
                <span>
15
                <span>
16
                    {{ vendor.listprice }}
16
                    {{ vendor.list_currency }}
17
                </span>
17
                </span>
18
            </li>
18
            </li>
19
            <li>
19
            <li>
20
                <label>{{ $__("Invoice prices are") }}:</label>
20
                <label>{{ $__("Invoice prices are") }}:</label>
21
                <span>
21
                <span>
22
                    {{ vendor.invoiceprice }}
22
                    {{ vendor.invoice_currency }}
23
                </span>
23
                </span>
24
            </li>
24
            </li>
25
            <li v-if="vendor.tax_rate">
25
            <li v-if="vendor.tax_rate">
26
                <label>{{ $__("Tax number registered") }}:</label>
26
                <label>{{ $__("Tax number registered") }}:</label>
27
                <span>
27
                <span>
28
                    {{ vendor.gstreg ? $__("Yes") : $__("No") }}
28
                    {{ vendor.gst ? $__("Yes") : $__("No") }}
29
                </span>
29
                </span>
30
            </li>
30
            </li>
31
            <li v-if="vendor.tax_rate">
31
            <li v-if="vendor.tax_rate">
32
                <label>{{ $__("List item price includes tax") }}:</label>
32
                <label>{{ $__("List item price includes tax") }}:</label>
33
                <span>
33
                <span>
34
                    {{ vendor.listincgst ? $__("Yes") : $__("No") }}
34
                    {{ vendor.list_includes_gst ? $__("Yes") : $__("No") }}
35
                </span>
35
                </span>
36
            </li>
36
            </li>
37
            <li v-if="vendor.tax_rate">
37
            <li v-if="vendor.tax_rate">
38
                <label>{{ $__("Invoice item price includes tax") }}:</label>
38
                <label>{{ $__("Invoice item price includes tax") }}:</label>
39
                <span>
39
                <span>
40
                    {{ vendor.invoiceincgst ? $__("Yes") : $__("No") }}
40
                    {{ vendor.invoice_includes_gst ? $__("Yes") : $__("No") }}
41
                </span>
41
                </span>
42
            </li>
42
            </li>
43
            <li>
43
            <li>
Lines 62-75 Link Here
62
            </li>
62
            </li>
63
        </ol>
63
        </ol>
64
    </fieldset>
64
    </fieldset>
65
    <fieldset class="rows" v-else>
66
        <legend>{{ $__("Ordering information") }}</legend>
67
        <ol>
68
            <li>
69
                <label for="activestatus">{{ $__("Vendor is") }}:</label>
70
                <input
71
                    type="radio"
72
                    name="active"
73
                    id="activestatus_active"
74
                    :value="true"
75
                    v-model="vendor.active"
76
                />
77
                <label class="radio" for="activestatus_active"
78
                    >{{ $__("Active") }}
79
                </label>
80
                <input
81
                    type="radio"
82
                    name="active"
83
                    id="activestatus_inactive"
84
                    :value="false"
85
                    v-model="vendor.active"
86
                />
87
                <label class="radio" for="activestatus_inactive"
88
                    >{{ $__("Inactive") }}
89
                </label>
90
            </li>
91
            <li>
92
                <label for="list_currency">{{ $__("List prices are") }}:</label>
93
                <v-select
94
                    id="list_currency"
95
                    v-model="vendor.list_currency"
96
                    label="currency"
97
                    :reduce="av => av.currency"
98
                    :options="currencies"
99
                />
100
            </li>
101
            <li>
102
                <label for="invoice_currency"
103
                    >{{ $__("Invoice prices are") }}:</label
104
                >
105
                <v-select
106
                    id="invoice_currency"
107
                    v-model="vendor.invoice_currency"
108
                    label="currency"
109
                    :reduce="av => av.currency"
110
                    :options="currencies"
111
                />
112
            </li>
113
            <li>
114
                <label for="gst">{{ $__("Tax number registered") }}:</label>
115
                <input
116
                    type="radio"
117
                    name="gst"
118
                    id="gst_yes"
119
                    :value="true"
120
                    v-model="vendor.gst"
121
                />
122
                <label class="radio" for="gst_yes">{{ $__("Yes") }} </label>
123
                <input
124
                    type="radio"
125
                    name="gst"
126
                    id="gst_no"
127
                    :value="false"
128
                    v-model="vendor.gst"
129
                />
130
                <label class="radio" for="gst_no">{{ $__("No") }} </label>
131
            </li>
132
            <li>
133
                <label for="invoice_gst">{{ $__("Invoice prices") }}:</label>
134
                <input
135
                    type="radio"
136
                    name="invoice_gst"
137
                    id="invoice_gst_yes"
138
                    :value="true"
139
                    v-model="vendor.invoice_includes_gst"
140
                />
141
                <label class="radio" for="invoice_gst_yes"
142
                    >{{ $__("Include tax") }}
143
                </label>
144
                <input
145
                    type="radio"
146
                    name="invoice_gst"
147
                    id="invoice_gst_no"
148
                    :value="false"
149
                    v-model="vendor.invoice_includes_gst"
150
                />
151
                <label class="radio" for="invoice_gst_no"
152
                    >{{ $__("Don't include tax") }}
153
                </label>
154
            </li>
155
            <li>
156
                <label for="list_gst">{{ $__("List prices") }}:</label>
157
                <input
158
                    type="radio"
159
                    name="list_gst"
160
                    id="list_gst_yes"
161
                    :value="true"
162
                    v-model="vendor.list_includes_gst"
163
                />
164
                <label class="radio" for="list_gst_yes"
165
                    >{{ $__("Include tax") }}
166
                </label>
167
                <input
168
                    type="radio"
169
                    name="list_gst"
170
                    id="list_gst_no"
171
                    :value="false"
172
                    v-model="vendor.list_includes_gst"
173
                />
174
                <label class="radio" for="list_gst_no"
175
                    >{{ $__("Don't include tax") }}
176
                </label>
177
            </li>
178
            <li>
179
                <label for="tax_rate">{{ $__("Tax rate") }}:</label>
180
                <v-select
181
                    id="tax_rate"
182
                    v-model="vendor.tax_rate"
183
                    label="label"
184
                    :reduce="av => av.value"
185
                    :options="gstValues"
186
                />
187
            </li>
188
            <li>
189
                <label for="discount">{{ $__("Discount") }}: </label>
190
                <input
191
                    type="text"
192
                    size="6"
193
                    id="discount"
194
                    name="discount"
195
                    v-model="vendor.discount"
196
                />
197
                %
198
            </li>
199
            <li>
200
                <label for="deliverytime">{{ $__("Delivery time") }}: </label>
201
                <input
202
                    type="text"
203
                    size="6"
204
                    id="deliverytime"
205
                    name="deliverytime"
206
                    v-model="vendor.deliverytime"
207
                />
208
                {{ $__("days") }}
209
            </li>
210
            <li>
211
                <label for="notes">{{ $__("Notes") }}:</label>
212
                <textarea
213
                    id="notes"
214
                    v-model="vendor.notes"
215
                    cols="40"
216
                    rows="3"
217
                />
218
            </li>
219
        </ol>
220
    </fieldset>
65
</template>
221
</template>
66
222
67
<script>
223
<script>
224
import { inject } from "vue"
225
import { storeToRefs } from "pinia"
226
68
export default {
227
export default {
69
    props: {
228
    props: {
70
        vendor: Object,
229
        vendor: Object,
230
        display: Boolean,
231
    },
232
    setup() {
233
        const vendorStore = inject("vendorStore")
234
        const { currencies, gstValues } = storeToRefs(vendorStore)
235
236
        const AVStore = inject("AVStore")
237
        const { get_lib_from_av } = AVStore
238
239
        return {
240
            currencies,
241
            gstValues,
242
        }
71
    },
243
    },
72
}
244
}
73
</script>
245
</script>
74
75
<style></style>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorShow.vue (-3 / +4 lines)
Lines 26-40 Link Here
26
        </h1>
26
        </h1>
27
        <div class="row">
27
        <div class="row">
28
            <div class="col-sm-6">
28
            <div class="col-sm-6">
29
                <VendorDetails :vendor="vendor" />
29
                <VendorDetails :vendor="vendor" :display="true" />
30
                <VendorOrderingInformation :vendor="vendor" />
30
                <VendorOrderingInformation :vendor="vendor" :display="true" />
31
                <VendorInterfaces
31
                <VendorInterfaces
32
                    :vendor="vendor"
32
                    :vendor="vendor"
33
                    v-if="vendor.interfaces.length > 0"
33
                    v-if="vendor.interfaces.length > 0"
34
                    :display="true"
34
                />
35
                />
35
            </div>
36
            </div>
36
            <div class="col-sm-6">
37
            <div class="col-sm-6">
37
                <VendorContacts :vendor="vendor" />
38
                <VendorContacts :vendor="vendor" :display="true" />
38
                <VendorSubscriptions :vendor="vendor" />
39
                <VendorSubscriptions :vendor="vendor" />
39
            </div>
40
            </div>
40
        </div>
41
        </div>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js (+3 lines)
Lines 22-27 export class AcquisitionAPIClient extends HttpClient { Link Here
22
                    endpoint: "vendors",
22
                    endpoint: "vendors",
23
                    query,
23
                    query,
24
                    params,
24
                    params,
25
                    headers: {
26
                        "x-koha-embed": "aliases",
27
                    },
25
                }),
28
                }),
26
            delete: id =>
29
            delete: id =>
27
                this.delete({
30
                this.delete({
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/acquisitions.js (-1 / +13 lines)
Lines 3-8 import { markRaw } from "vue"; Link Here
3
import Home from "../components/Vendors/Home.vue";
3
import Home from "../components/Vendors/Home.vue";
4
import VendorList from "../components/Vendors/VendorList.vue";
4
import VendorList from "../components/Vendors/VendorList.vue";
5
import VendorShow from "../components/Vendors/VendorShow.vue";
5
import VendorShow from "../components/Vendors/VendorShow.vue";
6
import VendorFormAdd from "../components/Vendors/VendorFormAdd.vue";
6
7
7
import { $__ } from "../i18n";
8
import { $__ } from "../i18n";
8
9
Lines 36-41 export const routes = [ Link Here
36
                        component: markRaw(VendorShow),
37
                        component: markRaw(VendorShow),
37
                        title: $__("Show vendor"),
38
                        title: $__("Show vendor"),
38
                    },
39
                    },
40
                    {
41
                        path: "add",
42
                        name: "VendorFormAdd",
43
                        component: markRaw(VendorFormAdd),
44
                        title: $__("Add vendor"),
45
                    },
46
                    {
47
                        path: "edit/:vendor_id",
48
                        name: "VendorFormAddEdit",
49
                        component: markRaw(VendorFormAdd),
50
                        title: $__("Edit vendor"),
51
                    },
39
                ],
52
                ],
40
            },
53
            },
41
        ],
54
        ],
42
- 

Return to bug 38010