Subversion Repositories wimsdev

Rev

Rev 14320 | Rev 14595 | 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
4
!! quota_used : actual used space 
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
14309 guerimand 54
   !readproc adm/class/classlang lang/scriptadmclass.phtml adm_class_quotafree
14297 guerimand 55
   <center>
14571 czzmrn 56
   <label for="freespace">$(name_availablespace[1]) ($wims_class_quota $name_mega)</label>
14297 guerimand 57
   <canvas id="freespace" width="700" height="50">
14571 czzmrn 58
     $(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 ).
14297 guerimand 59
   </canvas>
60
  !set x1=$[floor(($quota_used)/$wims_class_quota*700)]
61
  !set x2=$[floor(($quota_reserved)/$wims_class_quota*700)]
62
  <script type="application/javascript">
63
    function draw() {
64
      var canvas = document.getElementById("freespace");
65
      if (canvas.getContext) {
66
        var ctx = canvas.getContext("2d");
67
 
68
        ctx.fillStyle = 'red';
69
        ctx.fillRect(1,1,$x1,24);
70
        ctx.fillRect(100,30,10,10);
71
        !if $quota_reserved >0
72
          ctx.fillStyle = 'yellow';
73
          ctx.fillRect($x1,1,$x2,24);
74
          ctx.fillRect(250,30,10,10);
75
        !endif
76
        ctx.fillStyle = 'green';
77
        ctx.fillRect($[1+$x1+$x2],1,$[700-$x1-$X2],24);
78
        ctx.fillRect(400,30,10,10);
79
        ctx.fillStyle = 'black';
80
        ctx.strokeRect(0, 0, 700, 24);
81
        ctx.fillText('$(name_availablespace[2])',120,40);
82
        ctx.fillText('$quota_used',$[floor($x1/2)],15);
14301 guerimand 83
        ctx.fillText('$(name_availablespace[3])',420,40);
14297 guerimand 84
        ctx.fillText('$quota_free',$[floor((700+$x1+$x2)/2)],15);
85
        !if $quota_reserved>0
14309 guerimand 86
          ctx.fillText('$(name_availablespace[4])',270,40);
14297 guerimand 87
          ctx.fillText('$quota_reserved',$[floor($x1+($x2)/2)],15);
88
        !endif
89
 
90
      }
91
    }
92
    draw();
93
   </script>
94
   </center>
95
 
96
!exit