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

(-)a/C4/Acquisition.pm (-15 / +29 lines)
Lines 748-788 Results are ordered from most to least recent. Link Here
748
=cut
748
=cut
749
749
750
sub GetPendingOrders {
750
sub GetPendingOrders {
751
    my ($supplierid,$grouped,$owner,$basketno) = @_;
751
    my ($supplierid,$ordernumber,$search,$ean,$basketno,$grouped,$owner) = @_;
752
    my $dbh = C4::Context->dbh;
752
    my $dbh = C4::Context->dbh;
753
    my $strsth = "
753
    my $strsth = "
754
        SELECT    ".($grouped?"count(*),":"")."aqbasket.basketno,
754
        SELECT ".($grouped?"count(*),":"")."aqbasket.basketno,
755
                    surname,firstname,biblio.*,biblioitems.isbn,
755
               surname,firstname,biblio.*,biblioitems.isbn,
756
                    aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname,
756
               aqbasket.closedate, aqbasket.creationdate, aqbasket.basketname,
757
                    aqorders.*
757
               aqorders.*
758
        FROM      aqorders
758
        FROM aqorders
759
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
759
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
760
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
760
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
761
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
761
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
762
        LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber
762
        LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber
763
        WHERE booksellerid=?
763
        WHERE (quantity > quantityreceived OR quantityreceived is NULL)
764
            AND (quantity > quantityreceived OR quantityreceived is NULL)
764
        AND datecancellationprinted IS NULL";
765
            AND datecancellationprinted IS NULL";
765
    my @query_params;
766
    my @query_params = ( $supplierid );
767
    my $userenv = C4::Context->userenv;
766
    my $userenv = C4::Context->userenv;
768
    if ( C4::Context->preference("IndependantBranches") ) {
767
    if ( C4::Context->preference("IndependantBranches") ) {
769
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
768
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
770
            $strsth .= " and (borrowers.branchcode = ?
769
            $strsth .= " AND (borrowers.branchcode = ?
771
                        or borrowers.branchcode  = '')";
770
                        or borrowers.branchcode  = '')";
772
            push @query_params, $userenv->{branch};
771
            push @query_params, $userenv->{branch};
773
        }
772
        }
774
    }
773
    }
775
    if ($owner) {
774
    if ($supplierid) {
776
        $strsth .= " AND aqbasket.authorisedby=? ";
775
        $strsth .= " AND aqbasket.booksellerid = ?";
777
        push @query_params, $userenv->{'number'};
776
        push @query_params, $supplierid;
777
    }
778
    if($ordernumber){
779
        $strsth .= " AND (aqorders.ordernumber=?)";
780
        push @query_params, $ordernumber;
781
    }
782
    if($search){
783
        $strsth .= " AND (biblio.title like ? OR biblio.author LIKE ? OR biblioitems.isbn like ?)";
784
        push @query_params, ("%$search%","%$search%","%$search%");
785
    }
786
    if ($ean) {
787
        $strsth .= " AND biblioitems.ean = ?";
788
        push @query_params, $ean;
778
    }
789
    }
779
    if ($basketno) {
790
    if ($basketno) {
780
        $strsth .= " AND aqbasket.basketno=? ";
791
        $strsth .= " AND aqbasket.basketno=? ";
781
        push @query_params, $basketno;
792
        push @query_params, $basketno;
782
    }
793
    }
794
    if ($owner) {
795
        $strsth .= " AND aqbasket.authorisedby=? ";
796
        push @query_params, $userenv->{'number'};
797
    }
783
    $strsth .= " group by aqbasket.basketno" if $grouped;
798
    $strsth .= " group by aqbasket.basketno" if $grouped;
784
    $strsth .= " order by aqbasket.basketno";
799
    $strsth .= " order by aqbasket.basketno";
785
786
    my $sth = $dbh->prepare($strsth);
800
    my $sth = $dbh->prepare($strsth);
787
    $sth->execute( @query_params );
801
    $sth->execute( @query_params );
788
    my $results = $sth->fetchall_arrayref({});
802
    my $results = $sth->fetchall_arrayref({});
(-)a/acqui/parcel.pl (-49 / +14 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
    $pendingorders = GetPendingOrders($booksellerid,$orderno,$search,$ean,$basketno);
163
}else{
164
    $pendingorders = GetPendingOrders($booksellerid);
165
}
200
my $countpendings = scalar @$pendingorders;
166
my $countpendings = scalar @$pendingorders;
201
167
202
# pending orders totals
168
# pending orders totals
Lines 252-258 for (my $i = 0 ; $i < $countpendings ; $i++) { Link Here
252
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
218
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
253
    $line{subscriptions}        = scalar @subscriptions;
219
    $line{subscriptions}        = scalar @subscriptions;
254
    $line{left_holds}           = 1 if $holds >= 1;
220
    $line{left_holds}           = 1 if $holds >= 1;
255
    $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
221
    $line{left_holds_on_order}  = 1 if $line{left_holds} == 1 && ($line{items} == 0 || $itemholds );
256
    $line{holds}                = $holds;
222
    $line{holds}                = $holds;
257
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
223
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
258
    
224
    
Lines 260-266 for (my $i = 0 ; $i < $countpendings ; $i++) { Link Here
260
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
226
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
261
}
227
}
262
$freight = $totalfreight unless $freight;
228
$freight = $totalfreight unless $freight;
263
264
my $count = $countpendings;
229
my $count = $countpendings;
265
230
266
if ($count>$resultsperpage){
231
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