Changeset 860
- Timestamp:
- 07/06/08 11:44:17 (6 months ago)
- Files:
-
- trunk/admin/Public/A2B_entity_card_group.php (modified) (1 diff)
- trunk/admin/Public/A2B_entity_package_group.php (added)
- trunk/admin/Public/form_data/FG_var_package_group.inc (added)
- trunk/admin/Public/form_data/FG_var_package.inc (modified) (4 diffs)
- trunk/admin/Public/form_data/FG_var_tariffgroup.inc (modified) (2 diffs)
- trunk/admin/Public/templates/default/main.tpl (modified) (1 diff)
- trunk/common/lib/Class.A2Billing.php (modified) (3 diffs)
- trunk/common/lib/Class.RateEngine.php (modified) (12 diffs)
- trunk/common/lib/interface/constants.php (modified) (1 diff)
- trunk/DataBase/mysql-5.x/UPDATE-a2billing-v1.3.0-to-v1.4.0-mysql.sql (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/admin/Public/A2B_entity_card_group.php
r856 r860 37 37 // #### HEADER SECTION 38 38 $smarty->display('main.tpl'); 39 if ($popup_select)40 {41 ?>42 <SCRIPT LANGUAGE="javascript">43 <!-- Begin44 function sendValue(selvalue) {45 window.opener.document.<?php echo $popup_formname ?>.<?php echo $popup_fieldname ?>.value = selvalue;46 window.close();47 }48 // End -->49 </script>50 <?php51 }52 39 53 40 54 41 // #### HELP SECTION 55 if (!$popup_select) echo $CC_help_provider;42 echo $CC_help_list_customer; 56 43 57 44 58 echo $CALL_LABS;59 45 60 46 trunk/admin/Public/form_data/FG_var_package.inc
r792 r860 12 12 $billingtype_list = Constants::getBillingPeriodsList(); 13 13 14 // If packagetype == NUMBER OF FREE CALL -> concat unit with "times" 15 // Else concat with "sec" 16 $filter_unit ='CASE packagetype WHEN 1 THEN CONCAT( freetimetocall, " times" ) WHEN 0 THEN "ALL" ELSE CONCAT( freetimetocall, " sec" ) END '; 14 17 15 18 $HD_Form -> AddViewElement(gettext("LABEL"), "label", "18%", "center", "sort"); … … 18 21 $HD_Form -> AddViewElement(gettext("BILLINGTYPE"), "billingtype", "15%", "center", "sort","","list",$billingtype_list); 19 22 $HD_Form -> AddViewElement(gettext("STARTDAY"), "startday", "7%", "center", "sort"); 20 $HD_Form -> AddViewElement(gettext("FREE CALL"), "freetimetocall", "7%", "center", "sort", "30", "", "", "", "", "", "display_minute");23 $HD_Form -> AddViewElement(gettext("FREE"), "freetimetocall", "17%", "center", "sort", "30", "", "", "", "", "", ""); 21 24 22 $HD_Form -> FieldViewElement ('label, creationdate, packagetype, billingtype, startday, freetimetocall');25 $HD_Form -> FieldViewElement ('label, creationdate, packagetype, billingtype, startday, '.$filter_unit); 23 26 24 27 $HD_Form -> FG_ACTION_SIZE_COLUMN='15%'; … … 74 77 75 78 76 $HD_Form -> AddEditElement (gettext("FREE TIME TO CALL"),79 $HD_Form -> AddEditElement (gettext("FREE UNITS"), 77 80 "freetimetocall", 78 81 '$value', … … 81 84 "4", 82 85 gettext("Insert the amount of free time to call (seconds)"), 83 "" , "", "", "", "", "", "", gettext("Insert the amount of free time to call (seconds)")); 86 "" , "", "", "", "", "", "", gettext("Insert the amount of free units for UNLIMITED,FREE MINUTES,NORMAL, it's the times to call in seconds. For NUMBER OF FREE CALLS, introduce the numbers of free calls")); 87 88 89 90 $DBHandle_max = DbConnect(); 91 $numrow = 0; 92 $resmax = $DBHandle_max -> Execute("SELECT * FROM cc_ratecard"); 93 if ( $resmax ) 94 $numrow = $resmax -> RecordCount( ); 95 96 if ($numrow>0){ 97 $HD_Form -> AddEditElement (gettext("RATE ASSOCIATE"), 98 "rates", 99 '$value', 100 "SELECT", 101 'size="25" multiple="multiple"', 102 "", 103 "", 104 "sql", 105 "package_rates", 106 "", 107 "", "", "%1 : (%2)", "", "", "cc_package_rate:rate_id:cc_ratecard LEFT JOIN cc_package_rate ON cc_ratecard.id=cc_package_rate.rate_id:DISTINCT CONCAT(cc_ratecard.destination,' - ',cc_ratecard.dialprefix ), cc_ratecard.id,cc_ratecard.destination, cc_ratecard.dialprefix: cc_package_rate.package_id = %id:package_id:%3 - ( %4 )::::%1:id='%1'"); 108 109 } 110 111 84 112 85 113 $HD_Form -> FieldEditElement ('label, packagetype, billingtype, startday, freetimetocall'); trunk/admin/Public/form_data/FG_var_tariffgroup.inc
r792 r860 33 33 if (!$popup_select) $HD_Form -> AddViewElement(gettext("CREATIONDATE"), "creationdate", "20%", "center", "sort", "19", "", "", "", "", "", "display_dateformat"); 34 34 $HD_Form -> AddViewElement(gettext("LC TYPE"), "lcrtype", "15%", "center", "sort", "", "list", $lcrtype_list_short); 35 $HD_Form -> AddViewElement(gettext("PACKAGE"), "id_cc_package_offer", "11%", "center", "sort", "15", "lie", "cc_package_ offer", "label", "id='%id'", "%1");35 $HD_Form -> AddViewElement(gettext("PACKAGE"), "id_cc_package_offer", "11%", "center", "sort", "15", "lie", "cc_package_group", "name", "id='%id'", "%1"); 36 36 $HD_Form -> AddViewElement(gettext("INTER PREFIX"), "removeinterprefix", "15%", "center", "sort", "", "list", $inter_prefix_list_short); 37 37 … … 95 95 "", "", "", 96 96 "sql", 97 "cc_package_ offer",98 " label, id",99 "", "", "%1", "", gettext("Set the Package offer if you wish to use one with this Call Plan"), '', '<OPTION value="-1" selected>NO PACKAGE OFFER</OPTION>');97 "cc_package_group", 98 "name, id", 99 "", "", "%1", "", gettext("Set the Package Group offer if you wish to use one with this Call Plan"), '', '<OPTION value="-1" selected>NO PACKAGE OFFER</OPTION>'); 100 100 101 101 $HD_Form -> AddEditElement (gettext("REMOVE INTER PREFIX"), trunk/admin/Public/templates/default/main.tpl
r856 r860 156 156 <ul> 157 157 <li><ul> 158 <li><a href="A2B_entity_package_group.php?atmenu=prefixe&stitle=Prefix§ion=3_3">{php} echo gettext("List Group Packages");{/php}</a></li> 159 <li><a href="A2B_entity_package_group.php?form_action=ask-add&atmenu=prefixe&stitle=Prefix§ion=3_3">{php} echo gettext("Add Group Packages");{/php}</a></li> 158 160 <li><a href="A2B_entity_package.php?atmenu=prefixe&stitle=Prefix§ion=3_3">{php} echo gettext("List Offer Package");{/php}</a></li> 159 161 <li><a href="A2B_entity_package.php?form_action=ask-add&atmenu=prefixe&stitle=Prefix§ion=3_3">{php} echo gettext("Add Offer Package");{/php}</a></li> trunk/common/lib/Class.A2Billing.php
r859 r860 773 773 $id_cc_package_offer = $result[0][5]; 774 774 $freetimetocall_used = $this->FT2C_used_seconds($this->DBHandle, $this->id_card, $id_cc_package_offer, $billingtype, $startday); 775 776 //TO MANAGE BY PACKAGE TYPE IT -> only for freetime 775 777 if (($packagetype == 0) || ($packagetype == 1)) { 776 778 $minutes=intval(($freetime-$freetimetocall_used)/60); … … 792 794 $agi-> stream_file('prepaid-minute', '#'); 793 795 }else{ 796 794 797 if((strtolower($this->agiconfig['force_language'])=='ru')&& ( ( $minutes%10==2) || ($minutes%10==3 )|| ($minutes%10==4)) ){ 795 798 // test for the specific grammatical rules in RUssian … … 1570 1573 return $pwd; 1571 1574 } 1575 1576 /** Function to retrieve the number of used package Free call for a customer 1577 * according to billingtype (Monthly ; Weekly) & Startday 1578 * 1579 * @param object $DBHandle 1580 * @param integer $id_cc_card 1581 * @param integer $id_cc_package_offer 1582 * @param integer $billingtype 1583 * @param integer $startday 1584 * @return integer number of seconds used of FT2C package so far in this period 1585 **/ 1586 1587 function number_free_calls_used($DBHandle, $id_cc_card, $id_cc_package_offer, $billingtype, $startday){ 1588 1589 if ($billingtype == 0){ 1590 // PROCESSING FOR MONTHLY 1591 // if > last day of the month 1592 if ($startday > date("t")) $startday = date("t"); 1593 if ($startday <= 0 ) $startday = 1; 1594 1595 // Check if the startday is upper that the current day 1596 if ($startday > date("j")) $year_month = date('Y-m', strtotime('-1 month')); 1597 else $year_month = date('Y-m'); 1598 1599 $yearmonth = sprintf("%s-%02d",$year_month,$startday); 1600 if ($this->config["database"]['dbtype'] == "postgres"){ 1601 $UNIX_TIMESTAMP = ""; 1602 }else{ 1603 $UNIX_TIMESTAMP = "UNIX_TIMESTAMP"; 1604 } 1605 $CLAUSE_DATE=" $UNIX_TIMESTAMP(date_consumption) >= $UNIX_TIMESTAMP('$yearmonth')"; 1606 }else{ 1607 // PROCESSING FOR WEEKLY 1608 $startday = $startday % 7; 1609 $dayofweek = date("w"); // Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday) 1610 if ($dayofweek==0) $dayofweek=7; 1611 if ($dayofweek < $startday) $dayofweek = $dayofweek + 7; 1612 $diffday = $dayofweek - $startday; 1613 if ($this->config["database"]['dbtype'] == "postgres"){ 1614 $CLAUSE_DATE = "date_consumption >= (CURRENT_DATE - interval '$diffday day') "; 1615 }else{ 1616 $CLAUSE_DATE = "date_consumption >= DATE_SUB(CURRENT_DATE, INTERVAL $diffday DAY) "; 1617 } 1618 } 1619 $QUERY = "SELECT COUNT(*) AS number_calls FROM cc_card_package_offer ". 1620 "WHERE $CLAUSE_DATE AND id_cc_card = '$id_cc_card' AND id_cc_package_offer = '$id_cc_package_offer' "; 1621 $pack_result = $DBHandle -> Execute($QUERY); 1622 if ($pack_result && ($pack_result -> RecordCount() > 0)) { 1623 $result = $pack_result -> fetchRow(); 1624 $number_calls_used = $result[0]; 1625 } else { 1626 $number_calls_used = 0; 1627 } 1628 return $number_calls_used; 1629 1630 } 1572 1631 1573 1632 trunk/common/lib/Class.RateEngine.php
r822 r860 25 25 26 26 var $freetimetocall_left = array(); 27 var $freecall = array(); 28 var $package_to_apply= array(); 27 29 28 30 var $number_trunk = 0; … … 161 163 $prefixclause .= "'X', '[0-9]', 'g'), 'Z', '[1-9]', 'g'), 'N', '[2-9]', 'g'), E'\\\\.', '+', 'g'), '_', '', 'g'))"; 162 164 } 163 165 // select group by 5 ... more easy to count 164 166 $QUERY = "SELECT 165 tariffgroupname, lcrtype, idtariffgroup, cc_tariffgroup_plan.idtariffplan, tariffname, destination, 166 cc_ratecard.id, dialprefix, destination, buyrate, buyrateinitblock, buyrateincrement, rateinitial, initblock, billingblock, 167 connectcharge, disconnectcharge, stepchargea, chargea, timechargea, billingblocka, stepchargeb, chargeb, 168 timechargeb, billingblockb, stepchargec, chargec, timechargec, billingblockc, 169 cc_tariffplan.id_trunk AS tp_id_trunk, tp_trunk.trunkprefix AS tp_trunk, tp_trunk.providertech AS tp_providertech, 170 tp_trunk.providerip AS tp_providerip, tp_trunk.removeprefix AS tp_removeprefix, 171 cc_ratecard.id_trunk AS rc_id_trunk, rt_trunk.trunkprefix AS rc_trunkprefix, rt_trunk.providertech AS rc_providertech, 172 rt_trunk.providerip AS rc_providerip, rt_trunk.removeprefix AS rc_removeprefix, musiconhold, 173 tp_trunk.failover_trunk AS tp_failover_trunk, rt_trunk.failover_trunk AS rt_failover_trunk, 174 tp_trunk.addparameter AS tp_addparameter_trunk, rt_trunk.addparameter AS rt_addparameter_trunk, 175 id_outbound_cidgroup, freetimetocall_package_offer, freetimetocall, packagetype, billingtype, startday, id_cc_package_offer, 176 tp_trunk.status, rt_trunk.status, tp_trunk.inuse, rt_trunk.inuse, tp_trunk.maxuse, rt_trunk.maxuse, 177 tp_trunk.if_max_use, rt_trunk.if_max_use, 178 cc_ratecard.rounding_calltime AS rounding_calltime, 179 cc_ratecard.rounding_threshold AS rounding_threshold, 180 cc_ratecard.additional_block_charge AS additional_block_charge, 181 cc_ratecard.additional_block_charge_time AS additional_block_charge_time 167 tariffgroupname, lcrtype, idtariffgroup, cc_tariffgroup_plan.idtariffplan, tariffname, 168 destination, cc_ratecard.id, dialprefix, destination, buyrate, 169 buyrateinitblock, buyrateincrement, rateinitial, initblock, billingblock, 170 connectcharge, disconnectcharge, stepchargea, chargea, timechargea, 171 billingblocka, stepchargeb, chargeb,timechargeb, billingblockb, 172 stepchargec, chargec, timechargec, billingblockc,cc_tariffplan.id_trunk AS tp_id_trunk, 173 tp_trunk.trunkprefix AS tp_trunk, tp_trunk.providertech AS tp_providertech,tp_trunk.providerip AS tp_providerip, tp_trunk.removeprefix AS tp_removeprefix,cc_ratecard.id_trunk AS rc_id_trunk, 174 rt_trunk.trunkprefix AS rc_trunkprefix, rt_trunk.providertech AS rc_providertech,rt_trunk.providerip AS rc_providerip, rt_trunk.removeprefix AS rc_removeprefix, musiconhold, 175 tp_trunk.failover_trunk AS tp_failover_trunk, rt_trunk.failover_trunk AS rt_failover_trunk,tp_trunk.addparameter AS tp_addparameter_trunk, rt_trunk.addparameter AS rt_addparameter_trunk, id_outbound_cidgroup, 176 id_cc_package_offer,tp_trunk.status, rt_trunk.status, tp_trunk.inuse, rt_trunk.inuse, 177 tp_trunk.maxuse, rt_trunk.maxuse,tp_trunk.if_max_use, rt_trunk.if_max_use,cc_ratecard.rounding_calltime AS rounding_calltime, 178 cc_ratecard.rounding_threshold AS rounding_threshold,cc_ratecard.additional_block_charge AS additional_block_charge,cc_ratecard.additional_block_charge_time AS additional_block_charge_time 182 179 183 180 FROM cc_tariffgroup … … 187 184 LEFT JOIN cc_trunk AS rt_trunk ON cc_ratecard.id_trunk=rt_trunk.id_trunk 188 185 LEFT JOIN cc_trunk AS tp_trunk ON cc_tariffplan.id_trunk=tp_trunk.id_trunk 189 LEFT JOIN cc_package_offer ON cc_package_offer.id=cc_tariffgroup.id_cc_package_offer190 186 191 187 WHERE cc_tariffgroup.id=$tariffgroupid AND ($prefixclause) … … 264 260 265 261 if ($result[$i][34] == -1) { 266 $status = $result[$i][ 51];262 $status = $result[$i][46]; 267 263 $mylistoftrunk_next[]= $mycurrenttrunk = $result[$i][29]; 268 264 } else { 269 $status = $result[$i][ 52];265 $status = $result[$i][47]; 270 266 $mylistoftrunk_next[]= $mycurrenttrunk = $result[$i][34]; 271 267 } … … 356 352 $billingblockc = $this -> ratecard_obj[$K][28]; 357 353 // **************** PACKAGE PARAMETERS **************** 358 $freetimetocall_package_offer = $this -> ratecard_obj[$K][45]; 359 $freetimetocall = $this -> ratecard_obj[$K][46]; 360 $packagetype = $this -> ratecard_obj[$K][47]; 361 $billingtype = $this -> ratecard_obj[$K][48]; 362 $startday = $this -> ratecard_obj[$K][49]; 363 $id_cc_package_offer = $this -> ratecard_obj[$K][50]; 364 354 $id_cc_package_group = $this -> ratecard_obj[$K][45]; 355 $id_rate = $this -> ratecard_obj[$K][6]; 356 365 357 // CHANGE THIS - ONLY ALLOW FREE TIME FOR CUSTOMER THAT HAVE MINIMUM CREDIT TO CALL A DESTINATION 366 358 367 // WE HAVE THE SAME CALL PLAN FOR ALL SO WE CAN RESTRICT THIS CALCULATION TO 1 BEFORE EACH CALL368 359 $this -> freetimetocall_left[$K] = 0; 369 if ($K == 0){ 370 // CHECK IF WE HAVE A FREETIME THAT CAN APPLY FOR THIS DESTINATION 371 if ($freetimetocall_package_offer==1 && $freetimetocall>0){ 372 // WE NEED TO RETRIEVE THE AMOUNT OF USED MINUTE FOR THIS CUSTOMER ACCORDING TO BILLINGTYPE (Monthly ; Weekly) & STARTDAY 373 $this -> freetimetocall_used = $A2B -> FT2C_used_seconds($A2B->DBHandle, $A2B->id_card, $id_cc_package_offer, $billingtype, $startday); 374 $this -> freetimetocall_left[$K] = $freetimetocall - $this->freetimetocall_used; 375 if ($this -> freetimetocall_left[$K] < 0) $this -> freetimetocall_left[$K] = 0; 376 377 } 378 } 379 if ($this -> debug_st) print_r($this -> freetimetocall_left); 380 // **************** END PACKAGE PARAMETERS **************** 360 $this -> freecall[$K] = false; 361 $this -> package_to_apply [$K] = null; 362 363 //CHECK THE PACKAGES TOAPPLY TO THIS RATES 364 if($id_cc_package_group!=-1){ 365 366 $table_packages = new Table("cc_package_group,cc_packgroup_package,cc_package_offer,cc_package_rate", "cc_package_offer.id, packagetype,billingtype,startday,freetimetocall"); 367 $clause_packages= "cc_package_group.id= ".$id_cc_package_group."AND cc_package_group.id=cc_packgroup_package.packagegroup_id AND cc_packgroup_package.package_id = cc_package_offer.id AND cc_package_offer.id = cc_package_rate.package_id AND cc_package_rate.rate_id = ".$id_rate; 368 $order_packages = "cc_package_offer.packagetype"; 369 $sens_packages = "ASC"; 370 $result_packages= $table_agent_security -> Get_list ($HD_Form -> DBHandle, $clause_packages, $order_packages, $sens_packages, null, null, null, null); 371 $idx_pack = 0; 372 if(!empty($result_packages)) 373 { 374 $package_selected = false; 375 while(!$package_selected && $idx_pack < count($result_packages)){ 376 $freetimetocall = $result_packages[$idx_pack]["freetimetocall"]; 377 $packagetype = $result_packages[$idx_pack]["packagetype"]; 378 $billingtype = $result_packages[$idx_pack]["billingtype"]; 379 $startday = $result_packages[$idx_pack]["startday"]; 380 $id_cc_package_offer= $result_packages[$idx_pack][0]; 381 382 switch($packagetype){ 383 // 0 : UNLIMITED PACKAGE 384 //IF PACKAGE IS "UNLIMITED" SO WE DON'T NEED TO CALCULATE THE USED TIMES 385 case 0 : $this -> freecall[$K] = true; 386 $package_selected = true; 387 $package_to_apply [$K] = array("id"=>$id_cc_package_offer,"label"=>gettext("Unlimited calls"),"type"=>$packagetype); 388 break; 389 // 1 : FREE CALLS 390 //IF PACKAGE IS "NUMBER OF FREE CALLS" AND WE CAN USE IT ELSE WE CHECK THE OTHERS PACKAGE LIKE FREE TIMES 391 case 1 : if ( $freetimetocall>0){ 392 $number_calls_used =$A2B -> number_free_calls_used($A2B->DBHandle, $A2B->id_card, $id_cc_package_offer, $billingtype, $startday); 393 if($number_calls_used < $freetimetocall){ 394 $this -> freecall[$K] = true; 395 $package_selected = true; 396 $package_to_apply [$K] = array("id"=>$id_cc_package_offer,"label"=> gettext("Number of Free calls"),"type"=>$packagetype); 397 } 398 } 399 break; 400 //2 : FREE TIMES 401 case 2 : 402 // CHECK IF WE HAVE A FREETIME THAT CAN APPLY FOR THIS DESTINATION 403 if ( $freetimetocall>0){ 404 // WE NEED TO RETRIEVE THE AMOUNT OF USED MINUTE FOR THIS CUSTOMER ACCORDING TO BILLINGTYPE (Monthly ; Weekly) & STARTDAY 405 $this -> freetimetocall_used = $A2B -> FT2C_used_seconds($A2B->DBHandle, $A2B->id_card, $id_cc_package_offer, $billingtype, $startday); 406 $this -> freetimetocall_left[$K] = $freetimetocall - $this->freetimetocall_used; 407 if ($this -> freetimetocall_left[$K] < 0) $this -> freetimetocall_left[$K] = 0; 408 if ($this -> freetimetocall_left[$K] > 0) $package_to_apply [$K] = array("id"=>$id_cc_package_offer,"label"=> gettext("Free minutes"),"type"=>$packagetype); 409 410 } 411 if ($this -> debug_st) print_r($this -> freetimetocall_left); 412 // **************** END PACKAGE PARAMETERS **************** 413 break; 414 } 415 416 $idx_pack++; 417 } 418 419 420 421 422 } 423 } 381 424 382 425 $credit -= $connectcharge; … … 419 462 if ($rateinitial<=0){ 420 463 $this -> ratecard_obj[$K]['timeout']= $A2B->agiconfig['maxtime_tocall_negatif_free_route']; // 90 min 464 if ($this -> debug_st) print_r($this -> ratecard_obj[$K]); 465 return $TIMEOUT; 466 } 467 468 if ($this -> freecall[$K]){ 469 if( $this -> package_to_apply [$K] ["type"] == 0){ 470 $this -> ratecard_obj[$K]['timeout']= $A2B->agiconfig['maxtime_tounlimited_calls']; // default : 90 min 471 }else{ 472 $this -> ratecard_obj[$K]['timeout']= $A2B->agiconfig['maxtime_tofree_calls']; 473 } 474 421 475 if ($this -> debug_st) print_r($this -> ratecard_obj[$K]); 422 476 return $TIMEOUT; … … 649 703 $billingblockc = $this -> ratecard_obj[$K][28]; 650 704 // Initialization rounding calltime and rounding threshold variables 651 $rounding_calltime = $this->ratecard_obj[$K][5 9];652 $rounding_threshold = $this->ratecard_obj[$K][ 60];705 $rounding_calltime = $this->ratecard_obj[$K][54]; 706 $rounding_threshold = $this->ratecard_obj[$K][55]; 653 707 // Initialization additional block charge and additional block charge time variables 654 $additional_block_charge = $this->ratecard_obj[$K][ 61];655 $additional_block_charge_time = $this->ratecard_obj[$K][ 62];708 $additional_block_charge = $this->ratecard_obj[$K][56]; 709 $additional_block_charge_time = $this->ratecard_obj[$K][57]; 656 710 657 711 if (!is_numeric($rounding_calltime)) $rounding_calltime = 0; … … 703 757 $buyratecost -= ($buyratecallduration/60) * $buyrate; 704 758 if ($this -> debug_st) echo "1. cost: $cost\n buyratecost:$buyratecost\n"; 759 760 // IF IT S A FREE CALL, WE CAN STOP HERE COST = 0 761 if($this -> freecall[$K]){ 762 $this -> lastcost = 0; 763 $this -> lastbuycost = $buyratecost; 764 if ($this -> debug_st) echo "FINAL COST: $cost\n\n"; 765 $A2B -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[CC_RATE_ENGINE_CALCULCOST: K=$K - BUYCOST: $buyratecost - SELLING COST: $cost]"); 766 return; 767 } 705 768 706 769 // #### CALCUL SELLRATE COST ##### … … 841 904 $K = $this->usedratecard; 842 905 // **************** PACKAGE PARAMETERS **************** 843 $freetimetocall_package_offer = $this -> ratecard_obj[$K][45];844 $freetimetocall = $this -> ratecard_obj[$K][46];845 $id_cc_package_ offer = $this -> ratecard_obj[$K][50];906 //$freetimetocall_package_offer = $this -> ratecard_obj[$K][45]; 907 //$freetimetocall = $this -> ratecard_obj[$K][46]; 908 $id_cc_package_group= $this -> ratecard_obj[$K][45]; 846 909 847 910 if ($A2B -> CC_TESTING){ … … 860 923 if ($this -> debug_st) print_r($this -> freetimetocall_left[$K]); 861 924 862 if (($freetimetocall_package_offer==1) && ($freetimetocall > 0) && ($this -> freetimetocall_left[$K] > 0)){ 863 864 if ($this -> freetimetocall_left[$K] >= $sessiontime){ 865 $this->freetimetocall_used = $sessiontime; 866 }else{ 867 $this->freetimetocall_used = $this -> freetimetocall_left[$K]; 868 } 925 if (($id_cc_package_group!=-1) && ($this ->package_to_apply[$K] !=null )){ 926 927 switch($this ->package_to_apply[$K]["type"] ){ 928 //Unlimited 929 case 0 : $this->freetimetocall_used = $sessiontime;break; 930 //free calls 931 case 1 : $this->freetimetocall_used = $sessiontime;break; 932 //free times 933 case 2 : 934 if ($this -> freetimetocall_left[$K] >= $sessiontime){ 935 $this->freetimetocall_used = $sessiontime; 936 }else{ 937 $this->freetimetocall_used = $this -> freetimetocall_left[$K]; 938 } 939 break; 940 941 } 869 942 870 943 $this -> rate_engine_calculcost ($A2B, $sessiontime, 0); … … 1016 1089 $addparameter = $this -> ratecard_obj[$k][42+$usetrunk_failover]; 1017 1090 $cidgroupid = $this -> ratecard_obj[$k][44]; 1018 $inuse = $this -> ratecard_obj[$k][ 53+$usetrunk_failover];1019 $maxuse = $this -> ratecard_obj[$k][5 5+$usetrunk_failover];1020 $ifmaxuse = $this -> ratecard_obj[$k][5 7+$usetrunk_failover];1091 $inuse = $this -> ratecard_obj[$k][48+$usetrunk_failover]; 1092 $maxuse = $this -> ratecard_obj[$k][50+$usetrunk_failover]; 1093 $ifmaxuse = $this -> ratecard_obj[$k][52+$usetrunk_failover]; 1021 1094 1022 1095 if (strncmp($destination, $removeprefix, strlen($removeprefix)) == 0) … … 1248 1321 } // End for 1249 1322 1250 $this -> usedratecard = $k- 1;1323 $this -> usedratecard = $k-$loop_failover; 1251 1324 $A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[USEDRATECARD - FAIL =".$this -> usedratecard."]"); 1252 1325 return false; trunk/common/lib/interface/constants.php
r793 r860 142 142 public static function getPackagesTypeList(){ 143 143 $packagetype_list = array(); 144 $packagetype_list["0"] = array( gettext("Free minute + Unlimited"), "0"); 145 $packagetype_list["1"] = array( gettext("Free minute"), "1"); 146 $packagetype_list["2"] = array( gettext("Unlimited"), "2"); 147 $packagetype_list["3"] = array( gettext("Normal"), "3"); 144 $packagetype_list["0"] = array( gettext("Unlimited calls"), "0"); 145 $packagetype_list["1"] = array( gettext("Number of Free calls"), "1"); 146 $packagetype_list["2"] = array( gettext("Free minutes"), "2"); 148 147 return $packagetype_list; 149 148 } trunk/DataBase/mysql-5.x/UPDATE-a2billing-v1.3.0-to-v1.4.0-mysql.sql
r858 r860 983 983 984 984 ALTER TABLE cc_card ADD id_group INT NOT NULL DEFAULT '1'; 985 986 --create 987 988 CREATE TABLE cc_logpackage ( 989 id BIGINT NOT NULL AUTO_INCREMENT , 990 call_id BIGINT NOT NULL , 991 package_id INT NOT NULL , 992 username CHAR( 40 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL , 993 card_id BIGINT NOT NULL , 994 time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, 995 PRIMARY KEY ( id ) 996 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 997 998 999 CREATE TABLE cc_package_group ( 1000 id INT NOT NULL AUTO_INCREMENT , 1001 name CHAR( 30 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL , 1002 description MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_bin NULL, 1003 PRIMARY KEY ( id ) 1004 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 1005 1006 CREATE TABLE cc_packgroup_package ( 1007 packagegroup_id INT NOT NULL , 1008 package_id INT NOT NULL , 1009 PRIMARY KEY ( packagegroup_id , package_id ) 1010 ) ENGINE = MYISAM ; 1011 1012 1013 CREATE TABLE cc_package_rate ( 1014 package_id INT NOT NULL , 1015 rate_id INT NOT NULL , 1016 PRIMARY KEY ( package_id , rate_id ) 1017 ) ENGINE = MYISAM ; 1018 1019 1020 NSERT INTO cc_config ( 1021 id , 1022 config_title , 1023 config_key , 1024 config_value , 1025 config_description , 1026 config_valuetype , 1027 config_group_id , 1028 config_listvalues 1029 ) 1030 VALUES ( 1031 NULL , 'Max Time For Unlimited Calls', 'maxtime_tounlimited_calls', '5400', 'For unlimited calls, limit the duration: amount in seconds .', '0', '11', NULL 1032 ), ( 1033 NULL , 'Max Time For Free Calls', 'maxtime_tofree_calls', '5400', 'For free calls, limit the duration: amount in seconds .', '0', '11', NULL 1034 );
