Subversion Repositories wimsdev

Rev

Rev 12999 | Rev 14367 | 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
      !read adm/datepickerform.phtml $(begindscore$_num)\
11835 guerimand 87
begindscore$_num\
88
"$class_creation","$class_expiration"
12801 obado 89
    <label for="begintscore$_num">$wims_name_at</label>
14366 guerimand 90
    <input type="time" size="5" name="begintscore$_num" id="begintscore$_num" value="$(begintscore$_num)" />
11809 guerimand 91
 
12801 obado 92
    <label for="enddscore$_num">$wims_name_to</label>
12927 guerimand 93
      !read adm/datepickerform.phtml $(enddscore$_num)\
11835 guerimand 94
enddscore$_num\
95
"$class_creation","$class_expiration"
12801 obado 96
    <label for="endtscore$_num">$wims_name_at</label>
14366 guerimand 97
    <input type="time" size="5" name="endtscore$_num" id="endtscore$_num" value="$(endtscore$_num)" />
12977 obado 98
 
12801 obado 99
  </li><li>
100
    <label for="IPscore$_num">$wims_name_IP</label>
12977 obado 101
    <input size="15" name="IPscore$_num" id="IPscore$_num" value="$(IPscore$_num)" placeholder="127.0.0.1" />
12801 obado 102
  </li>
11870 bpr 103
</ul>
12977 obado 104
!reset datecheck$_num
11809 guerimand 105
!exit
106
 
107
:get
11836 guerimand 108
!! error are not display to user but default value replace bad value
11814 guerimand 109
!! date format verification
12803 bpr 110
!set _e=begin,end
111
!set _l=$class_creation,$class_expiration
112
!for _t=1 to 2
14366 guerimand 113
  !if $jquery_defined!=yes
114
    _m=!char 2,3 of $[abs(floor($(month$(_e[$_t])dscore$_num)))+100]
115
    _d=!char 2,3 of $[abs(floor($(day$(_e[$_t])dscore$_num)))+100]
116
    _y=!char -4 to -1 of $[abs($(year$(_e[$_t])dscore$_num))+100000]
117
    $(_e[$_t])dscore$_num=$_y$_m$_d
118
  !endif
12801 obado 119
  !set $(_e[$_t])dscore$_num=!text select 0123456789 in $($(_e[$_t])dscore$_num)
120
  !bound $(_e[$_t])dscore$_num between $class_creation and $class_expiration default $(_l[$_t])
121
  !set _y=!char 1 to 4 of $($(_e[$_t])dscore$_num)
122
  !set _m=!char 5 to 6 of $($(_e[$_t])dscore$_num)
123
  !set _d=!char 7 to 8 of $($(_e[$_t])dscore$_num)
124
  !! ---- day and month check (not realy good test should be an exact test of existence of date)
125
  !if $_m<1 or $_m>12 or $_d<1 or $_d>31
126
    !set $(_e[$_t])dscore$_num=$(_l[$_t])
127
  !endif
12803 bpr 128
!next _t
11814 guerimand 129
!! time format verification
12803 bpr 130
!set _l=00:00,23:59
131
!for _t=1 to 2
12801 obado 132
  !set $(_e[$_t])tscore$_num=!text select 0123456789: in $($(_e[$_t])tscore$_num)
133
  !set $(_e[$_t])tscore$_num=!replace internal : by , in $($(_e[$_t])tscore$_num)
134
  !set _nb=!itemcnt $($(_e[$_t])tscore$_num)
135
  !if $_nb=2
136
    !distribute item $($(_e[$_t])tscore$_num) into _h,_m
137
    !set _h=$[$_h*1]
138
    !set _m=$[$_m*1]
139
    !if $_h<0 or $_h>23 or $_m<0 or $_m>59 or NaN isin $_h$_m
140
      !set $(_e[$_t])tscore$_num=$(_l[$_t])
141
    !else
142
      !set _h=!char 2 to 3 of $[100+$_h]
143
      !set _m=!char 2 to 3 of $[100+$_m]
144
      !set $(_e[$_t])tscore$_num=$_h:$_m
145
    !endif
146
  !else
147
    !set $(_e[$_t])tscore$_num=$(_l[$_t])
148
  !endif
12803 bpr 149
!next _t
11814 guerimand 150
!! IP restriction char
12803 bpr 151
!set IPscore$_num=!text select char 1234567890. in $(IPscore$_num)
11815 guerimand 152
!! write output
12803 bpr 153
!reset _output
12977 obado 154
!if $(begindscore$_num)!=$empty and ($(begindscore$_num)!=$class_creation or $(begintscore$_num)!=00:00) and none notin $(datecheck$_num)
12801 obado 155
  !set _output=$_output>$(begindscore$_num).$(begintscore$_num)
12803 bpr 156
!endif
12977 obado 157
!if $(enddscore$_num)!=$empty and ($(enddscore$_num)!=$class_expiration or $(endtscore$_num)!=23:59) and none notin $(datecheck$_num)
12801 obado 158
  !set _output=$_output <$(enddscore$_num).$(endtscore$_num)
12803 bpr 159
!endif
160
!set _output=$_output $(IPscore$_num)
161
!exit