var corporategiftsummary_obj 	= null ;

var C_FILTER_GIFT_SUMMARY_LIST = "711";

function filterCorporateGiftSummary() {
	LoadingScreen("show");
	var data = { 
				"type"				: C_FILTER_GIFT_SUMMARY_LIST,
				"delivery_from"		: $('#txtCorporateGiftSummaryDeliveryDateFrom').val(),
				"delivery_to"		: $('#txtCorporateGiftSummaryDeliveryDateTo').val(),
				"gift"				: $('#cobCorporateGiftSummaryGift').val(),
				"gift_type"			: $('#cobCorporateGiftSummaryGiftType').val(),
			};

	var url  = "request.pzx?c=" + corporate_gift_summary_url + "&d=" + new Date().getTime() ;
	callServer(url,"json",data,onCorporateGiftSummaryResponse,null) ;
	return false;
}

//=====================================
            
function onCorporateGiftSummaryResponse(obj,resp) {
	LoadingScreen("hide");

    if (resp.status != C_OK) {
		swal.fire("Warning", resp.mesg, "warning")
        return false;
    }

    if(resp.type == C_FILTER_GIFT_SUMMARY_LIST) {
       	$('#corporategiftsummary-table').html('');
	   	$('#corporategiftsummary-table').html(resp.data);
	   	filterRow('corporategiftsummary-row-filter',this,false);
    } 

	if(resp.type == "C_GET_GIFT_ITEM"){
        $('#cobCorporateGiftSummaryGiftType').html(resp.data);
        $('#cobCorporateGiftSummaryGiftType').select2({
            width: '100%'
        });
    }
}

function changeGiftItem(){
    data = {
        "type"  : "C_GET_GIFT_ITEM",
        "id"    : $('#cobCorporateGiftSummaryGift').val()
    }
    var url = "index.pzx?c=" + corporate_gift_summary_url + "&d=" + new Date().getTime();
    callServer(url, "json", data, onCorporateGiftSummaryResponse, null);
    return false;
}

