require(['config'], function() {
	require([
	], function($) {
		pageObj.init();
	});
});


/*화면 변수*/
const ORDMNG02010_GRID_ID = '#ITP_ORDMNG02010_jqGrid';
const ORDMNG02010_GRID_LIST = '#ITP_ORDMNG02010_jqGrid_list';
const ORDMNG02010_GRID_PAGER = '#ITP_ORDMNG02010_jqGridPager';
const ORDMNG02010_GRID_EMPTY = '#ITP_ORDMNG02010_jqGridEmpty';

const ORDMNG02010_DETAIL_GRID_ID = '#ITP_ORDMNG02010_DETAIL_jqGrid';
const ORDMNG02010_DETAIL_GRID_LIST = '#ITP_ORDMNG02010_DETAIL_jqGrid_list';
const ORDMNG02010_DETAIL_GRID_PAGER = '#ITP_ORDMNG02010_DETAIL_jqGridPager';
const ORDMNG02010_DETAIL_GRID_EMPTY = '#ITP_ORDMNG02010_DETAIL_jqGridEmpty';

let ITP_FORM_OPER03010_DETAIL_IS_WRITING = false;
let ORDMNG02010_GRID_LAST_ROW_ID;

// editrules
let shmtQtyValue;		
let isExpryDate;

/*API URL*/
let API_POMNG_INOUTMNG_SPPLY_TARGET_GRID_LIST = '/api/pomng/inoutmng/spply-target-grid-list';	// 공급사 납품 대상리스트 그리 리스트
let API_POMNG_INOUTMNG_INIT_SPPLY_INV = '/api/pomng/inoutmng/init-spply-inv'; 					// 공급사 발주데이타 납품서 생성 초기데이타
let API_POMNG_INOUTMNG_SAVE_SPPLY_INV = '/api/pomng/inoutmng/save-spply-inv'					//공급사 납품서 생성 저장 저장


/*화면 Grid ColModel*/
const gridColModel = {
	list: [
		{
			index: 'VIEW_CD', name: 'viewCd',
			label: ITP_MSG_LOCALE.label.viewCd,
			width: '10', fixed: false, align: 'center',
			sortable: false, hidden: true
		},
		{
			index: 'BRAND_ID', name: 'brandId',
			label: ITP_MSG_LOCALE.label.brandId, 			//브랜드ID
			width: '10', fixed: false, align: 'center',
			sortable: false, hidden: true
		},
		{
			index: 'BRAND_NM', name: 'brandNm',
			label: ITP_MSG_LOCALE.label.brandNm, 			//브랜드명
			width: '6', fixed: false, align: 'left',
			sortable: false, hidden: false, classes: 'ui-ellipsis'
		},
		{
			index: 'PCH_PODR_UNQ_NO', name: 'pchPodrUnqNo',
			label: ITP_MSG_LOCALE.label.pchPodrUnqNo, 		//발주번호
			width: '8', fixed: false, align: 'center',
			sortable: false, hidden: false
		},
		{
			index: 'PCH_PODR_DTL_NO', name: 'pchPodrDtlNo',
			label: ITP_MSG_LOCALE.label.pchPodrDtlNo, 		//발주항번
			width: '4', fixed: false, align: 'center',
			sortable: false, hidden: false
		},
		{
			index: 'DLV_REQ_DT', name: 'dlvReqDt',
			label: ITP_MSG_LOCALE.label.dlvReqDt, 			//납품요청일
			width: '6', fixed: false, align: 'center',
			sortable: false, hidden: false
		},
		{
			index: 'WHS_NM', name: 'whsNm',
			label: ITP_MSG_LOCALE.label.whsNm, 				//납품장소
			width: '11', fixed: false, align: 'left',
			minwidht: 100,
			sortable: false, hidden: false, classes: 'ui-ellipsis'
		},
		{
			index: 'ITEM_ID', name: 'itemId',
			label: ITP_MSG_LOCALE.label.itemId, 			//품목번호
			width: '8', fixed: false, align: 'center',
			sortable: false, hidden: false
		},
		{
			index: 'ITEM_NM', name: 'itemNm',
			label: ITP_MSG_LOCALE.label.itemNm, 			//품목명
			width: '6', fixed: false, align: 'left',
			sortable: false, hidden: false, classes: 'ui-ellipsis'
		},
		{
			index: 'PODR_QTY', name: 'podrQty',
			label: ITP_MSG_LOCALE.label.podrQty, 			//발주수량
			width: '4', fixed: false, align: 'right',
			sortable: false, hidden: false
		},
		{
			index: 'UNIT_AMT', name: 'unitAmt',
			label: ITP_MSG_LOCALE.label.unitAmt, 			//단가
			width: '3', fixed: false, align: 'right',
			sortable: false, hidden: false,
			minwidth:80,
			formatter: 'integer', formatoptions: {thousandsSeparator: ','}
		},
		{
			index: 'PODR_AMT', name: 'podrAmt',
			label: ITP_MSG_LOCALE.label.podrAmt, 			//발주금액
			width: '4', fixed: false, align: 'right',
			minwidth:80,
			sortable: false, hidden: false,
			formatter: 'integer', formatoptions: {thousandsSeparator: ','}
		}
	],
	view: [],
	detail: []
};


/*화면공통 Object*/
let pageObj = {
	init: function() {
		this.ui.init();
		this.event.init();
	},
	ui: {
		init: function() {
			this.view();
			this.grid();
			this.form();
			this.ready();
		},
		view: function() {
			// 버튼 권한설정
			fn_proc_btn_auth('ORDMNG02010');
			// 공통코드 표시
			$('select').each(function() {
				if($(this).data('select-code')) {
					fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
				}
			});
			// 조회일자 지정	
			var now = new Date();
			var defaultToDate = new Date(now);
			defaultToDate.setDate(now.getDate() + 7);
			$('#ITP_TAB_ORDMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
			$('#ITP_FORM_ORDMNG02010_SEARCH_FROM_DT').datepicker('setDate', now);
			$('#ITP_FORM_ORDMNG02010_SEARCH_TO_DT').datepicker('setDate', defaultToDate);
		},
		form: function() {
			itp_fn_form_event.onKeyup('#ITP_FORM_ORDMNG02010_DETAIL');
		},
		grid: function() {
			itp_fn_jqgrid_resize(ORDMNG02010_GRID_ID, ORDMNG02010_GRID_LIST, 'lg');
			
		},
		ready: function() {
			listObj.init();
		}
	},
	event: {
		init: function() {
			this.button();
		},
		button: function() {
			// 버튼 클릭 이벤트
			$('button').each(function() {
				var id = $(this).attr('id');
				$(this).on('click', function() {
					switch (id) {
						case 'ITP_BTN_ORDMNG02010_SRH'				: listObj.button.search();		break;	// 조회 버튼 클릭
						case 'ITP_BTN_ORDMNG02010_NEWREG'			: listObj.button.create(); 		break;	// 신규등록 버튼
						case 'ITP_BTN_ORDMNG02010_CANCELLIST'		: modifyObj.button.cancel(); 	break;	// 취소/목록 버튼
						case 'ITP_BTN_ORDMNG02010_SAVE'				: modifyObj.button.save();		break;	// 생성버튼
						case 'ITP_BTN_ORDMNG02010_EXCEL'		    : listObj.excelDown();			break;	// 엑셀 다운로드
					}
				});
			});
			
			$('body').on('click', function(e) {
				var gridId = (ORDMNG02010_DETAIL_GRID_ID).replace('#', '');
				var rids = $(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getDataIDs');
				var last_row_id = rids[rids.length - 1];
				
				itp_fn_grid_reset_selection(e, last_row_id, gridId, 'ORDMNG02010_DETAIL');
				modifyObj.button.recal();
			})
		}
	},
	switchScreen: function(mode) {
		$('.itp_det_head').find('button[id^="ITP_BTN_ORDMNG02010_"]').each(function(i) {
			$(this).hide();
		});
		$('#ITP_TAB_ORDMNG02010').find('div[id$="_CONTAINER"]').each(function(i) {
			$(this).hide();
		});
		if(mode === 'LIST') { // 목록
			itp_fn_fire_window_resize();
			$('#ITP_AJAX_ORDMNG02010_LIST_CONTAINER').show();
			fn_show_btn_auth_array(['#ITP_BTN_ORDMNG02010_SRH', '#ITP_BTN_ORDMNG02010_NEWREG']);
			$('#ITP_FORM_ORDMNG02010_SEARCH #ITP_FORM_ORDMNG02010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
            $('#ITP_FORM_ORDMNG02010_SEARCH #ITP_FORM_ORDMNG02010_SEARCH_SPPLY_ID').val(fn_make_user_info.get('spplyId'));
            $('#ITP_BTN_ORDMNG02010_SEARCH_WHS_ID').show();
            $('#ITP_BTN_ORDMNG02010_DELETE_WHS_ID').show();
            $('#ITP_BTN_ORDMNG02010_EXCEL').show();
		} else if(mode === 'MODIFY') { // 수정
			$('#ITP_AJAX_ORDMNG02010_DETAIL_CONTAINER').show();
			fn_show_btn_auth_array(['#ITP_BTN_ORDMNG02010_CANCELLIST', '#ITP_BTN_ORDMNG02010_SAVE', '#ITP_BTN_ORDMNG02010_RESET_PW']);
			$('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
            $('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_SEARCH_SPPLY_ID').val(fn_make_user_info.get('spplyId'));
			$('#ITP_FORM_ORDMNG02010_DETAIL_USER_ID').attr('readonly', true);
			$('#ITP_FORM_ORDMNG02010_DETAIL_DUP').attr('disabled', true);
			$('#ITP_FORM_ORDMNG02010_DETAIL_SEARCH_AFFL_SHOP_NM').attr('readonly', true);
			$('#ITP_FORM_ORDMNG02010_DETAIL_USER_NM').attr('readonly', true);
			$('#ITP_FORM_ORDMNG02010_DETAIL_SEARCH_AFFL_SHOP').hide();
			$('#ITP_FORM_ORDMNG02010_DETAIL_DELETE_AFFL_SHOP').hide();
			$('#ITP_BTN_ORDMNG02010_CANCELLIST').show();
            $('#ITP_BTN_ORDMNG02010_SAVE').show();
		}
	}
};


/*목록화면 Object*/
let listObj = {
	init: function() {
		this.grid.init();
		this.action();
	},
	itp_ORDMNG02010_param: {},
	itp_ORDMNG02010_search: false,
	button: {
		search: function() {
			listObj.itp_ORDMNG02010_search = true;
			let param = $('#ITP_FORM_ORDMNG02010_SEARCH').serializeObject();
			param.gridSize = $.jgrid.defaults.rowNum;
            param.gridPage = $.jgrid.defaults.page;
			$(ORDMNG02010_GRID_ID).data('grid-param',param);
            $(ORDMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
        },
        create: function() {
        	var selectedIds = $(ORDMNG02010_GRID_ID).getGridParam('selarrrow');
    		if(selectedIds.length > 1) { // 1이상 선택시
    			alert("납품서 하나만 선택해주세요 (대표 납품서번호)") ;//출력
    			return; //리턴
    		}
    		var selRowData ; //변수선언		
    		for (var i=selectedIds.length-1; i>=0; i--) {		//1개만 선택시
    			selRowData = $(ORDMNG02010_GRID_ID).jqGrid('getRowData', selectedIds[i]);		//cell 선택
    		}
    		if (selRowData == null) {
    			itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.noData)
				return;
			}
    		let param = {brandId: selRowData.brandId, pchPodrUnqNo: selRowData.pchPodrUnqNo};
    		param.spplyId = fn_make_user_info.get('spplyId');
    		pageObj.switchScreen('MODIFY');
			itp_fn_form_clear_validate(null, '#ITP_FORM_ORDMNG02010_DETAIL');
			modifyObj.init(param);
		}
	},
	empty: {
		init: function() {
			
		},
		push: function() {
         
        },
        back: function() {
       
        }
	},
	grid: {
		init: function() {
			// 데이터 없을때
            this.search();
		},
		colModel: gridColModel.list,
		search: function() {
			pageObj.switchScreen('LIST');
			this.unload();
			this.load();
		},
		load: function() {
            let param = $('#ITP_FORM_ORDMNG02010_SEARCH').serializeObject();
            param.gridSize = $.jgrid.defaults.rowNum;
            var option = {
            	gridId: ORDMNG02010_GRID_ID,
            	colModel: gridColModel.list,
            	param: param,
            	url: DOMAIN + API_POMNG_INOUTMNG_SPPLY_TARGET_GRID_LIST,
            	pager: ORDMNG02010_GRID_PAGER,
            	multiselect: true,
				multiboxonly : false,
				rownumbers: false,
				loadComplete: function(data) {
                    itp_fn_grid_load_complete(data, ORDMNG02010_GRID_ID, true, 'number', 'ORDMNG02010', listObj.itp_ORDMNG02010_search, listObj.empty, true, data.gridRecords, true);
				},
				onPaging: function(action) {
                    itp_fn_grid_paging(ORDMNG02010_GRID_ID, action, param);
                }
            };
            itp_fn_grid_make_remote(option);
		},
		clearData: function() {
			$(ORDMNG02010_GRID_ID).jqGrid('clearGridData', true);
            $(ORDMNG02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
            $(ORDMNG02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
            $(ORDMNG02010_GRID_EMPTY).show();
		},
		unload: function() {
			$.jgrid.gridUnload(ORDMNG02010_GRID_ID);
		}
	},
	action: function() {
		var _this = this;
		// 출하창고 조회 버튼 클릭
		$('#ITP_BTN_ORDMNG02010_SEARCH_WHS_ID').on('click', function() {
			_this.popup();
		});
		// 출하창고 텍스트 삭제 버튼 클릭
		$('#ITP_BTN_ORDMNG02010_DELETE_WHS_ID').on('click', function() {
			$('#ITP_FORM_ORDMNG02010_SEARCH_WHS_NM').val('');
			$('#ITP_FORM_ORDMNG02010_SEARCH_WHS_ID').val('');
		});
	},
	popup: function() {
		var popFn = this.callback.create;
		
		const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'),whsDvsn: 'W01'};
		fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S');
	},
	callback: {
		create: function(rowDataPop) {
			$('#ITP_FORM_ORDMNG02010_SEARCH_WHS_ID').val(rowDataPop.whsId);
			$('#ITP_FORM_ORDMNG02010_SEARCH_WHS_NM').val(rowDataPop.whsNm);
		}
	},
	excelDown: function() {
		var param = {
			'url': API_POMNG_INOUTMNG_SPPLY_TARGET_GRID_LIST,
			'param': $('#ITP_FORM_ORDMNG02010_SEARCH').serializeObject(),
			'gridColumns': $(ORDMNG02010_GRID_ID).jqGrid('getGridParam', 'colModel'),
			'fileName': '공급사 납품서생성.xlsx',
			'sheetName': '공급사 납품서리스트'
		};
		itp_fn_remote_to_excel(param);
	}
};


/*수정화면 Object*/
let modifyObj = {
	init: function(param) {
		this.load(param);
	},
	itp_ORDMNG02010_param: {},
	itp_ORDMNG02010_search: false,
	button: {
		cancel: function() {
			listObj.grid.search();
		},
		save: function() {
			
			$('body').trigger('click');
			
			const formId = '#ITP_FORM_ORDMNG02010_DETAIL';
			itp_fn_form_clear_validate(null, formId);
			
			if (itp_fn_form_event.isValid(formId)) {
			
				itp_fn_grid_save_rows(ORDMNG02010_DETAIL_GRID_ID);
				let gridInsertData = [];
				for(var i=0; i<$(ORDMNG02010_DETAIL_GRID_ID).getGridParam('reccount'); i++) {
					$(ORDMNG02010_DETAIL_GRID_ID).jqGrid('saveCell', i+1, 2)
				}
				let param = $(formId).serializeObject();
				const rowData = $(ORDMNG02010_DETAIL_GRID_ID).getRowData();
				for (var i = 0; i < rowData.length; i++) {
					rowData[i].podrQty = Number(rowData[i].podrQty);
					rowData[i].shmtQty = Number(rowData[i].shmtQty);
				}
				
				var now = new Date();
				var today = now.getFullYear() +
								"." + (now.getMonth()+1 > 9 ? (now.getMonth()+1).toString() : "0" + (now.getMonth()+1).toString()) +
								"." + (now.getDate() > 9 ? now.getDate().toString() : "0" + now.getDate().toString());
				
				
				var dlvReqDt = $('#ITP_FORM_ORDMNG02010_DETAIL_DLV_SCH_DT').val();
				if (today > dlvReqDt) {
					alert("납품예정일은 오늘 이후이어야 합니다.");
					return;
				}	
				
				var modalFn = {
					callBack: (args) => {
						param.gridInsertData = rowData;
						var searhFn = function () {
							ITP_FORM_OPER03010_DETAIL_IS_WRITING = false;
							listObj.grid.search();
						}
						fn_ajax_call(API_POMNG_INOUTMNG_SAVE_SPPLY_INV, JSON.stringify(param), searhFn, 'POST');
					}
				};
				itp_fn_modal_confirm('납품서 생성 하시겠습니까?', modalFn);
			}
		},
		recal: function() {
			var ids = $(ORDMNG02010_DETAIL_GRID_ID).getDataIDs();
			$.each(ids, function(idx, rowId) {
				var unitAmt = jQuery(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'unitAmt');
				var shmtQty = jQuery(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'shmtQty');
				if (!isNaN(unitAmt) && !isNaN(shmtQty)) {
					if (unitAmt != null && unitAmt != '' && shmtQty != null && shmtQty != '') {
						jQuery(ORDMNG02010_DETAIL_GRID_ID).jqGrid('setRowData', rowId, {podrAmt: parseInt(unitAmt) * parseInt(shmtQty)});
					}
				}				
			});
			
			const rowData = $(ORDMNG02010_DETAIL_GRID_ID).getRowData();
			var podrTotalAmt = 0;
			$.each(rowData, function(key, value) {
				if(value.podrAmt != null && value.podrAmt != "") {
					podrTotalAmt = podrTotalAmt + parseInt(value.podrAmt);
				}
			});
			$('#ITP_FORM_ORDMNG02010_DETAIL .fnPodrTotalAmt').text(itp_fn_number_comma(podrTotalAmt));
		}
	},
	empty: {
		init: function() {
			/*
            var _this = this;
            this.push();
            $(ORDMNG02010_VIEW_GRID_EMPTY).on('click', function() {
                _this.back();
                modifyObj.itp_ORDMNG02010_param.gridSize = $.jgrid.defaults.rowNum;
                $(ORDMNG02010_DETAIL_GRID_ID).setGridParam({'postData': JSON.stringify(modifyObj.itp_ORDMNG02010_param)}).trigger('reloadGrid');
            });
*/
        },
        push: function() {
	/*
            let param = $('#ITP_FORM_ORDMNG02010_DETAIL').serializeObject();
            modifyObj.itp_ORDMNG02010_param = param;
*/
        },
        back: function() {
	/*
            $('#ITP_FORM_ORDMNG02010_SERVICE_BRAND_TYPE').val(modifyObj.itp_ORDMNG02010_param.brandType);
            $('#ITP_FORM_ORDMNG02010_SERVICE_ST_CD').val(modifyObj.itp_ORDMNG02010_param.stCd);
            $('#ITP_FORM_ORDMNG02010_SEARCH_BRAND_NM').val(modifyObj.itp_ORDMNG02010_param.brandNm);
*/
        }
	},
	load: function(param) {
		fn_ajax_call(API_POMNG_INOUTMNG_INIT_SPPLY_INV, param, this.callback, 'GET');
	},
	callback: function(result) {
		pageObj.switchScreen('MODIFY');
		$('#ITP_FORM_ORDMNG02010_DETAIL .fnBrandNm').text(result.brandNm);										// 브랜드
		$('#ITP_FORM_ORDMNG02010_DETAIL .fnPchPodrUnqNo').text(result.invPoInfoList[0].pchPodrUnqNo);			// 발주번호		
		$('#ITP_FORM_ORDMNG02010_DETAIL .fnDlvRegDt').text(result.dlvReqDt);									// 납품서생성일자
		$('#ITP_FORM_ORDMNG02010_DETAIL .fnWhsNm').text(result.whsNm);											// 발주총금액
		$('#ITP_FORM_ORDMNG02010_DETAIL .fnDeliTelNo').text(result.deliTelNo);									// 납품장소연락처
		$('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_DLV_SCH_DT').val(result.dlvSchDt);			// 납품예정일
		$('#ITP_FORM_ORDMNG02010_DETAIL .fnDlvRegDt').text(result.dlvReqDt);									// 납품요청일
		$('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_DLV_MGR_NM').val(result.dlvMgrNm);			// 납품담당자
		$('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_DLV_MGR_TEL_NO').val(result.dlvMgrTelNo);	// 납품담당자연락처

		shmtQtyValue = function(value, colname) {
			var selectedIds = $(ORDMNG02010_DETAIL_GRID_ID).getGridParam('selarrrow');
    		
    		var selRowData ; //변수선언		
    		for (var i=selectedIds.length-1; i>=0; i--) {		//1개만 선택시
    			selRowData = $(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getRowData', selectedIds[i]);		//cell 선택
    		}
    		let podrQty = selRowData.podrQty;
    		if(Number(value) > Number(podrQty) || value == null || value == '') {
				return [false, '발주수량보다 출하수량이 많습니다.'];
			} else if (Number(value) < 0) {
				return [false, '음수 입력 불가'];
			} else {
				return [true, ''];
			}
		};		
		isExpryDate = function(value, colname) {
        	var selectedIds = $(ORDMNG02010_DETAIL_GRID_ID).getGridParam('selarrrow');
    		
    		var selRowData ; //변수선언		
    		for (var i=selectedIds.length-1; i>=0; i--) {		//1개만 선택시
    			selRowData = $(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getRowData', selectedIds[i]);		//cell 선택
    		}
    		let expryYn = selRowData.expryYn;
    		if (expryYn !== 'Y' && value.length > 0) {
				return [false, '유통기한여부 N'];
			} else {
				return [true, ''];
			}
		};
		modifyObj.grid.init('MODIFY', result.invPoInfoList);		
	},
	grid: {
		init: function(mode, gridData) {
			this.mode = mode;
			this.gridId = ORDMNG02010_DETAIL_GRID_ID;
			this.gridList = ORDMNG02010_DETAIL_GRID_LIST;
			this.gridEmpty = ORDMNG02010_DETAIL_GRID_EMPTY;
			this.unload();
			this.load(gridData);
		},
		mode: '',
		colModel: gridColModel.detail,
		load: function(gridData) {
			var _this = this;
			var option = {
				gridId: _this.gridId,
				colModel: [
					{
						index: 'PCH_PODR_UNQ_NO', name: 'pchPodrUnqNo',
						label: ITP_MSG_LOCALE.label.pchPodrUnqNo,
						width: '8', fixed: false, align: 'center',
						sortable: false, hidden: true
					},
					{
						index: 'PCH_PODR_DTL_NO', name: 'pchPodrDtlNo',
						label: ITP_MSG_LOCALE.label.pchPodrDtlNo,  		//발주항번
						width: '8', fixed: false, align: 'center',
						sortable: false, hidden: false, edittype: 'text',
						editable: false
					},
					{
						index: 'ITEM_ID', name: 'itemId',
						label: ITP_MSG_LOCALE.label.itemId, 			//품목번호
						width: '10', fixed: false, align: 'center',
						minwidth: 100,
						sortable: false, hidden: false, edittype: 'text',
						editable: false
					},
					{
						index: 'ITEM_NM', name: 'itemNm',
						label: ITP_MSG_LOCALE.label.itemNm,  			//품목명
						width: '10', fixed: false, align: 'left',
						sortable: false, hidden: false, edittype: 'text',
						editable: false
					},
					{
						index: 'UNIT', name: 'unit',
						label: ITP_MSG_LOCALE.label.unit,  				//기본단위
						width: '8', fixed: false, align: 'center',
						sortable: false, hidden: false, edittype: 'text',
						editable: false
					},
					{
						index: 'UNIT_AMT', name: 'unitAmt',
						label: ITP_MSG_LOCALE.label.unitAmt,  			//단가
						width: '20', fixed: false, align: 'center',
						sortable: false, hidden: true, edittype: 'text',
						editable: false
					},
					{
						index: 'PODR_QTY', name: 'podrQty',
						label: ITP_MSG_LOCALE.label.podrQty,  			//발주수량
						width: '8', fixed: false, align: 'right',
						sortable: false, hidden: false, edittype: 'text',
						editable: false
					},
					{
						index: 'SHMT_QTY', name: 'shmtQty',
						label: ITP_MSG_LOCALE.label.shmtQty, 	 		//출하수량
						width: '8', fixed: false, align: 'right',
						sortable: false, hidden: false, edittype: 'text',
						classes: 'input_color',
						editable: true, editrules: {number: true, custom: true, custom_func: shmtQtyValue},
						editoptions: {"onKeyup": "this.value=this.value.replace(/[^0-9]/g,'');"},
					},
					{
						index: 'EXPRY_YN', name: 'expryYn',
						label: ITP_MSG_LOCALE.label.expryYn,  			//유통기한여부
						width: '10', fixed: false, align: 'center',
						sortable: false, hidden: false, edittype: 'text',
						editable: false
					},
					{
						index: 'EXPRY_DATE', name: 'expryDate',
						label: ITP_MSG_LOCALE.label.expryDate,  		//유통기한일자
						width: '10', fixed: false, align: 'center',
						sortable: false, hidden: false, 
						classes: 'input_color',
						editable: true, sorttype: 'date',
				        editoptions: {dataInit: function(e) {$(e).datepicker(ITP_DATE_LANGUAGE);}, 'readonly': 'readonly'},
				        editrules: {custom: true, custom_func: isExpryDate}
					},
					{
						index: 'REMARK', name: 'deliDesc',				//API 비고 키
						label: ITP_MSG_LOCALE.label.remark,  			//locale-ko 비고 값
						width: '10', fixed: false, align: 'center',
						classes: 'input_color',
						sortable: false, hidden: false, edittype: 'text',
						editable: true, editoptions: {maxlength: 200}
					},
					{
						index: 'PODR_AMT', name: 'podrAmt',
						label: ITP_MSG_LOCALE.label.podrAmt,  		//발주금액
						width: '20', fixed: false, align: 'center',
						sortable: false, hidden: true, edittype: 'text',
						editable: false
					},
				],
				data: gridData,
				multiselect: true,
				loadComplete: function(data) {
					itp_fn_grid_load_complete(data, ORDMNG02010_DETAIL_GRID_ID, true, 'number', 'ORDMNG02010', modifyObj.itp_ORDMNG02010_search, modifyObj.empty, true, data.gridRecords, true);
				},
				onCellSelect: function(rowId, cellIdx, cellValue) {
					ORDMNG02010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowId, cellIdx, ORDMNG02010_GRID_LAST_ROW_ID, ORDMNG02010_DETAIL_GRID_ID, ['actionId']);
					itp_fn_form_event.onKeyup(ORDMNG02010_DETAIL_GRID_ID);
				}
			};
			itp_fn_grid_make_local(option);
		},
		unload: function() {
			$.jgrid.gridUnload(this.gridId);
		}
	}
};
