Subversion Repositories wimsdev

Rev

Rev 12801 | Rev 12927 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11809 guerimand 1
!! file to manage score restriction for sheet, exam and other
11814 guerimand 2
!! don't forget to declare variable into var.def (with right number if in use) of the module
11870 bpr 3
!! line 1 (2 words)
12801 obado 4
!!  -first : html/put/get
5
!!    html : html form to display
6
!!    put  : initialise var with date in third line
7
!!    get  : verify data from reply and make char wimsdata in output
8
!!  -second : num of variable default empty (in case of several use in a same html page)
11814 guerimand 9
!! line 2 : value to put (default value in the form)
11809 guerimand 10
 
11814 guerimand 11
!distribute line $wims_read_parm into _job,_value
12
!distribute word $_job into _job,_num
11809 guerimand 13
!bound _job within html,put,get,empty default empty
12022 czzmrn 14
!set MAXnbvalue=!defof MAX_TECHVARVAL in wimshome/public_html/bases/sys/define.conf
15
!bound _num between 0 and $MAXnbvalue default $empty
11809 guerimand 16
 
17
!if $_job=empty
12801 obado 18
  !exit
11809 guerimand 19
!endif
11846 guerimand 20
!goto $_job
11809 guerimand 21
 
11846 guerimand 22
:put
23
 !set _value=!words2items $_value
24
 !set _n=!itemcnt $_value
25
 !reset IPscore$_num,begindscore$_num,enddscore$_num,begintscore$_num,endtscore$_num
26
 !for _k=1 to $_n
12801 obado 27
  !set _c=!char 1 of $(_value[$_k])
28
  !if $_c=>
29
    !set begindscore$_num=!char 2 to 9 of $(_value[$_k])
30
    !set begintscore$_num=!char 11 to 15 of $(_value[$_k])
31
  !else
32
    !if $_c=<
33
      !set enddscore$_num=!char 2 to 9 of $(_value[$_k])
34
      !set endtscore$_num=!char 11 to 15 of $(_value[$_k])
35
    !else
36
      !set IPscore$_num=$(IPscore$_num) $(_value[$_k])
37
    !endif
38
  !endif
11846 guerimand 39
 !next _k
12120 guerimand 40
 !let _now=!char 1 to 8 of $wims_now
41
 !if $(begindscore$_num)=$class_creation or $(begindscore$_num)=$empty
42
  !let begindscore$_num=$_now
43
 !endif
11846 guerimand 44
 !default enddscore$_num=$class_expiration
45
 !default begintscore$_num=00:00
46
 !default endtscore$_num=23:59
47
 !exit
48
 
11809 guerimand 49
:html
11870 bpr 50
<ul class="wims_nopuce">
12801 obado 51
  <li>
52
    <label for="begindscore$_num">$wims_name_from</label>
12803 bpr 53
!if $jquery_defined=yes
54
  !read adm/datepickerform.phtml $(begindscore$_num)\
11835 guerimand 55
begindscore$_num\
56
"$class_creation","$class_expiration"
12803 bpr 57
!else
58
  <input size="8" name="begindscore$_num" id="begindscore$_num" value="$(begindscore$_num)" />
59
!endif
12801 obado 60
    <label for="begintscore$_num">$wims_name_at</label>
61
    <input size="5" name="begintscore$_num" id="begintscore$_num" value="$(begintscore$_num)" />
11809 guerimand 62
 
12801 obado 63
    <label for="enddscore$_num">$wims_name_to</label>
12803 bpr 64
!if $jquery_defined=yes
65
  !read adm/datepickerform.phtml $(enddscore$_num)\
11835 guerimand 66
enddscore$_num\
67
"$class_creation","$class_expiration"
12803 bpr 68
!else
69
  <input size="8" name="enddscore$_num" id="enddscore$_num" value="$(enddscore$_num)" />
70
!endif
12801 obado 71
    <label for="endtscore$_num">$wims_name_at</label>
72
    <input size="5" name="endtscore$_num" id="endtscore$_num" value="$(endtscore$_num)" />
73
  </li><li>
74
    <label for="IPscore$_num">$wims_name_IP</label>
75
    <input size="10" name="IPscore$_num" id="IPscore$_num" value="$(IPscore$_num)" placeholder="127.0.0.1" />
76
  </li>
11870 bpr 77
</ul>
11809 guerimand 78
!exit
79
 
80
:get
11836 guerimand 81
!! error are not display to user but default value replace bad value
11814 guerimand 82
!! date format verification
12803 bpr 83
!set _e=begin,end
84
!set _l=$class_creation,$class_expiration
85
!for _t=1 to 2
12801 obado 86
  !set $(_e[$_t])dscore$_num=!text select 0123456789 in $($(_e[$_t])dscore$_num)
87
  !bound $(_e[$_t])dscore$_num between $class_creation and $class_expiration default $(_l[$_t])
88
  !set _y=!char 1 to 4 of $($(_e[$_t])dscore$_num)
89
  !set _m=!char 5 to 6 of $($(_e[$_t])dscore$_num)
90
  !set _d=!char 7 to 8 of $($(_e[$_t])dscore$_num)
91
  !! ---- day and month check (not realy good test should be an exact test of existence of date)
92
  !if $_m<1 or $_m>12 or $_d<1 or $_d>31
93
    !set $(_e[$_t])dscore$_num=$(_l[$_t])
94
  !endif
12803 bpr 95
!next _t
11814 guerimand 96
!! time format verification
12803 bpr 97
!set _l=00:00,23:59
98
!for _t=1 to 2
12801 obado 99
  !set $(_e[$_t])tscore$_num=!text select 0123456789: in $($(_e[$_t])tscore$_num)
100
  !set $(_e[$_t])tscore$_num=!replace internal : by , in $($(_e[$_t])tscore$_num)
101
  !set _nb=!itemcnt $($(_e[$_t])tscore$_num)
102
  !if $_nb=2
103
    !distribute item $($(_e[$_t])tscore$_num) into _h,_m
104
    !set _h=$[$_h*1]
105
    !set _m=$[$_m*1]
106
    !if $_h<0 or $_h>23 or $_m<0 or $_m>59 or NaN isin $_h$_m
107
      !set $(_e[$_t])tscore$_num=$(_l[$_t])
108
    !else
109
      !set _h=!char 2 to 3 of $[100+$_h]
110
      !set _m=!char 2 to 3 of $[100+$_m]
111
      !set $(_e[$_t])tscore$_num=$_h:$_m
112
    !endif
113
  !else
114
    !set $(_e[$_t])tscore$_num=$(_l[$_t])
115
  !endif
12803 bpr 116
!next _t
11814 guerimand 117
!! IP restriction char
12803 bpr 118
!set IPscore$_num=!text select char 1234567890. in $(IPscore$_num)
11815 guerimand 119
!! write output
12803 bpr 120
!reset _output
121
!if $(begindscore$_num)!=$empty and ($(begindscore$_num)!=$class_creation or $(begintscore$_num)!=00:00)
12801 obado 122
  !set _output=$_output>$(begindscore$_num).$(begintscore$_num)
12803 bpr 123
!endif
124
!if $(enddscore$_num)!=$empty and ($(enddscore$_num)!=$class_expiration or $(endtscore$_num)!=23:59)
12801 obado 125
  !set _output=$_output <$(enddscore$_num).$(endtscore$_num)
12803 bpr 126
!endif
127
!set _output=$_output $(IPscore$_num)
128
!exit