Rev 14320 | Rev 14595 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
!! define variables :
!! quota_total : deprecated use wims_class_quota instead ?
!! quota_free : actual free space of the class
!! quota_used : actual used space
!! quota_reserved : actual reserved space for some activity (active freework ...)
!! auth_upload : yes if class capacity is ok (else no)
!! wims_read_parm is proc or html (proc make calcul and html show result on page)
!if $wims_read_parm=html
!goto html
!else
!goto proc
!endif
:proc
!! ---- calcul
!read adm/du $wims_home/log/classes/$wims_class
!if $class_type=$empty
class_type=!defof class_type in wimshome/log/classes/$wims_class/.def
!endif
!if $class_type iswordof 2 4 and $wims_superclass_quota!=$empty
quota_total=$wims_superclass_quota
!else
quota_total=$wims_class_quota
!endif
quota_used=$du
!! -------------------- calculate space reserved
quota_reserved=0
!! ------- space reserved for active freework of type>=2
nb_=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freeworks
nbuser_=!recordcnt wimshome/log/classes/$wims_class/.userlist
!for k_=1 to $nb_
dt_=!record $k_ of wimshome/log/classes/$wims_class/freeworks/.freeworks
!distribute line $dt_ into s_,bl,bl,bl,bl,t_,bl,bl,c_
!if $s_=1 and $t_>=2
!read adm/du $wims_home/log/classes/$wims_class/freeworksdata/$k_/work
quota_reserved=$[$quota_reserved+$nbuser_*$c_*0.25-$du]
!endif
!next k_
quota_reserved=$[min($quota_reserved,$wims_class_quota-$quota_used)]
!! -------------------- end reserved calculation
quota_free=$[$quota_total-$quota_used-$quota_reserved]
!if $quota_free<5
auth_upload=no
!else
auth_upload=yes
!endif
!exit
:html
!readproc adm/class/classlang lang/scriptadmclass.phtml adm_class_quotafree
<center>
<label for="freespace">$(name_availablespace[1]) ($wims_class_quota $name_mega)</label>
<canvas id="freespace" width="700" height="50">
$(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 ).
</canvas>
!set x1=$[floor(($quota_used)/$wims_class_quota*700)]
!set x2=$[floor(($quota_reserved)/$wims_class_quota*700)]
<script type="application/javascript">
function draw() {
var canvas = document.getElementById("freespace");
if (canvas.getContext) {
var ctx = canvas.getContext("2d");
ctx.fillStyle = 'red';
ctx.fillRect(1,1,$x1,24);
ctx.fillRect(100,30,10,10);
!if $quota_reserved >0
ctx.fillStyle = 'yellow';
ctx.fillRect($x1,1,$x2,24);
ctx.fillRect(250,30,10,10);
!endif
ctx.fillStyle = 'green';
ctx.fillRect($[1+$x1+$x2],1,$[700-$x1-$X2],24);
ctx.fillRect(400,30,10,10);
ctx.fillStyle = 'black';
ctx.strokeRect(0, 0, 700, 24);
ctx.fillText('$(name_availablespace[2])',120,40);
ctx.fillText('$quota_used',$[floor($x1/2)],15);
ctx.fillText('$(name_availablespace[3])',420,40);
ctx.fillText('$quota_free',$[floor((700+$x1+$x2)/2)],15);
!if $quota_reserved>0
ctx.fillText('$(name_availablespace[4])',270,40);
ctx.fillText('$quota_reserved',$[floor($x1+($x2)/2)],15);
!endif
}
}
draw();
</script>
</center>
!exit