ARBO#31920 Maximaal reserveerbare tijd mogelijk maken

svn path=/Website/trunk/; revision=24722
This commit is contained in:
Erik Groener
2015-04-08 10:11:09 +00:00
parent ededff1a94
commit 3447dd2bfc
5 changed files with 145 additions and 91 deletions

View File

@@ -1640,6 +1640,90 @@ res = {
if (targethour_px < 16) hour_px = 8;
if (targethour_px < 8) hour_px = 4;
return hour_px;
},
max_duration: function (res_type, act_key, disc_key, duration_hurs)
{
var result = { err: false, message: "", maxhours: 0};
var sql = "SELECT rad.res_activiteit_key"
+ " , rdp.res_disc_params_maxduur"
+ " FROM res_activiteitdiscipline rad"
+ " , res_disc_params rdp"
+ " WHERE rad.res_discipline_key = rdp.res_ins_discipline_key"
+ " AND rad.res_discipline_key = " + disc_key
+ " AND rad.res_activiteit_key = " + act_key;
var oRs = Oracle.Execute(sql);
if (oRs.Eof)
{
result.message = L("lcl_res_bad_activity"+(res_type=="R"?"":"_CV"));
result.err = true;
}
else
{
maxHours = oRs("res_disc_params_maxduur").Value;
// Controle op maximale tijdsduur reservering.
if ((maxHours > 0) && (maxHours < duration_hours))
{
result.message = L("lcl_res_bad_maxperiod").format(maxHours);
result.maxhours = maxHours;
result.err = true;
}
}
oRs.close();
return result;
},
max_duration_cv: function (rsv_ruimte_key, duration_hours)
{
var result = { err: false, message: "", maxhours: 0};
if (rsv_ruimte_key > 0)
{
var sql = "SELECT rdp.res_disc_params_maxduur"
+ " FROM res_rsv_artikel rsva"
+ " , res_artikel ra"
+ " , res_rsv_ruimte rsv"
+ " , res_activiteitdiscipline rad"
+ " , res_disc_params rdp"
+ " WHERE rsva.res_artikel_key = ra.res_artikel_key"
+ " AND rsva.res_rsv_ruimte_key = rsv.res_rsv_ruimte_key"
+ " AND rad.res_discipline_key = rdp.res_ins_discipline_key"
+ " AND rad.res_discipline_key = ra.res_discipline_key"
+ " AND rad.res_activiteit_key = rsv.res_activiteit_key"
+ " AND rsv.res_rsv_ruimte_key = " + rsv_ruimte_key
+ " UNION "
+ "SELECT rdp.res_disc_params_maxduur"
+ " FROM res_rsv_deel rsvd"
+ " , res_deel rd"
+ " , res_rsv_ruimte rsv"
+ " , res_activiteitdiscipline rad"
+ " , res_disc_params rdp"
+ " WHERE rsvd.res_deel_key = rd.res_deel_key"
+ " AND rsvd.res_rsv_ruimte_key = rsv.res_rsv_ruimte_key"
+ " AND rad.res_discipline_key = rdp.res_ins_discipline_key"
+ " AND rad.res_discipline_key = rd.res_discipline_key"
+ " AND rad.res_activiteit_key = rsv.res_activiteit_key"
+ " AND rsv.res_rsv_ruimte_key = " + rsv_ruimte_key
+ " AND rad.res_discipline_key != " + S("vis_parking_key") // Parkeerplaatsen doen we niet moeilijk over
+ " ORDER BY 1";
var oRs = Oracle.Execute(sql);
var min_hours = 0;
while (!oRs.eof)
{
maxHours = oRs("res_disc_params_maxduur").Value;
// Controle op maximale tijdsduur reservering.
if ((maxHours > 0) && (maxHours < duration_hours))
{
if ((min_hours == 0) || (maxHours < min_hours))
{
min_hours = maxHours;
result.message = L("lcl_res_bad_maxperiod").format(maxHours);
result.maxhours = maxHours;
result.err = true;
}
}
oRs.MoveNext();
}
oRs.close();
}
return result;
}
}

View File

@@ -159,79 +159,16 @@ if (restype == "R")
oRs.Close();
// Mag deze activiteit in deze ruimte wel
sql = "SELECT rad.res_activiteit_key"
+ " , rdp.res_disc_params_maxduur"
+ " FROM res_activiteitdiscipline rad"
+ " , res_disc_params rdp"
+ " WHERE rad.res_discipline_key = rdp.res_ins_discipline_key"
+ " AND rad.res_discipline_key = " + disc_key
+ " AND rad.res_activiteit_key = " + act_key;
var oRs = Oracle.Execute(sql);
if (oRs.Eof)
{
abort_with_warning(L("lcl_res_bad_activity"));
}
else
{
maxHours = oRs("res_disc_params_maxduur").Value;
// Controle op maximale tijdsduur reservering.
if (maxHours > 0)
{
if (durationHours > maxHours)
abort_with_warning(L("lcl_res_bad_maxperiod").format(maxHours));
}
}
oRs.close();
var max_duration_err = res.max_duration(restype, act_key, disc_key, durationHours);
if (max_duration_err.err)
abort_with_warning(max_duration_err.message);
}
if (rsv_ruimte_key > 0)
{ // "CV" ook altijd controleren
sql = "SELECT ra.res_discipline_key"
+ " FROM res_rsv_artikel rsva"
+ " , res_artikel ra"
+ " WHERE rsva.res_artikel_key = ra.res_artikel_key"
+ " AND rsva.res_rsv_ruimte_key = " + rsv_ruimte_key
+ " UNION "
+ "SELECT rd.res_discipline_key"
+ " FROM res_rsv_deel rsvd"
+ " , res_deel rd"
+ " WHERE rsvd.res_deel_key = rd.res_deel_key"
+ " AND rsvd.res_rsv_ruimte_key = " + rsv_ruimte_key
+ " AND res_discipline_key != " + S("vis_parking_key") // Parkeerplaatsen doen we niet moeilijk over
+ " ORDER BY 1";
var oRs = Oracle.Execute(sql);
while (!oRs.eof)
{
var disc_key = oRs("res_discipline_key").Value;
var maxHours = 0;
// Mag deze activiteit voor deze catalogus (discipline) wel
sql2 = "SELECT rad.res_activiteit_key"
+ " , rdp.res_disc_params_maxduur"
+ " FROM res_activiteitdiscipline rad"
+ " , res_disc_params rdp"
+ " WHERE rad.res_discipline_key = rdp.res_ins_discipline_key"
+ " AND rad.res_discipline_key = " + disc_key
+ " AND rad.res_activiteit_key = " + act_key;
var oRs2 = Oracle.Execute(sql2);
if (oRs2.eof)
{
abort_with_warning(L("lcl_res_bad_activity_CV"));
}
else
{
maxHours = oRs2("res_disc_params_maxduur").Value;
// Controle op maximale tijdsduur reservering.
if (maxHours > 0)
{
if (durationHours > maxHours)
abort_with_warning(L("lcl_res_bad_maxperiod").format(maxHours));
}
}
oRs2.close();
oRs.MoveNext();
}
oRs.close();
var max_duration_err = res.max_duration_cv(rsv_ruimte_key, durationHours);
if (max_duration_err.err)
abort_with_warning(max_duration_err.message);
}
// Volgende voor zowel R als CV controleren

View File

@@ -63,27 +63,10 @@ if (this_res.canChange && this_res.canChangeFEOnly && res_van < res.discipline_e
}
// Controle op maximale tijdsduur reservering.
sql2 = "SELECT rdp.res_disc_params_maxduur"
+ " FROM res_activiteitdiscipline rad"
+ " , res_disc_params rdp"
+ " WHERE rad.res_discipline_key = rdp.res_ins_discipline_key"
+ " AND rad.res_discipline_key = " + disc_key
+ " AND rad.res_activiteit_key = " + act_key;
var oRs2 = Oracle.Execute(sql2);
if (!oRs2.eof)
{
var durationHours = (res_tot - res_van) / 1000/60/60;
var maxHours = oRs2("res_disc_params_maxduur").Value;
if (maxHours > 0)
{
if (durationHours > maxHours)
{
this_res.canChange = false;
this_res.readoReason = L("lcl_res_bad_maxperiod").format(maxHours);
}
}
}
oRs2.close();
var durationHours = (res_tot - res_van) / 1000/60/60;
var max_duration_err = res.max_duration_cv(rsv_ruimte_key, durationHours);
if (max_duration_err.err)
abort_with_warning(max_duration_err.message);
if (!this_res.canChange)
{ %>

View File

@@ -31,7 +31,9 @@ var dwidth = getFParamInt("dwidth")*S("res_h");
sql = "SELECT res_rsv_ruimte_van,"
+ " res_rsv_ruimte_tot,"
+ " res_rsv_ruimte_volgnr,"
+ " res_reservering_key"
+ " res_reservering_key,"
+ " res_activiteit_key,"
+ " res_ruimte_opstel_key"
+ " FROM res_rsv_ruimte"
+ " WHERE res_rsv_ruimte_key = " + rsv_ruimte_key;
var oRs = Oracle.Execute(sql);
@@ -40,7 +42,11 @@ var old_tot = new Date(oRs("res_rsv_ruimte_tot").Value);
var new_van = (new Date(old_van)).setFloatHours(old_van.getFloatHours() + dvan, S("res_h"));
var new_tot = (new Date(old_tot)).setFloatHours(old_tot.getFloatHours() + dvan + dwidth, S("res_h"));
var restxt = oRs("res_reservering_key").Value + "/" + oRs("res_rsv_ruimte_volgnr").Value;
var act_key = oRs("res_activiteit_key").Value;
var opstel_key = oRs("res_ruimte_opstel_key").Value;
oRs.Close();
var durationHours = (new_tot - new_van) / 1000/60/60;
var badmsg = null;
var this_res = res.func_enabled(rsv_ruimte_key); // Wat heb ik zoal aan rechten op deze specifieke reservering
if (!this_res.canChange)
@@ -50,6 +56,31 @@ else if (this_res.canChangeFEOnly)
if (new_van < this_res.earliest_expire_change)
badmsg = L("lcl_res_lastmin"); // te laat
}
if (!badmsg)
{
// Mag deze activiteit voor deze catalogus (discipline) wel
var sql = "SELECT rr.res_discipline_key"
+ " FROM res_ruimte_opstelling rro"
+ " , res_ruimte rr"
+ " WHERE rro.res_ruimte_key = rr.res_ruimte_key"
+ " AND rro.res_ruimte_opstel_key = " + opstel_key;
var oRs = Oracle.Execute(sql);
var disc_key = oRs("res_discipline_key").Value;
oRs.Close();
var max_duration_err = res.max_duration("R", act_key, disc_key, durationHours);
if (max_duration_err.err)
badmsg = max_duration_err.message;
}
if (!badmsg)
{
// "CV" ook altijd controleren
var max_duration_err = res.max_duration_cv(rsv_ruimte_key, durationHours);
if (max_duration_err.err)
badmsg = max_duration_err.message;
}
if (badmsg)
{
result = { message: badmsg }; // Ongeldige aanroep

View File

@@ -47,6 +47,7 @@ sql = "SELECT rrr.res_rsv_ruimte_van"
+ " , " + lcl.xsqla('rr.res_ruimte_nr', 'rr.res_ruimte_key')
+ " , rrr.res_activiteit_key"
+ " , rdp.res_disc_params_preposttime"
+ " , rdp.res_disc_params_maxduur"
+ " FROM res_rsv_ruimte rrr"
+ " , res_ruimte_opstelling rro"
+ " , res_ruimte rr"
@@ -63,6 +64,7 @@ var old_ruimte_key = oRs("res_ruimte_key").value;
var old_ruimte_oms = oRs("res_ruimte_nr").value;
var act_key = oRs("res_activiteit_key").value;
var prepost_time = oRs("res_disc_params_preposttime").value;
var max_hours = oRs("res_disc_params_maxduur").value;
// LET OP: De begintijd van het verschoven blokje is met of zonder schoonmaaktijd. En schoonmaaktijd wordt in het planbord niet goed bepaald en is altijd 1 blokje
if (prepost_time > 0)
{
@@ -138,6 +140,23 @@ else if (hours_new_van < S("res_t1") || hours_new_tot > S("res_t2"))
else if (!bTimeChanged && old_ruimte_key == new_ruimte_key)
badmsg = L("lcl_res_no_changes"); // "Geen aanpassingen";
var duration_hours = (new_tot - new_van) / 1000/60/60;
if (!badmsg)
{
// Controle op maximale tijdsduur reservering.
if ((max_hours > 0) && (max_hours < duration_hours))
{
badmsg = L("lcl_res_bad_maxperiod").format(max_hours);
}
}
if (!badmsg)
{
// "CV" ook altijd controleren
var max_duration_err = res.max_duration_cv(rsv_ruimte_key, duration_hours);
if (max_duration_err.err)
badmsg = max_duration_err.message;
}
//user.auth_required_or_abort(this_res.canChange && can_reserve_newroom); // Je krijgt al de melding lcl_res_no_auth_change via badmsg en je mag de gegevens gewoon zien (leesrechten heb je al). Met deze regel hier krijg je een lelijke niet leesbare foutmelding in modal scherm.
%>