/***********************************************************************************
 *
 * Function collection for  "vertriebspartner/auswertung_offene_transaktionen.php"
 *
 **********************************************************************************/


/**
 * Marked all transaction checkboxes by using the selected value of the dropdownbox
 *
 * @param objDD DropDownBoxof of the Limit list
  */
function maskTrans(objDD){

    var fLimit          = parseFloat(objDD.value);
    var arObjCheckBoxes = document.getElementsByName("okids");
    var arTransIds      = new Array();

    // no checkboxes, hmm....
    if ((arObjCheckBoxes == undefined) || (fLimit == "") ) {
        return;
    }

    // loop over all checkboxes
    for( var i=0;i<arObjCheckBoxes.length;i++) {
        if ( (arObjCheckBoxes[i].attributes.rawbetrag != null) &&
             (parseFloat(arObjCheckBoxes[i].attributes.rawbetrag.value) > (fLimit*-1)) &&
             (parseFloat(arObjCheckBoxes[i].attributes.rawbetrag.value) <  fLimit) )      {
            // select checkbox now
            arObjCheckBoxes[i].checked = true;
        }else{
            // deselect item
            arObjCheckBoxes[i].checked = false;
        }
    }

    return;
}

/**
 * Toogle all transaction checkboxes
 *
 * @param obj MainToogle checkbox self for check state
 * @return false
 */
function toogleTransCheckBoxes(obj){

    var arObjCheckBoxes = document.getElementsByName("okids");
    var arTransIds      = new Array();

    // no checkboxes, hmm....
    if (arObjCheckBoxes == undefined ) {
        return false;
    }

    // loop over all checkboxes
    for( var i=0;i<arObjCheckBoxes.length;i++) {
        arObjCheckBoxes[i].checked = obj.checked;
    }

    return false;
}

/**
 * Set the checked transaction to "gesehen" via http submit
 *
 * @return false
 */
function closeUpMarkedTrans() {

    var arObjCheckBoxes = document.getElementsByName("okids");
    var arTransIds      = new Array();

    // no checkboxes, hmm....
    if (arObjCheckBoxes == undefined ) {
        return false;
    }

    // loop over all checkboxes
    for( var i=0;i<arObjCheckBoxes.length;i++) {
        // if checked add transaction id to the array
        if ( arObjCheckBoxes[i].checked )
            arTransIds.push(arObjCheckBoxes[i].value);
    }

    // any transaction checked
    if (arTransIds.length == 0) {
        //...no
        alert("Bitte wählen Sie mindestens eine Transaktion aus.")
        return false;
    }


    // send request now to the server
    var objForm =  document.createElement('form');
    objForm.setAttribute("method","POST");
    // set ids and the right action
    objForm.innerHTML = "<input type='hidden' name='okids' value='"+arTransIds+"' />"+
                        "<input type='hidden' name='act' value='allmarked' />";

    
    document.body.appendChild(objForm);
    objForm.submit();//.remove();


    return false;

}
/***********************************************************************************
 *
 * Function collection for  "vertriebspartner/auswertung_offene_bestaetigungen.php"
 *
 **********************************************************************************/

/**
 * Toogle all transaction checkboxes
 *
 * @param obj MainToogle checkbox self for check state
 * @return false
 */
function toogleConfirmationCheckBoxes(obj){

    var arObjCheckBoxes = document.getElementsByName("okids");
    var arTransIds      = new Array();

    // no checkboxes, hmm....
    if (arObjCheckBoxes == undefined ) {
        return false;
    }

    // loop over all checkboxes
    for( var i=0;i<arObjCheckBoxes.length;i++) {
        arObjCheckBoxes[i].checked = obj.checked;
    }

    return false;
}

/**
 * Set the checked confirmation to "gesehen" via http submit
 *
 * @return false
 */
function closeUpMarkedConfirmation() {

    var arObjCheckBoxes = document.getElementsByName("okids");
    var arConfIds       = new Array();

    // no checkboxes, hmm....
    if (arObjCheckBoxes == undefined ) {
        return false;
    }

    // loop over all checkboxes
    for( var i=0;i<arObjCheckBoxes.length;i++) {
        // if checked add confirmation id to the array
        if ( arObjCheckBoxes[i].checked )
            arConfIds.push(arObjCheckBoxes[i].value);
    }

    // any transaction checked
    if (arConfIds.length == 0) {
        //...no
        alert("Bitte wählen Sie mindestens eine nicht gesehene Bestätigung aus.")
        return false;
    }


    // send request now to the server
    var objForm =  document.createElement('form');
    objForm.setAttribute("method","POST");
    // set ids and the right action
    objForm.innerHTML = "<input type='hidden' name='okids' value='"+arConfIds+"' />"+
                        "<input type='hidden' name='act' value='allmarked' />";


    document.body.appendChild(objForm);
    objForm.submit();//.remove();


    return false;

}