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