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

(-)a/C4/Acquisition.pm (-28 / +36 lines)
Lines 794-822 sub GetBasketgroups { Link Here
794
794
795
=head3 GetPendingOrders
795
=head3 GetPendingOrders
796
796
797
  $orders = &GetPendingOrders($booksellerid, $grouped, $owner);
797
$orders = &GetPendingOrders($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean);
798
798
799
Finds pending orders from the bookseller with the given ID. Ignores
799
Finds pending orders from the bookseller with the given ID. Ignores
800
completed and cancelled orders.
800
completed and cancelled orders.
801
801
802
C<$booksellerid> contains the bookseller identifier
802
C<$booksellerid> contains the bookseller identifier
803
C<$grouped> contains 0 or 1. 0 means returns the list, 1 means return the total
804
C<$owner> contains 0 or 1. 0 means any owner. 1 means only the list of orders entered by the user itself.
803
C<$owner> contains 0 or 1. 0 means any owner. 1 means only the list of orders entered by the user itself.
805
806
C<$orders> is a reference-to-array; each element is a
807
reference-to-hash with the following fields:
808
C<$grouped> is a boolean that, if set to 1 will group all order lines of the same basket
804
C<$grouped> is a boolean that, if set to 1 will group all order lines of the same basket
809
in a single result line
805
in a single result line
806
C<$orders> is a reference-to-array; each element is a reference-to-hash.
810
807
811
=over
808
Used also by the filter in parcel.pl
812
809
I have added:
813
=item C<authorizedby>
814
810
815
=item C<entrydate>
811
C<$ordernumber>
816
812
C<$search>
817
=item C<basketno>
813
C<$ean>
818
819
=back
820
814
821
These give the value of the corresponding field in the aqorders table
815
These give the value of the corresponding field in the aqorders table
822
of the Koha database.
816
of the Koha database.
Lines 826-866 Results are ordered from most to least recent. Link Here
826
=cut
820
=cut
827
821
828
sub GetPendingOrders {
822
sub GetPendingOrders {
829
    my ($supplierid,$grouped,$owner,$basketno) = @_;
823
    my ($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean) = @_;
830
    my $dbh = C4::Context->dbh;
824
    my $dbh = C4::Context->dbh;
831
    my $strsth = "
825
    my $strsth = "
832
        SELECT    ".($grouped?"count(*),":"")."aqbasket.basketno,
826
        SELECT ".($grouped?"count(*),":"")."aqbasket.basketno,
833
                    surname,firstname,biblio.*,biblioitems.isbn,
827
               surname,firstname,biblio.*,biblioitems.isbn,
834
                    aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname,
828
               aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname,
835
                    aqorders.*
829
               aqorders.*
836
        FROM      aqorders
830
        FROM aqorders
837
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
831
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
838
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
832
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
839
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
833
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
840
        LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber
834
        LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber
841
        WHERE booksellerid=?
835
        WHERE (quantity > quantityreceived OR quantityreceived is NULL)
842
            AND (quantity > quantityreceived OR quantityreceived is NULL)
836
        AND datecancellationprinted IS NULL";
843
            AND datecancellationprinted IS NULL";
837
    my @query_params;
844
    my @query_params = ( $supplierid );
845
    my $userenv = C4::Context->userenv;
838
    my $userenv = C4::Context->userenv;
846
    if ( C4::Context->preference("IndependantBranches") ) {
839
    if ( C4::Context->preference("IndependantBranches") ) {
847
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
840
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
848
            $strsth .= " and (borrowers.branchcode = ?
841
            $strsth .= " AND (borrowers.branchcode = ?
849
                        or borrowers.branchcode  = '')";
842
                        or borrowers.branchcode  = '')";
850
            push @query_params, $userenv->{branch};
843
            push @query_params, $userenv->{branch};
851
        }
844
        }
852
    }
845
    }
853
    if ($owner) {
846
    if ($supplierid) {
854
        $strsth .= " AND aqbasket.authorisedby=? ";
847
        $strsth .= " AND aqbasket.booksellerid = ?";
855
        push @query_params, $userenv->{'number'};
848
        push @query_params, $supplierid;
849
    }
850
    if($ordernumber){
851
        $strsth .= " AND (aqorders.ordernumber=?)";
852
        push @query_params, $ordernumber;
853
    }
854
    if($search){
855
        $strsth .= " AND (biblio.title like ? OR biblio.author LIKE ? OR biblioitems.isbn like ?)";
856
        push @query_params, ("%$search%","%$search%","%$search%");
857
    }
858
    if ($ean) {
859
        $strsth .= " AND biblioitems.ean = ?";
860
        push @query_params, $ean;
856
    }
861
    }
857
    if ($basketno) {
862
    if ($basketno) {
858
        $strsth .= " AND aqbasket.basketno=? ";
863
        $strsth .= " AND aqbasket.basketno=? ";
859
        push @query_params, $basketno;
864
        push @query_params, $basketno;
860
    }
865
    }
866
    if ($owner) {
867
        $strsth .= " AND aqbasket.authorisedby=? ";
868
        push @query_params, $userenv->{'number'};
869
    }
861
    $strsth .= " group by aqbasket.basketno" if $grouped;
870
    $strsth .= " group by aqbasket.basketno" if $grouped;
862
    $strsth .= " order by aqbasket.basketno";
871
    $strsth .= " order by aqbasket.basketno";
863
864
    my $sth = $dbh->prepare($strsth);
872
    my $sth = $dbh->prepare($strsth);
865
    $sth->execute( @query_params );
873
    $sth->execute( @query_params );
866
    my $results = $sth->fetchall_arrayref({});
874
    my $results = $sth->fetchall_arrayref({});
(-)a/acqui/parcel.pl (-49 / +16 lines)
Lines 78-138 my $invoice=$input->param('invoice') || ''; Link Here
78
my $freight=$input->param('freight');
78
my $freight=$input->param('freight');
79
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
79
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
80
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
80
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
81
my $datereceived =  ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived')) 
81
my $datereceived =  ($input->param('op') eq ('new' or "search")) ? C4::Dates->new($input->param('datereceived'))
82
					:  C4::Dates->new($input->param('datereceived'), 'iso')   ;
82
					:  C4::Dates->new($input->param('datereceived'), 'iso');
83
$datereceived = C4::Dates->new() unless $datereceived;
83
$datereceived = C4::Dates->new() unless $datereceived;
84
my $code            = $input->param('code');
84
my $code            = $input->param('code');
85
my @rcv_err         = $input->param('error');
85
my @rcv_err         = $input->param('error');
86
my @rcv_err_barcode = $input->param('error_bc');
86
my @rcv_err_barcode = $input->param('error_bc');
87
88
my $startfrom=$input->param('startfrom');
87
my $startfrom=$input->param('startfrom');
89
my $resultsperpage = $input->param('resultsperpage');
88
my $resultsperpage = $input->param('resultsperpage');
90
$resultsperpage = 20 unless ($resultsperpage);
89
$resultsperpage = 20 unless ($resultsperpage);
91
$startfrom=0 unless ($startfrom);
90
$startfrom=0 unless ($startfrom);
92
91
93
if($input->param('format') eq "json"){
94
    my ($template, $loggedinuser, $cookie)
95
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
96
                 query => $input,
97
				 type => "intranet",
98
                 authnotrequired => 0,
99
                 flagsrequired => {acquisition => 'order_receive'},
100
                 debug => 1,
101
    });
102
       
103
    my @datas;
104
    my $search   = $input->param('search')     || '';
105
    my $ean      = $input->param('ean')        || '';
106
    my $supplier = $input->param('booksellerid') || '';
107
    my $basketno = $input->param('basketno') || '';
108
    my $orderno  = $input->param('orderno') || '';
109
110
    my $orders = SearchOrder($orderno, $search, $ean, $supplier, $basketno);
111
    foreach my $order (@$orders) {
112
        if ( $order->{quantityreceived} < $order->{quantity} ) {
113
            my $data = {};
114
            
115
            $data->{basketno} = $order->{basketno};
116
            $data->{ordernumber} = $order->{ordernumber};
117
            $data->{title} = $order->{title};
118
            $data->{author} = $order->{author};
119
            $data->{isbn} = $order->{isbn};
120
            $data->{booksellerid} = $order->{booksellerid};
121
            $data->{biblionumber} = $order->{biblionumber};
122
            $data->{freight} = $order->{freight};
123
            $data->{quantity} = $order->{quantity};
124
            $data->{ecost} = $order->{ecost};
125
            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
126
            push @datas, $data;
127
        }
128
    }
129
    
130
    my $json_text = to_json(\@datas);
131
    $template->param(return => $json_text);
132
    output_html_with_http_headers $input, $cookie, $template->output;
133
    exit;
134
}
135
136
my ($template, $loggedinuser, $cookie)
92
my ($template, $loggedinuser, $cookie)
137
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
93
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
138
                 query => $input,
94
                 query => $input,
Lines 196-202 for (my $i = 0 ; $i < $countlines ; $i++) { Link Here
196
    $tototal       += $total;
152
    $tototal       += $total;
197
}
153
}
198
154
199
my $pendingorders = GetPendingOrders($booksellerid);
155
# We get the pending orders either all or filtered
156
my $pendingorders;
157
if($input->param('op') eq "search"){
158
    my $search   = $input->param('summaryfilter') || '';
159
    my $ean      = $input->param('eanfilter') || '';
160
    my $basketno = $input->param('basketfilter') || '';
161
    my $orderno  = $input->param('orderfilter') || '';
162
    my $grouped;
163
    my $owner;
164
    $pendingorders = GetPendingOrders($booksellerid,$grouped,$owner,$basketno,$orderno,$search,$ean);
165
}else{
166
    $pendingorders = GetPendingOrders($booksellerid);
167
}
200
my $countpendings = scalar @$pendingorders;
168
my $countpendings = scalar @$pendingorders;
201
169
202
# pending orders totals
170
# pending orders totals
Lines 252-258 for (my $i = 0 ; $i < $countpendings ; $i++) { Link Here
252
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
220
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
253
    $line{subscriptions}        = scalar @subscriptions;
221
    $line{subscriptions}        = scalar @subscriptions;
254
    $line{left_holds}           = 1 if $holds >= 1;
222
    $line{left_holds}           = 1 if $holds >= 1;
255
    $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
223
    $line{left_holds_on_order}  = 1 if $line{left_holds} == 1 && ($line{items} == 0 || $itemholds );
256
    $line{holds}                = $holds;
224
    $line{holds}                = $holds;
257
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
225
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
258
    
226
    
Lines 260-266 for (my $i = 0 ; $i < $countpendings ; $i++) { Link Here
260
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
228
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
261
}
229
}
262
$freight = $totalfreight unless $freight;
230
$freight = $totalfreight unless $freight;
263
264
my $count = $countpendings;
231
my $count = $countpendings;
265
232
266
if ($count>$resultsperpage){
233
if ($count>$resultsperpage){
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-74 / +13 lines)
Lines 96-163 Link Here
96
	$("#receivedt").before("<p id=\"receivedcollapserow\">" + _("All ") + rowCountReceived + _(" items are displayed.") + "<a href=\"javascript:receivedCollapse();\">" + _("Click here to show only the first ") + rowsToCollapse + _(" items") + "<\/a>.<\/p>");
96
	$("#receivedt").before("<p id=\"receivedcollapserow\">" + _("All ") + rowCountReceived + _(" items are displayed.") + "<a href=\"javascript:receivedCollapse();\">" + _("Click here to show only the first ") + rowsToCollapse + _(" items") + "<\/a>.<\/p>");
97
    }
97
    }
98
98
99
    // Launch filtering
100
    function filter() {
101
102
    var summaryStatus = jQuery.trim($("#summaryfilter").val());
103
	var basketStatus  = $("#basketfilter").val();
104
	var orderStatus   = $("#orderfilter").val();
105
    var eanStatus     = $("#eanfilter").val() || '';
106
107
    if (summaryStatus == '' && basketStatus == '' && orderStatus == '' && eanStatus == '') { clearFilters(); return false; }
108
109
	var filtered = "table#pendingt tbody.filterclass tr";
110
111
	// We hide everything
112
	$("#nothingfoundrow").remove();
113
	$(filtered).hide();
114
115
	// Do the search
116
	var callback =  {
117
		success: function(o) {
118
			var jsonString = o.responseText;
119
			var gst = "[% gst %]";
120
			try {
121
				var orders = YAHOO.lang.JSON.parse(jsonString);
122
				var foundCount = orders.length;
123
124
				for( i = 0 ; i < orders.length ; i++){
125
					order = orders[i];
126
					$('<tr class="orderfound">'
127
                       + '<td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=' + order.basketno + '">' + order.basketno + '</a></td>'
128
                       + '<td class="orderfilterclass"> <a href="neworderempty.pl?ordernumber=' + order.ordernumber + '&booksellerid=' + order.booksellerid + '">' + order.ordernumber + ' </a></td>'
129
                       + '<td class="summaryfilterclass">'
130
                       + '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + order.biblionumber + '">' + order.title + '</a>' + _(" by ") + order.author + '&nbsp;&ndash;&nbsp;' + order.isbn + '</td>'
131
                       + '<td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + order.biblionumber + '" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=' + order.biblionumber + '" title="MARC" rel="gb_page_center[600,500]">Card</a></td>'
132
                       + '<td>' + order.quantity + '</td>'
133
                       + '<td>' + order.ecost + '</td>'
134
                       + '<td>' + order.ordertotal + '</td>'
135
                       + '<td>'
136
                       + '<a href="orderreceive.pl?ordernumber=' + order.ordernumber + '&amp;datereceived=[% invoicedatereceived %]&amp;invoice=[% invoice %]&amp;gst=' + gst + '&amp;freight=' + order.freight + '&amp;booksellerid=[% booksellerid %]">Receive</a> /'
137
                       + '<a href="parcel.pl?type=intra&amp;ordernumber=' + order.ordernumber + '&amp;biblionumber=' + order.biblionumber + '&amp;action=cancelorder&amp;booksellerid=[% booksellerid %]&amp;datereceived=[% invoicedatereceived %]&amp;invoice=[% invoice %]" onclick="return confirm(\'' + _('Are you sure you want to cancel this order?') + '\');">Cancel</a>'
138
                       + '</td></tr>').appendTo("table#pendingt");
139
				}
140
141
				// If nothing has been found, we tell the user so
142
				if (orders.length == 0) {
143
				    $("<tr><td id=\"nothingfoundrow\" colspan=\"8\">No items match your criteria.<\/tr>").appendTo("#pendingt");
144
				}
145
			}catch(e){alert(e);}
146
		}
147
	}
148
    var transaction = YAHOO.util.Connect.asyncRequest('GET', '/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% booksellerid %]&search='+summaryStatus+'&basketno='+basketStatus+'&orderno='+orderStatus+'&ean='+eanStatus+'&format=json', callback, null);
149
150
	return false;
151
    }
152
153
    // Clear already applied filters
154
    function clearFilters() {
155
	$("#nothingfoundrow").remove();
156
        $("#pendingt tbody.filterclass tr").show();
157
        //$("#pendingt tbody.filterclass tr.orderfound").remove();
158
	pendingExpand();
159
    }
160
161
//]]>
99
//]]>
162
</script>
100
</script>
163
<script type="text/javascript">
101
<script type="text/javascript">
Lines 169-184 Link Here
169
                }
107
                }
170
            }
108
            }
171
            
109
            
172
            function confirm_delete_biblio(ordernumber, biblionumber) {
110
            function confirm_delete_biblio(ordernumber, basketno, biblionumber) {
173
                var is_confirmed = confirm(_('Are you sure you want to delete this catalog record and order ?'));
111
                var is_confirmed = confirm(_('Are you sure you want to delete this catalog record and order ?'));
174
                if (is_confirmed) {
112
                if (is_confirmed) {
175
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno="+basketno+"&quantity=0&biblionumber="+biblionumber+"&delbiblio=1";
113
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno="+basketno+"&quantity=0&biblionumber="+biblionumber+"&delbiblio=1";
176
                    }
114
                    }
177
            }
115
            }
178
179
//]]>
116
//]]>
180
</script>
117
</script>
181
182
</head>
118
</head>
183
<body id="acq_parcel" class="acq">
119
<body id="acq_parcel" class="acq">
184
[% INCLUDE 'header.inc' %]
120
[% INCLUDE 'header.inc' %]
Lines 237-243 Link Here
237
            <th>Basket</th>
173
            <th>Basket</th>
238
            <th>Order line</th>
174
            <th>Order line</th>
239
            <th>Summary</th>
175
            <th>Summary</th>
240
        <th>View record</th>
176
            <th>View record</th>
241
            <th>Quantity</th>
177
            <th>Quantity</th>
242
            <th>Unit cost</th>
178
            <th>Unit cost</th>
243
            <th>Order cost</th>
179
            <th>Order cost</th>
Lines 421-427 Link Here
421
</div>
357
</div>
422
</div>
358
</div>
423
<div class="yui-b">
359
<div class="yui-b">
424
<form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" onsubmit="return filter();">
360
<form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" method="post">
425
        <fieldset class="brief">
361
        <fieldset class="brief">
426
362
427
            <h4>Filter</h4>
363
            <h4>Filter</h4>
Lines 430-457 Link Here
430
366
431
		<li>
367
		<li>
432
		    <label for="summaryfilter">ISBN, author or title :</label>
368
		    <label for="summaryfilter">ISBN, author or title :</label>
433
		    <input type="text" name="summaryfilter" id="summaryfilter" />
369
		    <input type="text" name="summaryfilter" id="summaryfilter" value="[% summaryfilter %]"/>
434
		</li>
370
		</li>
435
371
436
		<li>
372
		<li>
437
		    <label for="basketfilter">Basket :</label>
373
		    <label for="basketfilter">Basket :</label>
438
		    <input type="text" name="basketfilter" id="basketfilter" />
374
		    <input type="text" name="basketfilter" id="basketfilter" value="[% basketfilter %]"/>
439
		</li>
375
		</li>
440
376
441
		<li>
377
		<li>
442
            <label for="orderfilter">Order line :</label>
378
            <label for="orderfilter">Order line :</label>
443
		    <input type="text" name="orderfilter" id="orderfilter" />
379
		    <input type="text" name="orderfilter" id="orderfilter" value="[% orderfilter %]"/>
444
		</li>
380
		</li>
445
                [% IF (UNIMARC) %]
381
                [% IF (UNIMARC) %]
446
        <li>
382
        <li>
447
            <label for="eanfilter">EAN :</label>
383
            <label for="eanfilter">EAN :</label>
448
            <input type="text" name="eanfilter" id="eanfilter" />
384
            <input type="text" name="eanfilter" id="eanfilter" value="[% eanfilter %]"/>
449
        </li>
385
        </li>
450
                [% END %]
386
                [% END %]
451
	    </ol>
387
	    </ol>
452
		<fieldset class="action">
388
		<fieldset class="action">
453
		    <input type="submit" value="Filter" />
389
        <input type="hidden" value="search" name="op" />
454
		    <a href="#" onclick="clearFilters();">Clear</a>
390
        <input type="hidden" value="[% booksellerid %]" name="booksellerid" />
391
        <input type="hidden" value="[% invoice %]" name="invoice" />
392
        <input type="hidden" value="[% invoicedatereceived %]" name="datereceived" />
393
        <input type="submit" value="Filter" />
394
        <a href="/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% booksellerid %]&invoice=[% invoice %]&op=new&datereceived=[% formatteddatereceived %]">Clear</a>
455
		</fieldset>
395
		</fieldset>
456
396
457
397
458
- 

Return to bug 8382