/*
     $Revision$
     $Id$
*/

function opdrEdit(row)
{
  var opdr_key = row.getAttribute("ROWKEY");
  url = "appl/bes/bes_opdr.asp?ordernr=" + opdr_key + "&urole=" + urole;
  FcltMgr.openDetail(url, { reuse: true });
}

function opdrReject(rowArray, isMulti)
{
  function opdrRejectCallback(json, modalParams)
  {
    FcltCallbackRefresh(json, modalParams);
  }

  var opdrKeyString = getKeyString(rowArray);
  url = "../BES/opdr_reject.asp?opdr_key=" + opdrKeyString + "&urole=" + urole;
  FcltMgr.openModalDetail(url, L("lcl_bes_order_reject"), {callback: opdrRejectCallback});
}

function opdrAccept(rowArray, isMulti)
{
  var opdrData = eval('(' + rowArray[0].getAttribute("ROWDATA") + ')');
  if (isMulti || opdrData)
  {
    FcltMgr.confirm(L("lcl_bes_confirm_accept").format(opdrData.opdrId), { autoconfirm: isMulti }, function() {
        var opdrKeyString = getKeyString(rowArray);
        var data = { urole: urole
                   , opdr_key: opdrKeyString
                   };
        protectRequest.dataToken(data);
        $.post("opdr_accept.asp", data, FcltCallbackRefresh, "json");
    });
  }
}

function opdrSent(rowArray, isMulti)
{
  var opdrData = eval('(' + rowArray[0].getAttribute("ROWDATA") + ')');
  if (isMulti || opdrData)
  {
    FcltMgr.confirm(L("lcl_bes_confirm_sent").format(opdrData.opdrId), { autoconfirm: isMulti }, function() {
        var opdrKeyString = getKeyString(rowArray);
        var opdrId = opdrData.opdrId;
        var data = { urole: urole
                   , opdr_key: opdrKeyString
                   };
        protectRequest.dataToken(data);
        $.post("opdr_sent.asp", data, FcltCallbackRefresh, "json");
    });
  }
}

function opdrDeliver(row)
{
  var opdr_key = row.getAttribute("ROWKEY");
  var opdrData = eval('(' + row.getAttribute("ROWDATA") + ')');
  if (opdrData)
  {
    var opdrId = opdrData.opdrId;

    $(row).addClass('dirty');
    url = "opdr_delivery.asp?opdr_key=" + opdr_key + "&urole=" + urole;
    FcltMgr.openModalDetail(url, L("lcl_bes_delivery"), {xwidth: 800});
  }
}
