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

(-)a/Koha/Acquisition/Order.pm (+15 lines)
Lines 33-38 use Koha::Biblios; Link Here
33
use Koha::Holds;
33
use Koha::Holds;
34
use Koha::Items;
34
use Koha::Items;
35
use Koha::Number::Price;
35
use Koha::Number::Price;
36
use Koha::Patrons;
36
use Koha::Subscriptions;
37
use Koha::Subscriptions;
37
38
38
use base qw(Koha::Object);
39
use base qw(Koha::Object);
Lines 400-405 sub claimed_date { Link Here
400
    return $last_claim->claimed_on;
401
    return $last_claim->claimed_on;
401
}
402
}
402
403
404
=head3 creator
405
406
my $creator = $order->creator;
407
408
Retrieves patron that created this order.
409
410
=cut
411
412
sub creator {
413
    my ( $self )  = @_;
414
    my $creator_rs = $self->_result->creator;
415
    return Koha::Patron->_new_from_dbic( $creator_rs );
416
}
417
403
=head3 duplicate_to
418
=head3 duplicate_to
404
419
405
    my $duplicated_order = $order->duplicate_to($basket, [$default_values]);
420
    my $duplicated_order = $order->duplicate_to($basket, [$default_values]);
(-)a/Koha/REST/V1/Acquisitions/Orders.pm (-1 / +1 lines)
Lines 193-199 sub list { Link Here
193
193
194
        return $c->render(
194
        return $c->render(
195
            status  => 200,
195
            status  => 200,
196
            openapi => $orders->to_api({ embed => $embed })
196
            openapi => $c->objects->to_api($orders)
197
        );
197
        );
198
    }
198
    }
199
    catch {
199
    catch {
(-)a/Koha/Schema/Result/Aqorder.pm (+20 lines)
Lines 851-856 __PACKAGE__->belongs_to( Link Here
851
  },
851
  },
852
);
852
);
853
853
854
=head2 creator
855
856
Type: belongs_to
857
858
Related object: L<Koha::Schema::Result::Borrower>
859
860
=cut
861
862
__PACKAGE__->belongs_to(
863
  "creator",
864
  "Koha::Schema::Result::Borrower",
865
  { borrowernumber => "created_by" },
866
  {
867
    is_deferrable => 1,
868
    join_type     => "LEFT",
869
    on_delete     => "SET NULL",
870
    on_update     => "CASCADE",
871
  },
872
);
873
854
__PACKAGE__->belongs_to(
874
__PACKAGE__->belongs_to(
855
  "subscription",
875
  "subscription",
856
  "Koha::Schema::Result::Subscription",
876
  "Koha::Schema::Result::Subscription",
(-)a/acqui/orderreceive.pl (-43 / +53 lines)
Lines 85-90 my $invoice = GetInvoice($invoiceid); Link Here
85
my $booksellerid   = $invoice->{booksellerid};
85
my $booksellerid   = $invoice->{booksellerid};
86
my $freight      = $invoice->{shipmentcost};
86
my $freight      = $invoice->{shipmentcost};
87
my $ordernumber  = $input->param('ordernumber');
87
my $ordernumber  = $input->param('ordernumber');
88
my $multiple_orders = $input->param('multiple_orders');
88
89
89
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
90
my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
90
my $order = Koha::Acquisition::Orders->find( $ordernumber );
91
my $order = Koha::Acquisition::Orders->find( $ordernumber );
Lines 98-110 my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user( Link Here
98
    }
99
    }
99
);
100
);
100
101
101
unless ( $order ) {
102
unless ( $order || $multiple_orders ) {
102
    output_html_with_http_headers $input, $cookie, $template->output;
103
    output_html_with_http_headers $input, $cookie, $template->output;
103
    exit;
104
    exit;
104
}
105
}
105
106
106
# prepare the form for receiving
107
my $budget;
107
my $basket = $order->basket;
108
if ($order) {
109
110
    # prepare the form for receiving
111
    my $creator = Koha::Patrons->find( $order->created_by );
112
113
    $budget = GetBudget( $order->budget_id );
114
115
    my $datereceived = $order->datereceived || dt_from_string;
116
117
    my $order_internalnote = $order->order_internalnote;
118
    my $order_vendornote   = $order->order_vendornote;
119
    if ( $order->subscriptionid ) {
120
121
        # Order from a subscription, we will display an history of what has been received
122
        my $orders = Koha::Acquisition::Orders->search(
123
            {
124
                subscriptionid     => $order->subscriptionid,
125
                parent_ordernumber => $order->ordernumber,
126
                ordernumber        => { '!=' => $order->ordernumber }
127
            }
128
        );
129
        if ( $order->parent_ordernumber != $order->ordernumber ) {
130
            my $parent_order = Koha::Acquisition::Orders->find( $order->parent_ordernumber );
131
            $order_internalnote = $parent_order->order_internalnote;
132
            $order_vendornote   = $parent_order->order_vendornote;
133
        }
134
        $template->param( orders => $orders, );
135
    }
136
137
    my $suggestion = GetSuggestionInfoFromBiblionumber( $order->biblionumber );
138
139
    if ($suggestion) {
140
        $template->param( suggestion => $suggestion );
141
    }
142
143
    $template->param(
144
        order              => $order,
145
        creator            => $creator,
146
        bookfund           => $budget->{budget_name},
147
        datereceived       => $datereceived,
148
        order_internalnote => $order_internalnote,
149
        order_vendornote   => $order_vendornote,
150
    );
151
}
152
153
if ($multiple_orders) {
154
    $template->param( multiple_orders => $multiple_orders );
155
}
156
108
my $currencies = Koha::Acquisition::Currencies->search;
157
my $currencies = Koha::Acquisition::Currencies->search;
109
my $active_currency = $currencies->get_active;
158
my $active_currency = $currencies->get_active;
110
159
Lines 114-174 unless($acq_fw) { Link Here
114
    $template->param('NoACQframework' => 1);
163
    $template->param('NoACQframework' => 1);
115
}
164
}
116
165
117
118
my $creator = Koha::Patrons->find( $order->created_by );
119
120
my $budget = GetBudget( $order->budget_id );
121
122
my $datereceived = $order->datereceived || dt_from_string;
123
124
# get option values for TaxRates syspref
166
# get option values for TaxRates syspref
125
my @gst_values = map {
167
my @gst_values = map {
126
    option => $_ + 0.0
168
    option => $_ + 0.0
127
}, split( '\|', C4::Context->preference("TaxRates") );
169
}, split( '\|', C4::Context->preference("TaxRates") );
128
170
129
my $order_internalnote = $order->order_internalnote;
130
my $order_vendornote   = $order->order_vendornote;
131
if ( $order->subscriptionid ) {
132
    # Order from a subscription, we will display an history of what has been received
133
    my $orders = Koha::Acquisition::Orders->search(
134
        {
135
            subscriptionid     => $order->subscriptionid,
136
            parent_ordernumber => $order->ordernumber,
137
            ordernumber        => { '!=' => $order->ordernumber }
138
        }
139
    );
140
    if ( $order->parent_ordernumber != $order->ordernumber ) {
141
        my $parent_order = Koha::Acquisition::Orders->find($order->parent_ordernumber);
142
        $order_internalnote = $parent_order->order_internalnote;
143
        $order_vendornote   = $parent_order->order_vendornote;
144
    }
145
    $template->param(
146
        orders => $orders,
147
    );
148
}
149
150
$template->param(
171
$template->param(
151
    order                 => $order,
152
    freight               => $freight,
172
    freight               => $freight,
153
    name                  => $bookseller->name,
173
    name                  => $bookseller->name,
154
    active_currency       => $active_currency,
174
    active_currency       => $active_currency,
155
    currencies            => $currencies->search({ rate => { '!=' => 1 } }),
175
    currencies            => $currencies->search({ rate => { '!=' => 1 } }),
156
    invoiceincgst         => $bookseller->invoiceincgst,
176
    invoiceincgst         => $bookseller->invoiceincgst,
157
    bookfund              => $budget->{budget_name},
158
    creator               => $creator,
159
    invoiceid             => $invoice->{invoiceid},
177
    invoiceid             => $invoice->{invoiceid},
160
    invoice               => $invoice->{invoicenumber},
178
    invoice               => $invoice->{invoicenumber},
161
    datereceived          => $datereceived,
162
    order_internalnote    => $order_internalnote,
163
    order_vendornote      => $order_vendornote,
164
    gst_values            => \@gst_values,
179
    gst_values            => \@gst_values,
165
);
180
);
166
181
167
my $suggestion = GetSuggestionInfoFromBiblionumber($order->biblionumber);
168
if ( $suggestion ) {
169
    $template->param( suggestion => $suggestion );
170
}
171
172
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
182
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
173
my %budget_loops;
183
my %budget_loops;
174
my $budgets = GetBudgetHierarchy( undef, undef, undef, 1 );
184
my $budgets = GetBudgetHierarchy( undef, undef, undef, 1 );
Lines 185-191 foreach my $budget (@{$budgets}) { Link Here
185
        b_sort1_authcat => $budget->{'sort1_authcat'},
195
        b_sort1_authcat => $budget->{'sort1_authcat'},
186
        b_sort2_authcat => $budget->{'sort2_authcat'},
196
        b_sort2_authcat => $budget->{'sort2_authcat'},
187
        b_active => $budget->{budget_period_active},
197
        b_active => $budget->{budget_period_active},
188
        b_sel => ( $budget->{budget_id} == $order->budget_id ) ? 1 : 0,
198
        # b_sel => ( $budget->{budget_id} == $order->budget_id ) ? 1 : 0,
189
        b_level => $budget->{budget_level},
199
        b_level => $budget->{budget_level},
190
    };
200
    };
191
}
201
}
(-)a/api/v1/swagger/definitions/order.yaml (+5 lines)
Lines 254-257 properties: Link Here
254
    type:
254
    type:
255
      - object
255
      - object
256
      - "null"
256
      - "null"
257
  creator:
258
    type:
259
      - object
260
      - "null"
261
    description: Patron that created the order
257
additionalProperties: false
262
additionalProperties: false
(-)a/api/v1/swagger/paths/acquisitions_orders.yaml (+5 lines)
Lines 59-68 Link Here
59
            - biblio.holds+count
59
            - biblio.holds+count
60
            - biblio.items+count
60
            - biblio.items+count
61
            - biblio.suggestions.suggester
61
            - biblio.suggestions.suggester
62
            - creator
62
            - fund
63
            - fund
64
            - fund.budget
63
            - current_item_level_holds+count
65
            - current_item_level_holds+count
64
            - invoice
66
            - invoice
65
            - items
67
            - items
68
            - items.home_branch
69
            - items.holding_branch
70
            - items.itemtype
66
            - items+strings
71
            - items+strings
67
            - subscription
72
            - subscription
68
        collectionFormat: csv
73
        collectionFormat: csv
(-)a/koha-tmpl/intranet-tmpl/lib/datatables/dataTables.select.min.js (+38 lines)
Line 0 Link Here
1
/*!
2
   Copyright 2015-2019 SpryMedia Ltd.
3
4
 This source file is free software, available under the following license:
5
   MIT license - http://datatables.net/license/mit
6
7
 This source file is distributed in the hope that it will be useful, but
8
 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9
 or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
10
11
 For details please refer to: http://www.datatables.net/extensions/select
12
 Select for DataTables 1.3.1
13
 2015-2019 SpryMedia Ltd - datatables.net/license/mit
14
*/
15
(function(f){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(k){return f(k,window,document)}):"object"===typeof exports?module.exports=function(k,p){k||(k=window);p&&p.fn.dataTable||(p=require("datatables.net")(k,p).$);return f(p,k,k.document)}:f(jQuery,window,document)})(function(f,k,p,h){function z(a,b,c){var d=function(c,b){if(c>b){var d=b;b=c;c=d}var e=!1;return a.columns(":visible").indexes().filter(function(a){a===c&&(e=!0);return a===b?(e=!1,!0):e})};var e=
16
function(c,b){var d=a.rows({search:"applied"}).indexes();if(d.indexOf(c)>d.indexOf(b)){var e=b;b=c;c=e}var f=!1;return d.filter(function(a){a===c&&(f=!0);return a===b?(f=!1,!0):f})};a.cells({selected:!0}).any()||c?(d=d(c.column,b.column),c=e(c.row,b.row)):(d=d(0,b.column),c=e(0,b.row));c=a.cells(c,d).flatten();a.cells(b,{selected:!0}).any()?a.cells(c).deselect():a.cells(c).select()}function v(a){var b=a.settings()[0]._select.selector;f(a.table().container()).off("mousedown.dtSelect",b).off("mouseup.dtSelect",
17
b).off("click.dtSelect",b);f("body").off("click.dtSelect"+a.table().node().id.replace(/[^a-zA-Z0-9\-_]/g,"-"))}function A(a){var b=f(a.table().container()),c=a.settings()[0],d=c._select.selector,e;b.on("mousedown.dtSelect",d,function(a){if(a.shiftKey||a.metaKey||a.ctrlKey)b.css("-moz-user-select","none").one("selectstart.dtSelect",d,function(){return!1});k.getSelection&&(e=k.getSelection())}).on("mouseup.dtSelect",d,function(){b.css("-moz-user-select","")}).on("click.dtSelect",d,function(c){var b=
18
a.select.items();if(e){var d=k.getSelection();if((!d.anchorNode||f(d.anchorNode).closest("table")[0]===a.table().node())&&d!==e)return}d=a.settings()[0];var l=f.trim(a.settings()[0].oClasses.sWrapper).replace(/ +/g,".");if(f(c.target).closest("div."+l)[0]==a.table().container()&&(l=a.cell(f(c.target).closest("td, th")),l.any())){var g=f.Event("user-select.dt");m(a,g,[b,l,c]);g.isDefaultPrevented()||(g=l.index(),"row"===b?(b=g.row,w(c,a,d,"row",b)):"column"===b?(b=l.index().column,w(c,a,d,"column",
19
b)):"cell"===b&&(b=l.index(),w(c,a,d,"cell",b)),d._select_lastCell=g)}});f("body").on("click.dtSelect"+a.table().node().id.replace(/[^a-zA-Z0-9\-_]/g,"-"),function(b){!c._select.blurable||f(b.target).parents().filter(a.table().container()).length||0===f(b.target).parents("html").length||f(b.target).parents("div.DTE").length||r(c,!0)})}function m(a,b,c,d){if(!d||a.flatten().length)"string"===typeof b&&(b+=".dt"),c.unshift(a),f(a.table().node()).trigger(b,c)}function B(a){var b=a.settings()[0];if(b._select.info&&
20
b.aanFeatures.i&&"api"!==a.select.style()){var c=a.rows({selected:!0}).flatten().length,d=a.columns({selected:!0}).flatten().length,e=a.cells({selected:!0}).flatten().length,l=function(b,c,d){b.append(f('<span class="select-item"/>').append(a.i18n("select."+c+"s",{_:"%d "+c+"s selected",0:"",1:"1 "+c+" selected"},d)))};f.each(b.aanFeatures.i,function(b,a){a=f(a);b=f('<span class="select-info"/>');l(b,"row",c);l(b,"column",d);l(b,"cell",e);var g=a.children("span.select-info");g.length&&g.remove();
21
""!==b.text()&&a.append(b)})}}function D(a){var b=new g.Api(a);a.aoRowCreatedCallback.push({fn:function(b,d,e){d=a.aoData[e];d._select_selected&&f(b).addClass(a._select.className);b=0;for(e=a.aoColumns.length;b<e;b++)(a.aoColumns[b]._select_selected||d._selected_cells&&d._selected_cells[b])&&f(d.anCells[b]).addClass(a._select.className)},sName:"select-deferRender"});b.on("preXhr.dt.dtSelect",function(){var a=b.rows({selected:!0}).ids(!0).filter(function(b){return b!==h}),d=b.cells({selected:!0}).eq(0).map(function(a){var c=
22
b.row(a.row).id(!0);return c?{row:c,column:a.column}:h}).filter(function(b){return b!==h});b.one("draw.dt.dtSelect",function(){b.rows(a).select();d.any()&&d.each(function(a){b.cells(a.row,a.column).select()})})});b.on("draw.dtSelect.dt select.dtSelect.dt deselect.dtSelect.dt info.dt",function(){B(b)});b.on("destroy.dtSelect",function(){v(b);b.off(".dtSelect")})}function C(a,b,c,d){var e=a[b+"s"]({search:"applied"}).indexes();d=f.inArray(d,e);var g=f.inArray(c,e);if(a[b+"s"]({selected:!0}).any()||
23
-1!==d){if(d>g){var u=g;g=d;d=u}e.splice(g+1,e.length);e.splice(0,d)}else e.splice(f.inArray(c,e)+1,e.length);a[b](c,{selected:!0}).any()?(e.splice(f.inArray(c,e),1),a[b+"s"](e).deselect()):a[b+"s"](e).select()}function r(a,b){if(b||"single"===a._select.style)a=new g.Api(a),a.rows({selected:!0}).deselect(),a.columns({selected:!0}).deselect(),a.cells({selected:!0}).deselect()}function w(a,b,c,d,e){var f=b.select.style(),g=b.select.toggleable(),h=b[d](e,{selected:!0}).any();if(!h||g)"os"===f?a.ctrlKey||
24
a.metaKey?b[d](e).select(!h):a.shiftKey?"cell"===d?z(b,e,c._select_lastCell||null):C(b,d,e,c._select_lastCell?c._select_lastCell[d]:null):(a=b[d+"s"]({selected:!0}),h&&1===a.flatten().length?b[d](e).deselect():(a.deselect(),b[d](e).select())):"multi+shift"==f?a.shiftKey?"cell"===d?z(b,e,c._select_lastCell||null):C(b,d,e,c._select_lastCell?c._select_lastCell[d]:null):b[d](e).select(!h):b[d](e).select(!h)}function t(a,b){return function(c){return c.i18n("buttons."+a,b)}}function x(a){a=a._eventNamespace;
25
return"draw.dt.DT"+a+" select.dt.DT"+a+" deselect.dt.DT"+a}function E(a,b){return-1!==f.inArray("rows",b.limitTo)&&a.rows({selected:!0}).any()||-1!==f.inArray("columns",b.limitTo)&&a.columns({selected:!0}).any()||-1!==f.inArray("cells",b.limitTo)&&a.cells({selected:!0}).any()?!0:!1}var g=f.fn.dataTable;g.select={};g.select.version="1.3.1";g.select.init=function(a){var b=a.settings()[0],c=b.oInit.select,d=g.defaults.select;c=c===h?d:c;d="row";var e="api",l=!1,u=!0,k=!0,m="td, th",p="selected",n=!1;
26
b._select={};!0===c?(e="os",n=!0):"string"===typeof c?(e=c,n=!0):f.isPlainObject(c)&&(c.blurable!==h&&(l=c.blurable),c.toggleable!==h&&(u=c.toggleable),c.info!==h&&(k=c.info),c.items!==h&&(d=c.items),e=c.style!==h?c.style:"os",n=!0,c.selector!==h&&(m=c.selector),c.className!==h&&(p=c.className));a.select.selector(m);a.select.items(d);a.select.style(e);a.select.blurable(l);a.select.toggleable(u);a.select.info(k);b._select.className=p;f.fn.dataTable.ext.order["select-checkbox"]=function(b,a){return this.api().column(a,
27
{order:"index"}).nodes().map(function(a){return"row"===b._select.items?f(a).parent().hasClass(b._select.className):"cell"===b._select.items?f(a).hasClass(b._select.className):!1})};!n&&f(a.table().node()).hasClass("selectable")&&a.select.style("os")};f.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(a,b){g.ext.selector[b.type].push(function(a,d,e){d=d.selected;var c=[];if(!0!==d&&!1!==d)return e;for(var f=0,g=e.length;f<g;f++){var h=a[b.prop][e[f]];(!0===d&&!0===h._select_selected||
28
!1===d&&!h._select_selected)&&c.push(e[f])}return c})});g.ext.selector.cell.push(function(a,b,c){b=b.selected;var d=[];if(b===h)return c;for(var e=0,f=c.length;e<f;e++){var g=a.aoData[c[e].row];(!0===b&&g._selected_cells&&!0===g._selected_cells[c[e].column]||!(!1!==b||g._selected_cells&&g._selected_cells[c[e].column]))&&d.push(c[e])}return d});var n=g.Api.register,q=g.Api.registerPlural;n("select()",function(){return this.iterator("table",function(a){g.select.init(new g.Api(a))})});n("select.blurable()",
29
function(a){return a===h?this.context[0]._select.blurable:this.iterator("table",function(b){b._select.blurable=a})});n("select.toggleable()",function(a){return a===h?this.context[0]._select.toggleable:this.iterator("table",function(b){b._select.toggleable=a})});n("select.info()",function(a){return B===h?this.context[0]._select.info:this.iterator("table",function(b){b._select.info=a})});n("select.items()",function(a){return a===h?this.context[0]._select.items:this.iterator("table",function(b){b._select.items=
30
a;m(new g.Api(b),"selectItems",[a])})});n("select.style()",function(a){return a===h?this.context[0]._select.style:this.iterator("table",function(b){b._select.style=a;b._select_init||D(b);var c=new g.Api(b);v(c);"api"!==a&&A(c);m(new g.Api(b),"selectStyle",[a])})});n("select.selector()",function(a){return a===h?this.context[0]._select.selector:this.iterator("table",function(b){v(new g.Api(b));b._select.selector=a;"api"!==b._select.style&&A(new g.Api(b))})});q("rows().select()","row().select()",function(a){var b=
31
this;if(!1===a)return this.deselect();this.iterator("row",function(b,a){r(b);b.aoData[a]._select_selected=!0;f(b.aoData[a].nTr).addClass(b._select.className)});this.iterator("table",function(a,d){m(b,"select",["row",b[d]],!0)});return this});q("columns().select()","column().select()",function(a){var b=this;if(!1===a)return this.deselect();this.iterator("column",function(b,a){r(b);b.aoColumns[a]._select_selected=!0;a=(new g.Api(b)).column(a);f(a.header()).addClass(b._select.className);f(a.footer()).addClass(b._select.className);
32
a.nodes().to$().addClass(b._select.className)});this.iterator("table",function(a,d){m(b,"select",["column",b[d]],!0)});return this});q("cells().select()","cell().select()",function(a){var b=this;if(!1===a)return this.deselect();this.iterator("cell",function(b,a,e){r(b);a=b.aoData[a];a._selected_cells===h&&(a._selected_cells=[]);a._selected_cells[e]=!0;a.anCells&&f(a.anCells[e]).addClass(b._select.className)});this.iterator("table",function(a,d){m(b,"select",["cell",b[d]],!0)});return this});q("rows().deselect()",
33
"row().deselect()",function(){var a=this;this.iterator("row",function(a,c){a.aoData[c]._select_selected=!1;f(a.aoData[c].nTr).removeClass(a._select.className)});this.iterator("table",function(b,c){m(a,"deselect",["row",a[c]],!0)});return this});q("columns().deselect()","column().deselect()",function(){var a=this;this.iterator("column",function(a,c){a.aoColumns[c]._select_selected=!1;var b=new g.Api(a),e=b.column(c);f(e.header()).removeClass(a._select.className);f(e.footer()).removeClass(a._select.className);
34
b.cells(null,c).indexes().each(function(b){var c=a.aoData[b.row],d=c._selected_cells;!c.anCells||d&&d[b.column]||f(c.anCells[b.column]).removeClass(a._select.className)})});this.iterator("table",function(b,c){m(a,"deselect",["column",a[c]],!0)});return this});q("cells().deselect()","cell().deselect()",function(){var a=this;this.iterator("cell",function(a,c,d){c=a.aoData[c];c._selected_cells[d]=!1;c.anCells&&!a.aoColumns[d]._select_selected&&f(c.anCells[d]).removeClass(a._select.className)});this.iterator("table",
35
function(b,c){m(a,"deselect",["cell",a[c]],!0)});return this});var y=0;f.extend(g.ext.buttons,{selected:{text:t("selected","Selected"),className:"buttons-selected",limitTo:["rows","columns","cells"],init:function(a,b,c){var d=this;c._eventNamespace=".select"+y++;a.on(x(c),function(){d.enable(E(a,c))});this.disable()},destroy:function(a,b,c){a.off(c._eventNamespace)}},selectedSingle:{text:t("selectedSingle","Selected single"),className:"buttons-selected-single",init:function(a,b,c){var d=this;c._eventNamespace=
36
".select"+y++;a.on(x(c),function(){var b=a.rows({selected:!0}).flatten().length+a.columns({selected:!0}).flatten().length+a.cells({selected:!0}).flatten().length;d.enable(1===b)});this.disable()},destroy:function(a,b,c){a.off(c._eventNamespace)}},selectAll:{text:t("selectAll","Select all"),className:"buttons-select-all",action:function(){this[this.select.items()+"s"]().select()}},selectNone:{text:t("selectNone","Deselect all"),className:"buttons-select-none",action:function(){r(this.settings()[0],
37
!0)},init:function(a,b,c){var d=this;c._eventNamespace=".select"+y++;a.on(x(c),function(){var b=a.rows({selected:!0}).flatten().length+a.columns({selected:!0}).flatten().length+a.cells({selected:!0}).flatten().length;d.enable(0<b)});this.disable()},destroy:function(a,b,c){a.off(c._eventNamespace)}}});f.each(["Row","Column","Cell"],function(a,b){var c=b.toLowerCase();g.ext.buttons["select"+b+"s"]={text:t("select"+b+"s","Select "+c+"s"),className:"buttons-select-"+c+"s",action:function(){this.select.items(c)},
38
init:function(a){var b=this;a.on("selectItems.dt.DT",function(a,d,e){b.active(e===c)})}}});f(p).on("preInit.dt.dtSelect",function(a,b){"dt"===a.namespace&&g.select.init(new g.Api(b))});return g.select});
(-)a/koha-tmpl/intranet-tmpl/lib/datatables/select.dataTables.min.css (+1 lines)
Line 0 Link Here
1
table.dataTable tbody>tr.selected,table.dataTable tbody>tr>.selected{background-color:#B0BED9}table.dataTable.stripe tbody>tr.odd.selected,table.dataTable.stripe tbody>tr.odd>.selected,table.dataTable.display tbody>tr.odd.selected,table.dataTable.display tbody>tr.odd>.selected{background-color:#acbad4}table.dataTable.hover tbody>tr.selected:hover,table.dataTable.hover tbody>tr>.selected:hover,table.dataTable.display tbody>tr.selected:hover,table.dataTable.display tbody>tr>.selected:hover{background-color:#aab7d1}table.dataTable.order-column tbody>tr.selected>.sorting_1,table.dataTable.order-column tbody>tr.selected>.sorting_2,table.dataTable.order-column tbody>tr.selected>.sorting_3,table.dataTable.order-column tbody>tr>.selected,table.dataTable.display tbody>tr.selected>.sorting_1,table.dataTable.display tbody>tr.selected>.sorting_2,table.dataTable.display tbody>tr.selected>.sorting_3,table.dataTable.display tbody>tr>.selected{background-color:#acbad5}table.dataTable.display tbody>tr.odd.selected>.sorting_1,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_1{background-color:#a6b4cd}table.dataTable.display tbody>tr.odd.selected>.sorting_2,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_2{background-color:#a8b5cf}table.dataTable.display tbody>tr.odd.selected>.sorting_3,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_3{background-color:#a9b7d1}table.dataTable.display tbody>tr.even.selected>.sorting_1,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_1{background-color:#acbad5}table.dataTable.display tbody>tr.even.selected>.sorting_2,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_2{background-color:#aebcd6}table.dataTable.display tbody>tr.even.selected>.sorting_3,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_3{background-color:#afbdd8}table.dataTable.display tbody>tr.odd>.selected,table.dataTable.order-column.stripe tbody>tr.odd>.selected{background-color:#a6b4cd}table.dataTable.display tbody>tr.even>.selected,table.dataTable.order-column.stripe tbody>tr.even>.selected{background-color:#acbad5}table.dataTable.display tbody>tr.selected:hover>.sorting_1,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_1{background-color:#a2aec7}table.dataTable.display tbody>tr.selected:hover>.sorting_2,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_2{background-color:#a3b0c9}table.dataTable.display tbody>tr.selected:hover>.sorting_3,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_3{background-color:#a5b2cb}table.dataTable.display tbody>tr:hover>.selected,table.dataTable.display tbody>tr>.selected:hover,table.dataTable.order-column.hover tbody>tr:hover>.selected,table.dataTable.order-column.hover tbody>tr>.selected:hover{background-color:#a2aec7}table.dataTable tbody td.select-checkbox,table.dataTable tbody th.select-checkbox{position:relative}table.dataTable tbody td.select-checkbox:before,table.dataTable tbody td.select-checkbox:after,table.dataTable tbody th.select-checkbox:before,table.dataTable tbody th.select-checkbox:after{display:block;position:absolute;top:1.2em;left:50%;width:12px;height:12px;box-sizing:border-box}table.dataTable tbody td.select-checkbox:before,table.dataTable tbody th.select-checkbox:before{content:' ';margin-top:-6px;margin-left:-6px;border:1px solid black;border-radius:3px}table.dataTable tr.selected td.select-checkbox:after,table.dataTable tr.selected th.select-checkbox:after{content:'\2714';margin-top:-11px;margin-left:-4px;text-align:center;text-shadow:1px 1px #B0BED9, -1px -1px #B0BED9, 1px -1px #B0BED9, -1px 1px #B0BED9}div.dataTables_wrapper span.select-info,div.dataTables_wrapper span.select-item{margin-left:0.5em}@media screen and (max-width: 640px){div.dataTables_wrapper span.select-info,div.dataTables_wrapper span.select-item{margin-left:0;display:block}}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc (+1 lines)
Lines 2-5 Link Here
2
[% USE Asset %]
2
[% USE Asset %]
3
[% INCLUDE 'format_price.inc' %]
3
[% INCLUDE 'format_price.inc' %]
4
[% Asset.js("lib/datatables/datatables.min.js") | $raw %]
4
[% Asset.js("lib/datatables/datatables.min.js") | $raw %]
5
[% Asset.js("lib/datatables/dataTables.select.min.js") | $raw %]
5
[% Asset.js("js/datatables.js") | $raw %]
6
[% Asset.js("js/datatables.js") | $raw %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc (+1 lines)
Lines 23-28 Link Here
23
[% Asset.css("lib/bootstrap/bootstrap-theme.min.css") | $raw %]
23
[% Asset.css("lib/bootstrap/bootstrap-theme.min.css") | $raw %]
24
[% Asset.css("lib/font-awesome/css/font-awesome.min.css") | $raw %]
24
[% Asset.css("lib/font-awesome/css/font-awesome.min.css") | $raw %]
25
[% Asset.css("lib/datatables/datatables.min.css") | $raw %]
25
[% Asset.css("lib/datatables/datatables.min.css") | $raw %]
26
[% Asset.css("lib/datatables/select.dataTables.min.css") | $raw %]
26
[% Asset.css("css/print.css", { media = "print" }) | $raw %]
27
[% Asset.css("css/print.css", { media = "print" }) | $raw %]
27
[% INCLUDE intranetstylesheet.inc %]
28
[% INCLUDE intranetstylesheet.inc %]
28
[% IF ( bidi ) %][% Asset.css("css/right-to-left.css") | $raw %][% END %]
29
[% IF ( bidi ) %][% Asset.css("css/right-to-left.css") | $raw %][% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-4 / +1128 lines)
Lines 33-39 Link Here
33
            <a href="#" aria-current="page">
33
            <a href="#" aria-current="page">
34
    Receive items from : [% name | html %] [% IF ( invoice ) %]
34
    Receive items from : [% name | html %] [% IF ( invoice ) %]
35
    [[% invoice | html %]]
35
    [[% invoice | html %]]
36
    [% END %] (order #[% order.ordernumber | html %])
36
    [% END %] (order #[% order.ordernumber || multiple_orders | html %])
37
            </a>
37
            </a>
38
        </li>
38
        </li>
39
    </ol>
39
    </ol>
Lines 42-54 Link Here
42
42
43
<div class="main container-fluid">
43
<div class="main container-fluid">
44
    <div class="row">
44
    <div class="row">
45
    [% AcqCreateItem = order.basket.effective_create_items %]
46
        <div class="col-sm-10 col-sm-push-2">
45
        <div class="col-sm-10 col-sm-push-2">
47
            <main>
46
            <main>
48
47
49
<h1>Receive items from : [% name | html %] [% IF ( invoice ) %][[% invoice | html %]] [% END %] (order #[% order.ordernumber | html %])</h1>
48
<h1>Receive items from : [% name | html %] [% IF ( invoice ) %][[% invoice | html %]] [% END %] (order #[% order.ordernumber || multiple_orders | html %])</h1>
50
49
51
[% IF ( order ) %]
50
[% IF ( order ) %]
51
    [% AcqCreateItem = order.basket.effective_create_items %]
52
    <form id="f" action="/cgi-bin/koha/acqui/finishreceive.pl" class="noEnterSubmit" method="post" onsubmit="return Check(this);">
52
    <form id="f" action="/cgi-bin/koha/acqui/finishreceive.pl" class="noEnterSubmit" method="post" onsubmit="return Check(this);">
53
<div class="row">
53
<div class="row">
54
<div class="col-sm-6">
54
<div class="col-sm-6">
Lines 459-464 Link Here
459
        <input type="submit" value="Save" class="btn btn-primary" accesskey="w" />
459
        <input type="submit" value="Save" class="btn btn-primary" accesskey="w" />
460
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]">Cancel</a>
460
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]">Cancel</a>
461
</fieldset></div>    </form>
461
</fieldset></div>    </form>
462
[% ELSIF multiple_orders %]
463
    <table id="multiple_orders" class="table table-bordered table-striped">
464
        <thead>
465
            <tr>
466
                <th>Order</td>
467
                <th>Title</th>
468
                <th>Author</th>
469
                <th>ISBN</th>
470
                <th>Date received</th>
471
                <th>Fund</th>
472
                <th>Quantity</th>
473
                <th>&nbsp;</th>
474
            </tr>
475
        </thead>
476
    </table>
477
478
    <div class="col">
479
        <div id="jobfailed" class="dialog alert"></div>
480
        <fieldset class="action">
481
            <button class="save">Save</button>
482
            <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]&sticky_filters=1">Return</a>
483
        </fieldset>
484
        <div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
485
    </div>
486
487
    <div class="modal fade" id="order_edit" tabindex="-1" role="dialog" aria-labelledby="Order edit">
488
        <div class="modal-dialog" role="document">
489
            <div class="modal-content modal-lg">
490
                <div class="modal-header row">
491
                    <h4 class="col-md-11 modal-title"></h4>
492
                    <button type="button" class="close col-md-1" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
493
                </div>
494
                <div class="modal-body">
495
                    <div class="hide" id="loading">Loading ...</div>
496
                    <div id="modal-order-main">
497
                        <ul>
498
                            <li><a href="#info-panel">Info</a></li>
499
                            <li><a href="#accounting-panel">Accounting</a></li>
500
                            <li><a href="#history-panel">Receipt history</a></li>
501
                            <li><a href="#items-panel">Items</a></li>
502
                        </ul>
503
504
505
                        <div id="info-panel">
506
                            <div>
507
                                <h4>Catalog details</h4>
508
509
                                <div class="row"> <span class="lbl col-sm-4">Title: </span><span class="col-sm-8" id="biblio_title"></span></div>
510
                                <div class="row"> <span class="lbl col-sm-4">Author: </span><span class="col-sm-8" id="biblio_author"></span></div>
511
                                <div class="row"> <span class="lbl col-sm-4">Copyright: </span><span class="col-sm-8" id="biblio_copyright_date"></span></div>
512
                                <div class="row"> <span class="lbl col-sm-4">ISBN: </span><span class="col-sm-8" id="biblio_isbn"></span></div>
513
                                <div class="row"> <span class="lbl col-sm-4">Series: </span><span class="col-sm-8" id="biblio_series_title"></span></div>
514
515
                            </div>
516
                            <div id="suggestion_fieldset">
517
                                <h4>Suggestion</h4>
518
                                <div class="row">
519
                                    <span class="lbl col-sm-4">Suggested by: </span> <span class="col-sm-8" id="biblio_suggestion_suggester"></span>
520
                                </div>
521
                                <div class="row" id="suggestion_reason">
522
                                    <span class="lbl col-sm-4">Reason:</span>
523
                                    <div class="col-sm-8">
524
                                        [% SET suggestion_reasons = AuthorisedValues.GetAuthValueDropbox( 'SUGGEST' ) %]
525
                                        <select class="select-reason" id="reason" name="reason">
526
                                            <option value=""> -- Choose a reason -- </option>
527
                                            [% FOREACH reason IN suggestion_reasons %]
528
                                            <option value="[% reason.lib | html %]">[% reason.lib | html %]</option>
529
                                            [% END %]
530
                                            <option value="other">Others...</option>
531
                                        </select>
532
533
                                        <span id="other_reason" name="other_reason">
534
                                            <input type="text" size="31" id="select-other_reason" name="other_reason" placeholder="please note your reason here..." />
535
                                            <a href="#back">Cancel</a>
536
                                        </span>
537
                                    </div>
538
                                </div>
539
                            </div>
540
                        </div>
541
                        <div id="history-panel">
542
                            <div id="child_orders">
543
                                <h4>Receipt history for this subscription</h4>
544
                                <table id="child_orders_table">
545
                                    <thead>
546
                                        <tr>
547
                                            <th>Invoice</th>
548
                                            <th>Order number</th>
549
                                            <th>Creation date</th>
550
                                            <th>Receive date</th>
551
                                            <th>Quantity received</th>
552
                                            <th>Status</th>
553
                                            <th title="Actual cost tax exc. / Actual cost tax inc.">Spent</th>
554
                                            <th>Internal note</th>
555
                                        </tr>
556
                                    </thead>
557
                                </table>
558
                            </div>
559
                        </div>
560
                        <div id="items-panel">
561
                            <div id="acq-create-receiving">
562
                                <div id="items_list" style="display: none">
563
                                    <h4>Items list</h4>
564
                                    <div style="width:100%;overflow:auto;">
565
                                        <table>
566
                                            <thead>
567
                                                <tr>
568
                                                    <th>Actions</th>
569
                                                    <th>Barcode</th>
570
                                                    <th>Home library</th>
571
                                                    <th>Holding library</th>
572
                                                    <th>Not for loan</th>
573
                                                    <th>Restricted</th>
574
                                                    <th>Location</th>
575
                                                    <th>Call number</th>
576
                                                    <th>Copy number</th>
577
                                                    <th>Inventory number</th>
578
                                                    <th>Collection</th>
579
                                                    <th>Item type</th>
580
                                                    <th>Materials</th>
581
                                                    <th>Notes</th>
582
                                                </tr>
583
                                            </thead>
584
                                            <tbody>
585
                                            </tbody>
586
                                        </table>
587
                                    </div>
588
                                </div>
589
590
                                <div id="itemfieldset">
591
                                    <h4>Item</h4>
592
                                    [% IF ( NoACQframework ) %]
593
                                        <p class="required">
594
                                            No ACQ framework, using default. You should create a
595
                                            framework with code ACQ, the items framework would be
596
                                            used
597
                                        </p>
598
                                    [% END %]
599
                                    <div id="outeritemblock"></div>
600
                                </div>
601
                            </div>
602
                            <div id="acq-create-ordering">
603
                                <h4>Items</h4>
604
                                <div style="width:100%;overflow:auto">
605
                                    <table>
606
                                        <thead>
607
                                            <tr>
608
                                                <th>Receive?</th>
609
                                                <th>&nbsp;</th>
610
                                                <th>Barcode</th>
611
                                                <th>Home library</th>
612
                                                <th>Current library</th>
613
                                                <th>Not for loan</th>
614
                                                <th>Restricted</th>
615
                                                <th>Location</th>
616
                                                <th>Call number</th>
617
                                                <th>Copy number</th>
618
                                                <th>Inventory number</th>
619
                                                <th>Collection</th>
620
                                                <th>Item type</th>
621
                                                <th>Materials</th>
622
                                                <th>Notes</th>
623
                                            </tr>
624
                                        </thead>
625
                                        <tbody>
626
                                        </tbody>
627
                                    </table>
628
                                </div>
629
                            </div>
630
                        </div>
631
                        <div id="accounting-panel">
632
                            <h4>Accounting details</h4>
633
                            <ol>
634
                                <li>
635
                                    <label for="datereceived">Date received: </label>
636
                                    <input type="text" size="10" id="datereceived" name="datereceived" class="datepicker" />
637
                                </li>
638
                                <li>
639
                                    <label for="bookfund">Fund: </label>
640
                                    <select id="bookfund" name="bookfund">
641
                                        <option value=""></option>
642
                                        [% FOREACH period IN budget_loop %]
643
                                        <optgroup label="[% period.description | html %]">
644
                                        [% FOREACH fund IN period.funds %]
645
                                            <option value="[% fund.b_id | html %]">[% fund.b_txt | html %]</option>
646
                                        [% END %]
647
                                        </optgroup>
648
                                        [% END %]
649
                                    </select>
650
                                </li>
651
                                <li>
652
                                    <label>&nbsp;</label>
653
                                    <span id="current-fund"></span>
654
                                </li>
655
                                <li>
656
                                    <label for="creator">Ordered by: </label>
657
                                    <span id="creator"></span>
658
                                </li>
659
                                <li>
660
                                    <label for="quantity_to_receive">Quantity ordered: </label>
661
                                    <input type="text" readonly="readonly" id="quantity_to_receive" name="quantity" />
662
                                </li>
663
                                <li>
664
                                    <label for="quantity">Quantity received: </label>
665
                                    <input type="text" size="20" name="quantityrec" id="quantity" />
666
                                    <div id="qtyrecerror" style="display:none">
667
                                        <p class="error">Warning, you have entered more items than expected.
668
                                        Items will not be created.</p>
669
                                    </div>
670
                                </li>
671
672
                                [% IF ( gst_values ) %]
673
                                <li>
674
                                    <label for="tax_rate">Tax rate: </label>
675
                                    <select name="tax_rate" id="tax_rate">
676
                                    [% FOREACH gst IN gst_values %]
677
                                        <option value="[% gst.option | html %]">[% gst.option * 100 | html %]%</option>
678
                                    [% END %]
679
                                    </select>
680
                                </li>
681
                                [% END %]
682
683
                                <li>
684
                                    <label for="rrp">Retail price: </label>
685
                                    <span id="rrp"></span>
686
                                <li>
687
                                    <label for="replacementprice">Replacement price:</label>
688
                                    <input type="text" size="20" name="replacementprice" id="replacementprice" />
689
                                </li>
690
                                <li>
691
                                    <label for="ecost">Budgeted cost: </label>
692
                                    <span id="ecost"></span>
693
                                </li>
694
                                <li>
695
                                    <label for="unitprice">Actual cost:</label>
696
                                    <input type="text" size="20" name="unitprice" id="unitprice" />
697
                                    <span id="unitprice_hint" class="hint"></span>
698
                                    <label style="font-weight: inherit; float:none;"><input type="checkbox" name="change_currency">Change currency</label>
699
                                </li>
700
                                <li id="select_currency">
701
                                    <label for="unitprice_currency"></label>
702
                                    <input type="text" size="20" name="unitprice_currency" id="unitprice_currency" value="" />
703
                                    [% IF currencies.count %]
704
                                    <select name="currency">
705
                                        <option value="[% active_currency.rate | html %]" selected="selected">[% active_currency.currency | html %] ([% active_currency.symbol | html %])</option>
706
                                        [% FOR currency IN currencies %]
707
                                        <option value="[% currency.rate | html %]">[% currency.currency | html %] ([% currency.symbol | html %])</option>
708
                                        [% END %]
709
                                    </select>
710
                                    [% END %]
711
                                </li>
712
                                <li>
713
                                    <label for="order_internalnote">Internal note: </label>
714
                                    <textarea name="order_internalnote" id="order_internalnote" width="40" rows="8" ></textarea>
715
                                </li>
716
                                <li>
717
                                    <label for="order_vendornote">Vendor note: </label>
718
                                    <span id="order_vendornote"></span>
719
                                </li>
720
                            </ol>
721
                        </div>
722
                    </div>
723
                </div>
724
                <div class="modal-footer">
725
                    <button type="button" class="btn btn-defualt modal-prev">Previous</button>
726
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
727
                    <button type="button" class="btn btn-primary modal-save">Save changes</button>
728
                    <button type="button" class="btn btn-defualt modal-next">Next</button>
729
                </div>
730
            </div>
731
        </div>
732
    </div>
462
[% ELSE %]
733
[% ELSE %]
463
    This ordernumber does not exist.
734
    This ordernumber does not exist.
464
[% END %]
735
[% END %]
Lines 474-484 Link Here
474
</div> <!-- /.row -->
745
</div> <!-- /.row -->
475
[% MACRO jsinclude BLOCK %]
746
[% MACRO jsinclude BLOCK %]
476
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
747
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
477
[% INCLUDE 'calendar.inc' %]
748
    [% INCLUDE 'calendar.inc' %]
478
    [% Asset.js("js/additem.js") | $raw %]
749
    [% Asset.js("js/additem.js") | $raw %]
479
    [% Asset.js("js/cataloging.js") | $raw %]
750
    [% Asset.js("js/cataloging.js") | $raw %]
480
    [% INCLUDE 'select2.inc' %]
751
    [% INCLUDE 'select2.inc' %]
752
    [% INCLUDE 'datatables.inc' %]
753
    [% INCLUDE 'js-date-format.inc' %]
754
    [% INCLUDE 'format_price.inc' %]
755
    [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
756
    <style>
757
        .lbl {
758
            font-weight: 700;
759
            text-align: right;
760
        }
761
        .modal-body ol {
762
            list-style-type: none;
763
        }
764
765
        .modal-body ol li {
766
            list-style-type: none;
767
            padding-bottom: 1em;
768
            width: 100%;
769
        }
770
771
        .modal-body h4 {
772
            margin-left: 1em;
773
            padding: .2em .5em;
774
            margin-bottom: 17px;
775
        }
776
777
        .modal-body label {
778
            margin-right: 1em;
779
            text-align: right;
780
            width: 11em;
781
            display: inline-block;
782
            font-weight: 700;
783
        }
784
785
        .modal-body textarea {
786
            vertical-align: text-top;
787
        }
788
    </style>
481
    <script>
789
    <script>
790
        [% IF order %]
482
        function Check(form) {
791
        function Check(form) {
483
            [% IF (AcqCreateItem == 'receiving') %]
792
            [% IF (AcqCreateItem == 'receiving') %]
484
                var total_errors = CheckMandatorySubfields(form);
793
                var total_errors = CheckMandatorySubfields(form);
Lines 651-656 Link Here
651
            });
960
            });
652
961
653
        });
962
        });
963
        [% ELSIF multiple_orders %]
964
965
        var _build_item = function(item, tr) {
966
            var chb = $('<input type="checkbox" name="items_to_receive" value="'+item.item_id+'" />')
967
                .prop('checked', item._checked)
968
                .change(function() {
969
                    item._checked = $(this).prop('checked');
970
                });
971
            tr.append($('<td style="text-align:center"></td>').append(chb));
972
            tr.append('<td><a style="cursor:pointer" onclick="PopupEditPage('+item.biblio_id+', '+item.item_id+');">'+EDIT[0].toUpperCase()+EDIT.substr(1).toLowerCase()+'</a></td>');
973
            tr.append('<td>'+(item.external_id||'')+'</td>');
974
            tr.append('<td>'+(item.home_branch && item.home_branch.name||'')+'</td>');
975
            tr.append('<td>'+(item.holding_branch && item.holding_branch.name||'')+'</td>');
976
            tr.append('<td>'+(item._authorised_values.not_for_loan_status && item._authorised_values.not_for_loan_status.lib||'')+'</td>');
977
            tr.append('<td>'+(item._authorised_values.restricted_status && item._authorised_values.restricted_status.lib||'')+'</td>');
978
            tr.append('<td><span class="shelvingloc">'+(item._authorised_values.location && item._authorised_values.location.lib||'')+'</span></td>');
979
            tr.append('<td>'+(item.callnumber||'')+'</td>');
980
            tr.append('<td>'+(item.copy_number||'')+'</td>');
981
            tr.append('<td>'+(item.inventory_number||'')+'</td>');
982
            tr.append('<td>'+(item._authorised_values.collection_code && item._authorised_values.collection_code.lib||'')+'</td>');
983
            tr.append('<td>'+(item.itemtype && item.itemtype.description || '')+'</td>');
984
            tr.append('<td>'+(item._authorised_values.materials_notes && item._authorised_values.materials_notes.lib||'')+'</td>')
985
            tr.append('<td>'+(item.public_notes||'')+'</td>');
986
        };
987
988
        var items_columns = [null, null, 'external_id', 'home_library_id',
989
                'holding_library_id', 'not_for_loan_status', 'restricted_status', 'location',
990
                'callnumber', 'copy_number', 'inventory_number', 'collection_code',
991
                'item_type', 'materials_notes', 'public_notes'];
992
993
        function PopupEditPage(biblionumber, itemnumber) {
994
            var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber="
995
                + biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem";
996
            var w = window.open(url);
997
            var watchClose = setInterval(function() {
998
                if (w.closed) {
999
                    clearTimeout(watchClose);
1000
                    $.ajax({
1001
                        dataType: "json",
1002
                        headers: {
1003
                            "x-koha-embed": "home_branch,holding_branch,itemtype",
1004
                            "x-koha-av": "1"
1005
                        },
1006
                        url: '/api/v1/items/'+itemnumber,
1007
                        success: function(item) {
1008
                            var tr = $("#item_"+itemnumber);
1009
                            tr.html('');
1010
                            _build_item(item, tr);
1011
                        }
1012
                    });
1013
                }
1014
            }, 500);
1015
        }
1016
1017
        var periods={};
1018
        var funds={};
1019
        var funds_tree = [];
1020
1021
        var QTY_TOTAL = _("Receiving %0$s out of %1$s");
1022
        var EDIT = _("edit");
1023
        var MOD_TITLE = _("Edit %s");
1024
        var SUGGESTION = _("suggestion #%s");
1025
        var FUND_KEEP = _("Keep current (%0$s - %1$s)");
1026
        var FUNC_CUR = _("(Current: %0$s - %1$s)");
1027
        var ADJ_TAX_INC = _("(adjusted for %s, tax inclusive)");
1028
        var ADJ_TAX_EXC = _("(adjusted for %s, tax exclusive)");
1029
        var TAX_INC = _("(tax inclusive)");
1030
        var TAX_EXC = _("(tax exclusive)");
1031
        var SAVE_WARNING = _("Order %s: Warning, you have entered more items than expected. Items will not be created.");
1032
        var SAVE_WARNING_NO_ITEMS = _("Order %s: No quantity to receive set. No items will be created.");
1033
        var SAVE_ERROR = _("Order %s: An error occurred while saving");
1034
1035
1036
        var CAN_user_acquisition = "[% CAN_user_acquisition | html %]";
1037
        var AcqCreateItem = "[% Koha.Preference('AcqCreateItem') | html %]";
1038
        var edit_mode = "[% edit | html %]";
1039
        var invoiceincgst = "[% invoiceincgst | html %]";
1040
        var active_currency = "[% active_currency.currency | html %]";
1041
        var invoice_id = "[% invoiceid | html %]";
1042
1043
        $(document).ready(function(){
1044
            var base_query = { "order_id": {"in": [[% multiple_orders | html %]]}};
1045
            var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1";
1046
            var options = {
1047
                "ajax": {
1048
                    "url": pending_orders_url + "&q=" + encodeURI(JSON.stringify(base_query)),
1049
                    "headers": {
1050
                        'x-koha-av': '1'
1051
                    }
1052
                },
1053
                "header_filter": true,
1054
                "embed": [
1055
                    "basket",
1056
                    "biblio.suggestions.suggester",
1057
                    "fund.budget",
1058
                    "items.home_branch",
1059
                    "items.holding_branch",
1060
                    "items.itemtype",
1061
                    "creator"
1062
                ],
1063
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
1064
                "columns": [
1065
                    {
1066
                        "data": "order_id",
1067
                        "searchable": true,
1068
                        "orderable": true
1069
                    },
1070
                    {
1071
                        "data": "biblio.title",
1072
                        "searchable": true,
1073
                        "orderable": true,
1074
                        "render": function(data, type, row, meta) {
1075
                            if ( data == null ) {
1076
                                return "";
1077
                            }
1078
                            else {
1079
                                return data;
1080
                            }
1081
                        }
1082
                    },
1083
                    {
1084
                        "data": "biblio.author",
1085
                        "searchable": true,
1086
                        "orderable": true,
1087
                        "render": function(data, type, row, meta) {
1088
                            if ( data == null ) {
1089
                                return "";
1090
                            }
1091
                            else {
1092
                                return data;
1093
                            }
1094
                        }
1095
                    },
1096
                    {
1097
                        "data": "biblio.isbn",
1098
                        "searchable": true,
1099
                        "orderable": true,
1100
                        "render": function(data, type, row, meta) {
1101
                            if ( data == null ) {
1102
                                return "";
1103
                            }
1104
                            else {
1105
                                return data;
1106
                            }
1107
                        }
1108
                    },
1109
                    {
1110
                        "searchable": false,
1111
                        "orderable": false,
1112
                        "data": function(row, type, val, meta) {
1113
                            return $date(row.date_received||new Date().toISOString());
1114
                        }
1115
                    },
1116
                    {
1117
                        "data": "fund.name",
1118
                        "searchable": true,
1119
                        "orderable": false,
1120
                        "render": function(data, type, row, meta) {
1121
                            return row.fund.budget.budget_period_description+" - "+row.fund.name;
1122
                        }
1123
                    },
1124
                    {
1125
                        "searchable": false,
1126
                        "orderable": true,
1127
                        "data": "quantity_received",
1128
                        "render": function(data, type, row, meta) {
1129
                            var data = $("#order_edit").data();
1130
                            return QTY_TOTAL.format(row.subscription_id&&(!data.saved||!data.saved.hasOwnProperty(row.order_id))?row.quantity:row.quantity_received, row.quantity);
1131
                        }
1132
                    },
1133
                    {
1134
                        "searchable": false,
1135
                        "orderable": false,
1136
                        "render": function(data, type, row, meta) {
1137
                            return '<a data-toggle="modal" href="#order_edit" data-row="'+meta.row+'" class="order_edit_toggle">'+EDIT+'</a>';
1138
                        }
1139
                    }
1140
                ]
1141
            };
1142
            var orders_table = $("#multiple_orders").kohaTable(options);
1143
            var api = orders_table.api();
1144
1145
            api.on('preDraw', function() {
1146
                var saved = $("#order_edit").data('saved');
1147
                if(saved) {
1148
                    var data = api.data();
1149
                    for(var i = 0; i<data.length; i++) {
1150
                        var row = data[i];
1151
                        var srow = saved[row.order_id];
1152
                        if(srow) {
1153
                            if(row.fund_id != srow.fund_id) {
1154
                                row.fund.budget.budget_period_description = $("#bookfund option[value="+srow.fund_id+"]").parent().attr('label');
1155
                                row.fund.name = $("#bookfund option[value="+srow.fund_id+"]").html();
1156
                            }
1157
                            row.date_received = srow.date_received;
1158
                            row.quantity = srow.quantity;
1159
                            row.quantity_received = srow.quantity_received;
1160
                        }
1161
                    }
1162
                }
1163
            });
1164
1165
            var _doSave = function(params) {
1166
                $.ajax($.extend({
1167
                    method: 'POST',
1168
                    url: '/cgi-bin/koha/acqui/finishreceive.pl'
1169
                }, params));
1170
            };
1171
1172
            var _set_error = function(error) {
1173
                if($('#jobfailed').html() == '') $('#jobfailed').append('<ul/>');
1174
                $('#jobfailed').show();
1175
                $('#jobfailed ul').append('<li>'+error+'</li>');
1176
            };
1177
1178
            var _transform_row = function(row, origrec) {
1179
                var params = {};
1180
                params['biblionumber'] = row.biblio_id;
1181
                params['invoiceid'] = invoice_id;
1182
                params['ordernumber'] = row.order_id;
1183
                params['booksellerid'] = row.basket.vendor_id;
1184
1185
                if(row.biblio.suggestions.length && row.biblio.suggestions[0].reason) {
1186
                    params["suggestionid"] = row.biblio.suggestions[0].suggestion_id;
1187
                    if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) {
1188
                        params['reason'] =  row.biblio.suggestions[0].reason;
1189
                    } else {
1190
                        params['reason'] = 'other';
1191
                        params['other_reason'] = row.biblio.suggestions[0].reason;
1192
                    }
1193
                }
1194
                params['datereceived'] = row.date_received;
1195
                params['bookfund'] = row.fund_id;
1196
                params['quantity'] = row.quantity;
1197
                params['quantityrec'] = row.quantity_received;
1198
                params['origquantityrec'] = origrec;
1199
                var effective_create_items = row.basket.create_items || AcqCreateItem;
1200
                params['tax_rate'] = (effective_create_items == 'receiving')?row.tax_rate_on_receiving:row.tax_rate_on_ordering;
1201
                params['replacementprice'] = row.replacement_price;
1202
                params['unitprice'] = invoiceincgst=="1"?row.unit_price_tax_included:row.unit_price_tax_excluded;
1203
                params['order_internalnote'] = row.internal_note;
1204
                if(effective_create_items == 'receiving') {
1205
                    Object.keys(row.items).forEach(function(key) {
1206
                        var item = row.items[key];
1207
                        Object.keys(item).forEach(function(key) {
1208
                            var field = item[key];
1209
                            Object.keys(field).forEach(function(key) {
1210
                                if(!params[key]) params[key] = [];
1211
                                params[key].push(item[key]);
1212
                            });
1213
                        });
1214
                    });
1215
                } else if(effective_create_items == 'ordering') {
1216
                    params['items_to_receive'] = (row.items||[])
1217
                        .filter(function(item) {
1218
                            return item._checked
1219
                        })
1220
                        .map(function(item) {
1221
                            item.item_id;
1222
                        })
1223
                }
1224
                return params;
1225
            };
1226
1227
            $('.save').click(function() {
1228
                var data = $("#order_edit").data();
1229
                var rows = api.rows().data();
1230
                $('this').prop('disabled', true);
1231
                var redirect = true;
1232
                if(rows.length) {
1233
                    $('#jobpanel, #jobstatus').show();
1234
1235
                    var loopRows = function(i) {
1236
                        var row = rows[i];
1237
                        if(!row) {
1238
                            if(redirect) {
1239
                                location.href = "/cgi-bin/koha/acqui/parcel.pl?invoiceid="+invoice_id
1240
                            }
1241
                            return;
1242
                        }
1243
                        if(data.saved && data.saved[row.order_id]) {
1244
                            row = data.saved[row.order_id];
1245
                            var origrec = data.origrec[row.order_id];
1246
                        } else {
1247
                            var origrec = row.quantity_received;
1248
                        }
1249
                        var _set_percentage = function() {
1250
                            var percentage = Math.round(( (i+1) / rows.length) * 100);
1251
                            var bgproperty = (parseInt(percentage*2)-300)+"px 0px";
1252
                            $("#jobprogress").css("background-position",bgproperty);
1253
                            $("#jobprogresspercent").text(percentage);
1254
                        }
1255
                        if(row.quantity_received > row.quantity) {
1256
                            redirect = false;
1257
                            _set_error(SAVE_WARNING.format(row.order_id));
1258
                            row.quantity_received = row.quantity;
1259
                        }
1260
                        if(row.quantity_received == '0') {
1261
                            redirect = false;
1262
                            _set_error(SAVE_WARNING_NO_ITEMS.format(row.order_id));
1263
                        }
1264
                        _doSave({
1265
                            data: _transform_row(row, origrec),
1266
                            success: function() {
1267
                                _set_percentage();
1268
                                loopRows(i+1);
1269
                            },
1270
                            error: function() {
1271
                                _set_percentage()
1272
                                _set_error(SAVE_ERROR.format(row.order_id));
1273
                                redirect = false;
1274
                                loopRows(i+1);
1275
                            }
1276
                        });
1277
                    };
1278
                    loopRows(0)
1279
                }
1280
            });
1281
1282
            $("#order_edit").on("change", "#reason", function() {
1283
                var val = $(this).val();
1284
                var row = $("#order_edit").data('row');
1285
                if(val == 'other') {
1286
                    $("#other_reason").show();
1287
                    $(this).hide();
1288
                } else {
1289
                    row.biblio.suggestions[0].reason = val;
1290
                }
1291
            });
1292
1293
            $("#order_edit").on("change", "#select-other_reason", function() {
1294
                var val = $(this).val();
1295
                var row = $("#order_edit").data('row');
1296
                row.biblio.suggestions[0].reason = val;
1297
            });
1298
1299
            $("#order_edit").on("click", "#other_reason a", function() {
1300
                $("#other_reason").hide();
1301
                $("#reason").val(null).show();
1302
            });
1303
1304
            $("#order_edit").on("change", "#datereceived", function() {
1305
                var val = $(this).val();
1306
                var row = $("#order_edit").data('row');
1307
                row.date_received = val;
1308
            });
1309
1310
            $("#order_edit").on("change", "#bookfund", function() {
1311
                var val = $(this).val();
1312
                var row = $("#order_edit").data('row');
1313
                row.fund_id = val;
1314
            });
1315
1316
            $("#order_edit").on("change", "#quantity_to_receive", function() {
1317
                var val = $(this).val();
1318
                var row = $("#order_edit").data('row');
1319
                row.quantity = val;
1320
                if(row.subscription_id) {
1321
                    $("#quantity").val(val).change();
1322
                }
1323
            });
1324
1325
            $("#order_edit").on("change", "#quantity", function() {
1326
                var val = $(this).val();
1327
                var row = $("#order_edit").data('row');
1328
                row.quantity_received = val;
1329
                var qtyto = parseInt($("#quantity_to_receive").val());
1330
                if(parseInt(val) > qtyto) {
1331
                    $("#qtyrecerror").show();
1332
                } else {
1333
                    $("#qtyrecerror").hide();
1334
                }
1335
                $("input[name='items_to_receive']").each(function() {
1336
                    $(this).prop('checked', false).change();
1337
                });
1338
                $("input[name='items_to_receive']:lt("+val+")").each(function () {
1339
                    $(this).prop('checked', true).change();
1340
                });
1341
            });
1342
1343
            $("#order_edit").on("change", "input[name='items_to_receive']", function() {
1344
                var qty = $("input[name='items_to_receive']:checked").length;
1345
                $("#quantity").val(qty);
1346
                var row = $("#order_edit").data('row');
1347
                row.quantity_received = qty;
1348
            })
1349
1350
            $("#order_edit").on("change", "#tax_rate", function() {
1351
                var val = $(this).val();
1352
                if(val === null) $(this).val($('option:first-child', this).attr('value'));
1353
                val = $(this).val();
1354
                var row = $("#order_edit").data('row');
1355
                var effective_create_items = row.basket.create_items || AcqCreateItem;
1356
                if(effective_create_items == 'receiving') {
1357
                    row.tax_rate_on_receiving = val;
1358
                } else {
1359
                    row.tax_rate_on_ordering = val;
1360
                }
1361
1362
            });
1363
1364
            $("#order_edit").on("change", "#unitprice", function() {
1365
                var val = $(this).val();
1366
                var row = $("#order_edit").data('row');
1367
                if(invoiceincgst == "1") {
1368
                    row.unit_price_tax_included = val;
1369
                } else {
1370
                    row.unit_price_tax_excluded = val;
1371
                }
1372
1373
            });
1374
1375
            $("#order_edit").on("change", "input[name='change_currency']", function(){
1376
                if ( $(this).is(":checked") ) {
1377
                    $("#select_currency").show();
1378
                    $("#unitprice").prop("readonly", "true");
1379
                } else {
1380
                    $("#select_currency").hide();
1381
                    $("#unitprice").prop("readonly", "");
1382
                }
1383
            });
1384
1385
            function _update_unitprice() {
1386
                var rate = Number($("select[name='currency'] option:selected").val());
1387
                var unitprice = $("#unitprice_currency").val();
1388
                var new_unitprice = Number( unitprice * rate ).toFixed(2);
1389
                $("#unitprice").val(new_unitprice).change();
1390
            }
1391
            $("#order_edit").on("change", "select[name='currency']", _update_unitprice );
1392
            $("#order_edit").on("change", "#unitprice_currency", _update_unitprice );
1393
1394
            $("#order_edit").on("change", "#replacementprice", function() {
1395
                var val = $(this).val();
1396
                var row = $("#order_edit").data('row');
1397
                row.replacement_price = val;
1398
            });
1399
1400
            $("#order_edit").on("change", "#order_internalnote", function() {
1401
                var val = $(this).val();
1402
                var row = $("#order_edit").data('row');
1403
                row.internal_note = val;
1404
1405
            });
1406
1407
            var keep_row = function() {
1408
                var row = $("#order_edit").data('row');
1409
                var kept = $("#order_edit").data('kept')||{};
1410
                if($('#items_list tbody tr').length) {
1411
                    row.items = [];
1412
                    $('#items_list tbody tr').each(function() {
1413
                        var item = {};
1414
                        $('#'+$(this).attr('idblock')).find('*[name=kohafield]').each(function() {
1415
                            var kf = $(this).val();
1416
                            var obj = {};
1417
                            $(this).parent().find('*[name]').each(function() {
1418
                                obj[$(this).prop('name')] = $(this).val();
1419
                            });
1420
                            item[kf] = obj;
1421
                        });
1422
                        row.items.push(item);
1423
                    });
1424
                }
1425
                kept[row.order_id] = row;
1426
                $("#order_edit").data('kept', kept);
1427
            };
1428
1429
            var save_row = function() {
1430
                keep_row();
1431
                var saved = $("#order_edit").data('saved')||{};
1432
                var kept = $("#order_edit").data('kept');
1433
                $("#order_edit").data('saved', $.extend(saved, kept));
1434
                api.draw();
1435
            }
1436
1437
            var set_modal_buttons = function() {
1438
                var n = $("#order_edit").data('n');
1439
                var info = api.page.info();
1440
1441
                $('.modal-prev').prop('disabled', info.page == 0 && n == 0);
1442
                $('.modal-next').prop('disabled', info.pages - 1 == info.page && info.end - info.start - 1 == n);
1443
            };
1444
1445
            var show_subs = function(row) {
1446
                //$("#child_orders").show();
1447
                var had_rows = false;
1448
                var base_query = { "subscription_id": row.subscription_id, "parent_order_id": row.order_id, "order_id": {"!=": row.order_id}};
1449
                var pending_orders_url = "/api/v1/acquisitions/orders";
1450
                var options = {
1451
                    "ajax": {
1452
                        "url": pending_orders_url + "?q=" + encodeURI(JSON.stringify(base_query))
1453
                    },
1454
                    "header_filter": true,
1455
                    "embed": [
1456
                        "invoice",
1457
                        "basket"
1458
                    ],
1459
                    "order": [[1, 'asc']],
1460
                    'dom': 'C<"top pager"ilpfB>tr<"bottom pager"ip>',
1461
                    "columns": [
1462
                        {
1463
                            "searchable": false,
1464
                            "orderable": false,
1465
                            "data": function(row, type, val, meta) {
1466
                                if(row.invoice) {
1467
                                    if(CAN_user_acquisition) {
1468
                                        return '<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid='+row.invoice_id+'" title="Invoice detail page">'+row.invoice.invoice_number+"</a>";
1469
                                    }
1470
                                    return row.invoice.invoice_number;
1471
                                }
1472
                            }
1473
                        },
1474
                        {
1475
                            "data": "order_id",
1476
                            "searchable": false,
1477
                            "orderable": false
1478
                        },
1479
                        {
1480
                            "searchable": false,
1481
                            "orderable": false,
1482
                            "data": "basket.creation_date",
1483
                            "render": function(data, type, row, meta) {
1484
                                return $date(row.basket.creation_date);
1485
                            }
1486
                        },
1487
                        {
1488
                            "searchable": false,
1489
                            "orderable": false,
1490
                            "data": function(row, type, val, meta) {
1491
                                return $date(row.date_received);
1492
                            }
1493
                        },
1494
                        {
1495
                            "searchable": false,
1496
                            "orderable": false,
1497
                            "data": function(row, type, val, meta) {
1498
                                return row.quantity_received;
1499
                            }
1500
                        },
1501
                        {
1502
                            "searchable": false,
1503
                            "orderable": true,
1504
                            "data": function(row, type, val, meta) {
1505
                                if(!row.status) return;
1506
                                var first_letter = row.status[0].toUpperCase();
1507
                                return first_letter+row.status.substr(1).toLowerCase();
1508
                            }
1509
                        },
1510
                        {
1511
                            "searchable": false,
1512
                            "orderable": false,
1513
                            "data": function(row, type, val, meta) {
1514
                                if(!row.date_received) return;
1515
                                return Number(row.unit_price_tax_excluded * row.quantity_received).format_price()+' / '+Number(row.unit_price_tax_included * row.quantity_received).format_price()
1516
                            }
1517
                        },
1518
                        {
1519
                            "searchable": false,
1520
                            "orderable": false,
1521
                            "data": function(row, type, val, meta) {
1522
                                return row.internal_note;
1523
                            }
1524
                        }
1525
                    ]
1526
                };
1527
                var child_orders_table = $("#child_orders_table").api(options);
1528
                var child_api = child_orders_table.api();
1529
                child_api.on('preDraw', function() {
1530
                    if(!child_api.data().length && !had_rows) return;
1531
                    $("#child_orders").show();
1532
                    had_rows = true;
1533
                });
1534
            };
1535
1536
            var set_editor = function() {
1537
                var modal = $("#order_edit");
1538
                var row = modal.data('row');
1539
                var origrec = $("#order_edit").data('origrec')||{};
1540
                if(!origrec.hasOwnProperty(row.order_id)) {
1541
                    origrec[row.order_id] = row.quantity_received;
1542
                    $("#order_edit").data('origrec', origrec);
1543
                }
1544
                if(row.subscription_id) {
1545
                    row.quantity_received = row.quantity;
1546
                }
1547
                var keep = $("#order_edit").data('kept');
1548
                if(keep && keep[row.order_id]) {
1549
                    row = keep[row.order_id];
1550
                    modal.data('row', row);
1551
                }
1552
                $('input, select, textarea', '.modal-body').val(null)
1553
                modal.find(".modal-title").text(MOD_TITLE.format(row.biblio.title));
1554
                ["title", "author", "copyright_date", "isbn", "series_title"].forEach(function(key){
1555
                    var o = modal.find(".modal-body #biblio_"+key);
1556
                    if(row.biblio[key] !== null) {
1557
                        o.parent().show();
1558
                        o.html(row.biblio[key]);
1559
                    } else {
1560
                        o.parent().hide();
1561
                    }
1562
                });
1563
                if(row.biblio.suggestions.length) {
1564
                    $("#suggestion_fieldset").show();
1565
                    if(row.biblio.suggestions[0].suggester) {
1566
                        $("#biblio_suggestion_suggester").parent().show();
1567
                        $("#biblio_suggestion_suggester")
1568
                            .html(
1569
                                [row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname]
1570
                                    .filter(function(name){
1571
                                        return name
1572
                                    })
1573
                                    .join(', ')+' (<a href="http://localhost:8081/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='+row.biblio.suggestions[0].suggestionid+'&op=show">'+SUGGESTION.format(row.biblio.suggestions[0].suggestionid)+'</a>)'
1574
                            );
1575
                    } else {
1576
                        $("#biblio_suggestion_suggester").parent().hide();
1577
                    }
1578
                    if(row.biblio.suggestions[0].reason) {
1579
                        $("#suggestion_reason").show();
1580
                        if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) {
1581
                             $("#other_reason a").click();
1582
                            $("#reason").val(row.biblio.suggestions[0].reason);
1583
                            $("#select-other_reason").val(null);
1584
                        } else {
1585
                            $("#reason").val("other").change();
1586
                            $("#select-other_reason").val(row.biblio.suggestions[0].reason);
1587
                        }
1588
1589
                    } else {
1590
                        $("#suggestion_reason").hide();
1591
                    }
1592
                } else {
1593
                    $("#suggestion_fieldset").hide();
1594
                }
1595
1596
                var effective_create_items = row.basket.create_items || AcqCreateItem;
1597
                $("#datereceived").val(row.date_received||$date(new Date().toISOString())).change();
1598
                $("#bookfund option[value='']").html(FUND_KEEP.format(row.fund.budget.budget_period_description, row.fund.name));
1599
                if(row.fund_id != row.fund.fund_id) {
1600
                    $("#bookfund").val(row.fund_id);
1601
                }
1602
                $("#current-fund").html(FUNC_CUR.format(row.fund.budget.budget_period_description, row.fund.name));
1603
                $("#creator").html([row.creator.surname, row.creator.firstname].filter(function(name){return name}).join(', ')+" ("+row.creator.patron_id+')')
1604
                $("#quantity_to_receive").val(row.quantity).prop('readonly', !row.subscription_id);
1605
                $("#quantity").val(row.quantity_received).prop('readonly', !row.subscription_id && effective_create_items == 'receiving');
1606
                $('#qtyrecerror').hide();
1607
                var tax_rate = row.tax_rate_on_receiving || row.tax_rate_on_ordering;
1608
                $("#tax_rate").val(tax_rate).change();
1609
                var rrp_txt;
1610
                var ecost_txt;
1611
                if(invoiceincgst == "1") {
1612
                    rrp_txt = Number(row.rrp_tax_included).format_price()+'<span class="hint">'+ADJ_TAX_INC.format(active_currency)+"</span>";
1613
                    ecost_txt = Number(row.ecost_tax_included).format_price()+'<span class="hint">'+TAX_INC+"</span>";
1614
                    $("#unitprice").val(row.unit_price_tax_included);
1615
                    $("#unitprice_hint").html(TAX_INC);
1616
                } else {
1617
                    rrp_txt = Number(row.rrp_tax_excluded).format_price()+'<span class="hint">'+ADJ_TAX_EXC.format(active_currency)+"</span>";
1618
                    ecost_txt = Number(row.ecost_tax_excluded).format_price()+'<span class="hint">'+TAX_EXC+"</span>";
1619
                    $("#unitprice").val(row.unit_price_tax_excluded);
1620
                    $("#unitprice_hint").html(TAX_EXC);
1621
                }
1622
                $("#rrp").html(rrp_txt);
1623
                $("#replacementprice").val(row.replacement_price);
1624
                $("#ecost").html(ecost_txt);
1625
                $("#order_internalnote").val(row.internal_note);
1626
                if(row.vendor_note) {
1627
                    $("#order_vendornote").html(row.vendor_note);
1628
                    $("#order_vendornote").parent().show();
1629
                } else {
1630
                    $("#order_vendornote").parent().hide();
1631
                }
1632
1633
1634
                $("#child_orders").hide();
1635
1636
                $('#items_list tbody tr, #outeritemblock > *, #acq-create-ordering tbody tr').remove();
1637
                $('#items_list').hide();
1638
                if(row.subscription_id) {
1639
                    $('#modal-order-main').tabs("disable", "#items-panel");
1640
                    $('#modal-order-main').tabs("enable", "#history-panel");
1641
                    if($('#modal-order-main').tabs( "option", "active" ) == 3) {
1642
                        $('#modal-order-main').tabs( "option", "active", 0);
1643
                    }
1644
                } else {
1645
                    $('#modal-order-main').tabs("enable", "#items-panel");
1646
                    $('#modal-order-main').tabs("disable", "#history-panel");
1647
                    if($('#modal-order-main').tabs( "option", "active" ) == 2) {
1648
                        $('#modal-order-main').tabs( "option", "active", 0);
1649
                    }
1650
                    if(effective_create_items == 'receiving') {
1651
                        $("#acq-create-receiving").show();
1652
                        $("#acq-create-ordering").hide();
1653
                        if(row.items && row.items.length) {
1654
                            row.items.forEach(function(item, index) {
1655
                                cloneItemBlock(index, '[% UniqueItemFields | html %]', function(block_id) {
1656
                                    var block = $('#'+block_id).hide();
1657
                                    Object.keys(item).forEach(function(key) {
1658
                                        block
1659
                                            .find('*[name=kohafield][value="'+key+'"]')
1660
                                            .parent()
1661
                                            .find('*[name=field_value]')
1662
                                            .val(item[key].field_value);
1663
                                    });
1664
                                    addItemInList(block_id, '[% UniqueItemFields | html %]');
1665
                                    block.find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) );
1666
                                    block.find("input[name='buttonPlusMulti']").remove();
1667
                                    block.find("input[name='multiValue']").remove();
1668
                                });
1669
                            });
1670
                        }
1671
                        cloneItemBlock((row.items && row.items.length) || 0, '[% UniqueItemFields | html %]');
1672
                    } else if (effective_create_items == 'ordering') {
1673
                        $("#acq-create-receiving").hide();
1674
                        $("#acq-create-ordering").show();
1675
                        if(row.items.length) {
1676
                            $("#acq-create-ordering tbody").append(
1677
                                row.items.map(function(item) {
1678
                                    var tr = $('<tr id="item_'+item.item_id+'"/>');
1679
                                    _build_item(item, tr);
1680
                                    return tr;
1681
                                })
1682
                            );
1683
                        }
1684
                    } else {
1685
                        if($('#modal-order-main').tabs( "option", "active" ) == 3) {
1686
                            $('#modal-order-main').tabs( "option", "active", 0);
1687
                        }
1688
                        $('#modal-order-main').tabs("disable", "#items-panel");
1689
                    }
1690
                }
1691
                $("#select_currency").hide();
1692
                $("#unitprice").prop("readonly", "");
1693
                $("input[name='change_currency']").prop('checked', false);
1694
                set_modal_buttons();
1695
            };
1696
1697
            $('.modal-prev').click(function() {
1698
                var modal = $("#order_edit");
1699
                keep_row();
1700
                var n = modal.data('n');
1701
                if(n > 0) {
1702
                    n--;
1703
                    modal.data('row', JSON.parse(JSON.stringify(api.row(n).data())));
1704
                    modal.data('n', n);
1705
                    set_editor();
1706
                } else {
1707
                    $('.modal-next, .modal-prev').prop('disabled', true);
1708
                    orders_table.one('draw.dt', function() {
1709
                        var info = api.page.info();
1710
                        n = info.end - info.start - 1;
1711
                        modal.data('row', JSON.parse(JSON.stringify(api.row(n).data())));
1712
                        modal.data('n', n);
1713
                        set_editor();
1714
                    });
1715
                    api.page('previous').draw( 'page' );
1716
                }
1717
            });
1718
1719
            $('.modal-next').click(function() {
1720
                var modal = $("#order_edit");
1721
                keep_row();
1722
                var n = modal.data('n');
1723
                var info = api.page.info();
1724
                if(n < info.end - info.start - 1) {
1725
                    n++;
1726
                    modal.data('row', JSON.parse(JSON.stringify(api.row(n).data())));
1727
                    modal.data('n', n);
1728
                    set_editor();
1729
                } else {
1730
                    $('.modal-next, .modal-prev').prop('disabled', true);
1731
                    orders_table.one('draw.dt', function() {
1732
                        var info = api.page.info();
1733
                        n = 0;
1734
                        modal.data('row', JSON.parse(JSON.stringify(api.row(n).data())));
1735
                        modal.data('n', n);
1736
                        set_editor();
1737
                    });
1738
                    api.page('next').draw( 'page' );
1739
                }
1740
            });
1741
1742
            $('.modal-save').click(function() {
1743
                save_row();
1744
                $("#order_edit").modal('hide');
1745
            })
1746
1747
            $('#modal-order-main').tabs({
1748
                activate: function(event, ui) {
1749
                    var active = ui.newPanel.attr('id')
1750
                    if(active == 'history-panel') {
1751
                        show_subs($("#order_edit").data('row'));
1752
                    }
1753
                }
1754
            });
1755
1756
            $("#order_edit").on("show.bs.modal", function (event) {
1757
                var anchor = $(event.relatedTarget);
1758
                var n = anchor.data("row");
1759
                var row = api.row(n).data();
1760
1761
                var modal = $(this);
1762
                modal.data('row', JSON.parse(JSON.stringify(row)));
1763
                modal.data('n', n);
1764
                modal.data('keep', modal.data('saved')||{});
1765
                $('#modal-order-main').tabs("option", "active", 0);
1766
                set_editor();
1767
            });
1768
/*            $("#order_edit").on("shown.bs.modal", function() {
1769
                var modal = $(this);
1770
1771
                if(modal.data('show_subs')) show_subs(modal.data('row'));
1772
            });*/
1773
            $("#order_edit").on("hide.bs.modal", function() {
1774
                $("#child_orders_table").DataTable().off('preDraw').destroy();
1775
            });
1776
        });
1777
        [% END %]
654
    </script>
1778
    </script>
655
[% END %]
1779
[% END %]
656
1780
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-3 / +65 lines)
Lines 119-124 Link Here
119
        <table id="pending_orders" class="table table-bordered table-striped">
119
        <table id="pending_orders" class="table table-bordered table-striped">
120
            <thead>
120
            <thead>
121
                <tr>
121
                <tr>
122
                    [% IF Koha.Preference('AcqReceiveMultipleOrderLines') %]
123
                    <th><!--input type="checkbox" id="selectAll"/--></th>
124
                    [% END %]
122
                    <th>Basket</th>
125
                    <th>Basket</th>
123
                    <th>Basket group</th>
126
                    <th>Basket group</th>
124
                    <th>Order line</th>
127
                    <th>Order line</th>
Lines 134-139 Link Here
134
                </tr>
137
                </tr>
135
            </thead>
138
            </thead>
136
        </table>
139
        </table>
140
      [% IF Koha.Preference('AcqReceiveMultipleOrderLines') %]
141
      <fieldset class="action">
142
        <button id="select_multiple"></button>
143
      </fieldset>
144
      [% END %]
137
    </div>
145
    </div>
138
[% ELSE %]
146
[% ELSE %]
139
    <p>
147
    <p>
Lines 346-353 Link Here
346
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
354
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
347
    [% INCLUDE 'datatables.inc' %]
355
    [% INCLUDE 'datatables.inc' %]
348
    [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
356
    [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
357
    <style>fieldset.action { margin-bottom: 20px }</style>
349
    <script>
358
    <script>
350
        dt_overwrite_html_sorting_localeCompare();
359
        dt_overwrite_html_sorting_localeCompare();
360
        var PENDING_MULTI_SELECTION = _("Receive selected (%s)");
351
        var columns_filter = {};
361
        var columns_filter = {};
352
362
353
        $(document).ready(function(){
363
        $(document).ready(function(){
Lines 379-385 Link Here
379
                }));
389
                }));
380
            }
390
            }
381
391
382
            var pending_orders_table = $("#pending_orders").kohaTable({
392
            var options = {
383
                "ajax": {
393
                "ajax": {
384
                    "url": '/api/v1/acquisitions/orders?only_active=1'
394
                    "url": '/api/v1/acquisitions/orders?only_active=1'
385
                },
395
                },
Lines 406-412 Link Here
406
                },
416
                },
407
                "columns": [
417
                "columns": [
408
                    { "data": "basket.name",
418
                    { "data": "basket.name",
409
                    "searchable": true,
419
                      "searchable": true,
410
                      "orderable": true,
420
                      "orderable": true,
411
                      "render": function(data, type, row, meta) {
421
                      "render": function(data, type, row, meta) {
412
                        if (type != 'display') return escape_str(data);
422
                        if (type != 'display') return escape_str(data);
Lines 643-649 Link Here
643
                        "searchable": false
653
                        "searchable": false
644
                    }
654
                    }
645
                ]
655
                ]
646
            }, null, 1, {"basket.vendor_id": [% booksellerid | html %]});
656
            };
657
658
            [% IF Koha.Preference('AcqReceiveMultipleOrderLines') %]
659
            var selected_rows = {};
660
            $('#select_multiple').click(function() {
661
              var ids = Object.keys(selected_rows);
662
              if(!ids.length) return;
663
              if(ids.length == 1) {
664
                location.href = 'orderreceive.pl?ordernumber='+ids[0]+ '&invoiceid=[% invoiceid | uri %]';
665
              } else {
666
                location.href = 'orderreceive.pl?multiple_orders='+ids.join(',')+ '&invoiceid=[% invoiceid | uri %]';
667
              }
668
            }).html(PENDING_MULTI_SELECTION.format('0'))
669
            options.select = {
670
              style: 'api'
671
            };
672
            options.order = [[1, 'asc']];
673
            options.columns.unshift({
674
              "data": function(row, type, val, meta) {
675
                  return '<input type="checkbox" class="selOrder" />';
676
              },
677
              "searchable": false,
678
              "orderable": false
679
            });
680
            [% END %]
681
682
            var pending_orders_table = $("#pending_orders").kohaTable(options, {}, 1, {"basket.vendor_id": [% booksellerid | html %]});
683
684
            [% IF Koha.Preference('AcqReceiveMultipleOrderLines') %]
685
            var api = pending_orders_table.api();
686
            api.on('draw', function() {
687
              api.rows().every(function() {
688
                var row = this;
689
                var data = row.data();
690
                $('.selOrder', row.node()).on('click', function(event) {
691
                  if($(this).prop('checked')) {
692
                    row.select();
693
                    selected_rows[data.order_id] = data;
694
                  } else {
695
                    row.deselect();
696
                    delete selected_rows[data.order_id];
697
                  }
698
                  $('#select_multiple').html(PENDING_MULTI_SELECTION.format(Object.keys(selected_rows).length));
699
                });
700
                if(selected_rows[data.order_id]) {
701
                  row.select();
702
                  $('.selOrder', row.node()).prop('checked', true);
703
                }
704
              });
705
            });
706
707
            [% END %]
708
647
709
648
            $(".previewData").on("click", function(e){
710
            $(".previewData").on("click", function(e){
649
                e.preventDefault();
711
                e.preventDefault();
(-)a/t/db_dependent/Koha/Acquisition/Order.t (+1 lines)
Lines 20-25 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 13;
22
use Test::More tests => 13;
23
use Test::Exception;
23
24
24
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
25
use t::lib::Mocks;
26
use t::lib::Mocks;
(-)a/t/db_dependent/Koha/Item.t (-34 / +5 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
use utf8;
21
use utf8;
22
22
23
use Test::More tests => 29;
23
use Test::More tests => 28;
24
use Test::Exception;
24
use Test::Exception;
25
use Test::MockModule;
25
use Test::MockModule;
26
26
Lines 33-39 use Koha::Database; Link Here
33
use Koha::DateUtils qw( dt_from_string );
33
use Koha::DateUtils qw( dt_from_string );
34
use Koha::Old::Items;
34
use Koha::Old::Items;
35
use Koha::Recalls;
35
use Koha::Recalls;
36
use Koha::AuthorisedValueCategories;
37
use Koha::AuthorisedValues;
36
use Koha::AuthorisedValues;
38
37
39
use List::MoreUtils qw(all);
38
use List::MoreUtils qw(all);
Lines 1431-1436 subtest 'columns_to_str' => sub { Link Here
1431
        }
1430
        }
1432
    );
1431
    );
1433
1432
1433
    Koha::Caches->get_instance->flush_all;
1434
1434
    $item = $item->get_from_storage;
1435
    $item = $item->get_from_storage;
1435
1436
1436
    my $s = $item->columns_to_str;
1437
    my $s = $item->columns_to_str;
Lines 1576-1581 subtest 'strings_map() tests' => sub { Link Here
1576
        }
1577
        }
1577
    )->store();
1578
    )->store();
1578
1579
1580
    Koha::Caches->get_instance->flush_all;
1581
1579
    $item->set(
1582
    $item->set(
1580
        {
1583
        {
1581
            cn_source => $class_source->id,
1584
            cn_source => $class_source->id,
Lines 2126-2159 subtest 'is_denied_renewal' => sub { Link Here
2126
2129
2127
    $schema->storage->txn_rollback;
2130
    $schema->storage->txn_rollback;
2128
};
2131
};
2129
2130
subtest '_fetch_authorised_values' => sub {
2131
    plan tests => 1;
2132
2133
    $schema->storage->txn_begin;
2134
2135
    # Delete all Authorised Values of 'Countries' category
2136
    Koha::AuthorisedValues->search({category => 'Countries'})->delete;
2137
    Koha::AuthorisedValueCategories->search({category_name => 'Countries'})->delete;
2138
2139
    # Create 'Countries' category and authorised value
2140
    my $cat = $builder->build_object({ class => 'Koha::AuthorisedValueCategories'});
2141
    my $country = $builder->build_object({ class => 'Koha::AuthorisedValues', value => { category => $cat->category_name } });
2142
2143
    # Create a new biblio framework
2144
    my $fw = $builder->build_object({ class => 'Koha::BiblioFrameworks' });
2145
2146
    # Add a Marc subfield with kohafield setted to 'items.itemnote'
2147
    $builder->build_object({class => 'Koha::MarcSubfieldStructures', value => {frameworkcode => $fw->frameworkcode, authorised_value => $cat->category_name, kohafield => 'items.itemnotes'}});
2148
2149
    # Create biblio and item
2150
    my $biblio = $builder->build_sample_biblio({frameworkcode => $fw->frameworkcode});
2151
    my $item = $builder->build_sample_item({biblionumber => $biblio->biblionumber, itemnotes => $country->authorised_value});
2152
2153
    # Fetch authorised values
2154
    my $avs = $item->_fetch_authorised_values();
2155
2156
    is($avs->{itemnotes}->{lib}, $country->lib, 'Fetched auhtorised value is ok');
2157
2158
    $schema->storage->txn_rollback;
2159
};
2160
- 

Return to bug 8179