PayPlan.jsp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <%--
  2. - Author(s) : Kim Myung Ho
  3. - Date : 2014.08.22
  4. - Description: 계약 구매 대금 계획
  5. --%>
  6. <%@ page contentType="text/html; charset=utf-8" %>
  7. <SCRIPT language="JavaScript">
  8. var sheet1 = new ibsheetObject();
  9. var pCount = 0;
  10. var mCount = 0;
  11. var rCount = 0;
  12. function doSearchPayPlanSheet(){
  13. $("#fevent").val("");
  14. var url = Modular.model.PageContext.CONTEXT_ROOT + "/cont/purchase/payPlan_sheet.screen";
  15. Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
  16. }
  17. //Grid 상태값 변경
  18. function doInsert(gRow) {
  19. for(var i=1; i<=sheet1.RowCount(); i++){
  20. sheet1.SetCellValue(i,2,i);
  21. }
  22. sheet1.SetColProperty(gRow,1,info);
  23. var info= {Edit:true};
  24. }
  25. function gridInit(sheetName){
  26. var init_sheet = {};
  27. init_sheet.Cfg = {SearchMode:3, Page:30};
  28. init_sheet.Cols = [
  29. {Header:'삭제', Type:"DelCheck", SaveName:"DEL_CHECK", Width:0, Align:"Center", HeaderCheck:false},
  30. {Header:'구분', Type:"Combo", SaveName:"PAY_DIV_CD", Width:80, Align:"Left", Edit:false, ComboText:"중도금|선급금|잔금", ComboCode:"02|01|03"},
  31. {Header:'지급차수', Type:"Int", SaveName:"PAY_SEQ", Width:60, Align:"Center", Edit:false},
  32. {Header:'청구금액', Type:"AutoSum", SaveName:"PAY_SUPPLY_AMT", Width:100, Align:"Right", Edit:true},
  33. {Header:'요율(%)', Type:"Text", SaveName:"PAY_SUPPLY_AMT_RATE", Width:100, Align:"Center", Edit:false},
  34. {Header:'대금여부', Type:"Text", SaveName:"PAY_YN", Width:100, Align:"Center", Edit:false},
  35. {Header:'보증서여부', Type:"CheckBox", SaveName:"GUAR_YN", Width:100, Align:"Center", Edit:true, TrueValue:"Y", FalseValue:"N"},
  36. {Header:'Vendor Print 여부', Type:"CheckBox", SaveName:"VP_YN", Width:100, Align:"Center", Edit:true, TrueValue:"Y", FalseValue:"N"},
  37. {Header:'Vendor Print 항목', Type:"Text", SaveName:"VP_DESC", Width:200, Align:"Left"},
  38. {Header:'지급신청ID_PUR100T', Type:"Text", SaveName:"PAYREQ_ID", Width:0, Align:"Left", Hidden:"True"},
  39. {Header:'WARR_GUBUN', Type:"Text", SaveName:"WARR_GUBUN", Width:50, Align:"Left", Hidden:"True"},
  40. {Header:'Status', Type:"Status", SaveName:"STATUS", Width:50, Align:"Center", Hidden:"True"},
  41. {Header:'INFLAG', Type:"Text", SaveName:"INFLAG", Width:50, Align:"Center", Hidden:"True"},
  42. {Header:'Vendor Print 담당자ID', Type:"Text", SaveName:"VP_CHK_EMPNO", Width:20, Align:"Left", Hidden:"True"},
  43. {Header:'설계평가 담당자ID', Type:"Text", SaveName:"PLAN_APPR_CHK_EMPNO", Width:20, Align:"Left", Hidden:"True"},
  44. {Header:'Vendor Print 담당자명', Type:"Popup", SaveName:"VP_CHK_EMPNM", Width:100, Align:"Left"},
  45. {Header:'설계평가여부', Type:"CheckBox", SaveName:"PLAN_APPR_YN", Width:100, Align:"Center", Edit:true, TrueValue:"Y", FalseValue:"N"},
  46. {Header:'설계평가 담당자명', Type:"Popup", SaveName:"PLAN_APPR_CHK_EMPNM", Width:100, Align:"Left"},
  47. {Header:'PLAN_APPR_SEND_YN', Type:"Text", SaveName:"PLAN_APPR_SEND_YN", Width:50, Align:"Center", Hidden:"True"},
  48. {Header:'DEPT_CD', Type:"Text", SaveName:"DEPT_CD", Width:50, Align:"Center", Hidden:"True"},
  49. {Header:'ORD_DOC_NO', Type:"Text", SaveName:"ORD_DOC_NO", Width:50, Align:"Center", Hidden:"True"},
  50. {Header:'CORP_ID', Type:"Text", SaveName:"CORP_ID", Width:50, Align:"Center", Hidden:"True"},
  51. ];
  52. init_sheet.HeaderMode = {Sort:0};
  53. IBS_InitSheet(sheetName, init_sheet);
  54. sheetName.SetDataAutoTrim(0);
  55. //sheetName.SizeMode(0);
  56. setGridSize();
  57. }
  58. /**
  59. * IBSheet Event: Click
  60. */
  61. function sheet1_OnClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
  62. }
  63. /**
  64. * IBSheet size setting
  65. */
  66. function setGridSize() {
  67. sheet1.FitColWidth();
  68. }
  69. /**
  70. * IBSheet Event: Search End(IBSheet 데이터 조회 CallBack)
  71. var pCount = 0;
  72. var mCount = 0;
  73. var rCount = 0;
  74. */
  75. function sheet1_OnSearchEnd(code, message) {
  76. if(code == 0) {
  77. for(var i=1; i<=sheet1.RowCount(); i++){
  78. if(sheet1.GetCellValue(i,1)=="01"){
  79. pCount = pCount + 1;
  80. }else if(sheet1.GetCellValue(i,1)=="02"){
  81. mCount = mCount + 1;
  82. }else if(sheet1.GetCellValue(i,1)=="03"){
  83. rCount = rCount + 1;
  84. }
  85. }
  86. //소수점 설정
  87. var info = {Type:"Float", PointCount:jQuery('#sosuNum').val()};
  88. for(var i=1;i <= sheet1.RowCount();i++){
  89. if(sheet1.GetCellValue(i,"PAY_YN") == "Y"){
  90. sheet1.SetRowEditable(i,0);
  91. }
  92. //소수점 설정
  93. sheet1.InitCellProperty(i, 3, info);
  94. }
  95. setGridSize();
  96. } else {
  97. //조회 에러 수행
  98. alert(message);
  99. }
  100. }
  101. function sheet1_OnSaveEnd(code, msg)
  102. {
  103. var event = $("#fevent").val();
  104. if(event == "SHEET_SAVE"){
  105. if(code>= "0"){
  106. if(payCallNum==1){
  107. alert("계약서저장에 성공하였습니다.\n\n저장된 계약서는 구매_계약현황페이지에서 확인하실수 있습니다.");
  108. location.href="/cont/purchase/ContIngList.screen";
  109. //location.reload();
  110. }else if(payCallNum==2){
  111. alert("저장 되었습니다.");
  112. //goListProc();
  113. location.reload();
  114. }else{
  115. alert("저장 되었습니다.")
  116. location.reload();
  117. }
  118. }
  119. }else{
  120. if(code>= "0"){
  121. alert("저장되었습니다.");
  122. refresh();
  123. }else{
  124. alert("저장실패.");
  125. }
  126. }
  127. }
  128. function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
  129. if(Row == 0)return;
  130. if ((sheet1.ColSaveName(Col) == "PAY_YN")) {
  131. if("<%=user.get("RIGHT_NAME")%>" == "ADMIN NEW"){
  132. $("#p_pay_seq").val(sheet1.GetCellValue(Row,"PAY_SEQ"));
  133. if(sheet1.GetCellValue(Row,"PAY_YN") == "Y"){
  134. $("#p_pay_yn").val("N");
  135. }
  136. else{
  137. $("#p_pay_yn").val("Y");
  138. }
  139. if (confirm("대금여부 값을 변경 하시겠습니까?")){
  140. var f = document.form1;
  141. jQuery("#fevent").val("TRANS_PAY_YN");
  142. submitXmlRequest("/cont/purchase/ContResult_form.screen", "TRANS_PAY_YN", f);
  143. }
  144. }
  145. }
  146. }
  147. /**
  148. * IBSheet size setting
  149. */
  150. function setGridSize() {
  151. sheet1.FitColWidth();
  152. }
  153. /**
  154. * IBSheet Change Event
  155. */
  156. function sheet1_OnChange(Row, Col, Value, OldValue, RaiseFlag) {
  157. var oldPrepayAmt ="";
  158. if(Col == 3){//선급금 금액 체크
  159. oldPrepayAmt = sheet1.GetCellValue(Row,3);
  160. if(sheet1.GetCellValue(Row,1) == "01"){
  161. if(parseInt(trimComma(form1.prepay_amt.value)) != parseInt(sheet1.GetCellValue(Row,3))){
  162. alert("계약서의 금액과 선급금 금액이 일치 하지 않습니다.");
  163. sheet1.SetCellValue(Row,Col,OldValue,0);
  164. //return;
  165. }
  166. }
  167. for(var i=1; i<=sheet1.RowCount(); i++){
  168. sheet1.SetCellValue(i,4, (parseFloat(sheet1.GetCellValue(i,3)) / parseFloat(trimComma(form1.ord_supply_amt.value))*100).toFixed(2));
  169. }
  170. }
  171. }
  172. //사용자 추가
  173. function sheet1_OnPopupClick(Row, Col) {
  174. var sName = sheet1.ColSaveName(Col);
  175. if(sName=="VP_CHK_EMPNM"){
  176. if(sheet1.GetCellValue(Row,"VP_YN")=="N"){
  177. alert("Vendor Print 여부에 체크를 해주시고 담당자를 선택 해 주시기 바랍니다.");
  178. return;
  179. }
  180. if ( sName=="VP_CHK_EMPNM" ) { // 현장
  181. clickRow = Row;
  182. SearchUser('Sheet','','');
  183. }
  184. }
  185. if(sName=="PLAN_APPR_CHK_EMPNM"){
  186. if(sheet1.GetCellValue(Row,"PLAN_APPR_YN")=="N"){
  187. alert("설계평가 여부에 체크를 해주시고 담당자를 선택 해 주시기 바랍니다.");
  188. return;
  189. }
  190. if ( sName=="PLAN_APPR_CHK_EMPNM" ) { // 현장
  191. clickRow = Row;
  192. SearchUser('Sheet2','','');
  193. }
  194. }
  195. }
  196. function paySaveChk(){
  197. var pAmt = 0;
  198. var mAmt = 0;
  199. var rAmt = 0;
  200. var sumAmt = 0;
  201. for(var i=1; i<=sheet1.RowCount(); i++){
  202. if(sheet1.GetCellValue(i,1)=="01"){
  203. pAmt = pAmt + sheet1.GetCellValue(i,3)
  204. }else if(sheet1.GetCellValue(i,1)=="02"){
  205. mAmt = mAmt + sheet1.GetCellValue(i,3)
  206. }else if(sheet1.GetCellValue(i,1)=="03"){
  207. rAmt = rAmt + sheet1.GetCellValue(i,3)
  208. }
  209. sheet1.SetCellValue(i, 12, "Y");
  210. }
  211. for(var i=1; i<=sheet1.RowCount(); i++){
  212. if((sheet1.GetCellValue(i,"PAY_DIV_CD")=="01") && (sheet1.GetCellValue(i,"PLAN_APPR_YN")=="Y")){
  213. alert("선급금은 설계평가를 하지 않습니다.");
  214. sheet1.SetCellValue(i, "PLAN_APPR_YN", "N");
  215. sheet1.SetCellValue(i, "PLAN_APPR_CHK_EMPNO", "");
  216. sheet1.SetCellValue(i, "PLAN_APPR_CHK_EMPNM", "");
  217. sheet1.SetCellValue(i, "PLAN_APPR_SEND_YN", "");
  218. return false;
  219. }
  220. if((sheet1.GetCellValue(i,"PLAN_APPR_YN")=="N") || (sheet1.GetCellValue(i,"PLAN_APPR_YN")=="")){
  221. sheet1.SetCellValue(i, "PLAN_APPR_YN", "N");
  222. sheet1.SetCellValue(i, "PLAN_APPR_CHK_EMPNO", "");
  223. sheet1.SetCellValue(i, "PLAN_APPR_CHK_EMPNM", "");
  224. sheet1.SetCellValue(i, "PLAN_APPR_SEND_YN", "");
  225. }
  226. if((sheet1.GetCellValue(i,"PLAN_APPR_YN")=="Y") && (sheet1.GetCellValue(i,"PLAN_APPR_CHK_EMPNO")=="")){
  227. alert(i+ "번째 설계평가 담당자를 선택해 주세요.");
  228. return false;
  229. }
  230. }
  231. for(var i=1; i<=sheet1.RowCount(); i++){
  232. if((sheet1.GetCellValue(i,"VP_YN")=="Y") && (sheet1.GetCellValue(i,"VP_CHK_EMPNO")=="")){
  233. alert(i+ "번째 Vendor Print 담당자를 선택해 주세요.");
  234. return false;
  235. }
  236. }
  237. //alert(form1.prepay_amt.value + " / " + trimComma(form1.mid_amt.value) + " / " + form1.rmdr_amt.value + " / " + mAmt);
  238. sumAmt = sheet1.GetSumValue(0 ,"PAY_SUPPLY_AMT");
  239. if(trimComma(form1.ord_supply_amt.value) != sumAmt){
  240. alert("계약서의 금액과 합계 금액이 일치 하지 않습니다.");
  241. return false;
  242. }
  243. /*
  244. if(trimComma(form1.prepay_amt.value) != pAmt){
  245. alert("계약서의 금액과 선급금 금액이 일치 하지 않습니다.");
  246. return false;
  247. }
  248. if(trimComma(form1.mid_amt.value) != mAmt){
  249. alert("계약서의 금액과 중도금 합계 금액이 일치 하지 않습니다.");
  250. return false;
  251. }
  252. if(trimComma(form1.rmdr_amt.value) != rAmt){
  253. alert("계약서의 금액과 잔금 합계 금액이 일치 하지 않습니다.");
  254. return false;
  255. }
  256. */
  257. return true;
  258. }
  259. function payPlanSave(){ //저장
  260. jQuery("#fevent").val("SHEET_SAVE");
  261. var url = Modular.model.PageContext.CONTEXT_ROOT + "/cont/purchase/payPlan_sheet.screen";
  262. var result = Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), false);
  263. }
  264. function sheet1_OnSearchEnd(code, message) {
  265. if(code == 0 && jQuery("#fevent").val() == "PAYPLAN_COPY") {
  266. //payPlanSave(); //대금 계획 저장
  267. //alert("대금계획저장 클릭 후 적용됩니다.");
  268. }
  269. }
  270. function payPlanInit(){ //초기 셋팅
  271. sheet1.SetSumValue(3,"총 금 액");
  272. doSearchPayPlanSheet();
  273. //2016.4.27 이전차수 자료 복사
  274. jQuery("#btnAdd0").click(function() {
  275. if (confirm("이전 차수 대금계획을 가져 오시겠습니까?")){
  276. jQuery("#fevent").val("PAYPLAN_COPY");
  277. var url = Modular.model.PageContext.CONTEXT_ROOT + "/cont/purchase/payPlan_sheet.screen";
  278. Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
  279. }
  280. });
  281. jQuery("#btnAdd1").click(function() {
  282. if(pCount==0){
  283. var rowIdx = sheet1.DataInsert(0);
  284. sheet1.SetCellValue(rowIdx,1,"01");
  285. pCount = pCount + 1;
  286. doInsert(rowIdx);
  287. }else{
  288. alert("선급금은 한번만 입력 하실수 있습니다.")
  289. }
  290. });
  291. jQuery("#btnAdd2").click(function() {
  292. var rowIdx = sheet1.DataInsert();
  293. sheet1.SetCellValue(rowIdx,1,"02");
  294. doInsert(rowIdx);
  295. });
  296. jQuery("#btnAdd3").click(function() {
  297. var rowIdx = sheet1.DataInsert(); //2017.11.20 -1
  298. sheet1.SetCellValue(rowIdx,1,"03");
  299. rCount = rCount + 1;
  300. doInsert(rowIdx);
  301. });
  302. }
  303. function sheet1_OnSearchEnd(code, message) {
  304. if(code == 0) {
  305. setGridSize();
  306. for(var i=1;i <= sheet1.RowCount();i++){
  307. if(sheet1.GetCellValue(i,"PAY_YN") == "Y"){
  308. sheet1.SetRowEditable(i,0);
  309. }
  310. }
  311. } else {
  312. //조회 에러 수행
  313. alert(message);
  314. }
  315. }
  316. </SCRIPT>
  317. <INPUT type="hidden" name="p_pay_yn" value="">
  318. <INPUT type="hidden" name="p_pay_seq" value="">
  319. <table id=copr_list width="100%">
  320. <colgroup>
  321. <col width="500" />
  322. <col width="*" />
  323. </colgroup>
  324. <tr>
  325. <th>
  326. <div class="application-info magT20">
  327. <div class="application-sub-title">
  328. <span class="title">대금계획</span>
  329. </div>
  330. </div>
  331. </th>
  332. <td align="right">
  333. <% if (!ContInfo.get("MOD_NO").equals("0") && ContInfo.get("PUR1100T_CNT").equals("0") ) { %> <!-- 2016.4.28 변경계약이고, 변경계약으로 생성된 대금지급이 없을때만 -->
  334. <span class="btnSearch center" id="btnAdd0"><a href="javascript:void(0);">대금계획생성</a></span>
  335. <%} %>
  336. <span class="btnSearch center" id="btnAdd1"><a href="javascript:void(0);">선급금추가</a></span>
  337. <span class="btnSearch center" id="btnAdd2"><a href="javascript:void(0);">중도금추가</a></span>
  338. <span class="btnSearch center" id="btnAdd3"><a href="javascript:void(0);">잔금추가</a></span>
  339. <%if (isViewWrite=="V"){ %>
  340. <span class="btnSearch center" id="btnPaySave"><a href="javascript:void(0);">대금계획저장</a></span>
  341. <%} %>
  342. </td>
  343. </tr>
  344. </table>
  345. <div id="sheet1_div" style="padding-top:5px;height: auto; min-height: 200px; overflow: auto;">
  346. <script>createIBSheet('sheet1','100%', '200px');</script>
  347. </div>
  348. <script>
  349. /*대금 계획 추가 내용*/
  350. gridInit(sheet1);
  351. //대금계획 조회
  352. payPlanInit();
  353. </script>