Bladeren bron

240726-1755-Kim

hokky 3 maanden geleden
bovenliggende
commit
da81986091

+ 4 - 2
app/Http/Controllers/Front/Dabory/Erp/Purchase/PurchController.php

@@ -16,6 +16,8 @@ class PurchController extends Controller
         try {
             $formB = new FormB(request('bpa'));
             $purchModal = (new Modal('/search/slip-search/purch/purch'))->getData();
+            $porderModal = (new Modal('/search/slip-search/purch/porder'))->getData();
+            // dd($porderModal);
             $companyModal = (new Modal('/search/company-search/supplier'))->getData();
             $itemModal = (new Modal('/search/item-search/supplier'))->getData();
         } catch (ParameterException $e) {
@@ -28,6 +30,7 @@ class PurchController extends Controller
         $slipFormInitCacheData = Utils::getSlipFormInitCache(
             $formB->getData()['formB']['QueryVars']['QueryName']
         );
+        // dd($slipFormInitCacheData);
         $pickCacheData = Utils::getParamCache($menuCode,
             $formB->getData()['formB']['General']['PickApi'],
             $formB->getData()['formB']['QueryVars']['QueryName']);
@@ -40,8 +43,7 @@ class PurchController extends Controller
             array_merge(
                 compact('menuCode'),
                 $formB->getData(),
-                compact('purchModal',
-                    'companyModal', 'itemModal'),
+                compact('purchModal','companyModal', 'itemModal', 'porderModal'),
                 compact('pickCacheData', 'slipCacheData', 'slipFormInitCacheData'),
             )
         )->with('codeTitle', [ "deal_type('deal-type')", "status('porder')" ]);

+ 15 - 15
dabory/para/erp/ko_KR/form/form-b/purch/purch.json

@@ -55,27 +55,27 @@
         {
             "SaveButton": "저장",
             "AddNewBdButton": "항목추가",
-            "AutoSlipNo": "매입번호*(자동채번 없슴)",
+            "AutoSlipNo": "매입번호*(자동채번)",
             "PurchDate": "매입일자*",
             "StockDate": "수불일자*",
-            "PorderNo": "발주번호#",
-            "Status": "상황#",
-            "Supplier": "매입업체#",
-            "Contact": "업체담당자#",
-            "DealType": "거래구분#",
-            "VatType": "부가세#",
-            "VatTypeRate": "부가세율#",
-            "Delivery": "납품기한#",
-            "PayTerms": "지불조건#",
+            "PorderNo": "발주번호*",
+            "Status": "상황",
+            "Supplier": "매입업체*",
+            "Contact": "업체담당자",
+            "DealType": "거래구분",
+            "VatType": "부가세*",
+            "VatTypeRate": "부가세율",
+            "Delivery": "납품기한",
+            "PayTerms": "지불조건",
             "Destination": "납품장소#",
             "Column1": "컬럼1#",
             "Column2": "컬럼2#",
             "Remarks": "비고",
-            "RefNo": "참고번호#",
-            "IsClosed": "발주종결#",
-            "OurContact": "발주담당자#",
-            "SgroupName": "영업부서#",
-            "UserName": "사용자명#"
+            "RefNo": "참고번호",
+            "IsClosed": "발주종결",
+            "OurContact": "발주담당자",
+            "SgroupName": "영업부서*",
+            "UserName": "사용자명*"
         },
         {
             "SaveButton": "left",

+ 203 - 132
resources/views/front/dabory/erp/purchase/purch.blade.php

@@ -73,12 +73,6 @@
                                                maxlength="{{ $formB['FormVars']['MaxLength']['StockDate'] }}"
                                             {{ $formB['FormVars']['Required']['StockDate'] }}>
                                     </div>
-                                    {{-- <div class="form-group d-flex flex-column mb-2">
-                                        <label class="m-0">{{ $formB['FormVars']['Title']['PorderNo'] }}</label>
-                                        <input class="rounded w-100" type="text" id="porder-no-txt" disabled
-                                               maxlength="{{ $formB['FormVars']['MaxLength']['PorderNo'] }}"
-                                            {{ $formB['FormVars']['Required']['PorderNo'] }}>
-                                    </div>--}}
 
                                     <div class="form-group d-flex flex-column mb-2">
                                         <label class="m-0 ">{{ $formB['FormVars']['Title']['Supplier'] }}</label>
@@ -98,17 +92,21 @@
                                     </div>
 
                                     <div class="form-group d-flex flex-column mb-2">
-                                        <label class="m-0">{{ $formB['FormVars']['Title']['Status'] }}</label>
-                                        <select class="rounded w-100" data-closed="0" id="status-select" onchange="Btype.set_is_closed_val(this)"
-                                                maxlength="{{ $formB['FormVars']['MaxLength']['Status'] }}"
-                                            {{ $formB['FormVars']['Required']['Status'] }}>
-                                            @foreach ($codeTitle['status']['porder'] as $key => $status)
-                                                <option value="{{ $status['Code'] }}">
-                                                    {{ $status['Title'] }}
-                                                </option>
-                                            @endforeach
-                                        </select>
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['PorderNo'] }}</label>
+                                        <div class="d-flex">
+                                            <input type="text" class="rounded w-100 radius-r0" id="porder-no-txt"
+                                                maxlength="{{ $formB['FormVars']['MaxLength']['PorderNo'] }}"
+                                                {{ $formB['FormVars']['Required']['PorderNo'] }}>
+                                                <button type="button"
+                                                class="btn-dark rounded btn-open-modal border-0 radius-l0 col-3 window sorder-modal-btn"
+                                                data-target="slip"
+                                                data-clicked="get_porder_no"
+                                                data-variable="porderModal">
+                                                <i class="icon-folder-open"></i>
+                                            </button>
+                                            </div>
                                     </div>
+
                                 </div>
                             </div>
                         </div>
@@ -139,12 +137,27 @@
                                             {{ $formB['FormVars']['Required']['VatType'] }}>
                                         </select>
                                     </div>
-                                    <div class="form-group d-flex flex-column">
+                                    <div class="form-group d-flex flex-column mb-2">
                                         <label class="m-0">{{ $formB['FormVars']['Title']['VatTypeRate'] }}</label>
                                         <input type="text" id="vat-type-rate-text" class="rounded w-100" autocomplete="off" value="" disabled
                                                maxlength="{{ $formB['FormVars']['MaxLength']['VatTypeRate'] }}"
                                             {{ $formB['FormVars']['Required']['VatTypeRate'] }}>
                                     </div>
+
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['Status'] }}</label>
+                                        <select class="rounded w-100" data-closed="0" id="status-select" onchange="Btype.set_is_closed_val(this)"
+                                                maxlength="{{ $formB['FormVars']['MaxLength']['Status'] }}"
+                                            {{ $formB['FormVars']['Required']['Status'] }}>
+                                            @foreach ($codeTitle['status']['porder'] as $key => $status)
+                                                <option value="{{ $status['Code'] }}">
+                                                    {{ $status['Title'] }}
+                                                </option>
+                                            @endforeach
+                                        </select>
+                                    </div>
+
+
                                 </div>
                             </div>
                         </div>
@@ -385,6 +398,7 @@
 
 @section('modal')
     @include('front.outline.static.slip', ['moealSetFile' => $purchModal])
+    @include('front.outline.static.slip', ['moealSetFile' => $porderModal])
     @include('front.outline.static.company', ['moealSetFile' => $companyModal])
     @include('front.outline.static.item', ['moealSetFile' => $itemModal])
     @include('front.outline.static.memo2')
@@ -404,32 +418,29 @@
             // 매입일자, 수불일자 가져오기
             $('#purch-date').val(date_to_sting(new Date()))
             $('#stock-date').val(date_to_sting(new Date()))
-
-            let sgroup_pick = await get_api_data('sgroup-pick', { Page: [ { Id:  parseInt(window.User['SgroupId']) } ] });
-            window.User['SgroupName'] = sgroup_pick['data']['Page'][0]['SgroupName'];
-
             //storage_name, branch_name 받아오기
             Btype.get_storage_name_and_branch_name()
+            slipInit = await Btype.get_slip_form_init()
+            // slipInit = @json($slipFormInitCacheData);
+            formB['SlipCommonSetup'] = slipInit['SlipCommonSetup']
+            console.log('slipInit : ', slipInit);
 
-            // 백엔드 작업완료시 주석 해제
-                // slipInit = await Btype.get_slip_form_init()
-                // slipInit = @json($slipFormInitCacheData);
-                // formB['SlipCommonSetup'] = slipInit['SlipCommonSetup']
-                // console.log('slipInit : ', slipInit);
-                // await Btype.create_deal_type_select_box_options(slipInit.DealTypePage)
-                // await Btype.create_vat_type_select_box_options(slipInit.VatRatePage)
-                // await Btype.create_sgroup_select_box_options(slipInit.SgroupPage)
-                // await create_etc_select_box_options(slipInit)
-            // 백엔드 작업완료시 주석 해제
+            await Btype.create_deal_type_select_box_options(slipInit.DealTypePage)
+            await Btype.create_vat_type_select_box_options(slipInit.VatRatePage)
+            await Btype.create_sgroup_select_box_options(slipInit.SgroupPage)
 
+            await create_etc_select_box_options(slipInit)
             $('#user-txt').val(window.User['NickName'])
+            console.log('NickName: ', window.User['NickName']);
 
-            // if (formB['SlipCommonSetup']['IsNewRecAutoSlipNo']) {
+            let sgroup_pick = await get_api_data('sgroup-pick', { Page: [ { Id:  parseInt(window.User['SgroupId']) } ] });
+            window.User['SgroupName'] = sgroup_pick['data']['Page'][0]['SgroupName'];
+
+            if (formB['SlipCommonSetup']['IsNewRecAutoSlipNo']) {
                 $('.is-new-rec-auto-slip-no').text('자동채번')
                 $('#auto-slip-no-txt').prop('disabled', true)
                 // get_last_slip_no()
-            // }
-
+            }
 
             if (! isEmpty(pickCacheData['query'])) {
                 let query = JSON.parse(pickCacheData['query'])
@@ -437,11 +448,10 @@
             }
 
             $('.purch-act').on('click', function () {
-                // console.log($(this).data('value'))
                 switch( $(this).data('value') ) {
                     case 'save': Btype.btn_act_save('#purch-form #frm'); break;
-                    // case 'new': btn_act_new(); break;
-                    // case 'save-and-new': Btype.btn_act_save_and_new(); break;
+                    case 'new': btn_act_new(); break;
+                    case 'save-and-new': Btype.btn_act_save_and_new(); break;
                     case 'copy-to-another': btn_act_copy_to_another(str_replace_hyphen($(this).data('parameter'), '/')); break;
                     case 'delete': Btype.btn_act_del('#purch-form #frm'); break;
                 }
@@ -507,16 +517,24 @@
 
 
         async function btn_bd_act_add() {
-            if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0) {
-                iziToast.error({
-                    title: 'Error',
-                    message: @json(_e('Action failed')),
-                });
-                return;
-            }
-            if (! Btype.last_item_added_check('#purch-table-body')) {
-                add_tr();
-            }
+            Btype.btn_act_save('#sales-form #frm', async function () {
+                if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0) {
+                    iziToast.error({
+                        title: 'Error',
+                        message: @json(_e('Action failed')),
+                    });
+                    return;
+                }
+                if (! Btype.last_item_added_check('#sales-table-body')) {
+                    add_tr();
+                }
+            });
+        }
+
+        // 발주번호 찾기 -> 발주번호 입력
+        function get_porder_no(id){
+            $('#porder-no-txt').val(id)
+	        $('#modal-slip').modal('hide');
         }
 
         function btn_bd_act_body_copy(parameter_name) {
@@ -540,63 +558,10 @@
         }
 
         function btn_act_new() {
-            bd_page = [];
-            $(`#frm`).find(`input[name="Id"]`).val(0)
-            $('.save-button').prop('disabled', false)
-
-            $('#auto-slip-no-txt').val('')
-            // Btype.set_slip_no_btn_abled()
-            $('#purch-date').val(date_to_sting(new Date()))
-            $('#stock-date').val(date_to_sting(new Date()))
-            $('#porder-no-txt').val('')
-            $('#porder-no-txt').data('id', 0)
-            $('#status-txt').val('')
-
-            // select_box_first_selected('#deal-type-select')
-            $('#deal-type-txt').val('')
-            $('#supplier-txt').val('')
-            $('#supplier-txt').data('id', 0)
-            $('#supplier-txt').data('contact', '')
-            $('#supplier-contact-txt').val('')
-            $('#vat-type-txt').val('')
-            $('#vat-type-select').html(`<option value=""></option>`);
-            $('#vat-type-rate-text').val('')
-
-            $('#delivery-txt').val('')
-            $('#payTerms-txt').val('')
-            $('#destination-txt').val('')
-            $('#column1-txt').val('')
-            $('#column2-txt').val('')
-            // select_box_first_selected('#delivery-select')
-            // select_box_first_selected('#payTerms-select')
-            // select_box_first_selected('#destination-select')
-            // select_box_first_selected('#column1-select')
-            // select_box_first_selected('#column2-select')
-
-            $('#remarks-txt-area').val('')
-            $('#remarks-preview').html('')
-            $('#ref-no-txt').val('')
-            $('#is-not-stock-io-txt').val('')
-            $('#is-closed-check').prop('checked', false)
-
-            $('#sgroup-name-txt').val('')
-            // select_box_first_selected('#sgroup-name-select')
-            $('#user-txt').val('')
-            $('#our-contact-txt').val('')
-            // select_box_first_selected('#our-contact-select')
-
-            $('#StorageName').val('')
-            $('#BranchName').val('')
-
-            // table body 초기화
-            table_head_check_box_reset('#purch-table-head')
-            $('#purch-table-body').html('');
-
-            // footer 합계 초기화
-            $('#QtyTotal').val('')
-            $('#SupplyTotal').val('')
-            $('#VatTotal').val('')
-            $('#SumTotal').val('')
+            data_init()
+            if (formB['SlipCommonSetup']['IsNewRecAutoSlipNo']) {
+                get_last_slip_no()
+            }
         }
 
         function btn_act_copy_to_another(parameter_name) {
@@ -611,10 +576,12 @@
         }
 
         function get_parameter() {
-            // const deal_name = slipInit['DealTypePage'].filter(page => page['Id'] === Number($('#deal-type-select').val()))[0]['DealName']
-            // const vat_rate = $('#vat-type-select').find('option:selected').data('vatrate')
-            // const vat_name = slipInit['VatRatePage'].filter(page => page['Id'] === Number($('#vat-type-select').val()))[0]['VatName']
-
+            const deal_name = slipInit['DealTypePage'].filter(page => page['Id'] === Number($('#deal-type-select').val()))[0]['DealName']
+            const vat_rate = $('#vat-type-select').find('option:selected').data('vatrate')
+            const vat_name = slipInit['VatRatePage'].filter(page => page['Id'] === Number($('#vat-type-select').val()))[0]['VatName']
+            console.log('deal_name : ', deal_name);
+            console.log('vat_rate : ', vat_rate);
+            console.log('vat_name : ', vat_name);
             let first_item = ''
             let first_thumb = ''
             if (bd_page.length > 0) {
@@ -649,19 +616,18 @@
                 // UserId: window.User['UserId'],
                 // Remarks: $('#remarks-txt-area').val(),
                 // Ip: window.User['Ip'],
-                // IsNotStockIo: $('#is-not-stock-io-txt').val(),
                 Id: id,
                 CreatedOn: get_now_time_stamp(),
                 UpdatedOn: get_now_time_stamp(),
                 SorderId: parseInt($('#sorder-no-txt').data('id')),
                 PurchNo: $('#auto-slip-no-txt').val(),
-                PurchDate: moment(new Date($('#sales-date').val())).format('YYYYMMDD'),
+                PurchDate: moment(new Date($('#purch-date').val())).format('YYYYMMDD'),
                 StockDate: moment(new Date($('#stock-date').val())).format('YYYYMMDD'),
                 DealTypeId: parseInt($('#deal-type-select').val()),
                 SgroupId: parseInt($('#sgroup-id-select').val()),
                 BranchId: window.User['BranchId'],
                 StorageId: window.User['StorageId'],
-                BuyerId: parseInt($('#supplier-txt').data('id')),
+                SupplierId: parseInt($('#supplier-txt').data('id')),
                 VatRateId: parseInt($('#vat-type-select').val()),
                 BuyerContact: $('#supplier-txt').data('contact'),
                 PayTerms: $('#payTerms-select').val(),
@@ -674,7 +640,6 @@
                 Ip: window.User['Ip'],
                 IsNotStockIo: $('#is-not-stock-io-txt').val(),
 
-
                 FirstItem: first_item,
                 ItmtotAmt: String(itmtot_amt),
                 // DiscountAmt: '0',
@@ -683,9 +648,13 @@
                 VatRate: vat_rate,
                 VatName: vat_name,
                 SgroupName: window.User['SgroupName'],
-                // FirstThumb : first_thumb,
                 TotalQty : String(Number(total_qty) - 0)
             }
+
+            if (typeof first_thumb !== 'undefined') {
+                parameter.FirstThumb = first_thumb;
+            }
+
             if (id < 0) {
                 parameter = { Id: id }
             } else if (id > 0) {
@@ -697,6 +666,74 @@
             return parameter;
         }
 
+        function data_init() {
+            bd_page = [];
+            $(`#frm`).find(`input[name="Id"]`).val(0)
+            $('.save-button').prop('disabled', false)
+
+            $('#auto-slip-no-txt').val('')
+            Btype.set_slip_no_btn_abled()
+            $('#purch-date').val(date_to_sting(new Date()))
+            $('#stock-date').val(date_to_sting(new Date()))
+            $('#supplier-txt').val('')
+            $('#supplier-txt').data('id', 0)
+            $('#supplier-txt').data('contact', '')
+            $('#supplier-contact-txt').val('')
+
+            select_box_first_selected('#deal-type-select')
+            select_box_first_selected('#vat-type-select')
+            $('#vat-type-select').trigger('change');
+            select_box_first_selected('#status-select')
+            $('#status-select').data('closed', 0)
+            select_box_first_selected('#sgroup-id-select')
+            select_box_first_selected('#delivery-select')
+            select_box_first_selected('#payTerms-select')
+            select_box_first_selected('#destination-select')
+            $('#ref-no-txt').val('')
+            $('#remarks-txt-area').val('')
+            $('#remarks-preview').html('')
+            $('#porder-no-txt').val('')
+            $('#porder-no-txt').data('id', 0)
+            $('#is-closed-check').prop('checked', false)
+
+            $('#status-txt').val('')
+
+            // $('#vat-type-txt').val('')
+            // $('#vat-type-select').html(`<option value=""></option>`);
+            // $('#vat-type-rate-text').val('')
+
+            $('#delivery-txt').val('')
+            $('#payTerms-txt').val('')
+            $('#destination-txt').val('')
+            $('#column1-txt').val('')
+            $('#column2-txt').val('')
+
+            // select_box_first_selected('#column1-select')
+            // select_box_first_selected('#column2-select')
+            $('#is-not-stock-io-txt').val('')
+
+
+            $('#sgroup-name-txt').val('')
+            select_box_first_selected('#sgroup-name-select')
+            // $('#user-txt').val('')
+            $('#our-contact-txt').val('')
+            select_box_first_selected('#our-contact-select')
+
+            $('#StorageName').val('')
+            $('#BranchName').val('')
+
+            // table body 초기화
+            table_head_check_box_reset('#purch-table-head')
+            $('#purch-table-body').html('');
+
+            // footer 합계 초기화
+            $('#QtyTotal').val('')
+            $('#SupplyTotal').val('')
+            $('#VatTotal').val('')
+            $('#SumTotal').val('')
+        }
+
+
         async function get_last_slip_no($this) {
             Btype.set_slip_no_btn_disabled()
             let response = await Btype.get_last_slip_no('purch');
@@ -708,14 +745,14 @@
             $('#supplier-contact-txt').val($('#supplier-txt').data('contact'))
         }
 
-        async function create_etc_select_box_options() {
+        async function create_etc_select_box_options(data) {
             // let delivery = create_options(await get_select_box_options_data('etc-page', 'select_name="납품기한"'))
             // let payTerms = create_options(await get_select_box_options_data('etc-page', 'select_name="지불조건"'))
             // let destination = create_options(await get_select_box_options_data('etc-page', 'select_name="납품장소"'))
             // let our_contact = create_options(await get_select_box_options_data('etc-page', 'select_name="발주담당자"'))
             // let column1 = create_options(await get_select_box_options_data('etc-page', 'select_name="공란1"'))
             // let column2 = create_options(await get_select_box_options_data('etc-page', 'select_name="공란2"'))
-
+            console.log
             let delivery = create_options(data.EtcDeliveryPage)
             let payTerms = create_options(data.EtcPayTermPage)
             let destination = create_options(data.EtcDestinationPage)
@@ -731,17 +768,18 @@
 
         function set_vat_type_rate($this, msg = true) {
             let vate_rate = $($this).find('option:selected').data('viewvatrate');
+            console.log();
             $('#vat-type-rate-text').val(vate_rate + '%')
 
             if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0 || ! msg) return;
-            // call_act_api(get_parameter(), function() { });
+            Btype.call_act_api(get_parameter(), function() { });
 
-            // if (isEmpty(bd_page)) return;
+            if (isEmpty(bd_page)) return;
 
-            // let data = bd_update_due_to_vat_rate_change();
-            // Btype.call_bd_act_api(data, function() {
-            //     create_bd_page();
-            // })
+            let data = bd_update_due_to_vat_rate_change();
+            Btype.call_bd_act_api(data, function() {
+                create_bd_page();
+            })
         }
 
         function get_bd_parameter(bd) {
@@ -841,6 +879,32 @@
                     message: @json(_e('(*)Required item(s) omitted')),
                 });
             }
+            scrollToTop();
+        }
+
+        function body_act_success_callback($this, tr) {
+            // 합계 계산
+            amt_total_calc();
+
+            let qty = $(tr).children('td:eq(6)').find('input')
+            let prc = $(tr).children('td:eq(7)').find('input')
+            let supply_amt = $(tr).children('td:eq(8)').find('input')
+            let vat_amt = $(tr).children('td:eq(9)').find('input')
+            let sum_amt = $(tr).children('td:eq(10)').find('input')
+            let std_sales_price = $(tr).children('td:eq(11)')
+
+            $(qty).val( format_conver_for(minusComma($(qty).val()), formB.ListVars['Format'].SalesQty) )
+            $(prc).val( format_conver_for(minusComma($(prc).val()), formB.ListVars['Format'].SorderPrc) ) // 수주단가
+            $(supply_amt).val( format_conver_for(minusComma($(supply_amt).val()), formB.ListVars['Format'].SupplyAmt) )
+            $(vat_amt).val( format_conver_for(minusComma($(vat_amt).val()), formB.ListVars['Format'].VatAmt) )
+            $(sum_amt).val( format_conver_for(minusComma($(sum_amt).val()), formB.ListVars['Format'].SumAmt) )
+            $(std_sales_price).text( format_conver_for(minusComma($(std_sales_price).text()), formB.ListVars['Format'].SorderPrc) ) // 표준 매출가
+
+            if ($($this).data('last')) {
+                add_tr();
+                $($this).data('last', false)
+            }
+            iziToast.success({ title: 'Success', message: $('#action-completed').text() });
         }
 
         function override_amt_calc_txt_is_changed() {
@@ -907,7 +971,7 @@
                         class="text-${formB.ListVars['Align'].ItemCode}" ${formB.ListVars['Hidden'].ItemCode}
                         >
                         <input type="text" class="text-${formB.ListVars['Align'].ItemCode} border-0 bg-white" value="${bd.ItemCode}" readonly
-                        onchange="Btype.check_the_checkbox_when_changing(this)">
+                        onchange="Btype.check_the_checkbox_when_changing(this)" required>
                     </td>
                     <td onkeydown="Btype.enterPressedinCell(event, 2)"
                         class="text-${formB.ListVars['Align'].ItemName}" ${formB.ListVars['Hidden'].ItemName}
@@ -934,7 +998,8 @@
                         >
                         <input type="text" class="text-${formB.ListVars['Align'].PorderPrc} border-0 bg-white" value="${format_conver_for(bd.PorderPrc, formB.ListVars['Format'].PorderPrc)}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
-                        onfocusout="override_amt_calc_txt_is_changed()">
+                        onfocusout="override_amt_calc_txt_is_changed()"
+                        require>
                     </td>
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].SupplyAmt}" ${formB.ListVars['Hidden'].SupplyAmt}
@@ -1187,7 +1252,7 @@
                 return;
             }
             Btype.set_slip_no_btn_disabled()
-
+            console.log(response);
             let hd_page = response.data.HdPage[0]
             bd_page = response.data.BdPage ?? []
             let thumb = response.data.HdPage[0]['FirstThumb']
@@ -1211,17 +1276,17 @@
             $('#supplier-txt').data('contact', hd_page.SupplierContact)
             $('#supplier-contact-txt').val(hd_page.SupplierContact)
 
-            let html = `<option value="${hd_page.VatRateId}" data-vatrate="${hd_page.VatRate}" data-viewvatrate="${hd_page.VatRate * 100}">${hd_page.VatName}</option>`
-            $('#vat-type-select').html(html);
+            // let html = `<option value="${hd_page.VatRateId}" data-vatrate="${hd_page.VatRate}" data-viewvatrate="${hd_page.VatRate * 100}">${hd_page.VatName}</option>`
+            // $('#vat-type-select').html(html);
+            // $('#vat-type-txt').val(hd_page.VatName)
             $('#vat-type-select').val(hd_page.VatRateId)
-            $('#vat-type-txt').val(hd_page.VatName)
             set_vat_type_rate('#vat-type-select', false);
 
-            $('#delivery-txt').val(hd_page.Delivery)
-            $('#payTerms-txt').val(hd_page.PayTerms)
-            $('#destination-txt').val(hd_page.Destination)
-            $('#column1-txt').val(hd_page.Column1)
-            $('#column2-txt').val(hd_page.Column2)
+            // $('#delivery-txt').val(hd_page.Delivery)
+            // $('#payTerms-txt').val(hd_page.PayTerms)
+            // $('#destination-txt').val(hd_page.Destination)
+            // $('#column1-txt').val(hd_page.Column1)
+            // $('#column2-txt').val(hd_page.Column2)
 
             $('#remarks-txt-area').val(hd_page.Remarks)
             $('#remarks-preview').html(hd_page.Remarks)
@@ -1249,7 +1314,13 @@
             $('#modal-slip').modal('hide');
         }
 
+        function scrollToTop() {
+            var scrollArea = document.getElementById("scroll-area");
+            scrollArea.scrollTop = 0;
+        }
+
         const purchModal = {!! json_encode($purchModal) !!};
+        const porderModal = {!! json_encode($porderModal) !!};
         const companyModal = {!! json_encode($companyModal) !!};
         const itemModal = {!! json_encode($itemModal) !!};
         const slipCacheData = {!! json_encode($slipCacheData) !!};

+ 36 - 26
resources/views/front/dabory/erp/revenue/sales.blade.php

@@ -96,10 +96,10 @@
                                                 maxlength="{{ $formB['FormVars']['MaxLength']['SorderNo'] }}"
                                                 {{ $formB['FormVars']['Required']['SorderNo'] }}>
                                                 <button type="button"
-                                                class="btn btn-success btn-open-modal"
+                                                class="btn-dark rounded btn-open-modal border-0 radius-l0 col-3 window sorder-modal-btn"
                                                 data-target="slip"
-                                                data-clicked="Btype.fetch_slip_form_book"
-                                                data-variable="salesModal">
+                                                data-clicked="get_sorder_no"
+                                                data-variable="sorderModal">
                                                 <i class="icon-folder-open"></i>
                                             </button>
                                             </div>
@@ -271,7 +271,7 @@
                             @endif
                         </div>
 
-                        <div class="table-responsive mt-2" style="height:200px;" id="scroll-area">
+                        <div class="table-responsive mt-2" style="height:400px;" id="scroll-area">
                             <table class="table-row sales-table">
                                 <thead id="sales-table-head">
                                     @include('front.dabory.erp.partial.make-thead', [
@@ -365,6 +365,7 @@
 
 @section('modal')
     @include('front.outline.static.slip', ['moealSetFile' => $salesModal])
+    @include('front.outline.static.slip', ['moealSetFile' => $sorderModal])
     @include('front.outline.static.company', ['moealSetFile' => $companyModal])
     @include('front.outline.static.item', ['moealSetFile' => $itemModal])
     @include('front.outline.static.memo2')
@@ -376,10 +377,9 @@
         window.onload = async function () {
             ThumbArr = [];
             make_dynamic_table_css('.sales-table', make_dynamic_table_px(formB['ListVars']['Size']))
-
             $('#sales-date').val(date_to_sting(new Date()))
             $('#stock-date').val(date_to_sting(new Date()))
-            var test = Btype.get_storage_name_and_branch_name()
+            Btype.get_storage_name_and_branch_name()
             let sgroup_pick = await get_api_data('sgroup-pick', { Page: [ { Id:  parseInt(window.User['SgroupId']) } ] });
             window.User['SgroupName'] = sgroup_pick['data']['Page'][0]['SgroupName'];
 
@@ -391,6 +391,7 @@
             await Btype.create_sgroup_select_box_options(slipInit.SgroupPage)
             await create_etc_select_box_options(slipInit)
             $('#user-txt').val(window.User['NickName'])
+            console.log('NickName: ', window.User['NickName']);
 
             if (formB['SlipCommonSetup']['IsNewRecAutoSlipNo']) {
                 $('.is-new-rec-auto-slip-no').text('자동채번')
@@ -516,7 +517,15 @@
             });
         }
 
+        // 수주번호 찾기 -> 수주번호 입력
+        function get_sorder_no(id){
+            $('#sorder-no-txt').val(id)
+	        $('#modal-slip').modal('hide');
+        }
+
         function btn_bd_act_body_copy(parameter_name) {
+            console.log('btn_bd_act_body_copy : ', $('#sorder-no-txt').val());
+            console.log('btn_bd_act_body_copy : ', parameter_name);
             if (parseInt($('#frm').find('#Id').val()) == 0) {
                 iziToast.error({
                     title: 'Error',
@@ -525,7 +534,8 @@
                 return;
             }
 
-            $(`#modal-bodycopy.${parameter_name}`).find('.slip_no-txt').val($('#auto-slip-no-txt').val())
+            // $(`#modal-bodycopy.${parameter_name}`).find('.slip_no-txt').val($('#auto-slip-no-txt').val())
+            $(`#modal-bodycopy.${parameter_name}`).find('.slip_no-txt').val($('#sorder-no-txt').val())
             $(`#modal-bodycopy.${parameter_name}`).find('.company_name-txt').val($('#supplier-txt').val())
 
             let data = formB['BodySelectOptions'].filter(selectOption => selectOption['ModalClassName'] == parameter_name)[0];
@@ -533,7 +543,8 @@
             $('.revenue').find('.modal-btn').data('variable', data['Parameter'])
             $('.revenue').find('.modal-btn').data('class', parameter_name)
             $('.revenue').find('.modal-btn').trigger('click')
-            $(`#modal-bodycopy.${parameter_name}`).find('.body-copy-act').data('slip_no', $('#auto-slip-no-txt').val() )
+            // $(`#modal-bodycopy.${parameter_name}`).find('.body-copy-act').data('slip_no', $('#auto-slip-no-txt').val() )
+            $(`#modal-bodycopy.${parameter_name}`).find('.body-copy-act').data('slip_no', $('#sorder-no-txt').val() )
         }
 
         function btn_act_new() {
@@ -643,6 +654,8 @@
                 TotalQty : String(Number(total_qty) - 0)
             }
 
+            console.log('save : ', parameter);
+
             if (typeof first_thumb !== 'undefined') {
                 parameter.FirstThumb = first_thumb;
             }
@@ -660,7 +673,6 @@
             bd_page = [];
             $(`#frm`).find(`input[name="Id"]`).val(0)
             $('.save-button').prop('disabled', false)
-
             $('#auto-slip-no-txt').val('')
             Btype.set_slip_no_btn_abled()
             $('#sales-date').val(date_to_sting(new Date()))
@@ -668,25 +680,21 @@
             $('#supplier-txt').data('id', 0)
             $('#supplier-txt').data('contact', '')
             $('#supplier-contact-txt').val('')
-
             select_box_first_selected('#deal-type-select')
             select_box_first_selected('#vat-type-select')
             $('#vat-type-select').trigger('change');
             select_box_first_selected('#status-select')
             $('#status-select').data('closed', 0)
-
             select_box_first_selected('#sgroup-id-select')
             select_box_first_selected('#delivery-select')
             select_box_first_selected('#payTerms-select')
             select_box_first_selected('#destination-select')
             $('#ref-no-txt').val('')
-
             $('#remarks-txt-area').val('')
             $('#remarks-preview').html('')
             $('#sorder-no-txt').val('')
             $('#is-closed-check').prop('checked', false)
-            // select_box_first_selected('#is-closed-select')
-
+            select_box_first_selected('#is-closed-select')
             select_box_first_selected('#our-contact-select')
 
             // table body 초기화
@@ -721,12 +729,12 @@
             let delivery = create_options(data.EtcDeliveryPage)
             let payTerms = create_options(data.EtcPayTermPage)
             let destination = create_options(data.EtcDestinationPage)
-            let our_contact = create_options(data.EtcOurContactPage)
+            // let our_contact = create_options(data.EtcOurContactPage)
 
             $('#delivery-select').html(delivery);
             $('#payTerms-select').html(payTerms);
             $('#destination-select').html(destination);
-            $('#our-contact-select').html(our_contact);
+            // $('#our-contact-select').html(our_contact);
         }
 
         function set_vat_type_rate($this, msg = true) {
@@ -994,7 +1002,7 @@
                         onfocusout="save_data_when_entering_text()">
                     </td>
                     <td
-                        class="text-${formB.ListVars['Align'].SalesMemo}" ${formB.ListVars['Hidden'].SorderMemo}>
+                        class="text-${formB.ListVars['Align'].SorderMemo}" ${formB.ListVars['Hidden'].SorderMemo}>
                         <textarea style="max-height: 30px;" class="rounded w-100 bg-white memo-textarea" id="memo-textarea-${bd.Id}"
                             ondblclick="Btype.dblclick_memo_textarea(this, ${bd.Id})" role="button" readonly>${bd.SorderMemo}</textarea>
                     </td>
@@ -1089,7 +1097,6 @@
                 <td
                     class="text-${formB.ListVars['Align'].StdSalesPrc}" ${formB.ListVars['Hidden'].StdSalesPrc}>
                 </td>
-
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].Ref1}" ${formB.ListVars['Hidden'].Ref1}
                     >
@@ -1151,8 +1158,10 @@
             $(tr).children('td:eq(4)').text(item.SubName)
             $(tr).children('td:eq(5)').text(item.CountUnit)
             $(tr).children('td:eq(6)').find('input').val()
-            $(tr).children('td:eq(7)').find('input').val(parseFloat(item.PurchPrc).toFixed(window.User['PurchPrcPoint']))
-            $(tr).children('td:eq(11)').text(parseFloat(item.SalesPrc).toFixed(window.User['PurchPrcPoint']))
+            // $(tr).children('td:eq(7)').find('input').val(parseFloat(item.PurchPrc).toFixed(window.User['PurchPrcPoint']))
+            // $(tr).children('td:eq(11)').text(parseFloat(item.SalesPrc).toFixed(window.User['PurchPrcPoint']))
+            $(tr).children('td:eq(7)').find('input').val(parseFloat(item.PurchPrc).toFixed(window.User['SalesPrcPoint'])) //표준매출가
+            $(tr).children('td:eq(10)').text(parseFloat(item.SalesPrc).toFixed(window.User['SalesPrcPoint']))
             let index = $(tr).prevAll().length;
             bd_page[index].ItemId = item.Id
             bd_page[index].ItemCode = item.ItemCode
@@ -1160,8 +1169,8 @@
             bd_page[index].SubName = item.SubName
             bd_page[index].CountUnit = item.CountUnit
             bd_page[index].SorderPrc = item.SalesPrc
-            bd_page[index].CurrPurchPrc = item.SalesPrc
-            bd_page[index].CurrSalesPrc = item.PurchPrc// override_amt_calc_txt_is_changed();
+            bd_page[index].CurrPurchPrc = item.PurchPrc
+            bd_page[index].CurrSalesPrc = item.SalesPrc // override_amt_calc_txt_is_changed();
 
             if (!ThumbArr) { // item 받아왔을 때만 bd_page에 TurboThumb 저장
                 bd_page[index].TurboThumb = item.TurboThumb
@@ -1172,10 +1181,10 @@
                 bd_page[index].SorderMemo = item.ItemMemo
             }
 
-            if (bd_page[index].Id === 0) {
-                $(tr).children('td:eq(16)').find('textarea').val(item.ItemMemo)
-                bd_page[index].SalesMemo = item.ItemMemo
-            }
+            // if (bd_page[index].Id === 0) {
+            //     $(tr).children('td:eq(16)').find('textarea').val(item.ItemMemo)
+            //     bd_page[index].SalesMemo = item.ItemMemo
+            // }
 
             return $(tr).children('td:eq(6)').find('input')
         }
@@ -1250,6 +1259,7 @@
         }
 
         const salesModal = {!! json_encode($salesModal) !!};
+        const sorderModal = {!! json_encode($sorderModal) !!};
         const companyModal = {!! json_encode($companyModal) !!};
         const itemModal = {!! json_encode($itemModal) !!};
         const slipCacheData = {!! json_encode($slipCacheData) !!};