Bug 20410: DBRev 20.12.00.010
[koha-ffzg.git] / admin / aqcontract.pl
index dfe0fc0..9bd4d47 100755 (executable)
@@ -20,8 +20,7 @@
 # You should have received a copy of the GNU General Public License
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-use warnings;
+use Modern::Perl;
 use CGI qw ( -utf8 );
 use C4::Context;
 use C4::Auth;
@@ -29,20 +28,19 @@ use C4::Output;
 use C4::Contract;
 use Koha::DateUtils;
 
-use Koha::Acquisition::Bookseller;
+use Koha::Acquisition::Booksellers;
 
-my $input          = new CGI;
+my $input          = CGI->new;
 my $contractnumber = $input->param('contractnumber');
 my $booksellerid   = $input->param('booksellerid');
 my $op             = $input->param('op') || 'list';
 
-my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
+my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {   template_name   => "admin/aqcontract.tt",
         query           => $input,
         type            => "intranet",
-        authnotrequired => 0,
         flagsrequired   => { acquisition => 'contracts_manage' },
         debug           => 1,
     }
@@ -51,10 +49,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 $template->param(
     contractnumber => $contractnumber,
     booksellerid   => $booksellerid,
-    booksellername => $bookseller->{name},
-    basketcount   => $bookseller->{'basketcount'},
-    active         => $bookseller->{active},
-    subscriptioncount   => $bookseller->{'subscriptioncount'},
+    booksellername => $bookseller->name,
+    basketcount   => $bookseller->baskets->count,
+    active         => $bookseller->active,
+    subscriptioncount   => $bookseller->subscriptions->count,
 );
 
 #ADD_FORM: called if $op is 'add_form'. Used to create form to add or  modify a record
@@ -93,8 +91,8 @@ elsif ( $op eq 'add_validate' ) {
 
     my $is_a_modif = $input->param("is_a_modif");
 
-    my $contractstart_dt = eval { dt_from_string( $input->param('contractstartdate') ); };
-    my $contractend_dt = eval { dt_from_string( $input->param('contractenddate') ); };
+    my $contractstart_dt = eval { dt_from_string( scalar $input->param('contractstartdate') ); };
+    my $contractend_dt = eval { dt_from_string( scalar $input->param('contractenddate') ); };
     unless ( $contractstart_dt and $contractend_dt ) {
         my $today = dt_from_string;
         $contractstart_dt ||= $today;
@@ -115,8 +113,8 @@ elsif ( $op eq 'add_validate' ) {
             contractname        => scalar $input->param('contractname'),
             contractdescription => scalar $input->param('contractdescription'),
             booksellerid        => scalar $input->param('booksellerid'),
-            contractstartdate   => eval { output_pref({ dt => dt_from_string( $input->param('contractstartdate') ), dateformat => 'iso', dateonly => 1 } ); },
-            contractenddate     => eval { output_pref({ dt => dt_from_string( $input->param('contractenddate') ), dateformat => 'iso', dateonly => 1 } ); },
+            contractstartdate   => eval { output_pref({ dt => dt_from_string( scalar $input->param('contractstartdate') ), dateformat => 'iso', dateonly => 1 } ); },
+            contractenddate     => eval { output_pref({ dt => dt_from_string( scalar $input->param('contractenddate') ), dateformat => 'iso', dateonly => 1 } ); },
         });
     }