<?php
include('functions.php');

#$query = "UPDATE kontobewegungen  SET gueltig = 1 WHERE gueltig = 0";

#$result = dbQuery($query) or error ("Cannot get users from database: " . dbError());
$query = "SELECT userId FROM users";
$result = dbQuery($query) or error ("Cannot get users from database: " . dbError());
$num = dbNumRows($result);
$progress = new Progress($num);
$rownum=0;
print "UserId;Anrede;Titel;Vorname;Nachname;Strasse Nr.;PLZ;Ort;Land;Versnummer;Kontostand aktuell;Verfall naechster Monat; Verfall uebernaechster Monat\n";
$i = 0;
while ($row = dbFetchRow($result)) {
#  if ($i > 100) {
#      exit;
#  }
#  $i++;
  $userId = $row['userId'];
  $user = new user(0,$userId);
  $konto = new konto($userId);  
  $verfall = $konto->calcinvalidatenext();
  $month1 = $verfall[0];
  $month2 = $verfall[1];

  $line = $userId . ';' . 
          $user->anrede . ';' .
          $user->titel . ';' .
          $user->vorname . ';' .
          $user->name . ';' .
          $user->strasse . ' ' . $user->hausnummer . ';' .
          $user->plz . ';' .
          $user->ort . ';' .
          $user->land . ';' .
          $user->versnummer . ';' .
          $konto->getSaldo() . ';' .
          $month1 . ';' . 
          $month2;
  print $line . "\n";
}
dbFreeResult($result);
?>
