Witam Ja mam 3 templejty i wysyłam je codziennie (bo codziennie może zajść jedna z trzech sytuacji): 1. Do userów którym właśnie naliczył się abonament: lms-notify -D 1st-time -P 0 2. Do userów, którym trzeba przypomnieć, że mija termin płatności: lsm-notify -D 2nd-time -P 13 3. Do userów, których muszę ostrzec przed automatycznym odcięciem: lms-notify -D 3th-time -P 20 gdzie P to liczba dni wstecz. -- pozdrawiam Paweł Rohde [patt] [gadu-gadu: 755284 mail:pawel_NOSPAM@rohde.poznan.pl ] [komórka : 501 433 051 ] --- lms-notify~ 2004-10-07 01:27:30.000000000 +0200 +++ lms-notify 2004-10-07 01:39:05.000000000 +0200 @@ -32,10 +32,14 @@ my $_version = '1.4.0rc4 Evalla'; my $my_template; +my $DaysAfter; +my $curr_date = strftime("%s",localtime()); + my %options = ( "--config-file|C=s" => \$configfile, "--template-file|D=s" => \$my_template, + "--DaysAfter|P=s" => \$DaysAfter, "--quiet|q" => \$quiet, "--help|h" => \$help, "--version|v" => \$version @@ -53,6 +57,7 @@ -C, --config-file=/etc/lms/lms.ini alternate config file (default: /etc/lms/lms.ini); -D, --template-file=/etc/lms/another.template.txt alternate (default in config file); -h, --help print this help and exit; +-P, --DaysAfter Days delay notify; -v, --version print version info and exit; -q, --quiet suppress any output, except errors; @@ -163,12 +168,17 @@ my @mtempl = <MTFILE>; close MTFILE; -my $dbq = $dbase->prepare("SELECT users.id AS id, pin, lastname, name, email, phone1, SUM((type * -2 + 7) * cash.value) AS balance FROM users LEFT JOIN cash ON users.id = cash.userid GROUP BY users.id, pin, lastname, name, email, phone1 HAVING SUM((type * -2 + 7) * cash.value) < 0"); +my $dbq = $dbase->prepare("SELECT users.id AS id, pin, lastname, name, email, phone1, SUM((type * -2 + 7) * cash.value) AS balance, MAX(cash.time) as paytime FROM users LEFT JOIN cash ON users.id = cash.userid GROUP BY users.id HAVING SUM((type * -2 + 7) * cash.value) < 0"); + $dbq->execute(); while (my $row = $dbq->fetchrow_hashref()) { my $balance = $row->{'balance'}; - if($balance < $limit) + + my $IleDni = ($curr_date - (defined $row->{'paytime'} ? $row->{'paytime'} : 0))/86400; + + if($balance < $limit and $IleDni > $DaysAfter and $IleDni < $DaysAfter+1) { if(!$quiet) {