Bug 8037: (follow-up) improve GetBudgetByOrderNumber test
[koha.git] / serials / serials-recieve.pl
index 6df5b94..c14e4d0 100755 (executable)
@@ -13,9 +13,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
@@ -28,7 +28,7 @@ serials-recieve.pl
 
 =item op
 op can be :
-    * modsubscriptionhistory :to modify the subscription history 
+    * modsubscriptionhistory :to modify the subscription history
     * serialchangestatus     :to modify the status of this subscription
 
 =item subscriptionid
@@ -63,6 +63,7 @@ op can be :
 
 
 use strict;
+use warnings;
 use CGI;
 use C4::Auth;
 use C4::Dates qw/format_date format_date_in_iso/;
@@ -125,7 +126,7 @@ if ($op eq 'serialchangestatus') {
     my $sth = $dbh->prepare("select status from serial where serialid=?");
     for (my $i=0;$i<=$#serialids;$i++) {
         $sth->execute($serialids[$i]);
-        
+
         my ($oldstatus) = $sth->fetchrow;
         if ($serialids[$i]) {
             ModSerialStatus($serialids[$i],$serialseqs[$i],format_date_in_iso($planneddates[$i]),format_date_in_iso($publisheddates[$i]),$status[$i],$notes[$i]) unless ($hassubscriptionexpired && $oldstatus == 1);
@@ -140,11 +141,11 @@ if ($op eq 'serialchangestatus') {
                 my ($status2, @errors)= ItemizeSerials($serialids[$i],\%info);
                 my $sth2 = $dbh->prepare("UPDATE subscriptionhistory SET lastbranch = ? WHERE subscriptionid = ?");
                 $sth2->execute($homebranches[$i],$subscriptionid);
-                $sth2->finish;                     
+                $sth2->finish;
                 # remove from missing list if item being checked in is on it
                 if ($status2 ==1){
                 removeMissingIssue($serialseqs[$i],$subscriptionid);
-                }                          
+                }
             }
         } else {
             # add a special issue
@@ -185,16 +186,13 @@ my $subs = &GetSubscription($subscriptionid);
 my ($totalissues,@serialslist) = GetSerials($subscriptionid);
 my $count = @serialslist;
 for(my $i=0;$i<$count;$i++){
-    warn "la : $i";
+    #warn "la : $i";
     $serialslist[$i]->{'callnumber'} = $subscription->{'callnumber'};
     my $temp = rand(10000000);
     $serialslist[$i]->{'barcode'} = "TEMP" . sprintf("%.0f",$temp);
 }
 
-my $sth= C4::Serials::GetSubscriptionHistoryFromSubscriptionId();
-
-$sth->execute($subscriptionid);
-my $solhistory = $sth->fetchrow_hashref;
+my $solhistory = GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
 
 $subs = &GetSubscription($subscriptionid);
 ($totalissues,@serialslist) = GetSerials($subscriptionid);
@@ -217,7 +215,7 @@ if (C4::Context->preference("serialsadditems")){
     }
     my $itemstatushash = GetItemStatus($fwk);
     my @itemstatusloop;
-       my $itemstatusloopcount=0;    
+       my $itemstatusloopcount=0;
     foreach my $thisitemstatus (keys %$itemstatushash) {
         my %row =(itemval => $thisitemstatus,
                     itemlib => $itemstatushash->{$thisitemstatus},
@@ -242,7 +240,7 @@ if (C4::Context->preference("serialsadditems")){
                $data->{"branchloop"} = \@branchloop ;
        }
 # warn "Choice: $choice";
-    $template->param(choice => $choice);    
+    $template->param(choice => $choice);
     $template->param(serialadditems =>C4::Context->preference("serialsadditems"),
                     branchloop => \@branchloop,
                     ) ;
@@ -252,9 +250,7 @@ if (C4::Context->preference("serialsadditems")){
     $template->param(branchloop=>[],itemstatusloop=>[],itemlocationloop=>[]) ;
 }
 
-$sth= C4::Serials::GetSubscriptionHistoryFromSubscriptionId();
-$sth->execute($subscriptionid);
-$solhistory = $sth->fetchrow_hashref;
+$solhistory = GetSubscriptionHistoryFromSubscriptionId($subscriptionid);
 
 $template->param(
             user => $auser,
@@ -271,11 +267,12 @@ $template->param(
             bibliotitle => $subs->{bibliotitle},
             biblionumber => $subs->{biblionumber},
             hassubscriptionexpired =>$hassubscriptionexpired,
-            abouttoexpire =>$abouttoexpire,    
+            abouttoexpire =>$abouttoexpire,
             routing => $routing,
             missingseq => $manualissue,
             frommissing => $manualstatus,
             missingdate => $manualdate,
             missingid => $manualid,
+            (uc(C4::Context->preference("marcflavour"))) => 1
         );
 output_html_with_http_headers $query, $cookie, $template->output;