Display current selected category when editing lists.
[koha_ffzg] / acqui / parcel.pl
index 3a161eb..5ee97b0 100755 (executable)
@@ -17,9 +17,9 @@
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 =head1 NAME
 
@@ -52,6 +52,8 @@ To filter the results list on this given date.
 
 =cut
 
+use strict;
+#use warnings; FIXME - Bug 2505
 use C4::Auth;
 use C4::Acquisition;
 use C4::Budgets;
@@ -61,8 +63,7 @@ use C4::Items;
 use CGI;
 use C4::Output;
 use C4::Dates qw/format_date format_date_in_iso/;
-
-use strict;
+use JSON;
 
 my $input=new CGI;
 my $supplierid=$input->param('supplierid');
@@ -83,6 +84,48 @@ my $resultsperpage = $input->param('resultsperpage');
 $resultsperpage = 20 unless ($resultsperpage);
 $startfrom=0 unless ($startfrom);
 
+if($input->param('format') eq "json"){
+    my ($template, $loggedinuser, $cookie)
+        = get_template_and_user({template_name => "acqui/ajax.tmpl",
+                 query => $input,
+                                type => "intranet",
+                 authnotrequired => 0,
+                 flagsrequired => {acquisition => 'order_receive'},
+                 debug => 1,
+    });
+       
+    my @datas;
+    my $search   = $input->param('search') || '';
+    my $supplier = $input->param('supplierid') || '';
+    my $basketno = $input->param('basketno') || '';
+    my $orderno  = $input->param('orderno') || '';
+
+    my $orders = SearchOrder($orderno, $search, $supplier, $basketno);
+    foreach my $order (@$orders){
+        if($order->{quantityreceived} < $order->{quantity}){
+            my $data = {};
+            
+            $data->{basketno} = $order->{basketno};
+            $data->{ordernumber} = $order->{ordernumber};
+            $data->{title} = $order->{title};
+            $data->{author} = $order->{author};
+            $data->{isbn} = $order->{isbn};
+            $data->{booksellerid} = $order->{booksellerid};
+            $data->{biblionumber} = $order->{biblionumber};
+            $data->{freight} = $order->{freight};
+            $data->{quantity} = $order->{quantity};
+            $data->{ecost} = $order->{ecost};
+            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
+            push @datas, $data;
+        }
+    }
+    
+    my $json_text = to_json(\@datas);
+    $template->param(return => $json_text);
+    output_html_with_http_headers $input, $cookie, $template->output;
+    exit;
+}
+
 my ($template, $loggedinuser, $cookie)
     = get_template_and_user({template_name => "acqui/parcel.tmpl",
                  query => $input,
@@ -192,7 +235,6 @@ for (my $i = 0 ; $i < $countpendings ; $i++) {
     my %line;
     %line = %{$pendingorders->[$i]};
     $line{quantity}+=0;
-    $line{quantrem} = $line{quantity} - $line{quantityreceived};
     $line{quantityreceived}+=0;
     $line{unitprice}+=0;
     $totalPunitprice += $line{unitprice};