function buildPartiesResults()

in webpos/webapp/webpos/images/js/SearchPartiesResults.js [68:151]


function buildPartiesResults(parties, fromPartySearch) {
    var alt_row = false;
    var idx = 1;
    var tableList = "";
    jQuery.each(parties, function(i, party) {
        if (alt_row) {
            classType = "class=\"pos-cart-even\"";
        } else {
            classType = "class=\"pos-cart-odd\"";
        }
        lastName = checkNull(party.lastName);
        firstName = checkNull(party.firstName);
        partyIdentificationNumber = checkNull(party.idValue);
        address1 = checkNull(party.address1);
        city = checkNull(party.city);
        postalCode = checkNull(party.postalCode);
        stateProvinceGeoId = checkNull(party.stateProvinceGeoId);
        countryGeoId = checkNull(party.countryGeoId);
        contactMechPurposeTypeId = checkNull(party.contactMechPurposeTypeId);
        billingShipping = "B";
        if (contactMechPurposeTypeId == 'SHIPPING_LOCATION') {
            billingShipping = "S";
        }
        editAddr = "editAddress" + i;
        selectedPartyId = "selectedPartyId" + i;
        selectedContactMechId = "selectedContactMechId" + i;
        selectedContactMechPurposeTypeId = "selectedContactMechPurposeTypeId" + i;
        tableList = tableList + "<tr " + classType + ">";
        tableList = tableList + "<td><input type=\"hidden\" id=\"" + selectedPartyId + "\" name=\"" + selectedPartyId + "\" value=\"" + party.partyId + "\"/>";
        tableList = tableList + "<input type=\"hidden\" id=\"" + selectedContactMechId + "\" name=\"" + selectedContactMechId + "\" value=\"" + party.contactMechId + "\"/>";
        tableList = tableList + "<input type=\"hidden\" id=\"" + selectedContactMechPurposeTypeId + "\" name=\"" + selectedContactMechPurposeTypeId + "\" value=\"" + party.contactMechPurposeTypeId + "\"/>";
        tableList = tableList + "<input type=\"checkbox\" class=\"editAddress\" id=\"" + editAddr + "\"/></td>";
        tableList = tableList + "<td><a href=\"javascript:setParty(\'" + party.partyId + "\', \'" + party.contactMechId + "\', \'" + party.contactMechPurposeTypeId +"\');\">" + party.partyId + "</a></td>";
        tableList = tableList + "<td><a href=\"javascript:setParty(\'" + party.partyId + "\', \'" + party.contactMechId + "\', \'" + party.contactMechPurposeTypeId +"\');\">" + lastName + "</a></td>";
        tableList = tableList + "<td><a href=\"javascript:setParty(\'" + party.partyId + "\', \'" + party.contactMechId + "\', \'" + party.contactMechPurposeTypeId +"\');\">" + firstName + "</a></td>";
        tableList = tableList + "<td>" + partyIdentificationNumber + "</td>";
        tableList = tableList + "<td>" + address1 + "</td>";
        tableList = tableList + "<td>" + city + "</td>";
        tableList = tableList + "<td>" + postalCode + "</td>";
        tableList = tableList + "<td>" + stateProvinceGeoId + "</td>";
        tableList = tableList + "<td>" + countryGeoId + "</td>";
        tableList = tableList + "<td>" + billingShipping + "</td>";
        tableList = tableList + "</tr>";
        alt_row = !alt_row;
        idx++;
    });
    jQuery('#searchPartiesResultsList').html(tableList);
    editAddressClick();
    jQuery('#searchPartiesResults').show();
    if (fromPartySearch == 'Y') {
        if (jQuery('#searchPartyBy').val() == 'lastName') {
            jQuery('#searchByPartyLastName').val(jQuery('#partyToSearch').val());
            jQuery('#searchByPartyFirstName').val("");
            jQuery('#searchByPartyIdValue').val("");
            jQuery('#searchByPartyLastName').focus();
        } else if (jQuery('#searchPartyBy').val() == 'firstName') {
            jQuery('#searchByPartyLastName').val("");
            jQuery('#searchByPartyFirstName').val(jQuery('#partyToSearch').val());
            jQuery('#searchByPartyIdValue').val("");
            jQuery('#searchByPartyFirstName').focus();
        } else if (jQuery('#searchPartyBy').val() == 'idValue') {
            jQuery('#searchByPartyLastName').val("");
            jQuery('#searchByPartyFirstName').val("");
            jQuery('#searchByPartyIdValue').val(jQuery('#partyToSearch').val());
            jQuery('#searchByPartyIdValue').focus();
        }
        
        if (jQuery('#billingLocation').val() == 'Y') {
            jQuery('#billingLoc').val('Y');
            jQuery('#billingLoc').attr('checked', true);
        } else {
            jQuery('#billingLoc').val('N');
            jQuery('#billingLoc').attr('checked', false);
        }
        
        if (jQuery('#shippingLocation').val() == 'Y') {
            jQuery('#shippingLoc').val('Y');
            jQuery('#shippingLoc').attr('checked', true);
        } else {
            jQuery('#shippingLoc').val('N');
            jQuery('#shippingLoc').attr('checked', false);
        }
    }
}