cp_periodCal.xfdl 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <FDL version="1.5">
  3. <TypeDefinition url="..\default_typedef.xml"/>
  4. <Form id="cp_periodCal" classname="cp_periodCal" inheritanceid="" position="absolute 0 0 216 20" titletext="Period Calendar" onload="cp_periodCal_onload" scrollbars="none" style="background:transparent;">
  5. <Layouts>
  6. <Layout>
  7. <Calendar id="cal_to" taborder="1" autoselect="true" type="spin" dateformat="yyyy.MM.dd" onchanged="cal_to_onchanged" position="absolute 116 0 216 20" value="null" editformat="yyyy.MM.dd" onkillfocus="cal_onkillfocus" onkeydown="fn_onkeydown"/>
  8. <Static id="Static00" text="~" position="absolute 100 0 116 20" style="align:center middle; "/>
  9. <Calendar id="cal_from" taborder="0" autoselect="true" type="spin" dateformat="yyyy.MM.dd" position="absolute 0 0 100 20" value="null" editformat="yyyy.MM.dd" onkillfocus="cal_from_onkillfocus" onchanged="cal_from_onchanged" onkeydown="fn_onkeydown"/>
  10. <Div id="div_Base2" taborder="4" tabstop="false" style="background:white; " position="absolute 198 1 214 19"/>
  11. <Button id="btn_Cal" taborder="2" onclick="btn_Cal_onclick" class="btn_month" position="absolute 200 3 214 18"/>
  12. <Div id="div_Base1" taborder="3" tabstop="false" style="background:white;" position="absolute 81 1 99 19"/>
  13. <Button id="btn_Cal00" taborder="5" onclick="btn_Cal_onclick" class="btn_month" position="absolute 84 3 98 18"/>
  14. </Layout>
  15. </Layouts>
  16. <Script type="xscript4.0"><![CDATA[/***************************************************************************************
  17. * System Name : KMTC
  18. * Job Name : Composite
  19. * File Name : cp_periodCal.xfdl
  20. * Creator : TOBESOFT
  21. * Make Date : 2013.01.18
  22. *
  23. * Description : Calendar Day Period Select Composite
  24. *---------------------------------------------------------------------------------------
  25. * Modify Date Modifier Modify Description
  26. *---------------------------------------------------------------------------------------
  27. * 2013.01.18 TOBESOFT Initial Make Program
  28. *
  29. *---------------------------------------------------------------------------------------
  30. ****************************************************************************************/
  31. //=======================================================================================
  32. // Common Lib Include
  33. //---------------------------------------------------------------------------------------
  34. //=======================================================================================
  35. // Global Form Variable
  36. //---------------------------------------------------------------------------------------
  37. var iv_aRtn = new Array(2);
  38. var iv_event;
  39. var iv_sDate;
  40. var iv_nLimit = 0;
  41. var iv_sTitle = "";
  42. var iv_Curr = "";
  43. var iv_bNotNull = true;
  44. /****************************************************************************************
  45. * Description : Form Initialization
  46. * Argument : obj : Object Event has occurred
  47. * : e : Event Object
  48. * return :
  49. ****************************************************************************************/
  50. function cp_periodCal_onload(obj:Form, e:LoadEventInfo)
  51. {
  52. var objDate = new Date();
  53. iv_sDate = objDate.toFormatString("%Y%m%d");
  54. cal_from.value = iv_sDate;
  55. cal_to.value = iv_sDate;
  56. }
  57. //=======================================================================================
  58. // Event
  59. //---------------------------------------------------------------------------------------
  60. function fn_onkeydown(obj, e)
  61. {
  62. if(e.keycode == 13)
  63. {
  64. var sCompNm = this.name;
  65. if(sCompNm.indexOf("_S") > -1)
  66. {
  67. ufn_compositeEvent("ufn_search","");
  68. }
  69. }
  70. }
  71. /****************************************************************************************
  72. * Components : Button
  73. * Event : onclick
  74. * Argument : 01.obj : Object Event has occurred
  75. * : 02.e : Event Object
  76. * Description : Selected popup button
  77. ****************************************************************************************/
  78. function btn_Cal_onclick(obj:Button, e:ClickEventInfo)
  79. {
  80. if(cal_from.text == undefined){
  81. cal_from.value = iv_sDate;
  82. }
  83. if(cal_to.text == undefined){
  84. cal_to.value = iv_sDate;
  85. }
  86. var aArg = new Array(2);
  87. if(iv_bNotNull){
  88. aArg[0] = ufn_getDateToStr(cal_from.value);
  89. aArg[1] = ufn_getDateToStr(cal_to.value);
  90. }else{
  91. aArg[0] = cal_from.value;
  92. aArg[1] = cal_to.value;
  93. }
  94. var aRtn = ufn_Calendar(obj, "F", aArg);
  95. if(aRtn <> null)
  96. {
  97. cal_from.value = aRtn[0];
  98. cal_to.value = aRtn[1];
  99. if(!ufn_isNull(iv_event)) ufn_compositeEvent(iv_event,this.name);
  100. }
  101. }
  102. /****************************************************************************************
  103. * Components : Calendar
  104. * Event : onchange
  105. * Argument : 01.obj : Object Event has occurred
  106. * : 02.e : Event Object
  107. * Description : When the date changes
  108. ****************************************************************************************/
  109. function cal_from_onchanged(obj:Calendar, e:ChangeEventInfo)
  110. {
  111. if(ufn_isEmpty(cal_from.value) == true || ufn_isEmpty(cal_to.value) == true){
  112. return false;
  113. }
  114. if(obj.name == "cal_from"){
  115. var sFromDate = ufn_getDateToStr(cal_from.value);
  116. var sToDate = ufn_getDateToStr(cal_to.value);
  117. if(ufn_isDate(sToDate) == true && ufn_isDate(sToDate) == true){
  118. var retVal = ufn_compareDate(sFromDate, sToDate);
  119. if(retVal > 0){
  120. alert("Select period incorrect.");
  121. cal_from.value = "";
  122. return false;
  123. }
  124. }else{
  125. alert("The month format is not.");
  126. cal_from.value = "";
  127. return false;
  128. }
  129. }
  130. if(!ufn_isNull(iv_event)) ufn_compositeEvent(iv_event,this.name);
  131. }
  132. /****************************************************************************************
  133. * Components : Calendar
  134. * Event : onchange
  135. * Argument : 01.obj : Object Event has occurred
  136. * : 02.e : Event Object
  137. * Description : When the date changes
  138. ****************************************************************************************/
  139. function cal_to_onchanged(obj:Calendar, e:ChangeEventInfo)
  140. {
  141. if(ufn_isEmpty(cal_from.value) == true || ufn_isEmpty(cal_to.value) == true){
  142. return false;
  143. }
  144. if(obj.name == "cal_to"){
  145. var sFromDate = ufn_getDateToStr(cal_from.value);
  146. var sToDate = ufn_getDateToStr(cal_to.value);
  147. if(ufn_isDate(sToDate) == true && ufn_isDate(sToDate) == true){
  148. var retVal = ufn_compareDate(sFromDate, sToDate);
  149. if(retVal > 0){
  150. alert("Select period incorrect.");
  151. cal_to.value = "";
  152. return false;
  153. }
  154. }else{
  155. alert("The month format is not.");
  156. cal_to.value = "";
  157. return false;
  158. }
  159. }
  160. if(!ufn_isNull(iv_event)) ufn_compositeEvent(iv_event,this.name);
  161. }
  162. //=======================================================================================
  163. // User Function
  164. //---------------------------------------------------------------------------------------
  165. /****************************************************************************************
  166. * Description : 컴포지트 이벤트 호출 함수
  167. * Argument : sEventId - 호출할 이벤트 ID
  168. * sCompNm - 컴포지트명
  169. * @return N / A
  170. ****************************************************************************************/
  171. function ufn_compositeEvent(sEventId,sCompNm)
  172. {
  173. var lv_oFrame = this.getOwnerFrame();
  174. var lv_bInhForm = ufn_isNull(lv_oFrame.bInhForm) ? false : lv_oFrame.bInhForm;
  175. var lv_bMdiForm = ufn_isNull(lv_oFrame.bMdiForm) ? false : lv_oFrame.bMdiForm;
  176. var lv_bMdiPopForm = ufn_isNull(lv_oFrame.bMdiPopForm) ? false : lv_oFrame.bMdiPopForm;
  177. try{
  178. if(lv_bInhForm)
  179. {
  180. if(lv_bMdiForm == true || lv_bMdiPopForm == true)
  181. {
  182. if(ufn_isNull(sCompNm))
  183. {
  184. eval("this.getOwnerFrame().form.div_Layout.div_Work."+sEventId+"()");
  185. }
  186. else
  187. {
  188. eval("this.getOwnerFrame().form.div_Layout.div_Work."+sEventId+"('"+sCompNm+"')");
  189. }
  190. }
  191. else
  192. {
  193. if(ufn_isNull(sCompNm))
  194. {
  195. eval("this.getOwnerFrame().form."+sEventId+"()");
  196. }
  197. else
  198. { ;
  199. eval("this.getOwnerFrame().form."+sEventId+"('"+sCompNm+"')");
  200. }
  201. }
  202. }
  203. else
  204. {
  205. if(ufn_isNull(sCompNm))
  206. {
  207. eval(sEventId+"()");
  208. }
  209. else
  210. {
  211. eval(sEventId+"('"+sCompNm+"')");
  212. }
  213. }
  214. }catch(err){}
  215. }
  216. /****************************************************************************************
  217. * Description : Converted to a String Date Type
  218. * Argument : date date Type
  219. * return : yyyyMMdd
  220. ****************************************************************************************/
  221. function ufn_getDateToStr(date)
  222. {
  223. if(ufn_isNull(date)) return;
  224. var strYear = date.getYear().toString();
  225. var sMonth = (date.getMonth()+1).toString();
  226. var sDate = date.getDate().toString();
  227. if(strYear.length==2)
  228. strYear = '19'+strYear;
  229. else if(strYear.length==1)
  230. strYear = '190'+strYear;
  231. if(sMonth.length==1)
  232. sMonth = '0'+sMonth;
  233. if(sDate.length==1)
  234. sDate = '0'+sDate;
  235. return strYear+sMonth+sDate;
  236. }
  237. /****************************************************************************************
  238. * Description : 입력값이 null 또는 wihte space로만 이루어져 있으면 빈문자를 리턴하는 함수
  239. * Argument : sValue String
  240. * return : String
  241. ****************************************************************************************/
  242. function ufn_isEmpty(sValue)
  243. {
  244. if (new String(sValue).valueOf() == "undefined") return "";
  245. if (sValue == null) return "";
  246. var lv_sChkStr = new String(sValue);
  247. if (lv_sChkStr == null) return "";
  248. if (lv_sChkStr.toString().length == 0 ) return "";
  249. return sValue;
  250. }
  251. /****************************************************************************************
  252. * Description : 입력값이 null 또는 wihte space로만 이루어져 있는지 확인 하는 함수
  253. * Argument : value 입력값
  254. * return : boolean. null(혹은 white space) 여부
  255. ****************************************************************************************/
  256. function ufn_isNull(sValue)
  257. {
  258. if (new String(sValue).valueOf() == "undefined") return true;
  259. if (sValue == null) return true;
  260. var lv_sChkStr = new String(sValue);
  261. if (lv_sChkStr == null) return true;
  262. if (lv_sChkStr.toString().length == 0 ) return true;
  263. return false;
  264. }
  265. /****************************************************************************************
  266. * Description : Check the validity date.
  267. * Argument : sDate yyyyMM or yyyyMMdd, ex) "201205" or "20120506"
  268. * return : boolean
  269. ****************************************************************************************/
  270. function ufn_isDate(sDate)
  271. {
  272. var retVal;
  273. switch(sDate.length)
  274. {
  275. case 6://yyyyMM
  276. retVal = ufn_isYM(sDate);
  277. break;
  278. case 8://yyyyMMdd
  279. retVal = ufn_isYMD(sDate);
  280. break;
  281. default:
  282. retVal = false;
  283. break;
  284. }
  285. return retVal;
  286. }
  287. /****************************************************************************************
  288. * Description : Check the date format
  289. * Argument : sDate yyyyMMdd, ex) "20120506"
  290. * return : boolean
  291. ****************************************************************************************/
  292. function ufn_isYMD(sDate)
  293. {
  294. if (sDate.length != 8 || !isNumeric(sDate)) {
  295. return false;
  296. }
  297. var strYM = String(sDate).substr(0,6); // yyyyMM
  298. if (!ufn_isYM(strYM)) {
  299. return false;
  300. }
  301. var nDay = toNumber(String(sDate).substr(6,2)); // dd
  302. var nLastDay = toNumber(ufn_getLastDay(strYM));
  303. if (nDay < 1 || nDay > nLastDay) {
  304. return false;
  305. }
  306. return true;
  307. }
  308. /****************************************************************************************
  309. * Description : Check the date format
  310. * Argument : sDate yyyyMM, ex) "201205"
  311. * return : boolean
  312. ****************************************************************************************/
  313. function ufn_isYM(sDate)
  314. {
  315. if (sDate.length != 6 || !isNumeric(sDate)) {
  316. return false;
  317. }
  318. var nYear = toNumber(String(sDate).substr(0,4));
  319. var nMonth = toNumber(String(sDate).substr(4,2));
  320. if((nMonth < 1) || (nMonth > 12)) {
  321. return false;
  322. }
  323. return true;
  324. }
  325. /****************************************************************************************
  326. * Description : Compare the two dates.
  327. * Argument : sFormDate yyyyMMdd ex) "20120501"
  328. sToDate yyyyMMdd ex) "20120530"
  329. * @return
  330. * <p>1. The date is equal to two : return 0</p>
  331. * <p>2. sFormDate < sToDate : return -1</p>
  332. * <p>3. strFromDate > sToDate : return 1</p>
  333. * <p>4. Unless the date format : return null</p>
  334. ****************************************************************************************/
  335. function ufn_compareDate(sFormDate, sToDate)
  336. {
  337. var retVal;
  338. if (ufn_isDate(sFormDate) && ufn_isDate(sToDate)) {
  339. if (sFormDate == sToDate) {
  340. retVal = 0;
  341. } else if (sFormDate < sToDate) {
  342. retVal = -1;
  343. } else if (sFormDate > sToDate) {
  344. retVal = 1;
  345. }
  346. }
  347. return retVal;
  348. }
  349. /****************************************************************************************
  350. * Description : User Composite Get Data Method
  351. * Argument : none
  352. * return : none
  353. ****************************************************************************************/
  354. function getData()
  355. {
  356. iv_aRtn = new Array(2);
  357. if(iv_bNotNull){
  358. iv_aRtn[0] = ufn_getDateToStr(cal_from.value);
  359. iv_aRtn[1] = ufn_getDateToStr(cal_to.value);
  360. }else{
  361. iv_aRtn[0] = cal_from.value;
  362. iv_aRtn[1] = cal_to.value;
  363. }
  364. return iv_aRtn;
  365. }
  366. /****************************************************************************************
  367. * Description : User Composite Set Data Method
  368. * Argument : none
  369. * return : none
  370. ****************************************************************************************/
  371. function setData(aData)
  372. {
  373. if((!ufn_isDate(aData[0])) || (!ufn_isDate(aData[1]))) return;
  374. trace(aData[0]+" "+aData[1]);
  375. cal_from.value = aData[0];
  376. cal_to.value = aData[1];
  377. }
  378. function setEmpty()
  379. {
  380. cal_from.value = "";
  381. cal_to.value = "";
  382. }
  383. function setIsNull()
  384. {
  385. iv_bNotNull = false;
  386. }
  387. /****************************************************************************************
  388. * Description : User Composite Set Blank Method
  389. * Argument : none
  390. * return : none
  391. ****************************************************************************************/
  392. function setBlank()
  393. {
  394. cal_from.value = "";
  395. cal_to.value = "";
  396. }
  397. /****************************************************************************************
  398. * Description : When the user select a date set limits
  399. * Argument : 1. sTitle : Title
  400. * : 2. nLimit : number
  401. * : 3. sFlag :
  402. * return : none
  403. ****************************************************************************************/
  404. function setLimit(sTitle, nLimit, sFlag)
  405. {
  406. iv_sTitle = sTitle
  407. iv_nLimit = nLimit;
  408. if(ufn_isEmpty(sFlag)){
  409. iv_Curr = sFlag;
  410. }
  411. }
  412. /****************************************************************************************
  413. * Description : User composite set required
  414. * Argument : none
  415. * return : none
  416. ****************************************************************************************/
  417. function setRequestment(bReq)
  418. {
  419. if(bReq)
  420. {
  421. cal_from.class = "input_essential";
  422. cal_to.class = "input_essential";
  423. }
  424. else
  425. {
  426. cal_from.class = "";
  427. cal_to.class = "";
  428. }
  429. }
  430. function setEnbale(bReq)
  431. {
  432. cal_from.enable = bReq;
  433. cal_to.enable = bReq;
  434. btn_Cal.enable = bReq;
  435. if(bReq)
  436. {
  437. div_Base1.style.background = "white";
  438. div_Base2.style.background = "white";
  439. }
  440. else
  441. {
  442. div_Base1.style.background = "#eeeeee";
  443. div_Base2.style.background = "#eeeeee";
  444. }
  445. }
  446. /****************************************************************************************
  447. * Description : User Composite Set Event Method
  448. * Argument : none
  449. * return : none
  450. ****************************************************************************************/
  451. function setCallEvent(sEvent)
  452. {
  453. iv_event = sEvent;
  454. }
  455. /****************************************************************************************
  456. * Description : User Composite Set NullValue Method
  457. * Argument : none
  458. * return : none
  459. ****************************************************************************************/
  460. function setNullValue(sGbn)
  461. {
  462. if(sGbn == "F")
  463. {
  464. cal_from.value = null;
  465. }
  466. else if(sGbn == "T")
  467. {
  468. cal_to.value = null;
  469. }
  470. else if(sGbn == "A")
  471. {
  472. cal_from.value = null;
  473. cal_to.value = null;
  474. }
  475. }
  476. /****************************************************************************************
  477. * Description : Calendar option select
  478. * Argument : 1.oBtn : Button object
  479. * : 2.sGb : Date type
  480. * : 3.sDate : Selected date
  481. * : 4.sMenuId : Form ID
  482. * : 5.sType :
  483. * return : Selected date
  484. ****************************************************************************************/
  485. var iv_CalendarDateFg;
  486. var iv_CalendarValue;
  487. var iv_bCalendarNaviFq = true;
  488. function ufn_Calendar(oBtn,sGb,vDate,sMenuId,sType)
  489. {
  490. if(sMenuId == null) sMenuId = "";
  491. if(sType == null) sType = "";
  492. var sUrl;
  493. var sName;
  494. var objPdvCal = new PopupDiv();
  495. if(sGb == "F")
  496. {
  497. sName = "PopDiv_CalendarF";
  498. sUrl = "COMPOSITE::Comm_periodDayCalendar.xfdl";
  499. objPdvCal.init(sName, 0, 0, 410, 255);
  500. objPdvCal.text = sName;
  501. }
  502. // Add Object to Parent Form
  503. this.addChild(sName, objPdvCal);
  504. objPdvCal.style.border = "none";
  505. objPdvCal.style.background = "transparent";
  506. objPdvCal.style.opacity = 100;
  507. objPdvCal.url = sUrl;
  508. // Show Object
  509. objPdvCal.show();
  510. if((sGb == "W") || (sGb == "D")) objPdvCal.msDataFg = sGb;
  511. objPdvCal.iv_mvArgValue = vDate;
  512. objPdvCal.fn_CrCal();
  513. var nPosX = system.clientToScreenX(cal_from, cal_from.position.left);
  514. var nPosY = system.clientToScreenY(cal_from, cal_from.position.height);
  515. var rtn = objPdvCal.trackPopup(nPosX,nPosY);
  516. this.removeChild(sName);
  517. objPdvCal.destroy();
  518. return rtn;
  519. }
  520. function cal_onkillfocus(obj:Calendar, e:KillFocusEventInfo)
  521. {
  522. if(iv_bNotNull)
  523. {
  524. if(ufn_isNull(obj.value)) obj.setFocus();
  525. }
  526. }
  527. /****************************************************************************************
  528. * Description : Returns the last date
  529. * Argument : sDate yyyyMM, ex) "201205"
  530. * return : Last date(dd)
  531. ****************************************************************************************/
  532. function ufn_getLastDay(sDate)
  533. {
  534. var lv_sRetVal = "";
  535. if (sDate == null) {
  536. var date = (new Date()).addMonth(1);
  537. }
  538. else {
  539. var date = new Date(parseInt(String(sDate).substr(0,4)),parseInt(String(sDate).substr(4,2)),1);
  540. }
  541. date = (new Date(date)).addDate((new Date(date)).getDate()*-1);
  542. lv_sRetVal = (new Date(date)).getFullYear()
  543. + (((new Date(date)).getMonth() + 1) + "").padLeft(2, '0')
  544. + ((new Date(date)).getDate() + "").padLeft(2, '0');
  545. return (lv_sRetVal);
  546. }
  547. ]]></Script>
  548. </Form>
  549. </FDL>