218 lines
8.2 KiB
Plaintext
218 lines
8.2 KiB
Plaintext
<%@ language = "JavaScript" %>
|
|
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: res_multi_save.asp
|
|
Description: save script van res_multi_deit.asp
|
|
Globalen:
|
|
Context:
|
|
Note:
|
|
*/
|
|
var JSON_Result = true;
|
|
%>
|
|
|
|
<!-- #include file="../Shared/common.inc" -->
|
|
<!-- #include file="../Shared/json2.js" -->
|
|
<!-- #include file="../Shared/save2db.inc" -->
|
|
<!-- #include file="./res.inc" -->
|
|
|
|
<%
|
|
|
|
var urole = getQParamSafe("urole");
|
|
var rsv_ruimte_key = getQParamInt("rsv_ruimte_key");
|
|
//
|
|
// Submit code
|
|
//
|
|
/* --flags (0-16383)
|
|
-- 0 Niks
|
|
-- 1 Omschrijving
|
|
-- 2 Opmerkingen
|
|
-- 4 Tijdstip
|
|
-- 8 Aantal personen
|
|
-- 16 Ruimte/opstelling
|
|
-- 32 Gastheer
|
|
-- 64 Kostenplaats
|
|
-- 128 Voorzieningen (delen)
|
|
-- 256 Catering (artikelen)
|
|
-- 512 Bezoekers
|
|
-- 1024 Flexkenmerken
|
|
-- 2048 Tijdstip
|
|
-- 4096 Naam contactpersoon
|
|
-- 8192 Reserveringsstatus
|
|
*/
|
|
|
|
var what = getFParamInt( "c1", 0, true) + getFParamInt( "c2", 0, true) + getFParamInt( "c4", 0, true) + getFParamInt( "c8", 0, true)
|
|
+ getFParamInt( "c16", 0, true) + getFParamInt( "c32", 0, true) + getFParamInt( "c64", 0, true) + getFParamInt( "c128", 0, true)
|
|
+ getFParamInt( "c256", 0, true) + getFParamInt( "c512", 0, true) + getFParamInt("c1024", 0, true) + getFParamInt("c2048", 0, true)
|
|
+ getFParamInt("c4096", 0, true) + getFParamInt("c8192", 0, true);
|
|
|
|
var sql = "SELECT rr.res_reservering_key"
|
|
+ " , rr.res_rsv_ruimte_van"
|
|
+ " , rr.res_rsv_ruimte_volgnr"
|
|
+ " , rr.res_status_fo_key"
|
|
+ " , r.res_ruimte_vervaldatum"
|
|
+ " FROM res_rsv_ruimte rr"
|
|
+ " , res_ruimte_opstelling ro"
|
|
+ " , res_ruimte r"
|
|
+ " WHERE rr.res_ruimte_opstel_key = ro.res_ruimte_opstel_key(+)"
|
|
+ " AND ro.res_ruimte_key = r.res_ruimte_key(+)"
|
|
+ " AND rr.res_rsv_ruimte_key = " + rsv_ruimte_key;
|
|
oRs = Oracle.Execute(sql);
|
|
var resnum = oRs("res_reservering_key").value + "/" + oRs("res_rsv_ruimte_volgnr").value;
|
|
var date_from = new Date(oRs("res_rsv_ruimte_van").Value);
|
|
var ruimte_vervaldatum_from = oRs("res_ruimte_vervaldatum").Value;
|
|
if (ruimte_vervaldatum_from != null)
|
|
ruimte_vervaldatum_from = new Date(ruimte_vervaldatum_from);
|
|
var status_fo_from = oRs("res_status_fo_key").Value;
|
|
oRs.Close();
|
|
|
|
var changed = "";
|
|
if (what & 1)
|
|
changed += (changed != ""? ", " : "") + L("lcl_descr")
|
|
if (what & 2)
|
|
changed += (changed != ""? ", " : "") + L("lcl_remark")
|
|
if (what & 4)
|
|
changed += (changed != ""? ", " : "") + L("lcl_date_time")
|
|
if (what & 8)
|
|
changed += (changed != ""? ", " : "") + L("lcl_visitors")
|
|
if (what & 16)
|
|
changed += (changed != ""? ", " : "") + L("lcl_room")
|
|
if (what & 32)
|
|
changed += (changed != ""? ", " : "") + L("lcl_host")
|
|
if (what & 64)
|
|
changed += (changed != ""? ", " : "") + L("lcl_account")
|
|
if (what & 128)
|
|
changed += (changed != ""? ", " : "") + L("lcl_reserved_object")
|
|
if (what & 256)
|
|
changed += (changed != ""? ", " : "") + L("lcl_catering")
|
|
if (what & 512)
|
|
changed += (changed != ""? ", " : "") + (S("bez_sel_internpersoon") == 1? L("lcl_res_frame_visitors") : L("lcl_res_frame_visitors_external"))
|
|
if (what & 1024)
|
|
changed += (changed != ""? ", " : "") + L("lcl_res_flexblok")
|
|
if (what & 2048)
|
|
changed += (changed != ""? ", " : "") + L("lcl_date")
|
|
if (what & 4096)
|
|
changed += (changed != ""? ", " : "") + L("lcl_name");
|
|
if (what & 8192)
|
|
changed += (changed != ""? ", " : "") + L("lcl_status_FO");
|
|
|
|
var msg = L("lcl_res_multi_copy").format(resnum) + changed;
|
|
|
|
var keyList = getFParamIntArray("deelreserveringen", []);
|
|
|
|
if (what != "" && keyList.length > 0)
|
|
{
|
|
|
|
if (getFParamInt("c2048", 0) == 2048) // datum. Controleer dat ze allemaal dezelfde datum hadden
|
|
{
|
|
var xsql = "SELECT TRUNC(res_rsv_ruimte_van), TRUNC(res_rsv_ruimte_tot), COUNT(*) "
|
|
+ " FROM res_rsv_ruimte"
|
|
+ " WHERE res_rsv_ruimte_key IN (" + keyList.join(",") + ")"
|
|
+ " GROUP BY TRUNC(res_rsv_ruimte_van), TRUNC(res_rsv_ruimte_tot)";
|
|
oRs = Oracle.Execute("SELECT COUNT(*) aantal FROM (" + xsql + ")");
|
|
if (oRs("aantal") > 1)
|
|
abort_with_warning(L("lcl_res_multi_save_dates")); // "Te veel datumvariatie";
|
|
}
|
|
|
|
// Maak een array met rsv_ruimte_key-s waarvan de status wijzigd.
|
|
if (what & 8192)
|
|
{
|
|
var keyStatusList = [];
|
|
var sql_to = "SELECT res_rsv_ruimte_key"
|
|
+ " FROM res_rsv_ruimte"
|
|
+ " WHERE res_status_fo_key <> " + status_fo_from
|
|
+ " AND res_rsv_ruimte_key IN (" + keyList.join(",") + ")";
|
|
oRs_to = Oracle.Execute(sql_to);
|
|
while (!oRs_to.eof)
|
|
{
|
|
keyStatusList.push( oRs_to("res_rsv_ruimte_key").Value );
|
|
oRs_to.MoveNext();
|
|
}
|
|
oRs_to.Close();
|
|
}
|
|
|
|
// Maak de update voor elke res_rsv_ruimte.
|
|
var sql = "BEGIN"
|
|
var i;
|
|
for (i in keyList)
|
|
{
|
|
var rsv_ruimte_key_to = keyList[i];
|
|
|
|
if ((what & 16) > 0 || (what & 2048) > 0)
|
|
{
|
|
if (what & 2048) // Wordt de datum overgenomen?
|
|
datum_to = date_from; // Datum wordt overgenomen.
|
|
else
|
|
{ // Datum wordt niet overgenomen. Bepaal de datum van de reservering die gewijzigd wordt.
|
|
var sql_to = "SELECT rr.res_rsv_ruimte_van"
|
|
+ " FROM res_rsv_ruimte rr"
|
|
+ " WHERE rr.res_rsv_ruimte_key = " + rsv_ruimte_key_to;
|
|
var oRs_to = Oracle.Execute(sql_to);
|
|
var datum_to = new Date(oRs_to("res_rsv_ruimte_van").Value);
|
|
oRs_to.Close();
|
|
}
|
|
|
|
if (what & 16) // Wordt de ruimte overgenomen?
|
|
ruimte_vervaldatum_to = ruimte_vervaldatum_from; // Ruimte wordt overgenomen.
|
|
else
|
|
{ // Ruimte wordt niet overgenomen. Bepaal de vervaldatum van de ruimte van de reservering die gewijzigd wordt.
|
|
var sql_to = "SELECT rr.res_rsv_ruimte_van"
|
|
|
|
var sql_to = "SELECT r.res_ruimte_vervaldatum"
|
|
+ " FROM res_rsv_ruimte rr"
|
|
+ " , res_ruimte_opstelling ro"
|
|
+ " , res_ruimte r"
|
|
+ " WHERE rr.res_ruimte_opstel_key = ro.res_ruimte_opstel_key"
|
|
+ " AND ro.res_ruimte_key = r.res_ruimte_key"
|
|
+ " AND rr.res_rsv_ruimte_key = " + rsv_ruimte_key_to;
|
|
oRs_to = Oracle.Execute(sql_to);
|
|
var ruimte_vervaldatum_to = oRs_to("res_ruimte_vervaldatum").Value;
|
|
if (ruimte_vervaldatum_to != null)
|
|
ruimte_vervaldatum_to = new Date(ruimte_vervaldatum_to);
|
|
oRs_to.Close();
|
|
}
|
|
if (ruimte_vervaldatum_to != null && ruimte_vervaldatum_to < datum_to)
|
|
{ // Ruimte heeft een vervaldatum en de ruimte is voor de datum al vervallen. Ruimte kan niet gereserveerd worden.
|
|
abort_with_warning(L("lcl_res_room_expired").format(toDateString(ruimte_vervaldatum_to)));
|
|
}
|
|
}
|
|
|
|
sql += " res.res_sync_deelres(" + rsv_ruimte_key + "," + rsv_ruimte_key_to + "," + what + ", " + S("res_copy_to_bez") + ");";
|
|
sql += " fac.trackaction ('#RESUPD'," + rsv_ruimte_key_to + ", " + user_key + ", NULL, " + safe.quoted_sql(msg) + ");" // het hekje voorkomt notificaties
|
|
|
|
if (S("res_fe_allow_dirty") != 1 && urole == 'fe')
|
|
{
|
|
sql += " IF res.dirty_level_all(" + rsv_ruimte_key_to + ") <> 0 THEN"
|
|
+ " raise_application_error (-20000, 'res_m960 " + rsv_ruimte_key_to + " " + L("lcl_res_fe_no_dirty") + "');"
|
|
+ " END IF;"
|
|
}
|
|
}
|
|
sql += " END;"
|
|
|
|
var err = Oracle.Execute(sql, true);
|
|
if (err.friendlyMsg)
|
|
abort_with_warning(err.friendlyMsg);
|
|
|
|
// Alle status_fo zijn succesvol gewijzigd.
|
|
if (what & 8192)
|
|
{
|
|
var noti = { 1: "RESOPT",
|
|
2: "RESBEV",
|
|
3: "RESBLK",
|
|
4: "RESDEL"
|
|
}[status_fo_from];
|
|
if (noti)
|
|
{
|
|
for (i in keyStatusList)
|
|
shared.trackaction(noti, keyStatusList[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
shared.trackaction("RESMLT", rsv_ruimte_key);
|
|
result = { success : true, refresh: true };
|
|
|
|
Response.Write(JSON.stringify(result));
|
|
Response.End;
|
|
%> |