| Lines 108-229
          my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
      
      
        Link Here | 
        
          | 108 |     } | 108 |     } | 
        
          | 109 | ); | 109 | ); | 
        
          | 110 |  | 110 |  | 
          
            
              | 111 | my $count = scalar @$results; | 111 | unless ( @$results ) { | 
            
              | 112 | # prepare the form for receiving | 112 |     output_html_with_http_headers $input, $cookie, $template->output; | 
            
              | 113 | if ( $count == 1 ) { | 113 |     exit; | 
            
              | 114 |     my $order = $results->[0]; | 114 | } | 
            
              | 115 |  |  |  | 
            
              | 116 |     # Check if ACQ framework exists | 
            
              | 117 |     my $acq_fw = GetMarcStructure(1, 'ACQ'); | 
            
              | 118 |     unless($acq_fw) { | 
            
              | 119 |         $template->param('NoACQframework' => 1); | 
            
              | 120 |     } | 
            
              | 121 |  | 
            
              | 122 |     my $AcqCreateItem = C4::Context->preference('AcqCreateItem'); | 
            
              | 123 |     if ($AcqCreateItem eq 'receiving') { | 
            
              | 124 |         $template->param( | 
            
              | 125 |             AcqCreateItemReceiving => 1, | 
            
              | 126 |             UniqueItemFields => C4::Context->preference('UniqueItemFields'), | 
            
              | 127 |         ); | 
            
              | 128 |     } elsif ($AcqCreateItem eq 'ordering') { | 
            
              | 129 |         my $fw = ($acq_fw) ? 'ACQ' : ''; | 
            
              | 130 |         my @itemnumbers = GetItemnumbersFromOrder($order->{ordernumber}); | 
            
              | 131 |         my @items; | 
            
              | 132 |         foreach (@itemnumbers) { | 
            
              | 133 |             my $item = GetItem($_); | 
            
              | 134 |             if($item->{homebranch}) { | 
            
              | 135 |                 $item->{homebranchname} = GetBranchName($item->{homebranch}); | 
            
              | 136 |             } | 
            
              | 137 |             if($item->{holdingbranch}) { | 
            
              | 138 |                 $item->{holdingbranchname} = GetBranchName($item->{holdingbranch}); | 
            
              | 139 |             } | 
            
              | 140 |             if(my $code = GetAuthValCode("items.notforloan", $fw)) { | 
            
              | 141 |                 $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan}); | 
            
              | 142 |             } | 
            
              | 143 |             if(my $code = GetAuthValCode("items.restricted", $fw)) { | 
            
              | 144 |                 $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted}); | 
            
              | 145 |             } | 
            
              | 146 |             if(my $code = GetAuthValCode("items.location", $fw)) { | 
            
              | 147 |                 $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location}); | 
            
              | 148 |             } | 
            
              | 149 |             if(my $code = GetAuthValCode("items.ccode", $fw)) { | 
            
              | 150 |                 $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode}); | 
            
              | 151 |             } | 
            
              | 152 |             if(my $code = GetAuthValCode("items.materials", $fw)) { | 
            
              | 153 |                 $item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials}); | 
            
              | 154 |             } | 
            
              | 155 |             my $itemtype = getitemtypeinfo($item->{itype}); | 
            
              | 156 |             $item->{itemtype} = $itemtype->{description}; | 
            
              | 157 |             push @items, $item; | 
            
              | 158 |         } | 
            
              | 159 |         $template->param(items => \@items); | 
            
              | 160 |     } | 
            
              | 161 |  | 
            
              | 162 |     if ( $order->{'unitprice'} == 0 ) { | 
            
              | 163 |         $order->{'unitprice'} = ''; | 
            
              | 164 |     } | 
            
              | 165 |  | 
            
              | 166 |     my $suggestion   = GetSuggestionInfoFromBiblionumber($order->{'biblionumber'}); | 
        
          | 167 |  | 115 |  | 
          
            
              | 168 |     my $authorisedby = $order->{'authorisedby'}; | 116 | # prepare the form for receiving | 
            
              | 169 |     my $member = GetMember( borrowernumber => $authorisedby ); | 117 | my $order = $results->[0]; | 
        
          | 170 |  | 118 |  | 
          
            
              | 171 |     my $budget = GetBudget( $order->{'budget_id'} ); | 119 | # Check if ACQ framework exists | 
            
              |  |  | 120 | my $acq_fw = GetMarcStructure(1, 'ACQ'); | 
            
              | 121 | unless($acq_fw) { | 
            
              | 122 |     $template->param('NoACQframework' => 1); | 
            
              | 123 | } | 
        
          | 172 |  | 124 |  | 
            
              |  |  | 125 | my $AcqCreateItem = C4::Context->preference('AcqCreateItem'); | 
            
              | 126 | if ($AcqCreateItem eq 'receiving') { | 
        
          | 173 |     $template->param( | 127 |     $template->param( | 
          
            
              | 174 |         AcqCreateItem         => $AcqCreateItem, | 128 |         AcqCreateItemReceiving => 1, | 
            
              | 175 |         count                 => 1, | 129 |         UniqueItemFields => C4::Context->preference('UniqueItemFields'), | 
            
              | 176 |         biblionumber          => $order->{'biblionumber'}, |  |  | 
            
              | 177 |         ordernumber           => $order->{'ordernumber'}, | 
            
              | 178 |         biblioitemnumber      => $order->{'biblioitemnumber'}, | 
            
              | 179 |         booksellerid          => $order->{'booksellerid'}, | 
            
              | 180 |         freight               => $freight, | 
            
              | 181 |         gst                   => $gst, | 
            
              | 182 |         name                  => $bookseller->{'name'}, | 
            
              | 183 |         date                  => format_date($order->{entrydate}), | 
            
              | 184 |         title                 => $order->{'title'}, | 
            
              | 185 |         author                => $order->{'author'}, | 
            
              | 186 |         copyrightdate         => $order->{'copyrightdate'}, | 
            
              | 187 |         isbn                  => $order->{'isbn'}, | 
            
              | 188 |         seriestitle           => $order->{'seriestitle'}, | 
            
              | 189 |         bookfund              => $budget->{budget_name}, | 
            
              | 190 |         quantity              => $order->{'quantity'}, | 
            
              | 191 |         quantityreceivedplus1 => $order->{'quantityreceived'} + 1, | 
            
              | 192 |         quantityreceived      => $order->{'quantityreceived'}, | 
            
              | 193 |         rrp                   => $order->{'rrp'}, | 
            
              | 194 |         ecost                 => sprintf( "%.2f",$order->{'ecost'}), | 
            
              | 195 |         unitprice             => sprintf( "%.2f",$order->{'unitprice'}), | 
            
              | 196 |         memberfirstname       => $member->{firstname} || "", | 
            
              | 197 |         membersurname         => $member->{surname} || "", | 
            
              | 198 |         invoice               => $invoice, | 
            
              | 199 |         datereceived          => $datereceived->output(), | 
            
              | 200 |         datereceived_iso      => $datereceived->output('iso'), | 
            
              | 201 |         notes                 => $order->{notes}, | 
            
              | 202 |         suggestionid          => $suggestion->{suggestionid}, | 
            
              | 203 |         surnamesuggestedby    => $suggestion->{surnamesuggestedby}, | 
            
              | 204 |         firstnamesuggestedby  => $suggestion->{firstnamesuggestedby}, | 
        
          | 205 |     ); | 130 |     ); | 
          
            
              | 206 | } | 131 | } elsif ($AcqCreateItem eq 'ordering') { | 
            
              | 207 | else { | 132 |     my $fw = ($acq_fw) ? 'ACQ' : ''; | 
            
              | 208 |     my @loop; | 133 |     my @itemnumbers = GetItemnumbersFromOrder($order->{ordernumber}); | 
            
              | 209 |     for ( my $i = 0 ; $i < $count ; $i++ ) { | 134 |     my @items; | 
            
              | 210 |         my %line = %{ @$results[$i] }; | 135 |     foreach (@itemnumbers) { | 
            
              | 211 |  | 136 |         my $item = GetItem($_); | 
            
              | 212 |         $line{invoice}      = $invoice; | 137 |         if($item->{homebranch}) { | 
            
              | 213 |         $line{datereceived} = $datereceived->output(); | 138 |             $item->{homebranchname} = GetBranchName($item->{homebranch}); | 
            
              | 214 |         $line{freight}      = $freight; | 139 |         } | 
            
              | 215 |         $line{gst}          = $gst; | 140 |         if($item->{holdingbranch}) { | 
            
              | 216 |         $line{title}        = @$results[$i]->{'title'}; | 141 |             $item->{holdingbranchname} = GetBranchName($item->{holdingbranch}); | 
            
              | 217 |         $line{author}       = @$results[$i]->{'author'}; | 142 |         } | 
            
              | 218 |         $line{booksellerid}   = $booksellerid; | 143 |         if(my $code = GetAuthValCode("items.notforloan", $fw)) { | 
            
              | 219 |         push @loop, \%line; | 144 |             $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan}); | 
            
              |  |  | 145 |         } | 
            
              | 146 |         if(my $code = GetAuthValCode("items.restricted", $fw)) { | 
            
              | 147 |             $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted}); | 
            
              | 148 |         } | 
            
              | 149 |         if(my $code = GetAuthValCode("items.location", $fw)) { | 
            
              | 150 |             $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location}); | 
            
              | 151 |         } | 
            
              | 152 |         if(my $code = GetAuthValCode("items.ccode", $fw)) { | 
            
              | 153 |             $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode}); | 
            
              | 154 |         } | 
            
              | 155 |         if(my $code = GetAuthValCode("items.materials", $fw)) { | 
            
              | 156 |             $item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials}); | 
            
              | 157 |         } | 
            
              | 158 |         my $itemtype = getitemtypeinfo($item->{itype}); | 
            
              | 159 |         $item->{itemtype} = $itemtype->{description}; | 
            
              | 160 |         push @items, $item; | 
        
          | 220 |     } | 161 |     } | 
            
              |  |  | 162 |     $template->param(items => \@items); | 
            
              | 163 | } | 
        
          | 221 |  | 164 |  | 
          
            
              | 222 |     $template->param( | 165 | if ( $order->{'unitprice'} == 0 ) { | 
            
              | 223 |         loop         => \@loop, | 166 |     $order->{'unitprice'} = ''; | 
            
              | 224 |         booksellerid   => $booksellerid, |  |  | 
            
              | 225 |     ); | 
        
          | 226 | } | 167 | } | 
            
              |  |  | 168 |  | 
            
              | 169 | my $suggestion   = GetSuggestionInfoFromBiblionumber($order->{'biblionumber'}); | 
            
              | 170 |  | 
            
              | 171 | my $authorisedby = $order->{'authorisedby'}; | 
            
              | 172 | my $member = GetMember( borrowernumber => $authorisedby ); | 
            
              | 173 |  | 
            
              | 174 | my $budget = GetBudget( $order->{'budget_id'} ); | 
            
              | 175 |  | 
            
              | 176 | $template->param( | 
            
              | 177 |     AcqCreateItem         => $AcqCreateItem, | 
            
              | 178 |     count                 => 1, | 
            
              | 179 |     biblionumber          => $order->{'biblionumber'}, | 
            
              | 180 |     ordernumber           => $order->{'ordernumber'}, | 
            
              | 181 |     biblioitemnumber      => $order->{'biblioitemnumber'}, | 
            
              | 182 |     booksellerid          => $order->{'booksellerid'}, | 
            
              | 183 |     freight               => $freight, | 
            
              | 184 |     gst                   => $gst, | 
            
              | 185 |     name                  => $bookseller->{'name'}, | 
            
              | 186 |     date                  => format_date($order->{entrydate}), | 
            
              | 187 |     title                 => $order->{'title'}, | 
            
              | 188 |     author                => $order->{'author'}, | 
            
              | 189 |     copyrightdate         => $order->{'copyrightdate'}, | 
            
              | 190 |     isbn                  => $order->{'isbn'}, | 
            
              | 191 |     seriestitle           => $order->{'seriestitle'}, | 
            
              | 192 |     bookfund              => $budget->{budget_name}, | 
            
              | 193 |     quantity              => $order->{'quantity'}, | 
            
              | 194 |     quantityreceivedplus1 => $order->{'quantityreceived'} + 1, | 
            
              | 195 |     quantityreceived      => $order->{'quantityreceived'}, | 
            
              | 196 |     rrp                   => $order->{'rrp'}, | 
            
              | 197 |     ecost                 => sprintf( "%.2f",$order->{'ecost'}), | 
            
              | 198 |     unitprice             => sprintf( "%.2f",$order->{'unitprice'}), | 
            
              | 199 |     memberfirstname       => $member->{firstname} || "", | 
            
              | 200 |     membersurname         => $member->{surname} || "", | 
            
              | 201 |     invoice               => $invoice, | 
            
              | 202 |     datereceived          => $datereceived->output(), | 
            
              | 203 |     datereceived_iso      => $datereceived->output('iso'), | 
            
              | 204 |     notes                 => $order->{notes}, | 
            
              | 205 |     suggestionid          => $suggestion->{suggestionid}, | 
            
              | 206 |     surnamesuggestedby    => $suggestion->{surnamesuggestedby}, | 
            
              | 207 |     firstnamesuggestedby  => $suggestion->{firstnamesuggestedby}, | 
            
              | 208 | ); | 
            
              | 209 |  | 
        
          | 227 | my $op = $input->param('op'); | 210 | my $op = $input->param('op'); | 
        
          | 228 | if ($op and $op eq 'edit'){ | 211 | if ($op and $op eq 'edit'){ | 
        
          | 229 |     $template->param(edit   =>   1); | 212 |     $template->param(edit   =>   1); |