Subversion Repositories wimsdev

Rev

Rev 15238 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
14297 guerimand 1
!! define variables :
2
!! quota_total : deprecated use wims_class_quota instead ?
3
!! quota_free : actual free space of the class
14595 obado 4
!! quota_used : actual used space
14297 guerimand 5
!! quota_reserved : actual reserved space for some activity (active freework ...)
6
!! auth_upload : yes if class capacity is ok (else no)
7
!! wims_read_parm is proc or html (proc make calcul and html show result on page)
8
 
14864 obado 9
!if $wims_read_parm isitemof proc,html,canvas
10
  !goto $wims_read_parm
14297 guerimand 11
!endif
12
 
13
:proc
14
!! ---- calcul
15238 czzmrn 15
!if $class_limit=$empty
16
  class_limit=!defof class_limit in wimshome/log/classes/$wims_class/.def
17
!endif
14297 guerimand 18
!read adm/du $wims_home/log/classes/$wims_class
14320 guerimand 19
!if $class_type=$empty
20
  class_type=!defof class_type in wimshome/log/classes/$wims_class/.def
21
!endif
22
!if $class_type iswordof 2 4 and $wims_superclass_quota!=$empty
23
  quota_total=$wims_superclass_quota
24
!else
25
  quota_total=$wims_class_quota
26
!endif
14297 guerimand 27
quota_used=$du
28
!! -------------------- calculate space reserved
29
quota_reserved=0
30
!! ------- space reserved for active freework of type>=2
31
nb_=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freeworks
32
!for k_=1 to $nb_
33
  dt_=!record $k_ of wimshome/log/classes/$wims_class/freeworks/.freeworks
34
  !distribute line $dt_ into s_,bl,bl,bl,bl,t_,bl,bl,c_
14984 czzmrn 35
  !default c_=0
14297 guerimand 36
  !if $s_=1 and $t_>=2
37
    !read adm/du $wims_home/log/classes/$wims_class/freeworksdata/$k_/work
15161 guerimand 38
    quota_reserved=$[$quota_reserved+$class_limit*$c_*0.25-$du]
14297 guerimand 39
  !endif
40
!next k_
41
 
42
quota_reserved=$[min($quota_reserved,$wims_class_quota-$quota_used)]
15161 guerimand 43
 
14297 guerimand 44
!! -------------------- end reserved calculation
45
quota_free=$[$quota_total-$quota_used-$quota_reserved]
46
 
47
!if $quota_free<5
48
  auth_upload=no
49
!else
50
  auth_upload=yes
51
!endif
52
 
53
!exit
54
 
55
:html
14863 obado 56
!readproc adm/class/classlang lang/scriptadmclass.phtml adm_class_quotafree
18565 lemaire 57
!set x1=$[floor($quota_used/$quota_total*10000)/100]
14863 obado 58
!set x1_int=$[floor($x1)]
18565 lemaire 59
!set x2=$[floor($quota_reserved/$quota_total*10000)/100]
14863 obado 60
!set x2_int=$[floor($x2)]
18565 lemaire 61
!set x3=$[floor($quota_free/$quota_total*10000)/100]
14863 obado 62
 
14907 obado 63
<div class="wims_quotafree">
64
  <style>@import "html/themes/_css/quota_bar.css";</style>
65
  <div class="wimscenter">
18565 lemaire 66
    $(name_availablespace[1]) ($quota_total $name_mega)
14907 obado 67
  </div>
68
  <div class="quota-bar" role="progressbar" tabindex="0"
69
       aria-valuenow="$x1" aria-valuemin="0" aria-valuemax="100"
70
       aria-valuetext="$(name_availablespace[2]): $x1% of $wims_class_quota$name_mega">
71
    !! used
72
    <div class="quota-index alert" title="$x1% $(name_availablespace[2])" style="width:$x1%">$x1_int%</div>
73
    !! reserved
74
    !if $x2>0
75
      <div class="quota-index warning" title="$x2% $(name_availablespace[4])" style="width:$x2%">$x2_int%</div>
76
    !endif
77
    !!free
78
    <div class="quota-index blank" title="$x3% $(name_availablespace[3])">&nbsp;</div>
79
  </div>
80
  <p class="formHelp wimscenter">
81
    <span class="quota-legend alert">$(name_availablespace[2]): $quota_used$name_mega</span>;
82
    !if $quota_reserved>0
83
      <span class="quota-legend warning">$(name_availablespace[4]): $quota_reserved$name_mega</span>;
84
    !endif
85
    <span class="quota-legend">$(name_availablespace[3]): $quota_free$name_mega</span>.
86
  </p>
14863 obado 87
</div>
88
 
89
!exit
90
:canvas
14595 obado 91
  !readproc adm/class/classlang lang/scriptadmclass.phtml adm_class_quotafree
92
  <div class="wimscenter">
93
    <label for="freespace">$(name_availablespace[1]) ($wims_class_quota $name_mega)</label>
94
    <canvas id="freespace" width="700" height="50">
95
      $(name_availablespace[1]) : $wims_class_quota  $name_mega ($(name_availablespace[2]): $quota_used $name_mega ; $(name_availablespace[4]): $quota_reserved $name_mega ; $(name_availablespace[3]): $quota_free $name_mega ).
96
    </canvas>
97
    !set x1=$[floor(($quota_used)/$wims_class_quota*700)]
98
    !set x2=$[floor(($quota_reserved)/$wims_class_quota*700)]
99
    <script>
14297 guerimand 100
    function draw() {
101
      var canvas = document.getElementById("freespace");
102
      if (canvas.getContext) {
103
        var ctx = canvas.getContext("2d");
104
 
14595 obado 105
          ctx.fillStyle = 'red';
106
          ctx.fillRect(1,1,$x1,24);
107
          ctx.fillRect(100,30,10,10);
14297 guerimand 108
 
14595 obado 109
          !if $quota_reserved>0
110
            ctx.fillStyle = 'yellow';
111
            ctx.fillRect($x1,1,$x2,24);
112
            ctx.fillRect(250,30,10,10);
113
          !endif
114
 
115
          ctx.fillStyle = 'green';
116
          ctx.fillRect($[1+$x1+$x2],1,$[700-$x1-$X2],24);
117
          ctx.fillRect(400,30,10,10);
118
 
119
          ctx.fillStyle = 'black';
120
          ctx.strokeRect(0, 0, 700, 24);
121
          ctx.fillText('$(name_availablespace[2])',120,40);
122
          ctx.fillText('$quota_used',$[floor($x1/2)],15);
123
          ctx.fillText('$(name_availablespace[3])',420,40);
124
          ctx.fillText('$quota_free',$[floor((700+$x1+$x2)/2)],15);
125
          !if $quota_reserved>0
126
            ctx.fillText('$(name_availablespace[4])',270,40);
127
            ctx.fillText('$quota_reserved',$[floor($x1+($x2)/2)],15);
128
          !endif
129
        }
14297 guerimand 130
      }
14595 obado 131
      draw();
132
    </script>
133
  </div>
14297 guerimand 134
!exit