/*
     $Revision$
     $Id$

     File:        fin_show_factuur.js
*/
function fin_change(fin_status)
{
  if (fin_status == 6 && !confirm(L("lcl_fin_approve_again")))
    return;
  if (FcltMgr.startEdit(window))
    window.location.href = "fin_edit_factuur.asp?fin_key=" + fin_key + "&embedded=1";
}

function fin_print()
{
  window.open('./fin_xml.asp?fin_key=' + fin_key);
}

function finMailCallback(data)
{
  alert(L("lcl_fin_inv_mailed") + data.emails);
}

function fin_approve()
{
  if (confirm(L("lcl_fin_approve_factuur").format(fin_key)))
  {
    // Goedkeuren scherm
    var data = { fin_key: fin_key };
    protectRequest.dataToken(data);
    $.post("fin_approve.asp?a=1",
           data,
           FcltCallbackRefresh,
           "json");
  }
}

function fin_goedkeuren()
{
  if (confirm(L("lcl_fin_goedkeuren_factuur").format(fin_key)))
  {
    // Goedkeuren scherm
    var data = { fin_key: fin_key };
    protectRequest.dataToken(data);
    $.post("fin_goedkeur.asp?a=1",
           data,
           FcltCallbackRefresh,
           "json");
  }
}

function fin_unapprove()
{
  if (confirm(L("lcl_fin_unapprove_factuur").format(fin_key)))
  {
    // Goedkeuren scherm
    var data = { fin_key: fin_key };
    protectRequest.dataToken(data);
    $.post("fin_unapprove.asp",
           data,
           FcltCallbackRefresh,
           "json");
  }
}

function fin_reject()
{
  if (confirm(L("lcl_fin_reject_factuur").format(fin_key)))
  {
    // Goedkeuren scherm
    var data = { fin_key: fin_key };
    protectRequest.dataToken(data);
    $.post("fin_approve.asp?r=1",
           data,
           FcltCallbackRefresh,
           "json");
  }
}

function fin_unreject()
{
  if (confirm(L("lcl_fin_unreject_factuur").format(fin_key)))
  {
    // Goedkeuren scherm
    var data = { fin_key: fin_key };
    protectRequest.dataToken(data);
    $.post("fin_unreject.asp",
           data,
           FcltCallbackRefresh,
           "json");
  }
}

function fin_delete()
{
    if (confirm(L("lcl_fin_delete_factuur").format(fin_key)))
    {
        var data = { fin_key: fin_key };
        protectRequest.dataToken(data);
        $.post("fin_delete.asp",
               data,
               FcltCallbackClose,
               "json");
    }
}

function fin_copy()
{
  url = "appl/FIN/fin_factuur.asp?fin_key=" + fin_key + "&fin_copy=1";
  FcltMgr.openDetail(url, L("lcl_fin_copy") + ' ' + L("lcl_fin_invoice"));
}
