Code:
<?php
include ("lib/defines.php");
include ("lib/module.access.php");
include ("frontoffice_data/CC_var_def_ratecard.inc");
include ("lib/Class.RateEngine.php");
if (! has_rights (ACX_ACCESS)){
Header ("HTTP/1.0 401 Unauthorized");
Header ("Location: PP_error.php?c=accessdenied");
die();
}
$QUERY = "SELECT username, credit, lastname, firstname, address, city, state, country, zipcode, phone, email, fax, lastuse, activated, id,tariff FROM cc_card WHERE username = '".$_SESSION["pr_login"]."' AND uipass = '".$_SESSION["pr_password"]."'";
//echo $QUERY."<br>";
$DBHandle_max = DbConnect();
$resmax = $DBHandle_max -> query($QUERY);
$numrow = $DBHandle_max -> num_rows();
if ($numrow == 0) exit();
$DBHandle_max -> next_record();
$customer_info =$DBHandle_max -> Record;
if( $customer_info [13] != "t" && $customer_info [13] != "1" ) {
exit();
}
getpost_ifset(array('posted', 'tariffplan', 'balance', 'id_cc_card', 'called'));
$id_cc_card = $customer_info[14];
$tariffplan = $customer_info[15];
$balance = $customer_info[1];
$FG_DEBUG = 0;
$DBHandle = DbConnect();
if ($called && $id_cc_card){
$calling=ereg_replace("^\+","011",$called);
$calling=ereg_replace("[^0-9]","",$called);
$calling=ereg_replace("^01100","011",$called);
$calling=ereg_replace("^00","011",$called);
$calling=ereg_replace("^0111","1",$called);
if ( strlen($calling)>2 && is_numeric($calling)){
$A2B -> DBHandle = DbConnect();
$instance_table = new Table();
$A2B -> set_instance_table ($instance_table);
//$resmax = $DBHandle -> query("SELECT username, tariff FROM cc_card where id='$id_cc_card'");
$resmax = $DBHandle -> query("SELECT username, tariff FROM cc_card where id='$customer_info[14]'");
$num = $DBHandle -> num_rows();
if ($num==0){ echo "Error card !!!"; exit();}
for($i=0;$i<$num;$i++)
{
$DBHandle -> next_record();
$row [] =$DBHandle -> Record;
}
$A2B -> cardnumber = $row[0][0] ;
$A2B -> credit = $balance;
if ($FG_DEBUG == 1) echo "cardnumber = ".$row[0][0] ."<br>";
if ($A2B -> callingcard_ivr_authenticate_light ($error_msg)){
if ($FG_DEBUG == 1) $RateEngine -> debug_st = 1;
$RateEngine = new RateEngine();
$RateEngine -> webui = 0;
// LOOKUP RATE : FIND A RATE FOR THIS DESTINATION
$A2B ->agiconfig['accountcode'] = $A2B -> cardnumber ;
$A2B ->agiconfig['use_dnid']=1;
$A2B ->agiconfig['say_timetocall']=0;
$A2B ->dnid = $A2B ->destination = $called;
$resfindrate = $RateEngine->rate_engine_findrates($A2B, $called, $row[0][1]);
if ($FG_DEBUG == 1) echo "resfindrate=$resfindrate";
// IF FIND RATE
if ($resfindrate!=0){
$res_all_calcultimeout = $RateEngine->rate_engine_all_calcultimeout($A2B, $A2B->credit);
if ($FG_DEBUG == 1) print_r($RateEngine->ratecard_obj);
}
}
}
}
/**************************************************************/
$instance_table_tariffname = new Table("cc_tariffplan", "id, tariffname");
$FG_TABLE_CLAUSE = "";
$list_tariffname = $instance_table_tariffname -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, "tariffname", "ASC", null, null, null, null);
$nb_tariffname = count($list_tariffname);
/*************************************************************/
?>
<?php
include("PP_header.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
function openURL(theLINK)
{
// grab index number of the selected option
selInd = document.theForm.choose_list.selectedIndex;
if(selInd==''){alert('Please, select a tariff'); return false;}
// get value of the selected option
goURL = document.theForm.choose_list.options[selInd].value;
definecredit = document.theForm.definecredit.value;
// redirect browser to the grabbed value (hopefully a URL)
self.location.href = theLINK + goURL + "&definecredit="+definecredit ; //+ "&opt="+opt;
}
//-->
</script>
<br><br>
<div id="div1000" style="display:visible;">
<div id="kiblue"><div class="w4">
<img src="Css/kicons/connect_to_network.png" width="48" height="48" class="kikipic"/>
<div class="w2">
<table width="100%">
<tr>
<td width="50%">
En esta pagina usted podra simular el proceso de llamada, si desea saber el costo por minuto a un<br> determinado destino o el pais y ciudad al que pertenece determinado numero,<br>incluso podra conocer el numero de minutos disponibles! </td>
</tr>
</table>
</div></div></div>
<br>
<br>
<table width="<?php echo $FG_HTML_TABLE_WIDTH?>" border="0" align="center" cellpadding="0" cellspacing="0">
<TR>
<TD style="border-bottom: medium dotted #8888CC" colspan="2"> <B> Simulador de Llamadas </B></TD>
</TR>
<FORM NAME="theFormFilter" action="<?php echo $PHP_SELF?>">
<tr>
<td height="31" bgcolor="#8888CC" style="padding-left: 5px; padding-right: 3px;">
<br>
<font color="white"><b>Ingrese el numero al que desea llamar :</b></font>
<INPUT type="text" name="called" value="<?php echo $called;?>">
<br>
<?php if (false){ ?>
<br>
<font color="white"><b>YOUR BALANCE :</b></font>
<INPUT type="text" name="balance" value="<?php if (!isset($balance)) echo "10"; else echo $balance;?>">
<?php } ?>
<br>
<br>
</td>
<td height="31" bgcolor="#8888CC" style="padding-left: 5px; padding-right: 3px;">
<span class="bar-search">
<input type="image" name="image16" align="top" border="0" src="images/button-search.gif" />
</span></td>
</tr>
</FORM>
<TR>
<TD style="border-bottom: medium dotted #8888CC" colspan="2"><br></TD>
</TR>
</table>
<?php if ( (is_array($RateEngine->ratecard_obj)) && (!empty($RateEngine->ratecard_obj)) ){
if ($FG_DEBUG == 1) print_r($RateEngine->ratecard_obj);
$arr_ratecard=array('idtariffgroup', 'cc_tariffgroup_plan.idtariffplan', 'tariffname', 'Nombre Del Destino', 'cc_ratecard.id' , 'dialprefix', 'destination', 'buyrate', 'buyrateinitblock', 'buyrateincrement', 'Costo Por Minuto', 'initblock', 'billingblock', 'connectcharge', 'disconnectcharge', 'stepchargea', 'chargea', 'timechargea', 'billingblocka', 'stepchargeb', 'chargeb', 'timechargeb', 'billingblockb', 'stepchargec', 'chargec', 'timechargec', 'billingblockc', 'tp_id_trunk', 'tp_trunk', 'providertech', 'tp_providerip', 'tp_removeprefix');
$FG_TABLE_ALTERNATE_ROW_COLOR[0]='#CDC9C9';
$FG_TABLE_ALTERNATE_ROW_COLOR[1]='#EEE9E9';
?>
<br>
<table width="65%" border="0" align="center" cellpadding="0" cellspacing="0">
<TR>
<TD style="border-bottom: medium dotted #FF4444" colspan="2"> <B><font color="red" size="3"> Felicitaciones, el simulador ha encontrado el destino!</font></B></TD>
</TR>
<?php if (count($RateEngine->ratecard_obj)>1){ ?>
<TR>
<td height="15" bgcolor="#5555CC" style="padding-left: 5px; padding-right: 3px;" colspan="2">
<b>Se han encontrado varios destinos </b></td>
</TR>
<?php } ?>
<?php for($j=0;$j<count($RateEngine->ratecard_obj);$j++){ ?>
<TR>
<td height="15" bgcolor="" style="padding-left: 5px; padding-right: 3px;" colspan="2">
</td>
</TR>
<TR>
<td height="15" bgcolor="#55CC55" style="padding-left: 5px; padding-right: 3px;" colspan="2">
<b>DESTINO : #<?php echo $j+1;?></b>
</td>
</TR>
<tr>
<td height="15" bgcolor="<?php echo $FG_TABLE_ALTERNATE_ROW_COLOR[1]?>" style="padding-left: 5px; padding-right: 3px;">
<font color="blue"><b><a href="did.php"><img src="includes/js/ThemeOffice/user.png" alt="a " name="image2" width="16" height="16" border="0" align="texttop" id="image2" /></a>Tiempo Disponible</b></font> </td>
<td height="15" bgcolor="<?php echo $FG_TABLE_ALTERNATE_ROW_COLOR[1]?>" style="padding-left: 5px; padding-right: 3px;">
<font color="blue"><i><?php echo $RateEngine->ratecard_obj[$j]['timeout']/60;?> minutos </i></font>
</td>
</tr>
<p> <p> <p>
<tr>
<td height="15" bgcolor="<?php echo $FG_TABLE_ALTERNATE_ROW_COLOR[0]?>" style="padding-left: 5px; padding-right: 3px;"><b><a href="did.php"><img src="includes/js/ThemeOffice/globe1.png" alt="a " name="image2" width="16" height="16" border="0" align="texttop" id="image2" /></a><a href="simulador.php"></a><?php echo $arr_ratecard[3];?></b> </td>
<td height="15" bgcolor="<?php echo $FG_TABLE_ALTERNATE_ROW_COLOR[0]?>" style="padding-left: 5px; padding-right: 3px;">
<i><?php echo $RateEngine->ratecard_obj[$j][5];?></i>
</td>
</tr>
<tr>
<td height="15" bgcolor="<?php echo $FG_TABLE_ALTERNATE_ROW_COLOR[1]?>" style="padding-left: 5px; padding-right: 3px;">
<b><a href="simulador.php"><img src="includes/js/ThemeOffice/query.png" alt="a " name="image2" width="16" height="16" border="0" align="texttop" id="image2" /></a><?php echo $arr_ratecard[10];?></b> </td>
<td height="15" bgcolor="<?php echo $FG_TABLE_ALTERNATE_ROW_COLOR[1]?>" style="padding-left: 5px; padding-right: 3px;">
<i><?php echo "$" . $RateEngine->ratecard_obj[$j][12] . " COP";?></i>
</td>
</tr>
<p> <p> <p>
<?php } ?>
<TR>
<TD style="border-bottom: medium dotted #8888CC" colspan="2"><br></TD>
</TR>
</table>
<div align="center">
<?php } ?>
<? if (count($RateEngine->ratecard_obj)==0) {
if ($called){
?>
<span style="font-weight: bold"> <img src="Css/kicons/button_cancel.png" alt="a" width="32" height="32" /> El numero que ha ingresado no es correcto </span>
<?php } ?>
<?php } ?>
<br>
<br>
<br>
<br>
</div>
<?php
include("PP_footer.php");
?>