3 Commity a95b45623d ... 55e6b34e86

Autor SHA1 Wiadomość Data
  hokky 55e6b34e86 240719-1452-Kim 4 miesięcy temu
  hokky 734a26832a commit 4 miesięcy temu
  hokky 7ae5623fac commit 4 miesięcy temu
27 zmienionych plików z 2246 dodań i 395 usunięć
  1. 8 1
      app/Http/Controllers/Front/Dabory/Erp/Purchase/PorderController.php
  2. 7 2
      app/Http/Controllers/Front/Dabory/Erp/Revenue/SalesController.php
  3. 5 1
      app/Http/Controllers/Front/Dabory/Erp/Revenue/SorderController.php
  4. 2 0
      app/Http/Controllers/Front/Dabory/Erp/Sales/SquoteController.php
  5. 133 0
      dabory/para/erp/ko_KR/copy/body-copy/purch/pquote-sorder.json
  6. 133 0
      dabory/para/erp/ko_KR/copy/body-copy/sales/sorder-sorder.json
  7. 133 0
      dabory/para/erp/ko_KR/copy/body-copy/sales/squote-sorder.json
  8. 34 0
      dabory/para/erp/ko_KR/copy/copy-to-another/purch/pquote-sorder.json
  9. 3 3
      dabory/para/erp/ko_KR/copy/copy-to-another/sales/sorder-sorder.json
  10. 34 0
      dabory/para/erp/ko_KR/copy/copy-to-another/sales/squote-sorder.json
  11. 35 0
      dabory/para/erp/ko_KR/etc/code-title/status/sales.json
  12. 3 3
      dabory/para/erp/ko_KR/form/form-a/company.json
  13. 32 22
      dabory/para/erp/ko_KR/form/form-b/sales/sales.json
  14. 9 14
      dabory/para/erp/ko_KR/form/form-b/sales/sorder.json
  15. 1 5
      dabory/para/erp/ko_KR/search/slip-search/sales/sales.json
  16. 1 0
      public/js/modals-controller/b-type/body-copy.js
  17. 13 7
      public/js/modals-controller/b-type/common.js
  18. 5 1
      public/js/modals-controller/b-type/copy-to-another.js
  19. 0 17
      public/js/modals-controller/b-type/slip.js
  20. 15 0
      resources/views/front/dabory/erp/master-data/company.blade.php
  21. 57 45
      resources/views/front/dabory/erp/purchase/porder.blade.php
  22. 1124 0
      resources/views/front/dabory/erp/revenue/sales.blade copy.php
  23. 315 190
      resources/views/front/dabory/erp/revenue/sales.blade.php
  24. 108 58
      resources/views/front/dabory/erp/revenue/sorder.blade.php
  25. 9 2
      resources/views/front/dabory/erp/sales/squote.blade.php
  26. 4 0
      resources/views/front/dabory/erp/stock/genio.blade.php
  27. 23 24
      resources/views/front/dabory/erp/stock/tab/genio-correct.blade.php

+ 8 - 1
app/Http/Controllers/Front/Dabory/Erp/Purchase/PorderController.php

@@ -18,6 +18,7 @@ class PorderController extends Controller
         try {
             $formB = new FormB(request('bpa'));
             $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) {
@@ -27,6 +28,12 @@ class PorderController extends Controller
         // pick api para(cache) 얻는 함수
         $menuCode = Utils::bpaDecoding(request('bpa'))['menu_code'];
 
+        $slipFormInitCacheData = Utils::getSlipFormInitCache(
+            $formB->getData()['formB']['QueryVars']['QueryName']
+        );
+
+        // dd($slipFormInitCacheData);
+
         $pickCacheData = Utils::getParamCache($menuCode,
             $formB->getData()['formB']['General']['PickApi'],
             $formB->getData()['formB']['QueryVars']['QueryName']);
@@ -41,7 +48,7 @@ class PorderController extends Controller
                 $formB->getData(),
                 compact('porderModal',
                     'companyModal', 'itemModal'),
-                compact('pickCacheData', 'slipCacheData'),
+                compact('pickCacheData', 'slipCacheData', 'slipFormInitCacheData'),
             )
         )->with('codeTitle', [ "deal_type('deal-type')", "status('porder')" ]);
     }

+ 7 - 2
app/Http/Controllers/Front/Dabory/Erp/Revenue/SalesController.php

@@ -14,6 +14,7 @@ class SalesController extends Controller
     {
         try {
             $formB = new FormB(request('bpa'));
+            // dd($formB);
             $salesModal = (new Modal('/search/slip-search/sales/sales'))->getData();
             $companyModal = (new Modal('/search/company-search/supplier'))->getData();
             $itemModal = (new Modal('/search/item-search/supplier'))->getData();
@@ -24,6 +25,10 @@ class SalesController extends Controller
         // pick api para(cache) 얻는 함수
         $menuCode = Utils::bpaDecoding(request('bpa'))['menu_code'];
 
+        $slipFormInitCacheData = Utils::getSlipFormInitCache(
+            $formB->getData()['formB']['QueryVars']['QueryName']
+        );
+
         $pickCacheData = Utils::getParamCache($menuCode,
             $formB->getData()['formB']['General']['PickApi'],
             $formB->getData()['formB']['QueryVars']['QueryName']);
@@ -38,8 +43,8 @@ class SalesController extends Controller
                 $formB->getData(),
                 compact('salesModal',
                     'companyModal', 'itemModal'),
-                compact('pickCacheData', 'slipCacheData'),
+                compact('pickCacheData', 'slipCacheData', 'slipFormInitCacheData'),
             )
-        )->with('codeTitle', [ "deal_type('deal-type')" ]);
+        )->with('codeTitle', [ "deal_type('deal-type')", "status('sales')" ]);
     }
 }

+ 5 - 1
app/Http/Controllers/Front/Dabory/Erp/Revenue/SorderController.php

@@ -25,6 +25,10 @@ class SorderController extends Controller
         // pick api para(cache) 얻는 함수
         $menuCode = Utils::bpaDecoding(request('bpa'))['menu_code'];
 
+        $slipFormInitCacheData = Utils::getSlipFormInitCache(
+            $formB->getData()['formB']['QueryVars']['QueryName']
+        );
+
         $pickCacheData = Utils::getParamCache($menuCode,
             $formB->getData()['formB']['General']['PickApi'],
             $formB->getData()['formB']['QueryVars']['QueryName']);
@@ -39,7 +43,7 @@ class SorderController extends Controller
                 $formB->getData(),
                 compact('sorderModal',
                     'companyModal', 'itemModal'),
-                compact('pickCacheData', 'slipCacheData'),
+                compact('pickCacheData', 'slipCacheData', 'slipFormInitCacheData'),
             )
         )->with('codeTitle', [ "deal_type('deal-type')", "status('sorder')" ]);
     }

+ 2 - 0
app/Http/Controllers/Front/Dabory/Erp/Sales/SquoteController.php

@@ -31,6 +31,8 @@ class SquoteController extends Controller
             $formB->getData()['formB']['QueryVars']['QueryName']
         );
 
+        // dd($slipFormInitCacheData);
+
         $pickCacheData = Utils::getParamCache($menuCode,
             $formB->getData()['formB']['General']['PickApi'],
             $formB->getData()['formB']['QueryVars']['QueryName']);

+ 133 - 0
dabory/para/erp/ko_KR/copy/body-copy/purch/pquote-sorder.json

@@ -0,0 +1,133 @@
+{
+    "General": {
+        "Title": "매입 가격표에서 수주로 품목 복사",
+        "PageApi": "body-copy-page",
+        "ActApi": "body-copy-mact"
+    },
+
+    "QueryVars": {
+        "QueryName": "purch/pquote-sorder"
+    },
+
+    "LastSeqNoVars": {
+		"TableName": "sorder"
+	},
+
+    "BodyCopyPageVars": {
+		"GroupBy": "dbr_pquote_bd.id",
+		"SlipNoField": "pquote_no"
+	},
+
+    "//FormVars": "ListVars[0]-Caption,",
+    "FormVars": [
+        {
+            "SlipNoButton": "매입가 번호",
+            "ItemCodeButton": "품목코드",
+            "CompanyNameButton": "업체명",
+            "AutoCreateSlipChecked": "",
+            "ShowOnlyClosedChecked": "종결처리만 표시",
+            "BalanceOption": "잔량",
+            "DayFromTodayOption": "배송예정 일수",
+            "SelectedItems": "선택항목",
+            "SelectedQty": "선택수량"
+        }
+    ],
+
+    "// BalanceOptions": "",
+    "BalanceOptions": [
+        {
+            "Value": "bal_qty > 0",
+            "Caption": "있는 경우만"
+        },
+        {
+            "Value": "bal_qty >= -900000000",
+            "Caption": "없는 경우도 표함"
+        }
+    ],
+    "// OrderByOptions": "OrderBy Options//첫번째 Value가 Default",
+    "OrderByOptions": [
+        {
+            "Value": "pquote_no desc",
+            "Caption": "매입가 번호 역순"
+        },
+        {
+            "Value": "pquote_no asc",
+            "Caption": "매입가번호 정렬순"
+        },
+        {
+            "Value": "company_name asc",
+            "Caption": "업체명 정렬"
+        },
+        {
+            "Value": "company_name desc",
+            "Caption": "업체명 역순"
+        },
+        {
+            "Value": "item_code asc",
+            "Caption": "품목코드 정렬"
+        },
+        {
+            "Value": "item_code desc",
+            "Caption": "품목코드 역순"
+        }
+    ],
+
+    "// ListVars": "ListVars[0]-caption, ListVars[2]-size(%), ListVars[3]-align",
+    "ListVars": [
+        {
+            "$Check": "$Check",
+            "No": "번호",
+            "SlipNo": "매입가 번호",
+            "CompanyName": "공급업체",
+            "ItemCode": "품목코드",
+            "ItemName": "품명",
+            "SubName": "서브명",
+            "OrderQty": "수량",
+            "BalQty": "복사수량",
+            "Ref": "관련정보"
+        },
+        {
+            "$Check": "5",
+            "No": "10",
+            "SlipNo": "15",
+            "CompanyName": "15",
+            "ItemCode": "10",
+            "ItemName": "10",
+            "SubName": "10",
+            "OrderQty": "10",
+            "BalQty": "10",
+            "Ref": "10"
+        },
+        {
+            "$Check": "center",
+            "No": "center",
+            "SlipNo": "center",
+            "CompanyName": "left",
+            "ItemCode": "left",
+            "ItemName": "left",
+            "SubName": "left",
+            "OrderQty": "right",
+            "BalQty": "right",
+            "Ref": "left"
+        }
+    ],
+
+    "//BodyCopyPopupVars": "[0]-filter, [1]-component, [2]-parameter",
+    "BodyCopyPopupVars": [
+        {
+            "SlipNo": "slip_no",
+            "CompanyName": "company_name",
+            "ItemCode": "item_code"
+        },
+        {
+            "SlipNo": "slip",
+            "CompanyName": "company",
+            "ItemCode": "item"
+        },
+        {
+            "SlipNo": "/search/slip-search/purch/pquote",
+            "CompanyName": "/search/company-search/company",
+            "ItemCode": "/search/item-search/supplier"
+        }
+    ]
+}

+ 133 - 0
dabory/para/erp/ko_KR/copy/body-copy/sales/sorder-sorder.json

@@ -0,0 +1,133 @@
+{
+    "General": {
+        "Title": "수주에서 수주로 품목 복사",
+        "PageApi": "body-copy-page",
+        "ActApi": "body-copy-mact"
+    },
+
+    "QueryVars": {
+        "QueryName": "sales/sorder-sorder"
+    },
+
+    "LastSeqNoVars": {
+		"TableName": "sorder"
+	},
+
+    "BodyCopyPageVars": {
+		"GroupBy": "dbr_sorder_bd.id",
+		"SlipNoField": "sorder_no"
+	},
+
+    "//FormVars": "ListVars[0]-Caption,",
+    "FormVars": [
+        {
+            "SlipNoButton": "수주번호",
+            "ItemCodeButton": "품목코드",
+            "CompanyNameButton": "업체명",
+            "AutoCreateSlipChecked": "",
+            "ShowOnlyClosedChecked": "종결처리만 표시",
+            "BalanceOption": "잔량",
+            "DayFromTodayOption": "배송예정 일수",
+            "SelectedItems": "선택항목",
+            "SelectedQty": "선택수량"
+        }
+    ],
+
+    "// BalanceOptions": "",
+    "BalanceOptions": [
+        {
+            "Value": "bal_qty > 0",
+            "Caption": "있는 경우만"
+        },
+        {
+            "Value": "bal_qty >= -900000000",
+            "Caption": "없는 경우도 표함"
+        }
+    ],
+    "// OrderByOptions": "OrderBy Options//첫번째 Value가 Default",
+    "OrderByOptions": [
+        {
+            "Value": "sorder_no desc",
+            "Caption": "발주번호 역순"
+        },
+        {
+            "Value": "sorder_no asc",
+            "Caption": "발주번호 정렬순"
+        },
+        {
+            "Value": "company_name asc",
+            "Caption": "업체명 정렬"
+        },
+        {
+            "Value": "company_name desc",
+            "Caption": "업체명 역순"
+        },
+        {
+            "Value": "item_code asc",
+            "Caption": "품목코드 정렬"
+        },
+        {
+            "Value": "item_code desc",
+            "Caption": "품목코드 역순"
+        }
+    ],
+
+    "// ListVars": "ListVars[0]-caption, ListVars[2]-size(%), ListVars[3]-align",
+    "ListVars": [
+        {
+            "$Check": "$Check",
+            "No": "번호",
+            "SlipNo": "발주번호",
+            "CompanyName": "공급업체",
+            "ItemCode": "품목코드",
+            "ItemName": "품명",
+            "SubName": "서브명",
+            "OrderQty": "수량",
+            "BalQty": "복사수량",
+            "Ref": "관련정보"
+        },
+        {
+            "$Check": "5",
+            "No": "10",
+            "SlipNo": "15",
+            "CompanyName": "15",
+            "ItemCode": "10",
+            "ItemName": "10",
+            "SubName": "10",
+            "OrderQty": "10",
+            "BalQty": "10",
+            "Ref": "10"
+        },
+        {
+            "$Check": "center",
+            "No": "center",
+            "SlipNo": "center",
+            "CompanyName": "left",
+            "ItemCode": "left",
+            "ItemName": "left",
+            "SubName": "left",
+            "OrderQty": "right",
+            "BalQty": "right",
+            "Ref": "left"
+        }
+    ],
+
+    "//BodyCopyPopupVars": "[0]-filter, [1]-component, [2]-parameter",
+    "BodyCopyPopupVars": [
+        {
+            "SlipNo": "slip_no",
+            "CompanyName": "company_name",
+            "ItemCode": "item_code"
+        },
+        {
+            "SlipNo": "slip",
+            "CompanyName": "company",
+            "ItemCode": "item"
+        },
+        {
+            "SlipNo": "/search/slip-search/sales/sorder",
+            "CompanyName": "/search/company-search/company",
+            "ItemCode": "/search/item-search/supplier"
+        }
+    ]
+}

+ 133 - 0
dabory/para/erp/ko_KR/copy/body-copy/sales/squote-sorder.json

@@ -0,0 +1,133 @@
+{
+    "General": {
+        "Title": "견적에서 수주로 품목 복사",
+        "PageApi": "body-copy-page",
+        "ActApi": "body-copy-mact"
+    },
+
+    "QueryVars": {
+        "QueryName": "sales/squote-sorder",
+        "GroupBy": "dbr_squote_bd.id"
+    },
+
+    "LastSeqNoVars": {
+		"TableName": "squote"
+	},
+
+    "BodyCopyPageVars": {
+		"SlipNoField": "squote_no"
+	},
+
+    "//FormVars": "ListVars[0]-Caption,",
+    "FormVars": [
+        {
+            "SlipNoButton": "견적서 번호",
+            "ItemCodeButton": "품목코드",
+            "CompanyNameButton": "업체명",
+            "AutoCreateSlipChecked": "",
+            "ShowOnlyClosedChecked": "종결처리만 표시",
+            "BalanceOption": "잔량",
+            "DayFromTodayOption": "배송예정 일수",
+            "SelectedItems": "선택항목",
+            "SelectedQty": "선택수량"
+        }
+    ],
+
+    "// BalanceOptions": "",
+    "BalanceOptions": [
+        {
+            "Value": "bal_qty > 0",
+            "Caption": "있는 경우만"
+        },
+        {
+            "Value": "bal_qty >= -900000000",
+            "Caption": "없는 경우도 표함"
+        }
+    ],
+    "// OrderByOptions": "OrderBy Options//첫번째 Value가 Default",
+    "OrderByOptions": [
+        {
+            "Value": "squote_no desc",
+            "Caption": "전표번호 역순"
+        },
+        {
+            "Value": "squote_no asc",
+            "Caption": "전표번호 정렬"
+        },
+        {
+            "Value": "company_name asc",
+            "Caption": "업체명 정렬"
+        },
+        {
+            "Value": "company_name desc",
+            "Caption": "업체명 역순"
+        },
+        {
+            "Value": "item_code asc",
+            "Caption": "품목코드 정렬"
+        },
+        {
+            "Value": "item_code desc",
+            "Caption": "품목코드 역순"
+        }
+    ],
+
+    "// ListVars": "ListVars[0]-caption, ListVars[2]-size(%), ListVars[3]-align",
+    "ListVars": [
+        {
+            "$Check": "$Check",
+            "No": "번호",
+            "SlipNo": "견적서 번호",
+            "CompanyName": "공급업체",
+            "ItemCode": "품목코드",
+            "ItemName": "품명",
+            "SubName": "서브명",
+            "OrderQty": "수량",
+            "BalQty": "복사수량",
+            "Ref": "관련정보"
+        },
+        {
+            "$Check": "3",
+            "No": "5",
+            "SlipNo": "10",
+            "CompanyName": "10",
+            "ItemCode": "10",
+            "ItemName": "30",
+            "SubName": "8",
+            "OrderQty": "8",
+            "BalQty": "8",
+            "Ref": "10"
+        },
+        {
+            "$Check": "center",
+            "No": "center",
+            "SlipNo": "center",
+            "CompanyName": "left",
+            "ItemCode": "center",
+            "ItemName": "left",
+            "SubName": "left",
+            "OrderQty": "right",
+            "BalQty": "right",
+            "Ref": "left"
+        }
+    ],
+
+    "//BodyCopyPopupVars": "[0]-filter, [1]-component, [2]-parameter",
+    "BodyCopyPopupVars": [
+        {
+            "SlipNo": "slip_no",
+            "CompanyName": "company_name",
+            "ItemCode": "item_code"
+        },
+        {
+            "SlipNo": "slip",
+            "CompanyName": "company",
+            "ItemCode": "item"
+        },
+        {
+            "SlipNo": "/search/slip-search/sales/squote",
+            "CompanyName": "/search/company-search/company",
+            "ItemCode": "/search/item-search/supplier"
+        }
+    ]
+}

+ 34 - 0
dabory/para/erp/ko_KR/copy/copy-to-another/purch/pquote-sorder.json

@@ -0,0 +1,34 @@
+{
+    "General": {
+        "Title": "매입 가격표에서 수주로 복사",
+        "ActApi": "copy-to-another",
+        "PickApi": "sorder-pick",
+        "SourceTable": "purch/pquote",
+        "TargetTable": "sorder"
+    },
+
+    "//FormVars": "ListVars[0]-Caption",
+    "FormVars": [
+        {
+            "SourceButton": "복사할 매입가 번호",
+            "TargetButton": "복사될 수주 번호",
+            "EqualLabel": "복사할 번호를 복사될 번호의 컬럼에 복사하기",
+            "ItemCopyLabel": "전체 품목 복사 선택",
+            "CopyItemRadio": "복사 함",
+            "DontCopyRadio": "복사 않음"
+        }
+    ],
+
+    "//CopyToAnotherPopupVars": "[0]-filter, [1]-component, [2]-parameter",
+    "CopyToAnotherPopupVars": [
+        {
+            "Source": "slip_no"
+        },
+        {
+            "Source": "slip"
+        },
+        {
+            "Source": "/search/slip-search/purch/pquote"
+        }
+    ]
+}

+ 3 - 3
dabory/para/erp/ko_KR/copy/copy-to-another/sales/sorder-sorder.json

@@ -1,6 +1,6 @@
 {
     "General": {
-        "Title": "매입 가격표에서 발주로 복사",
+        "Title": "수주에서 수주로 복사",
         "ActApi": "copy-to-another",
         "PickApi": "sorder-pick",
         "SourceTable": "sales/sorder",
@@ -10,8 +10,8 @@
     "//FormVars": "ListVars[0]-Caption",
     "FormVars": [
         {
-            "SourceButton": "복사할 주 번호",
-            "TargetButton": "복사될 주문번호",
+            "SourceButton": "복사할 주 번호",
+            "TargetButton": "복사될 수주 번호",
             "EqualLabel": "복사할 번호를 복사될 번호의 컬럼에 복사하기",
             "ItemCopyLabel": "전체 품목 복사 선택",
             "CopyItemRadio": "복사 함",

+ 34 - 0
dabory/para/erp/ko_KR/copy/copy-to-another/sales/squote-sorder.json

@@ -0,0 +1,34 @@
+{
+    "General": {
+        "Title": "견적서에서 수주로 복사",
+        "ActApi": "copy-to-another",
+        "PickApi": "sorder-pick",
+        "SourceTable": "sales/squote",
+        "TargetTable": "sorder"
+    },
+
+    "//FormVars": "ListVars[0]-Caption",
+    "FormVars": [
+        {
+            "SourceButton": "복사할 견적서 번호",
+            "TargetButton": "복사될 수주 번호",
+            "EqualLabel": "복사할 번호를 복사될 번호의 컬럼에 복사하기",
+            "ItemCopyLabel": "전체 품목 복사 선택",
+            "CopyItemRadio": "복사 함",
+            "DontCopyRadio": "복사 않음"
+        }
+    ],
+
+    "//CopyToAnotherPopupVars": "[0]-filter, [1]-component, [2]-parameter",
+    "CopyToAnotherPopupVars": [
+        {
+            "Source": "slip_no"
+        },
+        {
+            "Source": "slip"
+        },
+        {
+            "Source": "/search/slip-search/sales/squote"
+        }
+    ]
+}

+ 35 - 0
dabory/para/erp/ko_KR/etc/code-title/status/sales.json

@@ -0,0 +1,35 @@
+[
+    {
+        "Code": "",
+        "Title": "상태값 없음"
+    },
+    {
+        "Code": "0",
+        "Title": "입금대기"
+    },
+    {
+        "Code": "1",
+        "Title": "결제완료"
+    },
+    {
+        "Code": "2",
+        "Title": "배송준비"
+    },
+    {
+        "Code": "3",
+        "Title": "배송중"
+    },
+    {
+        "Code": "4",
+        "Title": "배송완료"
+    },
+    {
+        "Code": "5",
+        "Title": "구매확정"
+    },
+    {
+        "Code": "C",
+        "Title": "클레임발생"
+    }
+]
+

+ 3 - 3
dabory/para/erp/ko_KR/form/form-a/company.json

@@ -100,13 +100,13 @@
             "MainContact": "",
             "MobileNo": "",
             "Email": "",
-            "CardChar4": "required",
+            "CardChar4": "",
             "TelNo": "",
             "FaxNo": "",
             "FullName": "",
             "President": "",
-            "ZipCode": "required",
-            "Addr1": "required",
+            "ZipCode": "",
+            "Addr1": "",
             "Addr2": "",
             "BizType": "",
             "DealItem": "",

+ 32 - 22
dabory/para/erp/ko_KR/form/form-b/sales/sales.json

@@ -10,6 +10,16 @@
     },
 
     "HeadSelectOptions": [
+        {
+            "Value": "new",
+            "Caption": "추가",
+            "Parameter": ""
+        },
+        {
+            "Value": "save-and-new",
+            "Caption": "저장후 추가",
+            "Parameter": ""
+        },
         {
             "Value": "copy-to-another",
             "Caption": "수주에서 매출으로 복사",
@@ -62,24 +72,24 @@
     "FormVars": [
         {
             "SaveButton": "저장",
-            "AddNewBdButton": "",
+            "AddNewBdButton": "항목추가",
             "AutoSlipNo": "매출번호*(자동채번 없슴)",
             "SalesDate": "매출일자*",
             "StockDate": "수불일자*",
-            "SorderNo": "수주번호#",
-            "Status": "상황#",
-            "Supplier": "매출업체#",
-            "Contact": "업체담당자#",
-            "DealType": "거래구분#",
-            "VatType": "부가세#",
-            "VatTypeRate": "부가세율#",
-            "Delivery": "납품기한#",
-            "PayTerms": "지불조건#",
-            "Destination": "납품장소#",
+            "SorderNo": "수주번호*",
+            "Status": "상황",
+            "Supplier": "매출업체*",
+            "Contact": "업체담당자",
+            "DealType": "거래구분",
+            "VatType": "부가세",
+            "VatTypeRate": "부가세율",
+            "Delivery": "납품기한",
+            "PayTerms": "지불조건",
+            "Destination": "납품장소",
             "Column1": "컬럼1#",
             "Column2": "컬럼2#",
             "Remarks": "비고",
-            "IsClosed": "수주종결#",
+            "IsClosed": "수주종결",
             "SgroupName": "영업부서#",
             "UserName": "사용자명#"
         },
@@ -135,7 +145,7 @@
             "AutoSlipNo": "required",
             "SalesDate": "required",
             "StockDate": "required",
-            "SorderNo": "",
+            "SorderNo": "required",
             "Status": "",
             "Supplier": "",
             "Contact": "",
@@ -157,25 +167,25 @@
     "// ListVars": "ListVars[0]-Caption, ListVars[1]-Size(%), ListVars[2]-align",
     "ListVars": [
         {
-            "$Radio": "$Radio",
+            "$Radio": "",
             "$Check": "$Check",
-            "ItemCode": "품목코드#",
-            "ItemName": "품명#",
+            "ItemCode": "품목코드*",
+            "ItemName": "품명*",
             "SubName": "서브명#",
             "CountUnit": "단위#",
             "SalesQty": "매출수량*",
-            "SorderPrc": "수주단가#",
+            "SorderPrc": "수주단가*",
             "SupplyAmt": "공급가액*",
             "VatAmt": "세액*",
             "SumAmt": "합계금액*",
             "StdSalesPrc": "표준매출가#",
-            "DeliDate": "확정납기일#",
-            "Ref1": "참고1#",
-            "Ref2": "참고2#",
+            "DeliDate": "확정납기일*",
+            "Ref1": "참고1",
+            "Ref2": "참고2",
             "SorderMemo": "품목설명(M)"
         },
         {
-            "$Radio": "3",
+            "$Radio": "",
             "$Check": "3",
             "ItemCode": "10",
             "ItemName": "30",
@@ -193,7 +203,7 @@
             "SorderMemo": "10"
         },
         {
-            "$Radio": "center",
+            "$Radio": "",
             "$Check": "center",
             "ItemCode": "left",
             "ItemName": "left",

+ 9 - 14
dabory/para/erp/ko_KR/form/form-b/sales/sorder.json

@@ -27,13 +27,13 @@
         },
         {
             "Value": "copy-to-another",
-            "Caption": "견적에서 수주로 복사",
-            "Parameter": "purch/pquote-porder"
+            "Caption": "매입 가격표에서 수주로 복사(-)",
+            "Parameter": "purch/pquote-sorder"
         },
         {
             "Value": "copy-to-another",
-            "Caption": "수주에서 매출로 복사(-)",
-            "Parameter": "sales/sorder-porder"
+            "Caption": "견적에서 수주로 복사",
+            "Parameter": "sales/squote-sorder"
         },
         {
             "Value": "delete",
@@ -57,17 +57,12 @@
         {
             "Value": "body-copy",
             "Caption": "수주에서 수주로 품목 복사(-)",
-            "Parameter": "purch/porder-porder"
+            "Parameter": "sales/sorder-sorder"
         },
         {
             "Value": "body-copy",
             "Caption": "견적에서 수주로 품목 복사(-)",
-            "Parameter": "purch/pquote-porder"
-        },
-        {
-            "Value": "body-copy",
-            "Caption": "수주에서 매출로 품목 복사",
-            "Parameter": "sales/sorder-sales"
+            "Parameter": "sales/squote-sorder"
         },
         {
             "Value": "multi-delete",
@@ -163,7 +158,7 @@
     "// ListVars": "ListVars[0]-Caption, ListVars[1]-Size(%), ListVars[2]-align",
     "ListVars": [
         {
-            "$Radio": "$Radio",
+            "$Radio": "",
             "$Check": "$Check",
             "ItemCode": "품목코드*",
             "ItemName": "품명*",
@@ -182,7 +177,7 @@
             "SorderMemo": "품목설명(M)"
         },
         {
-            "$Radio": "3",
+            "$Radio": "",
             "$Check": "3",
             "ItemCode": "10",
             "ItemName": "30",
@@ -201,7 +196,7 @@
             "SorderMemo": "10"
         },
         {
-            "$Radio": "center",
+            "$Radio": "",
             "$Check": "center",
             "ItemCode": "left",
             "ItemName": "left",

+ 1 - 5
dabory/para/erp/ko_KR/search/slip-search/sales/sales.json

@@ -65,10 +65,6 @@
             "Value": "quick",
             "Caption": "빠른검색"
         },
-        {
-            "Value": "normal",
-            "Caption": "대표품목-금액검색"
-        },
         {
             "Value": "detailed",
             "Caption": "거래처-품목 상세검색"
@@ -134,7 +130,7 @@
             "SetGroup": "left",
             "Item": "left",
             "Amt": "decimal('sales_amt')",
-            "Status": "left",
+            "Status": "status('sales')",
             "Ref": "left"
         }
     ]

+ 1 - 0
public/js/modals-controller/b-type/body-copy.js

@@ -82,6 +82,7 @@ function is_auto_create_slip_checked() {
 }
 
 async function body_copy($this) {
+    console.log('body_copy');
     mainModalGetsFocus(`#modal-bodycopy.show`, bodyCopy[$('#modal-bodycopy.show').data('class')]);
 
     let slip_no = $($this).data('slip_no');

+ 13 - 7
public/js/modals-controller/b-type/common.js

@@ -35,7 +35,6 @@
     Btype.get_slip_form_init = async function (query_name = undefined) {
         if (isEmpty(query_name)) {
             query_name = formB['QueryVars']['QueryName']
-            // console.log('query_name : ', query_name);
         }
         const response = await get_api_data('slip-form-init', {
             QueryVars: {
@@ -56,7 +55,7 @@
 
     Btype.create_vat_type_select_box_options = async function (page, dom_val = '#vat-type-select') {
         // let page = await get_select_box_options_data('vat-rate-page', '')
-        // console.log(page)
+        console.log(page)
         let html =  page.reduce(function (accumulator, item) {
             return accumulator + `
                 <option value="${item.Id}" data-vatrate="${item.VatRate}" data-viewvatrate="${item.VatRate * 100}"
@@ -131,7 +130,6 @@
         let url = eval(namespace).formB.General.ActApi;
 
         if (! isEmpty(act_api)) { url = act_api; }
-
         $('.save-button').prop('disabled', true);
         $.when(get_api_data(url, {
             Page: [
@@ -162,6 +160,7 @@
 
     // input 요소를 통해 상위 요소 제어
     Btype.bd_cursor_click = function ($this) {
+        console.log('bd_cursor_click');
         let table = $($this).closest('table');
         let th = $(table).find('thead th');
         let tr = $($this).closest('tr');
@@ -210,10 +209,11 @@
     };
 
     Btype.enterPressedinCell = async function (event, type = 1, namespace = 'window') {
+        console.log('enterPressedinCell');
         if ((event.which && event.which == 13) || event.keyCode && event.keyCode == 13) {
             document.activeElement.blur();
             let query, input_class;
-
+            console.log('enterPressedinCell : ', type);
             switch (type) {
                 case 1:
                     query = `item_code='${$(event.target).val()}'`
@@ -230,6 +230,8 @@
                 }
             })
 
+            console.log('response : ', response);
+
             if (response.data.PageVars['QueryCnt'] != 1) {
                 window.input_box_reset_for('#modal-item .modal-body')
                 $('#modal-item').find(input_class).val($(event.target).val())
@@ -311,6 +313,7 @@
     };
 
     Btype.handleEnterPressedinTabCell = function (event) {
+        console.log('handleEnterPressedinTabCell');
         if ((event.which && event.which == 13) || event.keyCode && event.keyCode == 13) {
             let table = $(event.target).closest('table');
             let cursor = $($(event.target).closest('tr')).find('td:eq(0) input').attr('name')
@@ -606,6 +609,7 @@
     };
 
     Btype.check_the_checkbox_when_changing = function ($this, checked = true, namespace = 'window') {
+        console.log('check_the_checkbox_when_changing');
         let tr = $($this).closest('tr');
         let index = $(tr).prevAll().length
 
@@ -634,6 +638,7 @@
     };
 
     Btype.fetch_slip_form_book = async function (slip_no, namespace = 'window', callback = undefined) {
+
         let response = await call_slip_form_book(eval(namespace).formB['General']['PickApi'],
             eval(namespace).formB['QueryVars']['QueryName'], slip_no, menuCode);
 
@@ -673,6 +678,7 @@
             });
             return;
         }
+
         Btype.call_act_api(eval(namespace).get_parameter(), function() {
             eval(namespace).btn_act_new();
         }, undefined, argObj, namespace);
@@ -687,11 +693,10 @@
             });
             return false;
         }
-
-        test = Btype.call_act_api(eval(namespace).get_parameter(), function() {
+        console.log('save : ', get_parameter());
+        Btype.call_act_api(eval(namespace).get_parameter(), function() {
             if (! isEmpty(callback)) { callback(); }
         }, undefined, argObj, namespace);
-
         return true;
     };
     // end head act btn
@@ -710,6 +715,7 @@
         });
         const page = response.data.Page
         if (page) {
+            console.log('page : ', page);
             set_as_response_id(page[0].Id, argObj)
             return true
         } else {

+ 5 - 1
public/js/modals-controller/b-type/copy-to-another.js

@@ -114,6 +114,9 @@ async function copy_to_another() {
                 ]
             });
         }
+        console.log('response : ',response);
+    }else{
+        console.log('test : ', $('#modal-copy-to-another.show').find('.target-slip-no-btn').attr('disabled'));
     }
 
     let class_name = $('#modal-copy-to-another.show').data('class')
@@ -123,7 +126,8 @@ async function copy_to_another() {
 
     console.log(copy_data)
     fetch_copy_to_another(moealSetFile.General.ActApi, copy_data, function (response) {
-        console.log(response)
+        console.log("moealSetFile.General.ActApi", moealSetFile.General.ActApi)
+        console.log("copy_data", copy_data)
         let d = response.data
         if (d.Hd) {
             iziToast.success({

+ 0 - 17
public/js/modals-controller/b-type/slip.js

@@ -74,23 +74,6 @@ const slip = (function ($, window, document, undefined) {
 
         $(id).find('.slip-save-spinner-btn').show()
         $(id).find('.slip-search-btn').hide()
-        console.log(moealSetFile['General']['PageApi']);
-        console.log('FilterName : ', $(id).find('#filter-name-select').val());
-        console.log('FilterValue : ', $(id).find('#filter-value-txt').val());
-        console.log('SimpleFilter : ', $(id).find('#simple-filter-select').val());
-        console.log('StartDate : ', start_date);
-        console.log('EndDate : ', end_date);
-        console.log('QuerySpeed : ', $(id).find(`input:radio[name=${modal_class_name}query-speed]:checked`).val());
-        console.log('SlipNo : ', $(id).find('.slip-no').val());
-        console.log('CompanyName : ', $(id).find('.company-name').val());
-        console.log('ItemCode : ', $(id).find('.item-code').val());
-        console.log('OrderBy : ', $(id).find('.modal-order-by-select').val());
-
-        console.log('SlipDateField : ', moealSetFile['SlipSearchFields']['SlipDateField']);
-        console.log('SlipNoField : ', moealSetFile['SlipSearchFields']['SlipNoField']);
-
-        console.log('Limit : ', parseInt(limit));
-        console.log('Offset : ', parseInt(offset));
 
         $.when(get_api_data(moealSetFile['General']['PageApi'], {
             QueryVars: {

+ 15 - 0
resources/views/front/dabory/erp/master-data/company.blade.php

@@ -234,6 +234,21 @@
             }
         });
 
+        $('#full-name-txt').on('click', function(){
+            var companyName = $('#company-name-txt').val();
+            if(companyName){
+                $('#full-name-txt').val(companyName);
+            }
+        })
+
+        $('#president-txt').on('click', function(){
+            var mainContact = $('#main-contact-txt').val();
+            if(mainContact){
+                $('#president-txt').val(mainContact);
+            }
+        })
+
+
         $('#company-form').find('#remarks-txt-area').on('dblclick', function () {
             $('#froala-editor').data('preview_id', '#remarks-preview')
             $('#froala-editor').data('txtarea_id', '#remarks-txt-area')

+ 57 - 45
resources/views/front/dabory/erp/purchase/porder.blade.php

@@ -2,6 +2,8 @@
 @section('title', $formB['General']['Title'])
 @section('content')
 
+
+
 <div class="content purchase">
     <div class="row">
         <div class="col-xl-12">
@@ -124,9 +126,11 @@
                                         <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'] }}>
-                                            <option value=""></option>
-                                            <option value="{{ $formB['StatusOptions'][0]['Value'] }}">{{ $formB['StatusOptions'][0]['Caption'] }}</option>
-                                            <option value="{{ $formB['StatusOptions'][1]['Value'] }}">{{ $formB['StatusOptions'][1]['Caption'] }}</option>
+                                            @foreach ($codeTitle['status']['porder'] as $key => $status)
+                                                <option value="{{ $status['Code'] }}">
+                                                    {{ $status['Title'] }}
+                                                </option>
+                                            @endforeach
                                         </select>
                                     </div>
                                 </div>
@@ -351,10 +355,9 @@
             $('#porder-date').val(date_to_sting(new Date()))
 
             Btype.get_storage_name_and_branch_name()
-            let data = await Btype.get_slip_form_init()
-            // console.log(data)
-
-            slipInit = await Btype.get_slip_form_init()
+            // let data = await Btype.get_slip_form_init()
+            // slipInit = await Btype.get_slip_form_init()
+            slipInit = @json($slipFormInitCacheData);
             // formB['SlipCommonSetup'] = data['SlipCommonSetup']
             formB['SlipCommonSetup'] = slipInit['SlipCommonSetup']
             await Btype.create_deal_type_select_box_options(slipInit.DealTypePage)
@@ -489,6 +492,7 @@
                 SeqNo: bd.SeqNo,
                 ItemId: parseInt(bd.ItemId),
                 PorderQty: String(bd.PorderQty),
+                PurchBalQty : String(bd.PorderQty),
                 PorderPrc: String(bd.PorderPrc),
                 PorderSupply: String(bd.PorderSupply),
                 PorderVat: String(bd.PorderVat),
@@ -501,9 +505,9 @@
                 Ref2: bd.Ref2,
                 PorderMemo: bd.PorderMemo,
                 IsEnd: parseInt(bd.IsEnd),
-                Ip: window.User['Ip']
+                Ip: window.User['Ip'],
+                FirstThumb: bd.TurboThumb
             }
-
             if (id < 0) {
                 parameter = { Id: id }
             } else if (id > 0) {
@@ -533,30 +537,31 @@
         }
 
         async function add_td_last_tap_out($this, id) {
-            let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
-            let index = $(tr).prevAll().length
-
-            // 필수텍스트가 안비어있으고 fouces out == 다음 tr 추가
-            if (bd_page[index].ItemId != 0 && ! dom_required_check($(tr).find(`input`))) {
-                if ($($this).data('last')) {
-                    let seq_no = await Btype.get_last_seq_no('porder', $('#auto-slip-no-txt').val())
-                    bd_page[index].SeqNo = seq_no;
+            Btype.btn_act_save('#squote-form #frm', async function () {
+                let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
+                let index = $(tr).prevAll().length
+
+                // 필수텍스트가 안비어있으고 fouces out == 다음 tr 추가
+                if (bd_page[index].ItemId != 0 && ! dom_required_check($(tr).find(`input`))) {
+                    if ($($this).data('last')) {
+                        let seq_no = await Btype.get_last_seq_no('porder', $('#auto-slip-no-txt').val())
+                        bd_page[index].SeqNo = seq_no;
+                    }
+
+                    Btype.call_bd_act_api([ get_bd_parameter(bd_page[index]) ], function (page) {
+                        bd_page[index].Id = page[0].Id;
+
+                        Btype.body_act_success_callback($this, tr);
+                        Btype.check_the_checkbox_when_changing($this, false)
+                        // Btype.btn_act_save('#porder-form #frm');
+                    });
+                } else {
+                    iziToast.error({
+                        title: 'Error',
+                        message: @json(_e('(*)Required item(s) omitted')),
+                    });
                 }
-
-                Btype.call_bd_act_api([ get_bd_parameter(bd_page[index]) ], function (page) {
-                    bd_page[index].Id = page[0].Id;
-
-                    Btype.body_act_success_callback($this, tr);
-                    Btype.check_the_checkbox_when_changing($this, false)
-                });
-                console.log('필수데이터 노누락');
-            } else {
-                console.log('필수데이터 누락');
-                iziToast.error({
-                    title: 'Error',
-                    message: @json(_e('(*)Required item(s) omitted')),
-                });
-            }
+            });
         }
 
         // start body act btn
@@ -564,8 +569,6 @@
             // if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0 && formB['SlipCommonSetup']['IsAutoSaveHdByItemButton']) {
             if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0) {
                 if (! await Btype.btn_act_add_chain('#porder-form #frm')) { return }
-            }else{
-                console.log('formb.SlipCommonSetup : ', formB['SlipCommonSetup']);
             }
 
             if (! Btype.last_item_added_check('#porder-table-body')) {
@@ -658,12 +661,11 @@
         }
 
         function get_parameter() {
-            console.log('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']
             let first_item = ''
-
+            let first_thumb = ''
             if (bd_page.length > 0) {
                 const first_porder = bd_page[0]
                 first_item = first_porder['ItemCode'] + '_' + first_porder['ItemName']
@@ -671,7 +673,18 @@
                     first_item += '_' + first_porder['SubName']
                 }
                 first_item += '(' + bd_page.length + ')'
+
+                if(first_porder['TurboThumb']){
+                    first_thumb = first_porder['TurboThumb']
+                }
             }
+            const itmtot_amt = bd_page.reduce((accumulator, bd) => {
+                return accumulator + parseFloat(bd.PorderSupply) + parseFloat(bd.PorderVat) // 합계금액 (공급가액 + 세액)
+            }, 0)
+
+            const total_qty = bd_page.reduce((accumulator, bd) => {
+                return accumulator + parseFloat(bd.PorderQty) //발주수량
+            }, 0)
 
             let id = parseInt($(`#frm`).find(`input[name="Id"]`).val());
             let parameter = {
@@ -708,10 +721,11 @@
                 DealName: deal_name,
                 VatRate: vat_rate,
                 VatName: vat_name,
-                SgroupName: window.User['SgroupName']
+                SgroupName: window.User['SgroupName'],
+                TotalQty : String(Number(total_qty) - 0),
+                FirstThumb : first_thumb
             }
 
-            console.log('parameter : ', parameter);
             if (id < 0) {
                 parameter = { Id: id }
             } else if (id > 0) {
@@ -753,7 +767,6 @@
 
         function bd_update_due_to_vat_rate_change() {
             let data = [];
-
             bd_page = bd_page.filter(function (bd) {
                 return bd.Id != 0;
             });
@@ -778,7 +791,6 @@
         }
 
         function set_vat_type_rate($this, msg = true) {
-            console.log('set_vat_type_rate');
             let vate_rate = $($this).find('option:selected').data('viewvatrate');
             $('#vat-type-rate-text').val(vate_rate + '%')
 
@@ -1071,14 +1083,14 @@
                     data-last=true onfocusout="add_td_last_tap_out(this, ${last_bd_id_inc})"
                     class="text-${formB.ListVars['Align'].Ref2}" ${formB.ListVars['Hidden'].Ref2}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].Ref2} border-0 bg-white"readonly
+                    <input type="text" class="text-${formB.ListVars['Align'].Ref2} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="save_data_when_entering_text()">
                 </td>
                 <td
                     class="text-${formB.ListVars['Align'].PorderMemo}" ${formB.ListVars['Hidden'].PorderMemo}>
                     <textarea style="max-height: 30px;" class="rounded w-100 bg-white memo-textarea"
-                        ondblclick="Btype.dblclick_memo_textarea(this, ${last_bd_id_inc})" id="memo-textarea-${last_bd_id_inc}" role="button" readonly></textarea>
+                        ondblclick="Btype.dblclick_memo_textarea(this, ${last_bd_id_inc})" id="memo-textarea-${last_bd_id_inc}" role="button"></textarea>
                 </td>
             </tr>`;
 
@@ -1120,7 +1132,7 @@
             $(tr).children('td:eq(3)').find('input').val(item.ItemName)
             $(tr).children('td:eq(4)').text(item.SubName)
             $(tr).children('td:eq(5)').text(item.CountUnit)
-            $(tr).children('td:eq(6)').find('input').val(1)
+            $(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.PurchPrc).toFixed(window.User['PurchPrcPoint']))
             let index = $(tr).prevAll().length;
@@ -1131,6 +1143,7 @@
             bd_page[index].CountUnit = item.CountUnit
             bd_page[index].PorderPrc = item.PurchPrc
             bd_page[index].StdPurchPrc = item.PurchPrc// override_amt_calc_txt_is_changed();
+            bd_page[index].TurboThumb = item.TurboThumb
 
             if (bd_page[index].Id === 0) {
                 $(tr).children('td:eq(16)').find('textarea').val(item.ItemMemo)
@@ -1145,12 +1158,11 @@
                 $('#modal-slip').modal('hide');
                 return;
             }
+
             Btype.set_slip_no_btn_disabled()
 
             let hd_page = response.data.HdPage[0]
             bd_page = response.data.BdPage ?? []
-            // console.log(hd_page)
-            // console.log(bd_page)
 
             $('#Id').val(hd_page.Id)
             $('#auto-slip-no-txt').val(hd_page.PorderNo)

+ 1124 - 0
resources/views/front/dabory/erp/revenue/sales.blade copy.php

@@ -0,0 +1,1124 @@
+@extends('layouts.master')
+@section('title', $formB['General']['Title'])
+@section('content')
+
+<div class="content revenue">
+    <div class="row">
+        <div class="col-xl-12">
+            <div class="mb-1 pt-2 text-right">
+                <button type="button" hidden
+                    class="btn btn-success btn-open-modal item-modal-btn"
+                    data-target="item"
+                    data-clicked="Btype.get_item_id"
+                    data-variable="itemModal">
+                </button>
+
+                <button type="button" hidden
+                    class="btn btn-success btn-open-modal modal-btn">
+                </button>
+
+                <button type="button"
+                    class="btn btn-success btn-open-modal"
+                    data-target="slip"
+                    data-clicked="Btype.fetch_slip_form_book"
+                    data-variable="salesModal">
+                    <i class="icon-folder-open"></i>
+                </button>
+                <button type="button" class="btn btn-sm btn-primary save-spinner-btn">
+                    <span class="save-spinner spinner-border spinner-border-sm text-center" role="status" aria-hidden="true"></span>
+                        Loading...
+                </button>
+                <div class="btn-group" hidden>
+                    <button type="button" class="btn btn-sm btn-primary sales-act save-button" data-value="save" {{ $formB['FormVars']['Hidden']['SaveButton'] }}>
+                        {{ $formB['FormVars']['Title']['SaveButton'] }}
+                    </button>
+                    @include('front.dabory.erp.partial.select-btn-options', [
+                        'selectBtns' => $formB['HeadSelectOptions'],
+                        'eventClassName' => 'sales-act',
+                    ])
+                </div>
+            </div>
+
+            <div class="card" id="sales-form">
+                <div class="card-header" id="frm">
+                    <div class="row">
+                        <div class="col-12 col-md-4 col-lg card-header-item">
+                            <div class="card card card-primary mb-3 mb-md-2 mb-lg-0 border-light" style="height: 310px">
+                                <div class="card-header p-0 mb-2">
+                                </div>
+                                <div class="card-body">
+                                    <input type="hidden" id="Id" name="Id" value="0">
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0 overflow-hidden text-nowrap">{{ $formB['FormVars']['Title']['AutoSlipNo'] }}</label>
+                                        <div class="col-12 d-flex p-0">
+                                        {{-- <button id="auto-slip-no-btn" class="btn-dark border-white rounded overflow-hidden col-3 text-center text-white text-nowrap radius-r0"--}}
+                                        {{--       onclick="get_last_slip_no(this)">--}}
+                                        {{--       <span class="icon-cogs"></span>--}}
+                                        {{--    </button>                           --}}
+                                            <input type="text" id="auto-slip-no-txt" class="rounded w-100 radius-l0" autocomplete="off" disabled
+                                                   maxlength="{{ $formB['FormVars']['MaxLength']['AutoSlipNo'] }}"
+                                                {{ $formB['FormVars']['Required']['AutoSlipNo'] }}>
+                                        </div>
+                                    </div>
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['SalesDate'] }}</label>
+                                        <input class="rounded w-100" type="date" value="" id="sales-date"
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['SalesDate'] }}"
+                                            {{ $formB['FormVars']['Required']['SalesDate'] }}>
+                                    </div>
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0 ">{{ $formB['FormVars']['Title']['StockDate'] }}</label>
+                                        <input class="rounded w-100" type="date" value="" id="stock-date"
+                                               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']['SorderNo'] }}</label>
+                                        <input class="rounded w-100" type="text" id="sorder-no-txt" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['SorderNo'] }}"
+                                            {{ $formB['FormVars']['Required']['SorderNo'] }}>
+                                    </div>
+                                    <div class="form-group d-flex flex-column">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['Status'] }}</label>
+                                        <input type="text" id="status-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['Status'] }}"
+                                            {{ $formB['FormVars']['Required']['Status'] }}>
+
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                        <div class="col-12 col-md-4 col-lg card-header-item">
+                            <div class="card card card-info mb-3 mb-md-2 mb-lg-0 border-light" style="height: 310px">
+                                <div class="card-header p-0 mb-2">
+                                </div>
+                                <div class="card-body">
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['DealType'] }}</label>
+                                        <input type="text" id="deal-type-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['DealType'] }}"
+                                            {{ $formB['FormVars']['Required']['DealType'] }}>
+                                        {{-- <select class="rounded w-100" id="deal-type-select" disabled>
+                                            <option value=""></option>
+                                        </select> --}}
+                                    </div>
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0 ">{{ $formB['FormVars']['Title']['Supplier'] }}</label>
+                                        <input type="text" id="supplier-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['Supplier'] }}"
+                                            {{ $formB['FormVars']['Required']['Supplier'] }}>
+                                    </div>
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['Contact'] }}</label>
+                                        <input class="rounded w-100" id="supplier-contact-txt" type="text" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['Contact'] }}"
+                                            {{ $formB['FormVars']['Required']['Contact'] }}>
+                                    </div>
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['VatType'] }}</label>
+                                        <input type="text" id="vat-type-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['VatType'] }}"
+                                            {{ $formB['FormVars']['Required']['VatType'] }}>
+                                        <select class="rounded w-100" id="vat-type-select" onchange="set_vat_type_rate(this)" hidden disabled>
+                                            <option value=""></option>
+                                        </select>
+                                    </div>
+                                    <div class="form-group d-flex flex-column">
+                                        <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>
+                            </div>
+                        </div>
+                        <div class="col-12 col-md-4 col-lg card-header-item">
+                            <div class="card card card-success mb-3 mb-md-2 mb-lg-0 border-light" style="height: 310px"><!--260-->
+                                <div class="card-header p-0 mb-2">
+                                    {{-- <p class="card-title p-1 ml-2">거래 조건</p> --}}
+                                </div>
+                                <div class="card-body">
+
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['Delivery'] }}</label>
+                                        <input type="text" id="delivery-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['Delivery'] }}"
+                                            {{ $formB['FormVars']['Required']['Delivery'] }}>
+                                        {{-- <select class="rounded w-100" id="delivery-select" disabled>
+                                            <option value=""></option>
+                                        </select> --}}
+                                    </div>
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['PayTerms'] }}</label>
+                                        <input type="text" id="payTerms-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['PayTerms'] }}"
+                                            {{ $formB['FormVars']['Required']['PayTerms'] }}>
+                                        {{-- <select class="rounded w-100" id="payTerms-select" disabled>
+                                            <option value=""></option>
+                                        </select> --}}
+                                    </div>
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['Destination'] }}</label>
+                                        <input type="text" id="destination-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['Destination'] }}"
+                                            {{ $formB['FormVars']['Required']['Destination'] }}>
+                                        {{-- <select class="rounded w-100" id="destination-select" disabled>
+                                            <option value=""></option>
+                                        </select> --}}
+                                    </div>
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['Column1'] }}</label>
+                                        <input type="text" id="column1-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['Column1'] }}"
+                                            {{ $formB['FormVars']['Required']['Column1'] }}>
+                                        {{-- <select class="rounded w-100" id="column1-select" disabled>
+                                            <option value=""></option>
+                                        </select> --}}
+                                    </div>
+                                    <div class="form-group d-flex flex-column">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['Column2'] }}</label>
+                                        <input type="text" id="column2-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['Column2'] }}"
+                                            {{ $formB['FormVars']['Required']['Column2'] }}>
+                                        {{-- <select class="rounded w-100" id="column2-select" disabled>
+                                            <option value=""></option>
+                                        </select> --}}
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                        <div class="col-12 col-md-4 col-lg card-header-item">
+                            <div class="card card card-danger mb-3 mb-md-0 border-light" style="height: 310px">
+                                <div class="card-header p-0 mb-2">
+                                    {{-- <p class="card-title p-1 ml-2">기타</p> --}}
+                                </div>
+                                <div class="card-body">
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['Remarks'] }}</label>
+                                        <textarea style="height: 85px" class="rounded w-100 bg-white" id="remarks-txt-area" role="button" readonly></textarea>
+                                        <div class="fr-view" id="remarks-preview" hidden></div>
+                                    </div>
+                                    <div class="form-group d-flex flex-column">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['IsClosed'] }}</label>
+                                        <input class="rounded" type="checkbox" id="is-closed-check" value="1" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['IsClosed'] }}"
+                                            {{ $formB['FormVars']['Required']['IsClosed'] }}>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                        <div class="col-12 col-md-4 col-lg card-header-item">
+                            <div class="card card card-danger mb-0 border-light" style="height: 310px">
+                                <div class="card-header p-0 mb-2">
+                                </div>
+                                <div class="card-body">
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['SgroupName'] }}</label>
+                                        <input type="text" id="sgroup-name-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['SgroupName'] }}"
+                                            {{ $formB['FormVars']['Required']['SgroupName'] }}>
+                                        {{-- <select class="rounded w-100" data-closed="0" id="sgroup-id-select" disabled>
+                                            <option value=""></option>
+                                        </select> --}}
+                                    </div>
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['UserName'] }}</label>
+                                        <input class="rounded w-100" type="text" id="user-txt" disabled
+                                               maxlength="{{ $formB['FormVars']['MaxLength']['UserName'] }}"
+                                            {{ $formB['FormVars']['Required']['UserName'] }}>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+
+                <div class="card-body p-0 mt-2 mx-2">
+                    <div id="">
+                        <div class="d-flex justify-content-end">
+                            <button class="btn btn-primary mr-1" id="down-btn" onclick="override_seq_no_up_down('down')"
+                                data-clicked="">▼
+                            </button>
+                            <button class="btn btn-primary mr-1" id="up-btn" onclick="override_seq_no_up_down('up')"
+                                data-clicked="">▲
+                            </button>
+
+                            @if ($formB['FormVars']['Hidden']['AddNewBdButton'] == 'hidden')
+                                <div class="btn-group">
+                                    <button class="btn btn-sm btn-primary sales-bd-act" data-parameter="{{ $formB['BodySelectOptions'][0]['ParameterName'] ?? '' }}" data-value="{{ $formB['BodySelectOptions'][0]['Value'] }}">
+                                            {{ $formB['BodySelectOptions'][0]['Caption'] }}
+                                    </button>
+
+                                    @include('front.dabory.erp.partial.select-btn-options', [
+                                        'selectBtns' => array_slice($formB['BodySelectOptions'], 1),
+                                        'eventClassName' => 'sales-bd-act'
+                                    ])
+                                </div>
+                            @else
+                                <div class="btn-group">
+                                    <button class="btn btn-sm btn-primary sales-bd-act" data-value="add">
+                                        {{ $formB['FormVars']['Title']['AddNewBdButton'] }}
+                                    </button>
+
+                                    @include('front.dabory.erp.partial.select-btn-options', [
+                                        'selectBtns' => $formB['BodySelectOptions'],
+                                        'eventClassName' => 'sales-bd-act'
+                                    ])
+                                </div>
+                            @endif
+                        </div>
+
+                        <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', [
+                                        'listVars' => $formB['ListVars'],
+                                        'checkboxName' => 'bd-cud-check'
+                                    ])
+                                </thead>
+                                <tbody id="sales-table-body">
+                                </tbody>
+                            </table>
+                        </div>
+
+                        <div class="table-footer justify-content-between col-12 d-flex flex-column flex-md-row align-items-start align-items-stretch mb-2 p-2 border mt-2 rounded">
+                            <div class="d-flex flex-column flex-md-row ml-0 ml-md-4">
+                                <div class="d-flex align-items-stretch flex-column  mb-2 mb-md-0 px-2">
+                                    <label class="w-100 overflow-hidden text-nowrap m-0 p-0" {{ $formB['FooterVars']['Hidden']['StorageName'] }}
+                                        rowspan="1" colspan="1">
+                                        {{ $formB['FooterVars']['Title']['StorageName'] }}
+                                    </label>
+                                    <input type="text" class="w-100 w-md-80 rounded text-left" id="StorageName" disabled>
+                                </div>
+                                <div class="d-flex align-items-stretch flex-column  mb-2 mb-md-0 px-2">
+                                    <label class="w-100 overflow-hidden text-nowrap m-0 p-0" {{ $formB['FooterVars']['Hidden']['BranchName'] }}
+                                        rowspan="1" colspan="1">
+                                        {{ $formB['FooterVars']['Title']['BranchName'] }}
+                                    </label>
+                                    <input type="text" class="w-100 w-md-80 rounded text-left" id="BranchName" disabled>
+                                </div>
+                            </div>
+                            <div class="d-flex flex-column flex-md-row">
+                                <div class="d-flex align-items-stretch flex-column  mb-2 mb-md-0 px-2">
+                                    <label class="w-100 overflow-hidden text-nowrap m-0 p-0" {{ $formB['FooterVars']['Hidden']['QtyTotal'] }}
+                                        rowspan="1" colspan="1">
+                                        {{ $formB['FooterVars']['Title']['QtyTotal'] }}
+                                    </label>
+                                    <input type="text" class="w-100 w-md-80 rounded" id="QtyTotal" disabled>
+                                </div>
+                                <div class="d-flex align-items-stretch flex-column  mb-2 mb-md-0 px-2">
+                                    <label class="w-100 overflow-hidden text-nowrap m-0 p-0" {{ $formB['FooterVars']['Hidden']['SupplyTotal'] }}
+                                        rowspan="1" colspan="1">
+                                        {{ $formB['FooterVars']['Title']['SupplyTotal'] }}
+                                    </label>
+                                    <input type="text" class="w-100 w-md-80 rounded" id="SupplyTotal" disabled>
+                                </div>
+                                <div class="d-flex align-items-stretch flex-column  mb-2 mb-md-0 px-2">
+                                    <label class="w-100 overflow-hidden text-nowrap m-0 p-0" {{ $formB['FooterVars']['Hidden']['VatTotal'] }}
+                                        rowspan="1" colspan="1">
+                                        {{ $formB['FooterVars']['Title']['VatTotal'] }}
+                                    </label>
+                                    <input type="text" class="w-100 w-md-80 rounded" id="VatTotal" disabled>
+                                </div>
+                                <div class="d-flex align-items-stretch flex-column  mb-2 mb-md-0 px-2">
+                                    <label class="w-100 overflow-hidden text-nowrap m-0 p-0" {{ $formB['FooterVars']['Hidden']['SumTotal'] }}
+                                        rowspan="1" colspan="1">
+                                        {{ $formB['FooterVars']['Title']['SumTotal'] }}
+                                    </label>
+                                    <input type="text" class="w-100 w-md-80 rounded" id="SumTotal" disabled>
+                                </div>
+                            </div>
+                        </div>
+
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+@endsection
+
+@foreach ($formB['HeadSelectOptions'] as $selectOption)
+    @if (! empty($selectOption['Parameter']))
+        @push('modal')
+            @include($selectOption['BladeRoute'], [
+                'moealSetFile' => $selectOption['Parameter'],
+                'modalClassName' => $selectOption['ModalClassName']
+            ])
+        @endpush
+    @endif
+@endforeach
+
+@foreach ($formB['BodySelectOptions'] as $selectOption)
+    @if (! empty($selectOption['Parameter']))
+        @push('modal')
+            @include($selectOption['BladeRoute'], [
+                'moealSetFile' => $selectOption['Parameter'],
+                'modalClassName' => $selectOption['ModalClassName']
+            ])
+        @endpush
+    @endif
+@endforeach
+
+@section('modal')
+    @include('front.outline.static.slip', ['moealSetFile' => $salesModal])
+    @include('front.outline.static.company', ['moealSetFile' => $companyModal])
+    @include('front.outline.static.item', ['moealSetFile' => $itemModal])
+    @include('front.outline.static.memo2')
+@endsection
+
+@section('js')
+<script src="{{ csset('/js/modals-controller/b-type/common.js') }}"></script>
+    <script>
+        window.onload = async function () {
+            make_dynamic_table_css('.sales-table', make_dynamic_table_px(formB['ListVars']['Size']))
+            // slip-search cache 사용
+            // Btype.set_slip_cache_data();
+
+            slipInit = await Btype.get_slip_form_init()
+            console.log('slipInit : ', slipInit);
+            // slipInit = @json($slipFormInitCacheData);
+            // formB['SlipCommonSetup'] = slipInit['SlipCommonSetup']
+            // await Btype.create_deal_type_select_box_options(slipInit.DealTypePage)
+            // await Btype.create_vat_type_select_box_options(slipInit.VatRatePage)
+            // await create_etc_select_box_options(slipInit)
+
+            // if (formB['SlipCommonSetup']['IsNewRecAutoSlipNo']) {
+            //     $('.is-new-rec-auto-slip-no').text('자동채번')
+            //     $('#auto-slip-no-txt').prop('disabled', true)
+            //     // get_last_slip_no()
+            // }
+
+
+            Btype.set_slip_no_btn_disabled()
+            $('#sales-date').val(date_to_sting(new Date()))
+            $('#stock-date').val(date_to_sting(new Date()))
+
+            // if (! isEmpty(pickCacheData['query'])) {
+            //     let query = JSON.parse(pickCacheData['query'])
+            //     await Btype.fetch_slip_form_book(query['QueryVars']['FilterValue']);
+            // }
+
+            $('.sales-act').on('click', function () {
+                // console.log($(this).data('value'))
+                switch( $(this).data('value') ) {
+                    case 'save': Btype.btn_act_save('#sales-form #frm'); 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('#sales-form #frm'); break;
+                    case 'rpt-print': Btype.rpt_print(); break;
+                    case 'rpt-custom': Btype.rpt_custom(); break;
+                }
+            });
+
+            $('.sales-bd-act').on('click', function () {
+                switch( $(this).data('value') ) {
+                    case 'add': btn_bd_act_add(); break;
+                    case 'body-copy': btn_bd_act_body_copy(str_replace_hyphen($(this).data('parameter'), '/')); break;
+                    case 'multi-delete': override_btn_bd_act_multi_delete(); break;
+                    case 'multi-update': override_btn_bd_act_multi_update(); break;
+                }
+            });
+
+            $('#remarks-txt-area').on('dblclick', function () {
+                $('#modal-memo2').find('#memo-textarea').val('')
+                $('#modal-memo2').data('txtarea_id', '#remarks-txt-area')
+
+                $('#modal-memo2').find('#memo-textarea').val($('#remarks-txt-area').val())
+                $('#modal-memo2').modal('show')
+            });
+
+            activate_button_group()
+
+        }
+
+        async function override_seq_no_up_down(move) {
+            let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
+            let index = $(tr).prevAll().length
+            let bd = bd_page[index]
+
+            if (isEmpty(bd) || parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0) {
+                iziToast.error({
+                    title: 'Error',
+                    message: @json(_e('Can NOT move UP or DOWN in the status')),
+                });
+                return;
+            }
+
+            let data = {
+                BdTableName: 'dbr_sales_bd',
+                HdIdName: 'sales_id',
+                HdId: parseInt(bd.SalesId),
+                CurrId: parseInt(bd.Id),
+                Move: move,
+            }
+
+            $('#down-btn').prop('disabled', true);
+            $('#up-btn').prop('disabled', true);
+            await Btype.seq_no_up_down(move, data, '#sales-table-body', index)
+            $('#down-btn').prop('disabled', false);
+            $('#up-btn').prop('disabled', false);
+        }
+
+        // start body act btn
+        function override_btn_bd_act_multi_update() {
+            Btype.btn_bd_act_multi_update('.sales-table')
+        }
+
+        function override_btn_bd_act_multi_delete() {
+            Btype.btn_bd_act_multi_delete('.sales-table')
+        }
+
+
+        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('#sales-table-body')) {
+                add_tr();
+            }
+        }
+
+        function btn_bd_act_body_copy(parameter_name) {
+            if (parseInt($('#frm').find('#Id').val()) == 0) {
+                iziToast.error({
+                    title: 'Error',
+                    message: @json(_e('Can NOT copy in the status')),
+                });
+                return;
+            }
+
+            $(`#modal-bodycopy.${parameter_name}`).find('.slip_no-txt').val($('#auto-slip-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];
+            $('.revenue').find('.modal-btn').data('target', 'bodycopy')
+            $('.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() )
+        }
+
+        function btn_act_new() {
+            console.log('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()
+            $('#sales-date').val(date_to_sting(new Date()))
+            $('#stock-date').val(date_to_sting(new Date()))
+            $('#sorder-no-txt').val('')
+            $('#sorder-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('')
+            $('#is-closed-check').prop('checked', false)
+
+            $('#sgroup-name-txt').val('')
+            select_box_first_selected('#sgroup-name-select')
+            $('#user-txt').val('')
+            select_box_first_selected('#our-contact-select')
+
+            $('#StorageName').val('')
+            $('#BranchName').val('')
+
+            // table body 초기화
+            table_head_check_box_reset('#sales-table-head')
+            $('#sales-table-body').html('');
+
+            // footer 합계 초기화
+            $('#QtyTotal').val('')
+            $('#SupplyTotal').val('')
+            $('#VatTotal').val('')
+            $('#SumTotal').val('')
+
+            // if (formB['SlipCommonSetup']['IsNewRecAutoSlipNo']) {
+                get_last_slip_no()
+            // }
+        }
+
+        function btn_act_copy_to_another(parameter_name) {
+            let data = formB['HeadSelectOptions'].filter(selectOption => selectOption['ModalClassName'] == parameter_name)[0];
+            // $(`#modal-copy-to-another.${parameter_name}`).find('.target-slip-no-txt').data('slip-no', $('#auto-slip-no-txt').val())
+            $(`#modal-copy-to-another.${parameter_name}`).find('.source-slip-no-txt').val($('#auto-slip-no-txt').val())
+
+            $('.revenue').find('.modal-btn').data('target', 'copy-to-another')
+            $('.revenue').find('.modal-btn').data('variable', data['Parameter'])
+            $('.revenue').find('.modal-btn').data('class', parameter_name)
+            $('.revenue').find('.modal-btn').trigger('click')
+        }
+
+        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']
+            let first_item = ''
+            let first_thumb = ''
+            if (bd_page.length > 0) {
+                const first_sales = bd_page[0]
+                first_item = first_sales['ItemCode'] + '_' + first_sales['ItemName']
+                if (first_sales['SubName']) {
+                    first_item += '_' + first_sales['SubName']
+                }
+                first_item += '(' + bd_page.length + ')'
+
+                if(first_sales['TurboThumb']){
+                    first_thumb = first_sales['TurboThumb']
+                }
+            }
+            // console.log('first_sales : ', bd_page[0]);
+            const itmtot_amt = bd_page.reduce((accumulator, bd) => {
+                return accumulator + parseFloat(bd.SalesSupply) //공급가액
+            }, 0)
+
+            console.log('itmtot_amt : ', itmtot_amt);
+
+            // const total_qty = bd_page.reduce((accumulator, bd) => {
+            //     return accumulator + parseFloat(bd.PorderQty) //발주수량
+            // }, 0)
+            let id = parseInt($(`#frm`).find(`input[name="Id"]`).val());
+            let parameter = {
+                Id: id,
+                CreatedOn: get_now_time_stamp(),
+                UpdatedOn: get_now_time_stamp(),
+                SorderId: parseInt($('#sorder-no-txt').data('id')),
+                SalesNo: $('#auto-slip-no-txt').val(),
+                SalesDate: moment(new Date($('#sales-date').val())).format('YYYYMMDD'),
+                StockDate: moment(new Date($('#stock-date').val())).format('YYYYMMDD'),
+                UserId: window.User['UserId'],
+                Remarks: $('#remarks-txt-area').val(),
+                Ip: window.User['Ip'],
+
+                FirstItem: first_item,
+                ItmtotAmt: String(itmtot_amt),
+                // DiscountAmt: '0',
+                TotalAmt: String(Number(itmtot_amt) - 0),
+                //DealName: deal_name,
+                // VatRate: vat_rate,
+                // VatName: vat_name,
+                // SgroupName: window.User['SgroupName'],
+                //TotalQty : String(Number(total_qty) - 0),
+                FirstThumb : first_thumb
+            }
+            if (id < 0) {
+                parameter = { Id: id }
+            } else if (id > 0) {
+                delete parameter.CreatedOn;
+            } else {
+                delete parameter.UpdatedOn;
+            }
+
+            return parameter;
+        }
+
+        async function get_last_slip_no($this) {
+            Btype.set_slip_no_btn_disabled()
+            let response = await Btype.get_last_slip_no(formB['QueryVars']['QueryName']);
+            $('#auto-slip-no-txt').val(moment(new Date()).format('YYMMDD') + '-' + response.data.LastSlipNo)
+        }
+
+        async function get_override_supplier_id(supplier_id) {
+            await get_supplier_id(supplier_id);
+            $('#supplier-contact-txt').val($('#supplier-txt').data('contact'))
+        }
+
+        function set_vat_type_rate($this, msg = true) {
+            let vate_rate = $($this).find('option:selected').data('viewvatrate');
+            $('#vat-type-rate-text').val(vate_rate + '%')
+
+            if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0 || ! msg) return;
+        }
+
+        function get_bd_parameter(bd) {
+            let id = parseInt(bd.Id);
+
+            let parameter = {
+                Id: id,
+                CreatedOn: get_now_time_stamp(),
+                UpdatedOn: get_now_time_stamp(),
+                SalesId: parseInt(bd.SalesId),
+                SeqNo: bd.SeqNo,
+                SalesQty: String(bd.SalesQty),
+                SalesSupply: String(bd.SalesSupply),
+                SalesVat: String(bd.SalesVat),
+                SalesSum: String(bd.SalesSum),
+                CostPrc: String(bd.CostPrc),
+                Ip: window.User['Ip'],
+                FirstThumb: bd.TurboThumb
+            }
+
+            if (id < 0) {
+                parameter = { Id: id }
+            } else if (id > 0) {
+                delete parameter.CreatedOn;
+            } else {
+                delete parameter.UpdatedOn;
+            }
+
+            return parameter;
+        }
+
+        function amt_total_calc() {
+            let qty_total = 0, supply_total = 0, vat_amt_vat_total = 0, sum_total = 0;
+
+            bd_page.forEach(bd => {
+                qty_total += parseFloat(bd.SalesQty);
+                supply_total += parseFloat(bd.SalesSupply);
+                vat_amt_vat_total += parseFloat(bd.SalesVat);
+                sum_total += parseFloat(bd.SalesSum);
+            })
+
+            $('#QtyTotal').val(format_conver_for(qty_total, formB.ListVars['Format'].SalesQty));
+            $('#SupplyTotal').val(format_conver_for(supply_total, formB.ListVars['Format'].SupplyAmt));
+            $('#VatTotal').val(format_conver_for(vat_amt_vat_total, formB.ListVars['Format'].VatAmt));
+            $('#SumTotal').val(format_conver_for(sum_total, formB.ListVars['Format'].SumAmt));
+        }
+
+        async function add_td_last_tap_out($this, id) {
+            Btype.btn_act_save('#sales-form #frm', async function () {
+                let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
+                let index = $(tr).prevAll().length
+
+                if (bd_page[index].SorderBdId == 0) {
+                    iziToast.error({
+                        title: 'Error',
+                        message: @json(_e('Action failed')),
+                    });
+                    return;
+                };
+
+                // 필수텍스트가 안비어있으고 fouces out == 다음 tr 추가
+                if (! dom_required_check($(tr).find(`input`))) {
+                    if ($($this).data('last')) {
+                        let seq_no = await Btype.get_last_seq_no('sales', $('#auto-slip-no-txt').val())
+                        bd_page[index].SeqNo = seq_no;
+                    }
+                    console.log('get_bd_parameter', get_bd_parameter(bd_page[index]));
+                    Btype.call_bd_act_api([ get_bd_parameter(bd_page[index]) ], function (page) {
+                        bd_page[index].Id = page[0].Id;
+
+                        body_act_success_callback($this, tr);
+                        Btype.check_the_checkbox_when_changing($this, false)
+                    });
+                } else {
+                    iziToast.error({
+                        title: 'Error',
+                        message: @json(_e('(*)Required item(s) omitted')),
+                    });
+                }
+            });
+        }
+
+        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() {
+            console.log('override_amt_calc_txt_is_changed');
+            let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
+            let index = $(tr).prevAll().length
+            let supply_amt, vat_amt, sum_amt;
+
+            Btype.amt_calc_txt_is_changed(tr, function (bd) {
+                [supply_amt, vat_amt, sum_amt] = Btype.amt_calc(bd, parseFloat($('#vat-type-select').find('option:selected').data('vatrate')));
+
+                if (isNaN(bd.pquote_prc)) return;
+
+                $(tr).children('td:eq(6)').find('input').val(format_conver_for(bd.pquote_qty, formB.ListVars['Format'].SalesQty))
+                $(tr).children('td:eq(7)').find('input').val(format_conver_for(bd.pquote_prc, formB.ListVars['Format'].SorderPrc))
+
+                $(tr).children('td:eq(8)').find('input').val(format_conver_for(supply_amt, formB.ListVars['Format'].SupplyAmt))
+                $(tr).children('td:eq(9)').find('input').val(format_conver_for(vat_amt, formB.ListVars['Format'].VatAmt))
+                $(tr).children('td:eq(10)').find('input').val(format_conver_for(sum_amt, formB.ListVars['Format'].SumAmt))
+
+                bd_page[index].SorderPrc = bd.pquote_prc
+                bd_page[index].SalesQty = bd.pquote_qty
+                bd_page[index].SalesSupply = supply_amt
+                bd_page[index].SalesVat = vat_amt
+                bd_page[index].SalesSum = sum_amt
+            })
+        }
+
+        function override_custom_supply_amt_or_vat_amt() {
+            Btype.custom_supply_amt_or_vat_amt(function (supply_amt, vat_amt, sum_amt, index) {
+                bd_page[index].SalesSupply = supply_amt
+                bd_page[index].SalesVat = vat_amt
+                bd_page[index].SalesSum = sum_amt
+            })
+        }
+
+        function override_custom_sum_amt() {
+            Btype.custom_sum_amt(function (sum_amt, index) {
+                bd_page[index].SalesSum = sum_amt
+            })
+        }
+
+        function create_bd_page() {
+            let html = []
+            let qty_total = 0, supply_total = 0, vat_amt_vat_total = 0, sum_total = 0;
+            bd_page.forEach(bd => {
+                qty_total += parseFloat(bd.SalesQty);
+                supply_total += parseFloat(bd.SalesSupply);
+                vat_amt_vat_total += parseFloat(bd.SalesVat);
+                sum_total += parseFloat(bd.SalesSum);
+
+                // 품목코드, 수량, 단가, 공급가액, 세액, 합계금액
+                html.push (
+                `<tr>
+                    <td class="text-${formB.ListVars['Align'].$Radio} px-import-0" ${formB.ListVars['Hidden'].$Radio}>
+                        <input name="bd-cursor-state" type="radio" value="1" tabindex="-1"
+                        class="text-${formB.ListVars['Align'].$Radio}"
+                        onclick="Btype.bd_cursor_click(this)">
+                    </td>
+                    <td class="text-${formB.ListVars['Align'].$Check} px-import-0">
+                        <input name="bd-cud-check" type="checkbox" value="1" tabindex="-1"
+                        class="text-${formB.ListVars['Align'].$Check}">
+                    </td>
+                    <td onkeydown="Btype.enterPressedinCell(event)"
+                        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)">
+                    </td>
+                    <td
+                        class="text-${formB.ListVars['Align'].ItemName}" ${formB.ListVars['Hidden'].ItemName}>${bd.ItemName}
+                    </td>
+                    <td
+                        class="text-${formB.ListVars['Align'].SubName}" ${formB.ListVars['Hidden'].SubName}>${bd.SubName}
+                    </td>
+                    <td
+                        class="text-${formB.ListVars['Align'].CountUnit}" ${formB.ListVars['Hidden'].CountUnit}>${bd.CountUnit}
+                    </td>
+                    <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                        class="text-${formB.ListVars['Align'].SalesQty}" ${formB.ListVars['Hidden'].SalesQty}
+                        >
+                        <input type="text" class="text-${formB.ListVars['Align'].SalesQty} border-0 bg-white" value="${format_conver_for(bd.SalesQty, formB.ListVars['Format'].SalesQty)}" disabled
+                        onchange="Btype.check_the_checkbox_when_changing(this)"
+                        onfocusout="override_amt_calc_txt_is_changed()"
+                        required>
+                    </td>
+                    <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                        class="text-${formB.ListVars['Align'].SorderPrc}" ${formB.ListVars['Hidden'].SorderPrc}
+                        >
+                        <input type="text" class="text-${formB.ListVars['Align'].SorderPrc} border-0 bg-white" value="${format_conver_for(bd.SorderPrc, formB.ListVars['Format'].SorderPrc)}" disabled
+                        onchange="Btype.check_the_checkbox_when_changing(this)"
+                        onfocusout="override_amt_calc_txt_is_changed()">
+                    </td>
+                    <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                        class="text-${formB.ListVars['Align'].SupplyAmt}" ${formB.ListVars['Hidden'].SupplyAmt}
+                        >
+                        <input type="text" class="text-${formB.ListVars['Align'].SupplyAmt} border-0 bg-white" value="${format_conver_for(bd.SalesSupply, formB.ListVars['Format'].SupplyAmt)}" disabled
+                        onchange="Btype.check_the_checkbox_when_changing(this)"
+                        onfocusout="override_custom_supply_amt_or_vat_amt()"
+                        required>
+                    </td>
+                    <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                        class="text-${formB.ListVars['Align'].VatAmt}" ${formB.ListVars['Hidden'].VatAmt}
+                        >
+                        <input type="text" class="text-${formB.ListVars['Align'].VatAmt} border-0 bg-white" value="${format_conver_for(bd.SalesVat, formB.ListVars['Format'].VatAmt)}" disabled
+                        onchange="Btype.check_the_checkbox_when_changing(this)"
+                        onfocusout="override_custom_supply_amt_or_vat_amt()"
+                        required>
+                    </td>
+                    <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                        onfocusout="add_td_last_tap_out(this, ${bd.Id})"
+                        class="text-${formB.ListVars['Align'].SumAmt}" ${formB.ListVars['Hidden'].SumAmt}
+                        >
+                        <input type="text" class="text-${formB.ListVars['Align'].SumAmt} border-0 bg-white" value="${format_conver_for(bd.SalesSum, formB.ListVars['Format'].SumAmt)}" disabled
+                        onchange="Btype.check_the_checkbox_when_changing(this)"
+                        onfocusout="override_custom_sum_amt()"
+                        required>
+                    </td>
+                    <td
+                        class="text-${formB.ListVars['Align'].StdSalesPrc}" ${formB.ListVars['Hidden'].StdSalesPrc}>${format_conver_for(bd.StdSalesPrc, formB.ListVars['Format'].StdSalesPrc)}
+                    </td>
+
+                    <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                        class="text-${formB.ListVars['Align'].DeliDate}" ${formB.ListVars['Hidden'].DeliDate}
+                        >
+                        <input type="date" class="text-${formB.ListVars['Align'].DeliDate} border-0 bg-white" value="${isEmpty(bd.DeliDate) ? '' : moment(bd.DeliDate).format(formB.ListVars['Format'].DeliDate)}" disabled
+                        onchange="Btype.check_the_checkbox_when_changing(this)"
+                        onfocusout="save_data_when_entering_text()">
+                    </td>
+                    <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                        class="text-${formB.ListVars['Align'].Ref1}" ${formB.ListVars['Hidden'].Ref1}
+                        >
+                        <input type="text" class="text-${formB.ListVars['Align'].Ref1} border-0 bg-white" value="${bd.Ref1}" disabled
+                        onchange="Btype.check_the_checkbox_when_changing(this)"
+                        onfocusout="save_data_when_entering_text()">
+                    </td>
+                    <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                        class="text-${formB.ListVars['Align'].Ref2}" ${formB.ListVars['Hidden'].Ref2}
+                        >
+                        <input type="text" class="text-${formB.ListVars['Align'].Ref2} border-0 bg-white" value="${bd.Ref2}" disabled
+                        onchange="Btype.check_the_checkbox_when_changing(this)"
+                        onfocusout="save_data_when_entering_text()">
+                    </td>
+                    <td
+                        class="text-${formB.ListVars['Align'].SorderMemo}" ${formB.ListVars['Hidden'].SorderMemo}>${bd.SorderMemo}
+                    </td>
+                </tr>` )
+            });
+
+            $('#QtyTotal').val(format_conver_for(qty_total, formB.ListVars['Format'].SalesQty));
+            $('#SupplyTotal').val(format_conver_for(supply_total, formB.ListVars['Format'].SupplyAmt));
+            $('#VatTotal').val(format_conver_for(vat_amt_vat_total, formB.ListVars['Format'].VatAmt));
+            $('#SumTotal').val(format_conver_for(sum_total, formB.ListVars['Format'].SumAmt));
+
+            document.getElementById('sales-table-body').innerHTML = html.join('');
+
+        }
+
+        async function add_tr() {
+            let last_bd_id_inc = 0;
+            if (bd_page.length > 0) {
+                last_bd_id_inc = bd_page[bd_page.length - 1].cursorId + 1 || 0
+            }
+
+            let html =
+            `<tr>
+                <td class="text-${formB.ListVars['Align'].$Radio} px-import-0">
+                    <input name="bd-cursor-state" type="radio" value="1" tabindex="-1"
+                    class="text-${formB.ListVars['Align'].$Radio}"
+                    id="bd-cursor-state-${last_bd_id_inc}"
+                    onclick="Btype.bd_cursor_click(this)">
+                </td>
+                <td class="text-${formB.ListVars['Align'].$Check} px-import-0">
+                    <input name="bd-cud-check" type="checkbox" value="1" tabindex="-1"
+                    class="text-${formB.ListVars['Align'].$Check}">
+                </td>
+                <td onkeydown="Btype.enterPressedinCell(event)"
+                    class="text-${formB.ListVars['Align'].ItemCode}" ${formB.ListVars['Hidden'].ItemCode}
+                    >
+                    <input type="text" class="text-${formB.ListVars['Align'].ItemCode} border-0 bg-white" value=""
+                    onchange="Btype.check_the_checkbox_when_changing(this)"
+                    id="item-code-${last_bd_id_inc}">
+                </td>
+                <td
+                    class="text-${formB.ListVars['Align'].ItemName}" ${formB.ListVars['Hidden'].ItemName}>
+                </td>
+                <td
+                    class="text-${formB.ListVars['Align'].SubName}" ${formB.ListVars['Hidden'].SubName}>
+                </td>
+                <td
+                    class="text-${formB.ListVars['Align'].CountUnit}" ${formB.ListVars['Hidden'].CountUnit}>
+                </td>
+                <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                    class="text-${formB.ListVars['Align'].SalesQty}" ${formB.ListVars['Hidden'].SalesQty}
+                    >
+                    <input type="text" class="text-${formB.ListVars['Align'].SalesQty} border-0 bg-white"
+                    onchange="Btype.check_the_checkbox_when_changing(this)"
+                    onfocusout="override_amt_calc_txt_is_changed()"
+                    required>
+                </td>
+                <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                    class="text-${formB.ListVars['Align'].SorderPrc}" ${formB.ListVars['Hidden'].SorderPrc}
+                    >
+                    <input type="text" class="text-${formB.ListVars['Align'].SorderPrc} border-0 bg-white"
+                    onchange="Btype.check_the_checkbox_when_changing(this)"
+                    onfocusout="override_amt_calc_txt_is_changed()">
+                </td>
+                <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                    class="text-${formB.ListVars['Align'].SupplyAmt}" ${formB.ListVars['Hidden'].SupplyAmt}
+                    >
+                    <input type="text" class="text-${formB.ListVars['Align'].SupplyAmt} border-0 bg-white"
+                    onchange="Btype.check_the_checkbox_when_changing(this)"
+                    onfocusout="override_custom_supply_amt_or_vat_amt()"
+                    required>
+                </td>
+                <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                    class="text-${formB.ListVars['Align'].VatAmt}" ${formB.ListVars['Hidden'].VatAmt}
+                    >
+                    <input type="text" class="text-${formB.ListVars['Align'].VatAmt} border-0 bg-white"
+                    onchange="Btype.check_the_checkbox_when_changing(this)"
+                    onfocusout="override_custom_supply_amt_or_vat_amt()"
+                    required>
+                </td>
+                <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                    data-last=true onfocusout="add_td_last_tap_out(this, ${last_bd_id_inc})"
+                    class="text-${formB.ListVars['Align'].SumAmt}" ${formB.ListVars['Hidden'].SumAmt}
+                    >
+                    <input type="text" class="text-${formB.ListVars['Align'].SumAmt} border-0 bg-white"
+                    onchange="Btype.check_the_checkbox_when_changing(this)"
+                    onfocusout="override_custom_sum_amt()"
+                    required>
+                </td>
+                <td
+                    class="text-${formB.ListVars['Align'].StdSalesPrc}" ${formB.ListVars['Hidden'].StdSalesPrc}>
+                </td>
+
+                <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                    class="text-${formB.ListVars['Align'].DeliDate}" ${formB.ListVars['Hidden'].DeliDate}
+                    >
+                    <input type="date" class="text-${formB.ListVars['Align'].DeliDate} border-0 bg-white"
+                    onchange="Btype.check_the_checkbox_when_changing(this)"
+                    onfocusout="save_data_when_entering_text()">
+                </td>
+                <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                    class="text-${formB.ListVars['Align'].Ref1}" ${formB.ListVars['Hidden'].Ref1}
+                    >
+                    <input type="text" class="text-${formB.ListVars['Align'].Ref1} border-0 bg-white"
+                    onchange="Btype.check_the_checkbox_when_changing(this)"
+                    onfocusout="save_data_when_entering_text()">
+                </td>
+                <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                    class="text-${formB.ListVars['Align'].Ref2}" ${formB.ListVars['Hidden'].Ref2}
+                    >
+                    <input type="text" class="text-${formB.ListVars['Align'].Ref2} border-0 bg-white"
+                    onchange="Btype.check_the_checkbox_when_changing(this)"
+                    onfocusout="save_data_when_entering_text()">
+                </td>
+                <td
+                    class="text-${formB.ListVars['Align'].SorderMemo}" ${formB.ListVars['Hidden'].SorderMemo}>
+                </td>
+            </tr>`;
+
+            $('#sales-table-body').append(html)
+
+            await setTimeout( function() {
+                $(`#bd-cursor-state-${last_bd_id_inc}`).trigger('click')
+            }, 100);
+
+            bd_page.push({
+                cursorId: last_bd_id_inc,
+                Id: 0,
+                ItemId: 0,
+                ItemCode: '',
+                ItemName: '',
+                SubName: '',
+                CountUnit: '',
+                SeqNo: 0,
+                SalesId: parseInt($(`#frm`).find(`input[name="Id"]`).val()),
+                SorderBdId: 0,
+                SorderPrc: 0,
+                SalesQty: 0,
+                SalesSupply: 0,
+                SalesVat: 0,
+                SalesSum: 0,
+                StdSalesPrc: 0,
+                CostPrc: 0,
+                DeliDate: '',
+                Ref1: '',
+                Ref2: '',
+                SorderMemo: '',
+            })
+        }
+
+        function update_hd_ui(response) {
+            if (isEmpty(response.data) || response.data.apiStatus) {
+                $('#modal-slip').modal('hide');
+                return;
+            }
+            Btype.set_slip_no_btn_disabled()
+
+            let hd_page = response.data.HdPage[0]
+            bd_page = response.data.BdPage ?? []
+
+            $('#Id').val(hd_page.Id)
+            $('#auto-slip-no-txt').val(hd_page.SalesNo)
+            $('#sales-date').val(moment(to_date(hd_page.SalesDate)).format('YYYY-MM-DD'))
+            $('#stock-date').val(moment(to_date(hd_page.StockDate)).format('YYYY-MM-DD'))
+            $('#sorder-no-txt').val(hd_page.SorderNo)
+            $('#sorder-no-txt').data('id', hd_page.SorderId)
+            $('#status-txt').val(hd_page.Status)
+
+            $('#deal-type-txt').val(format_conver_for(hd_page.DealCode, "deal_type('deal-type')"))
+            $('#supplier-txt').val(hd_page.CompanyName)
+            $('#supplier-txt').data('id', hd_page.SupplierId)
+            $('#supplier-txt').data('contact', hd_page.BuyerContact)
+            $('#supplier-contact-txt').val(hd_page.BuyerContact)
+
+            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-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)
+
+            $('#remarks-txt-area').val(hd_page.Remarks)
+            $('#remarks-preview').html(hd_page.Remarks)
+            $('#is-closed-check').prop('checked', hd_page.IsClosed == '1')
+            $('#is-closed-check').val(hd_page.IsClosed)
+
+            $('#sgroup-name-txt').val(hd_page.SgroupName)
+            $('#user-txt').val(hd_page.NickName)
+
+            $('#StorageName').val(hd_page.StorageName)
+            $('#BranchName').val(hd_page.BranchName)
+
+            // table body에 데이터 추가
+            create_bd_page();
+
+            if (bd_page.length > 0) {
+                let unique = bd_page[bd_page.length - 1].SeqNo * bd_page[bd_page.length - 1].Id + rand(1, 999);
+                bd_page[bd_page.length - 1].cursorId = unique
+            }
+
+            $('#modal-slip').modal('hide');
+        }
+
+        const salesModal = {!! json_encode($salesModal) !!};
+        const companyModal = {!! json_encode($companyModal) !!};
+        const itemModal = {!! json_encode($itemModal) !!};
+        const slipCacheData = {!! json_encode($slipCacheData) !!};
+        const pickCacheData = {!! json_encode($pickCacheData) !!};
+        var formB = {!! json_encode($formB) !!};
+        var bd_page = [];
+        let slipInit = null;
+    </script>
+@endsection

+ 315 - 190
resources/views/front/dabory/erp/revenue/sales.blade.php

@@ -51,10 +51,10 @@
                                     <div class="form-group d-flex flex-column mb-2">
                                         <label class="m-0 overflow-hidden text-nowrap">{{ $formB['FormVars']['Title']['AutoSlipNo'] }}</label>
                                         <div class="col-12 d-flex p-0">
-                                            <button id="auto-slip-no-btn" class="btn-dark border-white rounded overflow-hidden col-3 text-center text-white text-nowrap radius-r0"
-                                                onclick="get_last_slip_no(this)">
-                                                <span class="icon-cogs"></span>
-                                            </button>
+                                        {{-- <button id="auto-slip-no-btn" class="btn-dark border-white rounded overflow-hidden col-3 text-center text-white text-nowrap radius-r0"--}}
+                                        {{--       onclick="get_last_slip_no(this)">--}}
+                                        {{--       <span class="icon-cogs"></span>--}}
+                                        {{--    </button>                           --}}
                                             <input type="text" id="auto-slip-no-txt" class="rounded w-100 radius-l0" autocomplete="off" disabled
                                                    maxlength="{{ $formB['FormVars']['MaxLength']['AutoSlipNo'] }}"
                                                 {{ $formB['FormVars']['Required']['AutoSlipNo'] }}>
@@ -72,18 +72,19 @@
                                                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']['SorderNo'] }}</label>
-                                        <input class="rounded w-100" type="text" id="sorder-no-txt" disabled
-                                               maxlength="{{ $formB['FormVars']['MaxLength']['SorderNo'] }}"
-                                            {{ $formB['FormVars']['Required']['SorderNo'] }}>
-                                    </div>
-                                    <div class="form-group d-flex flex-column">
+                                    <div class="form-group d-flex flex-column ">
                                         <label class="m-0">{{ $formB['FormVars']['Title']['Status'] }}</label>
-                                        <input type="text" id="status-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
-                                               maxlength="{{ $formB['FormVars']['MaxLength']['Status'] }}"
+                                        <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']['sales'] as $key => $status)
+                                                <option value="{{ $status['Code'] }}">
+                                                    {{ $status['Title'] }}
+                                                </option>
+                                            @endforeach
+                                        </select>
                                     </div>
+
                                 </div>
                             </div>
                         </div>
@@ -93,41 +94,26 @@
                                 </div>
                                 <div class="card-body">
                                     <div class="form-group d-flex flex-column mb-2">
-                                        <label class="m-0">{{ $formB['FormVars']['Title']['DealType'] }}</label>
-                                        <input type="text" id="deal-type-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
-                                               maxlength="{{ $formB['FormVars']['MaxLength']['DealType'] }}"
+                                        <label class="m-0 ">{{ $formB['FormVars']['Title']['DealType'] }}</label>
+                                        <select class="rounded w-100" id="deal-type-select"
+                                                maxlength="{{ $formB['FormVars']['MaxLength']['DealType'] }}"
                                             {{ $formB['FormVars']['Required']['DealType'] }}>
-                                        {{-- <select class="rounded w-100" id="deal-type-select" disabled>
-                                            <option value=""></option>
-                                        </select> --}}
-                                    </div>
-                                    <div class="form-group d-flex flex-column mb-2">
-                                        <label class="m-0 ">{{ $formB['FormVars']['Title']['Supplier'] }}</label>
-                                        <input type="text" id="supplier-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
-                                               maxlength="{{ $formB['FormVars']['MaxLength']['Supplier'] }}"
-                                            {{ $formB['FormVars']['Required']['Supplier'] }}>
-                                    </div>
-                                    <div class="form-group d-flex flex-column mb-2">
-                                        <label class="m-0">{{ $formB['FormVars']['Title']['Contact'] }}</label>
-                                        <input class="rounded w-100" id="supplier-contact-txt" type="text" disabled
-                                               maxlength="{{ $formB['FormVars']['MaxLength']['Contact'] }}"
-                                            {{ $formB['FormVars']['Required']['Contact'] }}>
-                                    </div>
-                                    <div class="form-group d-flex flex-column mb-2">
-                                        <label class="m-0">{{ $formB['FormVars']['Title']['VatType'] }}</label>
-                                        <input type="text" id="vat-type-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
-                                               maxlength="{{ $formB['FormVars']['MaxLength']['VatType'] }}"
-                                            {{ $formB['FormVars']['Required']['VatType'] }}>
-                                        <select class="rounded w-100" id="vat-type-select" onchange="set_vat_type_rate(this)" hidden disabled>
-                                            <option value=""></option>
                                         </select>
                                     </div>
-                                    <div class="form-group d-flex flex-column">
-                                        <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']['VatType'] }}</label>
+                                            <select class="rounded w-100" id="vat-type-select" onchange="set_vat_type_rate(this)"
+                                                    maxlength="{{ $formB['FormVars']['MaxLength']['VatType'] }}"
+                                                {{ $formB['FormVars']['Required']['VatType'] }}>
+                                            </select>
+                                        </div>
+                                        <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>
                             </div>
                         </div>
@@ -140,30 +126,21 @@
 
                                     <div class="form-group d-flex flex-column mb-2">
                                         <label class="m-0">{{ $formB['FormVars']['Title']['Delivery'] }}</label>
-                                        <input type="text" id="delivery-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
-                                               maxlength="{{ $formB['FormVars']['MaxLength']['Delivery'] }}"
-                                            {{ $formB['FormVars']['Required']['Delivery'] }}>
-                                        {{-- <select class="rounded w-100" id="delivery-select" disabled>
-                                            <option value=""></option>
-                                        </select> --}}
+                                        <select class="rounded w-100" id="delivery-select"
+                                                maxlength="{{ $formB['FormVars']['MaxLength']['Delivery'] }}"
+                                            {{ $formB['FormVars']['Required']['Delivery'] }}></select>
                                     </div>
                                     <div class="form-group d-flex flex-column mb-2">
                                         <label class="m-0">{{ $formB['FormVars']['Title']['PayTerms'] }}</label>
-                                        <input type="text" id="payTerms-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
-                                               maxlength="{{ $formB['FormVars']['MaxLength']['PayTerms'] }}"
-                                            {{ $formB['FormVars']['Required']['PayTerms'] }}>
-                                        {{-- <select class="rounded w-100" id="payTerms-select" disabled>
-                                            <option value=""></option>
-                                        </select> --}}
+                                        <select class="rounded w-100" id="payTerms-select"
+                                                maxlength="{{ $formB['FormVars']['MaxLength']['PayTerms'] }}"
+                                            {{ $formB['FormVars']['Required']['PayTerms'] }}></select>
                                     </div>
                                     <div class="form-group d-flex flex-column mb-2">
                                         <label class="m-0">{{ $formB['FormVars']['Title']['Destination'] }}</label>
-                                        <input type="text" id="destination-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
-                                               maxlength="{{ $formB['FormVars']['MaxLength']['Destination'] }}"
-                                            {{ $formB['FormVars']['Required']['Destination'] }}>
-                                        {{-- <select class="rounded w-100" id="destination-select" disabled>
-                                            <option value=""></option>
-                                        </select> --}}
+                                        <select class="rounded w-100" id="destination-select"
+                                                maxlength="{{ $formB['FormVars']['MaxLength']['Destination'] }}"
+                                            {{ $formB['FormVars']['Required']['Destination'] }}></select>
                                     </div>
                                     <div class="form-group d-flex flex-column mb-2">
                                         <label class="m-0">{{ $formB['FormVars']['Title']['Column1'] }}</label>
@@ -199,7 +176,7 @@
                                     </div>
                                     <div class="form-group d-flex flex-column">
                                         <label class="m-0">{{ $formB['FormVars']['Title']['IsClosed'] }}</label>
-                                        <input class="rounded" type="checkbox" id="is-closed-check" value="1" disabled
+                                        <input class="rounded" type="checkbox" id="is-closed-check" value="1"
                                                maxlength="{{ $formB['FormVars']['MaxLength']['IsClosed'] }}"
                                             {{ $formB['FormVars']['Required']['IsClosed'] }}>
                                     </div>
@@ -213,10 +190,10 @@
                                 <div class="card-body">
                                     <div class="form-group d-flex flex-column mb-2">
                                         <label class="m-0">{{ $formB['FormVars']['Title']['SgroupName'] }}</label>
-                                        <input type="text" id="sgroup-name-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off" disabled
+                                        <input type="text" id="sgroup-name-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off"
                                                maxlength="{{ $formB['FormVars']['MaxLength']['SgroupName'] }}"
                                             {{ $formB['FormVars']['Required']['SgroupName'] }}>
-                                        {{-- <select class="rounded w-100" data-closed="0" id="sgroup-id-select" disabled>
+                                        {{-- <select class="rounded w-100" data-closed="0" id="sgroup-id-select">
                                             <option value=""></option>
                                         </select> --}}
                                     </div>
@@ -371,24 +348,65 @@
     <script>
         window.onload = async function () {
             make_dynamic_table_css('.sales-table', make_dynamic_table_px(formB['ListVars']['Size']))
+
+            let sgroup_pick = await get_api_data('sgroup-pick', { Page: [ { Id:  parseInt(window.User['SgroupId']) } ] });
+            window.User['SgroupName'] = sgroup_pick['data']['Page'][0]['SgroupName']
+
+            slipInit = await Btype.get_slip_form_init()
+            console.log('slipInit : ', slipInit);
+            // slipInit = @json($slipFormInitCacheData);
+            formB['SlipCommonSetup'] = slipInit['SlipCommonSetup']
+            await Btype.create_deal_type_select_box_options(slipInit.DealTypePage)
+            await Btype.create_vat_type_select_box_options(slipInit.VatRatePage)
+            await create_etc_select_box_options(slipInit)
+
+            console.log('slipInit.DealTypePage : ', slipInit.DealTypePage);
+            console.log('slipInit.VatRatePage : ', slipInit.VatRatePage);
+            console.log('slipInit : ', slipInit);
+
+            if (formB['SlipCommonSetup']['IsNewRecAutoSlipNo']) {
+                $('.is-new-rec-auto-slip-no').text('자동채번')
+                $('#auto-slip-no-txt').prop('disabled', true)
+                // get_last_slip_no()
+            }
+
             // slip-search cache 사용
+            if (formB['SlipCommonSetup']['IsLastSlipGet']) {
+                // slip-search cache 사용
+                Btype.set_slip_cache_data();
+
+                if (! isEmpty(pickCacheData['query'])) {
+                    let query = JSON.parse(pickCacheData['query'])
+                    await Btype.fetch_slip_form_book(query['QueryVars']['FilterValue']);
+                }
+            }
             // Btype.set_slip_cache_data();
 
+
+            $('#sales-table-body').on('click', 'tr', function() {
+                // Find the input element with name="bd-cursor-state" within the clicked row
+                const $bdCursorStateInput = $(this).find('input[name="bd-cursor-state"]');
+                if ($bdCursorStateInput.length) {
+                    $($bdCursorStateInput).prop('checked', true)
+                    Btype.bd_cursor_click($bdCursorStateInput)
+                }
+            });
+
             Btype.set_slip_no_btn_disabled()
             $('#sales-date').val(date_to_sting(new Date()))
             $('#stock-date').val(date_to_sting(new Date()))
 
-            // if (! isEmpty(pickCacheData['query'])) {
-            //     let query = JSON.parse(pickCacheData['query'])
-            //     await Btype.fetch_slip_form_book(query['QueryVars']['FilterValue']);
-            // }
+            if (! isEmpty(pickCacheData['query'])) {
+                let query = JSON.parse(pickCacheData['query'])
+                await Btype.fetch_slip_form_book(query['QueryVars']['FilterValue']);
+            }
 
             $('.sales-act').on('click', function () {
                 // console.log($(this).data('value'))
                 switch( $(this).data('value') ) {
                     case 'save': Btype.btn_act_save('#sales-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('#sales-form #frm'); break;
                     case 'rpt-print': Btype.rpt_print(); break;
@@ -445,6 +463,17 @@
             $('#up-btn').prop('disabled', false);
         }
 
+
+        function save_data_when_entering_text() {
+            let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
+            let index = $(tr).prevAll().length
+
+            bd_page[index].ConfirmDate = $(tr).children('td:eq(12)').find('input').val()
+            bd_page[index].DeliDate = $(tr).children('td:eq(13)').find('input').val()
+            bd_page[index].Ref1 = $(tr).children('td:eq(14)').find('input').val()
+            bd_page[index].Ref2 = $(tr).children('td:eq(15)').find('input').val()
+        }
+
         // start body act btn
         function override_btn_bd_act_multi_update() {
             Btype.btn_bd_act_multi_update('.sales-table')
@@ -489,60 +518,11 @@
         }
 
         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()
-            $('#sales-date').val(date_to_sting(new Date()))
-            $('#stock-date').val(date_to_sting(new Date()))
-            $('#sorder-no-txt').val('')
-            $('#sorder-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')
+            data_init()
 
-            $('#remarks-txt-area').val('')
-            $('#remarks-preview').html('')
-            $('#is-closed-check').prop('checked', false)
-
-            $('#sgroup-name-txt').val('')
-            // select_box_first_selected('#sgroup-name-select')
-            $('#user-txt').val('')
-            // select_box_first_selected('#our-contact-select')
-
-            $('#StorageName').val('')
-            $('#BranchName').val('')
-
-            // table body 초기화
-            table_head_check_box_reset('#sales-table-head')
-            $('#sales-table-body').html('');
-
-            // footer 합계 초기화
-            $('#QtyTotal').val('')
-            $('#SupplyTotal').val('')
-            $('#VatTotal').val('')
-            $('#SumTotal').val('')
+            // if (formB['SlipCommonSetup']['IsNewRecAutoSlipNo']) {
+                get_last_slip_no()
+            // }
         }
 
         function btn_act_copy_to_another(parameter_name) {
@@ -557,6 +537,33 @@
         }
 
         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']
+            let first_item = ''
+            let first_thumb = ''
+            if (bd_page.length > 0) {
+                const first_sales = bd_page[0]
+                first_item = first_sales['ItemCode'] + '_' + first_sales['ItemName']
+                if (first_sales['SubName']) {
+                    first_item += '_' + first_sales['SubName']
+                }
+                first_item += '(' + bd_page.length + ')'
+
+                if(first_sales['TurboThumb']){
+                    first_thumb = first_sales['TurboThumb']
+                }
+            }
+            // console.log('first_sales : ', bd_page[0]);
+            const itmtot_amt = bd_page.reduce((accumulator, bd) => {
+                return accumulator + parseFloat(bd.SalesSupply) //공급가액
+            }, 0)
+
+            console.log('itmtot_amt : ', itmtot_amt);
+
+            // const total_qty = bd_page.reduce((accumulator, bd) => {
+            //     return accumulator + parseFloat(bd.PorderQty)
+            // }, 0)
             let id = parseInt($(`#frm`).find(`input[name="Id"]`).val());
             let parameter = {
                 Id: id,
@@ -568,7 +575,18 @@
                 StockDate: moment(new Date($('#stock-date').val())).format('YYYYMMDD'),
                 UserId: window.User['UserId'],
                 Remarks: $('#remarks-txt-area').val(),
-                Ip: window.User['Ip']
+                Ip: window.User['Ip'],
+
+                FirstItem: first_item,
+                ItmtotAmt: String(itmtot_amt),
+                // DiscountAmt: '0',
+                TotalAmt: String(Number(itmtot_amt) - 0),
+                DealName: deal_name,
+                VatRate: vat_rate,
+                VatName: vat_name,
+                SgroupName: window.User['SgroupName'],
+                //TotalQty : String(Number(total_qty) - 0),
+                FirstThumb : first_thumb
             }
             if (id < 0) {
                 parameter = { Id: id }
@@ -581,6 +599,50 @@
             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()
+            $('#sales-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('')
+            $('#sorder-no-txt').val('')
+            $('#is-closed-check').prop('checked', false)
+            // select_box_first_selected('#is-closed-select')
+
+            select_box_first_selected('#our-contact-select')
+
+            // table body 초기화
+            table_head_check_box_reset('#sales-table-head')
+            $('#sales-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(formB['QueryVars']['QueryName']);
@@ -592,8 +654,27 @@
             $('#supplier-contact-txt').val($('#supplier-txt').data('contact'))
         }
 
+
+        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 delivery = create_options(data.EtcDeliveryPage)
+            let payTerms = create_options(data.EtcPayTermPage)
+            let destination = create_options(data.EtcDestinationPage)
+            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);
+        }
+
         function set_vat_type_rate($this, msg = true) {
             let vate_rate = $($this).find('option:selected').data('viewvatrate');
+            console.log('vate_rate2 : ', vate_rate);
             $('#vat-type-rate-text').val(vate_rate + '%')
 
             if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0 || ! msg) return;
@@ -613,7 +694,8 @@
                 SalesVat: String(bd.SalesVat),
                 SalesSum: String(bd.SalesSum),
                 CostPrc: String(bd.CostPrc),
-                Ip: window.User['Ip']
+                Ip: window.User['Ip'],
+                FirstThumb: bd.TurboThumb
             }
 
             if (id < 0) {
@@ -644,36 +726,38 @@
         }
 
         async function add_td_last_tap_out($this, id) {
-            let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
-            let index = $(tr).prevAll().length
-
-            if (bd_page[index].SorderBdId == 0) {
-                iziToast.error({
-                    title: 'Error',
-                    message: @json(_e('Action failed')),
-                });
-                return;
-            };
-
-            // 필수텍스트가 안비어있으고 fouces out == 다음 tr 추가
-            if (! dom_required_check($(tr).find(`input`))) {
-                if ($($this).data('last')) {
-                    let seq_no = await Btype.get_last_seq_no('sales', $('#auto-slip-no-txt').val())
-                    bd_page[index].SeqNo = seq_no;
+            Btype.btn_act_save('#sales-form #frm', async function () {
+                let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
+                let index = $(tr).prevAll().length
+
+                if (bd_page[index].SorderBdId == 0) {
+                    iziToast.error({
+                        title: 'Error',
+                        message: @json(_e('Action failed')),
+                    });
+                    return;
+                };
+
+                // 필수텍스트가 안비어있으고 fouces out == 다음 tr 추가
+                if (! dom_required_check($(tr).find(`input`))) {
+                    if ($($this).data('last')) {
+                        let seq_no = await Btype.get_last_seq_no('sales', $('#auto-slip-no-txt').val())
+                        bd_page[index].SeqNo = seq_no;
+                    }
+                    console.log('get_bd_parameter', get_bd_parameter(bd_page[index]));
+                    Btype.call_bd_act_api([ get_bd_parameter(bd_page[index]) ], function (page) {
+                        bd_page[index].Id = page[0].Id;
+
+                        body_act_success_callback($this, tr);
+                        Btype.check_the_checkbox_when_changing($this, false)
+                    });
+                } else {
+                    iziToast.error({
+                        title: 'Error',
+                        message: @json(_e('(*)Required item(s) omitted')),
+                    });
                 }
-
-                Btype.call_bd_act_api([ get_bd_parameter(bd_page[index]) ], function (page) {
-                    bd_page[index].Id = page[0].Id;
-
-                    body_act_success_callback($this, tr);
-                    Btype.check_the_checkbox_when_changing($this, false)
-                });
-            } else {
-                iziToast.error({
-                    title: 'Error',
-                    message: @json(_e('(*)Required item(s) omitted')),
-                });
-            }
+            });
         }
 
         function body_act_success_callback($this, tr) {
@@ -702,6 +786,7 @@
         }
 
         function override_amt_calc_txt_is_changed() {
+            console.log('override_amt_calc_txt_is_changed');
             let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
             let index = $(tr).prevAll().length
             let supply_amt, vat_amt, sum_amt;
@@ -752,7 +837,7 @@
                 // 품목코드, 수량, 단가, 공급가액, 세액, 합계금액
                 html.push (
                 `<tr>
-                    <td class="text-${formB.ListVars['Align'].$Radio} px-import-0">
+                    <td class="text-${formB.ListVars['Align'].$Radio} px-import-0" ${formB.ListVars['Hidden'].$Radio}>
                         <input name="bd-cursor-state" type="radio" value="1" tabindex="-1"
                         class="text-${formB.ListVars['Align'].$Radio}"
                         onclick="Btype.bd_cursor_click(this)">
@@ -764,11 +849,14 @@
                     <td onkeydown="Btype.enterPressedinCell(event)"
                         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}" disabled
-                        onchange="Btype.check_the_checkbox_when_changing(this)">
+                        <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)" required>
                     </td>
-                    <td
-                        class="text-${formB.ListVars['Align'].ItemName}" ${formB.ListVars['Hidden'].ItemName}>${bd.ItemName}
+                    <td onkeydown="Btype.enterPressedinCell(event, 2)"
+                        class="text-${formB.ListVars['Align'].ItemName}" ${formB.ListVars['Hidden'].ItemName}
+                        >
+                        <input type="text" class="text-${formB.ListVars['Align'].ItemName} border-0 bg-white" value="${bd.ItemName}" readonly
+                        onchange="Btype.check_the_checkbox_when_changing(this)" required>
                     </td>
                     <td
                         class="text-${formB.ListVars['Align'].SubName}" ${formB.ListVars['Hidden'].SubName}>${bd.SubName}
@@ -779,7 +867,7 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].SalesQty}" ${formB.ListVars['Hidden'].SalesQty}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].SalesQty} border-0 bg-white" value="${format_conver_for(bd.SalesQty, formB.ListVars['Format'].SalesQty)}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].SalesQty} border-0 bg-white" value="${format_conver_for(bd.SalesQty, formB.ListVars['Format'].SalesQty)}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="override_amt_calc_txt_is_changed()"
                         required>
@@ -787,14 +875,15 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].SorderPrc}" ${formB.ListVars['Hidden'].SorderPrc}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].SorderPrc} border-0 bg-white" value="${format_conver_for(bd.SorderPrc, formB.ListVars['Format'].SorderPrc)}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].SorderPrc} border-0 bg-white" value="${format_conver_for(bd.SorderPrc, formB.ListVars['Format'].SorderPrc)}" 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}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].SupplyAmt} border-0 bg-white" value="${format_conver_for(bd.SalesSupply, formB.ListVars['Format'].SupplyAmt)}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].SupplyAmt} border-0 bg-white" value="${format_conver_for(bd.SalesSupply, formB.ListVars['Format'].SupplyAmt)}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="override_custom_supply_amt_or_vat_amt()"
                         required>
@@ -802,16 +891,15 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].VatAmt}" ${formB.ListVars['Hidden'].VatAmt}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].VatAmt} border-0 bg-white" value="${format_conver_for(bd.SalesVat, formB.ListVars['Format'].VatAmt)}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].VatAmt} border-0 bg-white" value="${format_conver_for(bd.SalesVat, formB.ListVars['Format'].VatAmt)}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="override_custom_supply_amt_or_vat_amt()"
                         required>
                     </td>
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
-                        onfocusout="add_td_last_tap_out(this, ${bd.Id})"
                         class="text-${formB.ListVars['Align'].SumAmt}" ${formB.ListVars['Hidden'].SumAmt}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].SumAmt} border-0 bg-white" value="${format_conver_for(bd.SalesSum, formB.ListVars['Format'].SumAmt)}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].SumAmt} border-0 bg-white" value="${format_conver_for(bd.SorderSum, formB.ListVars['Format'].SumAmt)}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="override_custom_sum_amt()"
                         required>
@@ -823,26 +911,30 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].DeliDate}" ${formB.ListVars['Hidden'].DeliDate}
                         >
-                        <input type="date" class="text-${formB.ListVars['Align'].DeliDate} border-0 bg-white" value="${isEmpty(bd.DeliDate) ? '' : moment(bd.DeliDate).format(formB.ListVars['Format'].DeliDate)}" disabled
+                        <input type="date" class="text-${formB.ListVars['Align'].DeliDate} border-0 bg-white" value="${isEmpty(bd.DeliDate) ? '' : moment(bd.DeliDate).format('YYYY-MM-DD')}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
-                        onfocusout="save_data_when_entering_text()">
+                        onfocusout="save_data_when_entering_text()"
+                        required>
                     </td>
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].Ref1}" ${formB.ListVars['Hidden'].Ref1}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].Ref1} border-0 bg-white" value="${bd.Ref1}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].Ref1} border-0 bg-white" value="${bd.Ref1}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="save_data_when_entering_text()">
                     </td>
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
+                        onfocusout="add_td_last_tap_out(this, ${bd.Id})"
                         class="text-${formB.ListVars['Align'].Ref2}" ${formB.ListVars['Hidden'].Ref2}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].Ref2} border-0 bg-white" value="${bd.Ref2}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].Ref2} border-0 bg-white" value="${bd.Ref2}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="save_data_when_entering_text()">
                     </td>
                     <td
-                        class="text-${formB.ListVars['Align'].SorderMemo}" ${formB.ListVars['Hidden'].SorderMemo}>${bd.SorderMemo}
+                        class="text-${formB.ListVars['Align'].SorderMemo}" ${formB.ListVars['Hidden'].SordderMemo}>
+                        <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>
                 </tr>` )
             });
@@ -864,7 +956,7 @@
 
             let html =
             `<tr>
-                <td class="text-${formB.ListVars['Align'].$Radio} px-import-0">
+                <td class="text-${formB.ListVars['Align'].$Radio} px-import-0" ${formB.ListVars['Hidden'].$Radio}>
                     <input name="bd-cursor-state" type="radio" value="1" tabindex="-1"
                     class="text-${formB.ListVars['Align'].$Radio}"
                     id="bd-cursor-state-${last_bd_id_inc}"
@@ -877,12 +969,15 @@
                 <td onkeydown="Btype.enterPressedinCell(event)"
                     class="text-${formB.ListVars['Align'].ItemCode}" ${formB.ListVars['Hidden'].ItemCode}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].ItemCode} border-0 bg-white" value=""
+                    <input type="text" class="text-${formB.ListVars['Align'].ItemCode} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
-                    id="item-code-${last_bd_id_inc}">
+                    id="item-code-${last_bd_id_inc}" required>
                 </td>
-                <td
-                    class="text-${formB.ListVars['Align'].ItemName}" ${formB.ListVars['Hidden'].ItemName}>
+                <td onkeydown="Btype.enterPressedinCell(event, 2)"
+                    class="text-${formB.ListVars['Align'].ItemName}" ${formB.ListVars['Hidden'].ItemName}
+                    >
+                    <input type="text" class="text-${formB.ListVars['Align'].ItemName} border-0 bg-white" readonly
+                    onchange="Btype.check_the_checkbox_when_changing(this)" required>
                 </td>
                 <td
                     class="text-${formB.ListVars['Align'].SubName}" ${formB.ListVars['Hidden'].SubName}>
@@ -893,7 +988,7 @@
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].SalesQty}" ${formB.ListVars['Hidden'].SalesQty}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].SalesQty} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].SalesQty} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="override_amt_calc_txt_is_changed()"
                     required>
@@ -901,14 +996,15 @@
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].SorderPrc}" ${formB.ListVars['Hidden'].SorderPrc}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].SorderPrc} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].SorderPrc} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
-                    onfocusout="override_amt_calc_txt_is_changed()">
+                    onfocusout="override_amt_calc_txt_is_changed()"
+                    required>
                 </td>
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].SupplyAmt}" ${formB.ListVars['Hidden'].SupplyAmt}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].SupplyAmt} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].SupplyAmt} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="override_custom_supply_amt_or_vat_amt()"
                     required>
@@ -916,14 +1012,13 @@
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].VatAmt}" ${formB.ListVars['Hidden'].VatAmt}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].VatAmt} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].VatAmt} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="override_custom_supply_amt_or_vat_amt()"
                     required>
                 </td>
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
-                    data-last=true onfocusout="add_td_last_tap_out(this, ${last_bd_id_inc})"
-                    class="text-${formB.ListVars['Align'].SumAmt}" ${formB.ListVars['Hidden'].SumAmt}
+                    class="text-${formB.ListVars['Align'].SumAmt}" ${formB.ListVars['Hidden'].SumAmt} readonly
                     >
                     <input type="text" class="text-${formB.ListVars['Align'].SumAmt} border-0 bg-white"
                     onchange="Btype.check_the_checkbox_when_changing(this)"
@@ -933,25 +1028,26 @@
                 <td
                     class="text-${formB.ListVars['Align'].StdSalesPrc}" ${formB.ListVars['Hidden'].StdSalesPrc}>
                 </td>
-
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].DeliDate}" ${formB.ListVars['Hidden'].DeliDate}
                     >
-                    <input type="date" class="text-${formB.ListVars['Align'].DeliDate} border-0 bg-white"
+                    <input type="date" class="text-${formB.ListVars['Align'].DeliDate} border-0 bg-white" readonly
+                    value="${moment().format('YYYY-MM-DD')}"
                     onchange="Btype.check_the_checkbox_when_changing(this)"
-                    onfocusout="save_data_when_entering_text()">
+                    onfocusout="save_data_when_entering_text()"
+                    required>
                 </td>
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].Ref1}" ${formB.ListVars['Hidden'].Ref1}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].Ref1} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].Ref1} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="save_data_when_entering_text()">
                 </td>
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].Ref2}" ${formB.ListVars['Hidden'].Ref2}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].Ref2} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].Ref2} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="save_data_when_entering_text()">
                 </td>
@@ -991,6 +1087,34 @@
             })
         }
 
+        function set_item_data_to_textbox(item) {
+            console.log('item : ', item);
+            let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
+            // $(tr).children('td:eq(2)').find('input').val(item.ItemCode)
+            // $(tr).children('td:eq(3)').find('input').val(item.ItemName)
+            // $(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.PurchPrc).toFixed(window.User['PurchPrcPoint']))
+            // let index = $(tr).prevAll().length;
+            // bd_page[index].ItemId = item.Id
+            // bd_page[index].ItemCode = item.ItemCode
+            // bd_page[index].ItemName = item.ItemName
+            // bd_page[index].SubName = item.SubName
+            // bd_page[index].CountUnit = item.CountUnit
+            // bd_page[index].StdSalesPrc = item.PurchPrc
+            // bd_page[index].StdPurchPrc = item.PurchPrc// override_amt_calc_txt_is_changed();
+            // bd_page[index].TurboThumb = item.TurboThumb
+
+            // if (bd_page[index].Id === 0) {
+            //     $(tr).children('td:eq(16)').find('textarea').val(item.ItemMemo)
+            //     bd_page[index].PorderMemo = item.ItemMemo
+            // }
+
+            return $(tr).children('td:eq(6)').find('input')
+        }
+
         function update_hd_ui(response) {
             if (isEmpty(response.data) || response.data.apiStatus) {
                 $('#modal-slip').modal('hide');
@@ -1056,5 +1180,6 @@
         const pickCacheData = {!! json_encode($pickCacheData) !!};
         var formB = {!! json_encode($formB) !!};
         var bd_page = [];
+        let slipInit = null;
     </script>
 @endsection

+ 108 - 58
resources/views/front/dabory/erp/revenue/sorder.blade.php

@@ -53,9 +53,9 @@
                                     <div class="form-group d-flex flex-column mb-2">
                                         <label class="m-0 overflow-hidden text-nowrap">{{ $formB['FormVars']['Title']['AutoSlipNo'] }}</label>
                                         <div class="col-12 d-flex p-0">
-                                            <button id="auto-slip-no-btn" class="btn-dark border-white rounded overflow-hidden col-3 text-center text-white text-nowrap radius-r0"
-                                                onclick="get_last_slip_no(this)">
-                                                <span class="icon-cogs"></span>
+                                        {{-- <button id="auto-slip-no-btn" class="btn-dark border-white rounded overflow-hidden col-3 text-center text-white text-nowrap radius-r0"--}}
+                                        {{-- onclick="get_last_slip_no(this)">--}}
+                                        {{--  <span class="icon-cogs"></span>--}}
                                             </button>
                                             <input type="text" id="auto-slip-no-txt" class="rounded w-100 radius-l0" autocomplete="off" disabled
                                                    maxlength="{{ $formB['FormVars']['MaxLength']['AutoSlipNo'] }}"
@@ -327,17 +327,20 @@
 <script src="{{ csset('/js/modals-controller/b-type/common.js') }}"></script>
     <script>
         window.onload = async function () {
+            //await Btype.fetch_slip_form_book(query['QueryVars']['FilterValue']);
             make_dynamic_table_css('.sorder-table', make_dynamic_table_px(formB['ListVars']['Size']))
 
             $('#sorder-date').val(date_to_sting(new Date()))
 
             Btype.get_storage_name_and_branch_name()
-            let data = await Btype.get_slip_form_init()
-            formB['SlipCommonSetup'] = data['SlipCommonSetup']
-            await Btype.create_deal_type_select_box_options(data.DealTypePage)
-            await Btype.create_vat_type_select_box_options(data.VatRatePage)
-            await Btype.create_sgroup_select_box_options(data.SgroupPage)
-            await create_etc_select_box_options(data)
+            // let data = await Btype.get_slip_form_init()
+            slipInit = @json($slipFormInitCacheData);
+            console.log('slipInit : ', slipInit);
+            formB['SlipCommonSetup'] = slipInit['SlipCommonSetup']
+            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'])
 
             if (formB['SlipCommonSetup']['IsLastSlipGet']) {
@@ -350,6 +353,15 @@
                 }
             }
 
+            $('#sorder-table-body').on('click', 'tr', function() {
+                // Find the input element with name="bd-cursor-state" within the clicked row
+                const $bdCursorStateInput = $(this).find('input[name="bd-cursor-state"]');
+                if ($bdCursorStateInput.length) {
+                    $($bdCursorStateInput).prop('checked', true)
+                    Btype.bd_cursor_click($bdCursorStateInput)
+                }
+            });
+
             $('.sorder-act').on('click', function () {
                 // console.log($(this).data('value'))
                 switch( $(this).data('value') ) {
@@ -499,28 +511,30 @@
         }
 
         async function add_td_last_tap_out($this, id) {
-            let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
-            let index = $(tr).prevAll().length
-
-            // 필수텍스트가 안비어있으고 fouces out == 다음 tr 추가
-            if (bd_page[index].ItemId != 0 && ! dom_required_check($(tr).find(`input`))) {
-                if ($($this).data('last')) {
-                    let seq_no = await Btype.get_last_seq_no('sorder', $('#auto-slip-no-txt').val())
-                    bd_page[index].SeqNo = seq_no;
+            Btype.btn_act_save('#squote-form #frm', async function () {
+                let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
+                let index = $(tr).prevAll().length
+
+                // 필수텍스트가 안비어있으고 fouces out == 다음 tr 추가
+                if (bd_page[index].ItemId != 0 && ! dom_required_check($(tr).find(`input`))) {
+                    if ($($this).data('last')) {
+                        let seq_no = await Btype.get_last_seq_no('sorder', $('#auto-slip-no-txt').val())
+                        bd_page[index].SeqNo = seq_no;
+                    }
+
+                    Btype.call_bd_act_api([ get_bd_parameter(bd_page[index]) ], function (page) {
+                        bd_page[index].Id = page[0].Id;
+                        body_act_success_callback($this, tr);
+                        Btype.check_the_checkbox_when_changing($this, false)
+                        // Btype.btn_act_save('#sorder-form #frm');
+                    });
+                } else {
+                    iziToast.error({
+                        title: 'Error',
+                        message: @json(_e('(*)Required item(s) omitted')),
+                    });
                 }
-
-                Btype.call_bd_act_api([ get_bd_parameter(bd_page[index]) ], function (page) {
-                    bd_page[index].Id = page[0].Id;
-
-                    body_act_success_callback($this, tr);
-                    Btype.check_the_checkbox_when_changing($this, false)
-                });
-            } else {
-                iziToast.error({
-                    title: 'Error',
-                    message: @json(_e('(*)Required item(s) omitted')),
-                });
-            }
+            });
         }
 
         function body_act_success_callback($this, tr) {
@@ -550,7 +564,8 @@
 
         // start body act btn
         async function btn_bd_act_add() {
-            if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0 && formB['SlipCommonSetup']['IsAutoSaveHdByItemButton']) {
+            // if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0 && formB['SlipCommonSetup']['IsAutoSaveHdByItemButton']) {
+            if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0) {
                 if (! await Btype.btn_act_add_chain('#sorder-form #frm')) { return }
             }
 
@@ -648,6 +663,29 @@
         }
 
         function get_parameter() {
+            console.log('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']
+            let first_item = ''
+
+            if (bd_page.length > 0) {
+                const first_sorder = bd_page[0]
+
+                first_item = first_sorder['ItemCode'] + '_' + first_sorder['ItemName']
+                if (first_sorder['SubName']) {
+                    first_item += '_' + first_sorder['SubName']
+                }
+                first_item += '(' + bd_page.length + ')'
+            }
+            const itmtot_amt = bd_page.reduce((accumulator, bd) => {
+                return accumulator + parseFloat(bd.SorderSupply)
+            }, 0)
+
+            const total_qty = bd_page.reduce((accumulator, bd) => {
+                return accumulator + parseFloat(bd.SorderQty) //발주수량
+            }, 0)
+
             let id = parseInt($(`#frm`).find(`input[name="Id"]`).val());
             let parameter = {
                 Id: id,
@@ -670,8 +708,19 @@
                 Status: $('#status-select').val(),
                 IsClosed: $('#is-closed-check:checked').val() ?? '0',
                 Remarks: $('#remarks-txt-area').val(),
-                Ip: window.User['Ip']
+                Ip: window.User['Ip'],
+
+                FirstItem: first_item,
+                ItmtotAmt: String(itmtot_amt),
+                DiscountAmt: '0',
+                TotalAmt: String(Number(itmtot_amt) - 0),
+                DealName: deal_name,
+                VatRate: vat_rate,
+                VatName: vat_name,
+                SgroupName: window.User['SgroupName'],
+                TotalQty : String(Number(total_qty) - 0)
             }
+
             if (id < 0) {
                 parameter = { Id: id }
             } else if (id > 0) {
@@ -680,7 +729,7 @@
                 delete parameter.UpdatedOn;
             }
 
-            // console.log(parameter)
+            console.log('save : ', parameter)
             return parameter;
         }
 
@@ -797,7 +846,7 @@
                 // 품목코드, 수량, 단가, 공급가액, 세액, 합계금액
                 html.push (
                 `<tr>
-                    <td class="text-${formB.ListVars['Align'].$Radio} px-import-0">
+                    <td class="text-${formB.ListVars['Align'].$Radio} px-import-0" ${formB.ListVars['Hidden'].$Radio}>
                         <input name="bd-cursor-state" type="radio" value="1" tabindex="-1"
                         class="text-${formB.ListVars['Align'].$Radio}"
                         onclick="Btype.bd_cursor_click(this)">
@@ -809,13 +858,13 @@
                     <td onkeydown="Btype.enterPressedinCell(event)"
                         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}" disabled
+                        <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)" required>
                     </td>
                     <td onkeydown="Btype.enterPressedinCell(event, 2)"
                         class="text-${formB.ListVars['Align'].ItemName}" ${formB.ListVars['Hidden'].ItemName}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].ItemName} border-0 bg-white" value="${bd.ItemName}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].ItemName} border-0 bg-white" value="${bd.ItemName}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)" required>
                     </td>
                     <td
@@ -827,7 +876,7 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].SorderQty}" ${formB.ListVars['Hidden'].SorderQty}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].SorderQty} border-0 bg-white" value="${format_conver_for(bd.SorderQty, formB.ListVars['Format'].SorderQty)}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].SorderQty} border-0 bg-white" value="${format_conver_for(bd.SorderQty, formB.ListVars['Format'].SorderQty)}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="override_amt_calc_txt_is_changed()"
                         required>
@@ -835,7 +884,7 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].SorderPrc}" ${formB.ListVars['Hidden'].SorderPrc}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].SorderPrc} border-0 bg-white" value="${format_conver_for(bd.SorderPrc, formB.ListVars['Format'].SorderPrc)}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].SorderPrc} border-0 bg-white" value="${format_conver_for(bd.SorderPrc, formB.ListVars['Format'].SorderPrc)}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="override_amt_calc_txt_is_changed()"
                         required>
@@ -843,7 +892,7 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].SupplyAmt}" ${formB.ListVars['Hidden'].SupplyAmt}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].SupplyAmt} border-0 bg-white" value="${format_conver_for(bd.SorderSupply, formB.ListVars['Format'].SupplyAmt)}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].SupplyAmt} border-0 bg-white" value="${format_conver_for(bd.SorderSupply, formB.ListVars['Format'].SupplyAmt)}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="override_custom_supply_amt_or_vat_amt()"
                         required>
@@ -851,7 +900,7 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].VatAmt}" ${formB.ListVars['Hidden'].VatAmt}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].VatAmt} border-0 bg-white" value="${format_conver_for(bd.SorderVat, formB.ListVars['Format'].VatAmt)}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].VatAmt} border-0 bg-white" value="${format_conver_for(bd.SorderVat, formB.ListVars['Format'].VatAmt)}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="override_custom_supply_amt_or_vat_amt()"
                         required>
@@ -859,7 +908,7 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].SumAmt}" ${formB.ListVars['Hidden'].SumAmt}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].SumAmt} border-0 bg-white" value="${format_conver_for(bd.SorderSum, formB.ListVars['Format'].SumAmt)}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].SumAmt} border-0 bg-white" value="${format_conver_for(bd.SorderSum, formB.ListVars['Format'].SumAmt)}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="override_custom_sum_amt()"
                         required>
@@ -870,7 +919,7 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].ConfirmDate}" ${formB.ListVars['Hidden'].ConfirmDate}
                         >
-                        <input type="date" class="text-${formB.ListVars['Align'].ConfirmDate} border-0 bg-white" value="${isEmpty(bd.ConfirmDate) ? '' : moment(bd.ConfirmDate).format('YYYY-MM-DD')}" disabled
+                        <input type="date" class="text-${formB.ListVars['Align'].ConfirmDate} border-0 bg-white" value="${isEmpty(bd.ConfirmDate) ? '' : moment(bd.ConfirmDate).format('YYYY-MM-DD')}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="save_data_when_entering_text()">
                     </td>
@@ -878,7 +927,7 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].DeliDate}" ${formB.ListVars['Hidden'].DeliDate}
                         >
-                        <input type="date" class="text-${formB.ListVars['Align'].DeliDate} border-0 bg-white" value="${isEmpty(bd.DeliDate) ? '' : moment(bd.DeliDate).format('YYYY-MM-DD')}" disabled
+                        <input type="date" class="text-${formB.ListVars['Align'].DeliDate} border-0 bg-white" value="${isEmpty(bd.DeliDate) ? '' : moment(bd.DeliDate).format('YYYY-MM-DD')}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="save_data_when_entering_text()"
                         required>
@@ -886,7 +935,7 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].Ref1}" ${formB.ListVars['Hidden'].Ref1}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].Ref1} border-0 bg-white" value="${bd.Ref1}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].Ref1} border-0 bg-white" value="${bd.Ref1}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="save_data_when_entering_text()">
                     </td>
@@ -894,7 +943,7 @@
                         onfocusout="add_td_last_tap_out(this, ${bd.Id})"
                         class="text-${formB.ListVars['Align'].Ref2}" ${formB.ListVars['Hidden'].Ref2}
                         >
-                        <input type="text" class="text-${formB.ListVars['Align'].Ref2} border-0 bg-white" value="${bd.Ref2}" disabled
+                        <input type="text" class="text-${formB.ListVars['Align'].Ref2} border-0 bg-white" value="${bd.Ref2}" readonly
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="save_data_when_entering_text()">
                     </td>
@@ -923,7 +972,7 @@
 
             let html =
             `<tr>
-                <td class="text-${formB.ListVars['Align'].$Radio} px-import-0">
+                <td class="text-${formB.ListVars['Align'].$Radio} px-import-0"  ${formB.ListVars['Hidden'].$Radio}>
                     <input name="bd-cursor-state" type="radio" value="1" tabindex="-1"
                     class="text-${formB.ListVars['Align'].$Radio}"
                     id="bd-cursor-state-${last_bd_id_inc}"
@@ -936,14 +985,14 @@
                 <td onkeydown="Btype.enterPressedinCell(event)"
                     class="text-${formB.ListVars['Align'].ItemCode}" ${formB.ListVars['Hidden'].ItemCode}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].ItemCode} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].ItemCode} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     id="item-code-${last_bd_id_inc}" required>
                 </td>
                 <td onkeydown="Btype.enterPressedinCell(event, 2)"
                     class="text-${formB.ListVars['Align'].ItemName}" ${formB.ListVars['Hidden'].ItemName}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].ItemName} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].ItemName} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)" required>
                 </td>
                 <td
@@ -955,7 +1004,7 @@
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].SorderQty}" ${formB.ListVars['Hidden'].SorderQty}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].SorderQty} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].SorderQty} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="override_amt_calc_txt_is_changed()"
                     required>
@@ -963,7 +1012,7 @@
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].SorderPrc}" ${formB.ListVars['Hidden'].SorderPrc}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].SorderPrc} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].SorderPrc} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="override_amt_calc_txt_is_changed()"
                     required>
@@ -971,7 +1020,7 @@
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].SupplyAmt}" ${formB.ListVars['Hidden'].SupplyAmt}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].SupplyAmt} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].SupplyAmt} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="override_custom_supply_amt_or_vat_amt()"
                     required>
@@ -979,7 +1028,7 @@
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].VatAmt}" ${formB.ListVars['Hidden'].VatAmt}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].VatAmt} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].VatAmt} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="override_custom_supply_amt_or_vat_amt()"
                     required>
@@ -987,7 +1036,7 @@
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].SumAmt}" ${formB.ListVars['Hidden'].SumAmt}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].SumAmt} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].SumAmt} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="override_custom_sum_amt()"
                     required>
@@ -998,7 +1047,7 @@
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].ConfirmDate}" ${formB.ListVars['Hidden'].ConfirmDate}
                     >
-                    <input type="date" class="text-${formB.ListVars['Align'].ConfirmDate} border-0 bg-white"
+                    <input type="date" class="text-${formB.ListVars['Align'].ConfirmDate} border-0 bg-white" readonly
                     value="${moment().format('YYYY-MM-DD')}"
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="save_data_when_entering_text()">
@@ -1007,7 +1056,7 @@
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].DeliDate}" ${formB.ListVars['Hidden'].DeliDate}
                     >
-                    <input type="date" class="text-${formB.ListVars['Align'].DeliDate} border-0 bg-white"
+                    <input type="date" class="text-${formB.ListVars['Align'].DeliDate} border-0 bg-white" readonly
                     value="${moment().format('YYYY-MM-DD')}"
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="save_data_when_entering_text()"
@@ -1016,7 +1065,7 @@
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].Ref1}" ${formB.ListVars['Hidden'].Ref1}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].Ref1} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].Ref1} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="save_data_when_entering_text()">
                 </td>
@@ -1024,7 +1073,7 @@
                     data-last=true onfocusout="add_td_last_tap_out(this, ${last_bd_id_inc})"
                     class="text-${formB.ListVars['Align'].Ref2}" ${formB.ListVars['Hidden'].Ref2}
                     >
-                    <input type="text" class="text-${formB.ListVars['Align'].Ref2} border-0 bg-white"
+                    <input type="text" class="text-${formB.ListVars['Align'].Ref2} border-0 bg-white" readonly
                     onchange="Btype.check_the_checkbox_when_changing(this)"
                     onfocusout="save_data_when_entering_text()">
                 </td>
@@ -1074,7 +1123,7 @@
             $(tr).children('td:eq(3)').find('input').val(item.ItemName)
             $(tr).children('td:eq(4)').text(item.SubName)
             $(tr).children('td:eq(5)').text(item.CountUnit)
-            $(tr).children('td:eq(6)').find('input').val(1)
+            $(tr).children('td:eq(6)').find('input').val()
             $(tr).children('td:eq(7)').find('input').val(parseFloat(item.SalesPrc).toFixed(window.User['SalesPrcPoint']))
             $(tr).children('td:eq(11)').text(parseFloat(item.SalesPrc).toFixed(window.User['SalesPrcPoint']))
 
@@ -1148,5 +1197,6 @@
         const pickCacheData = {!! json_encode($pickCacheData) !!};
         var formB = {!! json_encode($formB) !!};
         var bd_page = [];
+        let slipInit = null;
     </script>
 @endsection

+ 9 - 2
resources/views/front/dabory/erp/sales/squote.blade.php

@@ -488,19 +488,26 @@
             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('vat_name : ', vat_name);
 
             let first_item = ''
             if (bd_page.length > 0) {
+                console.log('bd_page : ', bd_page[0]);
                 const first_squote = bd_page[0]
                 first_item = first_squote['ItemCode'] + '_' + first_squote['ItemName']
                 if (first_squote['SubName']) {
                     first_item += '_' + first_squote['SubName']
                 }
+                squote_vat=first_squote['SquoteVat'];
                 first_item += '(' + bd_page.length + ')'
+
+                console.log('squote_vat : ', squote_vat);
             }
             const itmtot_amt = bd_page.reduce((accumulator, bd) => {
-                return accumulator + parseFloat(bd.SquoteSupply)
+                return accumulator + parseFloat(bd.SquoteSupply) + parseFloat(bd.SquoteVat) // 합계금액 (공급가액 + 세액)
             }, 0)
+
+            console.log('itmtot_amt : ', itmtot_amt);
             let id = parseInt($(`#frm`).find(`input[name="Id"]`).val());
             let parameter = {
                 Id: id,
@@ -857,7 +864,7 @@
             $(tr).children('td:eq(3)').find('input').val(item.ItemName)
             $(tr).children('td:eq(4)').text(item.SubName)
             $(tr).children('td:eq(5)').text(item.CountUnit)
-            $(tr).children('td:eq(6)').find('input').val(1)
+            $(tr).children('td:eq(6)').find('input').val(0)
             $(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']))
 

+ 4 - 0
resources/views/front/dabory/erp/stock/genio.blade.php

@@ -359,6 +359,8 @@
                 first_item += '(' + GenioCorrect.bd_page.length + ')'
             }
             const itmtot_amt = GenioCorrect.bd_page.reduce((accumulator, bd) => {
+                console.log('accumulator : ', accumulator);
+                console.log('bd.GenioSupply : ', bd.GenioSupply);
                 return accumulator + parseFloat(bd.GenioSupply)
             }, 0)
             let id = parseInt($(`#frm`).find(`input[name="Id"]`).val());
@@ -392,6 +394,8 @@
                 VatName: vat_name,
                 SgroupName: window.User['SgroupName']
             }
+
+            console.log('parameter : ', parameter);
             if (id < 0) {
                 parameter = { Id: id }
             } else if (id > 0) {

+ 23 - 24
resources/views/front/dabory/erp/stock/tab/genio-correct.blade.php

@@ -113,8 +113,6 @@
                     }, 'GenioCorrect')
                 }
             });
-
-
         });
 
         $('#genio-table-body').on('click', 'tr', function() {
@@ -490,7 +488,7 @@
                 $(tr).children('td:eq(3)').find('input').val(item.ItemName)
                 $(tr).children('td:eq(4)').text(item.SubName)
                 $(tr).children('td:eq(5)').text(item.CountUnit)
-                $(tr).children('td:eq(6)').find('input').val(1)
+                $(tr).children('td:eq(6)').find('input').val(0)
                 $(tr).children('td:eq(7)').find('input').val(parseFloat(item.PurchPrc).toFixed(window.User['PurchPrcPoint']))
 
                 let index = $(tr).prevAll().length;
@@ -552,28 +550,29 @@
             }
 
             GenioCorrect.add_td_last_tap_out = async function ($this, id) {
-                let tr = $('#correct-tab').find(`input[name='bd-cursor-state']:checked`).closest('tr')
-                let index = $(tr).prevAll().length
-
-                // 필수텍스트가 안비어있으고 fouces out == 다음 tr 추가
-                if (GenioCorrect.bd_page[index].ItemId != 0 && ! window.dom_required_check($(tr).find(`input`))) {
-                    if ($($this).data('last')) {
-                        let seq_no = await Btype.get_last_seq_no('genio', $('#correct-tab').find('.auto-slip-no-txt').val())
-                        GenioCorrect.bd_page[index].SeqNo = seq_no;
+                Btype.btn_act_save('#squote-form #frm', async function () {
+                    let tr = $('#correct-tab').find(`input[name='bd-cursor-state']:checked`).closest('tr')
+                    let index = $(tr).prevAll().length
+
+                    // 필수텍스트가 안비어있으고 fouces out == 다음 tr 추가
+                    if (GenioCorrect.bd_page[index].ItemId != 0 && ! window.dom_required_check($(tr).find(`input`))) {
+                        if ($($this).data('last')) {
+                            let seq_no = await Btype.get_last_seq_no('genio', $('#correct-tab').find('.auto-slip-no-txt').val())
+                            GenioCorrect.bd_page[index].SeqNo = seq_no;
+                        }
+
+                        Btype.call_bd_act_api([ GenioCorrect.get_bd_parameter(GenioCorrect.bd_page[index]) ], function (page) {
+                            GenioCorrect.bd_page[index].Id = page[0].Id;
+                            GenioCorrect.custom_body_act_success_callback($this, tr);
+                            Btype.check_the_checkbox_when_changing($this, false, 'GenioCorrect')
+                        }, 'GenioCorrect');
+                    } else {
+                        iziToast.error({
+                            title: 'Error',
+                            message: @json(_e('(*)Required item(s) omitted')),
+                        });
                     }
-
-                    Btype.call_bd_act_api([ GenioCorrect.get_bd_parameter(GenioCorrect.bd_page[index]) ], function (page) {
-                        GenioCorrect.bd_page[index].Id = page[0].Id;
-
-                        GenioCorrect.custom_body_act_success_callback($this, tr);
-                        Btype.check_the_checkbox_when_changing($this, false, 'GenioCorrect')
-                    }, 'GenioCorrect');
-                } else {
-                    iziToast.error({
-                        title: 'Error',
-                        message: @json(_e('(*)Required item(s) omitted')),
-                    });
-                }
+                });
             }
 
             GenioCorrect.get_bd_parameter = function (bd) {