<%@language = "javascript" %>
<%
/*  $Revision$
    $Id$

    File:               prj_show_scenario.asp
    Description:        Detailscherm voor verhuisscenario's
    Parameters:
      prj_key           Scenario key (REQUIRED)
      verynew           optional
    Context:
    Note:
*/ %>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="prj.inc" -->

<%
FCLTHeader.Requires({ plugins: ["jQuery"],
                      js: ["jQuery-ui.js", "../PRJ/prj_show_scenario.js"]
                    })

var verynew = getQParamInt("verynew", 0) == 1;
var prj_key = getQParamInt("prj_key");

// De functie checkAutorisation(autfunction) geeft een Response.End indien er geen autorisatie voor autfunction wordt gevonden
var authparamsBOF = user.checkAutorisation("WEB_PRJBOF"); // om te bewerken
var authparamsMAN = user.checkAutorisation("WEB_PRJMAN", true); // om door te voeren

//var this_prj = prj.func_enabled_scenario(prj_key); // Wat heb ik zoal aan rechten op deze specifieke scenario

// Initialisatie met de initieel weer te geven gegevens
sql = "SELECT s.prj_scenario_omschrijving"
    + ", m.mld_melding_key || '-' || " + lcl.xsql('stdm.mld_stdmelding_omschrijving','stdm.mld_stdmelding_key') + " verhuisaanvraag"
    + ", prj_scenario_datum"
    + ", s.prj_scenario_status"
    + ", s.prj_scenario_raming"
    + ", s.prj_scenario_opmerking"
    + ", " + S("prs_pers_string") + " naam"
    + ", s.prs_perslid_key"
    + ", rx.alg_verdieping_key"
    + " FROM prj_scenario s"
    + ", prs_perslid p"
    + ", mld_melding m"
    + ", mld_stdmelding stdm"
    + ", prj_ruimte rx"
    + " WHERE s.prs_perslid_key = p.prs_perslid_key(+)"
    + " AND s.mld_melding_key = m.mld_melding_key(+)"
    + " AND m.mld_stdmelding_key = stdm.mld_stdmelding_key(+)"
    + " AND s.prj_scenario_key = rx.prj_scenario_key(+)"
    + " AND s.prj_scenario_key = " + prj_key;
oRs = Oracle.Execute(sql);
if (oRs.eof)
    shared.record_not_found("PRJ: Record not found");

prj_omschr = oRs("prj_scenario_omschrijving").value;
prj_verhuisaanvraag = oRs("verhuisaanvraag").value;
prj_datum = oRs("prj_scenario_datum").value;
prj_status = oRs("prj_scenario_status").value;
prj_raming = oRs("prj_scenario_raming").value;
prj_opm = oRs("prj_scenario_opmerking").value;
prj_name = oRs("naam").value;
prj_perslidkey = oRs("prs_perslid_key").value;
prj_verdieping = oRs("alg_verdieping_key").value;
if (!prj_verdieping) prj_verdieping = -1;


oRs.close();
var subjectMail = L("lcl_prj_scenario") + " " + prj_key;
var urlMail = "../shared/queuemail.asp?pcode=PRJMAI&defemail_key=" + prj_perslidkey
            + "&defemail_type=P"
            + "&key=" + prj_key
            + "&subject=" + Server.URLencode(subjectMail)
            + "&mailfrom=" + (authparamsBOF? 1 : 0); // Als je write rechten hebt heb je zeker ook read rechten.
%>
<html>
  <head>
<%
    FCLTHeader.Generate();
%>
<script  type="text/javascript" >
    defemail_key = <%=prj_perslidkey%>;
    defemail_type = "P";

       jQuery(document).ready(function()
                              {
                                $('textarea').resize(function() { FcltMgr.resized(window) });
                                $('textarea').autogrow();
                              });
    function prj_upload(prj_key)
    {
      var url = "<%=protectQS.create("../Shared/BijlagenForm.asp?module=FGIIP&multi=1&key=" + prj_key)%>";
      FcltMgr.openModalDetail(url, L("lcl_prj_tekeningen") + " " + L("lcl_prj_scenario").toLowerCase() + " " + prj_key);
    }

    function prj_mail(prj_key)
    {
      var subject = "<%=safe.jsstring(subjectMail)%>";
      var url = "<%=safe.jsstring(protectQS.create(urlMail))%>";
      FcltMgr.openModalDetail(url, subject, { callback: prjMailCallback });
    }

</script>
<%


%>
  </head>

  <body id="showbody">
<%
    var buttons = [];

    buttons.push({ title: L("lcl_prj_details"), icon: "wijzigen.png", action: "prj_edit(" + prj_key + ")" });
    buttons.push({ title: L("lcl_prj_grafisch"), icon: "grafisch.png", action: "prj_graphics(" + prj_key + ")" });

    // Er zijn schrijfrechten nodig op WEB_PRJMAN om de doorvoeren actie te activeren
    // en als er nog geen verdieping aan vastzit kan men het scenario ook niet doorvoeren
    if (authparamsMAN && authparamsMAN.ALGwritelevel < 9 && prj_verdieping > 1)
      buttons.push({ title: L("lcl_prj_doorvoeren"), icon: "doorvoeren.png", action: "prj_submit(" + prj_key + ")" });

    buttons.push({ title: L("lcl_prj_verwijderen"), icon: "delete.png", action: "prj_cancel(" + prj_key + ")" });
    buttons.push({ title: L("lcl_prj_tekeningen"), icon: "tekeningen.png", action: "prj_upload(" + prj_key + ")" });

    buttons.push({ title: L("lcl_prj_rapportage"), icon: "print.png", action: "prj_report(" + prj_key + ")" });
    buttons.push({ title: L("lcl_noti_prj_email"), icon: "email.png", action: "prj_mail(" + prj_key + ")" });

    IFRAMER_HEADER(L("lcl_prj_frame_algemeen"), buttons);
%>

    <div id="show">
    <form name="u2" onSubmit="return false;">
<%
    BLOCK_START("prjInfo", L("lcl_prj_scenario") + " " + prj_key);
    ROFIELDTR("fld", L("lcl_prj_verhuisaanvraag"), prj_verhuisaanvraag);
    ROFIELDTR("flddate", "<nobr>" + L("lcl_prj_geplande_aanvang") + "</nobr>", toDateString(prj_datum));
    ROFIELDTR("fld", L("lcl_txt"), prj_omschr);
    ROFIELDTR("fld", L("lcl_status"), prj_status);
    ROFIELDTR("fld", L("lcl_prj_starter"), prj_name);
    ROTEXTAREATR("fldtxt", L("lcl_remark"), prj_opm, {id: "txt", suppressEmpty: true});
    BLOCK_END();

    BLOCK_START("prjKosten", L("lcl_prj_kosten"), true);
    ROFIELDTR("fldprjraming", "<nobr>" + L("lcl_prj_cost") + "</nobr>", prj_raming);
    BLOCK_END();

    BLOCK_START("prjVerdiepingen", L("lcl_prj_bouwlaag_in_prj"));
%>
<%
    var sql = "SELECT a.alg_onroerendgoed_keys alg_verdieping_key,"
            + "       a.alg_plaatsaanduiding "
            + "  FROM alg_v_plaatsaanduiding a"
            + " WHERE EXISTS"
            + "         (SELECT alg_ruimte_key "
            + "            FROM prj_ruimte rx"
            + "           WHERE rx.prj_scenario_key =  " + prj_key
            + "             AND a.alg_onroerendgoed_keys = rx.alg_verdieping_key "
            + "             AND a.alg_onroerendgoed_type = 'V')"   // vermijdt locatie
            + " ORDER BY alg_plaatsaanduiding";
    oRs = Oracle.Execute(sql);
    while( !oRs.eof ) {
     %><tr><td><input class="fld details" readonly
                value="<%=safe.htmlattr(oRs("alg_plaatsaanduiding").value)%>"
                title="<%=L("lcl_prj_grafisch")%>"
                onclick='prj_graphics_floor(<%=prj_key%>, <%=oRs("alg_verdieping_key").value%>)'></td></tr><%
      oRs.MoveNext();
    }
    oRs.close();

%>
<%  BLOCK_END();


%>  </form>
    </div> <!-- edit -->

  </body>
</html>


