require(['config'], function() {
	require([
		'jquery'
	], function($) {

	});
});

function itp_fn_COMMONPOP_FILE(parentPopFn, args, returnType) {
	let fileNumber = $('#ITP_COMMONPOP_FILE_UPLOAD').attr('data-file-no');
	$('#ITP_COMMONPOP_FILE').one('shown.bs.modal', function(e) {
		const fileArgs = {
			'viewCd': $('#ITP_COMMONPOP_FILE_UPLOAD').attr('data-view-cd'),
			'showYn': $('#ITP_COMMONPOP_FILE_UPLOAD').attr('data-show-yn'),
			'fileNo': fileNumber
		};
		
		let folder = args.folder;
		itp_fn_set_file_upload('ITP_COMMONPOP_FILE_UPLOAD', folder, true, false, 'ITP_COMMONPOP_FILE', fileArgs);
	}).one('hidden.bs.modal', function(e) {
		$('#ITP_COMMONPOP_FILE').remove();
	}).modal('show');

	$('#ITP_COMMONPOP_FILE_BTN_SELECT').on('click', function() {
		var trRow = $('#ITP_COMMONPOP_FILE_UPLOAD').find('table.fileupload-preview tbody.files tr.row');
		var fileCount = trRow.length;
		var trRowDown = $('#ITP_COMMONPOP_FILE_UPLOAD').find('table.fileupload-download tbody tr.row');
		var fileCntDown = trRowDown.length;

		if (fileCount < 1 && fileCntDown < 1) {
			fileNumber = null;
		}

		const fileTot = fileCount + fileCntDown;
		const selectedRowData = {'fileNo': fileNumber, 'fileCnt': fileTot};
		parentPopFn(selectedRowData);
		$('#ITP_COMMONPOP_FILE').modal('hide');
	});
};