| Server IP : 138.197.176.125 / Your IP : 216.73.216.41 Web Server : Apache/2.4.41 (Ubuntu) System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/soltelcocrm/modules/SellingReactivation/ |
Upload File : |
<?php
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/
function handleSimModifyReprogramming($entityData){
$adb = PearDatabase::getInstance();
$moduleName = $entityData->getModuleName();
$wsId = $entityData->getId();
$parts = explode('x', $wsId);
$recordId = $parts[1];
$entityResult = $entityData->data;
if($recordId){
$reactivation_package = $entityResult['reactivation_package'];
/*$sellingsim_isdn = $entityResult['selling_ISDNNo'];
$sellingsim_imsi = $entityResult['selling_IMSINo'];*/
$sellingsim_newimsi = $entityResult['selling_descriptioniccd'];
$cardtype = $entityResult['selling_simtype'];
$related_contact = $entityResult['related_contact'];
$arrContactIds = explode('x',$related_contact);
$contactid = $arrContactIds[1];
if($contactid > 0){
$contactRecordModel = Vtiger_Record_Model::getInstanceById($contactid,'Contacts');
$sellingsim_isdn = $contactRecordModel->get('contact_simnumber');
$sellingsimold_isdn = $contactRecordModel->get('contact_iccid');
}
$inventoryModuleModel = new SellingInventory_Module_Model();
//$loginResponse = $inventoryModuleModel->checkHLRLoginAPI();
$loginCredentials = $inventoryModuleModel->getAPISettingsDetails();
$apiurl = $loginCredentials['hlr_apiurl'];
$username = $loginCredentials['hlr_username'];
$password = $loginCredentials['hlr_password'];
//call HLR login API
$curl = curl_init();
$crmapirequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<LGI>
<OPNAME>'.$username.'</OPNAME>
<PWD>'.$password.'</PWD>
</LGI>
</soapenv:Body>
</soapenv:Envelope>';
curl_setopt_array($curl, array(
CURLOPT_URL => $apiurl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_HEADER => true,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>$crmapirequest,
CURLOPT_HTTPHEADER => array(
'Content-Type: text/plain',
'User-Agent: Jakarta Commons-HttpClient/3.1'
),
));
$response = curl_exec($curl);
//if log enable save api log
$logStaus = $inventoryModuleModel->checkApiLogEnabled();
if($logStaus){
$loginsertid = $inventoryModuleModel->insertRecordInApiModule($apiurl, $crmapirequest,$response);
}
$headerlocation = '';
if (strpos($response, 'Location') !== false) {
$arrresponse = explode("Location:", $response);
$arrresponse1 = explode("Server:", $arrresponse[1]);
$headerlocation = $arrresponse1[0];
}
$loginResponse = trim($headerlocation);
if(!empty($loginResponse)){
// call list SUB reprogramming api
$apiurl = $loginResponse;
$crmapirequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<LST_SUB>
<ISDN>'.$sellingsim_isdn.'</ISDN>
<DETAIL>FALSE</DETAIL>
</LST_SUB>
</soapenv:Body>
</soapenv:Envelope>';
curl_setopt_array($curl, array(
CURLOPT_URL => $apiurl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_HEADER => false,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>$crmapirequest,
CURLOPT_HTTPHEADER => array(
'Content-Type: text/plain',
'User-Agent: Jakarta Commons-HttpClient/3.1'
),
));
$response1 = curl_exec($curl);
//if log enable save api log
$logStaus = $inventoryModuleModel->checkApiLogEnabled();
if($logStaus){
$loginsertid = $inventoryModuleModel->insertRecordInApiModule($apiurl, $crmapirequest,$response1);
}
$soap = simplexml_load_string($response1);
$arrresponse = $soap->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children();
$xmlresponse = $arrresponse->LST_SUBResponse->Result->ResultCode;
if($xmlresponse == 0){
//Modify IMISI reprogramming api
$apiurl = $loginResponse;
$crmapirequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<MOD_IMSI>
<IMSI>'.$sellingsimold_isdn.'</IMSI>
<NEWIMSI>'.$sellingsim_newimsi.'</NEWIMSI>
<CARDTYPE>USIM</CARDTYPE>
<ALG>MILENAGE</ALG>
</MOD_IMSI>
</soapenv:Body>
</soapenv:Envelope>';
curl_setopt_array($curl, array(
CURLOPT_URL => $apiurl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_HEADER => false,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>$crmapirequest,
CURLOPT_HTTPHEADER => array(
'Content-Type: text/plain',
'User-Agent: Jakarta Commons-HttpClient/3.1'
),
));
$response2 = curl_exec($curl);
curl_close($curl);
//if log enable save api log
$logStaus = $inventoryModuleModel->checkApiLogEnabled();
if($logStaus){
$loginsertid = $inventoryModuleModel->insertRecordInApiModule($apiurl, $crmapirequest,$response2);
}
$soap = simplexml_load_string($response2);
$arrresponse = $soap->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children();
$xmlresponse = $arrresponse->MOD_IMSIResponse->Result->ResultCode;
if($xmlresponse == 0){
$adb->pquery("UPDATE vtiger_simgenerate SET simgenerate_status=?,assignedstatus=? WHERE simcard_imsino=?", array('Activate','Activate', $sellingsim_newimsi));
}else{
$adb->pquery("UPDATE vtiger_simgenerate SET simgenerate_status=?,assignedstatus=? WHERE simcard_imsino=?", array('Fail','Fail', $sellingsim_newimsi));
}
}/*else{
$adb->pquery("UPDATE vtiger_simgenerate SET simgenerate_status=?,assignedstatus=? WHERE simcard_imsino=?", array('Fail','Fail', $sellingsim_newimsi));
}*/
}
if($reactivation_package == 'New Reactivation'){
//code added for get recharge api call start
$inventoryModuleModel = new SellingInventory_Module_Model();
$loginCredentials = $inventoryModuleModel->getAPISettingsDetails();
$apiurl = $loginCredentials['addons_apiurl'];
if(!empty($apiurl)){
$cbsurl = $apiurl.'/bundle';
$crmapirequest = '{
"subscriptionId": "'.$sellingsim_isdn.'",
"bundleId": "162"
}';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $cbsurl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_HEADER => true,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>$crmapirequest,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
),
));
$response = curl_exec($curl);
curl_close($curl);
//if log enable save api log
$logStaus = $inventoryModuleModel->checkApiLogEnabled();
if($logStaus){
$loginsertid = $inventoryModuleModel->insertRecordInApiModule($cbsurl, $crmapirequest,$response);
}
//echo $response;
$headers = explode(PHP_EOL, $response);
$arrResponse = json_decode($headers[9], true);
if($arrResponse['resultCode'] == 200){
$transactionId = $arrResponse['data']['transactionId'];
$adb->pquery("UPDATE vtiger_addonstransaction SET addons_transactionid=? WHERE addonstransactionid=?", array($transactionId,$recordId));
}
//update status and number record id
$recordModel = Vtiger_Record_Model::getInstanceById($loginsertid, 'APILog');
$recordModel->set('mode','edit');
//$recordModel->set('relatednumber',$numberId);
if($arrResponse['resultCode'] == 200){
$recordModel->set('apistatus','Success');
}else{
$recordModel->set('apistatus','Fail');
}
$recordModel->save();
}
}
}
}