/*
     $Revision$
     $Id$

     File:        prs_obligations.js
*/

function prs_edit(row)
{
  var prsData = eval('(' + row.getAttribute("ROWDATA") + ')');
  var item_key = row.getAttribute("ROWKEY");
  switch (prsData.xmlnode)
  {
    case "melding":
        FcltMgr.openDetail("appl/mld/mld_melding.asp?mld_key=" + item_key + "&urole=bo", L("lcl_shared_complain") + " " + prsData.item);
        break;
    case "opdracht":
        FcltMgr.openDetail("appl/mld/mld_opdr.asp?opdr_key=" + item_key + "&urole=bo", L("lcl_shared_order") + " " + prsData.item);
        break;
    case "deel":
        FcltMgr.openDetail("appl/INS/ins_deel.asp?ins_key=" + item_key + "&urole=bo", L("lcl_shared_object") + " " + prsData.item);
        break;
    case "reservering":
        FcltMgr.openDetail("appl/RES/res_reservering.asp?rsv_ruimte_key=" + item_key + "&urole=bo", L("lcl_shared_reservation") + " " + prsData.item);
        break;
    case "bestelling":
        FcltMgr.openDetail("appl/bes/bes_bestelling.asp?bes_key=" + item_key + "&urole=bo", L("lcl_shared_bestelling") + " " + item_key);
        break;
    case "afspraak":
        FcltMgr.openDetail("appl/BEZ/bez_afspraak.asp?afspr_key=" + item_key + "&urole=bo", L("lcl_shared_appointment") + " " + item_key);
        break;
    case "contract":
        FcltMgr.openDetail("appl/CNT/cnt_contract.asp?cnt_key=" + item_key + "&urole=bo", L("lcl_shared_contract") + " " + prsData.item);
        break;
    case null: // kostenplaats
        if (prsData.messagecode == "PRS_BUDGETHOUDER_VAN")
            FcltMgr.openDetail("appl/prs/kpn_kpn.asp?key=" + item_key + "&urole=bo", L("lcl_shared_account") + " " + prsData.item);
        else if (prsData.messagecode == "PRS_BUDGETHOUDER_GROEP")
            FcltMgr.openDetail("appl/prs/kpn_kpngroep.asp?key=" + item_key + "&urole=bo", L("lcl_shared_account") + " " + prsData.item);
        break;
  }
}

function prs_transfer(rowArray, isMulti)
{
  var item_keys = getKeyString(rowArray);

  var messagecode;
  var messagecodeString = "";
  for (var i = 0; i < rowArray.length; i++)
  {
    var prsData = eval("(" + rowArray[i].getAttribute("ROWDATA") + ")");
    if (prsData)
    {
      messagecode = prsData.messagecode;
      messagecodeString += ((messagecodeString == "") ? "" : ",") + messagecode;
    }
  }
  $("#item_keys").val(item_keys); // Item keys veilig stellen
  $("#messagecodes").val(messagecodeString); // Fac message codes veilig stellen

  url = "../prs/prs_transfer.asp";
  FcltMgr.openModalDetail(url, L("lcl_prs_transfer_opvolger"), {callback: transferCallback});
}

function transferCallback(data)
{
  var data = { prs_key: data.prs_key    // Opvolger
             , prs_key_current: prs_key // Huidige persoon
             , item_keys: $("#item_keys").val()
             , messagecodes: $("#messagecodes").val()
             };
  protectRequest.dataToken(data);
  $.post("prs_transfer_save.asp",
         data,
         FcltCallbackRefresh,
         "json");
}
