#!/bin/sh mail=0 warnmail=0 eval `ckconfig -s || /var/local/stat/bin/ckconfig -s` eval `$binDir/configuration` if [ "$1" = "" -o "$2" = "" ] ; then echo "Usage : "$0" MM username|ALL [MAIL]" exit else Month=$1 users=$2 if [ "$3" = "MAIL" ] ; then mail=1 fi fi Account=$homeDir/data/$Year/$Month/account tmp=$tmpDir/.report PATH=$binDir:$PATH export PATH echo "Starting MakeStat." CurMonth=`date +%m` if [ $Month -ne $CurMonth ] ; then monthstat=1 else monthstat=0 fi if [ "$users" = "ALL" ] ; then users=`$binDir/ulist` fi for user in $users do echo -n "." change=0 warnmail=0 subject="" class=`grep -w $user $UserStatus | awk '{print $2}'` status=`grep -w $user $UserStatus | awk '{print $3}'` date=`grep -w $user $UserStatus | awk '{print $4}'` comment=`grep -w $user $UserStatus | awk '{print $5}'` report=$userBase/$user/$user\.$Month rm -f $report > /dev/null if [ "$comment" = "english" ] ; then case $Month in "01") TxtMonth="JANUARY" ;; "02") TxtMonth="FEBRUARY" ;; "03") TxtMonth="MARCH" ;; "04") TxtMonth="APRIL" ;; "05") TxtMonth="MAY" ;; "06") TxtMonth="JUNE" ;; "07") TxtMonth="JULY" ;; "08") TxtMonth="AUGUST" ;; "09") TxtMonth="SEPTEMBER" ;; "10") TxtMonth="OCTOBER" ;; "11") TxtMonth="NOVEMBER" ;; "12") TxtMonth="DECEMBER" ;; esac else case $Month in "01") TxtMonth="ЯНВАРЬ" ;; "02") TxtMonth="ФЕВРАЛЬ" ;; "03") TxtMonth="МАРТ" ;; "04") TxtMonth="АПРЕЛЬ" ;; "05") TxtMonth="МАЙ" ;; "06") TxtMonth="ИЮНЬ" ;; "07") TxtMonth="ИЮЛЬ" ;; "08") TxtMonth="АВГУСТ" ;; "09") TxtMonth="СЕНТЯБРЬ" ;; "10") TxtMonth="ОКТЯБРЬ" ;; "11") TxtMonth="НОЯБРЬ" ;; "12") TxtMonth="ДЕКАБРЬ" ;; esac fi if [ $monthstat -eq 1 ] ; then if [ "$comment" = "english" ] ; then echo " Dear User !" >> $report echo " There is your statistics for "$TxtMonth" of 1996 year." >> $report echo >> $report subject="[+] Statistics for "$TxtMonth" of 1996 year." else echo " Уважаемый Абонент ! " >> $report echo " Высылаем Вам статистику за "$TxtMonth" месяц 1996 года." >> $report echo >> $report subject="[+] Статистика за "$TxtMonth" месяц 1996 года." fi fi Shift=`expr $CurMonth - $Month` table="%stattable -"$Shift":-"$Shift"%" accline=`grep -w $user $Account` >> /dev/null if [ "$class" = "normal" -a "$status" != "closed" ] ; then echo -n "." saldo=`echo $accline | awk '{printf ("%d",$5) }'` if [ $saldo -lt 0 ] ; then saldo=`expr $saldo \* -1` finaldate=`$binDir/plusdate 8 | awk '{print $1"."$2"."$3}'` if [ $monthstat -ne 1 ] ; then warnmail=1 fi if [ "$status" != "warned" ] ; then status="warned" finaldate=`$binDir/plusdate 8 | awk '{print $1"."$2"."$3}'` change=1 else finaldate=`$binDir/plusdate 8 $date | awk '{print $1"."$2"."$3}'` fi if [ "$comment" = "english" ] ; then echo " A T T E N T I O N !!!" >> $report echo " You have debt on your account "$saldo" rbl. without taxes (20%)." >> $report echo " So, you may pay it till "$finaldate" and pay minimum of 150000" >> $report echo " roubles more for future work." >> $report echo " If you'll not pay us till "$finaldate" your computer would be" >> $report echo " disconnected out off net." >> $report echo " We can send you a bill if you want it." >> $report echo >> $report else echo " В Н И М А Н И Е !!!" >> $report echo " За Вами имеется задолженность "$saldo" руб. без учета НДС (20%)." >> $report echo " Просьба до "$finaldate" оплатить задолженность и внести аванс в" >> $report echo " размере не менее 150000 руб." >> $report echo " В противном случае после "$finaldate" Вы будете отключены от сети" >> $report echo " без предупреждения." >> $report echo " Если необходимо Вам может быть выписан счет." >> $report echo >> $report fi if [ "$subject" = "" ] ; then if [ "$comment" = "english" ] ; then subject="[+] THERE IS NO MONEY ON YOUR ACCOUNT !!!" else subject="[+] ИСЧЕРПАНИЕ СРЕДСТВ НА СЧЕТУ !!!" fi fi elif [ $saldo -lt 30000 ] ; then if [ "$status" != "notify3" ] ; then if [ "$comment" = "english" ] ; then echo " A T T E N T I O N !!!" >> $report echo " You don't have enough money on your account to work during this" >> $report echo " month. We suppose you to watch out for a minimum of 150000 roubles" >> $report echo " on your account." >> $report echo >> $report else echo " В Н И М А Н И Е !!!" >> $report echo " На Вашем счету осталась сумма, которой Вам может не хватить на" >> $report echo " работу в текущем месяце. Просьба внимательно следить за состоя-" >> $report echo " нием Вашего счета и поддерживать на нем сумму не менее 150000 руб." >> $report echo >> $report fi if [ "$subject" = "" ] ; then if [ "$comment" = "english" ] ; then subject="[+] Pay us some money IMMEDIATLY, please !" else subject="[+] Просьба СРОЧНО внести предоплату !" fi fi status="notify3" change=1 warnmail=1 fi elif [ $saldo -lt 60000 ] ; then if [ "$status" != "notify2" ] ; then if [ "$comment" = "english" ] ; then echo " A T T E N T I O N !!!" >> $report echo " You don't have enough money on your account to work during this" >> $report echo " month. We suppose you to watch out for a minimum of 150000 roubles" >> $report echo " on your account." >> $report echo >> $report else echo " В Н И М А Н И Е !!!" >> $report echo " На Вашем счету осталась сумма, которой Вам может не хватить на" >> $report echo " работу в текущем месяце. Просьба внимательно следить за состоя-" >> $report echo " нием Вашего счета и поддерживать на нем сумму не менее 150000 руб." >> $report echo >> $report fi if [ "$subject" = "" ] ; then if [ "$comment" = "english" ] ; then subject="[+] Pay us some money, please !" else subject="[+] Просьба внести предоплату !" fi fi status="notify2" change=1 warnmail=1 fi elif [ $saldo -lt 100000 ] ; then if [ "$status" != "notify1" ] ; then if [ "$comment" = "english" ] ; then echo " A T T E N T I O N !!!" >> $report echo " You don't have enough money on your account to work during next" >> $report echo " month. We suppose you to watch out for a minimum of 150000 roubles" >> $report echo " on your account." >> $report echo >> $report else echo " В Н И М А Н И Е !!!" >> $report echo " На Вашем счету осталась сумма, которой Вам может не хватить на" >> $report echo " работу в следующем месяце. Просьба внимательно следить за состоя-" >> $report echo " нием Вашего счета и поддерживать на нем сумму не менее 150000 руб." >> $report echo >> $report fi if [ "$subject" = "" ] ; then if [ "$comment" = "english" ] ; then subject="[+] Pay us some money, please !" else subject="[+] Просьба внести предоплату !" fi fi status="notify1" change=1 warnmail=1 fi fi if [ $change = 1 ] ; then # userst=`grep -w $user $UserStatus` # grep -v -w $user $UserStatus > $tmp # echo $userst | awk '{printf ("%s %s",$1,$2)}' >> $tmp # echo " "$status" "`date +%d\.%m\.%y` >> $tmp # echo $userst | awk '{printf (" %s",$5)}' >> $tmp # sort $tmp > $UserStatus # rm -f $tmp $binDir/setstatus $user $status fi fi status=`grep -w $user $UserStatus | awk '{print $3}'` $binDir/mkreport -u$user -o$tmp =report.fm cat $tmp >> $report rm -f $tmp echo -n "." if [ "$comment" = "english" ] ; then echo " +============================ Your accounting ========================+" >> $report else echo " +========================= Состояние ЛС абонента =====================+" >> $report fi if [ $monthstat -eq 1 ] ; then if [ "$comment" = "english" ] ; then echo " | Month beginning | Your pays | You spent | To the end of month |" >> $report else echo " | К началу месяца | Перечислено | Наработал | Остаток на конец месяца |" >> $report fi else if [ "$comment" = "english" ] ; then echo " | Month beginning | Your pays | You spent | Your money on "`date +%d\.%m\.%y`" |" >> $report else echo " | К началу месяца | Перечислено | Наработал | Остаток на "`date +%d\.%m\.%y`" |" >> $report fi fi echo " +-----------------+-------------+-----------+-------------------------+" >> $report echo $accline | awk '{ printf (" | %13.2f | %9.2f | %9.2f | %16.2f |\n",$2,$4,$3,$5)}' >> $report echo " +---------------------------------------------------------------------+" >> $report if [ "$comment" = "english" ] ; then echo " | All data is shown in roubles without tax (20%) |" >> $report else echo " | Все суммы указаны в рублях без учета НДС (20%) |" >> $report fi echo " +=====================================================================+" >> $report echo >> $report echo $table | $binDir/mkreport -u$user - >> $report if [ "$status" = "warned" ] ; then if [ "$comment" = "english" ] ; then echo " This message would be repeated every day till the moment when you pay" >> $report echo " us or your disconnection out off the net." >> $report echo >> $report else echo " Это сообщение будет повторяться ежедневно до момента оплаты или Вашего" >> $report echo " отключения от сети." >> $report echo >> $report fi fi if [ "$comment" = "english" ] ; then echo " You can ask any questions by phone (0912) 44-48-04 or E-Mail us" >> $report echo " on the postmaster@ineco.ryazan.su" >> $report echo >> $report echo " Automatic Statistics Server of ineco node" >> $report echo " P.S. Sorry for bad english." >> $report echo >> $report else echo " Все вопросы Вы можете задать по телефону (0912) 44-48-04" >> $report echo " или по адресу postmaster@ineco.ryazan.su" >> $report echo >> $report echo " С уважением, сервер статистики узла ineco" >> $report echo >> $report echo " ПВП \"Связь-Сервис-Ирга\" Директор ____________ /Сазонов В.В./ " >> $report fi if [ $mail -eq 1 -o $warnmail -eq 1 ] ; then echo $subject > /tmp/.subject $binDir/sendstat $user $report rm -f /tmp/.subject fi echo -n ":" done echo echo "MakeStat finished."