Subversion Repositories wimsdev

Rev

Rev 14984 | Rev 15238 | 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
 
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
15
!read adm/du $wims_home/log/classes/$wims_class
14320 guerimand 16
!if $class_type=$empty
17
  class_type=!defof class_type in wimshome/log/classes/$wims_class/.def
18
!endif
19
!if $class_type iswordof 2 4 and $wims_superclass_quota!=$empty
20
  quota_total=$wims_superclass_quota
21
!else
22
  quota_total=$wims_class_quota
23
!endif
14297 guerimand 24
quota_used=$du
25
!! -------------------- calculate space reserved
26
quota_reserved=0
27
!! ------- space reserved for active freework of type>=2
28
nb_=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freeworks
29
!for k_=1 to $nb_
30
  dt_=!record $k_ of wimshome/log/classes/$wims_class/freeworks/.freeworks
31
  !distribute line $dt_ into s_,bl,bl,bl,bl,t_,bl,bl,c_
14984 czzmrn 32
  !default c_=0
14297 guerimand 33
  !if $s_=1 and $t_>=2
34
    !read adm/du $wims_home/log/classes/$wims_class/freeworksdata/$k_/work
15161 guerimand 35
    quota_reserved=$[$quota_reserved+$class_limit*$c_*0.25-$du]
14297 guerimand 36
  !endif
37
!next k_
38
 
39
quota_reserved=$[min($quota_reserved,$wims_class_quota-$quota_used)]
15161 guerimand 40
 
14297 guerimand 41
!! -------------------- end reserved calculation
42
quota_free=$[$quota_total-$quota_used-$quota_reserved]
43
 
44
!if $quota_free<5
45
  auth_upload=no
46
!else
47
  auth_upload=yes
48
!endif
49
 
50
!exit
51
 
52
:html
14863 obado 53
!readproc adm/class/classlang lang/scriptadmclass.phtml adm_class_quotafree
54
!set x1=$[floor($quota_used/$wims_class_quota*10000)/100]
55
!set x1_int=$[floor($x1)]
56
!set x2=$[floor($quota_reserved/$wims_class_quota*10000)/100]
57
!set x2_int=$[floor($x2)]
58
!set x3=$[floor($quota_free/$wims_class_quota*10000)/100]
59
 
14907 obado 60
<div class="wims_quotafree">
61
  <style>@import "html/themes/_css/quota_bar.css";</style>
62
  <div class="wimscenter">
63
    $(name_availablespace[1]) ($wims_class_quota $name_mega)
64
  </div>
65
  <div class="quota-bar" role="progressbar" tabindex="0"
66
       aria-valuenow="$x1" aria-valuemin="0" aria-valuemax="100"
67
       aria-valuetext="$(name_availablespace[2]): $x1% of $wims_class_quota$name_mega">
68
    !! used
69
    <div class="quota-index alert" title="$x1% $(name_availablespace[2])" style="width:$x1%">$x1_int%</div>
70
    !! reserved
71
    !if $x2>0
72
      <div class="quota-index warning" title="$x2% $(name_availablespace[4])" style="width:$x2%">$x2_int%</div>
73
    !endif
74
    !!free
75
    <div class="quota-index blank" title="$x3% $(name_availablespace[3])">&nbsp;</div>
76
  </div>
77
  <p class="formHelp wimscenter">
78
    <span class="quota-legend alert">$(name_availablespace[2]): $quota_used$name_mega</span>;
79
    !if $quota_reserved>0
80
      <span class="quota-legend warning">$(name_availablespace[4]): $quota_reserved$name_mega</span>;
81
    !endif
82
    <span class="quota-legend">$(name_availablespace[3]): $quota_free$name_mega</span>.
83
  </p>
14863 obado 84
</div>
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