/*
     $Revision$
     $Id$

     File:          fin_list.js
*/

function finEdit(row)
{
  $(row).addClass('dirty');
  var fin_key = row.getAttribute("ROWKEY");
  var url = "appl/fin/fin_factuur.asp?fin_key=" + fin_key
          + "&mode=viewUpdate";
  FcltMgr.openDetail(url, { reuse: true });
}

function finOrder(row)
{
  var finData = eval('(' + row.getAttribute("ROWDATA") + ')');
  if (finData)
  {
    if (finData.mld_opdr_key)
    {
      url = "appl/mld/mld_opdr.asp?opdr_key=" + finData.mld_opdr_key + "&readonly=1" + "&close_window=1&urole=bo&embedded=1";
    }
    else if (finData.cnt_contract_key)
    {
      url = "appl/cnt/cnt_contract.asp?cnt_key=" + finData.cnt_contract_key + "&mode=ReadOnly" + "&close_window=1&urole=bo&embedded=1";
    }
    else if (finData.bes_bestelopdr_key)
    {
      url = "appl/bes/bes_opdr.asp?ordernr=" + finData.bes_bestelopdr_key + "&reado=1" + "&close_window=1&urole=bo&embedded=1";
    }
    FcltMgr.openDetail(url, { reuse: true });
  }
}

function finApprove(rowArray, isMulti)
{
  FcltMgr.confirm(L("lcl_fin_approve_select"), { autoconfirm: isMulti }, function() {
      var finKeyString = getKeyString(rowArray);
      var data = {
          fin_key: finKeyString
      };
      protectRequest.dataToken(data);
      $.post("fin_approve.asp?a=1",
          data,
          FcltCallbackRefresh,
          "json");
  });
}

function finGoedkeur(rowArray, isMulti)
{
  FcltMgr.confirm(L("lcl_fin_goedkeur_select"), { autoconfirm: isMulti }, function() {
      var finKeyString = getKeyString(rowArray);
      var data = {
          fin_key: finKeyString
      };
      protectRequest.dataToken(data);
      $.post("fin_goedkeur.asp?a=1",
          data,
          FcltCallbackRefresh,
          "json");
  });
}

function finUnapprove(rowArray, isMulti)
{
  FcltMgr.confirm(L("lcl_fin_unapprove_select"), { autoconfirm: isMulti }, function() {
      var finKeyString = getKeyString(rowArray);
      var data = {
          fin_key: finKeyString
      };
      protectRequest.dataToken(data);
      $.post("fin_unapprove.asp",
          data,
          FcltCallbackRefresh,
          "json");
  });
}

function finRejectApprove(rowArray, isMulti)
{
  FcltMgr.confirm(L("lcl_fin_reject_select"), { autoconfirm: isMulti }, function() {
      var finKeyString = getKeyString(rowArray);
      var data = {
          fin_key: finKeyString
      };
      protectRequest.dataToken(data);
      $.post("fin_approve.asp?r=1",
          data,
          FcltCallbackRefresh,
          "json");
  });
}

function finRejectGoedkeur(rowArray, isMulti)
{
  FcltMgr.confirm(L("lcl_fin_reject_select"), { autoconfirm: isMulti }, function() {
      var finKeyString = getKeyString(rowArray);
      var data = {
          fin_key: finKeyString
      };
      protectRequest.dataToken(data);
      $.post("fin_goedkeur.asp?r=1",
          data,
          FcltCallbackRefresh,
          "json");
  });
}

function finUnreject(rowArray, isMulti)
{
  FcltMgr.confirm(L("lcl_fin_unreject_select"), { autoconfirm: isMulti }, function() {
      var finKeyString = getKeyString(rowArray);
      var data = {
          fin_key: finKeyString
      };
      protectRequest.dataToken(data);
      $.post("fin_unreject.asp",
          data,
          FcltCallbackRefresh,
          "json");
  });
}

function finDelete(rowArray, isMulti)
{
  FcltMgr.confirm(L("lcl_shared_row_delete_confirm"), { autoconfirm: isMulti }, function() {
      var finKeyString = getKeyString(rowArray);
      var data = {
          fin_key: finKeyString
      };
      protectRequest.dataToken(data);
      $.post("fin_delete.asp",
          data,
          FcltCallbackRefresh,
          "json");
  });
}
