UWVA#35539: ins: kan gedane inspectie aanpassen. svn path=/Website/trunk/; revision=28990
536 lines
30 KiB
Plaintext
536 lines
30 KiB
Plaintext
<%@language="javascript"%>
|
|
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: ins_inspect_list.asp
|
|
Description: Toont alle inspecties van een object
|
|
Parameters: ins_key
|
|
Context: embedded in ins_deel frame
|
|
Noot: We tonen een outer join van inspecties: ook degene die nog nooit
|
|
zijn uitgevoerd worden getoond.
|
|
|
|
*/ %>
|
|
<!-- #include file="../Shared/common.inc" -->
|
|
<!-- #include file="../Shared/iface.inc" -->
|
|
<!-- #include file="../Shared/json2.js" -->
|
|
<!-- #include file="../Shared/resultset_table_v2.inc" -->
|
|
<!-- #include file="ins.inc" -->
|
|
<%
|
|
FCLTHeader.Requires({ js: ["jquery-ui.js"]});
|
|
|
|
var ins_key = getQParamInt("ins_key");
|
|
var outputmode = getQParamInt("outputmode", 0);
|
|
var showall = getQParamInt("showall", 0) == 1;
|
|
var print = (outputmode == 1 || outputmode == 5);
|
|
var excel = (outputmode == 2 || outputmode == 6);
|
|
|
|
// Vooralsnog gebruiken we de relatieve INSUSE als rechtenbeperking voor insepecties
|
|
// Merk op dat de scope nog wordt genegeerd.
|
|
var authparams = user.checkAutorisation("WEB_INSUSE");
|
|
|
|
%>
|
|
|
|
<html>
|
|
<head>
|
|
<% FCLTHeader.Generate({outputmode: outputmode}); %>
|
|
<script>
|
|
function insEditInsp(row)
|
|
{
|
|
$(row).addClass('dirty');
|
|
var insKeyString = row.getAttribute("ROWKEY");
|
|
var rowdata = eval("(" + row.getAttribute("ROWDATA") + ")");
|
|
if (rowdata)
|
|
{
|
|
srtcontrolekey = rowdata.insSrtControleKey;
|
|
// De deelsrtcontrole key hoeft niet meegegeven worden. Dat kan ins_edit_inspect zelf wel bepalen (laatste record).
|
|
var url = "appl/ins/ins_edit_inspect.asp?ins_keys=" + insKeyString + "&srtcont_keys=" + srtcontrolekey;
|
|
FcltMgr.openDetail(url, L("lcl_change"));
|
|
}
|
|
}
|
|
|
|
function insShow(row)
|
|
{
|
|
$(row).addClass('dirty');
|
|
var insKeyString = row.getAttribute("ROWKEY");
|
|
var rowdata = eval("(" + row.getAttribute("ROWDATA") + ")");
|
|
if (rowdata)
|
|
{
|
|
srtcontrolekey = rowdata.insSrtControleKey;
|
|
srtcontroletype = rowdata.insSrtControleType;
|
|
// Meegeven welke afgeronde inspectie getoond moet worden.
|
|
deellsrtcontkey = rowdata.insDeelSrtContrKey;
|
|
var url = "appl/ins/ins_edit_inspect.asp?ins_keys=" + insKeyString + "&srtcont_keys=" + srtcontrolekey + "&deelsrtcont_key=" + deellsrtcontkey;
|
|
var title = "";
|
|
switch (srtcontroletype)
|
|
{
|
|
case 1: title = L("lcl_ins_srtcontrole_insp"); break;
|
|
case 2: title = L("lcl_ins_srtcontrole_repl"); break;
|
|
case 3: title = L("lcl_ins_srtcontrole_cert"); break;
|
|
}
|
|
FcltMgr.openDetail(url, title + " " + deellsrtcontkey);
|
|
}
|
|
}
|
|
|
|
function insPlan(row)
|
|
{
|
|
$(row).addClass('dirty');
|
|
var insKeyString = row.getAttribute("ROWKEY");
|
|
var rowdata = eval("(" + row.getAttribute("ROWDATA") + ")");
|
|
if (rowdata)
|
|
{
|
|
srtcontrolekey = rowdata.insSrtControleKey;
|
|
var url = "appl/ins/ins_edit_inspect.asp?plan=1&ins_keys=" + insKeyString + "&srtcont_keys=" + srtcontrolekey;
|
|
FcltMgr.openDetail(url, L("lcl_ins_schedule"));
|
|
}
|
|
}
|
|
|
|
function insStart(row)
|
|
{
|
|
if (confirm(L("lcl_ins_starting")))
|
|
{
|
|
var insKeyString = row.getAttribute("ROWKEY");
|
|
var rowdata = eval("(" + row.getAttribute("ROWDATA") + ")");
|
|
if (rowdata)
|
|
{
|
|
srtcontrolekey = rowdata.insSrtControleKey;
|
|
|
|
var data = { ins_keys: insKeyString,
|
|
srtcont_key_arr: srtcontrolekey
|
|
};
|
|
|
|
protectRequest.dataToken(data);
|
|
$.post( "ins_inspect_start.asp"
|
|
, data
|
|
, FcltCallbackRefresh
|
|
, "json"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
function insClose(row)
|
|
{
|
|
$(row).addClass('dirty');
|
|
var insKeyString = row.getAttribute("ROWKEY");
|
|
var rowdata = eval("(" + row.getAttribute("ROWDATA") + ")");
|
|
if (rowdata)
|
|
{
|
|
srtcontrolekey = rowdata.insSrtControleKey;
|
|
var url = "appl/ins/ins_edit_inspect.asp?close=1&ins_keys=" + insKeyString + "&srtcont_keys=" + srtcontrolekey;
|
|
FcltMgr.openDetail(url, L("lcl_ins_close"));
|
|
}
|
|
}
|
|
|
|
function insFinish(row)
|
|
{
|
|
if (confirm(L("lcl_ins_finishing")))
|
|
{
|
|
var insKeyString = row.getAttribute("ROWKEY");
|
|
var rowdata = eval("(" + row.getAttribute("ROWDATA") + ")");
|
|
if (rowdata)
|
|
{
|
|
deellsrtcontkey = rowdata.insDeelSrtContrKey;
|
|
|
|
var data = { ins_keys: insKeyString,
|
|
dlsrtcont_key_arr: deellsrtcontkey
|
|
};
|
|
|
|
protectRequest.dataToken(data);
|
|
$.post( "ins_inspect_finish.asp"
|
|
, data
|
|
, FcltCallbackRefresh
|
|
, "json"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</head>
|
|
|
|
<body id="listbody">
|
|
<%
|
|
// Twee queries achter elkaar.
|
|
// Eerst de inspecties die gaan komen.
|
|
// Dan de inspecties die gedaan zijn.
|
|
|
|
// Als de controlesoort niet meer geldig is dan kunnen er geen inspecties meer komen.
|
|
// Een object kan meerdere controlesoorten hebben. Alleen die controlesoorten laten zien die nog geldig zijn.
|
|
var lastinspect = "(SELECT GREATEST(COALESCE (idsc.ins_deelsrtcontrole_plandatum"
|
|
+ " , CASE di.ins_srtcontrole_mode"
|
|
+ " WHEN 0"
|
|
+ " THEN idsc.ins_deelsrtcontrole_datum_org" // Moment modus. Uitgaan van eigenlijke/orginele inspectiedatum.
|
|
+ " ELSE idsc.ins_deelsrtcontrole_datum" // Interval modus. Uitgaan van werkelijke inspectiedatum.
|
|
+ " END)"
|
|
+ " , CASE di.ins_srtcontrole_mode"
|
|
+ " WHEN 0"
|
|
+ " THEN idsc.ins_deelsrtcontrole_datum_org" // Moment modus. Uitgaan van eigenlijke/orginele inspectiedatum.
|
|
+ " ELSE idsc.ins_deelsrtcontrole_datum" // Interval modus. Uitgaan van werkelijke inspectiedatum.
|
|
+ " END) ins_deelsrtcontrole_datum"
|
|
+ " FROM ins_deelsrtcontrole idsc"
|
|
+ " WHERE idsc.ins_srtcontrole_key = di.ins_srtcontrole_key"
|
|
+ " AND idsc.ins_deelsrtcontrole_status IN (5, 6)"
|
|
+ " AND idsc.ins_deel_key = di.ins_deel_key"
|
|
+ " AND idsc.ins_deelsrtcontrole_key = (SELECT MAX(idsc2.ins_deelsrtcontrole_key)"
|
|
+ " FROM ins_deelsrtcontrole idsc2"
|
|
+ " WHERE idsc2.ins_deel_key = di.ins_deel_key"
|
|
+ " AND idsc2.ins_srtcontrole_key = di.ins_srtcontrole_key))";
|
|
|
|
var sql = "SELECT *"
|
|
+ " FROM (WITH defined_inspect AS (SELECT id.ins_srtdeel_key srtdeel_key"
|
|
+ " , isc.ins_srtcontrole_key"
|
|
+ " , isc.ins_srtcontrole_omschrijving"
|
|
+ " , isc.ins_srtcontrole_mode"
|
|
+ " , isc.ins_srtcontrole_eenheid"
|
|
+ " , isc.ins_srtcontrole_periode"
|
|
+ " , isc.ins_srtcontrole_bits"
|
|
+ " , isc.ins_srtcontrole_kosten"
|
|
+ " , isc.ins_srtcontrole_eind"
|
|
+ " , isc.ins_srtcontrole_groep"
|
|
+ " , isc.ins_srtcontrole_opmerking"
|
|
+ " , id.ins_deel_key"
|
|
+ " , id.ins_deel_aanmaak"
|
|
+ " , id.ins_deel_aantal"
|
|
+ " , isc.ins_srtcontrole_type"
|
|
+ " FROM ins_deel id"
|
|
+ " , ins_srtdeel s"
|
|
+ " , ins_srtcontrole isc"
|
|
+ " WHERE s.ins_srtdeel_key = id.ins_srtdeel_key"
|
|
+ " AND (isc.ins_srtcontrole_niveau = 'S'"
|
|
+ " AND isc.ins_srtinstallatie_key = id.ins_srtdeel_key"
|
|
+ " OR isc.ins_srtcontrole_niveau = 'G'"
|
|
+ " AND isc.ins_srtinstallatie_key = s.ins_srtgroep_key"
|
|
+ " OR isc.ins_srtcontrole_niveau = 'D'"
|
|
+ " AND isc.ins_srtinstallatie_key = id.ins_discipline_key)"
|
|
+ " AND id.ins_deel_key = " + ins_key + ")"
|
|
// mogelijke inspecties op dit object die nog gaan komen.
|
|
// Als er een voorlopige inspectie is aangemaakt maar nog niet is afgemeld of afgerond, dan hoeft er geen nieuwe inspectie te worden getoond.
|
|
// Dus met de respijt heb je in dit eerste deel van de query niet meer te maken.
|
|
+ " SELECT 1 seq"
|
|
+ " , di.ins_deel_key"
|
|
+ " , di.ins_deel_aanmaak"
|
|
+ " , di.ins_deel_aantal"
|
|
+ " , TO_DATE (NULL) ins_deelsrtcontrole_datum"
|
|
+ " , NULL inspectie_org"
|
|
+ " , NULL isrespijt"
|
|
+ " , CASE WHEN " + lastinspect + " IS NULL THEN 1 ELSE 0 END nonext"
|
|
// Als respijtdatum vandaag of dit uur is dan is de respijtdatum de eerstvolgende inspectie en dus maar 1 step.
|
|
// Als er vandaag al geinspecteerd is dan de volgende inspectiedatum in de toekomst (functie nextcyclusdatesteps())
|
|
+ " , fac.nextcyclusdatesteps (COALESCE(" + lastinspect + ", SYSDATE)"
|
|
+ " , di.ins_srtcontrole_mode"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_eenheid , di.ins_srtcontrole_eenheid)"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_periode , di.ins_srtcontrole_periode)"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_bits, di.ins_srtcontrole_bits))"
|
|
+ " inspectie_steps"
|
|
// Als respijtdatum vandaag of dit uur is dan is de respijtdatum de eerstvolgende inspectie en dan dus de respijtdatum opleveren.
|
|
// Als er vandaag of dit uur niet geinspecteerd is dan de eerstvolgende inspectiedatum vandaag of in de toekomst (steps = 0: functie nextcyclusdate(..., 0))
|
|
// Als er vandaag of dit uur al geinspecteerd is dan de eerstvolgende inspectiedatum in de toekomst (steps = 1: functie nextcyclusdate(..., 1))
|
|
+ " , fac.nextcyclusdate (COALESCE(" + lastinspect + ", di.ins_deel_aanmaak)"
|
|
+ " , di.ins_srtcontrole_mode"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_eenheid , di.ins_srtcontrole_eenheid)"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_periode , di.ins_srtcontrole_periode)"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_bits, di.ins_srtcontrole_bits)"
|
|
+ " , CASE"
|
|
+ " WHEN di.ins_srtcontrole_mode = 1" // Interval modus
|
|
+ " THEN 1"
|
|
+ " WHEN COALESCE (xcp.ins_srtcontroledl_xcp_eenheid, di.ins_srtcontrole_eenheid) = 0 AND"
|
|
+ " TRUNC (COALESCE (" + lastinspect + ", di.ins_deel_aanmaak), 'HH24' ) >= TRUNC (SYSDATE, 'HH24')"
|
|
+ " THEN 1" // Uurlijks: Als de datum in de toekomst ligt, bepaal dan de volgende datum (1 step verder).
|
|
+ " WHEN COALESCE (xcp.ins_srtcontroledl_xcp_eenheid, di.ins_srtcontrole_eenheid) > 0 AND"
|
|
+ " TRUNC (COALESCE (" + lastinspect + ", di.ins_deel_aanmaak),'DDD') >= TRUNC (SYSDATE, 'DDD')"
|
|
+ " THEN 1" // Dagelijks t/m jaarlijks: Als de datum in de toekomst ligt, bepaal dan de volgende datum (1 step verder).
|
|
+ " WHEN " + lastinspect + " IS NULL"
|
|
+ " THEN 1" // Als Eerste inspectie, bepaal dan ook de volgende (1 step) datum.
|
|
+ " ELSE 0" // Vindt de eerste datum vandaag of in de toekomst
|
|
+ " END)"
|
|
+ " inspectie_next"
|
|
+ " , di.ins_srtcontrole_key"
|
|
+ " , " + lcl.xsqla('di.ins_srtcontrole_omschrijving', 'di.ins_srtcontrole_key')
|
|
+ " , di.ins_srtcontrole_groep"
|
|
+ " , di.ins_srtcontrole_opmerking"
|
|
+ " , NULL ins_deelsrtcontrole_key"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode) periode"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_eenheid, di.ins_srtcontrole_eenheid) eenheid"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_kosten, di.ins_srtcontrole_kosten) kosten"
|
|
+ " , di.ins_srtcontrole_mode isc_mode"
|
|
+ " , NULL plandatum"
|
|
+ " , '' ins_deelsrtcontrole_opmerking"
|
|
+ " , NULL inspecteur"
|
|
+ " , di.ins_srtcontrole_type"
|
|
+ " , -1 ins_deelsrtcontrole_status"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_eind, di.ins_srtcontrole_eind) inspectie_eind"
|
|
+ " FROM defined_inspect di"
|
|
+ " , ins_srtcontroledl_xcp xcp"
|
|
+ " WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)"
|
|
+ " AND di.ins_deel_key = xcp.ins_deel_key(+)"
|
|
+ " AND (COALESCE (xcp.ins_srtcontroledl_xcp_eind, di.ins_srtcontrole_eind) >= TRUNC(SYSDATE, 'DD')"
|
|
+ " OR COALESCE (xcp.ins_srtcontroledl_xcp_eind, di.ins_srtcontrole_eind) IS NULL)"
|
|
+ " AND di.ins_deel_key = " + ins_key
|
|
// Als er een voorlopige inspectie is aangemaakt maar nog niet is afgemeld of afgerond, dan hoeft er geen nieuwe inspectie te worden getoond.
|
|
+ " AND NOT EXISTS (SELECT idsc.ins_deelsrtcontrole_key"
|
|
+ " FROM ins_deelsrtcontrole idsc"
|
|
+ " WHERE idsc.ins_srtcontrole_key = di.ins_srtcontrole_key"
|
|
+ " AND idsc.ins_deelsrtcontrole_status NOT IN (6)"
|
|
+ " AND idsc.ins_deel_key = di.ins_deel_key)"
|
|
+ " UNION ALL"
|
|
// Combineren met uitgevoerde inspecties op dit object
|
|
+ " SELECT 2 seq"
|
|
+ " , di.ins_deel_key"
|
|
+ " , di.ins_deel_aanmaak"
|
|
+ " , di.ins_deel_aantal"
|
|
+ " , idsc.ins_deelsrtcontrole_datum"
|
|
+ " , COALESCE(idsc.ins_deelsrtcontrole_plandatum, ins_deelsrtcontrole_datum_org) inspectie_org"
|
|
+ " , CASE WHEN idsc.ins_deelsrtcontrole_plandatum > idsc.ins_deelsrtcontrole_datum_org THEN 1 ELSE 0 END isrespijt"
|
|
+ " , NULL nonext"
|
|
+ " , CASE"
|
|
+ " WHEN COALESCE (xcp.ins_srtcontroledl_xcp_eenheid, di.ins_srtcontrole_eenheid) = 0 AND"
|
|
+ " idsc.ins_deelsrtcontrole_plandatum IS NOT NULL AND"
|
|
+ " TRUNC (idsc.ins_deelsrtcontrole_plandatum, 'HH24') >= TRUNC (SYSDATE, 'HH24')"
|
|
+ " THEN 1"
|
|
+ " WHEN COALESCE (xcp.ins_srtcontroledl_xcp_eenheid, di.ins_srtcontrole_eenheid) > 0 AND"
|
|
+ " idsc.ins_deelsrtcontrole_plandatum IS NOT NULL AND"
|
|
+ " TRUNC (idsc.ins_deelsrtcontrole_plandatum, 'DDD') >= TRUNC (SYSDATE, 'DDD')"
|
|
+ " THEN 1"
|
|
+ " ELSE NULL"
|
|
+ " END inspectie_steps"
|
|
+ " , CASE"
|
|
+ " WHEN idsc.ins_deelsrtcontrole_status < 5"
|
|
+ " THEN idsc.ins_deelsrtcontrole_datum_org"
|
|
+ " ELSE TO_DATE (NULL)"
|
|
+ " END inspectie_next"
|
|
+ " , idsc.ins_srtcontrole_key"
|
|
+ " , " + lcl.xsqla('di.ins_srtcontrole_omschrijving', 'di.ins_srtcontrole_key')
|
|
+ " , di.ins_srtcontrole_groep"
|
|
+ " , di.ins_srtcontrole_opmerking"
|
|
+ " , idsc.ins_deelsrtcontrole_key"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode) periode"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_eenheid, di.ins_srtcontrole_eenheid) eenheid"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_kosten, di.ins_srtcontrole_kosten) kosten"
|
|
+ " , di.ins_srtcontrole_mode isc_mode"
|
|
+ " , idsc.ins_deelsrtcontrole_plandatum plandatum"
|
|
+ " , idsc.ins_deelsrtcontrole_opmerking"
|
|
+ " , " + S("prs_pers_string") + " inspecteur"
|
|
+ " , di.ins_srtcontrole_type"
|
|
+ " , idsc.ins_deelsrtcontrole_status"
|
|
+ " , COALESCE(xcp.ins_srtcontroledl_xcp_eind, di.ins_srtcontrole_eind) inspectie_eind"
|
|
+ " FROM defined_inspect di"
|
|
+ " , ins_srtcontroledl_xcp xcp"
|
|
+ " , ins_deelsrtcontrole idsc"
|
|
+ " , prs_perslid p"
|
|
+ " WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)"
|
|
+ " AND di.ins_deel_key = xcp.ins_deel_key(+)"
|
|
+ " AND idsc.ins_srtcontrole_key = di.ins_srtcontrole_key"
|
|
+ " AND idsc.ins_deel_key = di.ins_deel_key"
|
|
+ " AND idsc.prs_perslid_key = p.prs_perslid_key(+)"
|
|
+ " AND di.ins_deel_key = " + ins_key
|
|
// Gedaande inspectie altijd tonen.
|
|
+ " )"
|
|
+ " ORDER BY seq, ins_deelsrtcontrole_datum DESC, inspectie_org DESC, inspectie_next, ins_srtcontrole_omschrijving";
|
|
|
|
function fnrowData(oRs)
|
|
{
|
|
var insKey = ins_key;
|
|
var insSrtControleKey = oRs("ins_srtcontrole_key").Value;
|
|
var insSrtControleType = oRs("ins_srtcontrole_type").Value;
|
|
|
|
// Als de status Verwerkt(6) is dan kan/moet er weer een nieuw inspectie gestart worden. Dan geen ins_deelsrtcontrole_key meegegeven (-2).
|
|
var istatus = oRs("ins_deelsrtcontrole_status").Value;
|
|
var insDeelSrtContrKey = oRs("ins_deelsrtcontrole_key").Value != null? oRs("ins_deelsrtcontrole_key").Value : -2;
|
|
|
|
var data = { insKey: ins_key, insSrtControleKey: insSrtControleKey, insSrtControleType: insSrtControleType, insDeelSrtContrKey: insDeelSrtContrKey, ins_status: istatus};
|
|
return JSON.stringify(data);
|
|
}
|
|
|
|
function fnrowActionEnabler(oRs)
|
|
{
|
|
// Als object is vervallen dan kun je niet meer inspecteren en uitstellen.
|
|
var vervallen = (oRs("inspectie_eind").Value != null && new Date(oRs("inspectie_eind").Value).getTime() < new Date().midnight());
|
|
var this_ins = ins.func_enabled_deel(oRs("ins_deel_key").Value);
|
|
var istatus = oRs("ins_deelsrtcontrole_status").Value != null? oRs("ins_deelsrtcontrole_status").Value : -1;
|
|
|
|
// Gedaande inspecties kunnen alleen geedit worden.
|
|
// Ik zie alleen objecten waar ik read rechten (3d) op heb. Dan mag ik ze ook verder inzien.
|
|
var eEdit = !vervallen && istatus >= 0 && istatus < 6 && this_ins.canChange;
|
|
var eShow = istatus >= 0 && this_ins.canRead && !eEdit;
|
|
var ePlan = !vervallen && this_ins.canInspect && (istatus < 0);
|
|
var eStart = !vervallen && this_ins.canInspect && (istatus <= 0);
|
|
// Als de inspectie vervallen is moet je alleen nog de lopende inspecties kunnen gereed melden en afronden.
|
|
var eClose = (!vervallen || (vervallen && (istatus == 0 || istatus == 2))) && this_ins.canInspect && (istatus < 5);
|
|
var eFinish = this_ins.canInspect && istatus == 5;
|
|
|
|
var data = {eEdit: eEdit, eShow: eShow, ePlan: ePlan, eStart: eStart, eClose: eClose, eFinish: eFinish};
|
|
return data;
|
|
}
|
|
|
|
function fnrowClass(oRs)
|
|
{
|
|
var lclass = "";
|
|
var istatus = oRs("ins_deelsrtcontrole_status").Value != null? oRs("ins_deelsrtcontrole_status").Value : -1;
|
|
|
|
if (istatus == 2)
|
|
lclass = "pending";
|
|
if (istatus == 5)
|
|
lclass = "unsolved";
|
|
|
|
if (oRs("seq").Value == 2) // klaar
|
|
return lclass;
|
|
|
|
var dt = new Date(oRs("inspectie_next").Value);
|
|
dt.setHours(0,0,0,0); // trunc datum
|
|
var dtsoon = new Date();
|
|
dtsoon.setDate(dtsoon.getDate() + S("ins_inspect_soon_days"));
|
|
dtsoon.setHours(0,0,0,0); // trunc datum
|
|
var dtlate = new Date().setHours(0,0,0,0);
|
|
|
|
if (dt >= dtsoon)
|
|
return lclass; // meer dan 30 dagen in de toekomst
|
|
|
|
if (dt >= dtlate)
|
|
return lclass + " expired1"; // Binnenkort
|
|
|
|
return lclass + " expired2"; // Te laat
|
|
}
|
|
|
|
function fnControleDatum(oRs)
|
|
{
|
|
var controledatum = oRs("ins_deelsrtcontrole_datum").value;
|
|
if (oRs("eenheid").Value == 0)
|
|
return toDateTimeString(controledatum); // Datum + tijd tonen.
|
|
else
|
|
return toDateString(controledatum); // Alleen datum tonen.
|
|
}
|
|
|
|
function fnVolgende(oRs)
|
|
{
|
|
if (oRs("seq").Value == 2)
|
|
{
|
|
var dt = typeof oRs("inspectie_org").Value == "date"? new Date(oRs("inspectie_org").Value) : null;
|
|
var dtsting = (typeof dt == "date" && oRs("eenheid").value == 0? toDateTimeString(dt) : toDateString(dt)) + (oRs("isrespijt").Value == 1? " " + L("lcl_ins_respijt") : "");
|
|
return dtsting;
|
|
}
|
|
|
|
var nonext = oRs("nonext").Value == 1;
|
|
if (nonext)
|
|
{
|
|
switch (oRs("ins_srtcontrole_type").Value)
|
|
{ // 1: Controle, 2: Vervanging, 3: Certificering.
|
|
case 1: { var txt = L("lcl_ins_controle_first"); break; }; // Eerste controle.
|
|
case 2:
|
|
case 3: { var dt = new Date(oRs("inspectie_next").Value); // Registratiedatum.
|
|
var txt = (oRs("eenheid").value == 0? toDateTimeString(dt) : toDateString(dt));
|
|
break;
|
|
} // Eerste certificering.
|
|
}
|
|
return txt;
|
|
}
|
|
|
|
var dt = new Date(oRs("inspectie_next").Value);
|
|
var plandatum = oRs("plandatum").Value != null? " " + L("lcl_ins_respijt") : "";
|
|
dt = (oRs("eenheid").value == 0? toDateTimeString(dt) : toDateString(dt)); // Nog even afstemmen: altijd doen of alleen voor korte periode?
|
|
if (oRs("isc_mode").Value == 0 && oRs("inspectie_steps").Value && oRs("inspectie_steps").Value > 1)
|
|
dt += " (" + (parseInt(oRs("inspectie_steps").Value) - 1) + ")";
|
|
return dt + plandatum;
|
|
}
|
|
|
|
function fnSrtControleType(oRs)
|
|
{
|
|
var txt = "";
|
|
switch (oRs("ins_srtcontrole_type").Value)
|
|
{
|
|
case 1: { txt = L("lcl_ins_srtcontrole_insp"); break; } // Controle.
|
|
case 2: { txt = L("lcl_ins_srtcontrole_repl"); break; } // Vervanging.
|
|
case 3: { txt = L("lcl_ins_srtcontrole_cert"); break; } // Certificering.
|
|
}
|
|
|
|
return txt;
|
|
}
|
|
|
|
function fnKosten(oRs)
|
|
{
|
|
var kosten = oRs("kosten").Value || 0;
|
|
var aantal = oRs("ins_deel_aantal").Value || 0;
|
|
var totaal = aantal * kosten;
|
|
|
|
return totaal > 0? totaal : null;
|
|
}
|
|
|
|
// Mag ik het object aanpassen?
|
|
var this_ins = ins.func_enabled_deel(ins_key);
|
|
|
|
var buttons = [];
|
|
if (this_ins.canChange)
|
|
{
|
|
var addurl_add = "../ins/ins_xcp.asp?ins_key=" + ins_key + "&urole=bo&add=1";
|
|
var addurl_editxcp = "../ins/ins_xcp.asp?ins_key=" + ins_key + "&urole=bo";
|
|
// Zijn er inactieve soort controles (periode = 0) die ook gelden voor het object. Dan de "Toevoegen" knop tonen.
|
|
var bsql = "SELECT COUNT(*) aantal"
|
|
+ " FROM (WITH defined_inspect AS (SELECT isc.ins_srtcontrole_key"
|
|
+ " , isc.ins_srtcontrole_periode"
|
|
+ " , id.ins_deel_key"
|
|
+ " FROM ins_deel id"
|
|
+ " , ins_srtdeel s"
|
|
+ " , ins_srtcontrole isc"
|
|
+ " WHERE s.ins_srtdeel_key = id.ins_srtdeel_key"
|
|
+ " AND (isc.ins_srtcontrole_niveau = 'S'"
|
|
+ " AND isc.ins_srtinstallatie_key = id.ins_srtdeel_key"
|
|
+ " OR isc.ins_srtcontrole_niveau = 'G'"
|
|
+ " AND isc.ins_srtinstallatie_key = s.ins_srtgroep_key"
|
|
+ " OR isc.ins_srtcontrole_niveau = 'D'"
|
|
+ " AND isc.ins_srtinstallatie_key = id.ins_discipline_key)"
|
|
+ " AND id.ins_deel_key = " + ins_key + ")"
|
|
+ " SELECT di.ins_srtcontrole_key"
|
|
+ " FROM defined_inspect di"
|
|
+ " , ins_srtcontroledl_xcp xcp"
|
|
+ " WHERE di.ins_srtcontrole_key = xcp.ins_srtcontrole_key(+)"
|
|
+ " AND di.ins_deel_key = xcp.ins_deel_key(+)"
|
|
+ " AND di.ins_deel_key = " + ins_key
|
|
+ " AND COALESCE (xcp.ins_srtcontroledl_xcp_periode, di.ins_srtcontrole_periode) <= 0" // Inactieve soort controles tonen.
|
|
+ " AND xcp.ins_srtcontroledl_xcp_periode IS NULL" // Soort controles die niet overruled zijn tonen.
|
|
+ " GROUP BY di.ins_srtcontrole_key"
|
|
+ " , di.ins_deel_key)";
|
|
var boRs = Oracle.Execute(bsql);
|
|
var add = boRs("aantal").Value > 0;
|
|
boRs.close();
|
|
|
|
var buttons = [{ icon: "page_refresh.png", title: L("lcl_refresh"), action: "FcltMgr.reload()" }]
|
|
if (add)
|
|
buttons.push({ icon: "plus.png", title: L("lcl_add"), action: "FcltMgr.openModalDetail('" + addurl_add + "', '" + L("lcl_add") + "', {callback: FcltMgr.reload })" })
|
|
buttons.push({ icon: "wijzigen.png", title: L("lcl_ins_change_xcp"), action: "FcltMgr.openModalDetail('" + addurl_editxcp + "', '" + L("lcl_ins_change_xcp") + "', {callback: FcltMgr.reload })" })
|
|
}
|
|
|
|
var rst = new ResultsetTable({ keyColumn: "ins_deel_key", //dummy
|
|
sql: sql,
|
|
ID: "inspecttable",
|
|
rowData: fnrowData,
|
|
rowActionEnabler: fnrowActionEnabler,
|
|
rowClass: fnrowClass,
|
|
showAll: showall,
|
|
outputmode: outputmode,
|
|
title: L("lcl_ins_planned_activities"),
|
|
buttons: buttons
|
|
});
|
|
|
|
rst.addColumn(new Column({caption: L("lcl_ins_srtcontrole_type"), content: fnSrtControleType}));
|
|
rst.addColumn(new Column({caption: L("lcl_ins_controle_plandate"), content: fnVolgende}));
|
|
rst.addColumn(new Column({caption: L("lcl_ins_controle_datum"), content: fnControleDatum}));
|
|
rst.addColumn(new Column({caption: L("lcl_ins_controle_srt"), content: "ins_srtcontrole_omschrijving"}));
|
|
rst.addColumn(new Column({caption: L("lcl_ins_kosten") + " (" + L("lcl_valutasign") + ")", content: fnKosten, datatype: "currency"}));
|
|
rst.addColumn(new Column({caption: L("lcl_ins_controle_opm"), content: "ins_deelsrtcontrole_opmerking"}));
|
|
rst.addColumn(new Column({caption: L("lcl_ins_inspecteur"), content: "inspecteur"}));
|
|
if (print || excel)
|
|
{
|
|
rst.addColumn(new Column({caption: L("lcl_ins_controle_cat"), content: "ins_srtcontrole_groep"}));
|
|
rst.addColumn(new Column({caption: L("lcl_ins_controle_opm"), content: "ins_srtcontrole_opmerking"}));
|
|
}
|
|
rst.addAction({ action: "insShow", caption: L("lcl_edit"), enabler: "eShow", isDefault: true });
|
|
rst.addAction({ action: "insEditInsp", caption: L("lcl_edit"), enabler: "eEdit", isDefault: true });
|
|
rst.addAction({ action: "insPlan", caption: L("lcl_ins_schedule"), enabler: "ePlan" });
|
|
rst.addAction({ action: "insStart", caption: L("lcl_ins_start"), enabler: "eStart" });
|
|
rst.addAction({ action: "insClose", caption: L("lcl_ins_close") + "/" + L("lcl_ins_finish"), enabler: "eClose" });
|
|
rst.addAction({ action: "insFinish", caption: L("lcl_ins_finish"), enabler: "eFinish" });
|
|
|
|
var cnt = rst.processResultset();
|
|
%>
|
|
</body>
|
|
</html>
|