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

(-)a/acqui/basketheader.pl (-44 / +9 lines)
Lines 54-60 use C4::Acquisition qw( GetBasket ModBasket ModBasketHeader NewBasket ); Link Here
54
54
55
use Koha::Acquisition::Booksellers;
55
use Koha::Acquisition::Booksellers;
56
use Koha::Acquisition::Baskets;
56
use Koha::Acquisition::Baskets;
57
use Koha::Acquisition::Contracts;
58
use Koha::AdditionalFields;
57
use Koha::AdditionalFields;
59
use Koha::Database;
58
use Koha::Database;
60
59
Lines 71-114 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
71
#parameters:
70
#parameters:
72
my $booksellerid = $input->param('booksellerid');
71
my $booksellerid = $input->param('booksellerid');
73
my $basketno     = $input->param('basketno');
72
my $basketno     = $input->param('basketno');
74
my $basket;
73
my $op           = $input->param('op');
75
my $op         = $input->param('op');
74
my $is_an_edit   = $input->param('is_an_edit');
76
my $is_an_edit = $input->param('is_an_edit');
77
75
78
$template->param( available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqbasket' } ) );
76
$template->param( available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqbasket' } ) );
79
77
80
if ( $op eq 'add_form' ) {
78
if ( $op eq 'add_form' ) {
81
    my @contracts = Koha::Acquisition::Contracts->search(
79
    my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid);
82
        { booksellerid => $booksellerid, contractenddate => { '>=' => \'now()' } } )->as_list;
80
    my $contracts  = $bookseller->contracts->search( { contractenddate => { '>=' => \'now()' } } );
83
    my @contractloop;
81
84
    foreach my $contract (@contracts) {
85
        push( @contractloop, $contract->unblessed );
86
    }
87
    if ($basketno) {
82
    if ($basketno) {
88
83
89
        #this is an edit
84
        #this is an edit
90
        $basket = GetBasket($basketno);
85
        my $basket = Koha::Acquisition::Baskets->find($basketno);
91
        if ( !$booksellerid ) {
92
            $booksellerid = $basket->{'booksellerid'};
93
        }
94
86
95
        for (@contractloop) {
87
        $template->param( basket => $basket );
96
            if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) {
97
                $_->{selected} = 1;
98
            }
99
        }
100
        $template->param( is_an_edit => 1 );
101
        $template->param( additional_field_values =>
88
        $template->param( additional_field_values =>
102
                Koha::Acquisition::Baskets->find($basketno)->get_additional_field_values_for_template );
89
                Koha::Acquisition::Baskets->find($basketno)->get_additional_field_values_for_template );
103
    }
90
    }
104
    my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid);
105
    my $count      = scalar @contractloop;
106
    if ( $count > 0 ) {
107
        $template->param(
108
            contractloop         => \@contractloop,
109
            basketcontractnumber => $basket->{'contractnumber'}
110
        );
111
    }
112
91
113
    # Check if basket name should be read-only (EDI-generated with PO number setting)
92
    # Check if basket name should be read-only (EDI-generated with PO number setting)
114
    my $basket_name_readonly = 0;
93
    my $basket_name_readonly = 0;
Lines 130-153 if ( $op eq 'add_form' ) { Link Here
130
109
131
    $template->param(
110
    $template->param(
132
        add_form             => 1,
111
        add_form             => 1,
133
        basketname           => $basket->{'basketname'},
112
        vendor               => $bookseller,
134
        basketnote           => $basket->{'note'},
113
        contracts            => $contracts
135
        basketbooksellernote => $basket->{'booksellernote'},
136
        booksellername       => $bookseller->name,
137
        booksellerid         => $booksellerid,
138
        basketno             => $basketno,
139
        is_standing          => $basket->{is_standing},
140
        create_items         => $basket->{create_items},
141
        basket_name_readonly => $basket_name_readonly,
142
    );
114
    );
143
115
144
    my $billingplace  = $basket->{'billingplace'}  || C4::Context->userenv->{"branch"};
145
    my $deliveryplace = $basket->{'deliveryplace'} || C4::Context->userenv->{"branch"};
146
147
    $template->param( billingplace  => $billingplace );
148
    $template->param( deliveryplace => $deliveryplace );
149
150
    #End Edit
151
} elsif ( $op eq 'cud-add_validate' ) {
116
} elsif ( $op eq 'cud-add_validate' ) {
152
117
153
    #we are confirming the changes, save the basket
118
    #we are confirming the changes, save the basket
(-)a/admin/aqcontract.pl (-1 lines)
Lines 28-34 use C4::Output qw( output_html_with_http_headers ); Link Here
28
use Koha::DateUtils qw( dt_from_string );
28
use Koha::DateUtils qw( dt_from_string );
29
29
30
use Koha::Acquisition::Booksellers;
30
use Koha::Acquisition::Booksellers;
31
use Koha::Acquisition::Contract;
32
use Koha::Acquisition::Contracts;
31
use Koha::Acquisition::Contracts;
33
32
34
my $input          = CGI->new;
33
my $input          = CGI->new;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt (-31 / +31 lines)
Lines 8-17 Link Here
8
<title
8
<title
9
    >[% FILTER collapse %]
9
    >[% FILTER collapse %]
10
        [% IF ( add_form ) %]
10
        [% IF ( add_form ) %]
11
            [% IF ( basketno ) %]
11
            [% IF ( basket ) %]
12
                [% tx("Edit basket '{basketname}'", { basketname = basketname }) | html %]
12
                [% tx("Edit basket '{basketname}'", { basketname = basket.basketname }) | html %]
13
            [% ELSE %]
13
            [% ELSE %]
14
                [% tx("Add basket to {vendor}", { vendor = booksellername }) | html %]
14
                [% tx("Add basket to {vendor}", { vendor = vendor.name}) | html %]
15
            [% END %]
15
            [% END %]
16
        [% END %]
16
        [% END %]
17
        &rsaquo; [% t("Acquisitions") | html %] &rsaquo; [% t("Koha") | html %]
17
        &rsaquo; [% t("Acquisitions") | html %] &rsaquo; [% t("Koha") | html %]
Lines 31-46 Link Here
31
            <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
31
            <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
32
        [% END %]
32
        [% END %]
33
        [% WRAPPER breadcrumb_item %]
33
        [% WRAPPER breadcrumb_item %]
34
            <a href="/cgi-bin/koha/acquisition/vendors/[% booksellerid | uri %]">[% booksellername | html %]</a>
34
            <a href="/cgi-bin/koha/acquisition/vendors/[% vendor.id | uri %]">[% vendor.name | html %]</a>
35
        [% END %]
35
        [% END %]
36
        [% IF ( add_form ) %]
36
        [% IF ( add_form ) %]
37
            [% IF ( basketno ) %]
37
            [% IF basket %]
38
                [% WRAPPER breadcrumb_item bc_active= 1 %]
38
                [% WRAPPER breadcrumb_item bc_active= 1 %]
39
                    <span>Edit basket '[% basketname | html %]'</span>
39
                    <span>Edit basket '[% basket.basketname | html %]'</span>
40
                [% END %]
40
                [% END %]
41
            [% ELSE %]
41
            [% ELSE %]
42
                [% WRAPPER breadcrumb_item bc_active= 1 %]
42
                [% WRAPPER breadcrumb_item bc_active= 1 %]
43
                    <span>Add a basket to [% booksellername | html %]</span>
43
                    <span>Add a basket to [% vendor.name | html %]</span>
44
                [% END %]
44
                [% END %]
45
            [% END %]
45
            [% END %]
46
        [% END %]
46
        [% END %]
Lines 50-79 Link Here
50
[% WRAPPER 'main-container.inc' %]
50
[% WRAPPER 'main-container.inc' %]
51
51
52
    [% IF ( add_form ) %]
52
    [% IF ( add_form ) %]
53
        [% IF ( basketno ) %]
53
        [% IF basket %]
54
            <h1>Edit basket [% basketname | html %]</h1>
54
            <h1>Edit basket [% basket.basketname | html %]</h1>
55
        [% ELSE %]
55
        [% ELSE %]
56
            <h1>Add a basket to [% booksellername | html %]</h1>
56
            <h1>Add a basket to [% vendor.name | html %]</h1>
57
        [% END %]
57
        [% END %]
58
        <form name="Aform" action="/cgi-bin/koha/acqui/basketheader.pl" method="post" class="validated">
58
        <form name="Aform" action="/cgi-bin/koha/acqui/basketheader.pl" method="post" class="validated">
59
            [% INCLUDE 'csrf-token.inc' %]
59
            [% INCLUDE 'csrf-token.inc' %]
60
            <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
60
            <input type="hidden" name="booksellerid" value="[% vendor.id | html %]" />
61
            <fieldset class="rows">
61
            <fieldset class="rows">
62
                <ol>
62
                <ol>
63
                    [% IF ( basketno ) %]
63
                    [% IF basket %]
64
                        <li>
64
                        <li>
65
                            <input type="hidden" name="basketno" value="[% basketno | html %]" />
65
                            <input type="hidden" name="basketno" value="[% basket.basketno | html %]" />
66
                            <input type="hidden" name="is_an_edit" value="1" />
66
                            <input type="hidden" name="is_an_edit" value="1" />
67
                        </li>
67
                        </li>
68
                    [% END %]
68
                    [% END %]
69
                    <li>
69
                    <li>
70
                        <label for="basketname" class="required">Basket name: </label>
70
                        <label for="basketname" class="required">Basket name: </label>
71
                        [% IF basket_name_readonly %]
71
                        [% IF basket_name_readonly %]
72
                            <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basketname | html %]" required="required" class="focus required" readonly="readonly" />
72
                            <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basket.basketname | html %]" required="required" class="focus required" readonly="readonly" />
73
                            <span class="required">Required</span>
73
                            <span class="required">Required</span>
74
                            <div class="hint">This basket name is derived from the purchase order number and cannot be changed.</div>
74
                            <div class="hint">This basket name is derived from the purchase order number and cannot be changed.</div>
75
                        [% ELSE %]
75
                        [% ELSE %]
76
                            <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basketname | html %]" required="required" class="focus required" />
76
                            <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basket.basketname | html %]" required="required" class="focus required" />
77
                            <span class="required">Required</span>
77
                            <span class="required">Required</span>
78
                        [% END %]
78
                        [% END %]
79
                    </li>
79
                    </li>
Lines 81-120 Link Here
81
                        <label for="billingplace">Billing place: </label>
81
                        <label for="billingplace">Billing place: </label>
82
                        <select name="billingplace" id="billingplace">
82
                        <select name="billingplace" id="billingplace">
83
                            <option value="">--</option>
83
                            <option value="">--</option>
84
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => billingplace ) %]
84
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => basket.billingplace || Branches.GetLoggedInBranchcode() ) %]
85
                        </select>
85
                        </select>
86
                    </li>
86
                    </li>
87
                    <li>
87
                    <li>
88
                        <label for="deliveryplace">Delivery place: </label>
88
                        <label for="deliveryplace">Delivery place: </label>
89
                        <select name="deliveryplace" id="deliveryplace">
89
                        <select name="deliveryplace" id="deliveryplace">
90
                            <option value="">--</option>
90
                            <option value="">--</option>
91
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => deliveryplace ) %]
91
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => deliveryplace || Branches.GetLoggedInBranchcode() ) %]
92
                        </select>
92
                        </select>
93
                    </li>
93
                    </li>
94
                    <li>
94
                    <li>
95
                        <label for="basketbooksellerid">Vendor: </label>
95
                        <label for="basketbooksellerid">Vendor: </label>
96
                        <select name="basketbooksellerid" id="basketbooksellerid">
96
                        <select name="basketbooksellerid" id="basketbooksellerid">
97
                            <option value="[% booksellerid | html %]" selected="selected">Current vendor ([% booksellername | html %])</option>
97
                            <option value="[% vendor.id | html %]" selected="selected">Current vendor ([% vendor.name | html %])</option>
98
                        </select>
98
                        </select>
99
                    </li>
99
                    </li>
100
                    <li>
100
                    <li>
101
                        <label for="basketnote">Internal note: </label>
101
                        <label for="basketnote">Internal note: </label>
102
                        <textarea name="basketnote" id="basketnote" rows="5" cols="40">[% basketnote |html %]</textarea>
102
                        <textarea name="basketnote" id="basketnote" rows="5" cols="40">[% basket.note |html %]</textarea>
103
                    </li>
103
                    </li>
104
                    <li>
104
                    <li>
105
                        <label for="basketbooksellernote">Vendor note: </label>
105
                        <label for="basketbooksellernote">Vendor note: </label>
106
                        <textarea name="basketbooksellernote" id="basketbooksellernote" rows="5" cols="40">[% basketbooksellernote |html %]</textarea>
106
                        <textarea name="basketbooksellernote" id="basketbooksellernote" rows="5" cols="40">[% basket.booksellernote |html %]</textarea>
107
                    </li>
107
                    </li>
108
                    [% IF ( contractloop ) %]
108
                    [% IF contracts.count %]
109
                        <li
109
                        <li
110
                            ><label for="basketcontractnumber">Contract: </label>
110
                            ><label for="basketcontractnumber">Contract: </label>
111
                            <select id="basketcontractnumber" name="basketcontractnumber">
111
                            <select id="basketcontractnumber" name="basketcontractnumber">
112
                                <option value=""></option>
112
                                <option value=""></option>
113
                                [% FOREACH contractloo IN contractloop %]
113
                                [% FOREACH contract IN contracts %]
114
                                    [% IF ( contractloo.selected ) %]
114
                                    [% IF contract.contractnumber == basket.contractnumber %]
115
                                        <option value="[% contractloo.contractnumber | html %]" selected="selected">[% contractloo.contractname | html %]</option>
115
                                        <option value="[% contract.contractnumber | html %]" selected="selected">[% contract.contractname | html %]</option>
116
                                    [% ELSE %]
116
                                    [% ELSE %]
117
                                        <option value="[% contractloo.contractnumber | html %]">[% contractloo.contractname | html %]</option>
117
                                        <option value="[% contract.contractnumber | html %]">[% contract.contractname | html %]</option>
118
                                    [% END %]
118
                                    [% END %]
119
                                [% END %]
119
                                [% END %]
120
                            </select>
120
                            </select>
Lines 122-136 Link Here
122
                    [% END %]
122
                    [% END %]
123
                    <li>
123
                    <li>
124
                        <label for="is_standing">Orders are standing:</label>
124
                        <label for="is_standing">Orders are standing:</label>
125
                        [% IF is_standing %]
125
                        [% IF basket.is_standing %]
126
                            <input type="checkbox" id="is_standing" name="is_standing" checked="checked" />
126
                            <input type="checkbox" id="is_standing" name="is_standing" checked="checked" />
127
                        [% ELSE %]
127
                        [% ELSE %]
128
                            <input type="checkbox" id="is_standing" name="is_standing" />
128
                            <input type="checkbox" id="is_standing" name="is_standing" />
129
                        [% END %]
129
                        [% END %]
130
                        <div class="hint">Standing orders do not close when received.</div>
130
                        <div class="hint">Standing orders do not close when received.</div>
131
                    </li>
131
                    </li>
132
                    [% IF basketno %]
132
                    [% IF basket %]
133
                        <input type="hidden" name="create_items" value="[% create_items | html %]" />
133
                        <input type="hidden" name="create_items" value="[% basket.create_items | html %]" />
134
                    [% ELSE %]
134
                    [% ELSE %]
135
                        <li>
135
                        <li>
136
                            <label for="create_items">Create items when:</label>
136
                            <label for="create_items">Create items when:</label>
Lines 159-168 Link Here
159
            <fieldset class="action">
159
            <fieldset class="action">
160
                <input type="hidden" name="op" value="cud-add_validate" />
160
                <input type="hidden" name="op" value="cud-add_validate" />
161
                <input type="submit" class="btn btn-primary" value="Save" />
161
                <input type="submit" class="btn btn-primary" value="Save" />
162
                [% IF ( basketno ) %]
162
                [% IF basket %]
163
                    <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno | html %]">Cancel</a>
163
                    <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | html %]">Cancel</a>
164
                [% ELSE %]
164
                [% ELSE %]
165
                    <a class="cancel" href="/cgi-bin/koha/acquisition/vendors/[% booksellerid | html %]">Cancel</a>
165
                    <a class="cancel" href="/cgi-bin/koha/acquisition/vendors/[% vendor.id | html %]">Cancel</a>
166
                [% END %]
166
                [% END %]
167
            </fieldset>
167
            </fieldset>
168
        </form>
168
        </form>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-4 / +4 lines)
Lines 276-284 Link Here
276
                <ol>
276
                <ol>
277
                    [% IF ( basketnote ) %]<li><span class="label">Internal note:</span> [% basketnote | html %]</li>[% END %]
277
                    [% IF ( basketnote ) %]<li><span class="label">Internal note:</span> [% basketnote | html %]</li>[% END %]
278
                    [% IF ( basketbooksellernote ) %]<li><span class="label">Vendor note:</span> [% basketbooksellernote | html %]</li>[% END %]
278
                    [% IF ( basketbooksellernote ) %]<li><span class="label">Vendor note:</span> [% basketbooksellernote | html %]</li>[% END %]
279
                    [% IF ( basketcontractno ) %]
279
                    [% SET contract = basket_obj.contract %]
280
                        <li><span class="label">Contract number: </span>[% basketcontractno | html %]</li>
280
                    [% IF contract %]
281
                        <li><span class="label">Contract name:</span> <a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=[% basketcontractno | uri %]">[% basketcontractname | html %]</a></li>
281
                        <li><span class="label">Contract number: </span>[% contract.contractnumber | html %]</li>
282
                        <li><span class="label">Contract name:</span> <a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=[% contract.contractnumber | uri %]">[% contract.contractname | html %]</a></li>
282
                    [% END %]
283
                    [% END %]
283
                    [% IF ( authorisedbyname ) %]<li><span class="label">[% tp('Acquisitions basket managed by user', 'Managed by:') | html %]</span> [% authorisedbyname | html %]</li>[% END %]
284
                    [% IF ( authorisedbyname ) %]<li><span class="label">[% tp('Acquisitions basket managed by user', 'Managed by:') | html %]</span> [% authorisedbyname | html %]</li>[% END %]
284
                    [% IF ( creationdate ) %]<li><span class="label">Open on:</span> [% creationdate | $KohaDates %]</li>[% END %]
285
                    [% IF ( creationdate ) %]<li><span class="label">Open on:</span> [% creationdate | $KohaDates %]</li>[% END %]
285
- 

Return to bug 39711