PageRenderTime 28ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/templates/IWnoteboard_user_nova.tpl

https://github.com/intraweb-modules13/IWnoteboard
Smarty Template | 355 lines | 337 code | 18 blank | 0 comment | 60 complexity | 8a822b8069dce5fcd00bf81cbe12c293 MD5 | raw file
  1. <script language="javascript">
  2. function sendNote(){
  3. var f=document.forms['new_note'];
  4. var j=0;
  5. if(f.fitxer.value!="" && "{{$extensions}}".indexOf(f.fitxer.value.substring(f.fitxer.value.length-3,f.fitxer.value.length))==-1 && !error){
  6. //for gt detection
  7. alert("{{gt text="The extension of the attached file is not accepted. Allowed extensions are: "}}{{$extensions}}");
  8. var error=true;
  9. }
  10. {{if not $shipHeadersLines}}
  11. if(!error){
  12. if(!checkDate(f.caduca) || !checkDate(f.titulin) || !checkDate(f.titulout)){
  13. var error=true;
  14. }
  15. }
  16. {{/if}}
  17. if(!error){
  18. if(!chkdate()){
  19. var error=true;
  20. }
  21. }
  22. {{if $tria}}
  23. if(!error){
  24. for (var i=0; i<f.elements.length; i++) {
  25. var e = f.elements[i];
  26. if ((e.name != 'allbox') && (e.type=='checkbox') && (e.name!='admet_comentaris') && e.checked)
  27. var j=1;
  28. }
  29. }
  30. if(!error && j==0){
  31. //for gt detection
  32. alert("{{gt text="There are no chosen addressee for the note"}}");
  33. var error=true;
  34. }
  35. {{/if}}
  36. if(!error){
  37. //for gt detection
  38. resposta=confirm("{{gt text="Do you really want to send the note?"}}");
  39. }
  40. if(f.m.value=="n"){
  41. f.action="index.php?module=IWnoteboard&func=crear"
  42. }else{
  43. f.action="index.php?module=IWnoteboard&func=update"
  44. }
  45. if(!error && resposta){
  46. f.submit();
  47. }
  48. }
  49. // Original JavaScript code by Chirp Internet: www.chirp.com.au
  50. // Please acknowledge use of this code by including this header.
  51. function checkDate(field) {
  52. var allowBlank = true;
  53. var minYear = 00;
  54. var maxYear = 99;
  55. var errorMsg = "";
  56. // regular expression to match requiredate format
  57. re = /^(\d{1,2})\/(\d{1,2})\/(\d{2})$/;
  58. if(field.value != '') {
  59. if(regs = field.value.match(re)) {
  60. if(regs[1] < 1 || regs[1] > 31) {
  61. //for gt detection
  62. errorMsg = "{{gt text="Some of the dates in the form are not correct"}} " + field.value;
  63. } else if(regs[2] < 1 || regs[2] > 12) {
  64. //for gt detection
  65. errorMsg = "{{gt text="Some of the dates in the form are not correct"}} " + field.value;
  66. } else if(regs[3] < minYear || regs[3] > maxYear) {
  67. //for gt detection
  68. errorMsg = "{{gt text="Some of the dates in the form are not correct"}} " + field.value;
  69. }
  70. } else {
  71. //for gt detection
  72. errorMsg = "{{gt text="Some of the dates in the form are not correct"}} " + field.value;
  73. }
  74. } else if(!allowBlank) {
  75. //for gt detection
  76. errorMsg = "{{gt text="Some of the dates in the form are not correct"}}";
  77. }
  78. if(errorMsg != "") {
  79. alert(errorMsg);
  80. field.focus();
  81. return false;
  82. }
  83. return true;
  84. }
  85. function CheckAll() {
  86. var f=document.forms['new_note'];
  87. for (var i=0; i<f.elements.length; i++) {
  88. var e = f.elements[i];
  89. if ((e.name != 'allbox') && (e.type=='checkbox') && (e.name!='admet_comentaris') && (e.name!='modremitent') && (e.name!='segur') && (e.name!='public'))
  90. e.checked = f.allbox.checked;
  91. }
  92. }
  93. function CheckCheckAll() {
  94. var TotalBoxes = 0;
  95. var TotalOn = 0;
  96. var f=document.forms['new_note'];
  97. for (var i=0; i<f.elements.length; i++) {
  98. var e = f.elements[i];
  99. if ((e.name != 'allbox') && (e.type=='checkbox') && (e.name!='admet_comentaris') && (e.name!='modremitent') && (e.name!='segur') && (e.name!='public')) {
  100. TotalBoxes++;
  101. if (e.checked) {
  102. TotalOn++;
  103. }
  104. }
  105. }
  106. if (TotalBoxes==TotalOn) {
  107. f.allbox.checked=true;
  108. } else {
  109. f.allbox.checked=false;
  110. }
  111. }
  112. function chkdate(){
  113. var f=document.forms['new_note'];
  114. data = new Date(20 + f.data.value.substr(6,2), f.data.value.substr(3,2), f.data.value.substr(0,2))
  115. caduca = new Date(20 + f.caduca.value.substr(6,2), f.caduca.value.substr(3,2), f.caduca.value.substr(0,2))
  116. var result = true;
  117. if (data > caduca){
  118. //for gt detection
  119. alert("{{gt text="The closing date is incorrect"}}");
  120. result = false;
  121. }
  122. return result;
  123. }
  124. </script>
  125. <noscript>
  126. {assign var='noscript' value='true'}
  127. </noscript>
  128. <link rel="stylesheet" href="modules/IWmain/js/calendar/css/jscal2.css" type="text/css" />
  129. <link rel="stylesheet" href="modules/IWmain/js/calendar/css/border-radius.css" type="text/css" />
  130. <link rel="stylesheet" href="modules/IWmain/js/calendar/css/style.css" type="text/css" />
  131. <script type="text/javascript" src="modules/IWmain/js/calendar/jscal2.js"></script>
  132. <script type="text/javascript" src="modules/IWmain/js/calendar/lang/ca.js"></script>
  133. {include file="IWnoteboard_user_menu.tpl" pageTitle=$titol}
  134. <form class="z-form" id="new_note" enctype="multipart/form-data" method="post" action="">
  135. <input type="hidden" name="csrftoken" value="{insert name='csrftoken'}" />
  136. <input type="hidden" name="verifica" value="{$verifica}" />
  137. <input type="hidden" name="m" value="{$m}" />
  138. <input type="hidden" name="nid" value="{$nid}" />
  139. <input type="hidden" name="saved" value="{$saved}" />
  140. <input type="hidden" name="tema" value="{$tema}" />
  141. <fieldset>
  142. <legend>{gt text="Note content"}</legend>
  143. {if $temes_MS|@count gt 0}
  144. <div class="z-formrow">
  145. <label for="topic">{gt text="Choose a topic"}</label>
  146. <select name="tid">
  147. <option></option>
  148. {section name=temes_MS loop=$temes_MS}
  149. <option value="{$temes_MS[temes_MS].id}" {if $tid eq $temes_MS[temes_MS].id or $tema eq $temes_MS[temes_MS].id}selected{/if}>{$temes_MS[temes_MS].name}</option>
  150. {/section}
  151. </select>
  152. </div>
  153. {/if}
  154. {if $multiLanguage eq 1}
  155. <div class="z-formrow">
  156. <label for="language">{gt text="Choose a language"}</label>
  157. {html_select_languages id=mlsettings_language name=language selected=$language installed=1 all=true}
  158. </div>
  159. {/if}
  160. <div class="z-formrow">
  161. <label for="noticia">{gt text="Note content"}</label>
  162. <textarea id="noticia" name="noticia" cols="70" rows="7">{$noticia|safetext}</textarea>
  163. </div>
  164. <div class="z-formrow">
  165. <label for="data">{gt text="Publish date"}</label>
  166. <input type="text" name="data" id="data" maxlength="8" size="8" value="{$data}" onFocus=blur() />
  167. </div>
  168. <div class="z-formrow">
  169. <label for="caduca">{gt text="Closing date"}</label>
  170. <div class="z-formnote">
  171. <input size="10" id="caducaDate" name="caduca" value="{$caduca}" onfocus="blur();" />
  172. <img id="caducaDate_btn" src="modules/IWnoteboard/images/calendar.gif" style="cursor:pointer;" />
  173. </div>
  174. </div>
  175. </fieldset>
  176. {if not $shipHeadersLines}
  177. <fieldset>
  178. <legend>{gt text="Headline"}</legend>
  179. <div class="z-formrow">
  180. <label for="titular">{gt text="Headline text"}</label>
  181. <input id="titular" name="titular" id="titular" value="{$titular|safetext}" />
  182. </div>
  183. <div class="z-formrow">
  184. <label for="titulin">{gt text="Since"}</label>
  185. <div class="z-formnote">
  186. <input size="10" id="titulinDate" name="titulin" value="{$titulin}" onfocus="blur();" />
  187. <img id="titulinDate_btn" src="modules/IWnoteboard/images/calendar.gif" style="cursor:pointer;" />
  188. </div>
  189. </div>
  190. <div class="z-formrow">
  191. <label for="titulout">{gt text="Up to"}</label>
  192. <div class="z-formnote">
  193. <input size="10" id="tituloutDate" name="titulout" value="{$titulout}" onfocus="blur();" />
  194. <img id="tituloutDate_btn" src="modules/IWnoteboard/images/calendar.gif" style="cursor:pointer;" />
  195. </div>
  196. </div>
  197. </fieldset>
  198. {/if}
  199. <fieldset>
  200. <legend>{gt text="Additional information"}</legend>
  201. <div class="z-formrow">
  202. <label for="mes_info">{gt text="Link to find more information"}</label>
  203. <input type="text" id="mes_info" name="mes_info" size="50" maxlength="150" value="{$mes_info|safetext}" />
  204. </div>
  205. <div class="z-formrow">
  206. <label for="text">{gt text="Text for the link"}</label>
  207. <input type="text" name="text" id="text" size="50" maxlength="150" value="{$text|safetext}" />
  208. </div>
  209. <div class="z-formrow">
  210. <label for="file">{gt text="Add an attached file"}</label>
  211. {if $m eq 'n'}
  212. <input type="file" id="file" name="fitxer" size="50" />
  213. {else}
  214. {if $fitxer eq ""}
  215. <input type="file" name="fitxer" size="50" />
  216. <input type="hidden" name="new_file" value="1" />
  217. {else}
  218. <input type="hidden" name="fitxer" value="{$fitxer|safetext}" />
  219. <input type="hidden" name="new_file" value="0" />
  220. {$fitxer}
  221. <input type="checkbox" name="segur" value="1" />{gt text="Erase the file attached to the note"}
  222. {/if}
  223. {/if}
  224. <div class="z-formnote z-informationmsg">
  225. {gt text="Allowed extensions - "} {$extensions}
  226. </div>
  227. </div>
  228. <div class="z-formrow">
  229. <label for="textfitxer">{gt text="Attached file text"}</label>
  230. <input type="text" id="textfitxer" name="textfitxer" size="50" maxlength="50" value="{$textfitxer}" />
  231. </div>
  232. </fieldset>
  233. <fieldset>
  234. <legend>{gt text="Addressee"}</legend>
  235. <table border="0" width="100%">
  236. {if $tria}
  237. <tr>
  238. <td>
  239. {gt text="All"}
  240. </td>
  241. <td align="right" valign="top">
  242. <input name="allbox" onclick="CheckAll();" type="checkbox" value="{gt text="Check all"}" /></td>
  243. </td>
  244. </tr>
  245. {section name=grups_array loop=$grups_array}
  246. <tr>
  247. <td align="left" valign="top">
  248. --> {$grups_array[grups_array].name}
  249. </td>
  250. <td align="right" valign="top">
  251. <input type="checkbox" onclick="CheckCheckAll();" name="destinataris[{$smarty.section.grups_array.rownum-1}]" {$grups_array[grups_array].select} value="{$grups_array[grups_array].id}">
  252. </td>
  253. </tr>
  254. {/section}
  255. {else}
  256. <tr>
  257. <td align="left" valign="top">
  258. {gt text="This note will be sent to all registered users"}
  259. </td>
  260. </tr>
  261. {/if}
  262. <tr>
  263. <td colspan="2">&nbsp;
  264. </td>
  265. </tr>
  266. <tr>
  267. <td>
  268. {gt text="Comments allowed"}
  269. </td>
  270. <td align="right">
  271. <input type="checkbox" {if $admet_comentaris OR $m eq 'n' AND $commentCheckedByDefault eq 1}checked{/if} name="admet_comentaris" value="1" />
  272. </td>
  273. </tr>
  274. {if $m eq 'e'}
  275. <tr>
  276. <td>
  277. {gt text="Send note to first line"}
  278. </td>
  279. <td align="right">
  280. <input type="checkbox" name="firstLine" value="1" />
  281. </td>
  282. </tr>
  283. {/if}
  284. {if $saved eq 1}
  285. <tr>
  286. <td>
  287. <strong>{gt text="Put me as the sender of the note"}</strong>
  288. </td>
  289. <td align="right">
  290. <input type="checkbox" name="modremitent" value="1" />
  291. </td>
  292. </tr>
  293. {/if}
  294. </table>
  295. </fieldset>
  296. <div class="z-center">
  297. {if $noscript eq 'true'}
  298. <span class="z-buttons">
  299. <a onClick="javascript:sendNote()" title="{$submit}">
  300. {img modname='core' src='button_ok.png' set='icons/small'} {$submit}
  301. </a>
  302. </span>
  303. <span class="z-buttons">
  304. <a href="#" onclick ='javascript:history.back(-1)'>
  305. {img modname='core' src='button_cancel.png' set='icons/small' __alt="Cancel" __title="Cancel"} {gt text="Cancel"}
  306. </a>
  307. </span>
  308. {/if}
  309. <noscript>
  310. <div class="z-button">
  311. {button src='button_ok.png' set='icons/small' __alt="Create" __title="Create"} {$submit}
  312. </div>
  313. <div class="z-button">
  314. <a href="{modurl modname='IWnoteboard' type='user' func='main'}">
  315. {img modname='core' src='button_cancel.png' set='icons/small' __alt="Cancel" __title="Cancel"} {gt text="Cancel"}
  316. </a>
  317. </div>
  318. </noscript>
  319. </div>
  320. </form>
  321. {notifydisplayhooks eventname='iwnoteboard.ui_hooks.iwnoteboard.form_edit'}
  322. <script type="text/javascript">
  323. var caduca = Calendar.setup({
  324. onSelect : function(caduca) { caduca.hide() }
  325. });
  326. caduca.manageFields("caducaDate_btn", "caducaDate", "%d/%m/%y");
  327. {{if not $shipHeadersLines}}
  328. var titulin = Calendar.setup({
  329. onSelect : function(titulin) { titulin.hide() }
  330. });
  331. titulin.manageFields("titulinDate_btn", "titulinDate", "%d/%m/%y");
  332. var titulout = Calendar.setup({
  333. onSelect : function(titulout) { titulout.hide() }
  334. });
  335. titulout.manageFields("tituloutDate_btn", "tituloutDate", "%d/%m/%y");
  336. {{/if}}
  337. </script>