387 lines
18 KiB
Plaintext
387 lines
18 KiB
Plaintext
<%@language = "javascript" %>
|
|
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: contract.asp
|
|
Description: Bekijk/wijzig contract (Mobile version)
|
|
Parameters: cnt_key voor bestaand contract
|
|
|
|
Nog niet helemaal uitgekristalliseerd hoe de stdm geselecteerd en gefilterd kan worden, handigst
|
|
Note:
|
|
|
|
*/ %>
|
|
|
|
<!-- #include file="../Shared/common.inc" -->
|
|
<!-- #include file="../Shared/selector.inc" -->
|
|
<!-- #include file="../Shared/get_objecten_sql.inc" -->
|
|
<!-- #include file="./resultset_table.inc" -->
|
|
<!-- #include file="../cnt/cnt.inc" -->
|
|
<!-- #include file="../cnt/cnt_flexkenmerk.inc" -->
|
|
<!-- #include file="./mobile.inc" -->
|
|
<!-- #include file="./iface.inc" -->
|
|
|
|
|
|
<%
|
|
FCLTHeader.Requires({plugins: ["suggest"]});
|
|
|
|
var cnt_key = getQParamInt("cnt_key", -1);
|
|
var qrc = getQParamInt("qrc", 0) != 0;
|
|
|
|
|
|
if (cnt_key > -1)
|
|
{ // BESTAAND CONTRACT
|
|
var this_cnt = cnt.func_enabled_contract(cnt_key, cnt_info); // Wat heb ik zoal aan rechten op dit contract?
|
|
user.auth_required_or_abort(this_cnt.canReadAny);
|
|
|
|
var cnt_info = cnt.cnt_contract_info(cnt_key); // nog heel beperkt
|
|
}
|
|
|
|
var subject = L("lcl_cnt_contract") + " " + cnt_info.nummer_intern+ (cnt_info.versie == null || cnt_info.versie == ""? "" : "." + cnt_info.versie);
|
|
|
|
%>
|
|
<html>
|
|
<head>
|
|
<% FCLTMHeader.Generate({title: subject }); %>
|
|
|
|
<script>
|
|
<% if (getQParamInt("notitie", 0) == 1) { %>
|
|
$(function() {
|
|
jqToast(L("lcl_mobile_data_saved"));
|
|
});
|
|
<% } %>
|
|
function cnt_goedkeur()
|
|
{
|
|
if (confirm(L("lcl_cnt_approve").format("<%=safe.jsstring(cnt_info.nummer_intern)%>")))
|
|
{
|
|
var data = {cnt_key: <%=cnt_key%>};
|
|
<% protectRequest.dataToken("data"); %>
|
|
$.post("<%=rooturl%>/appl/cnt/cnt_approve.asp",
|
|
data,
|
|
McltCallbackAndThenAlways(cnt_action_callback),
|
|
"json");
|
|
}
|
|
}
|
|
|
|
function cnt_reject()
|
|
{
|
|
var opmerk = prompt(L("lcl_cnt_inf_opmerking_fiat"), "");
|
|
if (!opmerk)
|
|
return;
|
|
if (confirm(L("lcl_mld_opdr_reject").format("<%=cnt_key%>")))
|
|
{
|
|
var data = {cnt_key: <%=cnt_key%>,
|
|
opmerk: opmerk };
|
|
<% protectRequest.dataToken("data"); %>
|
|
$.post("<%=rooturl%>/appl/cnt/cnt_reject_save.asp",
|
|
data,
|
|
McltCallbackAndThenAlways(cnt_action_callback),
|
|
"json");
|
|
}
|
|
}
|
|
|
|
function cnt_print()
|
|
{
|
|
FcltMgr.openDetail("/appl/cnt/cnt_xml.asp?cnt_key=<%=cnt_key%>");
|
|
return false;
|
|
};
|
|
|
|
function cnt_action_callback()
|
|
{
|
|
//window.location.href = "fiat_list.asp"; // Als je terug bent in fiat_list en doet dan "terug" kom je in de zojuist gefiatteerde opdracht.
|
|
// Het fiatteren van een contract is aangeroepen vanuit fiat_list.
|
|
// Dus 1 stap terug in history om daar weer te komen.
|
|
window.history.go(-1);
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<%
|
|
PAGE_START({id: "page-1-" + cnt_key});
|
|
HEADER({title: (cnt_key > -1 ? subject : "") , back: !qrc, home: !qrc});
|
|
CONTENT_START();
|
|
|
|
ROFIELD ("fldoms", L("lcl_cnt_descr"), cnt_info.discipline_omschrijving +"/"+ cnt_info.omschrijving);
|
|
ROFIELD ("fldpers", L("lcl_cnt_contact_eig"), cnt_info.perslid_naam_eig, {suppressEmpty: true});
|
|
ROFIELD ("fldpers", L("lcl_cnt_manager"), cnt_info.perslid_naam_beh);
|
|
ROFIELD ("fldcntnr", L("lcl_cnt_contractnr"), cnt_info.nummer, {suppressEmpty: true});
|
|
if (cnt_info.mantel_key != null)
|
|
{
|
|
ROFIELD ("fldcontract", L("lcl_cnt_mantel"), cnt_info.mantelcontractnummer + " - " + cnt_info.mantelomschrijving, { moreinfo: "./contract.asp?cnt_key="+cnt_info.mantel_key });
|
|
}
|
|
ROFIELD ("fldtxt", L("lcl_cnt_document"), cnt_info.document, {suppressEmpty: true, multi: true});
|
|
ROFIELD("fldtxt", L("lcl_remark"), cnt_info.opmerking, {suppressEmpty: true, multi: true});
|
|
|
|
|
|
if (cnt_info.srtcontract_type == S("cnt_srttype_rental"))
|
|
{
|
|
ROFIELD ("fld", L("lcl_cnt_mutatie_huurder"), cnt_info.bedrijf_naam, {moreinfo: "./bedrijf.asp?bedrijf_key=" + cnt_info.bedrijf_key, suppressEmpty: true});
|
|
ROFIELD ("flddep", L("lcl_cnt_afdeling"), cnt_info.afdeling_naam, {suppressEmpty: true});
|
|
}
|
|
else
|
|
{
|
|
ROFIELD ("fld", L("lcl_cnt_company"), cnt_info.bedrijf_naam, {moreinfo: "./bedrijf.asp?bedrijf_key=" + cnt_info.bedrijf_key, suppressEmpty: true});
|
|
ROFIELD ("fld", L("lcl_person"), cnt_info.perslid_naam, {suppressEmpty: true});
|
|
}
|
|
|
|
ROFIELD ("flddate", L("lcl_cnt_looptijd"), toDateString(cnt_info.looptijd_van)+ " " +L("lcl_tot")+" "+ toDateString(cnt_info.looptijd_tot));
|
|
|
|
|
|
var fin_collapse = !this_cnt.canGoedkeur1 && !this_cnt.canGoedkeur2 && !this_cnt.canGoedkeur3 && !this_cnt.canGoedkeur4 && !this_cnt.canGoedkeur5 && !this_cnt.canReject;
|
|
BLOCK_START({collapsed: fin_collapse, title: L("lcl_cnt_fin_data")});
|
|
ROFIELD ("fld", L("lcl_cnt_kostenplaats"), cnt_info.kostenplaats_naam);
|
|
ROFIELD ("fld", L("lcl_cnt_contract_sum")+ " " + S("currency_pref"), safe.curr(cnt_info.kosten), {suppressEmpty: true});
|
|
ROFIELD ("fld", L("lcl_cnt_period_sum")+ " " + S("currency_pref"), safe.curr(cnt_info.termijnkosten), {suppressEmpty: true});
|
|
ROFIELD ("fldshort", L("lcl_hour_rate")+ " " + S("currency_pref"), safe.curr(cnt_info.uurloon), {suppressEmpty: true});
|
|
ROFIELD ("fldshort", L("lcl_cnt_discount"), cnt_info.korting, {suppressEmpty: true, datatype:"float"});
|
|
BLOCK_END();
|
|
|
|
generateFlexKenmerkCode ({cnt_key: cnt_key,
|
|
prs_key: user_key,
|
|
mobile: true,
|
|
reado: true
|
|
});
|
|
|
|
// De eventuelse scope
|
|
// Contractscope
|
|
// Deze alleen als er mogelijke scope is: type niet 4 (generiek) of 6 (mantel)
|
|
var cnt_typecontract = -1;
|
|
var sql = "SELECT dp.cnt_srtcontract_type "
|
|
+ " FROM cnt_contract c, cnt_disc_params dp "
|
|
+ " WHERE c.ins_discipline_key = dp.cnt_ins_discipline_key "
|
|
+ " AND cnt_contract_key =" + cnt_key ;
|
|
var oRs = Oracle.Execute( sql );
|
|
if(!oRs.eof){
|
|
cnt_typecontract = oRs("cnt_srtcontract_type").Value;
|
|
}
|
|
oRs.close();
|
|
if (cnt_typecontract != 4 && cnt_typecontract != 6)
|
|
{
|
|
|
|
var aantal = 0;
|
|
var totaal = 0;
|
|
sql = "SELECT COUNT (cnt_contract_plaats_key) aantal"
|
|
+ " , SUM(COALESCE(cnt_contract_plaats_gewicht, 0)) totaal"
|
|
+ " FROM cnt_contract_plaats"
|
|
+ " WHERE cnt_contract_key = " + cnt_key;
|
|
oRs = Oracle.Execute(sql);
|
|
// Altijd resultaat
|
|
aantal = oRs("aantal").Value;
|
|
totaal = oRs("totaal").Value;
|
|
|
|
var kosten = 0;
|
|
sql = "SELECT cnt_contract_kosten FROM cnt_contract WHERE cnt_contract_key = " + cnt_key;
|
|
oRs = Oracle.Execute(sql);
|
|
if (!oRs.eof)
|
|
{
|
|
kosten = oRs(0).Value;
|
|
}
|
|
|
|
sql = "";
|
|
var scopetext = "";
|
|
switch (cnt_typecontract)
|
|
{
|
|
// resultaatkolommen code, scope, gewicht, type
|
|
case 1: // Onderhoud op objecten
|
|
sql = "SELECT 0 code"
|
|
+ " , " + lcl.xsql('S.ins_srtdeel_omschrijving','S.ins_srtdeel_key') + " scope"
|
|
+ " , null gewicht"
|
|
+ " , 'S' type "
|
|
+ " , cnt_contract_object_key object_key"
|
|
+ " FROM cnt_contract_object, ins_srtdeel S "
|
|
+ " WHERE cnt_ins_deel_key IS NULL"
|
|
+ " AND cnt_ins_srtdeel_key = S.ins_srtdeel_key"
|
|
+ " AND cnt_contract_object_verwijder IS NULL"
|
|
+ " AND cnt_contract_key = " + cnt_key
|
|
+ " UNION ALL"
|
|
+ " SELECT 1 code"
|
|
+ " , COALESCE( (SELECT l.alg_locatie_omschrijving || ': ' || D.alg_plaatsaanduiding || ' ' || ins_deel_omschrijving || ' (' || " + lcl.xsql('D.ins_srtdeel_omschrijving','D.ins_srtdeel_key') + " || ')'"
|
|
+ " FROM ins_v_deel_gegevens D, alg_locatie l"
|
|
+ " WHERE cnt_ins_deel_key = D.ins_deel_key"
|
|
+ " AND l.alg_locatie_key =D.alg_locatie_key ),"
|
|
+ " COALESCE(( SELECT pf.prs_perslid_naam_full || ' ' || ins_deel_omschrijving || ' (' || " + lcl.xsql('SD.ins_srtdeel_omschrijving','SD.ins_srtdeel_key') + " || ')'"
|
|
+ " FROM ins_deel D, ins_srtdeel SD, prs_v_perslid_fullnames pf "
|
|
+ " WHERE cnt_ins_deel_key = D.ins_deel_key"
|
|
+ " AND SD.ins_srtdeel_key = D.ins_srtdeel_key"
|
|
+ " AND pf.prs_perslid_key = D.ins_alg_ruimte_key"
|
|
+ " AND D.ins_alg_ruimte_type = 'P'),"
|
|
+ " COALESCE(( SELECT " + S("prs_dep_string") + " || ' ' ||ins_deel_omschrijving || ' (' ||" + lcl.xsql('SD.ins_srtdeel_omschrijving','SD.ins_srtdeel_key') + " || ')'"
|
|
+ " FROM ins_deel D, ins_srtdeel SD, prs_v_aanwezigafdeling d"
|
|
+ " WHERE cnt_ins_deel_key = D.ins_deel_key"
|
|
+ " AND SD.ins_srtdeel_key = D.ins_srtdeel_key"
|
|
+ " AND d.prs_afdeling_key = D.ins_alg_ruimte_key"
|
|
+ " AND D.ins_alg_ruimte_type = 'A'), 'onb'))) scope"
|
|
+ " , null gewicht"
|
|
+ " , 'D' type"
|
|
+ " , cnt_contract_object_key object_key"
|
|
+ " FROM cnt_contract_object"
|
|
+ " WHERE cnt_ins_deel_key IS NOT NULL"
|
|
+ " AND cnt_contract_object_verwijder IS NULL"
|
|
+ " AND cnt_contract_key = " + cnt_key
|
|
+ " ORDER BY 3";
|
|
scopetext = L("lcl_cnt_objects");
|
|
break;
|
|
case 2: // DEPRECATED
|
|
break;
|
|
case 3: // onderhoud op objectsoorten en/of plaats
|
|
case 5: // onderhoud op plaats
|
|
if (cnt_typecontract == 3)
|
|
{
|
|
sql = "SELECT ins_srtdeel_code code"
|
|
+ " , " + lcl.xsql('sd.ins_srtdeel_omschrijving','SD.ins_srtdeel_key') + " scope"
|
|
+ " , null gewicht"
|
|
+ " , 'S' type"
|
|
+ " , -1 plaats_key"
|
|
+ " FROM cnt_contract_object co"
|
|
+ " , ins_srtdeel sd"
|
|
+ " WHERE co.cnt_ins_srtdeel_key = sd.ins_srtdeel_key"
|
|
+ " AND co.cnt_contract_object_verwijder IS NULL"
|
|
+ " AND sd.ins_srtdeel_verwijder IS NULL"
|
|
+ " AND cnt_contract_key = " + cnt_key
|
|
+ " UNION ALL ";
|
|
}
|
|
sql += "SELECT cnt_alg_plaats_code"
|
|
+ " , l.alg_locatie_omschrijving || ' (' || l.alg_locatie_code || ')' scope"
|
|
+ " , cnt_contract_plaats_gewicht gewicht"
|
|
+ " , cnt_alg_plaats_code type"
|
|
+ " , cnt_contract_plaats_key plaats_key"
|
|
+ " FROM cnt_contract_plaats"
|
|
+ " , alg_locatie l"
|
|
+ " WHERE cnt_alg_plaats_key = l.alg_locatie_key"
|
|
+ " AND cnt_alg_plaats_code = 'L'"
|
|
+ " AND cnt_contract_plaats_verwijder IS NULL"
|
|
+ " AND cnt_contract_key = " + cnt_key
|
|
+ " UNION "
|
|
+ "SELECT cnt_alg_plaats_code"
|
|
+ " , l.alg_locatie_omschrijving || ' (' || l.alg_locatie_code || '): "
|
|
+ L("lcl_building") + " ' ||g.alg_gebouw_naam scope"
|
|
+ " , cnt_contract_plaats_gewicht gewicht, cnt_alg_plaats_code type"
|
|
+ " , cnt_contract_plaats_key plaats_key"
|
|
+ " FROM cnt_contract_plaats, alg_locatie l"
|
|
+ " , alg_gebouw g "
|
|
+ " WHERE cnt_alg_plaats_code = 'G'"
|
|
+ " AND cnt_alg_plaats_key=g.alg_gebouw_key"
|
|
+ " AND g.alg_locatie_key=l.alg_locatie_key"
|
|
+ " AND cnt_contract_plaats_verwijder IS NULL"
|
|
+ " AND cnt_contract_key = " + cnt_key
|
|
+ " UNION "
|
|
+ "SELECT cnt_alg_plaats_code"
|
|
+ " , l.alg_locatie_omschrijving || ' (' || l.alg_locatie_code || '): "
|
|
+ L("lcl_terra") + " ' ||t.alg_terreinsector_naam scope"
|
|
+ " , cnt_contract_plaats_gewicht gewicht"
|
|
+ " , cnt_alg_plaats_code type"
|
|
+ " , cnt_contract_plaats_key plaats_key"
|
|
+ " FROM cnt_contract_plaats"
|
|
+ " , alg_locatie l"
|
|
+ " , alg_terreinsector t"
|
|
+ " WHERE cnt_alg_plaats_code = 'T'"
|
|
+ " AND cnt_alg_plaats_key=t.alg_terreinsector_key"
|
|
+ " AND t.alg_locatie_key=l.alg_locatie_key"
|
|
+ " AND cnt_contract_plaats_verwijder IS NULL"
|
|
+ " AND cnt_contract_key = " + cnt_key
|
|
+ " ORDER BY 4,2";
|
|
scopetext = L("lcl_cnt_locations");
|
|
break;
|
|
}
|
|
|
|
function fncolLink(oRs)
|
|
{
|
|
var nurl = "";
|
|
return nurl;
|
|
};
|
|
|
|
function fnGewicht(oRs)
|
|
{
|
|
var result = "";
|
|
if (aantal > 0 && totaal != 0)
|
|
result = (kosten * oRs("gewicht").Value / totaal);
|
|
return safe.curr(result);
|
|
}
|
|
|
|
function fnTotaal_opp(oRs)
|
|
{
|
|
if (!oRs("totaal_opp").Value)
|
|
return L("lcl_cnt_unknown");
|
|
return safe.displayfloat(oRs("totaal_opp").Value);
|
|
}
|
|
|
|
BLOCK_START({collapsed: true, title: L("lcl_cnt_frame_scope")});
|
|
var rst = new ResultsetTable({sql: sql,
|
|
keyColumn: (cnt_typecontract == 1? "object_key" : "plaats_key"),
|
|
linkColumn: fncolLink,
|
|
groupColumn: "scope",
|
|
headerColumn: "scope",
|
|
detailColumn: "", //"type",
|
|
//asideColumn: fnAside,
|
|
subheaderColumn: (cnt_typecontract == 2? fnTotaal_opp : fnGewicht),
|
|
ID: "scopetable",
|
|
noSearch: true,
|
|
showAll: true
|
|
});
|
|
|
|
var cnt = rst.processResultset();
|
|
BLOCK_END()
|
|
}
|
|
|
|
CONTROLGROUP_START()
|
|
// Buttons
|
|
if (cnt_key > -1)
|
|
{
|
|
if (this_cnt.canGoedkeur1 ||
|
|
this_cnt.canGoedkeur2 ||
|
|
this_cnt.canGoedkeur3 ||
|
|
this_cnt.canGoedkeur4 ||
|
|
this_cnt.canGoedkeur5)
|
|
BUTTON(L("lcl_goedkeur"), {click: "cnt_goedkeur()", icon: "fa-check"});
|
|
if (this_cnt.canReject)
|
|
BUTTON(L("lcl_reject"), {click: "cnt_reject()", icon: "fa-times"});
|
|
|
|
// (de close-knop die hier stond bestaat voor contracten helemaal niet)
|
|
|
|
trackinglines = mobile.hastrackingpage('contract', cnt_key);
|
|
if (trackinglines > 0) {
|
|
BUTTON(L("lcl_history"), {linkid: "#cnt-2-" + cnt_key, icon: "fa-list"});
|
|
}
|
|
|
|
var tsql = "SELECT COUNT(*) FROM cnt_contract_note n WHERE n.cnt_contract_key = " + cnt_key;
|
|
toRs = Oracle.Execute(tsql);
|
|
BUTTON(L("lcl_cnt_frame_notes")+" ("+toRs(0).value+")", {linkid: "./notitie.asp?node=contract&key="+cnt_key, icon: "fa-comment" });
|
|
toRs.close();
|
|
|
|
if (!Session("app_build")) {
|
|
BUTTON(L("lcl_print"), {click: "cnt_print()", icon: "fa-print"});
|
|
}
|
|
|
|
if (cnt_info.srtcontract_type == 6)
|
|
{
|
|
var csql = "SELECT COUNT(*) FROM cnt_contract "
|
|
+ " WHERE cnt_contract_verwijder is null"
|
|
+ " and cnt_contract_status = 0"
|
|
+ " and cnt_contract_looptijd_van < trunc(sysdate)"
|
|
+ " and cnt_contract_looptijd_tot > trunc(sysdate)"
|
|
+ " and cnt_contract_mantel_key = " + cnt_key
|
|
coRs = Oracle.Execute(csql);
|
|
BUTTON(L("lcl_cnt_child_contracts") +" ("+coRs(0).value+")", {linkid: "./cnt_list.asp?mantel_key="+cnt_key, icon: "fa-comment" });
|
|
coRs.close();
|
|
}
|
|
|
|
}
|
|
else
|
|
trackinglines = 0;
|
|
CONTROLGROUP_END()
|
|
|
|
CONTENT_END();
|
|
FOOTER();
|
|
PAGE_END()
|
|
|
|
if (trackinglines > 0)
|
|
{
|
|
PAGE_START({id: "cnt-2-" + cnt_key, dialog: true})
|
|
mobile.trackingpage('contract', cnt_key, subject);
|
|
PAGE_END();
|
|
}
|
|
PDA_PAGE_END(); %>
|
|
</body>
|
|
</html>
|
|
<% ASPPAGE_END(); %>
|