Home Forums EN Repairs Numbers Activation Reply To: Numbers Activation

Nishit Shan
Participant
Post count: 376

Hello All,

Here is my code.

public function ActivateRecentPurchaseNumber(){
$customer_id = getClass(‘ISC_CUSTOMER’)->getcustomerId();
$product_id = $_POST[‘productid’];
$order_id = $_POST[‘orderid’];
$status = $_POST[‘status’];

$query1 = “SELECT * FROM [|PREFIX|]customers where customerid=” . $customer_id;
$result1 = $GLOBALS[‘ISC_CLASS_DB’]->Query($query1);
$customer = $GLOBALS[‘ISC_CLASS_DB’]->Fetch($result1);

$query2 = “SELECT * FROM [|PREFIX|]order_pin where product_id=$product_id AND order_id=$order_id”;
$result2 = $GLOBALS[‘ISC_CLASS_DB’]->Query($query2);
$pin = $GLOBALS[‘ISC_CLASS_DB’]->Fetch($result2);

$query3 = “SELECT o.*,p.prodcarrier,p.prodpin,p.productid, p.prodname, p.prodpreorder, p.prodreleasedate, p.prodpreordermessage
FROM [|PREFIX|]order_products o
LEFT JOIN [|PREFIX|]products p ON (p.productid=o.ordprodid)
WHERE orderorderid=” . $pin[‘order_id’] . ” AND (ordprodid=” . $pin[‘product_id’] . ” OR orderprodid=” . $pin[‘product_id’] . “)
ORDER BY orderorderid”;
$result3 = $GLOBALS[‘ISC_CLASS_DB’]->Query($query3);
$product = $GLOBALS[‘ISC_CLASS_DB’]->Fetch($result3);

$query4 = sprintf(“SELECT * FROM [|PREFIX|]orders WHERE orderid=%d ORDER BY orderid DESC”, $order_id);
$result4 = $GLOBALS[‘ISC_CLASS_DB’]->Query($query4);
$order = $GLOBALS[‘ISC_CLASS_DB’]->Fetch($result4);

// $updateData1 = array(
// “ordcustmessage” => ”,
// );

// $update_comment = $GLOBALS[‘ISC_CLASS_DB’]->UpdateQuery(“orders”, $updateData1, “orderid=” . (int) $order[‘orderid’]);

// $updateData = array(
// “prodmanualactivate” => 0,
// );

// $update_status = $GLOBALS[‘ISC_CLASS_DB’]->UpdateQuery(“order_products”, $updateData, “orderprodid=” . (int) $product[‘orderprodid’]);

// echo ‘Update:-‘;
// print_r($update_comment);
// print_r($update_status);
// exit;

$testid = preg_replace(“/\(|\)|-| /”, “”, $_POST[‘order_number’]);
$result=”;
$keypad = array(
‘a’ => ‘2’, ‘b’ => ‘2’, ‘c’ => ‘2’, ‘d’ => ‘3’,
‘e’ => ‘3’, ‘f’ => ‘3’, ‘g’ => ‘4’, ‘h’ => ‘4’,
‘i’ => ‘4’, ‘j’ => ‘5’, ‘k’ => ‘5’, ‘l’ => ‘5’,
‘m’ => ‘6’, ‘n’ => ‘6’, ‘o’ => ‘6’, ‘p’ => ‘7’,
‘q’ => ‘7’, ‘r’ => ‘7’, ‘s’ => ‘7’, ‘t’ => ‘8’,
‘u’ => ‘8’, ‘v’ => ‘8’, ‘w’ => ‘9’, ‘x’ => ‘9’,
‘y’ => ‘9’, ‘z’ => ‘9’);

for ($x=0; $x GetConfig(‘TelintaUserName’),
‘password’ => GetConfig(‘TelintaPassword’)
);
$verify_hostname = false;
$wsdl_base = “https://$api_hostname/wsdl”;

try {
# login
$soap = new SoapClient($wsdl_base . ‘/SessionAdminService.wsdl’);
$session_id = $soap->login($params)->session_id;
// echo “Started session $session_id\n”;

$soap = new SoapClient($wsdl_base . ‘/AccountAdminService.wsdl’);
$soap_did = new SoapClient($wsdl_base . ‘/DIDAdminService.wsdl’);
$soap_customer = new SoapClient($wsdl_base . ‘/CustomerAdminService.wsdl’);

$auth = new stdClass();
$auth->session_id = $session_id;
$auth_header = new SoapHeader(‘ns1’, ‘auth_info’, $auth);
$soap->__setSoapHeaders($auth_header);
$soap_did->__setSoapHeaders($auth_header);
$soap_customer->__setSoapHeaders($auth_header);

$params = array(
‘id’ => ‘1’ . $Accountid,
);

// $AccountInfoReply = $soap->get_account_info($params);
// $active_number = $AccountInfoReply->account_info->is_active;
$customer_unid = $customer[‘custguid’];

$did_param = array(
‘number’ => ‘1’ . $Accountid,
// ‘number’ => ‘19999999999’,
);
$DIDCustomerNumber = $soap_did->get_number_info($did_param);
$i_did_number = $DIDCustomerNumber->number_info->i_did_number;

// $Customer_id = array(
// ‘i_customer’ => ‘277058’,
// );
// $customer_info = $soap_customer->get_customer_info($Customer_id);

echo ‘

'; print_r($DIDCustomerNumber); exit;
            // echo '
'; print_r($DIDCustomerNumber); exit;
            // $customer_assign = array(
            //     'i_customer' => $customer['custguid'],
            //     'i_did_number' => $i_did_number
            // );

            // $AssignToCustomer = $soap_did->assign_did_to_customer($customer_assign);

            // $vendor_batch_list = $soap_did->get_number_list();
        
            // $Status = $DIDCustomerNumber->number_info->frozen;
            // $i_customer_DID = $DIDCustomerNumber->number_info->i_customer;

            // echo '
'; print_r($vendor_batch_list); exit;
            
            require_once ISC_BASE_PATH . "/lib/email.php";
            $store_name     = GetConfig('StoreName');
            $emailTemplate  = FetchEmailTemplateParser();
            $allEmails      = array();
            
            $GLOBALS['Cust_FirstName'] = $customer['custconfirstname'].' '.$customer['custconlastname'];
            $GLOBALS['Cust_Email'] = $customer['custconemail'];
            $GLOBALS['Cust_number'] = $product['ordprodname'];
            $GLOBALS['customerIp'] = $_SERVER['REMOTE_ADDR'];
            $customer_unid = $customer['custguid'];
            
            $customer_email         = trim($customer['custconemail']);
            $allEmails[]            = $customer_email;
            $numberID               = '1' . $Accountid;

            $did_param = array(
                'number' => '1' . $Accountid,
            );
        
            try {
                $DIDCustomerNumber = $soap_did->get_number_info($did_param);
            }catch(Exception $e) {
                // echo 'Message: ' .$e->getMessage();
                // exit;
            }
            if (!empty($DIDCustomerNumber)){
                // echo '
'; print_r($DIDCustomerNumber); exit;
        
                $Status = $DIDCustomerNumber->number_info->frozen;
                $i_customer_DID = $DIDCustomerNumber->number_info->i_customer;
                $i_did_number = $DIDCustomerNumber->number_info->i_did_number;

                if(($Status == 'N' && $i_customer_DID == '') || ($Status == 'Y')){

                    try{
                        $Customer_id = array(
                            'i_customer' => $customer_unid,
                        );
                        $customer_info = $soap_customer->get_customer_info($Customer_id);
                    }catch(Exception $e) {
                        // echo 'Message: ' .$e->getMessage();
                    }

                    if(!empty($customer_info)){
                        $customer_assign = array(
                            'i_customer' => $customer['custguid'],
                            'i_did_number' => $i_did_number
                        );
            
                        $AssignToCustomer = $soap_did->assign_did_to_customer($customer_assign);
                        
                        if($AssignToCustomer->success == 1){
                            $account_params = array(
                                "account_info" => array(
                                    "id" => '1' . $Accountid,
                                    "billing_model" => 1,
                                    "i_customer" => $customer_unid,
                                    "iso_4217" => "USD",
                                    "activation_date" => date("Y-m-d"),
                                    'i_product' => '28337',
                                    "h323_password" => "excellentnumbers",
                                ),
                                "generate_web_password" => 1,
                            );

                            try{

                                $account_validation = $soap->validate_account_info($account_params);
                            }catch(Exception $e){
                                // echo 'Message: ' .$e->getMessage();
                                // exit;
                            }
                            // echo '
'; print_r($account_validation);

                            try {
                                $AddNewAccount = $soap->add_account($account_params);
                                $AccountInfoReply = $soap->get_account_info($params);
                            }catch(Exception $e){
                                // echo 'Message: ' .$e->getMessage();
                                // exit;
                            }

                            // echo '
'; print_r($AccountInfoReply); exit;
                            if (!empty($AccountInfoReply) && !empty($account_validation)){
                                $i_customer  = $AccountInfoReply->account_info->i_customer;

                                if($i_customer == $customer_unid){

                                    $updateData = array(
                                        "port_out_status" => $status,
                                        "port_out_date" => date('Y-m-d H:i:s'),
                                    );

                                    // $update_status = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_pin", $updateData, "id=" . (int) $pin['id']);

                                    // if ($product['flag_activation_date_per_product'] == 1) {
                                    //     $date = date('Y-m-d H:i:s');
                                    //     $queryupdate = "UPDATE [|PREFIX|]order_products SET activation_date='" . $date . "' WHERE orderorderid ='" . $product['orderorderid'] . "' AND orderprodid='" . $product['orderprodid'] . "'";
                                    //     $rs = $GLOBALS['ISC_CLASS_DB']->Query($queryupdate);
                                    // }

                                    if($update_status == 1){
                                        $subject = "Activation status: Successful";
                                        $emailTemplate->SetTemplate("activate_recent_purchase_number_success");
                                    }  else{
                                        $subject = "Activation status: Unsuccessful";
                                        $emailTemplate->SetTemplate("activate_recent_purchase_number_error");
                                    }
                                    $GLOBALS['Error_msg']       = "This phone number is not activate Successfully...";

                                    //send Email to the Admin
                                    $sendTo                     = @implode(", ", $allEmails);
                                    $GLOBALS['firstname']       = $customer['custconfirstname'];
                                    $GLOBALS['admin_message']   = "
Notifications sent to: " . $sendTo . "
"; $admin_message = $emailTemplate->ParseTemplate(true); $obj_email_admin = GetEmailClass(); $obj_email_admin->Set('CharSet', GetConfig('CharacterSet')); $obj_email_admin->From(GetConfig('OrderEmail'), $store_name); $obj_email_admin->Set("Subject", $subject); $obj_email_admin->AddBody("html", $admin_message); // $obj_email_admin->AddRecipient("excellentnumbers@gmail.com", "", "h"); // $obj_email_admin->AddRecipient("orders@excellentnumbers.com", "", "h"); // $obj_email_admin->AddRecipient("excellentnumberstest@yopmail.com", "", "h"); $obj_email_admin->AddRecipient("developer5@webmaklay.com", "", "h"); $email_result_admin = $obj_email_admin->Send(); $status = array( 'number' => $product['ordprodname'], 'status' => 1, ); echo json_encode($status); exit(); }else{ $subject = "Activation status: Unsuccessful"; $emailTemplate->SetTemplate("activate_recent_purchase_number_error"); $GLOBALS['Error_msg'] = $product['ordprodname']." phone number is already assign to other client in the Telinta’s pool."; //send Email to the Admin $sendTo = @implode(", ", $allEmails); $GLOBALS['firstname'] = $customer['custconfirstname']; $GLOBALS['admin_message'] = "
Notifications sent to: " . $sendTo . "
"; $admin_message = $emailTemplate->ParseTemplate(true); $obj_email_admin = GetEmailClass(); $obj_email_admin->Set('CharSet', GetConfig('CharacterSet')); $obj_email_admin->From(GetConfig('OrderEmail'), $store_name); $obj_email_admin->Set("Subject", $subject); $obj_email_admin->AddBody("html", $admin_message); // $obj_email_admin->AddRecipient("excellentnumbers@gmail.com", "", "h"); // $obj_email_admin->AddRecipient("orders@excellentnumbers.com", "", "h"); // $obj_email_admin->AddRecipient("excellentnumberstest@yopmail.com", "", "h"); $obj_email_admin->AddRecipient("developer5@webmaklay.com", "", "h"); $email_result_admin = $obj_email_admin->Send(); $date = new DateTime("now", new DateTimeZone('America/New_York') ); $Eastern_Time_zone = $date->format('Y-m-d H:i:s'); $updateData1 = array( "ordcustmessage" => $Eastern_Time_zone, ); // $update_comment = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $updateData1, "orderid=" . (int) $order['orderid']); $updateData = array( "prodmanualactivate" => 1, ); // $update_status = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_products", $updateData, "orderprodid=" . (int) $product['orderprodid']); $status = array( 'number' => $product['ordprodname'], 'status' => 2 ); echo json_encode($status); exit(); } }else{ $subject = "Activation status: Unsuccessful"; $emailTemplate->SetTemplate("activate_recent_purchase_number_error"); $GLOBALS['Error_msg'] = "DID number ".$numberID." cannot be used as an Account ID because it cannot be assigned to a Customer Error adding account with ID: ".$numberID; //send Email to the Admin $sendTo = @implode(", ", $allEmails); $GLOBALS['firstname'] = $customer['custconfirstname']; $GLOBALS['admin_message'] = "
Notifications sent to: " . $sendTo . "
"; $admin_message = $emailTemplate->ParseTemplate(true); $obj_email_admin = GetEmailClass(); $obj_email_admin->Set('CharSet', GetConfig('CharacterSet')); $obj_email_admin->From(GetConfig('OrderEmail'), $store_name); $obj_email_admin->Set("Subject", $subject); $obj_email_admin->AddBody("html", $admin_message); // $obj_email_admin->AddRecipient("excellentnumbers@gmail.com", "", "h"); // $obj_email_admin->AddRecipient("orders@excellentnumbers.com", "", "h"); // $obj_email_admin->AddRecipient("excellentnumberstest@yopmail.com", "", "h"); $obj_email_admin->AddRecipient("developer5@webmaklay.com", "", "h"); $email_result_admin = $obj_email_admin->Send(); $date = new DateTime("now", new DateTimeZone('America/New_York') ); $Eastern_Time_zone = $date->format('Y-m-d H:i:s'); $updateData1 = array( "ordcustmessage" => $Eastern_Time_zone, ); // $update_comment = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $updateData1, "orderid=" . (int) $order['orderid']); $updateData = array( "prodmanualactivate" => 1, ); // $update_status = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_products", $updateData, "orderprodid=" . (int) $product['orderprodid']); $status = array( 'number' => $product['ordprodname'], 'status' => 3 ); echo json_encode($status); exit(); } }else{ $subject = "Activation status: Unsuccessful"; $emailTemplate->SetTemplate("activate_recent_purchase_number_error"); $GLOBALS['Error_msg'] = "TN is already assign to other customer"; //send Email to the Admin $sendTo = @implode(", ", $allEmails); $GLOBALS['firstname'] = $customer['custconfirstname']; $GLOBALS['admin_message'] = "
Notifications sent to: " . $sendTo . "
"; $admin_message = $emailTemplate->ParseTemplate(true); $obj_email_admin = GetEmailClass(); $obj_email_admin->Set('CharSet', GetConfig('CharacterSet')); $obj_email_admin->From(GetConfig('OrderEmail'), $store_name); $obj_email_admin->Set("Subject", $subject); $obj_email_admin->AddBody("html", $admin_message); // $obj_email_admin->AddRecipient("excellentnumbers@gmail.com", "", "h"); // $obj_email_admin->AddRecipient("orders@excellentnumbers.com", "", "h"); // $obj_email_admin->AddRecipient("excellentnumberstest@yopmail.com", "", "h"); $obj_email_admin->AddRecipient("developer5@webmaklay.com", "", "h"); $email_result_admin = $obj_email_admin->Send(); $date = new DateTime("now", new DateTimeZone('America/New_York') ); $Eastern_Time_zone = $date->format('Y-m-d H:i:s'); $updateData1 = array( "ordcustmessage" => $Eastern_Time_zone, ); // $update_comment = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $updateData1, "orderid=" . (int) $order['orderid']); $updateData = array( "prodmanualactivate" => 1, ); // $update_status = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_products", $updateData, "orderprodid=" . (int) $product['orderprodid']); $status = array( 'number' => $product['ordprodname'], 'status' => 3 ); echo json_encode($status); exit(); } }else{ $subject = "Activation status: Unsuccessful"; $emailTemplate->SetTemplate("activate_recent_purchase_number_error"); $GLOBALS['Error_msg'] = "The Customer does not exist in the Telinta’s pool."; //send Email to the Admin $sendTo = @implode(", ", $allEmails); $GLOBALS['firstname'] = $customer['custconfirstname']; $GLOBALS['admin_message'] = "
Notifications sent to: " . $sendTo . "
"; $admin_message = $emailTemplate->ParseTemplate(true); $obj_email_admin = GetEmailClass(); $obj_email_admin->Set('CharSet', GetConfig('CharacterSet')); $obj_email_admin->From(GetConfig('OrderEmail'), $store_name); $obj_email_admin->Set("Subject", $subject); $obj_email_admin->AddBody("html", $admin_message); // $obj_email_admin->AddRecipient("excellentnumbers@gmail.com", "", "h"); // $obj_email_admin->AddRecipient("orders@excellentnumbers.com", "", "h"); // $obj_email_admin->AddRecipient("excellentnumberstest@yopmail.com", "", "h"); $obj_email_admin->AddRecipient("developer5@webmaklay.com", "", "h"); $email_result_admin = $obj_email_admin->Send(); $date = new DateTime("now", new DateTimeZone('America/New_York') ); $Eastern_Time_zone = $date->format('Y-m-d H:i:s'); $updateData1 = array( "ordcustmessage" => $Eastern_Time_zone, ); // $update_comment = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $updateData1, "orderid=" . (int) $order['orderid']); $updateData = array( "prodmanualactivate" => 1, ); // $update_status = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_products", $updateData, "orderprodid=" . (int) $product['orderprodid']); $status = array( 'number' => $product['ordprodname'], 'status' => 0 ); echo json_encode($status); exit(); } } if(isset($i_customer_DID)){ $subject = "Activation status: Unsuccessful"; $emailTemplate->SetTemplate("activate_recent_purchase_number_error"); $GLOBALS['Error_msg'] = "TN Status : IN Use."; //send Email to the Admin $sendTo = @implode(", ", $allEmails); $GLOBALS['firstname'] = $customer['custconfirstname']; $GLOBALS['admin_message'] = "
Notifications sent to: " . $sendTo . "
"; $admin_message = $emailTemplate->ParseTemplate(true); $obj_email_admin = GetEmailClass(); $obj_email_admin->Set('CharSet', GetConfig('CharacterSet')); $obj_email_admin->From(GetConfig('OrderEmail'), $store_name); $obj_email_admin->Set("Subject", $subject); $obj_email_admin->AddBody("html", $admin_message); // $obj_email_admin->AddRecipient("excellentnumbers@gmail.com", "", "h"); // $obj_email_admin->AddRecipient("orders@excellentnumbers.com", "", "h"); // $obj_email_admin->AddRecipient("excellentnumberstest@yopmail.com", "", "h"); $obj_email_admin->AddRecipient("developer5@webmaklay.com", "", "h"); $email_result_admin = $obj_email_admin->Send(); $date = new DateTime("now", new DateTimeZone('America/New_York') ); $Eastern_Time_zone = $date->format('Y-m-d H:i:s'); $updateData1 = array( "ordcustmessage" => $Eastern_Time_zone, ); // $update_comment = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $updateData1, "orderid=" . (int) $order['orderid']); $updateData = array( "prodmanualactivate" => 1, ); // $update_status = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_products", $updateData, "orderprodid=" . (int) $product['orderprodid']); $status = array( 'number' => $product['ordprodname'], 'status' => 2 ); echo json_encode($status); exit(); } }else{ $subject = "Activation status: Unsuccessful"; $emailTemplate->SetTemplate("activate_recent_purchase_number_error"); $GLOBALS['Error_msg'] = $product['ordprodname']." Number does not exist in the Telinta’s pool."; //send Email to the Admin $sendTo = @implode(", ", $allEmails); $GLOBALS['firstname'] = $customer['custconfirstname']; $GLOBALS['admin_message'] = "
Notifications sent to: " . $sendTo . "
"; $admin_message = $emailTemplate->ParseTemplate(true); $obj_email_admin = GetEmailClass(); $obj_email_admin->Set('CharSet', GetConfig('CharacterSet')); $obj_email_admin->From(GetConfig('OrderEmail'), $store_name); $obj_email_admin->Set("Subject", $subject); $obj_email_admin->AddBody("html", $admin_message); // $obj_email_admin->AddRecipient("excellentnumbers@gmail.com", "", "h"); // $obj_email_admin->AddRecipient("orders@excellentnumbers.com", "", "h"); // $obj_email_admin->AddRecipient("excellentnumberstest@yopmail.com", "", "h"); $obj_email_admin->AddRecipient("developer5@webmaklay.com", "", "h"); $email_result_admin = $obj_email_admin->Send(); $date = new DateTime("now", new DateTimeZone('America/New_York') ); $Eastern_Time_zone = $date->format('Y-m-d H:i:s'); $updateData1 = array( "ordcustmessage" => $Eastern_Time_zone, ); // $update_comment = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $updateData1, "orderid=" . (int) $order['orderid']); $updateData = array( "prodmanualactivate" => 1, ); // $update_status = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_products", $updateData, "orderprodid=" . (int) $product['orderprodid']); $status = array( 'number' => $product['ordprodname'], 'status' => 0 ); echo json_encode($status); exit(); } } catch (Exception $e) { echo $e; exit; } }