Moving "Check Out" from the action toolbar to the view menu
[koha.git] / circ / circulation.pl
index c68427c..e307fdd 100755 (executable)
@@ -26,7 +26,7 @@ use strict;
 use CGI;
 use C4::Output;
 use C4::Print;
-use C4::Auth;
+use C4::Auth qw/:DEFAULT get_session/;
 use C4::Date;
 use C4::Branch; # GetBranches
 use C4::Koha;   # GetPrinter
@@ -59,7 +59,7 @@ if ($branch){
     # update our session so the userenv is updated
     my $dbh=C4::Context->dbh;
     my $sessionID = $query->cookie("CGISESSID") ;
-    my $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh});
+    my $session = get_session($sessionID);
     $session->param('branch',$branch);
     my $branchname = GetBranchName($branch);
     $session->param('branchname',$branchname);
@@ -70,7 +70,7 @@ if ($printer){
     # update our session so the userenv is updated
        my $dbh=C4::Context->dbh;
        my $sessionID = $query->cookie("CGISESSID") ;
-       my $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh});
+       my $session = get_session($sessionID);
        $session->param('branchprinter',$printer);
 
 }
@@ -115,6 +115,7 @@ my $year           = $query->param('year');
 my $month          = $query->param('month');
 my $day            = $query->param('day');
 my $stickyduedate  = $query->param('stickyduedate');
+my $duedatespec    = $query->param('duedatespec');
 my $issueconfirmed = $query->param('issueconfirmed');
 my $cancelreserve  = $query->param('cancelreserve');
 my $organisation   = $query->param('organisations');
@@ -129,6 +130,16 @@ my $print          = $query->param('print');
 # }
 #
 
+my ($datedue,$invalidduedate);
+if($duedatespec) {
+       $datedue=  C4::Dates->new($duedatespec );
+       $invalidduedate=1 unless $datedue;
+}
+#if (defined($year)) {
+#        $duedatespec = "$year-$month-$day";
+#} else {
+#        ($year, $month, $day) = ($duedatespec) ? split /-/, $duedatespec : (0,0,0);
+#}
 
 my @datearr = localtime( time() );
 
@@ -185,7 +196,7 @@ if ($findborrower) {
 # get the borrower information.....
 my $borrower;
 my @lines;
-
+warn $borrowernumber;
 if ($borrowernumber) {
     $borrower = GetMemberDetails( $borrowernumber, 0 );
     my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
@@ -234,16 +245,15 @@ if ($borrowernumber) {
 #
 
 if ($barcode) {
-    $barcode = cuecatbarcodedecode($barcode);
-    my ( $datedue, $invalidduedate ) = fixdate( $year, $month, $day );
-    if ($issueconfirmed) {
+   # $barcode = cuecatbarcodedecode($barcode);
+    
+       if ($issueconfirmed) {
         AddIssue( $borrower, $barcode, $datedue, $cancelreserve );
         $inprocess = 1;
     }
     else {
         my ( $error, $question ) =
-          CanBookBeIssued( $borrower, $barcode, $year, $month, $day,
-            $inprocess );
+          CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess );
         my $noerror    = 1;
         my $noquestion = 1;
 #         Get the item title for more information
@@ -610,6 +620,10 @@ if ( C4::Context->preference("memberofinstitution") ) {
 
 $amountold = $temp[1];
 
+my $borrowercategory = GetBorrowercategory( $borrower->{'categorycode'} );
+my $category_type = $borrowercategory->{'category_type'};
+( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' );
+
 $template->param(
     issued_itemtypes_count_loop => $issued_itemtypes_loop,
     findborrower                => $findborrower,
@@ -641,17 +655,14 @@ $template->param(
     inprocess         => $inprocess,
     memberofinstution => $member_of_institution,
     CGIorganisations  => $CGIorganisations,
+       circview => 1,
+       
 );
 
 # set return date if stickyduedate
 if ($stickyduedate) {
-    my $t_year  = "year" . $year;
-    my $t_month = "month" . $month;
-    my $t_day   = "day" . $day;
     $template->param(
-        $t_year  => 1,
-        $t_month => 1,
-        $t_day   => 1,
+        duedatespec => $duedatespec,
     );
 }
 
@@ -660,7 +671,8 @@ if ($stickyduedate) {
 #}
 
 $template->param(
-    SpecifyDueDate     => C4::Context->preference("SpecifyDueDate")
+               SpecifyDueDate     => C4::Context->preference("SpecifyDueDate"),
+               CircAutocompl => C4::Context->preference("CircAutocompl") ,
+               DHTMLformat   => C4::Dates->DHTMLcalendar(),
 );
-$template->param( CircAutocompl => C4::Context->preference("CircAutocompl") );
 output_html_with_http_headers $query, $cookie, $template->output;