#!/bin/sh # eval `ckconfig -s || /var/local/stat/bin/ckconfig -s` eval `$binDir/configuration` tmp=$tmpDir/account tmppays=$tmpDir/pays PATH=$binDir:$PATH export PATH if [ "$1" = "" ] ; then users=`$binDir/ulist` else users=$1 fi if [ "$2" != "" ] ; then Month=$2 fi CurMonth=`date +%m` if [ $Month -gt $CurMonth ] ; then echo Invalid month number: $Month exit fi accDir=$homeDir/data/$Year/$Month Account=$accDir/account acctmp=$Account\.tmp errors=$Account\.err if [ ! -d $accDir ] ; then mkdir $accDir fi if [ -f $acctmp ] ; then rm -f $acctmp fi StartDate=$Year$Month\01 EndDate=$Year$Month\31 Delay1=`expr $CurMonth - $Month` Delay2=`expr $CurMonth - $Month + 1` echo Accounting... for user in $users do echo -n $user" " start=0 end=0 work=0 start=`echo "%total -$Delay2:-$Delay2%" | mkreport -u$user -` end=`echo "%total -$Delay1:-$Delay1%" | mkreport -u$user -` work=`echo "%stat -$Delay1:-$Delay1%" | mkreport -u$user -` echo "SELECT date,user,roubles FROM accounts WHERE roubles>0 AND date>=$StartDate AND date<=$EndDate AND user='$user' AND flag=0 ORDER BY date \g" | /usr/local/Minerva/bin/msql statserv | grep "| $user" | awk '{sum=sum+$6; printf("%10.2f\n",sum) }' > $tmppays pays=`tail -1 $tmppays` if [ "$pays" = "" ] ; then pays=0.00 fi end1=`echo $start $work $pays | awk '{printf("%10.2f",$1-$2+$3)}'` echo $user $start $work $pays $end | awk '{printf ("%-10s %15s %15s %15s %15s\n",$1,$2,$3,$4,$5)}' > $tmp minus=`echo $end1 $end | awk '{printf ("%3.2f",$2-$1)}'` if [ "$minus" != "0.00" ] ; then echo `date +%d.%m.%y`": $user: На счету: "$end", должно быть: "$end1", разница: "$minus >>$errors fi grep -v -w $user $Account > $acctmp cat $tmp >> $acctmp sort $acctmp > $Account rm -f $acctmp $tmp $tmppays done echo