calcDateTimeAdd.xts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. BI and PM: qs
  5. (C) Copyright IBM Corp. 2001, 2017
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <!--
  13. Used for add days, add months, add years
  14. -->
  15. <xts:morphlet resolverBase="prompting" version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/" messageBase="messages/QSRVUITextPL.xml,messages/portal.xml,messages/portalRL.xml" requiredCapability="canUseQueryStudio">
  16. <xts:block id="browserDetection" path="qs/browserDetection.xslt" mode="interpret" type="exec" processor="XSLT" contentId="browserDetection" partId="1"/>
  17. <xts:block id="page" type="exec" mode="output" processor="XSLT" mimeType="text/html" dependency="browserDetection">
  18. <!-- get the debug logic sheet -->
  19. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  20. <!-- get the new theme stuff -->
  21. <!-- apply the following logicsheets in order -->
  22. <xts:logicsheet path="qs/logicsheets/calc_theme.xsl"/>
  23. <xts:logicsheet path="logicsheets/portal.xsl"/>
  24. <xts:logicsheet path="qs/logicsheets/dialogs.xsl"/>
  25. <xts:logicsheet path="logicsheets/presentation/dialog/framework.xsl"/>
  26. <xts:logicsheet path="logicsheets/presentation/layout.xsl"/>
  27. <xts:logicsheet path="logicsheets/presentation/dialog/presentation.xsl"/>
  28. <xts:logicsheet path="logicsheets/presentation/controls/framework.xsl"/>
  29. <xts:logicsheet path="logicsheets/presentation/controls/presentation.xsl"/>
  30. <xts:logicsheet path="logicsheets/cm-logic.xsl"/>
  31. <!-- apply the form logic -->
  32. <xts:logicsheet path="logicsheets/formlogic.xslt"/>
  33. <xsl:stylesheet version="1.0"
  34. xmlns:clcdlg="test_calculationDlg"
  35. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  36. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  37. xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/"
  38. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  39. xmlns:dp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/presentation/"
  40. xmlns:df="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/framework/"
  41. xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/"
  42. xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/"
  43. xmlns:dbg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/debug/"
  44. xmlns:qsdlg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/qs/dialog/"
  45. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  46. exclude-result-prefixes="clcdlg xsl xts lyt pf dp df cp cf dbg qsdlg xtsext">
  47. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  48. <!-- Default variables (like skin) and prompt variables -->
  49. <qsdlg:variables/>
  50. <qsdlg:promptVariables/>
  51. <!-- Prompt Control XSL include -->
  52. <xsl:include href="p_include.xsl"/>
  53. <!-- add any theme variables -->
  54. <df:variables/>
  55. <pf:variables/>
  56. <!-- start the output -->
  57. <xsl:template match="/root">
  58. <dp:page>
  59. <dp:script>
  60. <xsl:call-template name="getPromptCommonIncludes"/>
  61. <xsl:call-template name="gettextBoxIncludes">
  62. <xsl:with-param name="promptLocale" select="$promptLocale"/>
  63. <xsl:with-param name="promptContentLocale" select="$contentLocale"/>
  64. </xsl:call-template>
  65. <link href="{$qsdlgskin}/qs/QSRVDialog.css" type="text/css" rel="stylesheet"/>
  66. <script type="text/javascript">
  67. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/qs/layout.js</xsl:attribute>
  68. <xsl:text/>//<xsl:text/>
  69. </script>
  70. <script type="text/javascript">
  71. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/rv/cvConstants.js</xsl:attribute>
  72. <xsl:text/>//<xsl:text/>
  73. </script>
  74. <script type="text/javascript">
  75. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/rv/common.js</xsl:attribute>
  76. <xsl:text/>//<xsl:text/>
  77. </script>
  78. <script type="text/javascript">
  79. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/rv/cvui.js</xsl:attribute>
  80. <xsl:text/>//<xsl:text/>
  81. </script>
  82. <script type="text/javascript">
  83. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/common/framework/notification/CObserver.js</xsl:attribute>
  84. <xsl:text/>//<xsl:text/>
  85. </script>
  86. <script type="text/javascript">
  87. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/qs/classes/CDialogManager.js</xsl:attribute>
  88. <xsl:text/>//<xsl:text/>
  89. </script>
  90. <script type="text/javascript">
  91. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/qs/classes/CWindowManager.js</xsl:attribute>
  92. <xsl:text/>//<xsl:text/>
  93. </script>
  94. <script type="text/javascript">&lt;!--
  95. var goDialogManager = new CDialogManager();
  96. <clcdlg:jvs/>
  97. var cf = getConfigFrame();
  98. var calcType = cf.dlgGlobalGetParm('xxCalcType');
  99. var calcParentIds = new Array();
  100. var substVarValue = null;
  101. function execute()
  102. {
  103. var before_col_id = cf.dlgGlobalGetParm('xxInsBeforeColid');
  104. var calcOp = document.f.calcList.options[document.f.calcList.selectedIndex].value; // addDays, addMonths, addYears
  105. var calcExpr = "generated";
  106. var unitVal = 1;
  107. var cType = 52;
  108. var listSeparator = goDialogManager.getMiniQueryManager().getListSeparator();
  109. if ((textBoxnumberValue.isValid())&amp;&amp;(document.getElementById("textBoxNumeric").style.display != "none"))
  110. unitVal = textBoxnumberValue.sGetValue();
  111. else if (document.getElementById("textBoxString")&amp;&amp;document.getElementById("textBoxString").style.display != "none")
  112. unitVal = substVarValue;
  113. else
  114. return;
  115. // unitVal should not be empty
  116. // Default to 1
  117. if (! unitVal || unitVal.length === 0)
  118. {
  119. unitVal = "1";
  120. }
  121. switch (calcOp)
  122. {
  123. case "addDays":
  124. calcOp = "adddays";
  125. calcExpr = "_add_days(" + document.f.repSel.options[document.f.repSel.options.selectedIndex].value + listSeparator + " " + unitVal + ")";
  126. break;
  127. case "addMonths":
  128. calcOp = "addmonths";
  129. calcExpr = "_add_months(" + document.f.repSel.options[document.f.repSel.options.selectedIndex].value + listSeparator + " " + unitVal + ")";
  130. break;
  131. default:
  132. calcOp = "addyears";
  133. calcExpr = "_add_years(" + document.f.repSel.options[document.f.repSel.options.selectedIndex].value + listSeparator + " " + unitVal + ")";
  134. break;
  135. }
  136. if (calcType == "date")
  137. {
  138. calcOp += "Date";
  139. cType = 50;
  140. }
  141. else
  142. calcOp += "DateTime";
  143. var calcName = getCalcName();
  144. getConfigFrame().addCalcColumn(before_col_id, calcExpr, calcExpr, calcName, "none", calcOp, "none", "none", cType, 2, "none", -1, "none", calcParentIds);
  145. }
  146. function generateName(withQuotes)
  147. {
  148. var calcName = document.f.calcList.options[document.f.calcList.selectedIndex].value; // addDays, addMonths, addYears
  149. var column = document.f.repSel.options[document.f.repSel.options.selectedIndex].text;
  150. switch (calcName)
  151. {
  152. case "addDays":
  153. calcName = "<xts:string id="CALCULATION_ADD_DAYS_EQUATION" encode="javascript"/>";
  154. break;
  155. case "addMonths":
  156. calcName = "<xts:string id="CALCULATION_ADD_MONTHS_EQUATION" encode="javascript"/>";
  157. break;
  158. default:
  159. calcName = "<xts:string id="CALCULATION_ADD_YEARS_EQUATION" encode="javascript"/>";
  160. break;
  161. }
  162. var unitVal = 1;
  163. if ((textBoxnumberValue.isValid())&amp;&amp;(textBoxnumberValue.sGetValue() > 0))
  164. unitVal = textBoxnumberValue.sGetFormatValue();
  165. else if ((textBoxnumberValue.m_oForm.value)&amp;&amp;(document.getElementById("textBoxNumeric").style.display != "none"))
  166. unitVal = textBoxnumberValue.m_oForm.value;
  167. else if (document.getElementById("textBoxString")&amp;&amp;document.getElementById("textBoxString").style.display != "none")
  168. unitVal = textBoxstringValue.m_oForm.value
  169. calcName = stringReplace (calcName, "\\^1", unitVal);
  170. calcName = stringReplace (calcName, "\\^0", column);
  171. return calcName;
  172. }
  173. function init()
  174. {
  175. attachMouseEvents();
  176. for (var i = 0; i &lt; cf.dlgGlobalSize('xxCalcParentIds'); i++)
  177. {
  178. var id = cf.dlgGlobalGetParmAt('xxCalcParentIds', i);
  179. calcParentIds[i] = id[0];
  180. }
  181. // populate selected columns menu
  182. for (var i = 0; i &lt; cf.dlgGlobalSize('xxColInfo'); i++)
  183. {
  184. var label = cf.dlgGlobalGetParmAt('xxColInfo', i);
  185. document.f.repSel.options[document.f.repSel.options.length] = new Option(label[0], label[1]);
  186. }
  187. var validCalcs = new Array();
  188. for (var i = 0; i &lt; cf.dlgGlobalSize('xxValidCalcItem'); i++)
  189. validCalcs[validCalcs.length] = cf.dlgGlobalGetParmAt('xxValidCalcItem', i);
  190. populateCalculationList(calcType, validCalcs);
  191. // select calculation
  192. document.f.calcList.selectedIndex = cf.dlgGlobalGetParm('xxCalcTypeIdx');
  193. getConfigFrame().cfgSet("CALCULATION_REFRESH", true);
  194. setGlobals(calcType, false);
  195. addInsert();
  196. if (typeof textBoxnumberValue != "undefined")
  197. {
  198. <xsl:choose>
  199. <xsl:when test="/root/browserInfo/isNS6='true'">
  200. textBoxnumberValue.m_oForm.addEventListener("keydown", redrawHint, true);
  201. </xsl:when>
  202. <xsl:otherwise>
  203. textBoxnumberValue.m_oForm.attachEvent("onkeydown", redrawHint);
  204. </xsl:otherwise>
  205. </xsl:choose>
  206. textBoxnumberValue.m_oForm.focus();
  207. }
  208. <xsl:if test="/root/env/param[@name='xxSubstVar']='true'">
  209. <clcdlg:subst_var numeric="true"/>
  210. <xsl:choose>
  211. <xsl:when test="/root/browserInfo/isNS6='true'">
  212. textBoxstringValue.m_oForm.addEventListener("change", redrawHint, true);
  213. </xsl:when>
  214. <xsl:otherwise>
  215. textBoxstringValue.m_oForm.attachEvent("onchange", redrawHint);
  216. </xsl:otherwise>
  217. </xsl:choose>
  218. //hide the second input field
  219. document.getElementById("textBoxString").style.display = "none";
  220. </xsl:if>
  221. loadHint();
  222. }
  223. function redrawHint()
  224. {
  225. setTimeout(loadHint, 10);
  226. }
  227. //--&gt;</script>
  228. </dp:script>
  229. <form style="margin:0px" name="f" method="POST" onsubmit="execute();return false;">
  230. <table border="0" cellspacing="0" cellpadding="0" height="100%" width="100%">
  231. <tr>
  232. <td width="100%" height="0%">
  233. <!-- dialog header -->
  234. <clcdlg:basic_header/>
  235. </td>
  236. </tr>
  237. <tr>
  238. <td width="100%" height="100%" valign="top">
  239. <lyt:layout style="2" border="no">
  240. <lyt:section>
  241. <clcdlg:calculations/>
  242. <dp:input>
  243. <dp:section1>
  244. <xts:string id="CALCULATION_REP_ITEM"/>
  245. </dp:section1>
  246. <dp:section2>
  247. <select name="repSel" size="1" style="width:260" onChange="javascript:loadHint();"/>
  248. </dp:section2>
  249. </dp:input>
  250. <dp:input>
  251. <dp:section1>
  252. <xts:string id="CALCULATION_NUMBER_OF_UNITS"/>
  253. </dp:section1>
  254. <dp:section2>
  255. <table>
  256. <tr>
  257. <td id="textBoxNumeric" valign="bottom">
  258. <xsl:call-template name="getTextBox">
  259. <xsl:with-param name="promptLocale" select="$promptLocale"/>
  260. <xsl:with-param name="promptFormName" select="$promptFormName"/>
  261. <xsl:with-param name="promptRequired" select="'false'"/>
  262. <xsl:with-param name="promptId" select="'numberValue'"/>
  263. <xsl:with-param name="promptHideText" select="'false'"/>
  264. <xsl:with-param name="promptMultiLine" select="'false'"/>
  265. <xsl:with-param name="promptParameter" select="'unitParam'"/>
  266. <xsl:with-param name="promptDataType" select="'integer'"/>
  267. <xsl:with-param name="promptMaxLength" select="'15'"/>
  268. </xsl:call-template>
  269. </td>
  270. <xsl:if test="/root/env/param[@name='xxSubstVar']='true'">
  271. <td id="textBoxString" valign="bottom">
  272. <xsl:call-template name="getTextBox">
  273. <xsl:with-param name="promptLocale" select="$promptLocale"/>
  274. <xsl:with-param name="promptFormName" select="$promptFormName"/>
  275. <xsl:with-param name="promptRequired" select="'false'"/>
  276. <xsl:with-param name="promptId" select="'stringValue'"/>
  277. <xsl:with-param name="promptHideText" select="'false'"/>
  278. <xsl:with-param name="promptMultiLine" select="'false'"/>
  279. <xsl:with-param name="promptParameter" select="'numberParam2'"/>
  280. <xsl:with-param name="promptReadOnly" select="'true'"/>
  281. </xsl:call-template>
  282. </td>
  283. <td id="buttonContainer"/>
  284. </xsl:if>
  285. </tr>
  286. </table>
  287. </dp:section2>
  288. </dp:input>
  289. </lyt:section>
  290. <lyt:section>
  291. <clcdlg:calc_hint/>
  292. </lyt:section>
  293. </lyt:layout>
  294. </td>
  295. </tr>
  296. <tr>
  297. <td width="100%" height="0%">
  298. <!-- Use default buttons [ OK = execute() and CANCEL = hideDialogFrame() ] -->
  299. <clcdlg:buttons/>
  300. </td>
  301. </tr>
  302. <!-- <dbg:dumpxml select="/"/> -->
  303. </table>
  304. </form>
  305. </dp:page>
  306. </xsl:template>
  307. </xsl:stylesheet>
  308. </xts:block>
  309. </xts:morphlet>