Subversion Repositories wimsdev

Rev

Rev 12994 | Rev 14366 | 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
12994 guerimand 6
!!    put  : initialise var with date in second line
12801 obado 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
12927 guerimand 23
  !set _value=!words2items $_value
24
  !set _n=!itemcnt $_value
25
  !reset IPscore$_num,begindscore$_num,enddscore$_num,begintscore$_num,endtscore$_num
26
  !set datecheck$_num=$empty
27
  !for _k=1 to $_n
28
    !set _c=!char 1 of $(_value[$_k])
29
    !if $_c=>
30
      !set begindscore$_num=!char 2 to 9 of $(_value[$_k])
31
      !set begintscore$_num=!char 11 to 15 of $(_value[$_k])
12801 obado 32
    !else
12927 guerimand 33
      !if $_c=<
34
        !set enddscore$_num=!char 2 to 9 of $(_value[$_k])
35
        !set endtscore$_num=!char 11 to 15 of $(_value[$_k])
36
      !else
37
        !set IPscore$_num=$(IPscore$_num) $(_value[$_k])
38
      !endif
12801 obado 39
    !endif
12927 guerimand 40
  !next _k
41
  !let _now=!char 1 to 8 of $wims_now
42
  !if $(begindscore$_num)=$class_creation or $(begindscore$_num)=$empty
43
    !let begindscore$_num=$_now
44
    !if $(enddscore$_num)=$empty
12977 obado 45
      !let datecheck$_num=none
12927 guerimand 46
    !endif
12801 obado 47
  !endif
12927 guerimand 48
  !default enddscore$_num=$class_expiration
49
  !default begintscore$_num=00:00
50
  !default endtscore$_num=23:59
51
  !exit
11846 guerimand 52
 
11809 guerimand 53
:html
12986 guerimand 54
!if exam isin $module
55
 !set allid_=3,4
56
!else
57
 !set allid_=2,3
58
!endif
12977 obado 59
!if $_num != $empty
60
  !! score restriction use a $_num for each techvar
61
  <select name="datecheck$_num" id="datecheck$_num"
12999 obado 62
          onchange="toggle_select_option(this, 'select')">
12977 obado 63
    <option value="none"
64
      !if $(datecheck$_num)=none
65
        selected="selected"
66
      !endif
12986 guerimand 67
    >$(name_allowtype[$(allid_[1])])</option>
12977 obado 68
    <option value="select"
69
      !if $(datecheck$_num)!=none
70
        selected="selected"
71
      !endif
12986 guerimand 72
    >$(name_allowtype[$(allid_[2])])</option>
12977 obado 73
  </select>
74
!endif
75
 
76
<ul class="wims_nopuce"
77
!if $_num != $empty and $(datecheck$_num)=none
78
  style="display:none"
79
!else
80
  style="display:block"
81
!endif
82
>
12801 obado 83
  <li>
84
    <label for="begindscore$_num">$wims_name_from</label>
12988 obado 85
 
12927 guerimand 86
    !if $jquery_defined=yes
87
      !read adm/datepickerform.phtml $(begindscore$_num)\
11835 guerimand 88
begindscore$_num\
89
"$class_creation","$class_expiration"
12927 guerimand 90
    !else
91
      <input size="8" name="begindscore$_num" id="begindscore$_num" value="$(begindscore$_num)" />
92
    !endif
12801 obado 93
    <label for="begintscore$_num">$wims_name_at</label>
94
    <input size="5" name="begintscore$_num" id="begintscore$_num" value="$(begintscore$_num)" />
11809 guerimand 95
 
12801 obado 96
    <label for="enddscore$_num">$wims_name_to</label>
12927 guerimand 97
    !if $jquery_defined=yes
98
      !read adm/datepickerform.phtml $(enddscore$_num)\
11835 guerimand 99
enddscore$_num\
100
"$class_creation","$class_expiration"
12927 guerimand 101
    !else
102
      <input size="8" name="enddscore$_num" id="enddscore$_num" value="$(enddscore$_num)" />
103
    !endif
12801 obado 104
    <label for="endtscore$_num">$wims_name_at</label>
105
    <input size="5" name="endtscore$_num" id="endtscore$_num" value="$(endtscore$_num)" />
12977 obado 106
 
12801 obado 107
  </li><li>
108
    <label for="IPscore$_num">$wims_name_IP</label>
12977 obado 109
    <input size="15" name="IPscore$_num" id="IPscore$_num" value="$(IPscore$_num)" placeholder="127.0.0.1" />
12801 obado 110
  </li>
11870 bpr 111
</ul>
12977 obado 112
!reset datecheck$_num
11809 guerimand 113
!exit
114
 
115
:get
11836 guerimand 116
!! error are not display to user but default value replace bad value
11814 guerimand 117
!! date format verification
12803 bpr 118
!set _e=begin,end
119
!set _l=$class_creation,$class_expiration
120
!for _t=1 to 2
12801 obado 121
  !set $(_e[$_t])dscore$_num=!text select 0123456789 in $($(_e[$_t])dscore$_num)
122
  !bound $(_e[$_t])dscore$_num between $class_creation and $class_expiration default $(_l[$_t])
123
  !set _y=!char 1 to 4 of $($(_e[$_t])dscore$_num)
124
  !set _m=!char 5 to 6 of $($(_e[$_t])dscore$_num)
125
  !set _d=!char 7 to 8 of $($(_e[$_t])dscore$_num)
126
  !! ---- day and month check (not realy good test should be an exact test of existence of date)
127
  !if $_m<1 or $_m>12 or $_d<1 or $_d>31
128
    !set $(_e[$_t])dscore$_num=$(_l[$_t])
129
  !endif
12803 bpr 130
!next _t
11814 guerimand 131
!! time format verification
12803 bpr 132
!set _l=00:00,23:59
133
!for _t=1 to 2
12801 obado 134
  !set $(_e[$_t])tscore$_num=!text select 0123456789: in $($(_e[$_t])tscore$_num)
135
  !set $(_e[$_t])tscore$_num=!replace internal : by , in $($(_e[$_t])tscore$_num)
136
  !set _nb=!itemcnt $($(_e[$_t])tscore$_num)
137
  !if $_nb=2
138
    !distribute item $($(_e[$_t])tscore$_num) into _h,_m
139
    !set _h=$[$_h*1]
140
    !set _m=$[$_m*1]
141
    !if $_h<0 or $_h>23 or $_m<0 or $_m>59 or NaN isin $_h$_m
142
      !set $(_e[$_t])tscore$_num=$(_l[$_t])
143
    !else
144
      !set _h=!char 2 to 3 of $[100+$_h]
145
      !set _m=!char 2 to 3 of $[100+$_m]
146
      !set $(_e[$_t])tscore$_num=$_h:$_m
147
    !endif
148
  !else
149
    !set $(_e[$_t])tscore$_num=$(_l[$_t])
150
  !endif
12803 bpr 151
!next _t
11814 guerimand 152
!! IP restriction char
12803 bpr 153
!set IPscore$_num=!text select char 1234567890. in $(IPscore$_num)
11815 guerimand 154
!! write output
12803 bpr 155
!reset _output
12977 obado 156
!if $(begindscore$_num)!=$empty and ($(begindscore$_num)!=$class_creation or $(begintscore$_num)!=00:00) and none notin $(datecheck$_num)
12801 obado 157
  !set _output=$_output>$(begindscore$_num).$(begintscore$_num)
12803 bpr 158
!endif
12977 obado 159
!if $(enddscore$_num)!=$empty and ($(enddscore$_num)!=$class_expiration or $(endtscore$_num)!=23:59) and none notin $(datecheck$_num)
12801 obado 160
  !set _output=$_output <$(enddscore$_num).$(endtscore$_num)
12803 bpr 161
!endif
162
!set _output=$_output $(IPscore$_num)
163
!exit