Bug 29394: Remove futuredate for renew
[koha-ffzg.git] / patroncards / edit-profile.pl
index 0dc312f..e5517da 100755 (executable)
 # 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::Auth qw(get_template_and_user);
-use C4::Output qw(output_html_with_http_headers);
-use C4::Creators::Lib qw(get_all_templates get_unit_values);
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_html_with_http_headers );
+use C4::Creators::Lib qw( get_all_templates get_unit_values );
 use C4::Patroncards::Profile;
 
-my $cgi = new CGI;
+my $cgi = CGI->new;
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
         template_name   => "patroncards/edit-profile.tt",
         query           => $cgi,
         type            => "intranet",
-        authnotrequired => 0,
-        flagsrequired   => { catalogue => 1 },
-        debug           => 1,
+        flagsrequired   => { tools => 'label_creator' },
     }
 );
 
@@ -50,7 +47,7 @@ my $units = get_unit_values();
 
 if ($op eq 'edit') {
     $profile = C4::Patroncards::Profile->retrieve(profile_id => $profile_id);
-    $template_list = get_all_templates(table_name => 'creator_templates', field_list => 'template_id,template_code, profile_id');
+    $template_list = get_all_templates({ fields => [ qw( template_id template_code profile_id ) ] });
 }
 elsif ($op eq 'save') {
     my @params = (
@@ -88,8 +85,9 @@ foreach my $unit (@$units) {
     }
 }
 
-if ($profile_id) { # if new layout, there will be no profile id, so shouldn't look for it
-    $template->param(profile_id => $profile->get_attr('profile_id')) if $profile->get_attr('profile_id') > 0;
+# if new layout, there will be no profile id, so shouldn't look for it
+if ( $profile_id && $profile->get_attr('profile_id') > 0 ) {
+    $template->param( profile_id => $profile->get_attr('profile_id') );
 }
 
 $template->param(