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

(-)a/acqui/basketheader.pl (-46 / +11 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
58
60
my $input = CGI->new;
59
my $input = CGI->new;
Lines 70-133 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
70
#parameters:
69
#parameters:
71
my $booksellerid = $input->param('booksellerid');
70
my $booksellerid = $input->param('booksellerid');
72
my $basketno     = $input->param('basketno');
71
my $basketno     = $input->param('basketno');
73
my $basket;
72
my $op           = $input->param('op');
74
my $op         = $input->param('op');
73
my $is_an_edit   = $input->param('is_an_edit');
75
my $is_an_edit = $input->param('is_an_edit');
76
74
77
$template->param( available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqbasket' } ) );
75
$template->param( available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqbasket' } ) );
78
76
79
if ( $op eq 'add_form' ) {
77
if ( $op eq 'add_form' ) {
80
    my @contracts = Koha::Acquisition::Contracts->search(
78
    my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid);
81
        { booksellerid => $booksellerid, contractenddate => { '>=' => \'now()' } } )->as_list;
79
    my $contracts  = $bookseller->contracts->search( { contractenddate => { '>=' => \'now()' } } );
82
    my @contractloop;
80
83
    foreach my $contract (@contracts) {
84
        push( @contractloop, $contract->unblessed );
85
    }
86
    if ($basketno) {
81
    if ($basketno) {
87
82
88
        #this is an edit
83
        #this is an edit
89
        $basket = GetBasket($basketno);
84
        my $basket = Koha::Acquisition::Baskets->find($basketno);
90
        if ( !$booksellerid ) {
85
91
            $booksellerid = $basket->{'booksellerid'};
86
        $template->param( basket => $basket );
92
        }
93
94
        for (@contractloop) {
95
            if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) {
96
                $_->{selected} = 1;
97
            }
98
        }
99
        $template->param( is_an_edit => 1 );
100
        $template->param( additional_field_values =>
87
        $template->param( additional_field_values =>
101
                Koha::Acquisition::Baskets->find($basketno)->get_additional_field_values_for_template );
88
                Koha::Acquisition::Baskets->find($basketno)->get_additional_field_values_for_template );
102
    }
89
    }
103
    my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid);
104
    my $count      = scalar @contractloop;
105
    if ( $count > 0 ) {
106
        $template->param(
107
            contractloop         => \@contractloop,
108
            basketcontractnumber => $basket->{'contractnumber'}
109
        );
110
    }
111
90
112
    $template->param(
91
    $template->param(
113
        add_form             => 1,
92
        add_form  => 1,
114
        basketname           => $basket->{'basketname'},
93
        vendor    => $bookseller,
115
        basketnote           => $basket->{'note'},
94
        contracts => $contracts,
116
        basketbooksellernote => $basket->{'booksellernote'},
117
        booksellername       => $bookseller->name,
118
        booksellerid         => $booksellerid,
119
        basketno             => $basketno,
120
        is_standing          => $basket->{is_standing},
121
        create_items         => $basket->{create_items},
122
    );
95
    );
123
124
    my $billingplace  = $basket->{'billingplace'}  || C4::Context->userenv->{"branch"};
125
    my $deliveryplace = $basket->{'deliveryplace'} || C4::Context->userenv->{"branch"};
126
127
    $template->param( billingplace  => $billingplace );
128
    $template->param( deliveryplace => $deliveryplace );
129
130
    #End Edit
131
} elsif ( $op eq 'cud-add_validate' ) {
96
} elsif ( $op eq 'cud-add_validate' ) {
132
97
133
    #we are confirming the changes, save the basket
98
    #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 (-30 / +30 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-114 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
                        <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basketname | html %]" required="required" class="focus required" />
71
                        <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basket.basketname | html %]" required="required" class="focus required" />
72
                        <span class="required">Required</span>
72
                        <span class="required">Required</span>
73
                    </li>
73
                    </li>
74
                    <li>
74
                    <li>
75
                        <label for="billingplace">Billing place: </label>
75
                        <label for="billingplace">Billing place: </label>
76
                        <select name="billingplace" id="billingplace">
76
                        <select name="billingplace" id="billingplace">
77
                            <option value="">--</option>
77
                            <option value="">--</option>
78
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => billingplace ) %]
78
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => basket.billingplace || Branches.GetLoggedInBranchcode() ) %]
79
                        </select>
79
                        </select>
80
                    </li>
80
                    </li>
81
                    <li>
81
                    <li>
82
                        <label for="deliveryplace">Delivery place: </label>
82
                        <label for="deliveryplace">Delivery place: </label>
83
                        <select name="deliveryplace" id="deliveryplace">
83
                        <select name="deliveryplace" id="deliveryplace">
84
                            <option value="">--</option>
84
                            <option value="">--</option>
85
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => deliveryplace ) %]
85
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => deliveryplace || Branches.GetLoggedInBranchcode() ) %]
86
                        </select>
86
                        </select>
87
                    </li>
87
                    </li>
88
                    <li>
88
                    <li>
89
                        <label for="basketbooksellerid">Vendor: </label>
89
                        <label for="basketbooksellerid">Vendor: </label>
90
                        <select name="basketbooksellerid" id="basketbooksellerid">
90
                        <select name="basketbooksellerid" id="basketbooksellerid">
91
                            <option value="[% booksellerid | html %]" selected="selected">Current vendor ([% booksellername | html %])</option>
91
                            <option value="[% vendor.id | html %]" selected="selected">Current vendor ([% vendor.name | html %])</option>
92
                        </select>
92
                        </select>
93
                    </li>
93
                    </li>
94
                    <li>
94
                    <li>
95
                        <label for="basketnote">Internal note: </label>
95
                        <label for="basketnote">Internal note: </label>
96
                        <textarea name="basketnote" id="basketnote" rows="5" cols="40">[% basketnote |html %]</textarea>
96
                        <textarea name="basketnote" id="basketnote" rows="5" cols="40">[% basket.note |html %]</textarea>
97
                    </li>
97
                    </li>
98
                    <li>
98
                    <li>
99
                        <label for="basketbooksellernote">Vendor note: </label>
99
                        <label for="basketbooksellernote">Vendor note: </label>
100
                        <textarea name="basketbooksellernote" id="basketbooksellernote" rows="5" cols="40">[% basketbooksellernote |html %]</textarea>
100
                        <textarea name="basketbooksellernote" id="basketbooksellernote" rows="5" cols="40">[% basket.booksellernote |html %]</textarea>
101
                    </li>
101
                    </li>
102
                    [% IF ( contractloop ) %]
102
                    [% IF contracts.count %]
103
                        <li
103
                        <li
104
                            ><label for="basketcontractnumber">Contract: </label>
104
                            ><label for="basketcontractnumber">Contract: </label>
105
                            <select id="basketcontractnumber" name="basketcontractnumber">
105
                            <select id="basketcontractnumber" name="basketcontractnumber">
106
                                <option value=""></option>
106
                                <option value=""></option>
107
                                [% FOREACH contractloo IN contractloop %]
107
                                [% FOREACH contract IN contracts %]
108
                                    [% IF ( contractloo.selected ) %]
108
                                    [% IF contract.contractnumber == basket.contractnumber %]
109
                                        <option value="[% contractloo.contractnumber | html %]" selected="selected">[% contractloo.contractname | html %]</option>
109
                                        <option value="[% contract.contractnumber | html %]" selected="selected">[% contract.contractname | html %]</option>
110
                                    [% ELSE %]
110
                                    [% ELSE %]
111
                                        <option value="[% contractloo.contractnumber | html %]">[% contractloo.contractname | html %]</option>
111
                                        <option value="[% contract.contractnumber | html %]">[% contract.contractname | html %]</option>
112
                                    [% END %]
112
                                    [% END %]
113
                                [% END %]
113
                                [% END %]
114
                            </select>
114
                            </select>
Lines 116-130 Link Here
116
                    [% END %]
116
                    [% END %]
117
                    <li>
117
                    <li>
118
                        <label for="is_standing">Orders are standing:</label>
118
                        <label for="is_standing">Orders are standing:</label>
119
                        [% IF is_standing %]
119
                        [% IF basket.is_standing %]
120
                            <input type="checkbox" id="is_standing" name="is_standing" checked="checked" />
120
                            <input type="checkbox" id="is_standing" name="is_standing" checked="checked" />
121
                        [% ELSE %]
121
                        [% ELSE %]
122
                            <input type="checkbox" id="is_standing" name="is_standing" />
122
                            <input type="checkbox" id="is_standing" name="is_standing" />
123
                        [% END %]
123
                        [% END %]
124
                        <div class="hint">Standing orders do not close when received.</div>
124
                        <div class="hint">Standing orders do not close when received.</div>
125
                    </li>
125
                    </li>
126
                    [% IF basketno %]
126
                    [% IF basket %]
127
                        <input type="hidden" name="create_items" value="[% create_items | html %]" />
127
                        <input type="hidden" name="create_items" value="[% basket.create_items | html %]" />
128
                    [% ELSE %]
128
                    [% ELSE %]
129
                        <li>
129
                        <li>
130
                            <label for="create_items">Create items when:</label>
130
                            <label for="create_items">Create items when:</label>
Lines 153-162 Link Here
153
            <fieldset class="action">
153
            <fieldset class="action">
154
                <input type="hidden" name="op" value="cud-add_validate" />
154
                <input type="hidden" name="op" value="cud-add_validate" />
155
                <input type="submit" class="btn btn-primary" value="Save" />
155
                <input type="submit" class="btn btn-primary" value="Save" />
156
                [% IF ( basketno ) %]
156
                [% IF basket %]
157
                    <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno | html %]">Cancel</a>
157
                    <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | html %]">Cancel</a>
158
                [% ELSE %]
158
                [% ELSE %]
159
                    <a class="cancel" href="/cgi-bin/koha/acquisition/vendors/[% booksellerid | html %]">Cancel</a>
159
                    <a class="cancel" href="/cgi-bin/koha/acquisition/vendors/[% vendor.id | html %]">Cancel</a>
160
                [% END %]
160
                [% END %]
161
            </fieldset>
161
            </fieldset>
162
        </form>
162
        </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