#!/usr/bin/perl use Digest::MD5 qw(md5 md5_hex md5_base64); use Net::MySQL; $mysql = Net::MySQL->new(hostname=>'0.0.0.0', database=>'', user=>'', password=>''); $VERSION="1.0.0"; $TABELNAAM="transacties"; $passen[0]="pasnr. 001"; $passen[1]="pasnr. 002"; $passen[2]="pasnr. 003"; $passenNaam{'pasnr. 011'}="Pas 1"; $passenNaam{'pasnr. 010'}="Pas 2"; $passenNaam{'pasnr. 012'}="Pas 3"; $categorie[0]="Huis"; $categorie[1]="Auto"; $categorie[2]="Boodschappen"; $categorie[3]="Diverse"; $categorie[4]="Donatie"; $categorie[5]="Gokken"; $categorie[6]="Telefoon"; $categorie[7]="Verzekering"; $categorie[8]="Salaris"; $categorie[9]="Spaargeld"; $categorie[10]="Geld Pinnen"; $categorie[11]="TV / Internet"; $categorie[12]="Hond"; $categorie[13]="Kleding"; $categorie[14]="Belasting"; $categorie[15]="Lekker eten"; $categorie[16]="Tuin"; $categorie[17]="Verzorging"; $categorie[18]="Bank"; $categorie[19]="Rijles"; $categorie[20]="Trouwen"; $categorie[21]="Reizen"; $categorie[22]="I-deal"; $categorie[23]="Geld van andere"; $categorie[24]="Geld naar andere"; $categorie[25]="Eigen rekening"; $categorie[26]="Loterij"; $categorie[27]="Klussen"; @categorie = sort @categorie; $maandenNaam[0]="Jan"; $maandenNaam[1]="Feb"; $maandenNaam[2]="Mrt"; $maandenNaam[3]="Apr"; $maandenNaam[4]="Mei"; $maandenNaam[5]="Jun"; $maandenNaam[6]="Jul"; $maandenNaam[7]="Aug"; $maandenNaam[8]="Sep"; $maandenNaam[9]="Okt"; $maandenNaam[10]="Nov"; $maandenNaam[11]="Dec"; $maanden[0]="1"; $maanden[1]="2"; $maanden[2]="3"; $maanden[3]="4"; $maanden[4]="5"; $maanden[5]="6"; $maanden[6]="7"; $maanden[7]="8"; $maanden[8]="9"; $maanden[9]="10"; $maanden[10]="11"; $maanden[11]="12"; $maandNaarNaam{'1'}="Januari"; $maandNaarNaam{'2'}="Februari"; $maandNaarNaam{'3'}="Maart"; $maandNaarNaam{'4'}="April"; $maandNaarNaam{'5'}="Mei"; $maandNaarNaam{'6'}="Juni"; $maandNaarNaam{'7'}="Juli"; $maandNaarNaam{'8'}="Augustus"; $maandNaarNaam{'9'}="September"; $maandNaarNaam{'10'}="Oktober"; $maandNaarNaam{'11'}="November"; $maandNaarNaam{'12'}="December"; $maandNaarNaamKort{'1'}="Jan"; $maandNaarNaamKort{'2'}="Feb"; $maandNaarNaamKort{'3'}="Mrt"; $maandNaarNaamKort{'4'}="Apr"; $maandNaarNaamKort{'5'}="Mei"; $maandNaarNaamKort{'6'}="Jun"; $maandNaarNaamKort{'7'}="Jul"; $maandNaarNaamKort{'8'}="Aug"; $maandNaarNaamKort{'9'}="Sep"; $maandNaarNaamKort{'10'}="Okt"; $maandNaarNaamKort{'11'}="Nov"; $maandNaarNaamKort{'12'}="Dec"; # ============================================================================================== # =============================================== CREATE TABLE TRANSACTIES ===================== # DROP TABLE IF EXISTS transacties; # CREATE TABLE IF NOT EXISTS transacties ( # id int(11) NOT NULL auto_increment, # eigenrekening varchar(15) default NULL, # valuta varchar(5) default NULL, # datum date default NULL, # debetcredit varchar(1) default NULL, # bedrag float default NULL, # naarrekening varchar(20) default NULL, # naam varchar(60) default NULL, # datum2 date default NULL, # `type` varchar(5) default NULL, # omschrijving1 varchar(100) default NULL, # omschrijving2 varchar(100) default NULL, # omschrijving3 varchar(100) default NULL, # `hash` varchar(50) default NULL, # categorie varchar(50) default NULL, # PRIMARY KEY (id) # ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1; #=============================================================================================== #========== Gegevens uit query halen =========================================================== #=============================================================================================== $datalen = $ENV{'QUERY_STRING'}; read (STDIN, $querystring, $datalen); @namevaluepairs = split (/&/, $datalen); $n = 0; foreach $namevalue (@namevaluepairs) { ($name[$n], $value[$n]) = split ( /=/, $namevalue ); $value[$n]=~ tr/\<\>//d; $value[$n]=~ tr/\`//d; $key{$name[$n]}=$value[$n]; $n++; } # ======================================== POST STUK =========================================== $content_len = $ENV{'CONTENT_LENGTH'}; binmode STDIN; read(STDIN, $buffer, $content_len); @namevaluepairs = split (/&/, $buffer); $n = 0; foreach $namevalue (@namevaluepairs) { ($nameP[$n], $valueP[$n]) = split ( /=/, $namevalue ); $valueP[$n]=~ tr/\<\>//d; $valueP[$n]=~ tr/\`//d; $key{$nameP[$n]}=$valueP[$n]; $n++; } # ======================================== MULTIPART STUK ====================================== $content_type = $ENV{'CONTENT_TYPE'}; if ($content_type =~ m#^multipart/form-data#) { ($boundary = $content_type) =~ s/^.*boundary="?(.*?)"?$/\1/; @pairs = split(/\ name=\"/, $buffer); foreach $part(@pairs) { if ($part =~ /filename/) { ($line1, $line2, $line3) = split (/\r\n/, $part, 3); ($name, $value) = split (/\"\;\ /, $line1, 2); ($tmp, $value) = split (/filename\=\"/, $value); ($value, $tmp) = split (/\"/, $value); ($dump,$line3) = split(/\r\n/,$line3,2); ($line3, $tmp) = split (/--$boundary/, $line3); $data{$name}=$line3; } else { ($line1, $line2, $line3, $tmp) = split (/\r\n/, $part, 4); ($name, $tmp) = split (/\"/, $line1); ($value, $tmp) = split (/\"/, $line3); } $value=~ tr/\<\>//d; $value=~ tr/\`//d; $key{$name}=$value; } } while ( my ($keytje, $valuetje) = each(%key) ) { $key{$keytje}=~s/%([\dA-Fa-f][\dA-Fa-f])/pack("C",hex($1))/eg; $key{$keytje}=~tr/+/ /; } print "Content-type: text/html\n\n"; print ""; print ""; print "Rabobank - Inkomen en Uitgave ($VERSION)"; print ""; print ""; if ($key{'action'} eq "cattoevoegen") { $key{'name'}=~ s/\'/\'\'/g; $query="update $TABELNAAM set categorie='$key{'categorie'}' where naam='$key{'name'}'"; $mysql->query($query); $key{'categorie'}=""; } if ($key{'action'} eq "upload") { $tellergedaan=0; $tellernietgedaan=0; (@lines) = split (/\n/, $data{'filename'}); foreach $line (@lines) { $line=~ s/\'/\'\'/g; ($zooi, $eigenrekening, $valuta, $datum, $debitcredit, $bedrag, $rekeningnaar, $naam, $datum2, $type, $onbekend, $omschrijving1, $omschrijving2, $omschrijving3) = split (/^\"|\"\,\"|\"$|\"\,|\,\"/, $line); $digest = md5_hex($line); $aantal_entries_gevonden=0; $query="select count(*) from $TABELNAAM where hash='$digest'"; $mysql->query($query); $record_set = $mysql->create_record_iterator; while ($record = $record_set->each) { $aantal_entries_gevonden=$record->[0]; } if (($aantal_entries_gevonden eq "0") && ($eigenrekening eq "0124824803")) { $categorie_gevonden=""; $query="select categorie from $TABELNAAM where naam='$naam'"; $mysql->query($query); $record_set = $mysql->create_record_iterator; while ($record = $record_set->each) { $categorie_gevonden=$record->[0]; } $query="insert into $TABELNAAM (eigenrekening, valuta, datum, debetcredit, bedrag, naarrekening, naam, datum2, type, omschrijving1, omschrijving2, omschrijving3, hash, categorie) values ('$eigenrekening', '$valuta', '$datum', '$debitcredit', $bedrag, '$rekeningnaar', '$naam', '$datum2', '$type', '$omschrijving1', '$omschrijving2', '$omschrijving2', '$digest','$categorie_gevonden')"; $mysql->query($query); $tellergedaan++; } else { $tellernietgedaan++; } } print "
Er zijn $tellergedaan records geimporteerd en er zijn $tellernietgedaan records niet geimporteerd


"; } # ======================================================================================================================================== # ======================= Rabobank Jaar Overzicht ======================================================================================== # ======================================================================================================================================== if ($key{'page'} eq "") { print "
"; print ""; print ""; print ""; print "
  Rabobank - Inkomsten en Uitgaven ($VERSION)
  FILER:"; if ($key{'jaar'}) { print " Jaar: $key{'jaar'} "; } if ($key{'maand'}) { print " Maand: $maandNaarNaam{$key{'maand'}} "; } if ($key{'categorie'}) { print " Categorie: $key{'categorie'} "; } if ($key{'type'}) { print " Type: $key{'type'} "; } if ($key{'debetcredit'} eq "C") { print " Credit Debet: CREDIT "; } if ($key{'debetcredit'} eq "D") { print " Credit Debet: DEBET "; } if ($key{'pasje'}) { print " Pas: $key{'pasje'} ($passenNaam{$key{'pasje'}})"; } print "
"; # ============================= # ============================= print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; # ====================================================== SALARIS BLOK ===================================================== print ""; # ====================================================== SALARIS BLOK ===================================================== print ""; print "
"; @scope=undef; %transacties=undef; %gevonden=undef; $som1=0; $som2=0; $som3=0; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $teller=0; $query="select year(datum), month(datum), debetcredit, round(sum(bedrag), 2) from $TABELNAAM group by year(datum), month(datum), debetcredit order by year(datum) desc, month(datum) desc"; $mysql->query($query); $record_set = $mysql->create_record_iterator; while ($record = $record_set->each) { $jaar=$record->[0]; $maand=$record->[1]; $debetcredit=$record->[2]; $bedrag=$record->[3]; $transacties{$jaar}{$maand}{$debetcredit}="$bedrag"; if (!$gevonden{$jaar}{$maand}) { $scope[$teller]="$jaar-$maand"; $teller++; } $gevonden{$jaar}{$maand}=1; } $jaarteller=1; foreach $item (@scope) { if ($jaarteller <= 12) { ($jaartje, $maandje) = split (/\-/, $item); $verschil = $transacties{$jaartje}{$maandje}{'C'} - $transacties{$jaartje}{$maandje}{'D'}; if ($bgcolor eq "#EEEEEE") { $bgcolor="#FFFFFF"; } else { $bgcolor="#EEEEEE"; } if (($key{'maand'} eq $maandje) && ($key{'jaar'} eq $jaartje)) { $bgcolor="#FFFF64"; } print ""; print ""; print ""; print ""; if ($verschil < 0) { $color="#FF0000"; } else { $color="#009900"; } print ""; print ""; $som1=$som1+$transacties{$jaartje}{$maandje}{'C'}; $som2=$som2+$transacties{$jaartje}{$maandje}{'D'}; $som3=$som3+$verschil; } $jaarteller++; } print ""; print ""; print ""; print ""; if ($som3 < 0) { $color="#FF0000"; } else { $color="#009900"; } print ""; print ""; print "
Maandelijks In / Uit
MaandInUitVerschil
$jaartje $maandNaarNaam{$maandje}€ $transacties{$jaartje}{$maandje}{'C'}€ $transacties{$jaartje}{$maandje}{'D'}€ ".sprintf("%.2f",$verschil)."
Totaal
 
€ ".sprintf("%.2f",$som1)."
 
€ ".sprintf("%.2f",$som2)."
 
€ ".sprintf("%.2f",$som3)."
 
"; print "
"; @scope=undef; %transacties=undef; %gevonden=undef; $som=0; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; $teller=0; $query="select year(datum), month(datum), round(sum(bedrag), 2) from $TABELNAAM where type='BA' group by year(datum), month(datum) order by year(datum) desc, month(datum) desc"; $mysql->query($query); $record_set = $mysql->create_record_iterator; while ($record = $record_set->each) { $jaar=$record->[0]; $maand=$record->[1]; $bedrag=$record->[2]; $transacties{$jaar}{$maand}="$bedrag"; if (!$gevonden{$jaar}{$maand}) { $scope[$teller]="$jaar-$maand"; $teller++; } $gevonden{$jaar}{$maand}=1; } $jaarteller=1; foreach $item (@scope) { if ($jaarteller <= 12) { ($jaartje, $maandje) = split (/\-/, $item); if ($bgcolor eq "#EEEEEE") { $bgcolor="#FFFFFF"; } else { $bgcolor="#EEEEEE"; } if (($key{'maand'} eq $maandje) && ($key{'jaar'} eq $jaartje)) { $bgcolor="#FFFF64"; } print ""; print ""; print ""; print ""; $betaalautomaten[$jaarteller]=$transacties{$jaartje}{$maandje}; $som=$som+$transacties{$jaartje}{$maandje}; } $jaarteller++; } print ""; print ""; print ""; print "
Betaalautomaat
MaandBedrag
$maandNaarNaam{$maandje}€ $transacties{$jaartje}{$maandje}
Totaal
 
€ ".sprintf("%.2f",$som).""; print "
€ ".sprintf("%.2f",$som/12).""; print "
"; print "
"; @scope=undef; %transacties=undef; %gevonden=undef; $som=0; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; $teller=0; $query="select year(datum), month(datum), round(sum(bedrag), 2) from $TABELNAAM where type='GA' and debetcredit='D' group by year(datum), month(datum) order by year(datum) desc, month(datum) desc"; $mysql->query($query); $record_set = $mysql->create_record_iterator; while ($record = $record_set->each) { $jaar=$record->[0]; $maand=$record->[1]; $bedrag=$record->[2]; $transacties{$jaar}{$maand}="$bedrag"; if (!$gevonden{$jaar}{$maand}) { $scope[$teller]="$jaar-$maand"; $teller++; } $gevonden{$jaar}{$maand}=1; } $jaarteller=1; foreach $item (@scope) { if ($jaarteller <= 12) { ($jaartje, $maandje) = split (/\-/, $item); if ($bgcolor eq "#EEEEEE") { $bgcolor="#FFFFFF"; } else { $bgcolor="#EEEEEE"; } if (($key{'maand'} eq $maandje) && ($key{'jaar'} eq $jaartje)) { $bgcolor="#FFFF64"; } print ""; print ""; print ""; print ""; $pinautomaten[$jaarteller]=$transacties{$jaartje}{$maandje}; $som=$som+$transacties{$jaartje}{$maandje}; } $jaarteller++; } print ""; print ""; print ""; print "
Geldautomaat
MaandBedrag
$maandNaarNaam{$maandje}€ $transacties{$jaartje}{$maandje}
Totaal
 
€ ".sprintf("%.2f",$som).""; print "
€ ".sprintf("%.2f",$som/12).""; print "
"; print "
"; @scope=undef; %transacties=undef; %gevonden=undef; $som=0; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; $teller=0; $query="select year(datum), month(datum), round(sum(bedrag), 2) from $TABELNAAM where type='MA' and debetcredit='D' group by year(datum), month(datum) order by year(datum) desc, month(datum) desc"; $mysql->query($query); $record_set = $mysql->create_record_iterator; while ($record = $record_set->each) { $jaar=$record->[0]; $maand=$record->[1]; $bedrag=$record->[2]; $transacties{$jaar}{$maand}="$bedrag"; if (!$gevonden{$jaar}{$maand}) { $scope[$teller]="$jaar-$maand"; $teller++; } $gevonden{$jaar}{$maand}=1; } $jaarteller=1; foreach $item (@scope) { if ($jaarteller <= 12) { ($jaartje, $maandje) = split (/\-/, $item); if ($bgcolor eq "#EEEEEE") { $bgcolor="#FFFFFF"; } else { $bgcolor="#EEEEEE"; } if (($key{'maand'} eq $maandje) && ($key{'jaar'} eq $jaartje)) { $bgcolor="#FFFF64"; } print ""; print ""; print ""; print ""; $machtigingen[$jaarteller]=$transacties{$jaartje}{$maandje}; $som=$som+$transacties{$jaartje}{$maandje}; } $jaarteller++; } print ""; print ""; print ""; print "
Machtiging
MaandBedrag
$maandNaarNaam{$maandje}€ $transacties{$jaartje}{$maandje}
Totaal
 
€ ".sprintf("%.2f",$som).""; print "
€ ".sprintf("%.2f",$som/12).""; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; $jaarteller=1; $som=0; foreach $item (@scope) { if ($jaarteller <= 12) { ($jaartje, $maandje) = split (/\-/, $item); if ($bgcolor eq "#CCCCCC") { $bgcolor="#DDDDDD"; } else { $bgcolor="#CCCCCC"; } if (($key{'maand'} eq $maandje) && ($key{'jaar'} eq $jaartje)) { $bgcolor="#FFFF64"; } $superTotaal = $pinautomaten[$jaarteller] + $betaalautomaten[$jaarteller]; print ""; print ""; print ""; $som=$som+$superTotaal; } $jaarteller++; } print ""; print "
Totaal
Pin/Betaal
€ ".sprintf("%.2f",$superTotaal)."
€ ".sprintf("%.2f",$som).""; print "
€ ".sprintf("%.2f",$som/12).""; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; $jaarteller=1; $som=0; foreach $item (@scope) { if ($jaarteller <= 12) { ($jaartje, $maandje) = split (/\-/, $item); if ($bgcolor eq "#CCCCCC") { $bgcolor="#DDDDDD"; } else { $bgcolor="#CCCCCC"; } if (($key{'maand'} eq $maandje) && ($key{'jaar'} eq $jaartje)) { $bgcolor="#FFFF64"; } $superTotaal = $pinautomaten[$jaarteller] + $betaalautomaten[$jaarteller] + $machtigingen[$jaarteller]; print ""; print ""; print ""; $som=$som+$superTotaal; } $jaarteller++; } print ""; print "
Totaal
Alles
€ ".sprintf("%.2f",$superTotaal)."
€ ".sprintf("%.2f",$som).""; print "
€ ".sprintf("%.2f",$som/12).""; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; $jaarteller=1; $som=0; foreach $item (@scope) { if ($jaarteller <= 12) { ($jaartje, $maandje) = split (/\-/, $item); if ($bgcolor eq "#FFB9FF") { $bgcolor="#FFD7FF"; } else { $bgcolor="#FFB9FF"; } if (($key{'maand'} eq $maandje) && ($key{'jaar'} eq $jaartje)) { $bgcolor="#FFFF64"; } $superTotaal=0; $query="select round(sum(bedrag), 2) from $TABELNAAM where debetcredit='C' and year(datum)='$jaartje' and month(datum)='$maandje' and categorie='Salaris'"; $mysql->query($query); $record_set = $mysql->create_record_iterator; while ($record = $record_set->each) { $superTotaal=$record->[0]; } print ""; print ""; print ""; $som=$som+$superTotaal; } $jaarteller++; } print ""; print "
Salaris
 
€ ".sprintf("%.2f",$superTotaal)."
€ ".sprintf("%.2f",$som).""; print "
€ ".sprintf("%.2f",$som/12).""; print "
"; print "
"; # ========================================================================================== # ================================= DETAIL OVERZICHT WEERGEVEN ALS DEZE IS AANGEKLIKT ====== if (($key{'jaar'}) && ($key{'maand'})) { print ""; print ""; print ""; print ""; print "
"; $totaal=0; print "
"; print ""; print ""; print ""; print ""; print ""; for ($i=1; $i<=12; $i++) { ($jaartje, $maandje) = split (/\-/, $scope[$i - 1]); print ""; } print ""; $teller=0; if ($key{'type'}) { $query="select categorie, round(sum(bedrag), 2), debetcredit from $TABELNAAM where year(datum)=$key{'jaar'} and month(datum)=$key{'maand'} and type='$key{'type'}' group by categorie, debetcredit order by categorie"; } else { $query="select categorie, round(sum(bedrag), 2), debetcredit from $TABELNAAM where year(datum)=$key{'jaar'} and month(datum)=$key{'maand'} group by categorie, debetcredit order by categorie"; } $mysql->query($query); $record_set = $mysql->create_record_iterator; while ($record = $record_set->each) { $categorie=$record->[0]; $bedrag=$record->[1]; $debetcredit=$record->[2]; $color="#FF0000"; if (($debetcredit eq "c") || ($debetcredit eq "C")) { $bedrag=0 - $bedrag; $color="#009900"; } if ($bgcolor eq "#EEEEEE") { $bgcolor="#FFFFFF"; } else { $bgcolor="#EEEEEE"; } if (($categorie eq $key{'categorie'}) && ($debetcredit eq $key{'debetcredit'})) { $bgcolor="#FFFF64"; } print ""; print ""; $totaal = $totaal + $bedrag; $bedrag=~ s/\-//g; print ""; for ($i=1; $i<=12; $i++) { ($jaartje, $maandje) = split (/\-/, $scope[$i - 1]); $bedrag=0; if ($key{'type'}) { $query2="select round(sum(bedrag), 2) from $TABELNAAM where categorie='$categorie' and debetcredit='$debetcredit' and year(datum)=$jaartje and month(datum)=$maandje and type='$key{'type'}' group by categorie, debetcredit order by categorie"; } else { $query2="select round(sum(bedrag), 2) from $TABELNAAM where categorie='$categorie' and debetcredit='$debetcredit' and year(datum)=$jaartje and month(datum)=$maandje group by categorie, debetcredit order by categorie"; } $mysql->query($query2); $record_set2 = $mysql->create_record_iterator; while ($record2 = $record_set2->each) { $bedrag=$record2->[0]; } $color="#000000"; if (($debetcredit eq "c") || ($debetcredit eq "C")) { $bedrag=0 - $bedrag; $color="#009900"; } $maandTotaal[$maandje]=$maandTotaal[$maandje] + $bedrag; $bedrag=~ s/\-//g; if ($maandje eq $key{'maand'}) { print ""; } else { print ""; } } print ""; } print ""; print ""; $color="#FF0000"; if ($totaal < 0) { $totaal =~ s/\-//g; $color="#009900"; } print ""; for ($i=1; $i<=12; $i++) { ($jaartje, $maandje) = split (/\-/, $scope[$i - 1]); $color="#FF0000"; if ($maandTotaal[$maandje] < 0) { $maandTotaal[$maandje] =~ s/\-//g; $color="#009900"; } print ""; } print ""; print "
Categorie overzicht: $maandNaarNaam{$key{'maand'}}
CategorieBedrag$maandNaarNaam{$maandje}
($debetcredit) $categorie€ ".sprintf("%.2f",$bedrag).""; if ($bedrag != 0) { print "€ ".sprintf("%.2f",$bedrag); } print ""; if ($bedrag != 0) { print "€ ".sprintf("%.2f",$bedrag); } print "
TOTAAL€ ".sprintf("%.2f",$totaal)."€ ".sprintf("%.2f",$maandTotaal[$maandje])."
"; print "
"; } # ========================================================================================== # ========================================================================================== print ""; print ""; print ""; print ""; print "
"; $totaal=0; print "
"; print ""; print ""; print ""; print ""; for ($i=1; $i<=12; $i++) { ($jaartje, $maandje) = split (/\-/, $scope[$i - 1]); print ""; } print ""; foreach $pasje (@passen) { if ($bgcolor2 eq "#EEEEEE") { $bgcolor2="#FFFFFF"; } else { $bgcolor2="#EEEEEE"; } print ""; print ""; for ($i=1; $i<=12; $i++) { ($jaartje, $maandje) = split (/\-/, $scope[$i - 1]); $bedrag=0; if (($key{'type'}) && ($key{'categorie'})) { $query2="select round(sum(bedrag), 2) from $TABELNAAM where categorie='$key{'categorie'}' and year(datum)=$jaartje and month(datum)=$maandje and type='$key{'type'}' and omschrijving1 like '%$pasje%' and debetcredit='$key{'debetcredit'}'"; } elsif ($key{'type'}) { $query2="select round(sum(bedrag), 2) from $TABELNAAM where year(datum)=$jaartje and month(datum)=$maandje and type='$key{'type'}' and omschrijving1 like '%$pasje%'"; } elsif ($key{'categorie'}) { $query2="select round(sum(bedrag), 2) from $TABELNAAM where categorie='$key{'categorie'}' and year(datum)=$jaartje and month(datum)=$maandje and omschrijving1 like '%$pasje%' and debetcredit='$key{'debetcredit'}'"; } else { $query2="select round(sum(bedrag), 2) from $TABELNAAM where year(datum)=$jaartje and month(datum)=$maandje and omschrijving1 like '%$pasje%'"; } $mysql->query($query2); $record_set2 = $mysql->create_record_iterator; while ($record2 = $record_set2->each) { $bedrag=$record2->[0]; $color="#FF0000"; if ($bedrag < 0) { $bedrag =~ s/\-//g; $color="#009900"; } $bgcolor=""; if ($maandje eq $key{'maand'}) { $bgcolor="#FFFF64"; } print ""; $passensom[$i]=$passensom[$i]+$bedrag; } } print ""; } print ""; print ""; for ($i=1; $i<=12; $i++) { ($jaartje, $maandje) = split (/\-/, $scope[$i - 1]); $bgcolor="#CCCCCC"; if ($maandje eq $key{'maand'}) { $bgcolor="#FFFF64"; } print ""; } print ""; print "
Passen overzicht: $maandNaarNaam{$key{'maand'}}
Pas$maandNaarNaam{$maandje}
$pasje ($passenNaam{$pasje})"; if ($bedrag) { print "€ ".sprintf("%.2f",$bedrag); } print "
Totaal€ ".sprintf("%.2f",$passensom[$i])."
"; print "
"; print "
"; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
Detailoverzicht transacties
CategorieDatumTypeRekeningNaamOmschrijvingBedrag
"; $gevonden=0; # print "
"; print ""; $andpasje=""; if ($key{'pasje'}) { $andpasje=" and omschrijving1 like '%$key{'pasje'}%'"; } if ($key{'pasje'} eq "ALL") { $andpasje=""; $runner=""; foreach $pasje (@passen) { if ($runner) { $runner="$runner OR omschrijving1 like '%$pasje%' "; } else { $runner="omschrijving1 like '%$pasje%'"; } } $andpasje=" and ($runner)"; } if (($key{'type'}) && ($key{'categorie'})) { if ($key{'debetcredit'}) { $query="select datum, debetcredit, bedrag, naarrekening, naam, type, omschrijving1, omschrijving2, omschrijving3, categorie from $TABELNAAM where year(datum)=$key{'jaar'} and month(datum)=$key{'maand'} and type='$key{'type'}' and categorie='$key{'categorie'}' and debetcredit='$key{'debetcredit'}' $andpasje order by datum desc"; } else { $query="select datum, debetcredit, bedrag, naarrekening, naam, type, omschrijving1, omschrijving2, omschrijving3, categorie from $TABELNAAM where year(datum)=$key{'jaar'} and month(datum)=$key{'maand'} and type='$key{'type'}' and categorie='$key{'categorie'}' $andpasje order by datum desc"; } } elsif ($key{'type'}) { $query="select datum, debetcredit, bedrag, naarrekening, naam, type, omschrijving1, omschrijving2, omschrijving3, categorie from $TABELNAAM where year(datum)=$key{'jaar'} and month(datum)=$key{'maand'} and type='$key{'type'}' $andpasje order by datum desc"; } elsif ($key{'categorie'}) { if ($key{'debetcredit'}) { $query="select datum, debetcredit, bedrag, naarrekening, naam, type, omschrijving1, omschrijving2, omschrijving3, categorie from $TABELNAAM where year(datum)=$key{'jaar'} and month(datum)=$key{'maand'} and categorie='$key{'categorie'}' and debetcredit='$key{'debetcredit'}' $andpasje order by datum desc"; } else { $query="select datum, debetcredit, bedrag, naarrekening, naam, type, omschrijving1, omschrijving2, omschrijving3, categorie from $TABELNAAM where year(datum)=$key{'jaar'} and month(datum)=$key{'maand'} and categorie='$key{'categorie'}' order by datum $andpasje desc"; } } elsif (($key{'jaar'}) && ($key{'maand'})) { $query="select datum, debetcredit, bedrag, naarrekening, naam, type, omschrijving1, omschrijving2, omschrijving3, categorie from $TABELNAAM where year(datum)=$key{'jaar'} and month(datum)=$key{'maand'} $andpasje order by datum desc"; } else { $query="select datum, debetcredit, bedrag, naarrekening, naam, type, omschrijving1, omschrijving2, omschrijving3, categorie from $TABELNAAM where 1=0 $andpasje order by datum desc"; } $mysql->query($query); $record_set = $mysql->create_record_iterator; while ($record = $record_set->each) { $datum=$record->[0]; $debetcredet=$record->[1]; $bedrag=$record->[2]; $naarrekening=$record->[3]; $naam=$record->[4]; $type=$record->[5]; $omschrijving1=$record->[6]; $omschrijving2=$record->[7]; $omschrijving3=$record->[8]; $cat=$record->[9]; if ($bgcolor eq "#EEEEEE") { $bgcolor="#FFFFFF"; } else { $bgcolor="#EEEEEE"; } print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $color="#FF0000"; if ($debetcredet =~ /C|c/) { $color="#009900"; } print ""; if ($debetcredet =~ /D|d/) { $supersom = $supersom - $bedrag; } else { $supersom = $supersom + $bedrag; } print ""; $gevonden++; } $color="#FF0000"; if ($supersom > 0) { $color="#009900"; } else { $supersom =~ s/\-//g; } print ""; print "
$datum$type$debetcredet$naarrekening$naam$omschrijving1€ ".sprintf("%.2f",$bedrag)."
Totaal€ ".sprintf("%.2f",$supersom)."
"; # print ""; print ""; print ""; print "
"; if (!$gevonden) { print "
Er zijn geen transacties gevonden
"; } # ============================= # ============================= print "
"; print ""; } print "
"; print ""; print "
Rabobank comma MUT file:
"; print "
"; print ""; print "";