Changeset 895
- Timestamp:
- 07/24/08 17:40:11 (2 years ago)
- Files:
-
- trunk/AGI/a2billing.php (modified) (3 diffs)
- trunk/common/lib/Class.A2Billing.php (modified) (4 diffs)
- trunk/DataBase/mysql-5.x/UPDATE-a2billing-v1.3.0-to-v1.4.0-mysql.sql (modified) (1 diff)
- trunk/DataBase/psql/UPDATE-a2billing-v1.3.0-to-v1.4.0-pgsql.sql (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/AGI/a2billing.php
r817 r895 170 170 $A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, '[CHANNEL STATUS : '.$stat_channel["result"].' = '.$stat_channel["data"].']'. 171 171 "\n[CREDIT : ".$A2B-> credit."][CREDIT MIN_CREDIT_2CALL : ".$A2B->agiconfig['min_credit_2call']."]"); 172 172 173 173 // CHECK IF THE CHANNEL IS UP 174 174 //if ($stat_channel["status"]!= "6" && $stat_channel["status"]!= "1"){ … … 181 181 // CREATE A DIFFERENT UNIQUEID FOR EACH TRY 182 182 if ($i>0){ 183 $A2B-> uniqueid = $A2B-> uniqueid + 1000000000 ; 184 } 185 183 $A2B-> uniqueid = $A2B-> uniqueid + 1000000000; 184 } 185 186 // Feature to switch the Callplan from a customer : callplan_deck_minute_threshold 187 $A2B-> deck_switch($agi); 188 186 189 if( $A2B->credit < $A2B->agiconfig['min_credit_2call'] && $A2B -> typepaid==0 && $A2B->agiconfig['jump_voucher_if_min_credit']==1) { 187 190 … … 194 197 } 195 198 } 196 199 197 200 if( $A2B->credit < $A2B->agiconfig['min_credit_2call'] && $A2B -> typepaid==0) { 198 201 trunk/common/lib/Class.A2Billing.php
r884 r895 2438 2438 return 1; 2439 2439 } 2440 2441 2440 2441 2442 /* 2443 * Function deck_switch 2444 * to switch the Callplan from a customer : callplan_deck_minute_threshold 2445 * 2446 */ 2447 function deck_switch($agi) 2448 { 2449 if (strpos($this->agiconfig['callplan_deck_minute_threshold'], ',') === false) 2450 return false; 2451 2452 $arr_splitable_deck = explode(",", $this->agiconfig['callplan_deck_minute_threshold']); 2453 2454 foreach ($arr_splitable_deck as $arr_value) { 2455 2456 $arr_value = trim ($arr_value); 2457 $arr_value_explode = explode(":", $arr_value,2); 2458 if (count($arr_value_explode) > 1){ 2459 if (is_numeric($arr_value_explode[0]) && is_numeric($arr_value_explode[1]) ){ 2460 $arr_value_deck_callplan[] = $arr_value_explode[0]; 2461 $arr_value_deck_minute[] = $arr_value_explode[1]; 2462 } 2463 }else{ 2464 if (is_numeric($arr_value)){ 2465 $arr_value_deck_callplan[] = $arr_value; 2466 $arr_value_deck_minute[] = 0; 2467 } 2468 } 2469 } 2470 // We have $arr_value_deck_callplan with 1, 2, 3 & we have $arr_value_deck_minute with 5, 1, 0 2471 if (count($arr_value_deck_callplan) == 0) 2472 return false; 2473 2474 $QUERY = "SELECT sum(sessiontime), count(*) FROM cc_call WHERE card_id='".$this->id_card."'"; 2475 $result = $this->instance_table -> SQLExec ($this->DBHandle, $QUERY); 2476 $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[DECK SWITCH - Start]".print_r($result, true)); 2477 $sessiontime_for_card = $result[0][0]; 2478 $calls_for_card = $result[0][1]; 2479 2480 $find_deck = false; 2481 $accumul_seconds = 0; 2482 for ($ind_deck = 0 ; $ind_deck < count($arr_value_deck_callplan) ; $ind_deck++){ 2483 $accumul_seconds += $arr_value_deck_minute[$ind_deck]; 2484 2485 if ($arr_value_deck_callplan[$ind_deck] == $this->tariff) { 2486 if (is_numeric($arr_value_deck_callplan[$ind_deck+1])) { 2487 $find_deck = true; 2488 } else { 2489 $find_deck = false; 2490 } 2491 break; 2492 } 2493 } 2494 2495 $ind_deck = $ind_deck + 1; 2496 if ($find_deck) { 2497 // Check if the sum sessiontime call is more the the accumulation of the parameters seconds & that the amount of calls made is upper than the deck level 2498 if (($sessiontime_for_card > $accumul_seconds) && ($calls_for_card > $ind_deck)) { 2499 // UPDATE CARD 2500 $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[DECK SWITCH] : UPDATE CARD TO CALLPLAN ID = ".$arr_value_deck_callplan[$ind_deck]); 2501 $QUERY = "UPDATE cc_card SET tariff='".$arr_value_deck_callplan[$ind_deck]."' WHERE id='".$this->id_card."'"; 2502 $result = $this -> instance_table -> SQLExec ($this->DBHandle, $QUERY, 0); 2503 2504 $this->tariff = $arr_value_deck_callplan[$ind_deck]; 2505 } 2506 } 2507 return true; 2508 } 2509 2510 2511 /* 2512 * Function DbConnect 2513 * Returns: true / false if connection has been established 2514 */ 2442 2515 function DbConnect() 2443 2516 { … … 2456 2529 return true; 2457 2530 } 2458 2459 2531 2532 2533 /* 2534 * Function DbDisconnect 2535 */ 2460 2536 function DbDisconnect() 2461 2537 { … … 2466 2542 /* 2467 2543 * function splitable_data 2544 * used by parameter like interval_len_cardnumber : 8-10, 12-18, 20 2545 * it will build an array with the different interval 2468 2546 */ 2469 2547 function splitable_data ($splitable_value){ … … 2505 2583 }; 2506 2584 2507 ?>trunk/DataBase/mysql-5.x/UPDATE-a2billing-v1.3.0-to-v1.4.0-mysql.sql
r891 r895 1015 1015 1016 1016 1017 -- ALTER TABLE `cc_config` CHANGE `config_description` `config_description` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL; 1018 -- ALTER TABLE `cc_config` CHANGE `config_description` `config_description` VARCHAR( 500 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL 1019 1020 -- Deck threshold switch for callplan 1021 -- delete from cc_config where config_key='callplan_deck_minute_threshold'; 1022 1017 ALTER TABLE `cc_config` CHANGE `config_description` `config_description` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL; 1018 1019 1020 -- Deck threshold switch for callplan 1023 1021 INSERT INTO cc_config (config_title, config_key, config_value, config_description, config_valuetype, config_group_id, config_listvalues) 1024 1022 VALUES ('CallPlan threshold Deck switch', 'callplan_deck_minute_threshold', '', 'CallPlan threshold Deck switch. <br/>This option will switch the user callplan from one call plan ID to and other Callplan ID 1025 1023 The parameters are as follow : <br/> 1026 -- ID of the first callplan : called minutes needed to switch to the next CallplanID <br/>1027 -- ID of the second callplan : called minutes needed to switch to the next CallplanID <br/>1028 -- if not needed minutes are defined it will automatically switch to the next one <br/>1029 -- if defined we will sum the previous needed minutes and check if the caller had done at least the amount of calls necessary to go to the next step and have the amount of minutes needed<br/>1030 value example for callplan_deck_minute_threshold = 1: 5, 2:1, 3',1024 -- ID of the first callplan : called seconds needed to switch to the next CallplanID <br/> 1025 -- ID of the second callplan : called seconds needed to switch to the next CallplanID <br/> 1026 -- if not needed seconds are defined it will automatically switch to the next one <br/> 1027 -- if defined we will sum the previous needed seconds and check if the caller had done at least the amount of calls necessary to go to the next step and have the amount of seconds needed<br/> 1028 value example for callplan_deck_minute_threshold = 1:300, 2:60, 3', 1031 1029 '0', '11', NULL); 1032 1030 1033 1031 1034 1035 -- TODO Test insert of config and not show value1036 -- INSERT INTO `cc_config` ( `config_title`, `config_key`, `config_value`, `config_description`, `config_valuetype`, `config_group_id`, `config_listvalues`) VALUES('Extra charge DIDs', 'extracharge_did', '1800,1900', 'Add extra per-minute charges to this comma-separated list of DNIDs; needs "extracharge_fee" and "extracharge_buyfee"', 0, 11, NULL);trunk/DataBase/psql/UPDATE-a2billing-v1.3.0-to-v1.4.0-pgsql.sql
r891 r895 106 106 id BIGSERIAL NOT NULL, 107 107 config_title TEXT NOT NULL, 108 config_key TEXT NOT NULL,108 config_key TEXT NOT NULL, 109 109 config_value TEXT NOT NULL, 110 110 config_description TEXT NOT NULL, … … 1015 1015 VALUES ('CallPlan threshold Deck switch', 'callplan_deck_minute_threshold', '', 'CallPlan threshold Deck switch. <br/>This option will switch the user callplan from one call plan ID to and other Callplan ID 1016 1016 The parameters are as follow : <br/> 1017 -- ID of the first callplan : called minutes needed to switch to the next CallplanID <br/>1018 -- ID of the second callplan : called minutes needed to switch to the next CallplanID <br/>1019 -- if not needed minutes are defined it will automatically switch to the next one <br/>1020 -- if defined we will sum the previous needed minutes and check if the caller had done at least the amount of calls necessary to go to the next step and have the amount of minutes needed<br/>1021 value example for callplan_deck_minute_threshold = 1: 5, 2:1, 3',1017 -- ID of the first callplan : called seconds needed to switch to the next CallplanID <br/> 1018 -- ID of the second callplan : called seconds needed to switch to the next CallplanID <br/> 1019 -- if not needed seconds are defined it will automatically switch to the next one <br/> 1020 -- if defined we will sum the previous needed seconds and check if the caller had done at least the amount of calls necessary to go to the next step and have the amount of seconds needed<br/> 1021 value example for callplan_deck_minute_threshold = 1:300, 2:60, 3', 1022 1022 '0', '11', NULL); 1023 1023
