170 lines
8.3 KiB
PHP
170 lines
8.3 KiB
PHP
<!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>Brakujące agregaty w zleceniach w SoftSPM</title>
|
|
|
|
<!-- Bootstrap -->
|
|
<link href="bootstrap.min.css" rel="stylesheet">
|
|
|
|
|
|
</head>
|
|
<body>
|
|
<?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");
|
|
|
|
|
|
?>
|
|
|
|
<h1>Analiza danych - POMPY...</h1>
|
|
|
|
<?php
|
|
unset($lostAggArray);
|
|
$lostAggArray = sqlGetResAsArray("select * from rep_aggregate_departments where PUP_DRS_ID is null or PUP_DRS_ID=0");
|
|
|
|
for($i=0; $i<count($lostAggArray); $i++)
|
|
{
|
|
unset($pupArray);
|
|
$pupArray = sqlGetResAsArray("select * from seg_pumps where PUP_NAME='".$lostAggArray[$i]['PUP_NAME']."'");
|
|
|
|
unset($devArray);
|
|
$devArray = sqlGetResAsArray("select * from seg_dev_resources where DRS_SN_NUMBER='".$lostAggArray[$i]['PUP_SN_NO']."'");
|
|
|
|
// brakuje na stanie pompy - dodaje ze statusami 1
|
|
if ((empty($devArray[0]['DRS_ID']) || $devArray[0]['DRS_ID']<=0) && $pupArray[0]['PUP_ID']>0)
|
|
{
|
|
echo 'Brakuje pompy na stanie - dodaje nową';
|
|
mysql_query("INSERT INTO seg_dev_resources SET DRS_DEV_ID='".$pupArray[0]['PUP_ID']."',DRS_DEV_TYPE=10,DRS_SN_NUMBER='".$lostAggArray[$i]['PUP_SN_NO']."',DRS_STATUS_DIC_ID=1,DRS_RESOURCES_DIC_ID=1,DRS_DEPARTMENT='".$lostAggArray[$i]['PUP_DEPARTMENT']."',DRS_AUDIT_DATE=now()");
|
|
|
|
unset($devArray);
|
|
$devArray = sqlGetResAsArray("select * from seg_dev_resources where DRS_SN_NUMBER='".$lostAggArray[$i]['PUP_SN_NO']."'");
|
|
}
|
|
// istnieje agregat - aktualizauje dane
|
|
elseif ($devArray[0]['DRS_ID']>0 && $pupArray[0]['PUP_ID']>0)
|
|
{
|
|
echo 'Aktualizuje dane o pompie';
|
|
mysql_query("UPDATE seg_dev_resources SET DRS_DEV_ID='".$pupArray[0]['PUP_ID']."',DRS_DEV_TYPE=10,DRS_STATUS_DIC_ID=1,DRS_RESOURCES_DIC_ID=1,DRS_DEPARTMENT='".$lostAggArray[$i]['PUP_DEPARTMENT']."',DRS_AUDIT_DATE=now() WHERE DRS_ID=".$devArray[0]['DRS_ID']);
|
|
}
|
|
|
|
|
|
// aktualizauje wpisy w tabeli rep_aggregate_departments
|
|
if ($devArray[0]['DRS_ID']>0 && $pupArray[0]['PUP_ID']>0)
|
|
{
|
|
mysql_query("UPDATE rep_aggregate_departments SET PUP_ID='".$pupArray[0]['PUP_ID']."',PUP_DRS_ID='".$devArray[0]['DRS_ID']."',PUP_Q_N='".$pupArray[0]['PUP_Q_N']."',PUP_H_P='".$pupArray[0]['PUP_H_P']."' WHERE RAD_ID=".$lostAggArray[$i]['RAD_ID']);
|
|
}
|
|
|
|
echo'<br/>';
|
|
}
|
|
?>
|
|
|
|
<h1>Analiza danych - SILNIKI...</h1>
|
|
|
|
<?php
|
|
unset($lostAggArray);
|
|
$lostAggArray = sqlGetResAsArray("select * from rep_aggregate_departments where ENG_DRS_ID is null or ENG_DRS_ID=0");
|
|
for($i=0; $i<count($lostAggArray); $i++)
|
|
{
|
|
if ($lostAggArray[$i]['ENG_VOLTAGE']<200) $lostAggArray[$i]['ENG_VOLTAGE']=500;
|
|
|
|
unset($engArray);
|
|
$engArray = sqlGetResAsArray("select * from seg_engines where ENG_NAME='".$lostAggArray[$i]['ENG_NAME']."' and ENG_VOLTAGE='".$lostAggArray[$i]['ENG_VOLTAGE']."'");
|
|
|
|
unset($devArray);
|
|
$devArray = sqlGetResAsArray("select * from seg_dev_resources where DRS_SN_NUMBER='".$lostAggArray[$i]['ENG_SN_NO']."'");
|
|
|
|
|
|
// brakuje na stanie silnika - dodaje ze statusami 1
|
|
if ((empty($devArray[0]['DRS_ID']) || $devArray[0]['DRS_ID']<=0) && $engArray[0]['ENG_ID']>0)
|
|
{
|
|
echo 'Brakuje silnika na stanie - dodaje nowy';
|
|
mysql_query("INSERT INTO seg_dev_resources SET DRS_DEV_ID='".$engArray[0]['ENG_ID']."',DRS_DEV_TYPE=11,DRS_SN_NUMBER='".$lostAggArray[$i]['ENG_SN_NO']."',DRS_STATUS_DIC_ID=1,DRS_RESOURCES_DIC_ID=1,DRS_DEPARTMENT='".$lostAggArray[$i]['PUP_DEPARTMENT']."',DRS_AUDIT_DATE=now()");
|
|
|
|
unset($devArray);
|
|
$devArray = sqlGetResAsArray("select * from seg_dev_resources where DRS_SN_NUMBER='".$lostAggArray[$i]['ENG_SN_NO']."'");
|
|
}
|
|
// istnieje agregat - aktualizauje dane
|
|
elseif ($devArray[0]['DRS_ID']>0 && $engArray[0]['ENG_ID']>0)
|
|
{
|
|
echo 'Aktualizuje dane o silniku';
|
|
mysql_query("UPDATE seg_dev_resources SET DRS_DEV_ID='".$engArray[0]['ENG_ID']."',DRS_DEV_TYPE=11,DRS_STATUS_DIC_ID=1,DRS_RESOURCES_DIC_ID=1,DRS_DEPARTMENT='".$lostAggArray[$i]['PUP_DEPARTMENT']."',DRS_AUDIT_DATE=now() WHERE DRS_ID=".$devArray[0]['DRS_ID']);
|
|
}
|
|
|
|
// aktualizauje wpisy w tabeli rep_aggregate_departments
|
|
if ($devArray[0]['DRS_ID']>0 && $engArray[0]['ENG_ID']>0)
|
|
{
|
|
mysql_query("UPDATE rep_aggregate_departments SET ENG_ID='".$engArray[0]['ENG_ID']."',ENG_DRS_ID='".$devArray[0]['DRS_ID']."' WHERE RAD_ID=".$lostAggArray[$i]['RAD_ID']);
|
|
}
|
|
|
|
echo'<br/>';
|
|
}
|
|
?>
|
|
|
|
|
|
<h1>Popmy - dodatek...</h1>
|
|
<?php
|
|
unset($lostAggArray);
|
|
$lostAggArray = sqlGetResAsArray("select stp_stapo_id_p,stp_stapo_typ_p,stp_stapo_nr_p,stp_stapo_stat_id,DRS_ID,DRS_SN_NUMBER,stp_status_kod,stp_status_nazwa,stp_uzytkownik_kod,stp_uzytkownik_nazwa,stp_stapo_user_id,(case when stp_stapo_stat_id=9 then 707 when stp_stapo_stat_id=1 then 3 when stp_stapo_stat_id=5 then 40 when stp_stapo_stat_id=7 then 1 when stp_stapo_stat_id=10 then 707 when stp_stapo_stat_id=4 then 707 when stp_stapo_stat_id=8 then 707 when stp_stapo_stat_id=3 then 707 when stp_stapo_stat_id=2 then 707 when stp_stapo_stat_id=6 then 2 else 707 end) DEV_STATUS from stp_status,stp_stapo left join seg_dev_resources on stp_stapo_nr_p=DRS_SN_NUMBER and DRS_DEV_TYPE=10 left join stp_uzytkownik on stp_stapo_user_id=stp_uzytkownik_id_u where stp_stapo_stat_id=stp_status_id_s and DRS_SN_NUMBER is null and stp_stapo_user_id in (1,2,3)");
|
|
for($i=0; $i<count($lostAggArray); $i++)
|
|
{
|
|
unset($pupArray);
|
|
$pupArray = sqlGetResAsArray("select * from seg_pumps where PUP_NAME='".$lostAggArray[$i]['stp_stapo_typ_p']."'");
|
|
|
|
if ($pupArray[0]['PUP_ID']>0)
|
|
{
|
|
unset($dep);
|
|
if ($lostAggArray[$i]['stp_stapo_user_id']==1) $dep = 'P/Bełchatów';
|
|
elseif ($lostAggArray[$i]['stp_stapo_user_id']==2) $dep = 'Dębina';
|
|
elseif ($lostAggArray[$i]['stp_stapo_user_id']==3) $dep = 'P/Szczerców';
|
|
|
|
mysql_query("INSERT INTO seg_dev_resources SET DRS_DEV_ID='".$pupArray[0]['PUP_ID']."',DRS_DEV_TYPE=10,DRS_SN_NUMBER='".$lostAggArray[$i]['stp_stapo_nr_p']."',DRS_STATUS_DIC_ID=7,DRS_RESOURCES_DIC_ID='".$lostAggArray[$i]['DEV_STATUS']."',DRS_DEPARTMENT='".$dep."',DRS_AUDIT_USR='manual',DRS_AUDIT_DATE=now()");
|
|
|
|
echo'Dodano: '.$pupArray[0]['PUP_ID'].'<br/>';
|
|
}
|
|
}
|
|
?>
|
|
|
|
|
|
<h1>Silniki - dodatek...</h1>
|
|
<?php
|
|
unset($lostAggArray);
|
|
$lostAggArray = sqlGetResAsArray("select stp_stamot_id_m,stp_stamot_typ_m,stp_stamot_nr_m,stp_stamot_u,stp_stamot_stat_id,DRS_ID,DRS_SN_NUMBER,stp_status_kod,stp_status_nazwa,stp_uzytkownik_kod,stp_uzytkownik_nazwa,stp_stamot_user_id, (case when stp_stamot_stat_id=9 then 707 when stp_stamot_stat_id=1 then 3 when stp_stamot_stat_id=5 then 40 when stp_stamot_stat_id=7 then 1 when stp_stamot_stat_id=10 then 707 when stp_stamot_stat_id=4 then 707 when stp_stamot_stat_id=8 then 707 when stp_stamot_stat_id=3 then 707 when stp_stamot_stat_id=2 then 707 when stp_stamot_stat_id=6 then 2 else 707 end) DEV_STATUS from stp_status,stp_stamot left join seg_dev_resources on stp_stamot_nr_m=DRS_SN_NUMBER and DRS_DEV_TYPE=11 left join stp_uzytkownik on stp_stamot_user_id=stp_uzytkownik_id_u where stp_stamot_stat_id=stp_status_id_s and DRS_SN_NUMBER is null and stp_stamot_user_id in (1,2,3)");
|
|
for($i=0; $i<count($lostAggArray); $i++)
|
|
{
|
|
if ($lostAggArray[$i]['stp_stamot_u']<200) $lostAggArray[$i]['stp_stamot_u']=500;
|
|
|
|
unset($engArray);
|
|
$engArray = sqlGetResAsArray("select * from seg_engines where ENG_NAME='".$lostAggArray[$i]['stp_stamot_typ_m']."' and ENG_VOLTAGE='".$lostAggArray[$i]['stp_stamot_u']."'");
|
|
|
|
if ($engArray[0]['ENG_ID']>0)
|
|
{
|
|
unset($dep);
|
|
if ($lostAggArray[$i]['stp_stamot_user_id']==1) $dep = 'P/Bełchatów';
|
|
elseif ($lostAggArray[$i]['stp_stamot_user_id']==2) $dep = 'Dębina';
|
|
elseif ($lostAggArray[$i]['stp_stamot_user_id']==3) $dep = 'P/Szczerców';
|
|
|
|
mysql_query("INSERT INTO seg_dev_resources SET DRS_DEV_ID='".$engArray[0]['ENG_ID']."',DRS_DEV_TYPE=11,DRS_SN_NUMBER='".$lostAggArray[$i]['stp_stamot_nr_m']."',DRS_STATUS_DIC_ID=7,DRS_RESOURCES_DIC_ID='".$lostAggArray[$i]['DEV_STATUS']."',DRS_DEPARTMENT='".$dep."',DRS_AUDIT_USR='manual',DRS_AUDIT_DATE=now()");
|
|
|
|
echo'Dodano: '.$engArray[0]['ENG_ID'].'<br/>';
|
|
}
|
|
}
|
|
?>
|
|
|
|
|
|
<?php
|
|
mysql_close($polacz);
|
|
|
|
?>
|
|
</body>
|
|
</html>
|