Bug 8603: Patron card creator - 'Barcode Type' doesn't stick in layouts
[koha.git] / misc / devel / create_superlibrarian.pl
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Copyright 2016 Koha Development Team
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use Modern::Perl;
21 use Getopt::Long;
22 use Pod::Usage;
23
24 use C4::Installer;
25 use C4::Context;
26 use C4::Members;
27
28 use Koha::DateUtils;
29 use Koha::Libraries;
30 use Koha::Patrons;
31 use Koha::Patron::Categories;
32
33 my $library         = Koha::Libraries->search->next;
34 my $patron_category = Koha::Patron::Categories->search->next;
35
36 die
37 "Not enough data in the database, library and/or patron category does not exist"
38   unless $library and $patron_category;
39
40 die "A patron with userid 'koha' already exists"
41   if Koha::Patrons->find( { userid => 'koha' } );
42 die "A patron with cardnumber '42' already exists"
43   if Koha::Patrons->find( { cardnumber => 'koha' } );
44
45 my $userid   = 'koha';
46 my $password = 'koha';
47 my $help;
48
49 GetOptions(
50     'help|?'   => \$help,
51     'userid=s'   => \$userid,
52     'password=s' => \$password
53 );
54
55 pod2usage(1) if $help;
56
57 AddMember(
58     surname      => 'koha',
59     userid       => $userid,
60     cardnumber   => 42,
61     branchcode   => $library->branchcode,
62     categorycode => $patron_category->categorycode,
63     password     => $password,
64     flags        => 1,
65 );
66
67 =head1 NAME
68
69 create_superlibrarian.pl - create a user in Koha with superlibrarian permissions
70
71 =head1 SYNOPSIS
72
73 create_superlibrarian.pl
74   [ --userid <userid> ] [ --password <password> ]
75
76  Options:
77    -?|--help        brief help message
78    --userid         specify the userid to be set (defaults to koha)
79    --password       specify the password to be set (defaults to koha)
80
81 =head1 OPTIONS
82
83 =over 8
84
85 =item B<--help|-?>
86
87 Print a brief help message and exits
88
89 =item B<--userid>
90
91 Allows you to specify the userid to be set in the database
92
93 =item B<--password>
94
95 Allows you to specify the password to be set in the database
96
97 =back
98
99 =head1 DESCRIPTION
100
101 A simple script to create a user in the Koha database with superlibrarian permissions
102
103 =cut