// kid, kname, kdesc, kdate,kvalue,klbound,kobj
var excelReportingValueRow = new Entity(excelReportingValueRow,true, [ 
    [zipAlt1], [zipCount1], 0,0,[zipCount2],1,2,3,4,6,5]);
var excelReportingValue = new Entity(excelReportingValue,false, ["title.draw(['excel reporting value']);","(getSize())[1]/2;",[excelReportingValueRow]]);
excelReportingValue.refresh = function() {
	$.ajax({
		data: {q:"getSchValueList", d: $("#staffing").val()}, 
		success:function(data,textStatus) {
			if ( ! data ) return;		
			try {
				zipCount1.reset();
				zipCount2.reset();
				excelReportingValueRow.set(data);
				updateFormNumCB = data.length;
				$('#rightside').html(excelReportingValue.draw());
				var scr = 	["None", "Number", "CaseInsensitiveString"]; 
				var st1 = new SortableTable($("#excelReportingList").get(0), scr);
			} catch (e) {
				myCatch(e);
			} 
		}
	});
}

excelReportingValueRow.go = function() {
	var action = $("#action").val(); 
	var ids="";
	var selected=-1;
	try { 
		for (var i=0; i < this.numRows; i++){
			if ($("#checkBox_"+i).attr('checked')){
				if ( ids.length > 0 ) ids +=",";
				ids += $("#checkBox_"+i).val();
				if (selected == -1) selected  = i;
				if ( action == 'gantt' || action == 'ganttv') break;
			}
		}
    
		if ( ids.length == 0 ) {
			throw "You must select something!";
		}
    
		if  (action == 'delete') {
			if ( ! confirm("Do you really want to delete these items?")) {
				return;
			}
			$.ajax({
				data: {q:'deleteSchedule', d: ids},
				success: function(data, textStatus) {
					if ( ! data ) return;
					try {
						rightsideDraw();
					} catch (e) {
						myCatch(e);
					}					
				}
			});
		} else if (action == 'gantt' || action == 'schedule'){ // export
			var fileName =  $("#newName").val();
			var startDate = $('#startDate').val();
			if ( ! fileName ){ 
				fileName = action+'_'+ ids;				
			}
			if ( action == 'gantt' ) {
				if ( ! startDate){
					throw "Please specify the start date";
				}
				var d = Date.parse(startDate);
				if ( isNaN(d)) {
					throw 'Invalide date';					
				} 
			}
			$('#reporttype').val(action);
			$('#filename').val(fileName);
			$('#scheduleIds').val(ids);        
			document.post_form.submit();
		} else { // ganttv
			$('#scheduleIds').val(ids);
			gantt.refresh();
		}
	} catch(e) {
		myCatch(e);
	}
}	


