$(document).ready(function () {
	$("table").tablesorter({
		theme: 'blue',
		widgets: ['zebra', 'staticRow'],
		widgetOptions: {
			zebra: ["normal-row", "alt-row"]
		}
	});
});

function showHide(id) {
	$('[name=child_' + id + ']').toggle(0);
	if ($('#span_' + id).html() == '[+]') {
		$('#span_' + id).html('[-]');
	} else {
		$('#span_' + id).html('[+]');
	}
}

function pdfExport() {
	var url =  $(location).attr('href');
	url = url + "&toPDF=1&to_pdf=1";
	window.location.href = url;
	console.log('work');
}

function excelExport() {
	var url = $(location).attr('href').replace("ReportEcmWorkCardsEcmProduct", "ReportEcmWorkCardsToExcelFile");
	url = url + "&to_pdf=1";

	var fileUrl = url.slice(0, url.indexOf("index")) + "modules/EcmReports/ExcelFiles/ReportEcmWorkCards.xls";

	$.blockUI({css: {
			border: 'none',
			padding: '15px',
			backgroundColor: '#000',
			'-webkit-border-radius': '10px',
			'-moz-border-radius': '10px',
			opacity: .5,
			'font-weight': 'bold',
			'font-size': '16px',
			color: '#fff',
		},
		message: "Trwa generowanie pliku..."
	});

	$.ajax({
		url: url,
		data: {
			date_from: $('#date_from').val(),
			date_to: $('#date_to').val(),
		},
		success: function (data) {
			$.unblockUI();
			window.location.href = fileUrl
		},
		error: function () {
			$.unblockUI();
			alert('Eksport zakończony niepowodzeniem!');
		}
	});
}