Subversion Repositories wimsdev

Rev

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