| 
      
            Lines 140-183
          my ($template, $loggedinuser, $cookie)
      
      
        Link Here
      
     | 
  
        
          | 140 | 
                           debug => 1,  | 
          140 | 
                           debug => 1,  | 
        
        
          | 141 | 
          });  | 
          141 | 
          });  | 
        
        
          | 142 | 
           | 
          142 | 
           | 
        
            
              | 143 | 
              my $action = $input->param('action'); | 
               | 
               | 
            
            
              | 144 | 
              my $ordernumber = $input->param('ordernumber'); | 
            
            
              | 145 | 
              my $biblionumber = $input->param('biblionumber'); | 
            
            
              | 146 | 
               | 
            
            
              | 147 | 
              # If canceling an order  | 
            
            
              | 148 | 
              if ($action eq "cancelorder") { | 
            
            
              | 149 | 
               | 
            
            
              | 150 | 
                  my $error_delitem;  | 
            
            
              | 151 | 
                  my $error_delbiblio;  | 
            
            
              | 152 | 
               | 
            
            
              | 153 | 
                  # We delete the order  | 
            
            
              | 154 | 
                  DelOrder($biblionumber, $ordernumber);  | 
            
            
              | 155 | 
               | 
            
            
              | 156 | 
                  # We delete all the items related to this order  | 
            
            
              | 157 | 
                  my @itemnumbers = GetItemnumbersFromOrder($ordernumber);  | 
            
            
              | 158 | 
                  foreach (@itemnumbers) { | 
            
            
              | 159 | 
              	my $delcheck = DelItemCheck(C4::Context->dbh, $biblionumber, $_);  | 
            
            
              | 160 | 
              	# (should always success, as no issue should exist on item on order)  | 
            
            
              | 161 | 
              	if ($delcheck != 1) { $error_delitem = 1; } | 
            
            
              | 162 | 
                  }  | 
            
            
              | 163 | 
               | 
            
            
              | 164 | 
                  # We get the number of remaining items  | 
            
            
              | 165 | 
                  my $itemcount = GetItemsCount($biblionumber);  | 
            
            
              | 166 | 
                    | 
            
            
              | 167 | 
                  # If there are no items left,  | 
            
            
              | 168 | 
                  if ($itemcount eq 0) { | 
            
            
              | 169 | 
              	# We delete the record  | 
            
            
              | 170 | 
              	$error_delbiblio = DelBiblio($biblionumber);	  | 
            
            
              | 171 | 
                  }  | 
            
            
              | 172 | 
               | 
            
            
              | 173 | 
                  if ($error_delitem || $error_delbiblio) { | 
            
            
              | 174 | 
              	if ($error_delitem)   { $template->param(error_delitem => 1); } | 
            
            
              | 175 | 
              	if ($error_delbiblio) { $template->param(error_delbiblio => 1); } | 
            
            
              | 176 | 
                  } else { | 
            
            
              | 177 | 
              	$template->param(success_delorder => 1);  | 
            
            
              | 178 | 
                  }  | 
            
            
              | 179 | 
              }  | 
            
            
              | 180 | 
               | 
            
        
          | 181 | 
          # If receiving error, report the error (coming from finishrecieve.pl(sic)).  | 
          143 | 
          # If receiving error, report the error (coming from finishrecieve.pl(sic)).  | 
        
        
          | 182 | 
          if( scalar(@rcv_err) ) { | 
          144 | 
          if( scalar(@rcv_err) ) { | 
        
        
          | 183 | 
          	my $cnt=0;  | 
          145 | 
          	my $cnt=0;  | 
        
  
    | 
      
            Lines 237-242
          my @loop_orders = ();
      
      
        Link Here
      
     | 
  
        
          | 237 | 
          for (my $i = 0 ; $i < $countpendings ; $i++) { | 
          199 | 
          for (my $i = 0 ; $i < $countpendings ; $i++) { | 
        
        
          | 238 | 
              my %line;  | 
          200 | 
              my %line;  | 
        
        
          | 239 | 
              %line = %{$pendingorders->[$i]}; | 
          201 | 
              %line = %{$pendingorders->[$i]}; | 
        
            
               | 
               | 
              202 | 
                   | 
            
        
          | 240 | 
              $line{quantity}+=0; | 
          203 | 
              $line{quantity}+=0; | 
        
        
          | 241 | 
              $line{quantityreceived}+=0; | 
          204 | 
              $line{quantityreceived}+=0; | 
        
        
          | 242 | 
              $line{unitprice}+=0; | 
          205 | 
              $line{unitprice}+=0; | 
        
  
    | 
      
            Lines 252-257
          for (my $i = 0 ; $i < $countpendings ; $i++) {
      
      
        Link Here
      
     | 
  
        
          | 252 | 
              $line{total} = $total; | 
          215 | 
              $line{total} = $total; | 
        
        
          | 253 | 
              $line{supplierid} = $supplierid; | 
          216 | 
              $line{supplierid} = $supplierid; | 
        
        
          | 254 | 
              $ordergrandtotal += $line{ecost} * $line{quantity}; | 
          217 | 
              $ordergrandtotal += $line{ecost} * $line{quantity}; | 
        
            
               | 
               | 
              218 | 
                    | 
            
            
              | 219 | 
                  my $biblionumber = $line{'biblionumber'}; | 
            
            
              | 220 | 
                  my $countbiblio = CountBiblioInOrders($biblionumber);  | 
            
            
              | 221 | 
                  my $ordernumber = $line{'ordernumber'}; | 
            
            
              | 222 | 
                  my @subscriptions = GetSubscriptionsId ($biblionumber);  | 
            
            
              | 223 | 
                  my $itemcount = GetItemsCount($biblionumber);  | 
            
            
              | 224 | 
                  my $holds  = GetHolds ($biblionumber);  | 
            
            
              | 225 | 
                  my @items = GetItemnumbersFromOrder( $ordernumber );  | 
            
            
              | 226 | 
                  my $itemholds;  | 
            
            
              | 227 | 
                  foreach my $item (@items){ | 
            
            
              | 228 | 
                      my $nb = GetItemHolds($biblionumber, $item);  | 
            
            
              | 229 | 
                      if ($nb){ | 
            
            
              | 230 | 
                          $itemholds += $nb;  | 
            
            
              | 231 | 
                      }  | 
            
            
              | 232 | 
                  }  | 
            
            
              | 233 | 
                    | 
            
            
              | 234 | 
                  # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680  | 
            
            
              | 235 | 
                  $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds); | 
            
            
              | 236 | 
                  $line{items}                = ($itemcount) - (scalar @items); | 
            
            
              | 237 | 
                  $line{left_item}            = 1 if $line{items} >= 1; | 
            
            
              | 238 | 
                  $line{left_biblio}          = 1 if $countbiblio > 1; | 
            
            
              | 239 | 
                  $line{biblios}              = $countbiblio - 1; | 
            
            
              | 240 | 
                  $line{left_subscription}    = 1 if scalar @subscriptions >= 1; | 
            
            
              | 241 | 
                  $line{subscriptions}        = scalar @subscriptions; | 
            
            
              | 242 | 
                  $line{left_holds}           = 1 if $holds >= 1; | 
            
            
              | 243 | 
                  $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds ); | 
            
            
              | 244 | 
                  $line{holds}                = $holds; | 
            
            
              | 245 | 
                  $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; | 
            
            
              | 246 | 
                    | 
            
            
              | 247 | 
                    | 
            
        
          | 255 | 
              push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);  | 
          248 | 
              push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);  | 
        
        
          | 256 | 
          }  | 
          249 | 
          }  | 
        
        
          | 257 | 
          $freight = $totalfreight unless $freight;  | 
          250 | 
          $freight = $totalfreight unless $freight;  |