<?php require_once 'auth.php'; ?>
<?php
ini_set('max_execution_time', 0);
/*
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
		"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>AH Reisacher - SC/TZ</title>
<link rel="stylesheet" href="phpME.css" type="text/css"></link>
<link rel="stylesheet" href="styles/main.css" type="text/css"></link>
</head>
<body>
*/
?>
<?php

/*
 * IMPORTANT NOTE: This generated file contains only a subset of huge amount
 * of options that can be used with phpMyEdit. To get information about all
 * features offered by phpMyEdit, check official documentation. It is available
 * online and also for download on phpMyEdit project management page:
 *
 * http://www.platon.sk/projects/main_page.php?project_id=5
 */

// MySQL host name, user name, password, database, and table
$opts['tb'] = 'qb_report_901604039';
$opts['tb2'] = 'qb_report_2';

// Name of field which is the unique key
$opts['key'] = 'qb_id';

// Type of key field (int/real/string/date etc.)
$opts['key_type'] = 'int';

// Sorting field(s)
$opts['sort_field'] = array('ALL','ALL');
if ($opts['sort_field'][0] === '') $opts['sort_field'] = array();

// Number of records to display on the screen
// Value of -1 lists all records in a table
$opts['inc'] = 250;  //ORIGINAL

// Options you wish to give the users
// A - add,  C - change, P - copy, V - view, D - delete,
// F - filter, I - initial sort suppressed
$opts['options'] = ''; // FACDPV

// Number of lines to display on multiple selection filters
$opts['multiple'] = '4';

// Navigation style: B - buttons (default), T - text links, G - graphic links
// Buttons position: U - up, D - down (default)
$opts['navigation'] = 'UG'; //'DB';

// Display special page elements
$opts['display'] = array(
	'form'  => true,
	'query' => true,
	'sort'  => true,
	'time'  => true,
	'tabs'  => true
);

$opts['logtable'] =  'qb_changelog';

/* Get the user's default language and use it if possible or you can
   specify particular one you want to use. Refer to official documentation
   for list of available languages. */
$opts['language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'];

/* Table-level filter capability. If set, it is included in the WHERE clause
   of any generated SELECT statement in SQL query. This gives you ability to
   work only with subset of data from table.

$opts['filters'] = "column1 like '%11%' AND column2<17";
$opts['filters'] = "section_id = 9";
$opts['filters'] = "PMEtable0.sessions_count > 200";
*/

/* Field definitions

Fields will be displayed left to right on the screen in the order in which they
appear in generated list. Here are some most used field options documented.

['name'] is the title used for column headings, etc.;
['maxlen'] maximum length to display add/edit/search input boxes
['trimlen'] maximum length of string content to display in row listing
['width'] is an optional display width specification for the column
          e.g.  ['width'] = '100px';
['mask'] a string that is used by sprintf() to format field output
['sort'] true or false; means the users may sort the display on this column
['strip_tags'] true or false; whether to strip tags from content
['nowrap'] true or false; whether this field should get a NOWRAP
['required'] true or false; if generate javascript to prevent null entries
['select'] T - text, N - numeric, D - drop-down, M - multiple selection
['options'] optional parameter to control whether a field is displayed
  L - list, F - filter, A - add, C - change, P - copy, D - delete, V - view
            Another flags are:
            R - indicates that a field is read only
            W - indicates that a field is a password field
            H - indicates that a field is to be hidden and marked as hidden
['URL'] is used to make a field 'clickable' in the display
        e.g.: 'mailto:$value', 'http://$value' or '$page?stuff';
['URLtarget']  HTML target link specification (for example: _blank)
['textarea']['rows'] and/or ['textarea']['cols']
  specifies a textarea is to be used to give multi-line input
  e.g. ['textarea']['rows'] = 5; ['textarea']['cols'] = 10
['values'] restricts user input to the specified constants,
           e.g. ['values'] = array('A','B','C') or ['values'] = range(1,99)
['values']['table'] and ['values']['column'] restricts user input
  to the values found in the specified column of another table
['values']['description'] = 'desc_column'
  The optional ['values']['description'] field allows the value(s) displayed
  to the user to be different to those in the ['values']['column'] field.
  This is useful for giving more meaning to column values. Multiple
  descriptions fields are also possible. Check documentation for this.
*/

$opts['fdd']['Betrieb'] = array(
  'name'     => 'Betrieb',
  'select'   => 'T',
  'maxlen'   => 20,
  'sort'     => true
);
$opts['fdd']['Stufe2'] = array(
  'name'     => 'Stufe2',
  'select'   => 'T',
  'maxlen'   => 6,
  'sort'     => true
);
$opts['fdd']['FAGNR'] = array(
  'name'     => 'FAGNR',
  'select'   => 'T',
  'maxlen'   => 25,
  'required' => true,
  'sort'     => true
);
$opts['fdd']['FTYPE'] = array(
  'name'     => 'FTYPE',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true
);
$opts['fdd']['KNDNR'] = array(
  'name'     => 'KNDNR',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true
);
$opts['fdd']['KNAME'] = array(
  'name'     => 'KNAME',
  'select'   => 'T',
  'maxlen'   => 50,
  'sort'     => true
);
$opts['fdd']['Stufe5'] = array(
  'name'     => 'Stufe5',
  'select'   => 'T',
  'maxlen'   => 30,
  'sort'     => true
);
$opts['fdd']['REDAT'] = array(
  'name'     => 'REDAT',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true
);
$opts['fdd']['O500_HW2BUCHGBETR'] = array(
  'name'     => 'O500 HW2BUCHGBETR',
  'select'   => 'T',
  'maxlen'   => 8,
  'sort'     => true
);
$opts['fdd']['FLDAT_von'] = array(
  'name'     => 'FLDAT von',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true
);
$opts['fdd']['FLDAT_bis'] = array(
  'name'     => 'FLDAT bis',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true
);
$opts['fdd']['FLDAT'] = array(
  'name'     => 'FLDAT',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true
);
$opts['fdd']['O500_MAHNSTUFE'] = array(
  'name'     => 'O500 MAHNSTUFE',
  'select'   => 'T',
  'maxlen'   => 50,
  'sort'     => true
);
$opts['fdd']['Next_MAHNSTUFE'] = array(
  'name'     => 'Next MAHNSTUFE',
  'select'   => 'T',
  'maxlen'   => 50,
  'sort'     => true
);
$opts['fdd']['O500_HW2BETR_OFFEN'] = array(
  'name'     => 'O500 HW2BETR OFFEN',
  'select'   => 'T',
  'maxlen'   => 8,
  'sort'     => true
);
$opts['fdd']['OPDAT'] = array(
  'name'     => 'OPDAT',
  'select'   => 'T',
  'maxlen'   => 10,
  'default'  => '0000-00-00',
  'required' => true,
  'sort'     => true
);
$opts['fdd']['O500_BELEGNR1'] = array(
  'name'     => 'O500 BELEGNR1',
  'select'   => 'T',
  'maxlen'   => 20,
  'required' => true,
  'sort'     => true
);
$opts['fdd']['Ktelf'] = array(
  'name'     => 'Ktelf',
  'select'   => 'T',
  'maxlen'   => 13,
  'sort'     => true
);
$opts['fdd']['Kstra'] = array(
  'name'     => 'Kstra',
  'select'   => 'T',
  'maxlen'   => 40,
  'sort'     => true
);
$opts['fdd']['Kdplz'] = array(
  'name'     => 'Kdplz',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true
);
$opts['fdd']['Kdort'] = array(
  'name'     => 'Kdort',
  'select'   => 'T',
  'maxlen'   => 30,
  'sort'     => true
);
$opts['fdd']['Bemerkung'] = array(
  'name'     => 'Bemerkung',
  'select'   => 'T',
  'maxlen'   => 65535,
  'textarea' => array(
    'rows' => 5,
    'cols' => 50),
  'sort'     => true
);
$opts['fdd']['Wiedervorlage'] = array(
  'name'     => 'Wiedervorlage',
  'select'   => 'T',
  'maxlen'   => 10,
  'default'  => '0000-00-00',
  'sort'     => true
);
$opts['fdd']['Bemerkung_2'] = array(
  'name'     => 'Bemerkung 2',
  'select'   => 'T',
  'maxlen'   => 65535,
  'textarea' => array(
    'rows' => 5,
    'cols' => 50),
  'sort'     => true
);
$opts['fdd']['Bearbeitet'] = array(
  'name'     => 'Bearbeitet',
  'select'   => 'T',
  'maxlen'   => 1,
  'default'  => 'N',
  'sort'     => true
);
$opts['fdd']['Mahnen'] = array(
  'name'     => 'Mahnen',
  'select'   => 'T',
  'maxlen'   => 1,
  'default'  => 'J',
  'sort'     => true
);
$opts['fdd']['User'] = array(
  'name'     => 'User',
  'select'   => 'T',
  'maxlen'   => 30,
  'sort'     => true
);
$opts['fdd']['Aenderungsdatum'] = array(
  'name'     => 'Aenderungsdatum',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true
);
$opts['fdd']['User_2'] = array(
  'name'     => 'User 2',
  'select'   => 'T',
  'maxlen'   => 30,
  'sort'     => true
);
$opts['fdd']['Aenderungsdatum_u2'] = array(
  'name'     => 'Aenderungsdatum u2',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true
);
$opts['fdd']['KZALA'] = array(
  'name'     => 'KZALA',
  'select'   => 'T',
  'maxlen'   => 5,
  'sort'     => true
);
$opts['fdd']['Versicherung'] = array(
  'name'     => 'Versicherung',
  'select'   => 'T',
  'maxlen'   => 1,
  'default'  => 'N',
  'sort'     => true
);
$opts['fdd']['Rechtsanwalt'] = array(
  'name'     => 'Rechtsanwalt',
  'select'   => 'T',
  'maxlen'   => 1,
  'default'  => 'N',
  'required' => true,
  'sort'     => true
);
$opts['fdd']['Reklamation'] = array(
  'name'     => 'Reklamation',
  'select'   => 'T',
  'maxlen'   => 5,
  'default'  => 'N',
  'sort'     => true
);
$opts['fdd']['Selbstbeteiligung'] = array(
  'name'     => 'Selbstbeteiligung',
  'select'   => 'T',
  'maxlen'   => 12,
  'sort'     => true
);
$opts['fdd']['SelbstbeteiligungBetrag'] = array(
  'name'     => 'SelbstbeteiligungBetrag',
  'select'   => 'T',
  'maxlen'   => 12,
  'sort'     => true
);
$opts['fdd']['Mwst'] = array(
  'name'     => 'Mwst',
  'select'   => 'T',
  'maxlen'   => 12,
  'sort'     => true
);
$opts['fdd']['MwstBetrag'] = array(
  'name'     => 'MwstBetrag',
  'select'   => 'T',
  'maxlen'   => 12,
  'sort'     => true
);
$opts['fdd']['Reserve_1'] = array(
  'name'     => 'Reserve 1',
  'select'   => 'T',
  'maxlen'   => 255,
  'required' => true,
  'sort'     => true
);
$opts['fdd']['Reserve_3'] = array(
  'name'     => 'Reserve 3',
  'select'   => 'T',
  'maxlen'   => 255,
  'sort'     => true
);
$opts['fdd']['Faell_Tage'] = array(
  'name'     => 'Faell Tage',
  'select'   => 'T',
  'maxlen'   => 12,
  'sort'     => true
);
$opts['fdd']['Wochen'] = array(
  'name'     => 'Wochen',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true
);
$opts['fdd']['qb_id'] = array(
  'name'     => 'Qb ID',
  'select'   => 'T',
  'options'  => 'AVCPDR', // auto increment
  'maxlen'   => 11,
  'default'  => '0',
  'sort'     => true
);


function flag_enabled($rec) {
	global $adodb, $opts;
	$rs2 = $adodb->Execute('SELECT * FROM '.$opts['tb'].' '.
	' WHERE '.$opts['key'].' = ? ', array($rec));
	if ($rs2->EOF) return 1;
	$sql = "SELECT * FROM fm_ahr_report_crc WHERE FAGNR = [FAGNR]   AND O500_BELEGNR1 = [O500_BELEGNR1]   AND OPDAT = [OPDAT]  AND Reserve_1 = [Reserve_1];";
	$sql = trim($sql);
	if (!$sql) return 1;
	foreach ($rs2->fields as $k => $v) {
		$v = addslashes($v);
		$sql = str_replace('['.$k.']', "'$v'", $sql);
	}
	$rs = $adodb->Execute($sql);
	if ($rs->EOF) return 1;
	return 0;
}

if (flag_enabled(@$_REQUEST['rec']) === 0) {
if (isset($opts['fdd']['Betrieb'])) {
			$opts['fdd']['Betrieb']['input'] = 'R';
		}if (isset($opts['fdd']['O500_KTOART'])) {
			$opts['fdd']['O500_KTOART']['input'] = 'R';
		}if (isset($opts['fdd']['O500_KTONR'])) {
			$opts['fdd']['O500_KTONR']['input'] = 'R';
		}if (isset($opts['fdd']['O500_BELEGNR1'])) {
			$opts['fdd']['O500_BELEGNR1']['input'] = 'R';
		}if (isset($opts['fdd']['OPDAT'])) {
			$opts['fdd']['OPDAT']['input'] = 'R';
		}if (isset($opts['fdd']['O500_BELEGSYMBOL'])) {
			$opts['fdd']['O500_BELEGSYMBOL']['input'] = 'R';
		}if (isset($opts['fdd']['O500_HW2BUCHGBETR'])) {
			$opts['fdd']['O500_HW2BUCHGBETR']['input'] = 'R';
		}if (isset($opts['fdd']['O500_HW2BETR_OFFEN'])) {
			$opts['fdd']['O500_HW2BETR_OFFEN']['input'] = 'R';
		}if (isset($opts['fdd']['FLDAT'])) {
			$opts['fdd']['FLDAT']['input'] = 'R';
		}if (isset($opts['fdd']['REDAT'])) {
			$opts['fdd']['REDAT']['input'] = 'R';
		}if (isset($opts['fdd']['BELEG8'])) {
			$opts['fdd']['BELEG8']['input'] = 'R';
		}if (isset($opts['fdd']['REBEB'])) {
			$opts['fdd']['REBEB']['input'] = 'R';
		}if (isset($opts['fdd']['FAGNR'])) {
			$opts['fdd']['FAGNR']['input'] = 'R';
		}if (isset($opts['fdd']['FTYPE'])) {
			$opts['fdd']['FTYPE']['input'] = 'R';
		}if (isset($opts['fdd']['FZFIL'])) {
			$opts['fdd']['FZFIL']['input'] = 'R';
		}if (isset($opts['fdd']['FFIRM'])) {
			$opts['fdd']['FFIRM']['input'] = 'R';
		}if (isset($opts['fdd']['RAARTH'])) {
			$opts['fdd']['RAARTH']['input'] = 'R';
		}if (isset($opts['fdd']['KDBERA'])) {
			$opts['fdd']['KDBERA']['input'] = 'R';
		}if (isset($opts['fdd']['FILIALE'])) {
			$opts['fdd']['FILIALE']['input'] = 'R';
		}if (isset($opts['fdd']['KDBNR'])) {
			$opts['fdd']['KDBNR']['input'] = 'R';
		}if (isset($opts['fdd']['KDBNAME'])) {
			$opts['fdd']['KDBNAME']['input'] = 'R';
		}if (isset($opts['fdd']['KNAME'])) {
			$opts['fdd']['KNAME']['input'] = 'R';
		}if (isset($opts['fdd']['KNDNR'])) {
			$opts['fdd']['KNDNR']['input'] = 'R';
		}if (isset($opts['fdd']['ZAW'])) {
			$opts['fdd']['ZAW']['input'] = 'R';
		}if (isset($opts['fdd']['Kanrs'])) {
			$opts['fdd']['Kanrs']['input'] = 'R';
		}if (isset($opts['fdd']['Ktelf'])) {
			$opts['fdd']['Ktelf']['input'] = 'R';
		}if (isset($opts['fdd']['Kname'])) {
			$opts['fdd']['Kname']['input'] = 'R';
		}if (isset($opts['fdd']['Stufe1'])) {
			$opts['fdd']['Stufe1']['input'] = 'R';
		}if (isset($opts['fdd']['Stufe2'])) {
			$opts['fdd']['Stufe2']['input'] = 'R';
		}if (isset($opts['fdd']['Stufe3'])) {
			$opts['fdd']['Stufe3']['input'] = 'R';
		}if (isset($opts['fdd']['Stufe4'])) {
			$opts['fdd']['Stufe4']['input'] = 'R';
		}if (isset($opts['fdd']['Stufe5'])) {
			$opts['fdd']['Stufe5']['input'] = 'R';
		}if (isset($opts['fdd']['Next_MAHNSTUFE'])) {
			$opts['fdd']['Next_MAHNSTUFE']['input'] = 'R';
		}if (isset($opts['fdd']['O500_MAHNSTUFE'])) {
			$opts['fdd']['O500_MAHNSTUFE']['input'] = 'R';
		}if (isset($opts['fdd']['Kstra'])) {
			$opts['fdd']['Kstra']['input'] = 'R';
		}if (isset($opts['fdd']['Kdplz'])) {
			$opts['fdd']['Kdplz']['input'] = 'R';
		}if (isset($opts['fdd']['Kdort'])) {
			$opts['fdd']['Kdort']['input'] = 'R';
		}if (isset($opts['fdd']['Faell_Tage'])) {
			$opts['fdd']['Faell_Tage']['input'] = 'R';
		}if (isset($opts['fdd']['Wochen'])) {
			$opts['fdd']['Wochen']['input'] = 'R';
		}if (isset($opts['fdd']['KZALA'])) {
			$opts['fdd']['KZALA']['input'] = 'R';
		}if (isset($opts['fdd']['Reserve_1'])) {
			$opts['fdd']['Reserve_1']['input'] = 'R';
		}if (isset($opts['fdd']['Reserve_3'])) {
			$opts['fdd']['Reserve_3']['input'] = 'R';
		}
}

if (isset($opts['fdd']['FTYPE'])) {
			$opts['fdd']['FTYPE']['options'] = 'ACD';
		}if (isset($opts['fdd']['KNDNR'])) {
			$opts['fdd']['KNDNR']['options'] = 'ACD';
		}if (isset($opts['fdd']['Ktelf'])) {
			$opts['fdd']['Ktelf']['options'] = 'ACD';
		}if (isset($opts['fdd']['Kstra'])) {
			$opts['fdd']['Kstra']['options'] = 'ACD';
		}if (isset($opts['fdd']['Kdplz'])) {
			$opts['fdd']['Kdplz']['options'] = 'ACD';
		}if (isset($opts['fdd']['Kdort'])) {
			$opts['fdd']['Kdort']['options'] = 'ACD';
		}if (isset($opts['fdd']['User'])) {
			$opts['fdd']['User']['options'] = 'ACD';
		}if (isset($opts['fdd']['User_2'])) {
			$opts['fdd']['User_2']['options'] = 'ACD';
		}if (isset($opts['fdd']['Faell_Tage'])) {
			$opts['fdd']['Faell_Tage']['options'] = 'ACD';
		}if (isset($opts['fdd']['Next_MAHNSTUFE'])) {
			$opts['fdd']['Next_MAHNSTUFE']['options'] = 'ACD';
		}if (isset($opts['fdd']['FLDAT_ori'])) {
			$opts['fdd']['FLDAT_ori']['options'] = 'ACD';
		}if (isset($opts['fdd']['Reserve_1'])) {
			$opts['fdd']['Reserve_1']['options'] = 'ACD';
		}
$opts['triggers']['insert']['after'] = 'phpME_report_1246951913.TIA.inc.php';
$opts['triggers']['update']['after'] = 'phpME_report_1246951913.TUA.inc.php';
$opts['triggers']['delete']['after'] = 'phpME_report_1246951913.TDA.inc.php';
$opts['fdd']['qb_id']['input'] = 'H';
if ($isSupervisor) {
	$userAction['add'] = 1;
        $userAction['change'] = 1;
	$userAction['delete'] = 1;
	$userAction['list'] = 1;
	$userAction['filter'] = 1;
	$userAction['copy'] = 1;
} else {
        $userAction = getReportActions($_SESSION['userid'], 'fm_ahr_sc');
}
if ($userAction['add']) $opts['options'] .= 'A';
if ($userAction['change']) $opts['options'] .= 'C';
if ($userAction['delete']) $opts['options'] .= 'D';
if (!$userAction['list']) $opts['filters'] = '1=0';
if ($userAction['filter']) $opts['options'] .= 'F';
#if ($userAction['copy']) $opts['options'] .= 'P';


$tableid = 'qb_report_901604039';
$tableid2 = 'qb_report_2';
$reportName = 'fm_ahr_sc';
$paramsql = 'FLDAT >= [datefrom:FLDAT] 
and FLDAT <= [dateuntil:FLDAT] 
and Betrieb = [betr:Betrieb] 
and Stufe5 = [stufe_5:Stufe5] 
and O500_Mahnstufe = [mahnst:O500_Mahnstufe] 
and Stufe2 = [stufe_2:Stufe2] 
and KNAME = [k_name:KNAME] 
and Wochen = [woch:Wochen] 
and Versicherung = [vers:Versicherung] 
and Rechtsanwalt = [ra:Rechtsanwalt]
and Reklamation = [rekl:Reklamation] 
and Wiedervorlage = [Wiedervorl:Wiedervorlage] 
and Mahnen = [Mahnen_ent:Mahnen]
and Reserve_3 = [rechgut:Reserve_3]';

$isparam = false;
foreach ($_POST as $k => $v) {
        $v = trim($v);
        // old style
        if (strstr($paramsql, '['.$k.']')) {
                $_SESSION[$k.'_1246951913'] = $v;
                $isparam = true;
                $key = '['.$k.']';
                $value = "'".$v."'";
        // new style
        } else if (ereg('\['.$k.':([^]]+)\]', $paramsql, $r)) {
                $isparam = true;
                $key = $r[0];
                if ($v) {
                	if(ereg('([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})', $v, $regs))
                    {
                    	$z = $regs[3].'-'.$regs[2].'-'.$regs[1];
                    	$value = "'".$z."'";
                    }else
                        $value = "'".$v."'";
                    $_SESSION[$k.'_1246951913'] = $v;
                } else {
                  	$value = $r[1];
                    $_SESSION[$k.'_1246951913'] = '';
                }
        }
        $paramsql = str_replace($key, $value, $paramsql);
}
if ($isparam) {
        $opts['filters'] = $paramsql;
        $_SESSION['filters_1246951913'] = $opts['filters'];
} else {
        $opts['filters'] = $_SESSION['filters_1246951913'];
}

//SQL for content of Filters

                $datefrom = '<input type=\'text\' class=\'report_filter_table_input_small\' name=\'datefrom\' value=\''.@$_SESSION['datefrom_1246951913'].'\'><image src=\'images/dynCalendar.gif\' name=\'calendar\' date=date onclick=\'startCalendar(this,"datefrom", "down");\'>';
            		
                $dateuntil = '<input type=\'text\' class=\'report_filter_table_input_small\' name=\'dateuntil\' value=\''.@$_SESSION['dateuntil_1246951913'].'\'><image src=\'images/dynCalendar.gif\' name=\'calendar\' date=date onclick=\'startCalendar(this,"dateuntil", "down");\'>';
            		
        		$rsFilters = $adodb->Execute('SELECT Betrieb FROM qb_report_901604039 GROUP BY Betrieb');
                $betr = $rsFilters -> GetMenu('betr', @$_SESSION['betr_1246951913']);
            		
        		$rsFilters = $adodb->Execute('SELECT Stufe5 FROM qb_report_901604039 GROUP BY Stufe5');
                $stufe_5 = $rsFilters -> GetMenu('stufe_5', @$_SESSION['stufe_5_1246951913']);
            		
        		$rsFilters = $adodb->Execute('SELECT O500_Mahnstufe FROM qb_report_901604039 GROUP BY O500_Mahnstufe');
                $mahnst = $rsFilters -> GetMenu('mahnst', @$_SESSION['mahnst_1246951913']);
            		
        		$rsFilters = $adodb->Execute('SELECT Stufe2 FROM qb_report_901604039 GROUP BY Stufe2');
                $stufe_2 = $rsFilters -> GetMenu('stufe_2', @$_SESSION['stufe_2_1246951913']);
            		
        		$rsFilters = $adodb->Execute('SELECT KNAME FROM qb_report_901604039 GROUP BY KNAME');
                $k_name = $rsFilters -> GetMenu('k_name', @$_SESSION['k_name_1246951913']);
            		
        		$rsFilters = $adodb->Execute('SELECT wochen FROM qb_report_901604039 GROUP BY wochen');
                $woch = $rsFilters -> GetMenu('woch', @$_SESSION['woch_1246951913']);
            		
        		$rsFilters = $adodb->Execute('SELECT Versicherung FROM qb_report_901604039 GROUP BY Versicherung');
                $vers = $rsFilters -> GetMenu('vers', @$_SESSION['vers_1246951913']);
            		
        		$rsFilters = $adodb->Execute('SELECT Rechtsanwalt FROM qb_report_901604039 GROUP BY Rechtsanwalt');
                $ra = $rsFilters -> GetMenu('ra', @$_SESSION['ra_1246951913']);
            		
        		$rsFilters = $adodb->Execute('SELECT Reklamation FROM qb_report_901604039 GROUP BY Reklamation');
                $rekl = $rsFilters -> GetMenu('rekl', @$_SESSION['rekl_1246951913']);
            		
                $Wiedervorl = '<input type=\'text\' class=\'report_filter_table_input_small\' name=\'Wiedervorl\' value=\''.@$_SESSION['Wiedervorl_1246951913'].'\'><image src=\'images/dynCalendar.gif\' name=\'calendar\' date=date onclick=\'startCalendar(this,"Wiedervorl", "down");\'>';
            		
        		$rsFilters = $adodb->Execute('SELECT Mahnen FROM qb_report_901604039 GROUP BY Mahnen');
                $Mahnen_ent = $rsFilters -> GetMenu('Mahnen_ent', @$_SESSION['Mahnen_ent_1246951913']);
            		
        		$rsFilters = $adodb->Execute('SELECT Reserve_3 FROM qb_report_901604039 GROUP BY Reserve_3');
                $rechgut = $rsFilters -> GetMenu('rechgut', @$_SESSION['rechgut_1246951913']);
            		

function translate($str) {
	return __($str, null, $tableid2);
}

require 'smarty/libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
$smarty->register_modifier("translate","translate");
$smarty->register_modifier("number_format","number_format");
$smarty->assign('curdate', time());
$smarty->assign('count', __('COUNT'));
$smarty->assign('grandTotal', __('grandTotal'));
$smarty->assign('subTotal', __('subTotal'));
$smarty->assign('title', __("TITLE", $reportName, $tableid2));
$smarty->assign('Total', __('Total'));
$smarty->assign('Query', __('Query'));
$smarty->assign('Reset', __('Reset'));
$smarty->assign("BetriebTxt", __("Betrieb", "Betrieb",  $tableid2));
$smarty->assign("Stufe2Txt", __("Stufe2", "Stufe2",  $tableid2));
$smarty->assign("FAGNRTxt", __("FAGNR", "FAGNR",  $tableid2));
$smarty->assign("FTYPETxt", __("FTYPE", "FTYPE",  $tableid2));
$smarty->assign("KNDNRTxt", __("KNDNR", "KNDNR",  $tableid2));
$smarty->assign("KNAMETxt", __("KNAME", "KNAME",  $tableid2));
$smarty->assign("Stufe5Txt", __("Stufe5", "Stufe5",  $tableid2));
$smarty->assign("REDATTxt", __("REDAT", "REDAT",  $tableid2));
$smarty->assign("O500_HW2BUCHGBETRTxt", __("O500_HW2BUCHGBETR", "O500_HW2BUCHGBETR",  $tableid2));
$smarty->assign("FLDAT_vonTxt", __("FLDAT_von", "FLDAT_von",  $tableid2));
$smarty->assign("FLDAT_bisTxt", __("FLDAT_bis", "FLDAT_bis",  $tableid2));
$smarty->assign("FLDATTxt", __("FLDAT", "FLDAT",  $tableid2));
$smarty->assign("O500_MAHNSTUFETxt", __("O500_MAHNSTUFE", "O500_MAHNSTUFE",  $tableid2));
$smarty->assign("Next_MAHNSTUFETxt", __("Next_MAHNSTUFE", "Next_MAHNSTUFE",  $tableid2));
$smarty->assign("O500_HW2BETR_OFFENTxt", __("O500_HW2BETR_OFFEN", "O500_HW2BETR_OFFEN",  $tableid2));
$smarty->assign("OPDATTxt", __("OPDAT", "OPDAT",  $tableid2));
$smarty->assign("O500_BELEGNR1Txt", __("O500_BELEGNR1", "O500_BELEGNR1",  $tableid2));
$smarty->assign("KtelfTxt", __("Ktelf", "Ktelf",  $tableid2));
$smarty->assign("KstraTxt", __("Kstra", "Kstra",  $tableid2));
$smarty->assign("KdplzTxt", __("Kdplz", "Kdplz",  $tableid2));
$smarty->assign("KdortTxt", __("Kdort", "Kdort",  $tableid2));
$smarty->assign("BemerkungTxt", __("Bemerkung", "Bemerkung",  $tableid2));
$smarty->assign("WiedervorlageTxt", __("Wiedervorlage", "Wiedervorlage",  $tableid2));
$smarty->assign("Bemerkung_2Txt", __("Bemerkung_2", "Bemerkung_2",  $tableid2));
$smarty->assign("BearbeitetTxt", __("Bearbeitet", "Bearbeitet",  $tableid2));
$smarty->assign("MahnenTxt", __("Mahnen", "Mahnen",  $tableid2));
$smarty->assign("UserTxt", __("User", "User",  $tableid2));
$smarty->assign("AenderungsdatumTxt", __("Aenderungsdatum", "Aenderungsdatum",  $tableid2));
$smarty->assign("User_2Txt", __("User_2", "User_2",  $tableid2));
$smarty->assign("Aenderungsdatum_u2Txt", __("Aenderungsdatum_u2", "Aenderungsdatum_u2",  $tableid2));
$smarty->assign("KZALATxt", __("KZALA", "KZALA",  $tableid2));
$smarty->assign("VersicherungTxt", __("Versicherung", "Versicherung",  $tableid2));
$smarty->assign("RechtsanwaltTxt", __("Rechtsanwalt", "Rechtsanwalt",  $tableid2));
$smarty->assign("ReklamationTxt", __("Reklamation", "Reklamation",  $tableid2));
$smarty->assign("SelbstbeteiligungTxt", __("Selbstbeteiligung", "Selbstbeteiligung",  $tableid2));
$smarty->assign("SelbstbeteiligungBetragTxt", __("SelbstbeteiligungBetrag", "SelbstbeteiligungBetrag",  $tableid2));
$smarty->assign("MwstTxt", __("Mwst", "Mwst",  $tableid2));
$smarty->assign("MwstBetragTxt", __("MwstBetrag", "MwstBetrag",  $tableid2));
$smarty->assign("Reserve_1Txt", __("Reserve_1", "Reserve_1",  $tableid2));
$smarty->assign("Reserve_3Txt", __("Reserve_3", "Reserve_3",  $tableid2));
$smarty->assign("Faell_TageTxt", __("Faell_Tage", "Faell_Tage",  $tableid2));
$smarty->assign("WochenTxt", __("Wochen", "Wochen",  $tableid2));
$smarty->assign("filter_datefromTxt", __("FLDAT_von", "FLDAT_von", "$tableid2"));
$smarty->assign("filter_datefromVal", $datefrom);
$smarty->assign("filter_dateuntilTxt", __("FLDAT_bis", "FLDAT_bis", "$tableid2"));
$smarty->assign("filter_dateuntilVal", $dateuntil);
$smarty->assign("filter_betrTxt", __("Betrieb", "Betrieb", "$tableid2"));
$smarty->assign("filter_betrVal", $betr);
$smarty->assign("filter_betrVal", $betr);
$smarty->assign("filter_stufe_5Txt", __("Stufe5", "Stufe5", "$tableid2"));
$smarty->assign("filter_stufe_5Val", $stufe_5);
$smarty->assign("filter_stufe_5Val", $stufe_5);
$smarty->assign("filter_mahnstTxt", __("O500_Mahnstufe", "O500_Mahnstufe", "$tableid2"));
$smarty->assign("filter_mahnstVal", $mahnst);
$smarty->assign("filter_mahnstVal", $mahnst);
$smarty->assign("filter_stufe_2Txt", __("Stufe2", "Stufe2", "$tableid2"));
$smarty->assign("filter_stufe_2Val", $stufe_2);
$smarty->assign("filter_stufe_2Val", $stufe_2);
$smarty->assign("filter_k_nameTxt", __("KNAME", "KNAME", "$tableid2"));
$smarty->assign("filter_k_nameVal", $k_name);
$smarty->assign("filter_k_nameVal", $k_name);
$smarty->assign("filter_wochTxt", __("wochen", "wochen", "$tableid2"));
$smarty->assign("filter_wochVal", $woch);
$smarty->assign("filter_wochVal", $woch);
$smarty->assign("filter_versTxt", __("Versicherung", "Versicherung", "$tableid2"));
$smarty->assign("filter_versVal", $vers);
$smarty->assign("filter_versVal", $vers);
$smarty->assign("filter_raTxt", __("Rechtsanwalt", "Rechtsanwalt", "$tableid2"));
$smarty->assign("filter_raVal", $ra);
$smarty->assign("filter_raVal", $ra);
$smarty->assign("filter_reklTxt", __("Reklamation", "Reklamation", "$tableid2"));
$smarty->assign("filter_reklVal", $rekl);
$smarty->assign("filter_reklVal", $rekl);
$smarty->assign("filter_WiedervorlTxt", __("Wiedervorlage", "Wiedervorlage", "$tableid2"));
$smarty->assign("filter_WiedervorlVal", $Wiedervorl);
$smarty->assign("filter_Mahnen_entTxt", __("Mahnen", "Mahnen", "$tableid2"));
$smarty->assign("filter_Mahnen_entVal", $Mahnen_ent);
$smarty->assign("filter_Mahnen_entVal", $Mahnen_ent);
$smarty->assign("filter_rechgutTxt", __("Reserve_3", "Reserve_3", "$tableid2"));
$smarty->assign("filter_rechgutVal", $rechgut);
$smarty->assign("filter_rechgutVal", $rechgut);




// Now important call to phpMyEdit
global $phpme;
require_once 'phpMyEdit3.class.php';
$phpme = new phpMyEdit($opts);

                        	$where='';
                        	if($whereParam = $phpme -> make_where_from_query_opts())
                            	$where = 'WHERE '.$whereParam;
	                        $rsGroup = $adodb->Execute('SELECT @A:=SUM(O500_HW2BETR_OFFEN) as ALLGroup_O500_HW2BETR_OFFEN FROM qb_report_901604039 '.$where);
                            //die($phpme -> make_where_from_query_opts());
	                		$smarty->assign('ALLGroup_SUM', __($rsGroup->fields['ALLGroup_O500_HW2BETR_OFFEN']));
	                        


$columnCount = $smarty->get_template_vars('columnCount');
#if ($columnCount < 1) return;

if (isset($_GET['dopdf'])) {
	ob_start();
}

if ($smarty->template_exists('report_fm_ahr_sc.tpl')) {
	$smarty->display('report_fm_ahr_sc.tpl');
} else {
	$smarty->display('report_fm_ahr_sc_default.tpl');
}

if (isset($_GET['dopdf'])) {
	$tmpfname = tempnam("/tmp", "output.html");
	$fp = fopen($tmpfname, 'w');
	fwrite($fp, ob_get_contents());
	ob_end_clean();
	fclose($fp);

	header('Content-Type: application/pdf');
	passthru('htmldoc -t pdf --webpage '.$tmpfname);
}



?>


		<script language=javascript>
		top.window.moveTo(0,0);
		if (document.all) {
		top.window.resizeTo(screen.availWidth,screen.availHeight);
		}
		else if (document.layers||document.getElementById) {
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
		top.window.outerHeight = screen.availHeight;
		top.window.outerWidth = screen.availWidth;
		}
		}
		</script>
		</body>
</html>
