276 lines
11 KiB
Plaintext
276 lines
11 KiB
Plaintext
<%@language = "javascript" %>
|
|
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: wp_change.asp
|
|
Description: Wijzig een prs_werkplek of prj_werkplek
|
|
Parameters: wp_key: te wijzigen prs_werkplek
|
|
scenario_key als groter 0 dan scenario
|
|
floor: op welke verdieping staat hij (of locatie_key)
|
|
Rot
|
|
DeltaRot
|
|
Scale
|
|
clearXY
|
|
autoAlign
|
|
delete
|
|
NewX, NewY, orgX, orgY
|
|
Context: default.asp/Ajax.Updater
|
|
Result: JSON object
|
|
Note: - een nieuwe locatie (XY) (Eventueel wordt hij ook in een andere ALG_RUIMTE geplaatst.)
|
|
- Wissen locatie (XY)
|
|
- Rotatie vaste hoek
|
|
- Rotatie/ snappen op muur
|
|
- Schaal
|
|
*/
|
|
DOCTYPE_Disable = 1;
|
|
%>
|
|
<!-- #include file="../Shared/common.inc" -->
|
|
<!-- #include file="../Shared/json2.js" -->
|
|
<!-- #include file="../SlnkDWF/SLNK2IMG.inc" -->
|
|
<!-- #include file="../Shared/WPFunctions.inc" -->
|
|
<!-- #include file="FGII.inc" -->
|
|
|
|
<%
|
|
var wp_key = getQParamInt("wp_key");
|
|
var vKey = getQParamInt("floor");
|
|
var scenario_key = getQParamInt("scenario_key"); // current scenario.
|
|
|
|
if (scenario_key == 0 && !WPCanWrite(vKey))
|
|
{
|
|
Response.Write(JSON.stringify({ success: false, message: L("lcl_fg_obj_noedit") }));
|
|
Response.End;
|
|
}
|
|
|
|
var pContmode = getQParam("contmode", "");
|
|
function myMiniContourProcessor(cHandle)
|
|
{
|
|
var pDiscs_arr = getQParamIntArray("discs", []);
|
|
cHandle.SetFilterLayers(myFilterLayer(pDiscs_arr));
|
|
}
|
|
|
|
var sql = null; // Hierin gaan we het updatestatement bouwen.
|
|
|
|
if (getQParamInt("clearXY", 0) == 1)
|
|
{ // Geen nieuwe positie, XY wissen
|
|
if (scenario_key == 0)
|
|
sql = "UPDATE prs_werkplek"
|
|
+ " SET prs_werkplek_dwgx = NULL,"
|
|
+ " prs_werkplek_dwgy = NULL,"
|
|
+ " prs_werkplek_dwgrotatie = 0,"
|
|
+ " prs_werkplek_dwgschaal = 1.0"
|
|
+ " WHERE prs_werkplek_key = " + wp_key;
|
|
else
|
|
sql = "UPDATE prj_werkplek"
|
|
+ " SET prj_werkplek_dwgx = NULL,"
|
|
+ " prj_werkplek_dwgy = NULL,"
|
|
+ " prj_werkplek_dwgrotatie = 0,"
|
|
+ " prj_werkplek_dwgschaal = 1.0"
|
|
+ " WHERE prj_werkplek_key = " + wp_key;
|
|
}
|
|
else if (getQParamInt("delete", 0) == 1)
|
|
{ // Symbool wissen
|
|
if (scenario_key==0)
|
|
{
|
|
sql = "UPDATE PRS_WERKPLEK"
|
|
+ " SET prs_werkplek_verwijder=SYSDATE"
|
|
+ " WHERE prs_werkplek_key = " + wp_key;
|
|
}
|
|
else
|
|
{
|
|
// Objecten binnen het project aangemaakt verwijderen we echt.
|
|
Oracle.Execute("DELETE FROM PRJ_WERKPLEK WHERE prs_werkplek_key IS NULL AND prj_werkplek_key = " + wp_key);
|
|
// het volgende statement is eigenlijk alleen relevant bij werkplekken die vroeger al bestonden
|
|
sql = "UPDATE PRJ_WERKPLEK"
|
|
+ " SET prj_werkplek_verwijder=SYSDATE"
|
|
+ " WHERE prj_werkplek_key = " + wp_key;
|
|
}
|
|
}
|
|
else if (Request.QueryString("newX").Count > 0)
|
|
{
|
|
var newX = parseFloat(getQParam("newX"));
|
|
var newY = parseFloat(getQParam("newY"));
|
|
var orgX = parseFloat(getQParam("orgX"));
|
|
var orgY = parseFloat(getQParam("orgY"));
|
|
var lblContour = getQParam("Contour", "");
|
|
var vKey = getQParamInt("floor");
|
|
|
|
if (lblContour.match(/^W:/) && lblContour.substring(2) != wp_key) // Op een andere werkplek gedropt
|
|
{ // Verhuis alle personen naar de nieuwe werkplek, laat de oude ongemoeid
|
|
lblContour = lblContour.substring(2);
|
|
if (scenario_key==0)
|
|
sql = "UPDATE prs_perslidwerkplek"
|
|
+ " SET prs_werkplek_key = " + lblContour
|
|
+ " WHERE prs_werkplek_key = " + wp_key
|
|
else
|
|
sql = "UPDATE prj_perslidwerkplek"
|
|
+ " SET prj_werkplek_key = " + lblContour
|
|
+ " WHERE prj_werkplek_key = " + wp_key
|
|
}
|
|
else // Op/in een ruimte gedropt of op onszelf
|
|
{
|
|
var ruimte_key = -1;
|
|
if (!lblContour.match(/^W:/)) // Onszelf is altijd goed
|
|
{ // Ook/alfanumeriek naar nieuwe werkplek
|
|
if (scenario_key==0)
|
|
{
|
|
sql = "SELECT alg_ruimte_key FROM " + S("fg_syncruimteview")
|
|
+ " WHERE cadlabel = " + safe.quoted_sql(lblContour)
|
|
+ " AND alg_verdieping_key = " + vKey;
|
|
var oRs = Oracle.Execute(sql);
|
|
if (!oRs.Eof) // Werkplek moet altijd in een ruimte
|
|
WPMove_PRS_WERKPLEK(wp_key, oRs("alg_ruimte_key").value);
|
|
oRs.Close();
|
|
}
|
|
else
|
|
{
|
|
sql = "SELECT prj_ruimte_key FROM " + S("fg_prj_syncruimteview")
|
|
+ " WHERE cadlabel = " + safe.quoted_sql(lblContour)
|
|
+ " AND alg_verdieping_key = " + vKey
|
|
+ " AND prj_scenario_key = " + scenario_key;
|
|
var oRs = Oracle.Execute(sql);
|
|
if (!oRs.Eof) // Werkplek moet altijd in een ruimte
|
|
Oracle.Execute("BEGIN prj.prj_move_werkplek (" + wp_key + "," + oRs(0).value + "); END;");
|
|
oRs.Close();
|
|
}
|
|
}
|
|
|
|
// Als XY nog niet was ingevuld nemen we newX, newY
|
|
// Anders nemen we 'verplaatsing' wat nauwkeuriger is
|
|
if (scenario_key==0)
|
|
sql = "UPDATE prs_werkplek"
|
|
+ " SET prs_werkplek_dwgx = coalesce(prs_werkplek_dwgx + " + (newX-orgX) + ", " + newX + "),"
|
|
+ " prs_werkplek_dwgy = coalesce(prs_werkplek_dwgy + " + (newY-orgY) + ", " + newY + "),"
|
|
+ " prs_werkplek_dwgrotatie = coalesce(prs_werkplek_dwgrotatie, 0),"
|
|
+ " prs_werkplek_dwgschaal = coalesce(prs_werkplek_dwgschaal, 1.0)"
|
|
+ " WHERE prs_werkplek_key = " + wp_key
|
|
else
|
|
sql = "UPDATE prj_werkplek"
|
|
+ " SET prj_werkplek_dwgx = coalesce(prj_werkplek_dwgx + " + (newX-orgX) + ", " + newX + "),"
|
|
+ " prj_werkplek_dwgy = coalesce(prj_werkplek_dwgy + " + (newY-orgY) + ", " + newY + "),"
|
|
+ " prj_werkplek_dwgrotatie = coalesce(prj_werkplek_dwgrotatie, 0),"
|
|
+ " prj_werkplek_dwgschaal = coalesce(prj_werkplek_dwgschaal, 1.0)"
|
|
+ " WHERE prj_werkplek_key = " + wp_key
|
|
}
|
|
}
|
|
else if (Request.QueryString("DeltaRot").Count > 0)
|
|
{
|
|
var angle = parseFloat(getQParam("DeltaRot"));
|
|
if (angle == 0)
|
|
{
|
|
if (scenario_key==0)
|
|
var sql = "UPDATE prs_werkplek"
|
|
+ " SET prs_werkplek_dwgrotatie = " + angle
|
|
+ " WHERE prs_werkplek_key = " + wp_key
|
|
else
|
|
var sql = "UPDATE prj_werkplek"
|
|
+ " SET prj_werkplek_dwgrotatie = " + angle
|
|
+ " WHERE prj_werkplek_key = " + wp_key;
|
|
}
|
|
else
|
|
{
|
|
if (scenario_key==0)
|
|
var sql = "UPDATE prs_werkplek"
|
|
+ " SET prs_werkplek_dwgrotatie = coalesce(prs_werkplek_dwgrotatie + " + angle + ", " + angle + ")"
|
|
+ " WHERE prs_werkplek_key = " + wp_key
|
|
else
|
|
var sql = "UPDATE prj_werkplek"
|
|
+ " SET prj_werkplek_dwgrotatie = coalesce(prj_werkplek_dwgrotatie + " + angle + ", " + angle + ")"
|
|
+ " WHERE prj_werkplek_key = " + wp_key
|
|
}
|
|
}
|
|
else if (Request.QueryString("Rot").Count > 0)
|
|
{
|
|
var angle = parseFloat(getQParam("rot"));
|
|
if (scenario_key==0)
|
|
var sql = "UPDATE prs_werkplek"
|
|
+ " SET prs_werkplek_dwgrotatie = " + angle
|
|
+ " WHERE prs_werkplek_key = " + wp_key;
|
|
else
|
|
var sql = "UPDATE prj_werkplek"
|
|
+ " SET prj_werkplek_dwgrotatie = " + angle
|
|
+ " WHERE prj_werkplek_key = " + wp_key;
|
|
}
|
|
else if (getQParamInt("AutoAlign", 0) == 1)
|
|
{
|
|
inoutMode = getQParam("mode" ,MODE_IN);
|
|
pvKey = getQParam("vKey" , -1);
|
|
dwfPath = SetVerdPlanDWF(pvKey, inoutMode,scenario_key);
|
|
if (dwfPath)
|
|
{
|
|
// Als we ook op symbolen (hun contour!) willen snappen
|
|
// SlnkSetContourProcessor(addSymbols);
|
|
var mySLNKDWF = new SLNKDWF({ dwfFile : dwfPath,
|
|
dwfProcessor : myMiniContourProcessor,
|
|
imgProcessor : null,
|
|
contourLayers: S("fg_contourlayers"),
|
|
labelLayers : S("fg_labellayers"),
|
|
maximize : S("fg_maximize"),
|
|
minArea : S("fg_contour_minArea"),
|
|
tempFolder : Server.MapPath("../../Temp")
|
|
});
|
|
|
|
var SLNKEvent = mySLNKDWF.Find(); // Werkt op Querystring parameters findX en findY
|
|
|
|
if (SlnkEvent.ContourLabel != "")
|
|
{
|
|
var sql = "select prs_werkplek_dwgrotatie, "
|
|
+ " prs_werkplek_dwgx, prs_werkplek_dwgy"
|
|
+ " from prs_werkplek"
|
|
+ " WHERE prs_werkplek_key = " + wp_key
|
|
oRs = Oracle.Execute(sql);
|
|
if (!oRs.Eof)
|
|
{
|
|
var oldAngle = (oRs("prs_werkplek_dwgrotatie").value + 360) % 360;
|
|
// newangle wordt SLNKEvent.EdgeAngle, SLNKEvent.EdgeAngle+90, SLNKEvent.EdgeAngle+180
|
|
// of SLNKEvent.EdgeAngle+270, wat maar het dichtst bij oldAngle zit
|
|
var newAngle = SLNKEvent.EdgeAngle; // Eerste gok
|
|
var dist = Math.abs(oldAngle - newAngle);
|
|
__Log("oa: " + oldAngle + " na: " + newAngle + " d: " + dist);
|
|
for (var deg=0; deg<360; deg+=90)
|
|
{
|
|
var dist2 = Math.min(Math.abs(oldAngle - (SLNKEvent.EdgeAngle + deg)),
|
|
Math.abs(oldAngle - (SLNKEvent.EdgeAngle + deg - 360)));
|
|
if (Math.abs(dist2) < dist)
|
|
{
|
|
dist = dist2;
|
|
newAngle = (SLNKEvent.EdgeAngle + deg) % 360;
|
|
}
|
|
__Log(" na: " + newAngle + " d: " + dist);
|
|
}
|
|
sql = "UPDATE prs_werkplek"
|
|
+ " SET prs_werkplek_dwgrotatie = " + newAngle
|
|
+ " WHERE prs_werkplek_key = " + wp_key
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Response.Write(JSON.stringify({ success: false, message: L("lcl_fg_place_wp_in_room") }));
|
|
Response.End;
|
|
}
|
|
|
|
}
|
|
}
|
|
else if (Request.QueryString("Scale").Count > 0)
|
|
{
|
|
var scl = parseFloat(getQParam("scale"));
|
|
if (scenario_key==0)
|
|
var sql = "UPDATE prs_werkplek"
|
|
+ " SET prs_werkplek_dwgschaal = " + scl
|
|
+ " WHERE prs_werkplek_key = " + wp_key
|
|
else
|
|
var sql = "UPDATE prj_werkplek"
|
|
+ " SET prj_werkplek_dwgschaal = " + scl
|
|
+ " WHERE prj_werkplek_key = " + wp_key
|
|
}
|
|
else
|
|
{
|
|
Response.Write(JSON.stringify({ success: false, message: "wp_change.asp: invalid parameter" }));
|
|
Response.End;
|
|
}
|
|
if (sql)
|
|
Oracle.Execute(sql);
|
|
|
|
Response.Write(JSON.stringify({ success: true }));
|
|
%>
|