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

(-)a/C4/Acquisition.pm (-28 / +36 lines)
Lines 717-745 sub GetBasketgroups { Link Here
717
717
718
=head3 GetPendingOrders
718
=head3 GetPendingOrders
719
719
720
  $orders = &GetPendingOrders($booksellerid, $grouped, $owner);
720
$orders = &GetPendingOrders($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean);
721
721
722
Finds pending orders from the bookseller with the given ID. Ignores
722
Finds pending orders from the bookseller with the given ID. Ignores
723
completed and cancelled orders.
723
completed and cancelled orders.
724
724
725
C<$booksellerid> contains the bookseller identifier
725
C<$booksellerid> contains the bookseller identifier
726
C<$grouped> contains 0 or 1. 0 means returns the list, 1 means return the total
727
C<$owner> contains 0 or 1. 0 means any owner. 1 means only the list of orders entered by the user itself.
726
C<$owner> contains 0 or 1. 0 means any owner. 1 means only the list of orders entered by the user itself.
728
729
C<$orders> is a reference-to-array; each element is a
730
reference-to-hash with the following fields:
731
C<$grouped> is a boolean that, if set to 1 will group all order lines of the same basket
727
C<$grouped> is a boolean that, if set to 1 will group all order lines of the same basket
732
in a single result line
728
in a single result line
729
C<$orders> is a reference-to-array; each element is a reference-to-hash.
733
730
734
=over
731
Used also by the filter in parcel.pl
735
732
I have added:
736
=item C<authorizedby>
737
733
738
=item C<entrydate>
734
C<$ordernumber>
739
735
C<$search>
740
=item C<basketno>
736
C<$ean>
741
742
=back
743
737
744
These give the value of the corresponding field in the aqorders table
738
These give the value of the corresponding field in the aqorders table
745
of the Koha database.
739
of the Koha database.
Lines 749-789 Results are ordered from most to least recent. Link Here
749
=cut
743
=cut
750
744
751
sub GetPendingOrders {
745
sub GetPendingOrders {
752
    my ($supplierid,$grouped,$owner,$basketno) = @_;
746
    my ($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean) = @_;
753
    my $dbh = C4::Context->dbh;
747
    my $dbh = C4::Context->dbh;
754
    my $strsth = "
748
    my $strsth = "
755
        SELECT    ".($grouped?"count(*),":"")."aqbasket.basketno,
749
        SELECT ".($grouped?"count(*),":"")."aqbasket.basketno,
756
                    surname,firstname,biblio.*,biblioitems.isbn,
750
               surname,firstname,biblio.*,biblioitems.isbn,
757
                    aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname,
751
               aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname,
758
                    aqorders.*
752
               aqorders.*
759
        FROM      aqorders
753
        FROM aqorders
760
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
754
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
761
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
755
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
762
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
756
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
763
        LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber
757
        LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber
764
        WHERE booksellerid=?
758
        WHERE (quantity > quantityreceived OR quantityreceived is NULL)
765
            AND (quantity > quantityreceived OR quantityreceived is NULL)
759
        AND datecancellationprinted IS NULL";
766
            AND datecancellationprinted IS NULL";
760
    my @query_params;
767
    my @query_params = ( $supplierid );
768
    my $userenv = C4::Context->userenv;
761
    my $userenv = C4::Context->userenv;
769
    if ( C4::Context->preference("IndependantBranches") ) {
762
    if ( C4::Context->preference("IndependantBranches") ) {
770
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
763
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
771
            $strsth .= " and (borrowers.branchcode = ?
764
            $strsth .= " AND (borrowers.branchcode = ?
772
                        or borrowers.branchcode  = '')";
765
                        or borrowers.branchcode  = '')";
773
            push @query_params, $userenv->{branch};
766
            push @query_params, $userenv->{branch};
774
        }
767
        }
775
    }
768
    }
776
    if ($owner) {
769
    if ($supplierid) {
777
        $strsth .= " AND aqbasket.authorisedby=? ";
770
        $strsth .= " AND aqbasket.booksellerid = ?";
778
        push @query_params, $userenv->{'number'};
771
        push @query_params, $supplierid;
772
    }
773
    if($ordernumber){
774
        $strsth .= " AND (aqorders.ordernumber=?)";
775
        push @query_params, $ordernumber;
776
    }
777
    if($search){
778
        $strsth .= " AND (biblio.title like ? OR biblio.author LIKE ? OR biblioitems.isbn like ?)";
779
        push @query_params, ("%$search%","%$search%","%$search%");
780
    }
781
    if ($ean) {
782
        $strsth .= " AND biblioitems.ean = ?";
783
        push @query_params, $ean;
779
    }
784
    }
780
    if ($basketno) {
785
    if ($basketno) {
781
        $strsth .= " AND aqbasket.basketno=? ";
786
        $strsth .= " AND aqbasket.basketno=? ";
782
        push @query_params, $basketno;
787
        push @query_params, $basketno;
783
    }
788
    }
789
    if ($owner) {
790
        $strsth .= " AND aqbasket.authorisedby=? ";
791
        push @query_params, $userenv->{'number'};
792
    }
784
    $strsth .= " group by aqbasket.basketno" if $grouped;
793
    $strsth .= " group by aqbasket.basketno" if $grouped;
785
    $strsth .= " order by aqbasket.basketno";
794
    $strsth .= " order by aqbasket.basketno";
786
787
    my $sth = $dbh->prepare($strsth);
795
    my $sth = $dbh->prepare($strsth);
788
    $sth->execute( @query_params );
796
    $sth->execute( @query_params );
789
    my $results = $sth->fetchall_arrayref({});
797
    my $results = $sth->fetchall_arrayref({});
(-)a/acqui/parcel.pl (-48 / +16 lines)
Lines 78-137 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 $supplier = $input->param('booksellerid') || '';
106
    my $basketno = $input->param('basketno') || '';
107
    my $orderno  = $input->param('orderno') || '';
108
109
    my $orders = SearchOrder($orderno, $search, $supplier, $basketno);
110
    foreach my $order (@$orders){
111
        if($order->{quantityreceived} < $order->{quantity}){
112
            my $data = {};
113
            
114
            $data->{basketno} = $order->{basketno};
115
            $data->{ordernumber} = $order->{ordernumber};
116
            $data->{title} = $order->{title};
117
            $data->{author} = $order->{author};
118
            $data->{isbn} = $order->{isbn};
119
            $data->{booksellerid} = $order->{booksellerid};
120
            $data->{biblionumber} = $order->{biblionumber};
121
            $data->{freight} = $order->{freight};
122
            $data->{quantity} = $order->{quantity};
123
            $data->{ecost} = $order->{ecost};
124
            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
125
            push @datas, $data;
126
        }
127
    }
128
    
129
    my $json_text = to_json(\@datas);
130
    $template->param(return => $json_text);
131
    output_html_with_http_headers $input, $cookie, $template->output;
132
    exit;
133
}
134
135
my ($template, $loggedinuser, $cookie)
92
my ($template, $loggedinuser, $cookie)
136
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
93
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
137
                 query => $input,
94
                 query => $input,
Lines 195-201 for (my $i = 0 ; $i < $countlines ; $i++) { Link Here
195
    $tototal       += $total;
152
    $tototal       += $total;
196
}
153
}
197
154
198
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
}
199
my $countpendings = scalar @$pendingorders;
168
my $countpendings = scalar @$pendingorders;
200
169
201
# pending orders totals
170
# pending orders totals
Lines 251-257 for (my $i = 0 ; $i < $countpendings ; $i++) { Link Here
251
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
220
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
252
    $line{subscriptions}        = scalar @subscriptions;
221
    $line{subscriptions}        = scalar @subscriptions;
253
    $line{left_holds}           = 1 if $holds >= 1;
222
    $line{left_holds}           = 1 if $holds >= 1;
254
    $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 );
255
    $line{holds}                = $holds;
224
    $line{holds}                = $holds;
256
    $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};
257
    
226
    
Lines 259-265 for (my $i = 0 ; $i < $countpendings ; $i++) { Link Here
259
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
228
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
260
}
229
}
261
$freight = $totalfreight unless $freight;
230
$freight = $totalfreight unless $freight;
262
263
my $count = $countpendings;
231
my $count = $countpendings;
264
232
265
if ($count>$resultsperpage){
233
if ($count>$resultsperpage){
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-72 / +18 lines)
Lines 70-136 Link Here
70
	$("#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>");
70
	$("#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>");
71
    }
71
    }
72
72
73
    // Launch filtering
74
    function filter() {
75
76
    var summaryStatus = jQuery.trim($("#summaryfilter").val());
77
	var basketStatus  = $("#basketfilter").val();
78
	var orderStatus   = $("#orderfilter").val();
79
80
	if (summaryStatus == '' && basketStatus == '' && orderStatus == '') { clearFilters(); return false; }
81
82
	var filtered = "table#pendingt tbody.filterclass tr";
83
84
	// We hide everything
85
	$("#nothingfoundrow").remove();
86
	$(filtered).hide();
87
88
	// Do the search
89
	var callback =  {
90
		success: function(o) {
91
			var jsonString = o.responseText;
92
			var gst = "[% gst %]";
93
			try {
94
				var orders = YAHOO.lang.JSON.parse(jsonString);
95
				var foundCount = orders.length;
96
97
				for( i = 0 ; i < orders.length ; i++){
98
					order = orders[i];
99
					$('<tr class="orderfound">'
100
                       + '<td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=' + order.basketno + '">' + order.basketno + '</a></td>'
101
                       + '<td class="orderfilterclass"> <a href="neworderempty.pl?ordernumber=' + order.ordernumber + '&booksellerid=' + order.booksellerid + '">' + order.ordernumber + ' </a></td>'
102
                       + '<td class="summaryfilterclass">'
103
                       + '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + order.biblionumber + '">' + order.title + '</a>' + _(" by ") + order.author + '&nbsp;&ndash;&nbsp;' + order.isbn + '</td>'
104
                       + '<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>'
105
                       + '<td>' + order.quantity + '</td>'
106
                       + '<td>' + order.ecost + '</td>'
107
                       + '<td>' + order.ordertotal + '</td>'
108
                       + '<td>'
109
                       + '<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> /'
110
                       + '<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>'
111
                       + '</td></tr>').appendTo("table#pendingt");
112
				}
113
114
				// If nothing has been found, we tell the user so
115
				if (orders.length == 0) {
116
				    $("<tr><td id=\"nothingfoundrow\" colspan=\"8\">No items match your criteria.<\/tr>").appendTo("#pendingt");
117
				}
118
			}catch(e){alert(e);}
119
		}
120
	}
121
	var transaction = YAHOO.util.Connect.asyncRequest('GET', '/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% booksellerid %]&search='+summaryStatus+'&basketno='+basketStatus+'&orderno='+orderStatus+'&format=json', callback, null);
122
123
	return false;
124
    }
125
126
    // Clear already applied filters
127
    function clearFilters() {
128
	$("#nothingfoundrow").remove();
129
        $("#pendingt tbody.filterclass tr").show();
130
        //$("#pendingt tbody.filterclass tr.orderfound").remove();
131
	pendingExpand();
132
    }
133
134
//]]>
73
//]]>
135
</script>
74
</script>
136
<script type="text/javascript">
75
<script type="text/javascript">
Lines 142-157 Link Here
142
                }
81
                }
143
            }
82
            }
144
            
83
            
145
            function confirm_delete_biblio(ordernumber, biblionumber) {
84
            function confirm_delete_biblio(ordernumber, basketno, biblionumber) {
146
                var is_confirmed = confirm(_('Are you sure you want to delete this catalog record and order ?'));
85
                var is_confirmed = confirm(_('Are you sure you want to delete this catalog record and order ?'));
147
                if (is_confirmed) {
86
                if (is_confirmed) {
148
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno="+basketno+"&quantity=0&biblionumber="+biblionumber+"&delbiblio=1";
87
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno="+basketno+"&quantity=0&biblionumber="+biblionumber+"&delbiblio=1";
149
                    }
88
                    }
150
            }
89
            }
151
152
//]]>
90
//]]>
153
</script>
91
</script>
154
155
</head>
92
</head>
156
<body id="acq_parcel" class="acq">
93
<body id="acq_parcel" class="acq">
157
[% INCLUDE 'header.inc' %]
94
[% INCLUDE 'header.inc' %]
Lines 210-216 Link Here
210
            <th>Basket</th>
147
            <th>Basket</th>
211
            <th>Order line</th>
148
            <th>Order line</th>
212
            <th>Summary</th>
149
            <th>Summary</th>
213
        <th>View record</th>
150
            <th>View record</th>
214
            <th>Quantity</th>
151
            <th>Quantity</th>
215
            <th>Unit cost</th>
152
            <th>Unit cost</th>
216
            <th>Order cost</th>
153
            <th>Order cost</th>
Lines 402-408 Link Here
402
</div>
339
</div>
403
</div>
340
</div>
404
<div class="yui-b">
341
<div class="yui-b">
405
<form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" onsubmit="return filter();">
342
<form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" method="post">
406
        <fieldset class="brief">
343
        <fieldset class="brief">
407
344
408
            <h4>Filter</h4>
345
            <h4>Filter</h4>
Lines 411-432 Link Here
411
348
412
		<li>
349
		<li>
413
		    <label for="summaryfilter">ISBN, author or title :</label>
350
		    <label for="summaryfilter">ISBN, author or title :</label>
414
		    <input type="text" name="summaryfilter" id="summaryfilter" />
351
		    <input type="text" name="summaryfilter" id="summaryfilter" value="[% summaryfilter %]"/>
415
		</li>
352
		</li>
416
353
417
		<li>
354
		<li>
418
		    <label for="basketfilter">Basket :</label>
355
		    <label for="basketfilter">Basket :</label>
419
		    <input type="text" name="basketfilter" id="basketfilter" />
356
		    <input type="text" name="basketfilter" id="basketfilter" value="[% basketfilter %]"/>
420
		</li>
357
		</li>
421
358
422
		<li>
359
		<li>
423
            <label for="orderfilter">Order line :</label>
360
            <label for="orderfilter">Order line :</label>
424
		    <input type="text" name="orderfilter" id="orderfilter" />
361
		    <input type="text" name="orderfilter" id="orderfilter" value="[% orderfilter %]"/>
425
		</li>
362
		</li>
363
                [% IF (UNIMARC) %]
364
        <li>
365
            <label for="eanfilter">EAN :</label>
366
            <input type="text" name="eanfilter" id="eanfilter" value="[% eanfilter %]"/>
367
        </li>
368
                [% END %]
426
	    </ol>
369
	    </ol>
427
		<fieldset class="action">
370
		<fieldset class="action">
428
		    <input type="submit" value="Filter" />
371
        <input type="hidden" value="search" name="op" />
429
		    <a href="#" onclick="clearFilters();">Clear</a>
372
        <input type="hidden" value="[% booksellerid %]" name="booksellerid" />
373
        <input type="hidden" value="[% invoice %]" name="invoice" />
374
        <input type="hidden" value="[% invoicedatereceived %]" name="datereceived" />
375
        <input type="submit" value="Filter" />
376
        <a href="/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% booksellerid %]&invoice=[% invoice %]&op=new&datereceived=[% formatteddatereceived %]">Clear</a>
430
		</fieldset>
377
		</fieldset>
431
378
432
379
433
- 

Return to bug 8382