mc.exec(function() {

    var customerMeta = new mc.data.MetaData({
        client : customerData,
        dataFormat: customerFormat
    });

    var goodsMeta = new mc.data.MetaData({
        client : goodsData,
        dataFormat: goodsFormat
    })

    var metaField = new mc.data.MetaField({
        width: 100,
        fields:[
            {field: 'item', text: '상품명', width: 110},
            {field: 'qty', text: '수 량', width: 90},
            {field: 'price', text: '단 가'},
            {field: 'amount', text: '산출 금액', comma: true, showRight: true},
            {field: 'dc_amount', text: '할인 금액'},
            {field: 'sales_amount', text: '판매 금액',comma: true, showRight: true},
            {field: 'vat_amount', text: '부가세', comma: true, showRight: true},
            {field: 'total_amount', text: '부가세포함', comma: true, showRight: true, defaultColor: 'blue'}
        ]
    })

    var entryObject = new mc.grid.GridEntry({
        showTo: 'showArea',
        metaField: metaField,
        title: {text: '주문 등록'},
        url: 'orderEntry.php',
        initLines: 7,
        width:870,
        height:220,

        calculator: [
            ['qty', '*', 'price', 'amount', 'ceil', 0],
            ['amount', '-', 'dc_amount', 'sales_amount'],
            ['sales_amount', '*', 0.1, 'vat_amount', 'floor', 0],
            ['sales_amount', '+', 'vat_amount', 'total_amount']
        ],

        operator: ['dc_amount', '>', 'amount', {title: '할인금액 오류', msg: '할인금액이 산출금액보다 클 수 없습니다.'}],

        formEntry: [
            {linefeed: 15},
            {ccode: 'typegroup',
             component: [
                {ccode: 'label', text: '주문처', width: 50},
                {ccode: 'combo',  id: 'customer', width: 120,
                    metaData: customerMeta,  imageType: 'combo',
                    showFields: [{field: 'customer_name'}],
                    suggestField: 'customer_name',
                    sendFields: 'customer_code'}
             ]},
            {linefeed: true}
        ],

        gridEntry: [
            {ccode: 'combo', id: 'item', metaData: goodsMeta,
                imageType: 'combo', emptyCheck: false,
                showFields: {field: 'goods_name'},
                suggestField: 'goods_name', sendFields: 'goods_code'},
            {ccode: 'numbertype', id: 'qty'},
            {ccode: 'numbertype', id: 'price'},
            {ccode: 'type', id: 'amount'},
            {ccode: 'numbertype', id: 'dc_amount', emptyCheck: false},
            {ccode: 'type', id: 'sales_amount'},
            {ccode: 'type', id: 'vat_amount'},
            {ccode: 'type', id: 'total_amount'}
        ],

        buttons: [
            {linefeed: true},
            {ccode: 'buttongroup', eachWidth: [80, 80], width: 700, space: 10,
             component: [
                {ccode: 'button', text: '저 장', buttonType: 'button', createData: true},
                {ccode: 'button', text: '입력 취소', buttonType: 'button', resetData: true}
            ]}
        ]
    })
});
