Files
2026-09-03 11:24:19 +02:00

303 lines
11 KiB
PHP

<?php session_start();
?>
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="../images/SoftSPM.ico">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Zrzut wody na odprowadzalniki</title>
<!-- Bootstrap -->
<link href="./bootstrap.min.css" rel="stylesheet">
</head>
<body>
<script src="./jquery.min.js"></script>
<?php
date_default_timezone_set('Europe/Warsaw');
require_once("../func.php");
require_once("../dbaccess.php");
$polacz = mysql_connect($db_host, $db_user, $db_user_pass) or die ('cannot connect to db');
mysql_select_db($db_name);
mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER_SET utf8_general_ci");
?>
<?php
function cdt($inDate)
{
unset($out);
$out = (float) str_replace(array('-',' '), array('',''), $inDate);
return $out;
}
function getFullTree($inOdprowadzID)
{
unset($outParam);
unset($counter); $counter=0;
$counter+= (float) sqlStringValue("select sum(Q_MIN) QM from softspm_rep.rep_003_data where WWD_ID=".$inOdprowadzID, "QM");
// ================================================================================================================================
unset($getArray01);
$getArray01 = sqlGetResAsArray("select WWD_ID,WWD_NAME from softspm_rep.rep_003_data where WWD_PARENT_ID=".$inOdprowadzID." and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' group by WWD_ID");
for($i1=0; $i1<count($getArray01); $i1++)
{
$counter+= (float) sqlStringValue("select sum(Q_MIN) QM from softspm_rep.rep_003_data where WWD_ID=".$getArray01[$i1]['WWD_ID'], "QM");
// ================================================================================================================================
if ($getArray01[$i1]['WWD_ID']>0)
{
unset($getArray02);
$getArray02 = sqlGetResAsArray("select WWD_ID,WWD_NAME from softspm_rep.rep_003_data where WWD_PARENT_ID=".$getArray01[$i1]['WWD_ID']." and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' group by WWD_ID");
for($i2=0; $i2<count($getArray02); $i2++)
{
$counter+= (float) sqlStringValue("select sum(Q_MIN) QM from softspm_rep.rep_003_data where WWD_ID=".$getArray02[$i2]['WWD_ID'], "QM");
// ================================================================================================================================
if ($getArray02[$i2]['WWD_ID']>0)
{
unset($getArray03);
$getArray03 = sqlGetResAsArray("select WWD_ID,WWD_NAME from softspm_rep.rep_003_data where WWD_PARENT_ID=".$getArray02[$i2]['WWD_ID']." and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' group by WWD_ID");
for($i3=0; $i3<count($getArray03); $i3++)
{
$counter+= (float) sqlStringValue("select sum(Q_MIN) QM from softspm_rep.rep_003_data where WWD_ID=".$getArray03[$i3]['WWD_ID'], "QM");
// ================================================================================================================================
if ($getArray03[$i3]['WWD_ID']>0)
{
unset($getArray04);
$getArray04 = sqlGetResAsArray("select WWD_ID,WWD_NAME from softspm_rep.rep_003_data where WWD_PARENT_ID=".$getArray03[$i3]['WWD_ID']." and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' group by WWD_ID");
for($i4=0; $i4<count($getArray04); $i4++)
{
$counter+= (float) sqlStringValue("select sum(Q_MIN) QM from softspm_rep.rep_003_data where WWD_ID=".$getArray04[$i4]['WWD_ID'], "QM");
// ================================================================================================================================
if ($getArray04[$i4]['WWD_ID']>0)
{
unset($getArray05);
$getArray05 = sqlGetResAsArray("select WWD_ID,WWD_NAME from softspm_rep.rep_003_data where WWD_PARENT_ID=".$getArray04[$i4]['WWD_ID']." and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' group by WWD_ID");
for($i5=0; $i5<count($getArray05); $i5++)
{
$counter+= (float) sqlStringValue("select sum(Q_MIN) QM from softspm_rep.rep_003_data where WWD_ID=".$getArray05[$i5]['WWD_ID'], "QM");
}
}
// ================================================================================================================================
}
}
// ================================================================================================================================
}
}
// ================================================================================================================================
}
}
// ================================================================================================================================
}
// ================================================================================================================================
// print_r($getArray01);
// ================================================================================================================================
// ================================================================================================================================
// ================================================================================================================================
// ================================================================================================================================
// ================================================================================================================================
// ================================================================================================================================
$outParam = (float) $counter;
return $outParam;
}
?>
<div class="panel panel-danger">
<div class="panel-heading">
<h3 class="panel-title">Zrzut wody na odprowadzalniki <?php echo $_SESSION['syndis_eq_stock'];?> <br/>Studnie pracujące - status ON</h3>
</div>
<div class="panel-body">
Na dzień:<b> <?php echo sqlStringValue("select max(WLL_AUDIT_CD) DT from softspm_rep.rep_003_data", "DT"); ?></b>
</div>
<div class="panel-footer">
<a class="btn btn-default" href="#" role="button" onclick="window.print();">Drukuj &nbsp;&nbsp;<span class="glyphicon glyphicon-print" aria-hidden="true"></span></a>&nbsp;&nbsp;&nbsp;
<a class="btn btn-success" href="#" role="button">Eksport do Excel &nbsp;&nbsp;<span class="glyphicon glyphicon-file" aria-hidden="true"></span></a>&nbsp;&nbsp;&nbsp;
<a class="btn btn-danger" href="#" role="button">Eksport do PDF &nbsp;&nbsp;<span class="glyphicon glyphicon-file" aria-hidden="true"></span></a>
</div>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th>Zrzut</th>
<th></th>
<th>[m<sup>3</sup>/min]</th>
</tr>
</thead>
<?php
$levVAL=0;
unset($rep003Array_00);
$rep003Array_00 = sqlGetResAsArray("select * from seg_water_drainage where WWD_PARENT_ID is null order by WWD_NAME");
for($f=0;$f<count($rep003Array_00);$f++)
{
//poziom pierwszy
unset($rep003Array_01);
$rep003Array_01 = sqlGetResAsArray("select WWD_ID,WWD_NAME from softspm_rep.rep_003_data where WWD_PARENT_ID=".$rep003Array_00[$f]['WWD_ID']." and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' group by WWD_ID order by WWD_NAME");
if (sqlValue("select count(*) from softspm_rep.rep_003_data where WWD_PARENT_ID=".$rep003Array_00[$f]['WWD_ID']." and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."'")>0)
{
echo"
<tr style='font-weight: bolder; background-color: #B22222; color: #ffffff;'>
<td style='width: 15%;'>".$rep003Array_00[$f]['WWD_NAME']."</td>
<td></td>
<td></td>
</tr>
";
// ================================================================================================================================
unset($rep003ArrayVal);$rep003ArrayVal=0;
for ($i1=0; $i1<count($rep003Array_01); $i1++)
{
$rep003ArrayVal+= (float) getFullTree($rep003Array_01[$i1]['WWD_ID']);
echo"
<tr>
<td></td>
<td style='background-color: #FFEBCD;'>".$rep003Array_01[$i1]['WWD_NAME']."</td>
<td style='font-weight: bolder; background-color: #ADD8E6;'>".getFullTree($rep003Array_01[$i1]['WWD_ID'])."</td>
</tr>";
}
echo"
<tr style='font-weight: bolder; background-color: #0000CD; color: #ffffff;'>
<td style='text-align: right;'>Łącznie</td>
<td></td>
<td>".$rep003ArrayVal."</td>
</tr><tr style='height: 10px;'><tr>
";
unset($rep003ArrayVal);
// ================================================================================================================================
// ================================================================================================================================
for ($i1=0; $i1<count($rep003Array_01); $i1++)
{
unset($rep003ArrayVal);$rep003ArrayVal=0;
echo"
<tr style='font-weight: bolder; background-color: #FFEBCD;'>
<td>".$rep003Array_01[$i1]['WWD_NAME']."</td>
<td style='text-align: center;'> &mdash; &mdash; &mdash; &rang; &nbsp;&nbsp;&nbsp; ".$rep003Array_00[$f]['WWD_NAME']."</td>
<td></td>
</tr>
";
unset($rep003Array_02);
$rep003Array_02 = sqlGetResAsArray("select * from softspm_rep.rep_003_data where WWD_ID=".$rep003Array_01[$i1]['WWD_ID']." and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' order by WLL_NAME");
for($i2=0; $i2<count($rep003Array_02); $i2++)
{
$rep003ArrayVal += (float) $rep003Array_02[$i2]['Q_MIN'];
echo"
<tr>
<td>".$rep003Array_02[$i2]['WLL_BARIERA']."</td>
<td>".$rep003Array_02[$i2]['WLL_NAME']."</td>
<td>".$rep003Array_02[$i2]['Q_MIN']."</td>
</tr>
";
}
unset($rep003Array_02);
$rep003Array_02 = sqlGetResAsArray("select * from softspm_rep.rep_003_data where WWD_ID=".$rep003Array_01[$i1]['WWD_ID']." and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' GROUP by WWD_ID");
for($i2=0; $i2<count($rep003Array_02); $i2++)
{
unset($rep003Array_03);
$rep003Array_03 = sqlGetResAsArray("select WWD_ID,WWD_NAME from softspm_rep.rep_003_data where WWD_PARENT_ID=".$rep003Array_02[$i2]['WWD_ID']." and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' GROUP by WWD_ID");
for($i3=0; $i3<count($rep003Array_03); $i3++)
{
$rep003ArrayVal += (float) getFullTree($rep003Array_03[$i3]['WWD_ID']);
echo"
<tr>
<td></td>
<td style='background-color: #FFEBCD;'>".$rep003Array_03[$i3]['WWD_NAME']."</td>
<td>".getFullTree($rep003Array_03[$i3]['WWD_ID'])."</td>
</tr>";
}
}
echo"
<tr style='font-weight: bolder; background-color: #ADD8E6;'>
<td style='text-align: right;'>Łącznie</td>
<td></td>
<td>".$rep003ArrayVal."</td>
</tr><tr style='height: 10px;'><tr>
";
unset($rep003ArrayVal);
// ================================================================================================================================
}
// ================================================================================================================================
}
}
?>
</table>
<?php
mysql_close($polacz);
?>
<script src="./bootstrap.min.js"></script>
</body>
</html>