gracias.
PS: adjunto el codigp
FUNCIONES JAVASCRIPT:
Código:
<script type="text/javascript"> function EbPP(N,A) { var E=1 ; for (var i = 1; i <= N; i++) { E=A*E/(i+A*E) } return (E) } function EbTraO(N,E) { var A=(N/(1-E)) ; var f=1 ; while ((E-f)>0.000005 | (f-E)>0.000005) { f=EbPP(N,A) ; A-=(A*(f-E)/(f*(N+1-A*f)-E)) } return (A) } function MoneyFormat(amount) { var val = parseFloat(amount); if (isNaN(val)) { return "0.00"; } if (val <= 0) { return "0.00"; } val += ""; // Next two lines remove anything beyond 2 decimal places if (val.indexOf('.') == -1) { return val+".00"; } else { val = val.substring(0,val.indexOf('.')+3); } val = (val == Math.floor(val)) ? val + '.00' : ((val*10 == Math.floor(val*10)) ? val + '0' : val); return val; } function CalculoErlang(tch,gos,trc) { tcal = EbTraO(tch,2); tcal = MoneyFormat(tcal); document.write("<td><div id=BandejaEntrada>"+tcal+"</div></td>"); porcent=((tcal-trc)/tcal); porcent = MoneyFormat(porcent); document.write("<td><div id=BandejaEntrada>"+porcent+"%</div></td>"); if(porcent > 50){ document.write("<td><div id=BandejaEntrada><font color=#FF9966><strong>SobreDimensionado</strong></font></div></td>"); }else{ if(porcent > 15){ document.write("<td><div id=BandejaEntrada><font color=#00CC00><strong>OK</strong></font></div></td>"); }else { document.write("<td><div id=BandejaEntrada><font color=#FF0000><strong>Subdimensionado</strong></font></div></td>"); } } } </script>
PHP QUE CORRE Y RECPOGE DATOS DE LA BASE DE DATOS Y CORRE EL JAVASCRIPT:
Código:
$l=1; $BTS = $bts->BTSs(); $bandera=0; while($linea = mysql_fetch_array($BTS,MYSQL_ASSOC)) { $sindex=$linea['Site_Index']; $sid=$linea['Site_ID']; $bsc=$linea['BSC_P']; $CELL2 = $bts->getCeldas2byIDs($sindex,$bsc); $linea7 = mysql_fetch_array($CELL2,MYSQL_ASSOC); $TotCell=$linea7['Total']; $CELL = $bts->getCeldasbyIDs($sindex,$bsc); for($g=0;$g<$TotCell;$g++) { $linea2 = mysql_fetch_array($CELL,MYSQL_ASSOC); $cindex=$linea2['Cell_Index']; $cname=$linea2['Cell_Name']; $cell_tmp =$temp->get_Cell_Common_data2($cname, $bsc); $linea15 = mysql_fetch_array($cell_tmp,MYSQL_ASSOC); $trx_reducir=$linea15['trx_reducir']; $tr_cursado=$linea15['Traffic']; $Porcent=($linea15['Porcentaje_carga'])/100; $Gos=$linea15['Grado_Servicio']; $TRX = $bts->getTrxbyIDs($sindex,$bsc,$cindex); $linea3 = mysql_fetch_array($TRX,MYSQL_ASSOC); $TotTrx=$linea3['Total']; $Totbcch=0; $Totpdch=0; $Totpdtch=0; $Tottch=0; $TRX2 = $bts->getTrxidbyIDs($sindex,$bsc,$cindex); for($j=0;$j<$TotTrx;$j++) { $linea4 = mysql_fetch_array($TRX2,MYSQL_ASSOC); $tindex=$linea4['Trx_Index']; $cad="Main BCCH"; $CHAN = $bts->getChanbyIDs($sindex,$bsc,$tindex,$cad); $linea5 = mysql_fetch_array($CHAN,MYSQL_ASSOC); $Totbcch=$Totbcch+$linea5['Total']; $cad="SDCCH8"; $CHAN = $bts->getChanbyIDs($sindex,$bsc,$tindex,$cad); $linea5 = mysql_fetch_array($CHAN,MYSQL_ASSOC); $Totbcch=$Totbcch+$linea5['Total']; $cad="Combined BCCH"; $CHAN = $bts->getChanbyIDs($sindex,$bsc,$tindex,$cad); $linea5 = mysql_fetch_array($CHAN,MYSQL_ASSOC); $Totbcch=$Totbcch+$linea5['Total']; $cad="SDCCH+CBCH"; $CHAN = $bts->getChanbyIDs($sindex,$bsc,$tindex,$cad); $linea5 = mysql_fetch_array($CHAN,MYSQL_ASSOC); $Totbcch=$Totbcch+$linea5['Total']; $cad="PDTCH"; $CHAN = $bts->getChanbyIDs($sindex,$bsc,$tindex,$cad); $linea5 = mysql_fetch_array($CHAN,MYSQL_ASSOC); $Totpdtch=$Totpdtch+$linea5['Total']; $cad="TCH Full Rate"; $CHAN = $bts->getChanbyIDs($sindex,$bsc,$tindex,$cad); $linea5 = mysql_fetch_array($CHAN,MYSQL_ASSOC); $Tottch=$Tottch+$linea5['Total']; $cad="Dynamic PDCH"; $CHAN = $bts->getChanbyIDs($sindex,$bsc,$tindex,$cad); $linea5 = mysql_fetch_array($CHAN,MYSQL_ASSOC); $Totpdch=$Totpdch+$linea5['Total']; echo "\t</tr>\n"; } if($bandera == 1){ echo "\t<tr class='fondo'>\n"; $bandera=0; }else{ echo "\t<tr>\n"; $bandera=1;} $tchequiv=$Tottch/(1-(0.65/2)); $zz=l+100; ?> <td><div id=BandejaEntrada><? echo "$l";?> </div></td> <td><div id=BandejaEntrada><? echo "$sindex";?> </div></td> <td><div id=BandejaEntrada><? echo "$sid";?> </div></td> <td><div id=BandejaEntrada><? echo "$bsc";?> </div></td> <td><div id=BandejaEntrada><? echo "$cindex";?> </div></td> <td><div id=BandejaEntrada><? echo "$cname";?> </div></td> <td><div id=BandejaEntrada><? echo "$tr_cursado";?> </div></td> <td><div id=BandejaEntrada><? echo "$trx_reducir";?> </div></td> <td><div id=BandejaEntrada><? echo "$TotTrx";?> </div></td> <td><div id=BandejaEntrada><? echo "$Totbcch";?> </div></td> <td><div id=BandejaEntrada><? echo "$Totpdtch";?> </div></td> <td><div id=BandejaEntrada><? echo "$Tottch";?> </div></td> <td><div id=BandejaEntrada><? echo "$Totpdch";?> </div></td> <td><div id=BandejaEntrada><? echo "$Porcent";?> </div></td> <td><div id=BandejaEntrada><? printf("%.2f","$tchequiv");?> </div></td> <script type="text/javascript"> CalculoErlang(100,100,100); </script> <? $l++; } }