Support A2Billing :

provided by Star2Billing S.L.

Support A2Billing :
It is currently Thu Mar 28, 2024 11:25 am
Voice Broadcast System


All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Again one solution for LCR issue, please check my results
PostPosted: Thu Sep 23, 2010 1:10 pm 
Offline

Joined: Fri Jul 11, 2008 6:54 pm
Posts: 39
Location: Armenia, Yerevan
Hello

I think I have find solution, a2b version 1.7.1.
First, I think we must not working on the trunk selection, we must look the ratecard (tariffplan) that included in Call Plan.
So, first I delete (or mark with //) this section:
Code:
//1) REMOVE THOSE THAT HAVE A SMALLER DIALPREFIX
      //$max_len_prefix = strlen($result[0][7]);
      //for ($i=1;$i<count($result);$i++) {
      //   if ( strlen($result[$i][7]) < $max_len_prefix) break;
      //}
      //$result = array_slice ($result, 0, $i);


After I have added the next code beetwen 1) and 2)
Code:
      //4) REMOVE THOSE THAT HAVE A SAME RATECARD ID
      $myresult = array();
      $myresult = $result;
      $mysearchvalue = array();
      
      if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: MYRESULT before sort \n".print_r($myresult, true));
      // Sorting  - 3 - tariff plan, 5 - dialprefix
      $myresult = $this -> array_csort($myresult,'3',SORT_NUMERIC,'5',SORT_NUMERIC,SORT_DESC);

      if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: MYRESULT  after sort \n".print_r($myresult, true));      
      
      $countdelete = 1;
      $resultcount = 0;

      for ($ii=0;$ii<count($result)-1;$ii++)
      {

         if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: Begin for II value ".$ii."]");

         $mysearchvalue[$resultcount] = $myresult[0];
         if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: MYSEARCHCVALUE".print_r($mysearchvalue,true)."]");
         
         if (count($myresult)>0){
         
             foreach($myresult as $j=>$i){
            if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: foreach J:".print_r($j, true));
            if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine:mysearchvalue[3]:".$mysearchvalue[$resultcount][3]);
            if ($mysearchvalue[$resultcount][3] == $i[3]) {
               unset($myresult[$j]);
               $countdelete = $countdelete+1;
               if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: COUNTDELETE: ".$countdelete."]");
            }
             }
      
             $myresult = array_values($myresult);
             if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: Count MYRESULT after foreach".count($myresult)."]");
             $resultcount++;
         }
         if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: End for II value ".$ii."]");
      }
      
      unset($mysearchvalue[$resultcount]);
      $mysearchvalue = array_values($mysearchvalue);
      unset($myresult);
      
      if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: RESULTCOUNT".$resultcount."]");
      if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: MYRESULT  after delete \n".print_r($myresult, true));
      if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: MYSEARCHVALUE after delete \n".print_r($mysearchvalue, true));
      
      if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: Count Total result after 4 ".count($myresult)."]");
      
      $result=$mysearchvalue;
      
      unset($mysearchvalue);
      if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: RESULT  after delete \n".print_r($result, true));


I have do the next algoritm:
I have 4 provider with different dial preffix and price.
Each provider(vendor) have self ratecard and trunk.
P1, P2, P3, P4
We are calling to 79055555658

in RateEngine after RateEnginere do SELECT is the following data:
RateCard ID Provayder DialPrefix BuyRate
1 P1 79055 0.04644
4 P2 7905 0.0598
3 P3 7905 0.06487
2 P4 7905 0.06487
1 P1 7905 0.0486
3 P3 790 0.03825
2 P4 790 0.03825
1 P1 790 0.0378
4 P2 79 0.0365
1 P1 79 0.0378
4 P2 7 0.023
3 P3 7 0.0461
2 P4 7 0.0508
1 P1 7 0.0108

I do the following sort:
Sort by field RateCardID ASC and dialprefix DESC
And after all we became this table:
RateCard ID Provayder DialPrefix BuyRate
1 P1 79055 0.04644
2 P4 7905 0.06487
3 P3 7905 0.06487
4 P2 7905 0.0598

and after work this code:
//2) TAKE THE VALUE OF LCTYPE

we became the next

RateCard ID Provayder DialPrefix BuyRate
1 P1 79055 0.04644
4 P2 7905 0.0598
2 P4 7905 0.06487
3 P3 7905 0.06487

So, it all.
Now this code is working in my production server and all is working fine.

Please test :)

Thanks


Top
 Profile  
 
 Post subject: Re: Again one solution for LCR issue, please check my results
PostPosted: Wed Oct 13, 2010 10:58 am 
Offline

Joined: Fri Jul 11, 2008 6:54 pm
Posts: 39
Location: Armenia, Yerevan
Some bugfixing
Code:
      //4) REMOVE THOSE THAT HAVE A SAME RATECARD ID
      $myresult = array();
      $myresult = $result;
      $mysearchvalue = array();
      
      if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: MYRESULT before sort \n".print_r($myresult, true));
      // 3 - tariff plan, 5 - dialprefix
      $myresult = $this -> array_csort($myresult,'3',SORT_NUMERIC,'5',SORT_NUMERIC,SORT_DESC);



      if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: MYRESULT  after sort \n".print_r($myresult, true));
      
      
      $countdelete = 0;
      $resultcount = 0;
      
      
      $mysearchvalue[$resultcount] = $myresult[0];
      
      for ($ii=0;$ii<count($result)-1;$ii++){
      
         $mysearchvalue[$resultcount] = $myresult[$ii];
         
         if ($this->webui) {
            $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: Begin for ii value ".$ii."]");
            $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: MYSEARCHCVALUE \n".print_r($mysearchvalue,true)."]");
         };
         
         if (count($myresult)>0){
         
             foreach($myresult as $j=>$i){
               if ($this->webui) {
                $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: foreach J=".print_r($j, true));
                $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine:mysearchvalue[4]=".$mysearchvalue[$resultcount][4]);
                $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine:i[4]=".$i[4]);
                $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine:mysearchvalue[3]=".$mysearchvalue[$resultcount][3]);
                $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine:i[3]=".$i[3]);
                $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine:mysearchvalue[7]=".$mysearchvalue[$resultcount][7]);
                $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine:i[7]=".$i[7]);
               };
               
               if ($mysearchvalue[$resultcount][3] == $i[3] ) {
                  if (strlen($mysearchvalue[$resultcount][7]) != strlen($i[7])) {
                   unset($myresult[$j]);
                   $countdelete = $countdelete+1;
                   if ($this->webui) {
                    $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: foreach: COUNTDELETE: ".$countdelete."]");
                    $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: foreach: MYRESULT count after delete: ".count($myresult)."]");
                   };
                  };
               }
             } //end foreach
      
             $myresult = array_values($myresult);
            $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: MYRESULT  after foreach \n".print_r($myresult, true));
            $resultcount++;
             if ($this->webui) {
             $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: Count MYRESULT after foreach=".count($myresult)."]");
             $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: RESULTCOUNT=".$resultcount."]");
            };
            
         }
         if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: End for II value ".$ii."]");
      }  //end for
      
      if ($this->webui) {
         $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: COUNTDELETE=".$countdelete."]");
         $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: MYRESULT  before unset \n".print_r($myresult, true));
      };
      
      if (count($result)>1 and $countdelete != 0) {
         if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: LAST UNSET");
         unset($mysearchvalue[$resultcount]);
         foreach ($mysearchvalue as $key => $value) {
            if (is_null($value) or $value == "") {
               unset($mysearchvalue[$key]);
            }
         }    
         $mysearchvalue = array_values($mysearchvalue);
         unset($myresult);
      };
      
      if ($this->webui) {
         $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: RESULTCOUNT".$resultcount."]");
         $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: MYRESULT  after delete \n".print_r($myresult, true));
         $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: MYSEARCHVALUE after delete \n".print_r($mysearchvalue, true));
         $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: Count Total result after 4 ".count($myresult)."]");
      };

      
      if (count($result)>1 and $countdelete != 0) {
         $result=$mysearchvalue;
      };
      
      unset($mysearchvalue);
      if ($this->webui) $A2B -> debug( DEBUG, $agi, __FILE__, __LINE__, "[rate-engine: RESULT  after delete \n".print_r($result, true));


Top
 Profile  
 
 Post subject: Re: Again one solution for LCR issue, please check my results
PostPosted: Tue Apr 19, 2011 8:28 am 
Offline

Joined: Sat Feb 19, 2011 6:19 am
Posts: 38
Dear varnar
is it possible to implement this code to a2billing 1.9.3
in which files or files do i need to do this modification

Your
Huseyin


Top
 Profile  
 
 Post subject: Re: Again one solution for LCR issue, please check my results
PostPosted: Tue Jun 28, 2011 1:23 am 
Offline

Joined: Thu Mar 19, 2009 5:14 pm
Posts: 1
Hello
About 1.9 I don't know. But the file where I have make changes is a Class.RateEngine.php in /var/lib/asterisk/agi-bin/ in lib for A2B

Best regards,

Vardan


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 
Hosted Voice Broadcast


All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group