Re: [Koha] How to receive reports to email

2019-03-09 Thread Katrin Fischer

Hi Satish,

thx for the update. Good to know!

Katrin

On 08.03.19 12:37, SATISH wrote:

Hi Katrin,

I verified for multiple reports today. It is working fine.

The correct syntax:
 * *  * * * root koha-foreach --enabled --email
 /usr/share/koha/bin/cronjobs/runreport.pl
 report-id1 report-id2 report-id3  --format=html
--to=email id
(report ids separated by one space only, no semicolon, no comma)
Since, I had an extra (star)* character in my cron entry earlier  by
typo error, caused cron not to send emails.

thank you everyone for your guidance.


With best regards.
--
*Satish MV*
M.Sc, PGDCA, UGC-NET,
Librarian - Govt. Engineering College
Opp. Dairy Circle, B.M.Road, Hassan 573 201
Karnataka, INDIA
Mobile: +91 9449765737
Personal Email: lis4sat...@gmail.com 
College Website: www. gechassan.ac.in

Library OPAC: http://library.gechassan.ac.in

Library Portal : https://librarygechassan.wixsite.com/library

___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-03-08 Thread SATISH
Hi Katrin,

I verified for multiple reports today. It is working fine.

The correct syntax:
 * *  * * * root koha-foreach --enabled --email
 /usr/share/koha/bin/cronjobs/runreport.pl report-id1 report-id2
report-id3  --format=html --to=email id
(report ids separated by one space only, no semicolon, no comma)
Since, I had an extra (star)* character in my cron entry earlier  by typo
error, caused cron not to send emails.

thank you everyone for your guidance.


With best regards.
-- 
*Satish MV*
M.Sc, PGDCA, UGC-NET,
Librarian - Govt. Engineering College
Opp. Dairy Circle, B.M.Road, Hassan 573 201
Karnataka, INDIA
Mobile: +91 9449765737
Personal Email: lis4sat...@gmail.com
College Website: www. gechassan.ac.in
Library OPAC: http://library.gechassan.ac.in
Library Portal :  https://librarygechassan.wixsite.com/library
___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-03-07 Thread Katrin Fischer

Hi Satish,

try to add multiple lines in crontab for the different reports you want
to run. I think the runreport.pl script only can only be run with one
report number at a time.

Katrin

On 06.03.19 12:53, SATISH wrote:

Thank you Paul, Barton, Alvaro

Still I am not able to run the said scripts.  I am getting same permission
problem.
I  tried to keep related files in /root directory and also in
/usr/share/koha/bin directory
same permission problem occurs. So, I did not understand it completely.
I need some more guidance to get desired results.

However, I also tried with other suggestions given in the mail,
since runreports.pl is already defined in koha,

I directly edited the file -- koha-common (etc/cron.d)
added following line,

45 17 * * * * root koha-foreach --enabled --email
/usr/share/koha/bin/cronjobs/runreport.pl report-id --format=html
--to=email id
I  am successful.

But, for multiple reports, I am not successful.
45 17 * * * * root koha-foreach --enabled --email
/usr/share/koha/bin/cronjobs/runreport.pl report-id1 report-id2 report-id3
--format=html --to=email id


Checkout report -  is taken from SQL library, developed by Sarah Cornel
List of items issued on a date with optional limit by due date

with little modification in the last line,  manual entry of   'issue date'
to 'current date' to chose date on which report is run.

SQL
--
SELECT
issuedate, date_due, items.barcode, items.itemcallnumber, biblio.title,
biblio.author, CONCAT(borrowers.firstname, ' ',borrowers.surname) AS
'patron',
borrowers.cardnumber, CONCAT(borrowers.borrowernumber) AS borrowernumber
FROM issues
LEFT JOIN items ON issues.itemnumber = items.itemnumber
LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber
LEFT JOIN borrowers ON issues.borrowernumber = borrowers.borrowernumber
WHERE DATE(issuedate) =  CURDATE()
---

Since I missed to CC koha forum, I am copying imp mails from Paul received.
--
The twiddle character (~) in the koha-shell command is being interpreted
as root's home directory (/root), not as the regular user's home
directory (/home/helm-gechlibrary or whatever).  The regular user can't
see inside /root, hence the permission error.

Try this:

# koha-shell gechlibrary -c '/home/helm-gechlibrary/bin/run-reports.pl
  /home/helm-gechlibrary/reports/checkout-report.txt'

Or, equivalently:

# koha-shell gechlibrary -c '~helm-gechlibrary/bin/run-reports.pl
  ~helm-gechlibrary/reports/checkout-report.txt'

This should also work:

# koha-shell gechlibrary --login -c 'bin/run-reports.pl
  reports/checkout-report.txt'

That's because the command -- i.e., the COMMAND in _koha-shell INSTANCE
--login -c COMMAND_ -- is executed by a process whose current working
directory is /home/helm-gechlibrary.
Good luck! Paul.
---
___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha

___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-03-06 Thread SATISH
Thank you Paul, Barton, Alvaro

Still I am not able to run the said scripts.  I am getting same permission
problem.
I  tried to keep related files in /root directory and also in
/usr/share/koha/bin directory
same permission problem occurs. So, I did not understand it completely.
I need some more guidance to get desired results.

However, I also tried with other suggestions given in the mail,
since runreports.pl is already defined in koha,

I directly edited the file -- koha-common (etc/cron.d)
added following line,

45 17 * * * * root koha-foreach --enabled --email
/usr/share/koha/bin/cronjobs/runreport.pl report-id --format=html
--to=email id
I  am successful.

But, for multiple reports, I am not successful.
45 17 * * * * root koha-foreach --enabled --email
/usr/share/koha/bin/cronjobs/runreport.pl report-id1 report-id2 report-id3
--format=html --to=email id


Checkout report -  is taken from SQL library, developed by Sarah Cornel
List of items issued on a date with optional limit by due date

with little modification in the last line,  manual entry of   'issue date'
to 'current date' to chose date on which report is run.

SQL
--
SELECT
issuedate, date_due, items.barcode, items.itemcallnumber, biblio.title,
biblio.author, CONCAT(borrowers.firstname, ' ',borrowers.surname) AS
'patron',
borrowers.cardnumber, CONCAT(borrowers.borrowernumber) AS borrowernumber
FROM issues
LEFT JOIN items ON issues.itemnumber = items.itemnumber
LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber
LEFT JOIN borrowers ON issues.borrowernumber = borrowers.borrowernumber
WHERE DATE(issuedate) =  CURDATE()
---

Since I missed to CC koha forum, I am copying imp mails from Paul received.
--
The twiddle character (~) in the koha-shell command is being interpreted
as root's home directory (/root), not as the regular user's home
directory (/home/helm-gechlibrary or whatever).  The regular user can't
see inside /root, hence the permission error.

Try this:

# koha-shell gechlibrary -c '/home/helm-gechlibrary/bin/run-reports.pl
 /home/helm-gechlibrary/reports/checkout-report.txt'

Or, equivalently:

# koha-shell gechlibrary -c '~helm-gechlibrary/bin/run-reports.pl
 ~helm-gechlibrary/reports/checkout-report.txt'

This should also work:

# koha-shell gechlibrary --login -c 'bin/run-reports.pl
 reports/checkout-report.txt'

That's because the command -- i.e., the COMMAND in _koha-shell INSTANCE
--login -c COMMAND_ -- is executed by a process whose current working
directory is /home/helm-gechlibrary.
Good luck! Paul.
---
___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-02-18 Thread Barton Chittenden
note that the format should be

 --format=csv

(comma separated values) not

 --format=cvs




On Mon, Feb 18, 2019 at 9:33 AM Alvaro Cornejo 
wrote:

> Hi
>
> You need to specify all time fields in your command. If you do not want to
> specify one, you must insert an *
>
> Time fields are
> [minute] [hour] [day] [month] [day of week]
>
> 30 17 * * *   __KOHA_USER__ $KOHA_CRON_PATH/runreport.pl 141  --format=cvs
> --to=lis4sat...@gmail.com
>
> As per above, your report will run every day al 17:30hrs.
>
> Regards
>
> Alvaro
>
>
>
> |-|
> Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier
> celular y Nextel
> en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS
> y GPRS online
>   Visitenos en www.perusms.com
>
>
> Le lun. 18 févr. 2019 à 09:25, Alvaro Cornejo  a
> écrit :
>
> > Hi
> >
> > I guess you should use  --format=cvs ... and maybe --cvs-header
> >
> > Regards,
> >
> > Alvaro
> >
> >
> >
> |-|
> > Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier
> > celular y Nextel
> > en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via
> SMS
> > y GPRS online
> >   Visitenos en www.perusms.com
> >
> >
> > Le sam. 16 févr. 2019 à 02:50, SATISH  a écrit :
> >
> >> Hi Caroline,
> >>
> >> Thank you for your email.
> >>
> >> Could you please confirm, the format I am using in cron is it correct?
> >>
> >> #test report
> >> 30 17   __KOHA_USER__ $KOHA_CRON_PATH/runreport.pl 141 --format=text
> >> --to=
> >> lis4sat...@gmail.com
> >>
> >> Also,  I would like to get the report in -  tab delimited format or csv
> >> format.
> >>
> >> Thank you
> >> Satish
> >> ___
> >> Koha mailing list  http://koha-community.org
> >> Koha@lists.katipo.co.nz
> >> https://lists.katipo.co.nz/mailman/listinfo/koha
> >>
> >
> ___
> Koha mailing list  http://koha-community.org
> Koha@lists.katipo.co.nz
> https://lists.katipo.co.nz/mailman/listinfo/koha
>
___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-02-18 Thread Alvaro Cornejo
Hi

You need to specify all time fields in your command. If you do not want to
specify one, you must insert an *

Time fields are
[minute] [hour] [day] [month] [day of week]

30 17 * * *   __KOHA_USER__ $KOHA_CRON_PATH/runreport.pl 141  --format=cvs
--to=lis4sat...@gmail.com

As per above, your report will run every day al 17:30hrs.

Regards

Alvaro


|-|
Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier
celular y Nextel
en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS
y GPRS online
  Visitenos en www.perusms.com


Le lun. 18 févr. 2019 à 09:25, Alvaro Cornejo  a
écrit :

> Hi
>
> I guess you should use  --format=cvs ... and maybe --cvs-header
>
> Regards,
>
> Alvaro
>
>
> |-|
> Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier
> celular y Nextel
> en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS
> y GPRS online
>   Visitenos en www.perusms.com
>
>
> Le sam. 16 févr. 2019 à 02:50, SATISH  a écrit :
>
>> Hi Caroline,
>>
>> Thank you for your email.
>>
>> Could you please confirm, the format I am using in cron is it correct?
>>
>> #test report
>> 30 17   __KOHA_USER__ $KOHA_CRON_PATH/runreport.pl 141 --format=text
>> --to=
>> lis4sat...@gmail.com
>>
>> Also,  I would like to get the report in -  tab delimited format or csv
>> format.
>>
>> Thank you
>> Satish
>> ___
>> Koha mailing list  http://koha-community.org
>> Koha@lists.katipo.co.nz
>> https://lists.katipo.co.nz/mailman/listinfo/koha
>>
>
___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-02-18 Thread Alvaro Cornejo
Hi

I guess you should use  --format=cvs ... and maybe --cvs-header

Regards,

Alvaro

|-|
Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier
celular y Nextel
en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS
y GPRS online
  Visitenos en www.perusms.com


Le sam. 16 févr. 2019 à 02:50, SATISH  a écrit :

> Hi Caroline,
>
> Thank you for your email.
>
> Could you please confirm, the format I am using in cron is it correct?
>
> #test report
> 30 17   __KOHA_USER__ $KOHA_CRON_PATH/runreport.pl 141 --format=text --to=
> lis4sat...@gmail.com
>
> Also,  I would like to get the report in -  tab delimited format or csv
> format.
>
> Thank you
> Satish
> ___
> Koha mailing list  http://koha-community.org
> Koha@lists.katipo.co.nz
> https://lists.katipo.co.nz/mailman/listinfo/koha
>
___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-02-15 Thread SATISH
Hi Caroline,

Thank you for your email.

Could you please confirm, the format I am using in cron is it correct?

#test report
30 17   __KOHA_USER__ $KOHA_CRON_PATH/runreport.pl 141 --format=text --to=
lis4sat...@gmail.com

Also,  I would like to get the report in -  tab delimited format or csv
format.

Thank you
Satish
___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-02-15 Thread Caroline Cyr-La-Rose

There is already the runreport.pl cronjob that can do this.

https://koha-community.org/manual/18.11/en/html/cron_jobs.html#run-report

Le 19-02-15 à 10 h 28, Alvaro Cornejo a écrit :

Hi Satish

Always CC koha list so you can have more feedbacks  and others can profit
from discussion.

You can start with the example Paul provided. I don't know perl but seems
complete; however you need to define/create your query. If you don't know
perl, you can use any language you know.

You can place it in any where you want -you must add-its path to the cron
line-. Koha have a cgi-script folder you might want to use or create one
for your specific scripts. It must also have the permissions required for
it to be run by your cron and access your database.

As Paul said, once you have your script ready you need to add a line in
your daily cron for it to execute.

Regards,

Alvaro
|-|
Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier
celular y Nextel
en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS
y GPRS online
   Visitenos en www.perusms.com


Le ven. 15 févr. 2019 à 01:16, SATISH  a écrit :


Hi Alvaro,

Thank you for your email, could you please do little elaborate on how to
write a script or could share some
example script. Where this script should be placed (path) and permissions.

Tks.
Satish

On Thu, 14 Feb 2019 at 19:03, Alvaro Cornejo 
wrote:


Hi

If already have an report for this, you can define it as public and
create a small script -in the language of your choice- that runs it and
insert an entry in cron jobs.

You can even create the whole report in your script accessing directly to
your database.

Regards,

Alvaro



___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


--
Caroline Cyr La Rose, M.L.I.S.
Librarian | Product Manager

Phone: 1-833-465-4276, ext. 221
caroline.cyr-la-r...@inlibro.com 

INLiBRO | Document Technologies Specialists | www.inLibro.com 


___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-02-15 Thread Alvaro Cornejo
Hi Satish

Always CC koha list so you can have more feedbacks  and others can profit
from discussion.

You can start with the example Paul provided. I don't know perl but seems
complete; however you need to define/create your query. If you don't know
perl, you can use any language you know.

You can place it in any where you want -you must add-its path to the cron
line-. Koha have a cgi-script folder you might want to use or create one
for your specific scripts. It must also have the permissions required for
it to be run by your cron and access your database.

As Paul said, once you have your script ready you need to add a line in
your daily cron for it to execute.

Regards,

Alvaro
|-|
Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier
celular y Nextel
en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS
y GPRS online
  Visitenos en www.perusms.com


Le ven. 15 févr. 2019 à 01:16, SATISH  a écrit :

> Hi Alvaro,
>
> Thank you for your email, could you please do little elaborate on how to
> write a script or could share some
> example script. Where this script should be placed (path) and permissions.
>
> Tks.
> Satish
>
> On Thu, 14 Feb 2019 at 19:03, Alvaro Cornejo 
> wrote:
>
>> Hi
>>
>> If already have an report for this, you can define it as public and
>> create a small script -in the language of your choice- that runs it and
>> insert an entry in cron jobs.
>>
>> You can even create the whole report in your script accessing directly to
>> your database.
>>
>> Regards,
>>
>> Alvaro
>>
>>
___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-02-14 Thread Katrin Fischer

Hi,

I think it might not be well known, but Koha has already a command line
script that you can run as a cronjob to email you the results of any report:

http://git.koha-community.org/gitweb/?p=koha.git;a=blob;f=misc/cronjobs/runreport.pl

Hope this helps!

Katrin


On 14.02.19 18:33, Paul Hoffman wrote:

On Thu, Feb 14, 2019 at 12:30:59PM +0530, SATISH wrote:

I need to keep print copy of daily transactions (cumulative) report for
check-out & check-in transactions that is from library
opening hours to closing hours every day. Currently I am running sql for
date range for check-in & check-out.

[...]

But, I am looking for using same sql report automatically through an email
on every day basis.

Here's one way to do it.  Start with a file that contains the SQL for
the report, preceded by a suitable e-mail header:

- /path/to/your/reports/foobar -
From: some.email.addr...@example.com
To: some.other.email.addr...@example.com, etc.etc@example.com
Subject: The report you asked for
Content-Type: text/plain

SELECT ...
FROM   ...
WHERE  ...


Then write a Perl script that runs the report and sends the results in
tab-delimited format:

--- /path/to/run-reports.pl 
#!/usr/bin/perl

use strict;
use warnings;

use C4::Context;

my $dbh = connect_to_database();

# Expand file globs
if (@ARGV == 1 && $ARGV[0] =~ /[*]/) {
 @ARGV = glob(@ARGV);
}
die "No reports to run" if !@ARGV;

# Run report(s)
foreach my $file (@ARGV) {
 open STDIN, '<', $file
 or die "Can't open $file: $!";
 my $header = read_header();
 my $sql= read_sql();
 my $sender = find_sender($header);
 my $sth= prepare_sql($sql);
 my $fh = start_sendmail($sender);
 print $fh $header;
 print $fh columns_header($sth);
 while (my @row = $sth->fetchrow_array) {
 print $fh tab_delimited(@row);
 }
 close $fh or die "Close sendmail handle: $!";
 close STDIN;
}

# Functions

sub connect_to_database {
 my $dbh = C4::Context->dbh;
 $dbh->{RaiseError} = 1;
 return $dbh;
}

sub find_sendmail {
 foreach (qw(/sbin/sendmail /usr/sbin/sendmail /bin/sendmail 
/usr/bin/sendmail)) {
 return $_ if -x $_;
 }
 die "Can't find sendmail";
}

sub read_header {
 my $header = '';
 while (<>) {
 $header .= $_;
 last if /^\r?$/;
 }
 return $header;
}

sub find_sender {
 my ($header) = @_;
 foreach (split /\n/, $header) {
 return email($1) if /^From:\s+(.+)/;
 }
 die "No sender found in e-mail header";
}

sub email {
 local $_ = shift;
 return $1 if /^([^@\s]+\@[^@\s]+)\b/;
 return $1 if /^.+ <([^<>\s]+)>/;
 die "Can't find sender e-mail address";
}

sub read_sql {
 # Read the SQL
 local $/;
 my $sql = <>;
 return $sql;
}

sub prepare_sql {
 my $sql = shift;
 my $sth = $dbh->prepare($sql);
 $sth->execute(@_);
 return $sth;
}

sub start_sendmail {
 my ($sender) = @_;
 my $sendmail = find_sendmail();
 open my $fh, '|-', $sendmail, qw(-oi -oem -t -f), $sender
 or die "Can't exec $sendmail: $!";
 return $fh;
}

sub columns_header {
 my ($sth) = @_;
 return join("\t", @{ $sth->{'NAME'} }) . "\n";
}

sub tab_delimited {
 return join("\t", map { defined $_ ? $_ : '' } @_) . "\n";
}


Then use koha-shell to run them:

[as root]
# koha-shell YOURINSTANCE -c '/path/to/run-reports.pl /path/to/your/reports/*'

I'll leave the rest to you -- cron, etc.

Paul.


___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-02-14 Thread Paul Hoffman
On Thu, Feb 14, 2019 at 12:30:59PM +0530, SATISH wrote:
> I need to keep print copy of daily transactions (cumulative) report for
> check-out & check-in transactions that is from library
> opening hours to closing hours every day. Currently I am running sql for
> date range for check-in & check-out.
> 
> [...]
> 
> But, I am looking for using same sql report automatically through an email
> on every day basis.

Here's one way to do it.  Start with a file that contains the SQL for 
the report, preceded by a suitable e-mail header:

- /path/to/your/reports/foobar -
From: some.email.addr...@example.com
To: some.other.email.addr...@example.com, etc.etc@example.com
Subject: The report you asked for
Content-Type: text/plain

SELECT ...
FROM   ...
WHERE  ...


Then write a Perl script that runs the report and sends the results in
tab-delimited format:

--- /path/to/run-reports.pl 
#!/usr/bin/perl

use strict;
use warnings;

use C4::Context;

my $dbh = connect_to_database();

# Expand file globs
if (@ARGV == 1 && $ARGV[0] =~ /[*]/) {
@ARGV = glob(@ARGV);
}
die "No reports to run" if !@ARGV;

# Run report(s)
foreach my $file (@ARGV) {
open STDIN, '<', $file
or die "Can't open $file: $!";
my $header = read_header();
my $sql= read_sql();
my $sender = find_sender($header);
my $sth= prepare_sql($sql);
my $fh = start_sendmail($sender);
print $fh $header;
print $fh columns_header($sth);
while (my @row = $sth->fetchrow_array) {
print $fh tab_delimited(@row);
}
close $fh or die "Close sendmail handle: $!";
close STDIN;
}

# Functions

sub connect_to_database {
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
return $dbh;
}

sub find_sendmail {
foreach (qw(/sbin/sendmail /usr/sbin/sendmail /bin/sendmail 
/usr/bin/sendmail)) {
return $_ if -x $_;
}
die "Can't find sendmail";
}

sub read_header {
my $header = '';
while (<>) {
$header .= $_;
last if /^\r?$/;
}
return $header;
}

sub find_sender {
my ($header) = @_;
foreach (split /\n/, $header) {
return email($1) if /^From:\s+(.+)/;
}
die "No sender found in e-mail header";
}

sub email {
local $_ = shift;
return $1 if /^([^@\s]+\@[^@\s]+)\b/;
return $1 if /^.+ <([^<>\s]+)>/;
die "Can't find sender e-mail address";
}

sub read_sql {
# Read the SQL
local $/;
my $sql = <>;
return $sql;
}

sub prepare_sql {
my $sql = shift;
my $sth = $dbh->prepare($sql);
$sth->execute(@_);
return $sth;
}

sub start_sendmail {
my ($sender) = @_;
my $sendmail = find_sendmail();
open my $fh, '|-', $sendmail, qw(-oi -oem -t -f), $sender
or die "Can't exec $sendmail: $!";
return $fh;
}

sub columns_header {
my ($sth) = @_;
return join("\t", @{ $sth->{'NAME'} }) . "\n";
}

sub tab_delimited {
return join("\t", map { defined $_ ? $_ : '' } @_) . "\n";
}


Then use koha-shell to run them:

[as root]
# koha-shell YOURINSTANCE -c '/path/to/run-reports.pl /path/to/your/reports/*'

I'll leave the rest to you -- cron, etc.

Paul.

-- 
Paul Hoffman 
Software Manager
Fenway Library Organization
550 Huntington Ave.
Boston, MA 02115
617-989-5032
___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-02-14 Thread Alvaro Cornejo
Hi

If already have an report for this, you can define it as public and create
a small script -in the language of your choice- that runs it and insert an
entry in cron jobs.

You can even create the whole report in your script accessing directly to
your database.

Regards,

Alvaro
|-|
Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier
celular y Nextel
en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS
y GPRS online
  Visitenos en www.perusms.com


Le jeu. 14 févr. 2019 à 06:07, SATISH  a écrit :

> Hi,
>
> There is bug (3935) registered for the same problem already
> ___
> Koha mailing list  http://koha-community.org
> Koha@lists.katipo.co.nz
> https://lists.katipo.co.nz/mailman/listinfo/koha
>
___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-02-14 Thread SATISH
Hi,

There is bug (3935) registered for the same problem already
___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha


Re: [Koha] How to receive reports to email

2019-02-13 Thread SATISH
Hi,

I am not referring to check-out and check-in messages through email for a
single or multiple transactions of a particular user.
We are getting email notifications to check-in/check-out/reminders/ etc.

I need to keep print copy of daily transactions (cumulative) report for
check-out & check-in transactions that is from library
opening hours to closing hours every day. Currently I am running sql for
date range for check-in & check-out.

Instead of running check-out or desired report using sql and saving to  csv
or some other format has to be performed manually.

But, I am looking for using same sql report automatically through an email
on every day basis.
So that, I could easily get the print done from single mail without running
sql manually and also I could assign printing and filing job to
other library staff in the library who do not have access to Koha but
access to Library Email.

Therefore, I am looking for  email communication on  complete transactions
(cumulative) report   for check-out or check-in in a single mail on daily
basis.

With regards
Satish
Librarian
Govt. Engineering College, Hassan.
Karnataka
___
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/listinfo/koha