<html>
<head>
<title>System Auswahl</title>
<?php include("includes/connect.php"); ?>
<?php
$System = $_POST['System'];
if (count($System) <> 0) {
$sql = "SELECT DISTINCT Komponentenbezeichnung FROM haupttabelle where Systembezeichnung = '" .$System[0] ."'";
for ($a = 1; $a < count($System); $a++) {
$sql = $sql ." OR Systembezeichnung = '" .$System[$a] ."'";
}
$query_stringONE = mysql_query($sql, $connection) or die(mysql_error());
$num_rows = mysql_num_rows($query_stringONE) - 1;
echo "<script type=\"text/javascript\">\n";
echo "var trans = $num_rows; \n";
echo "function changed(obj){\n";
echo "var Men,einzelA,einzelB,einzelC;\n";
echo "var totA = 0;\n";
echo "var totB = 0;\n";
echo "var totC = 0;\n";
echo "var num = obj.name.substr(3, obj.name.length - 3);\n";
echo "Men = parseInt(obj.value);\n";
echo "if (!(Men > 0)){\n";
echo "Men = 0;\n";
echo "obj.value = 0;\n";
echo "}\n";
echo "einzelA = parseInt(document.form1['MBF' + num].value) * Men;\n";
echo "einzelB = parseInt(document.form1['MIF' + num].value) * Men;\n";
echo "einzelC = parseInt(document.form1['MSC' + num].value) * Men;\n";
echo "document.form1['AAA' + num].value = einzelA;\n";
echo "document.form1['BBB' + num].value = einzelB;\n";
echo "document.form1['CCC' + num].value = einzelC;\n";
echo "if (einzelA > 0){\n";
echo "document.form1['LAA' + num].value = (1000000000/einzelA).toFixed(2);}\n";
echo "else { \n";
echo "document.form1['LAA' + num].value = 0;}\n";
echo "if (einzelB > 0){\n";
echo "document.form1['LBB' + num].value = (1000000000/einzelB).toFixed(2);}\n";
echo "else { \n";
echo "document.form1['LBB' + num].value = 0;}\n";
echo "if (einzelC > 0){\n";
echo "document.form1['LCC' + num].value = (1000000000/einzelC).toFixed(2);}\n";
echo "else { \n";
echo "document.form1['LCC' + num].value = 0;}\n";
echo "document.form1['AIJ' + num].value = (einzelA/8760).toFixed(2);\n";
echo "document.form1['BIJ' + num].value = (einzelB/8760).toFixed(2);\n";
echo "document.form1['CIJ' + num].value = (einzelC/8760).toFixed(2);\n";
echo "if (einzelA > 0){\n";
echo "document.form1['FEJ' + num].value = (8760/einzelA).toFixed(2);}\n";
echo "else { \n";
echo "document.form1['FEJ' + num].value = 0;}\n";
echo "if (einzelB > 0){\n";
echo "document.form1['EEJ' + num].value = (8760/einzelB).toFixed(2);}\n";
echo "else { \n";
echo "document.form1['EEJ' + num].value = 0;}\n";
echo "if (einzelC > 0){\n";
echo "document.form1['SEJ' + num].value = (8760/einzelC).toFixed(2);}\n";
echo "else { \n";
echo "document.form1['SEJ' + num].value = 0;}\n";
echo "for (var x = 0; x <= trans; x++)\n";
echo "totA += parseFloat(document.form1['LAA' + x].value);\n";
echo "if (totA != 0){\n";
echo "document.form1.totalMTBF.value = (1000000000/totA).toFixed(2);\n";
echo "document.form1.MTBFIJ.value = ((1000000000/totA)/8760).toFixed(2);\n";
echo "document.form1.FEIJ.value = (1/((1000000000/totA)/8760)).toFixed(2);\n";
echo "}\n";
echo "for (var x = 0; x <= trans; x++)\n";
echo "totB += parseFloat(document.form1['LBB' + x].value);\n";
echo "if (totB != 0){\n";
echo "document.form1.totalMTBFI.value = (1000000000/totB).toFixed(2);\n";
echo "document.form1.MTBFIIJ.value = ((1000000000/totB)/8760).toFixed(2);\n";
echo "document.form1.ETEJ.value = (1/((1000000000/totB)/8760)).toFixed(2);\n";
echo "}\n";
echo "for (var x = 0; x <= trans; x++)\n";
echo "totC += parseFloat(document.form1['LCC' + x].value);\n";
echo "if (totC != 0){\n";
echo "document.form1.totalMTBSC.value = (1000000000/totC).toFixed(2);\n";
echo "document.form1.MTBSCIJ.value = ((1000000000/totC)/8760).toFixed(2);\n";
echo "document.form1.SCEJ.value = (1/((1000000000/totC)/8760)).toFixed(2)}\n";
echo "}\n";
echo "</script>\n";
echo"<script language=javascript>\n";
echo "function exportToExcel()\n";
echo "{\n";
echo "var oExcel = new ActiveXObject('Excel.Application');\n";
echo "var oBook = oExcel.Workbooks.Add;\n";
echo "var oSheet = oBook.Worksheets(1);\n";
echo "for (var y=0;y< test.rows.length;y++)\n";
// detailsTable is the table where the content to be exported is
echo "{\n";
echo "for (var x=0;x< test.rows(y).cells.length;x++)\n";
echo "{\n";
echo "oSheet.Cells(y+1,x+1) =\n";
echo "test.rows(y).cells(x).innerText;\n";
echo "}\n";
echo "}\n";
echo "oExcel.Visible = true;\n";
echo "oExcel.UserControl = true;\n";
echo "}\n";
echo "</script>\n";
echo "<script language=JavaScript>\n";
echo "function ExporttoExcel()\n";
echo "{\n";
echo "var sOption='toolbar=yes,location=no,directories=yes,menubar=yes,';\n";
echo "sOption+='crollbars=yes,width=750,height=600,left=100,top=25';\n";
echo "var sWinHTML = document.getElementById('contentstart').innerHTML;\n";
echo "var winprint=window.open('','',sOption);\n";
echo "winprint.document.open();\n";
echo " winprint.document.write('<html><head>')\n";
echo "winprint.document.write('<meta http-equiv='Content-Type' content='application/vnd.ms-excel'>')\n";
echo " winprint.document.write('<meta http-equiv='Content-disposition': attachment; filename='file.xls'>')\n";
echo "winprint.document.write('</head><body>')\n";
echo "winprint.document.write(sWinHTML);\n";
echo "winprint.document.write('</body></html>');\n";
echo " winprint.document.close();\n";
echo "winprint.focus();\n";
echo "}\n";
echo "</script>\n";
?>
</head>
<body bgcolor="#d3d3d3">
<div style="background-color:#003366; font-size:16px; color:#FFFFFF"><?php $datum = date("d.m.Y"); $uhrzeit = date("H:i"); echo $datum; ?></div>
<br>
<br>
<div style="font-family:Arial,sans-serif; font-size:18px; color:black" >Ausgewählte Systeme:</div><br>
<div style="font-family:Arial,sans-serif; font-size:18px; border:2px solid darkolivegreen; color:blue"><?php for($i = 0;$i < count($_POST['System']);$i++) echo "¦ ".$_POST['System'][$i]." ¦ ";?></div>
<hr size="1" noshade>
<p style="font-family:Arial,sans-serif; font-size:14px; color:black">Anzahl Komponenten: <?php echo mysql_num_rows($query_stringONE);?></p>
<hr size="1" noshade>
<?php
echo ("<p style='font-family:Arial,sans-serif; font-size:18px; color:black'>Länder:</p>");
echo ("<form action='LänderFilter.php' method='POST'>");
$System = $_POST['System'];
for($i = 0;$i < count($_POST['System']);$i++){
echo ("<input type='hidden' name='SystemA[]' value='$System[$i]'>");
}
$sqlland = "SELECT DISTINCT Land FROM haupttabelle where Systembezeichnung = '" .$System[0] ."'";
for ($KK = 1; $KK < count($System); $KK++) {
$sqlland = $sqlland ." OR Systembezeichnung = '" .$System[$KK] ."'";
}
$query_stringKK = mysql_query($sqlland, $connection) or die(mysql_error());
$column_countKK = mysql_num_fields($query_stringKK);
while($rowKK = mysql_fetch_assoc($query_stringKK)) {
echo '<input type="checkbox" name="Land[]" value="' . $rowKK['Land'] . '">';
echo $rowKK['Land'] . ' ';
}
echo ("</br></br><input type='submit' value=' Filtern '>");
echo ("</form>");
?>
<hr size="1" noshade>
<form name='form1' action='in_file.php' onReset="return confirm('Mengeneingabe zurücksetzen?');" method='POST' enctype='text/plain'>
<input type="reset" value="Zurücksetzen" >
<!--<button onclick="exportToExcel();">Export to Excel File</button>-->
<input type="submit" name="make_XLS" value=" Exportieren " ><br>
<button onclick="exporttoExcel();">Export to Excel File</button>
<hr size="1" noshade>
<?php
$System = $_POST['System'];
$sql = "SELECT DISTINCT Komponentenbezeichnung FROM haupttabelle where Systembezeichnung = '" .$System[0] ."'";
for ($a = 1; $a < count($System); $a++) {
$sql = $sql ." OR Systembezeichnung = '" .$System[$a] ."'";
}
$query_string = mysql_query($sql, $connection) or die(mysql_error());
$column_count = mysql_num_fields($query_string);
print("<TABLE id='contentstart' BORDER=2>\n");
print("<TR ALIGN=LEFT VALIGN=TOP >");
print("<TD align='center'><p><STRONG>KOMPONENTEN</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>MTBF</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>MTBFI</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>MTBSC</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>MENGE</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>MTBF_bew</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>MTBFI_bew</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>MTBSC_bew</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>λMTBF</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>λMTBFI</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>λMTBSC</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>MTBF in Jahren</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>MTBFI in Jahren</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>MTBSC in Jahren</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>ET pro E im J</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>Fehler pro E im J</STRONG></p></TD>\n");
print("<TD align='center'><p><STRONG>SC pro E im J</STRONG></p></TD>\n");
print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP >");
print("<TR ALIGN=LEFT VALIGN=TOP >");
print("</TR>\n");
$zaehler = -1;
while ($row = mysql_fetch_array($query_string)){
print("<TR ALIGN=LEFT VALIGN=TOP>");
for ($column_num = 0;$column_num < $column_count;$column_num++){
$komponente = $row[$column_num];
$zaehler = $zaehler +1;
$query_stringA = mysql_query("SELECT MTBFwert FROM mtbfwerte where Komponente ='$komponente'",$connection)or die(mysql_error());
$rowA = mysql_fetch_array($query_stringA);
print ("<TD>$komponente</td>");
print ("<TD><input type='text' name='MBF$zaehler' value='$rowA[0]' size='15' maxlength='30' readonly='readonly'></td>");
$query_stringB = mysql_query("SELECT MTBFIwert FROM mtbfiwerte where Komponente ='$komponente'",$connection)or die(mysql_error());
$rowB = mysql_fetch_array($query_stringB);
print ("<TD><input type='text' name='MIF$zaehler' value='$rowB[0]' size='15' maxlength='30' readonly='readonly'></td>");
$query_stringC = mysql_query("SELECT MTBSCwert FROM mtbscwerte where Komponente ='$komponente'",$connection)or die(mysql_error());
$rowC = mysql_fetch_array($query_stringC);
print ("<TD><input type='text' name='MSC$zaehler' value='$rowC[0]' size='15' maxlength='30' readonly='readonly'></td>");
print ("<TD><input type='text' align='middle' name='Men$zaehler' size='15' maxlength='30' onchange='changed(this);' ></TD>");
print ("<TD><input type='text' size='15' name='AAA$zaehler' value='0'readonly='readonly' ></TD>");
print ("<TD><input type='text' size='15' name='BBB$zaehler' value='0' readonly='readonly' ></TD>");
print ("<TD><input type='text' size='15' name='CCC$zaehler' value='0' readonly='readonly' ></TD>");
print ("<TD><input type='text' size='15' name='LAA$zaehler' value='0'readonly='readonly' ></TD>");
print ("<TD><input type='text' size='15' name='LBB$zaehler' value='0' readonly='readonly' ></TD>");
print ("<TD><input type='text' size='15' name='LCC$zaehler' value='0' readonly='readonly' ></TD>");
print ("<TD><input type='text' size='15' name='AIJ$zaehler' value='0'readonly='readonly' ></TD>");
print ("<TD><input type='text' size='15' name='BIJ$zaehler' value='0' readonly='readonly' ></TD>");
print ("<TD><input type='text' size='15' name='CIJ$zaehler' value='0' readonly='readonly' ></TD>");
print ("<TD><input type='text' size='15' name='FEJ$zaehler' value='0'readonly='readonly' ></TD>");
print ("<TD><input type='text' size='15' name='EEJ$zaehler' value='0' readonly='readonly' ></TD>");
print ("<TD><input type='text' size='15' name='SEJ$zaehler' value='0' readonly='readonly' ></TD>");
print("</TR>\n");
}
}
print("<TR ALIGN=LEFT VALIGN=TOP>");print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP>");print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP>");print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP>");print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP>");
print ("<td align='center' colspan='7'></td>");
print ("<td align='center' bgcolor='#FFFFCC'><strong>Summe</strong></td>");
print ("<td><input name='totalMTBF' type='text' size='15' value='0' readonly='readonly'/></td>");
print ("<td><input name='totalMTBFI' type='text' size='15' value='0' readonly='readonly'/></td>");
print ("<td><input name='totalMTBSC' type='text' size='15' value='0' readonly='readonly'/></td>");
print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP>");print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP>");print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP >");
print ("<td align='center' colspan='7'></td>");
print ("<td align='right' colspan='4' bgcolor='#FFFCCC'><strong>MTBF in J.</strong></td>");
print ("<td><input name='MTBFIJ' type='text' size='15' value='0' maxlength='20' readonly='readonly'/></td>");
print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP >");
print ("<td align='center' colspan='7'></td>");
print ("<td align='right' colspan='4' bgcolor='#FFFCCC'><strong>MTBFI in J.</strong></td>");
print ("<td bgcolor='#FFFCCC'> </td>");
print ("<td><input name='MTBFIIJ' type='text' size='15' value='0' readonly='readonly'/></td>");
print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP >");
print ("<td align='center' colspan='7'></td>");
print ("<td align='right' colspan='4' bgcolor='#FFFCCC'><strong>MTBSC in J.</strong></td>");
print ("<td colspan='2' bgcolor='#FFFCCC'> </td>");
print ("<td><input name='MTBSCIJ' type='text' size='15' value='0' readonly='readonly'/></td>");
print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP>");print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP>");print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP >");
print ("<td align='center' colspan='7'></td>");
print ("<td align='right' colspan='7' bgcolor='#FFFCCC'><strong>Fehler pro Einheit im J.</strong></td>");
print ("<td><input name='FEIJ' type='text' size='15' value='0' readonly='readonly'/></td>");
print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP >");
print ("<td align='center' colspan='7'></td>");
print ("<td align='right' colspan='7' bgcolor='#FFFCCC'><strong>ET pro Einheit im J.</strong></td>");
print ("<td bgcolor='#FFFCCC'> </td>");
print ("<td><input name='ETEJ' type='text' size='15' value='0' readonly='readonly'/></td>");
print("</TR>\n");
print("<TR ALIGN=LEFT VALIGN=TOP >");
print ("<td align='center' colspan='7'></td>");
print ("<td align='right' colspan='7' bgcolor='#FFFCCC'><strong>SC pro Einheit im J.</strong></td>");
print ("<td colspan='2' bgcolor='#FFFCCC'> </td>");
print ("<td><input name='SCEJ' type='text' size='15' value='0' readonly='readonly'/></td>");
print("</TR>\n");
print("</TABLE>\n");
}
else{
echo"<p> </p>";
echo"<p> </p>";
echo"<strong><h3 align='center'>Bitte wählen Sie mindestens ein System aus!</h3></strong>";
}
?>
<?php include("includes/disconnect.php"); ?>
</form>
<div style="background-color:#003366; font-size:16px; color:#FFFFFF" align="center">MTBF Tool 1.0</div>
</body>
</html>