254 lines
12 KiB
PHP
254 lines
12 KiB
PHP
<?php
|
|
if (!empty($_SESSION['site304']))
|
|
{
|
|
?>
|
|
|
|
|
|
<?php
|
|
//dodawanie silnika na stan
|
|
if ($_POST['inEngineID']>0 && $_POST['subEngineSave']==$lab_ButtonName_Save)
|
|
{
|
|
if (sqlValue("select count(1) from seg_dev_resources where DRS_DEV_TYPE=11 and DRS_DEV_ID=".$_POST['inEngineID']." and DRS_SN_NUMBER='".$_POST['inEngineSN']."'")==0)
|
|
{
|
|
mysql_query("INSERT INTO seg_dev_resources SET DRS_DEV_ID=".$_POST['inEngineID'].",DRS_DEV_TYPE=11,DRS_SN_NUMBER='".$_POST['inEngineSN']."',DRS_BUY_DATE='".$_POST['inEngineBuyDate']."',DRS_AVAILABLE_DATE='".$_POST['inEngineAvDate']."',DRS_STATUS_DIC_ID=".$_POST['inEngineStat'].",DRS_RESOURCES_DIC_ID=".$_POST['inEngineDevRes'].",DRS_DEV_ATTENTION='".$_POST['inEngineAtt']."',DRS_DEPARTMENT = '".$_SESSION['syndis_eq_stock']."',DRS_AUDIT_USR='".$_POST['inEngineVol']."',DRS_AUDIT_DATE=now()");
|
|
$maxDRSid = sqlValue("select max(DRS_ID) from seg_dev_resources");
|
|
mysql_query("INSERT INTO seg_dev_resources_det SET DRD_DRS_ID=$maxDRSid,DRD_RESOURCES_DETAIL=(select DIC_ID from sys_dictionaries where DIC_TYPE='DEV_RESOURCES_DETAIL' and DIC_NAME='ASSET'),DRD_VALUE='".$_POST['inEngineEST']."',DRD_AUDIT_USR='".$_SESSION['user']."',DRD_AUDIT_DATE=now()");
|
|
mysql_query("insert into seg_dev_resources_his select * from seg_dev_resources where DRS_ID=$maxDRSid");
|
|
|
|
echo"<div class='actionOK'>$lab_Field_site803_013</div>";
|
|
unset($maxDRSid);
|
|
delSearchSessionData();
|
|
}
|
|
else
|
|
{
|
|
echo"<div class='actionERROR'>$lab_SaveRecordNotification_005</div>";
|
|
delSearchSessionData();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//usuwanie
|
|
// ==================================================================================
|
|
if (!empty($_GET['param']))
|
|
{
|
|
$tpmArray=explode(',', $_GET['param']);
|
|
|
|
if ($tpmArray[0]>0 && $tpmArray[1]=='del' && $tpmArray[2]==md5($tpmArray[0]))
|
|
{
|
|
// Sprawdza warunek, czy nie jest powiązany z jakimś stanem
|
|
if (sqlValue("select count(*) from seg_well_pump_eng_rel where RWL_ENG_DRS_ID=".$tpmArray[0])>0)
|
|
{
|
|
echo"<div class='actionERROR'>$lab_DeleteRecordNotification_003</div>";
|
|
delSearchSessionData();
|
|
}
|
|
else {
|
|
mysql_query("DELETE FROM seg_dev_resources WHERE DRS_ID=".$tpmArray[0]);
|
|
echo"<div class='actionOK'>$lab_DeleteRecordNotification_001</div>";
|
|
delSearchSessionData();
|
|
}
|
|
|
|
}
|
|
}
|
|
// ==================================================================================
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php
|
|
if (!$_POST['sr_status']) $_POST['sr_status']=100;
|
|
?>
|
|
|
|
<?php
|
|
//paginacja
|
|
if (!$_GET['pgn']) {$_GET['pgn']=1; delSearchSessionData(); }
|
|
if ($_POST['sub_search']=='Szukaj') $_SESSION['site304_input'] = $_POST['sr_well'];
|
|
?>
|
|
|
|
|
|
|
|
<form action="./?pg=site304&pgn=1" method="post">
|
|
<div class="tag100">
|
|
<table>
|
|
<tr>
|
|
<td>Typ silnika:</td>
|
|
<td style="width: 10px;"></td>
|
|
<td><input type="text" name="sr_well" value="<?php echo $_SESSION['site304_input'];?>"></td>
|
|
<td style="width: 10px;"></td>
|
|
<td>producent:</td>
|
|
<td style="width: 5px;"></td>
|
|
<td>
|
|
<select name="sr_status">
|
|
<?php
|
|
$wynik = mysql_query("select MCF_ID,MCF_NAME from seg_manufacturers order by MCF_NAME");
|
|
if($wynik)while ($r = mysql_fetch_array($wynik))
|
|
{
|
|
$resID=$r["MCF_ID"];
|
|
$resDESC=$r["MCF_NAME"];
|
|
|
|
if ($_POST['sr_status']==$resID)
|
|
echo"<option value='$resID' selected>$resDESC</option>";
|
|
else
|
|
echo"<option value='$resID'>$resDESC</option>";
|
|
}
|
|
if ($_POST['sr_status']==100)
|
|
echo"<option value='100' selected>Wszyscy</option>";
|
|
else
|
|
echo"<option value='100'>Wszyscy</option>";
|
|
?>
|
|
</select>
|
|
</td>
|
|
<td style="width: 10px;"></td>
|
|
<td><input type="submit" name="sub_search" value="Szukaj" class="btn btn-default btn-sm"></td>
|
|
<td></td>
|
|
</tr>
|
|
<tr><td> </td></tr>
|
|
<tr>
|
|
<td colspan="3">
|
|
<?php
|
|
if (!empty($_POST['sr_all'])) echo"<input type='checkbox' name='sr_all' value='1' checked>";
|
|
else echo"<input type='checkbox' name='sr_all' value='1'>";
|
|
?>
|
|
<?php echo $lab_HistoricalData_007; ?>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</form>
|
|
|
|
<div class="tag100">
|
|
<div class="head_tag"><?php echo $lab_Tag_site304_001 ;?></div>
|
|
<div class="tag">
|
|
<table WIDTH="100%" class="tag">
|
|
<TR>
|
|
<TD class="label">Lp.</TD>
|
|
<TD class="label"><?php echo $lab_Field_site204_001 ;?></TD>
|
|
<TD class="label">Nowe</TD>
|
|
<TD class="label">Rezerwa</TD>
|
|
<TD class="label">Remont</TD>
|
|
<TD class="label">Eksploatacja SPM</TD>
|
|
<TD class="label">Bestgum</TD>
|
|
<TD class="label">Kasacja [w likwidacji]</TD>
|
|
<TD class="label">Kasacja [zatopione]</TD>
|
|
<TD class="label">Razem</TD>
|
|
</TR>
|
|
|
|
<?php
|
|
|
|
if (empty($_SESSION['site304_array']) || $_POST['sub_search']=='Szukaj')
|
|
{
|
|
unset($_SESSION['site304_array']);
|
|
if (empty($_POST['sr_all'])) $subQuery .= " limit 100";
|
|
|
|
//$listArray = sqlGetResAsArray("select ENG_ID,count(ENG_ID) ILOSC,ENG_NAME from seg_dev_resources,seg_engines where DRS_DEV_TYPE=11 and DRS_DEV_ID=ENG_ID and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' and ENG_NAME like '%".$_POST['sr_well']."%' and ENG_ID>0 and (DRS_RESOURCES_DIC_ID in (1,2,3,707) or (DRS_RESOURCES_DIC_ID=40) and DRS_DEV_ATTENTION in ('1401','1524')) group by ENG_ID,ENG_NAME order by ENG_NAME,ENG_POWER".$subQuery);
|
|
$listArray = sqlGetResAsArray("select * from seg_engines,seg_dev_resources where DRS_DEV_TYPE=11 and DRS_DEV_ID=ENG_ID and ENG_NAME like '%".$_POST['sr_well']."%' and (DRS_RESOURCES_DIC_ID in (1,2,3,707) or (DRS_RESOURCES_DIC_ID=40 and DRS_DEV_ATTENTION in ('1401','1524'))) and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' group by ENG_ID order by ENG_NAME,ENG_VOLTAGE");
|
|
|
|
for ($i=0; $i<count($listArray); $i++)
|
|
{
|
|
unset($suma); unset($rec1); unset($rec2); unset($rec3ALL); unset($rec3SPM);
|
|
unset($rec707); unset($rec40_LIK); unset($rec40_ZAT); unset($rec3BESTGUM);
|
|
|
|
$rec1 = sqlValue("select count(*) CNT from seg_dev_resources,seg_engines where DRS_DEV_TYPE=11 and DRS_DEV_ID=ENG_ID and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' and ENG_ID=".$listArray[$i]['ENG_ID']." and DRS_RESOURCES_DIC_ID=1");
|
|
$rec2 = sqlValue("select count(*) CNT from seg_dev_resources,seg_engines where DRS_DEV_TYPE=11 and DRS_DEV_ID=ENG_ID and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' and ENG_ID=".$listArray[$i]['ENG_ID']." and DRS_RESOURCES_DIC_ID=2");
|
|
$rec3ALL = sqlValue("select count(*) CNT from seg_dev_resources,seg_engines where DRS_DEV_TYPE=11 and DRS_DEV_ID=ENG_ID and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' and ENG_ID=".$listArray[$i]['ENG_ID']." and DRS_RESOURCES_DIC_ID=3");
|
|
$rec3SPM = sqlValue("select count(*) from seg_well_pump_eng_rel where RWL_ENG_DRS_ID in (select DRS_ID from seg_dev_resources,seg_engines where DRS_DEV_TYPE=11 and DRS_DEV_ID=ENG_ID and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' and ENG_ID=".$listArray[$i]['ENG_ID']." and DRS_RESOURCES_DIC_ID=3)");
|
|
$rec707 = sqlValue("select count(*) CNT from seg_dev_resources,seg_engines where DRS_DEV_TYPE=11 and DRS_DEV_ID=ENG_ID and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' and ENG_ID=".$listArray[$i]['ENG_ID']." and DRS_RESOURCES_DIC_ID=707");
|
|
$rec40_LIK = sqlValue("select count(*) CNT from seg_dev_resources,seg_engines where DRS_DEV_TYPE=11 and DRS_DEV_ID=ENG_ID and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' and ENG_ID=".$listArray[$i]['ENG_ID']." and DRS_RESOURCES_DIC_ID=40 and DRS_DEV_ATTENTION='1524'");
|
|
//2018-04-08
|
|
$rec40_ZAT = sqlValue("select count(*) CNT from seg_dev_resources,seg_engines where DRS_DEV_TYPE=11 and DRS_DEV_ID=ENG_ID and DRS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."' and ENG_ID=".$listArray[$i]['ENG_ID']." and DRS_RESOURCES_DIC_ID=40 and DRS_DEV_ATTENTION='1401'");
|
|
//$rec40_ZAT = sqlValue("select count(*) CNT from seg_dev_resources,seg_engines where DRS_DEV_TYPE=11 and DRS_DEV_ID=ENG_ID and ENG_ID=".$listArray[$i]['ENG_ID']." and DRS_ID in (select RWS_ENG_DRS_ID from seg_wellsink_pump_eng_rel where RWS_ENG_DRS_ID is not null and RWS_DEPARTMENT='".$_SESSION['syndis_eq_stock']."')");
|
|
|
|
|
|
if ($rec1>0) $suma += $rec1; else $rec1=null;
|
|
if ($rec2>0) $suma += $rec2; else $rec2=null;
|
|
if ($rec3ALL>0) $suma += $rec3ALL; else $rec3ALL=null;
|
|
if ($rec707>0) $suma += $rec707; else $rec707=null;
|
|
if ($rec40_LIK>0) $suma += $rec40_LIK; else $rec40_LIK=null;
|
|
if ($rec40_ZAT>0) $suma += $rec40_ZAT; else $rec40_ZAT=null;
|
|
|
|
if ($rec3ALL>$rec3SPM) $rec3BESTGUM = $rec3ALL-$rec3SPM;
|
|
if ($rec3SPM==0) $rec3SPM=null;
|
|
|
|
|
|
$_SESSION['site304_array'][]=array(
|
|
'id' => $listArray[$i]['ENG_ID'],
|
|
'engName' => $listArray[$i]['ENG_NAME'],
|
|
'engcount' => $suma,
|
|
'nowe' => $rec1,
|
|
'rezerwa' => $rec2,
|
|
'remont' => $rec707,
|
|
'eksp_spm' => $rec3SPM,
|
|
'bestgum' => $rec3BESTGUM,
|
|
'kas_lik' => $rec40_LIK,
|
|
'kas_zatop' => $rec40_ZAT
|
|
);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
$start=($_GET['pgn']-1)*20;
|
|
$stop = $_GET['pgn']*20;
|
|
if ($stop>count($_SESSION['site304_array'])) $stop=count($_SESSION['site304_array']);
|
|
|
|
for($i=$start;$i<$stop;$i++)
|
|
{
|
|
echo"
|
|
<TR STYLE='cursor: pointer;' onclick=".chr(34)."document.location.href='./?pg=site304list&eng=".$_SESSION['site304_array'][$i]['id']."'".chr(34).">
|
|
<TD class='field_left'>".($i+1).".</TD>
|
|
<TD class='field_left'>".$_SESSION['site304_array'][$i]['engName']."</TD>
|
|
<TD class='field_right'>".$_SESSION['site304_array'][$i]['nowe']."</TD>
|
|
<TD class='field_right'>".$_SESSION['site304_array'][$i]['rezerwa']."</TD>
|
|
<TD class='field_right'>".$_SESSION['site304_array'][$i]['remont']."</TD>
|
|
<TD class='field_right'>".$_SESSION['site304_array'][$i]['eksp_spm']."</TD>
|
|
<TD class='field_right'>".$_SESSION['site304_array'][$i]['bestgum']."</TD>
|
|
<TD class='field_right'>".$_SESSION['site304_array'][$i]['kas_lik']."</TD>
|
|
<TD class='field_right'>".$_SESSION['site304_array'][$i]['kas_zatop']."</TD>
|
|
<TD class='field_right'>".$_SESSION['site304_array'][$i]['engcount']."</TD>
|
|
</TR>
|
|
";
|
|
}
|
|
?>
|
|
</table>
|
|
|
|
|
|
|
|
<table style="width:100%; background-color: #f5f5f5">
|
|
<tr>
|
|
<td style="width: 25%; text-align: left;"><span class="resume">Wyników: <?php echo count($_SESSION['site304_array']); ?></span></td>
|
|
<td style="width: 50%; text-align: center;">
|
|
<?php
|
|
if (count($_SESSION['site304_array'])>20)
|
|
echo pagination_grid('?pg=site304', $_GET['pgn'], count($_SESSION['site304_array']));
|
|
?>
|
|
</td>
|
|
<td style="width: 25%; text-align: right;">
|
|
<a href="./export/site304_xls.php" target="_blank" title="Export do EXCEL"><img src="./images/excel_ico.png" style="max-width: 20px; border: 0;"></a>
|
|
<a href="./export/site304_print.php" target="_blank" title="Wydruk"><img src="./images/printer-icon.png" style="max-width: 20px; border: 0;"></a>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<?php
|
|
if (!empty($_SESSION['site304_edit']))
|
|
echo"
|
|
<div class=tag_buttons>
|
|
<a href='?pg=site304A'> <INPUT class='btn btn-success btn-sm' TYPE='BUTTON' VALUE='$lab_ButtonName_Add'></A>
|
|
</div>
|
|
";
|
|
?>
|
|
|
|
|
|
</div>
|
|
|
|
<?php
|
|
}
|
|
else showFooterWarningAccessNotification($lab_FooterWarningAccessNotification_001);
|
|
?>
|