asterisk2billing.org
http://forum.asterisk2billing.org/

Card in use not being reset to 0
http://forum.asterisk2billing.org/viewtopic.php?f=34&t=8791
Page 1 of 2

Author:  vulcan [ Wed Apr 27, 2011 2:56 am ]
Post subject:  Card in use not being reset to 0

This is a long standing issue. I believe this is caused when SIP client dials and hangs up immediately before the call is answered. In this case the dial status is "CANCEL" but it bombs out on this code before it can process the CANCEL.

In two places @ lines 1166 and @ 1568 of Class.A2Billing.php

Change

Code:
         } elseif ($this->dialstatus == "NOANSWER") {


to

Code:
                } elseif ($dialstatus == "NOANSWER") {

Author:  sanjap [ Mon Jul 09, 2012 3:27 pm ]
Post subject:  Re: Card in use not being reset to 0

Vulcan,

What is the technical difference between $this->dialstatus and $dialstatus

Thanks,

Author:  vulcan [ Tue Jul 10, 2012 12:12 pm ]
Post subject:  Re: Card in use not being reset to 0

$this->dialstatus refers to a class global variable with full scope (which does not exist), $dialstatus in this case is a local variable defined in the function with limited scope.

These two patches found here include this fix.

viewtopic.php?f=34&t=9308

Author:  sanjap [ Fri Jul 13, 2012 7:18 pm ]
Post subject:  Re: Card in use not being reset to 0

Hi Vulcan,

Thanks. I am using prepaid only and customers still complain alot about "card in use" because 'In Use' value is not reset to 0. Any other help?

Author:  vulcan [ Sat Jul 14, 2012 10:13 am ]
Post subject:  Re: Card in use not being reset to 0

It is a general problem and the patch fixes it.

Author:  sanjap [ Sat Jul 14, 2012 7:27 pm ]
Post subject:  Re: Card in use not being reset to 0

I cannot download the patch files for some reason.

Author:  vulcan [ Sun Jul 15, 2012 5:11 am ]
Post subject:  Re: Card in use not being reset to 0

I can't download it either, maybe new forum restrictions , I don't know.

Author:  sanjap [ Mon Jul 16, 2012 3:23 pm ]
Post subject:  Re: Card in use not being reset to 0

Please how can i get this fix? I have customers who's car in use is not reset to 0 about 20 every day and they are getting frustrated? Please help !!!

Author:  jroper [ Tue Jul 17, 2012 8:48 am ]
Post subject:  Re: Card in use not being reset to 0

Hi

The fix is applied fot the next version - https://github.com/Star2Billing/a2billi ... 8aea69e3da

Joe

Author:  flatpack [ Wed Jul 18, 2012 6:40 pm ]
Post subject:  Re: Card in use not being reset to 0

joe, only this file need update?
https://github.com/Star2Billing/a2billi ... 8aea69e3da
what about second patch?

Author:  sanjap [ Fri Jul 20, 2012 7:45 pm ]
Post subject:  Re: Card in use not being reset to 0

Joe,

I updated the file Class.A2billing.php as stated in this file : https://github.com/Star2Billing/a2billi ... 8aea69e3da

But the issue persists. There must be another problem somewhere.

Thanks,

Sanjap

Author:  vulcan [ Sun Jul 22, 2012 12:55 am ]
Post subject:  Re: Card in use not being reset to 0

The changes that should be applied are incomplete in the git version Joe referenced. If you want to fix it, you need to apply the patch or do it manually. The second patch actually fixes an error in the first patch, so both patches must be executed in the order given.

Note: This patch addresses more than just the issue in question. The parts of the code pertaining to this specific issue are not fully implemented on git.

first patch

Code:
diff -B -u -r Star2Billing194orig/admin/Public/A2B_entity_friend.php Star2Billing194mod/admin/Public/A2B_entity_friend.php
--- Star2Billing194orig/admin/Public/A2B_entity_friend.php   2011-05-31 15:39:39.000000000 -0400
+++ Star2Billing194mod/admin/Public/A2B_entity_friend.php   2011-11-12 09:03:16.299767341 -0500
@@ -273,7 +273,7 @@
<b>&nbsp;<?php echo $HD_Form -> FG_NB_RECORD ?> <?php echo gettext("cards selected!"); ?>&nbsp;<?php echo gettext("Use the options below to batch update the selected cards.");?></b>
      <table align="center" border="0" width="65%"  cellspacing="1" cellpadding="2">
         <tbody>
-      <form name="updateForm" action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
+      <form name="updateForm" action="<?php echo $_SERVER['PHP_SELF'].'?atmenu='.$atmenu?>" method="post">
      <INPUT type="hidden" name="batchupdate" value="1">
      <tr>
           <td align="left" class="bgcolor_001" >
diff -B -u -r Star2Billing194orig/common/lib/Class.A2Billing.php Star2Billing194mod/common/lib/Class.A2Billing.php
--- Star2Billing194orig/common/lib/Class.A2Billing.php   2011-05-31 15:39:39.000000000 -0400
+++ Star2Billing194mod/common/lib/Class.A2Billing.php   2011-11-12 09:38:50.161765887 -0500
@@ -772,7 +772,7 @@
            return true;
         }
      } else {
-         if ($this->credit <= -$this->creditlimit) {
+         if (!($this->credit <= $this->creditlimit)) {
            $QUERY = "SELECT id_cc_package_offer FROM cc_tariffgroup WHERE id= ".$this->tariff ;
            $result = $this -> instance_table -> SQLExec ($this->DBHandle, $QUERY);
            if (!empty($result[0][0])) {
@@ -1163,7 +1163,7 @@
            if ($this->agiconfig['busy_timeout'] > 0)
               $res_busy = $agi->exec("Busy ".$this->agiconfig['busy_timeout']);
            $agi-> stream_file('prepaid-isbusy', '#');
-         } elseif ($this->dialstatus == "NOANSWER") {
+         } elseif ($dialstatus == "NOANSWER") {
            $answeredtime = 0;
            $agi-> stream_file('prepaid-noanswer', '#');
         } elseif ($dialstatus == "CANCEL") {
@@ -1318,7 +1318,7 @@
                     continue;
               } elseif ($dialstatus == "CANCEL") {
                  // Call cancelled, no need to follow-me
-                  return 1;
+                  $answeredtime = 0;
               } elseif ($dialstatus == "ANSWER") {
                  $this -> debug( DEBUG, $agi, __FILE__, __LINE__,
                              "[A2Billing] DID call friend: dialstatus : $dialstatus, answered time is ".$answeredtime." \n");
@@ -1459,10 +1459,10 @@
               }
                 }
             } else {
-            if ($this->credit <= -$this->creditlimit) {
+            if (!($this->credit <= $this->creditlimit)) {
               $time2call =0;
            } else {
-               $credit_without_charge = $this->credit + abs($this->creditlimit) - abs($connection_charge);
+               $credit_without_charge = $this->credit - abs($connection_charge);
               if ($credit_without_charge>0 && $selling_rate!=0 ) {
                  $time2call = intval($credit_without_charge / abs($selling_rate))*60;
               } else {
@@ -1523,7 +1523,7 @@
                     // Dial(IAX2/[email protected]/s@default)
                     $myres = $this -> run_dial($agi, $dialstr);
                     $this -> debug( INFO, $agi, __FILE__, __LINE__, "DIAL $dialstr");
-                } else {
+                } elseif ( $time2call > 0) {    // prevent 0 time to call on follow me               
                     
                     $this -> debug( INFO, $agi, __FILE__, __LINE__, "TIME TO CALL : $time2call");
                     $this -> fct_say_time_2_call($agi,$time2call,$selling_rate);
@@ -1543,6 +1543,8 @@
                         $myres = $agi->exec("StopMixMonitor");
                         $this -> debug( INFO, $agi, __FILE__, __LINE__, "EXEC StopMixMonitor (".$this->uniqueid.")");
                     }
+                } else {
+                    continue;
                 }

                 $answeredtime    = $agi->get_variable("ANSWEREDTIME");
@@ -1565,14 +1567,14 @@
               $agi-> stream_file('prepaid-isbusy', '#');
               if (count($listdestination)>$callcount)
                  continue;
-                } elseif ($this->dialstatus == "NOANSWER") {
+                } elseif ($dialstatus == "NOANSWER") {
               $answeredtime = 0;
               $agi-> stream_file('prepaid-callfollowme', '#');
               if (count($listdestination) > $callcount)
                  continue;
                 } elseif ($dialstatus == "CANCEL") {
               // Call cancelled, no need to follow-me
-               return 1;
+               $answeredtime = 0;
                 } elseif ($dialstatus == "ANSWER") {
               $this -> debug( DEBUG, $agi, __FILE__, __LINE__,
                           "[A2Billing] DID call friend: dialstatus : $dialstatus, answered time is ".$answeredtime." \n");
diff -B -u -r Star2Billing194orig/customer/form_data/FG_var_signup.inc Star2Billing194mod/customer/form_data/FG_var_signup.inc
--- Star2Billing194orig/customer/form_data/FG_var_signup.inc   2011-05-31 15:39:39.000000000 -0400
+++ Star2Billing194mod/customer/form_data/FG_var_signup.inc   2011-11-12 08:46:27.354704491 -0500
@@ -152,16 +152,32 @@

$language_list = Constants::getLanguagesList();
if (LANGUAGE_ENABLE)  {
-$HD_Form->AddEditElement(gettext("LANGUAGE"), "language", "", "SELECT", "", "", "", "list", "", "", "", $language_list, "%1", "", "");
-$language_editFG = "language,";
+
+    $languageSelect = '';
+    if (!empty($_POST['language'])) {
+        $languageSelect = $_POST['language'];
+    }
+    $HD_Form->AddEditElement(gettext("LANGUAGE"), "language", "$languageSelect", "SELECT", "", "", "", "list", "", "", "", $language_list, "%1", "", "");
+    $language_editFG = "language,";
}
if (CURRENCY_ENABLE)  {
-$HD_Form->AddEditElement("CURRENCY", "currency", "", "SELECT", "", "", "", "list", "", "", "", $currency_list, "%1", "", "");
-$currency_editFG = "currency,";
+
+    $currencySelect = '';
+    if (!empty($_POST['currency'])) {
+        $currencySelect = $_POST['currency'];
+    }
+
+    $HD_Form->AddEditElement("CURRENCY", "currency", "$currencySelect", "SELECT", "", "", "", "list", "", "", "", $currency_list, "%1", "", "");
+    $currency_editFG = "currency,";
}
if (!$agent_conf && strpos($callPlan_idlist, ',') !== false && !($subscriber_signup>0)) {
-   $HD_Form->AddEditElement(gettext("CALL PLAN"), "tariff", "", "SELECT", "", "", "", "list", "", "", "", $callPlan_list, "%1", "", "");
+    $callPlanSelect = '';
+    if (!empty($_POST['tariff'])) {
+        $callPlanSelect = $_POST['tariff'];
+    }
+   $HD_Form->AddEditElement(gettext("CALL PLAN"), "tariff", "$callPlanSelect", "SELECT", "", "", "", "list", "", "", "", $callPlan_list, "%1", "", "");
}
+
$comp_zero = $comp_date_plus = '';
if (isset ($form_action) && $form_action == "ask-add") {
   $begin_date = date("Y");
@@ -226,6 +242,9 @@
   $country_default_val = 'USA';
}
if (COUNTRY_ENABLE)  {
+    if (!empty($_POST['country'])) {
+        $country_default_val = $_POST['country'];
+    }
$HD_Form->AddEditElement(gettext("COUNTRY"),
               "country",
               "$country_default_val",
@@ -254,6 +273,9 @@
   }
}
if (TIMEZONE_ENABLE)  {
+    if (is_numeric($_POST['id_timezone'])) {
+        $timezone_default_val = $_POST['id_timezone'];
+    }
$HD_Form->AddEditElement(gettext("TIMEZONE"),
                        "id_timezone",
                        "$timezone_default_val",





second patch

Code:
diff -B -u -r Star2Billing194mod/common/lib/Class.A2Billing.php Star2Billing194mod2/common/lib/Class.A2Billing.php
--- Star2Billing194mod/common/lib/Class.A2Billing.php   2011-11-12 09:38:50.161765887 -0500
+++ Star2Billing194mod2/common/lib/Class.A2Billing.php   2012-01-24 01:21:17.095488158 -0500
@@ -766,13 +766,13 @@
   function enough_credit_to_call()
   {   
      if ($this->typepaid == 0) {
-         if ($this->credit < $this->agiconfig['min_credit_2call'] || $this->credit < 0 ) {
+         if ($this->credit < $this->agiconfig['min_credit_2call'] || $this->credit <= 0 ) {
            return false;
         } else {
            return true;
         }
      } else {
-         if (!($this->credit <= $this->creditlimit)) {
+         if ($this->credit <= 0) {
            $QUERY = "SELECT id_cc_package_offer FROM cc_tariffgroup WHERE id= ".$this->tariff ;
            $result = $this -> instance_table -> SQLExec ($this->DBHandle, $QUERY);
            if (!empty($result[0][0])) {
@@ -1459,7 +1459,7 @@
               }
                 }
             } else {
-            if (!($this->credit <= $this->creditlimit)) {
+            if ($this->credit <= 0) {
               $time2call =0;
            } else {
               $credit_without_charge = $this->credit - abs($connection_charge);

Author:  flatpack [ Mon Jul 23, 2012 12:49 pm ]
Post subject:  Re: Card in use not being reset to 0

First Patch error
Code:
@@ -1543,6 +1543,8 @@
                         $myres = $agi->exec("StopMixMonitor");
                         $this -> debug( INFO, $agi, __FILE__, __LINE__, "EXEC StopMixMonitor (".$this->uniqueid.")");
                     }
+                } else {
+                    continue;
                 }

                 $answeredtime    = $agi->get_variable("ANSWEREDTIME");

original code and you can see there isnt } else {
Code:
$myres = $agi->exec("StopMixMonitor");
                        $this -> debug( INFO, $agi, __FILE__, __LINE__, "EXEC StopMixMonitor (".$this->uniqueid.")");
                    }
                }

                $answeredtime    = $agi->get_variable("ANSWEREDTIME");
                $answeredtime    = $answeredtime['data'];

Author:  vulcan [ Mon Jul 23, 2012 3:19 pm ]
Post subject:  Re: Card in use not being reset to 0

It is intentional. The "else" would probably never ever get executed if the entire patch is applied.

the released version of 1.9.4 will allow a prepaid call to progress if the balance is exactly zero. It ultimately fails, but gives for confusing behavior. Three sections of the patch address this problem. The first is probably all that is necessary, though.

Code:
-         if ($this->credit < $this->agiconfig['min_credit_2call'] || $this->credit < 0 ) {
+         if ($this->credit < $this->agiconfig['min_credit_2call'] || $this->credit <= 0 ) {
.
.
-                } else {
+                } elseif ( $time2call > 0) {    // prevent 0 time to call on follow me
.
.
   +                } else {
+                    continue;
           


That "else" was put there to help debug the problem but is harmless. If both patches are applied it can be removed.

FYI: I've since found (by me and others) a few other typos in the code that should be fixed for the next release. I would post a cumulative patch for perusal, but not sure if it's ok to do so since uploading seems to have been disabled.

Author:  flatpack [ Mon Jul 23, 2012 4:16 pm ]
Post subject:  Re: Card in use not being reset to 0

vulcan
thanks for your prompt reply, not sure why file sharing is blocked? but we can share code within each post as i don’t see any problem with that.

Page 1 of 2 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/