Re: [Koha-devel] Changing the lost card value

2021-10-18 Thread Tomas Cohen Arazi
You need to run it inside koha-shell

El lun., 18 oct. 2021 12:30, Stephen Graham 
escribió:

> Actually I just testing this now and cannot get it to work. I'm getting an
> error about not being able to write to the plack-opac-error.log file. I'm
> logged in as the usual koha user, and it's for a non-web script - never
> seen that before. I guess it's not working and it's trying to log the error
> to the plack log.
>
> I have the below, it's print User has a lost card, and then bombs out.
>
> my $user = Koha::Patrons->find($userid);
> if ($user->lost) {
> print "User has a lost card\n";
> $user->lost(0)->store();
> } else {
> print "NO lost card\n";
> }
>
> Stephen
>
> -Original Message-
> From: Stephen Graham
> Sent: 18 October 2021 14:04
> To: Jonathan Druart 
> Cc: koha-devel 
> Subject: RE: [Koha-devel] Changing the lost card value
>
> Thanks Jonathan. I understand that the find method returns a Patron
> object, but don't understand where lost comes from. It's not a method in
> Patron is it? I guess it's a shortcut to update any individual database
> field value?
>
> Stephen
>
> -----Original Message-
> From: Jonathan Druart 
> Sent: 18 October 2021 12:37
> To: Stephen Graham 
> Cc: koha-devel 
> Subject: Re: [Koha-devel] Changing the lost card value
>
> Hi Stephen,
>
> You can use
>   Koha::Patrons->find(42)->lost(0)->store;
> to set borrowers.lost to 0 for patron with borrowernumber=42.
>
> Cheers,
> Jonathan
>
> Le lun. 18 oct. 2021 à 12:47, Stephen Graham  a
> écrit :
> >
> > Sorry if this is a basic question. I’ve searched through the
> Koha::Patron and C4::Members perldoc and had a quick look through the
> memberentry.pl code to see how this handles it, but I can’t seem to work
> out how it done. I want to change the value of the lost card field to zero.
> I can see the “lost” field in the borrowers table, so could update the
> value directly via SQL, but there must be a Koha method that I can use to
> do this? Any help/advice much appreciated!
> >
> >
> >
> > Cheers, Stephen
> >
> >
> >
> > --
> >
> > Stephen Graham
> >
> > Library Technology Consultant
> >
> > Library and Computing Services
> >
> >
> >
> > University of Hertfordshire
> >
> > Hatfield, Hertfordshire, AL10 9AB
> >
> >
> >
> > Tel: +44(0)1707 286111
> >
> > Ext: 77751
> >
> > Email: s.grah...@herts.ac.uk
> >
> > Website: herts.ac.uk
> >
> >
> >
> > ___
> > Koha-devel mailing list
> > Koha-devel@lists.koha-community.org
> > https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> > website : https://www.koha-community.org/ git :
> > https://git.koha-community.org/ bugs :
> > https://bugs.koha-community.org/
> ___
> Koha-devel mailing list
> Koha-devel@lists.koha-community.org
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : https://www.koha-community.org/
> git : https://git.koha-community.org/
> bugs : https://bugs.koha-community.org/
>
___
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/


Re: [Koha-devel] Changing the lost card value

2021-10-18 Thread Cab Vinton
I think another option would be the Patron Import tool:
...tools/import_borrowers.pl

Cheers,

Cab Vinton, Director
Plaistow Public Library
Plaistow, NH

On Mon, Oct 18, 2021 at 9:43 AM Jonathan Druart
 wrote:
>
> Hi Stephen,
>
> You can use
>   Koha::Patrons->find(42)->lost(0)->store;
> to set borrowers.lost to 0 for patron with borrowernumber=42.
>
> Cheers,
> Jonathan
>
> Le lun. 18 oct. 2021 à 12:47, Stephen Graham  a écrit :
> >
> > Sorry if this is a basic question. I’ve searched through the Koha::Patron 
> > and C4::Members perldoc and had a quick look through the memberentry.pl 
> > code to see how this handles it, but I can’t seem to work out how it done. 
> > I want to change the value of the lost card field to zero. I can see the 
> > “lost” field in the borrowers table, so could update the value directly via 
> > SQL, but there must be a Koha method that I can use to do this? Any 
> > help/advice much appreciated!
> >
> >
> >
> > Cheers, Stephen
> >
> >
> >
> > --
> >
> > Stephen Graham
> >
> > Library Technology Consultant
> >
> > Library and Computing Services
> >
> >
> >
> > University of Hertfordshire
> >
> > Hatfield, Hertfordshire, AL10 9AB
> >
> >
> >
> > Tel: +44(0)1707 286111
> >
> > Ext: 77751
> >
> > Email: s.grah...@herts.ac.uk
> >
> > Website: herts.ac.uk
> >
> >
> >
> > ___
> > Koha-devel mailing list
> > Koha-devel@lists.koha-community.org
> > https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> > website : https://www.koha-community.org/
> > git : https://git.koha-community.org/
> > bugs : https://bugs.koha-community.org/
> ___
> Koha-devel mailing list
> Koha-devel@lists.koha-community.org
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : https://www.koha-community.org/
> git : https://git.koha-community.org/
> bugs : https://bugs.koha-community.org/
___
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/


Re: [Koha-devel] Changing the lost card value

2021-10-18 Thread Jonathan Druart
The trick is in the AUTOLOAD of Koha::Object, any attributes (column's
names) will be a getter/setter.

To login as the koha user and set the correct env vars you need to use
the `koha-shell` command.

Le lun. 18 oct. 2021 à 15:18, Stephen Graham  a écrit :
>
> Actually I just testing this now and cannot get it to work. I'm getting an 
> error about not being able to write to the plack-opac-error.log file. I'm 
> logged in as the usual koha user, and it's for a non-web script - never seen 
> that before. I guess it's not working and it's trying to log the error to the 
> plack log.
>
> I have the below, it's print User has a lost card, and then bombs out.
>
> my $user = Koha::Patrons->find($userid);
> if ($user->lost) {
> print "User has a lost card\n";
> $user->lost(0)->store();
> } else {
> print "NO lost card\n";
> }
>
> Stephen
>
> -Original Message-
> From: Stephen Graham
> Sent: 18 October 2021 14:04
> To: Jonathan Druart 
> Cc: koha-devel 
> Subject: RE: [Koha-devel] Changing the lost card value
>
> Thanks Jonathan. I understand that the find method returns a Patron object, 
> but don't understand where lost comes from. It's not a method in Patron is 
> it? I guess it's a shortcut to update any individual database field value?
>
> Stephen
>
> -----Original Message-
> From: Jonathan Druart 
> Sent: 18 October 2021 12:37
> To: Stephen Graham 
> Cc: koha-devel 
> Subject: Re: [Koha-devel] Changing the lost card value
>
> Hi Stephen,
>
> You can use
>   Koha::Patrons->find(42)->lost(0)->store;
> to set borrowers.lost to 0 for patron with borrowernumber=42.
>
> Cheers,
> Jonathan
>
> Le lun. 18 oct. 2021 à 12:47, Stephen Graham  a écrit :
> >
> > Sorry if this is a basic question. I’ve searched through the Koha::Patron 
> > and C4::Members perldoc and had a quick look through the memberentry.pl 
> > code to see how this handles it, but I can’t seem to work out how it done. 
> > I want to change the value of the lost card field to zero. I can see the 
> > “lost” field in the borrowers table, so could update the value directly via 
> > SQL, but there must be a Koha method that I can use to do this? Any 
> > help/advice much appreciated!
> >
> >
> >
> > Cheers, Stephen
> >
> >
> >
> > --
> >
> > Stephen Graham
> >
> > Library Technology Consultant
> >
> > Library and Computing Services
> >
> >
> >
> > University of Hertfordshire
> >
> > Hatfield, Hertfordshire, AL10 9AB
> >
> >
> >
> > Tel: +44(0)1707 286111
> >
> > Ext: 77751
> >
> > Email: s.grah...@herts.ac.uk
> >
> > Website: herts.ac.uk
> >
> >
> >
> > ___
> > Koha-devel mailing list
> > Koha-devel@lists.koha-community.org
> > https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> > website : https://www.koha-community.org/ git :
> > https://git.koha-community.org/ bugs :
> > https://bugs.koha-community.org/
___
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/


Re: [Koha-devel] Changing the lost card value

2021-10-18 Thread Stephen Graham
Actually I just testing this now and cannot get it to work. I'm getting an 
error about not being able to write to the plack-opac-error.log file. I'm 
logged in as the usual koha user, and it's for a non-web script - never seen 
that before. I guess it's not working and it's trying to log the error to the 
plack log. 

I have the below, it's print User has a lost card, and then bombs out.

my $user = Koha::Patrons->find($userid);
if ($user->lost) {
print "User has a lost card\n";
$user->lost(0)->store();
} else {
print "NO lost card\n";
}

Stephen

-Original Message-
From: Stephen Graham 
Sent: 18 October 2021 14:04
To: Jonathan Druart 
Cc: koha-devel 
Subject: RE: [Koha-devel] Changing the lost card value

Thanks Jonathan. I understand that the find method returns a Patron object, but 
don't understand where lost comes from. It's not a method in Patron is it? I 
guess it's a shortcut to update any individual database field value?

Stephen

-Original Message-
From: Jonathan Druart  
Sent: 18 October 2021 12:37
To: Stephen Graham 
Cc: koha-devel 
Subject: Re: [Koha-devel] Changing the lost card value

Hi Stephen,

You can use
  Koha::Patrons->find(42)->lost(0)->store;
to set borrowers.lost to 0 for patron with borrowernumber=42.

Cheers,
Jonathan

Le lun. 18 oct. 2021 à 12:47, Stephen Graham  a écrit :
>
> Sorry if this is a basic question. I’ve searched through the Koha::Patron and 
> C4::Members perldoc and had a quick look through the memberentry.pl code to 
> see how this handles it, but I can’t seem to work out how it done. I want to 
> change the value of the lost card field to zero. I can see the “lost” field 
> in the borrowers table, so could update the value directly via SQL, but there 
> must be a Koha method that I can use to do this? Any help/advice much 
> appreciated!
>
>
>
> Cheers, Stephen
>
>
>
> --
>
> Stephen Graham
>
> Library Technology Consultant
>
> Library and Computing Services
>
>
>
> University of Hertfordshire
>
> Hatfield, Hertfordshire, AL10 9AB
>
>
>
> Tel: +44(0)1707 286111
>
> Ext: 77751
>
> Email: s.grah...@herts.ac.uk
>
> Website: herts.ac.uk
>
>
>
> ___
> Koha-devel mailing list
> Koha-devel@lists.koha-community.org
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : https://www.koha-community.org/ git : 
> https://git.koha-community.org/ bugs : 
> https://bugs.koha-community.org/
___
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/


Re: [Koha-devel] Changing the lost card value

2021-10-18 Thread Stephen Graham
Thanks Jonathan. I understand that the find method returns a Patron object, but 
don't understand where lost comes from. It's not a method in Patron is it? I 
guess it's a shortcut to update any individual database field value?

Stephen

-Original Message-
From: Jonathan Druart  
Sent: 18 October 2021 12:37
To: Stephen Graham 
Cc: koha-devel 
Subject: Re: [Koha-devel] Changing the lost card value

Hi Stephen,

You can use
  Koha::Patrons->find(42)->lost(0)->store;
to set borrowers.lost to 0 for patron with borrowernumber=42.

Cheers,
Jonathan

Le lun. 18 oct. 2021 à 12:47, Stephen Graham  a écrit :
>
> Sorry if this is a basic question. I’ve searched through the Koha::Patron and 
> C4::Members perldoc and had a quick look through the memberentry.pl code to 
> see how this handles it, but I can’t seem to work out how it done. I want to 
> change the value of the lost card field to zero. I can see the “lost” field 
> in the borrowers table, so could update the value directly via SQL, but there 
> must be a Koha method that I can use to do this? Any help/advice much 
> appreciated!
>
>
>
> Cheers, Stephen
>
>
>
> --
>
> Stephen Graham
>
> Library Technology Consultant
>
> Library and Computing Services
>
>
>
> University of Hertfordshire
>
> Hatfield, Hertfordshire, AL10 9AB
>
>
>
> Tel: +44(0)1707 286111
>
> Ext: 77751
>
> Email: s.grah...@herts.ac.uk
>
> Website: herts.ac.uk
>
>
>
> ___
> Koha-devel mailing list
> Koha-devel@lists.koha-community.org
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : https://www.koha-community.org/ git : 
> https://git.koha-community.org/ bugs : 
> https://bugs.koha-community.org/
___
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/


Re: [Koha-devel] Changing the lost card value

2021-10-18 Thread Jonathan Druart
Hi Stephen,

You can use
  Koha::Patrons->find(42)->lost(0)->store;
to set borrowers.lost to 0 for patron with borrowernumber=42.

Cheers,
Jonathan

Le lun. 18 oct. 2021 à 12:47, Stephen Graham  a écrit :
>
> Sorry if this is a basic question. I’ve searched through the Koha::Patron and 
> C4::Members perldoc and had a quick look through the memberentry.pl code to 
> see how this handles it, but I can’t seem to work out how it done. I want to 
> change the value of the lost card field to zero. I can see the “lost” field 
> in the borrowers table, so could update the value directly via SQL, but there 
> must be a Koha method that I can use to do this? Any help/advice much 
> appreciated!
>
>
>
> Cheers, Stephen
>
>
>
> --
>
> Stephen Graham
>
> Library Technology Consultant
>
> Library and Computing Services
>
>
>
> University of Hertfordshire
>
> Hatfield, Hertfordshire, AL10 9AB
>
>
>
> Tel: +44(0)1707 286111
>
> Ext: 77751
>
> Email: s.grah...@herts.ac.uk
>
> Website: herts.ac.uk
>
>
>
> ___
> Koha-devel mailing list
> Koha-devel@lists.koha-community.org
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : https://www.koha-community.org/
> git : https://git.koha-community.org/
> bugs : https://bugs.koha-community.org/
___
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/