Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions DataBase/mysql-5.x/UPDATE-a2billing-v2.1.4-to-v2.2.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,13 @@
*
**/





ALTER TABLE cc_callerid ADD COLUMN `id_didgroup` bigint(20) NOT NULL DEFAULT '-1'
ALTER TABLE cc_callerid DROP INDEX cons_cc_callerid_cid;
ALTER TABLE cc_callerid ADD UNIQUE INDEX cons_cc_callerid_cid ( `cid`,`id_didgroup` ) USING BTREE;

-- Update Version
UPDATE cc_version SET version = '2.2.0';
28 changes: 20 additions & 8 deletions admin/Public/form_data/FG_var_callerid.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ $HD_Form ->FG_LIST_ADDING_BUTTON_LINK2 = "A2B_entity_callerid.php?form_action=as
$HD_Form ->FG_LIST_ADDING_BUTTON_ALT2 = $HD_Form ->FG_LIST_ADDING_BUTTON_MSG2 = gettext("Add CallerID");
$HD_Form ->FG_LIST_ADDING_BUTTON_IMG2 = Images_Path ."/page_white_add.png" ;

$HD_Form -> FG_OTHER_BUTTON1 = true;
$HD_Form -> FG_OTHER_BUTTON1_IMG = Images_Path . '/info.png';
$HD_Form -> FG_OTHER_BUTTON1_LINK = "A2B_card_info.php?id=|col_orig2|";

$HD_Form -> FG_OTHER_BUTTON3 = true;
$HD_Form -> FG_OTHER_BUTTON3_LINK = "A2B_entity_logrefill.php?form_action=ask-add&card_id=|col_orig1|";
$HD_Form -> FG_OTHER_BUTTON3_LINK = "A2B_entity_logrefill.php?form_action=ask-add&card_id=|col_orig2|";
$HD_Form -> FG_OTHER_BUTTON3_IMG = Images_Path . "/brick_add.png";
$HD_Form -> FG_OTHER_BUTTON3_ALT = gettext('ADD REFILL');

Expand All @@ -53,12 +57,13 @@ $cnts = new Constants();
$actived_list = $cnts->getActivationTrueFalseList();
$yesno = $cnts->getYesNoList();

$HD_Form -> AddViewElement(gettext("CALLERID"), "cid", "20%", "center", "sort");
$HD_Form -> AddViewElement(gettext("CALLERID"), "cid", "15%", "center", "sort");
$HD_Form -> AddViewElement(gettext("DIDGROUP"), "id_didgroup", "15%", "center", "sort", "", "lie_link", "cc_didgroup", "didgroupname, id", "id='%id'", "%1", "", "A2B_entity_didgroup.php");
$HD_Form -> AddViewElement(gettext("ACCOUNT NUMBER"), "id_cc_card", "25%", "center", "sort", "", "lie_link", "cc_card", "username, id", "id='%id'", "%1", "", "A2B_entity_card.php");
$HD_Form -> AddViewElement(gettext("CUSTOMER NAME"), "id_cc_card", "25%", "center", "sort", "", "lie_link", "cc_card", "lastname, id, firstname", "id='%id'", "%1 %3", "", "A2B_entity_card.php");
$HD_Form -> AddViewElement(gettext("ACTIVATED"), "activated", "15%", "center", "sort", "", "list", $actived_list);
$HD_Form -> AddViewElement(gettext("ACTIVATED"), "activated", "10%", "center", "sort", "", "list", $actived_list);

$HD_Form -> FieldViewElement ('cid, id_cc_card, id_cc_card, cc_callerid.activated, cc_callerid.id');
$HD_Form -> FieldViewElement ('cid, id_didgroup, id_cc_card, id_cc_card, cc_callerid.activated, cc_callerid.id');


$HD_Form -> CV_NO_FIELDS = gettext("THERE IS NO ").strtoupper($HD_Form->FG_INSTANCE_NAME).gettext(" CREATED!");
Expand Down Expand Up @@ -102,8 +107,17 @@ $HD_Form -> AddEditElement (gettext("ID CARD"),
, ", 'CardNumberSelection','width=550,height=330,top=20,left=100,scrollbars=1'" ,
gettext("Define the card number ID to use."));

$HD_Form -> AddEditElement (gettext("DIDGROUP"),
"id_didgroup",
'$value',
"SELECT",
"", "", "",
"sql",
"cc_didgroup",
"didgroupname, id",
"", "", "%1","", "");

$HD_Form -> FieldEditElement ('cid, activated, id_cc_card');
$HD_Form -> FieldEditElement ('cid, activated, id_cc_card', 'id_didgroup');


// Set the filter variables
Expand All @@ -123,12 +137,10 @@ $HD_Form -> FG_INTRO_TEXT_ADD = gettext("you can add easily a new")." ".$HD_Form


$HD_Form -> FG_OTHER_BUTTON2 = true;
$HD_Form -> FG_OTHER_BUTTON2_LINK="A2B_entity_payment.php?stitle=Payment_add&form_action=ask-add&card_id=|col_orig1|";
$HD_Form -> FG_OTHER_BUTTON2_LINK="A2B_entity_payment.php?stitle=Payment_add&form_action=ask-add&card_id=|col_orig2|";
$HD_Form -> FG_OTHER_BUTTON2_IMG = Images_Path . "/money.png";
$HD_Form -> FG_OTHER_BUTTON2_ALT = gettext('ADD PAYMENT');



$HD_Form -> FG_INTRO_TEXT_ADITION = gettext("Add a ".$HD_Form->FG_INSTANCE_NAME." now.");
$HD_Form -> FG_TEXT_ADITION_CONFIRMATION = gettext("Your new")." ".$HD_Form->FG_INSTANCE_NAME." ".gettext("has been inserted.")."<br>";

Expand Down
55 changes: 55 additions & 0 deletions common/lib/Class.A2Billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class A2Billing
public $orig_dnid;
public $orig_ext;
public $extension;
public $dnid_obj=false;

// from apply_rules, if a prefix is removed we keep it to track exactly what the user introduce

Expand Down Expand Up @@ -2484,6 +2485,11 @@ public function callingcard_cid_sanitize($agi)
" FROM cc_callerid " .
" JOIN cc_card ON cc_callerid.id_cc_card = cc_card.id " .
" WHERE (cc_callerid.activated = 1 OR cc_callerid.activated = 't') AND cc_card.username = '" . $this->username . "' ";
// if dnid found in cc_did and we know group, set it as well
if ( $this->dnid_obj && isset($this->dnid_obj['id_cc_didgroup']) && $this->dnid_obj['id_cc_didgroup'] > 0 ) {
$QUERY .= " AND cc_didgroup = '" . $this->dnid_obj['id_cc_didgroup'] . "' ";
}

$QUERY .= "ORDER BY 1";
$result1 = $this->instance_table->SQLExec($this->DBHandle, $QUERY);
$this->debug(DEBUG, $agi, __FILE__, __LINE__, print_r($result1, true));
Expand Down Expand Up @@ -2642,6 +2648,20 @@ public function callingcard_ivr_authenticate($agi)
$language = 'en';
$callerID_enable = $this->agiconfig['cid_enable'];

// pick and store DNID data
if ($this->dnid_obj==false) {
$QUERY = 'SELECT * from cc_did WHERE did="'.$this->orig_dnid.'"';
file_put_contents('/tmp/a.log', print_r($QUERY,1), FILE_APPEND | LOCK_EX);
$result = $this->instance_table->SQLExec($this->DBHandle, $QUERY);
//if (is_array($result)) {
if (is_array($result) && count($result) == 1 && isset($result[0]) && is_array($result[0]) ) {
file_put_contents('/tmp/a.log', print_r($result,1), FILE_APPEND | LOCK_EX);
$this->dnid_obj=$result[0];
} else {
$this->dnid_obj=false;
}
}

// -%-%-%-%-%-%- FIRST TRY WITH THE CALLERID AUTHENTICATION -%-%-%-%-%-%-
if ($callerID_enable == 1 && is_numeric($this->CallerID) && $this->CallerID > 0) {

Expand All @@ -2659,6 +2679,9 @@ public function callingcard_ivr_authenticate($agi)
" LEFT JOIN cc_tariffgroup ON cc_card.tariff = cc_tariffgroup.id " .
" LEFT JOIN cc_country ON cc_card.country = cc_country.countrycode " .
" WHERE cc_callerid.cid = '" . $this->CallerID . "'";

if ( $this->dnid_obj && isset($this->dnid_obj['id_cc_didgroup']) && $this->dnid_obj['id_cc_didgroup'] > 0 )
$QUERY .= " AND ( cc_callerid.id_didgroup = '".$this->dnid_obj['id_cc_didgroup']."' OR cc_callerid.id_didgroup = -1 )";
$result = $this->instance_table->SQLExec($this->DBHandle, $QUERY);
$this->debug(DEBUG, $agi, __FILE__, __LINE__, print_r($result, true));

Expand Down Expand Up @@ -2712,6 +2735,12 @@ public function callingcard_ivr_authenticate($agi)
$QUERY_FIELS = 'cid, id_cc_card';
$QUERY_VALUES = "'" . $this->CallerID . "','$result'";

// if dnid found in cc_did and we know group, set it as well
if ( $this->dnid_obj && isset($this->dnid_obj['id_cc_didgroup']) && $this->dnid_obj['id_cc_didgroup'] > 0 ) {
$QUERY_FIELS .= ', id_didgroup';
$QUERY_VALUES .= ",'".$this->dnid_obj['id_cc_didgroup']."'";
}

$result = $this->instance_table->Add_table($this->DBHandle, $QUERY_VALUES, $QUERY_FIELS, 'cc_callerid');
if (!$result) {
$this->debug(ERROR, $agi, __FILE__, __LINE__, "[CALLERID CREATION ERROR TABLE cc_callerid]");
Expand Down Expand Up @@ -2913,6 +2942,12 @@ public function callingcard_ivr_authenticate($agi)
$QUERY = " SELECT cid, id_cc_card, activated FROM cc_callerid " .
" WHERE cc_callerid.cid = '" . $this->CallerID .
"' AND cc_callerid.id_cc_card = '" . $result[0][22] . "'";

// if dnid found in cc_did and we know group, set it as well
if ( $this->dnid_obj && isset($this->dnid_obj['id_cc_didgroup']) && $this->dnid_obj['id_cc_didgroup'] > 0 ) {
$QUERY .= " AND cc_didgroup = '" . $this->dnid_obj['id_cc_didgroup'] . "'";
}

$result_check_cid = $this->instance_table->SQLExec($this->DBHandle, $QUERY);
$this->debug(DEBUG, $agi, __FILE__, __LINE__, $result_check_cid);

Expand Down Expand Up @@ -3117,6 +3152,12 @@ public function callingcard_ivr_authenticate($agi)
$QUERY = " SELECT cid, id_cc_card, activated FROM cc_callerid " .
" WHERE cc_callerid.cid = '" . $this->CallerID .
"' AND cc_callerid.id_cc_card = '" . $result[0][23] . "'";

// if dnid found in cc_did and we know group, set it as well
if ( $this->dnid_obj && isset($this->dnid_obj['id_cc_didgroup']) && $this->dnid_obj['id_cc_didgroup'] > 0 ) {
$QUERY .= " AND cc_didgroup = '" . $this->dnid_obj['id_cc_didgroup'] . "'";
}

$result_check_cid = $this->instance_table->SQLExec($this->DBHandle, $QUERY);
$this->debug(DEBUG, $agi, __FILE__, __LINE__, print_r($result_check_cid, true));

Expand Down Expand Up @@ -3222,6 +3263,9 @@ public function callingcard_ivr_authenticate($agi)
if ($this->agiconfig['cid_enable'] == 1 && $this->agiconfig['cid_auto_assign_card_to_cid'] == 1 && is_numeric($this->CallerID) && $this->CallerID > 0 && $this->ask_other_cardnumber != 1 && $this->update_callerid != 1) {

$QUERY = "SELECT count(*) FROM cc_callerid WHERE id_cc_card = '$the_card_id'";
if ( $this->dnid_obj && isset($this->dnid_obj['id_cc_didgroup']) && $this->dnid_obj['id_cc_didgroup'] > 0 ) {
$QUERY .= " AND id_didgroup = '".$this->dnid_obj['id_cc_didgroup']."'";
}
$result = $this->instance_table->SQLExec($this->DBHandle, $QUERY, 1);

// CHECK IF THE AMOUNT OF CALLERID IS LESS THAN THE LIMIT
Expand All @@ -3230,6 +3274,12 @@ public function callingcard_ivr_authenticate($agi)
$QUERY_FIELS = 'cid, id_cc_card';
$QUERY_VALUES = "'" . $this->CallerID . "','$the_card_id'";

// if dnid found in cc_did and we know group, set it as well
if ( $this->dnid_obj && isset($this->dnid_obj['id_cc_didgroup']) && $this->dnid_obj['id_cc_didgroup'] > 0 ) {
$QUERY_FIELS .= ', id_didgroup';
$QUERY_VALUES .= ",'".$this->dnid_obj['id_cc_didgroup']."'";
}

$this->debug(DEBUG, $agi, __FILE__, __LINE__, "[CREATE AN INSTANCE IN CC_CALLERID - QUERY_VALUES:$QUERY_VALUES, QUERY_FIELS:$QUERY_FIELS]");
$result = $this->instance_table->Add_table($this->DBHandle, $QUERY_VALUES, $QUERY_FIELS, 'cc_callerid');

Expand All @@ -3250,6 +3300,11 @@ public function callingcard_ivr_authenticate($agi)
if ($this->update_callerid == 1 && strlen($this->CallerID) > 1 && $this->ask_other_cardnumber == 1) {
$this->ask_other_cardnumber = 0;
$QUERY = "UPDATE cc_callerid SET id_cc_card = '$the_card_id' WHERE cid = '" . $this->CallerID . "'";

if ( $this->dnid_obj && isset($this->dnid_obj['id_cc_didgroup']) && $this->dnid_obj['id_cc_didgroup'] > 0 ) {
$QUERY .= " AND id_didgroup='".$this->dnid_obj['id_cc_didgroup']."'";
}

$this->debug(DEBUG, $agi, __FILE__, __LINE__, "[QUERY UPDATE : $QUERY]");
$result = $this->instance_table->SQLExec($this->DBHandle, $QUERY, 0);
}
Expand Down