diff --git a/build/MagnusBilling-current.tar.gz b/build/MagnusBilling-current.tar.gz
index 96c773bce..fdc1809db 100644
Binary files a/build/MagnusBilling-current.tar.gz and b/build/MagnusBilling-current.tar.gz differ
diff --git a/protected/commands/BDServiceCommand.php b/protected/commands/BDServiceCommand.php
index 6c66125ef..ee52d61e8 100755
--- a/protected/commands/BDServiceCommand.php
+++ b/protected/commands/BDServiceCommand.php
@@ -38,6 +38,91 @@ public function run($args)
}
$log = DEBUG >= 1 ? Log::writeLog(LOGFILE, ' line:' . __LINE__ . " START NOTIFY CLIENT ") : null;
+ $this->tanaSend();
+
+ $this->ezzeapi();
+
+ }
+
+ public function tanaSend()
+ {
+
+ $config = LoadConfig::getConfig();
+
+ $userBD = $config['global']['BDService_username'];
+ $keyBD = $config['global']['BDService_token'];
+
+ $modelSendCreditSummary = SendCreditSummary::model()->findAll('confirmed = 0 AND service != :key AND date > :key1 AND provider = :key2', [
+ ':key' => 'international',
+ ':key1' => date('Y-m-d'),
+ ':key2' => 'TanaSend',
+ ]);
+
+ foreach ($modelSendCreditSummary as $key => $sendCredit) {
+ $url = "http://takasend.org/ezzeapi/status?id=" . $sendCredit->id . "&user=" . $userBD . "&key=" . $keyBD . "";
+ if (!$result = @file_get_contents($url, false)) {
+ $result = '';
+ }
+ echo $result . " $sendCredit->id \n";
+ $modelRefill = Refill::model()->find('invoice_number = :key AND id_user = :key1',
+ array(
+ ':key' => $sendCredit->id,
+ ':key1' => $sendCredit->id_user,
+ ));
+
+ if (preg_match("/ERROR|CANCELLED/", strtoupper($result))) {
+
+ $result = explode(':', $result);
+
+ $sendCredit->confirmed = 3;
+ $sendCredit->save();
+
+ if (isset($modelRefill->id)) {
+
+ $modelRefill->description = $modelRefill->description . '. Status: ' . $result[0] . '. Ref:' . $result[1];
+ $modelRefill->payment = 0;
+ try {
+ $modelRefill->save();
+ } catch (Exception $e) {
+
+ }
+
+ $modelUser = User::model()->findByPk($sendCredit->id_user);
+ $modelUser->credit = $modelUser->credit + ($modelRefill->credit * -1);
+
+ try {
+ $modelUser->save();
+ } catch (Exception $e) {
+
+ }
+ }
+
+ } else if (preg_match("/SUCCESS|COMPLETED|ERROR/", $result)) {
+
+ $result = explode(':', $result);
+
+ $sendCredit->confirmed = 1;
+ $sendCredit->save();
+
+ if (isset($modelRefill->id)) {
+
+ $modelRefill->description = @$modelRefill->description . '. Status: ' . $result[0] . '. Ref:' . $result[1];
+ $modelRefill->payment = 1;
+ try {
+ $modelRefill->save();
+ } catch (Exception $e) {
+
+ }
+ }
+
+ }
+
+ }
+
+ }
+ public function ezzeapi()
+ {
+
/*$_POST = array(
"refid" => 23597,
@@ -57,7 +142,10 @@ public function run($args)
Configuration::model()->updateAll(array('config_value' => $result), 'config_key = :key',
array(':key' => 'BDService_credit_provider'));
- $modelSendCreditSummary = SendCreditSummary::model()->findAll('confirmed = 0 AND service != "international"');
+ $modelSendCreditSummary = SendCreditSummary::model()->findAll('confirmed = 0 AND service != :key AND date > :key1 ', [
+ ':key' => 'international',
+ ':key1' => date('Y-m-d'),
+ ]);
foreach ($modelSendCreditSummary as $key => $sendCredit) {
diff --git a/protected/commands/CallChartCommand.php b/protected/commands/CallChartCommand.php
index d94121801..b74648d44 100755
--- a/protected/commands/CallChartCommand.php
+++ b/protected/commands/CallChartCommand.php
@@ -191,7 +191,7 @@ public function user_cdr_show($calls)
if (!count($modelSip)) {
if ($status == 'Ring') {
- $sip_account = $originate;
+ $sip_account = $originate;
}
if (strlen($sip_account) > 3) {
//echo "check per sip_account $originate\n";
@@ -345,7 +345,11 @@ public function user_cdr_show($calls)
$sql[] = "(NULL,'" . $uniqueid . "', '$sip_account', $id_user, '$channel', '" . utf8_encode($trunk) . "', '$ndiscado', '" . preg_replace('/\(|\)/', '', $codec) . "', '$status', '$cdr', 'no','no', '" . $call['server'] . "')";
if (count($callShopIds)) {
- if (in_array($modelSip->id_user, $callShopIds)) {
+ if (in_array($id_user, $callShopIds)) {
+
+ if (!isset($modelSip->id)) {
+ $modelSip = Sip::model()->find('name =:key', array(':key' => $sip_account));
+ }
$modelSip->status = 3;
$modelSip->callshopnumber = $ndiscado;
$modelSip->callshoptime = $cdr;
diff --git a/protected/components/AsteriskAccess.php b/protected/components/AsteriskAccess.php
index ac371b5d3..29acba70a 100755
--- a/protected/components/AsteriskAccess.php
+++ b/protected/components/AsteriskAccess.php
@@ -278,13 +278,13 @@ public function writeAsteriskFile($model, $file, $head_field = 'name')
$line .= 'context=slave' . "\n";
} else if ($data['type'] == 'sipproxy') {
- $line = "\n\n[sipproxy-" . preg_replace('/ /', '', strtolower($data['name'])) . "]\n";
+ $line = "\n\n[sipproxy-" . preg_replace('/ /', '', strtolower($data['name'])) . "-" . $data['id'] . "]\n";
$line .= 'host=' . $data['host'] . "\n";
$line .= 'fromdomain=' . $data['host'] . "\n";
$line .= 'accountcode=sipproxy' . "\n";
$line .= 'context=proxy' . "\n";
- $line .= 'directmedia=yes' . "\n";
- $line .= 'nat=no' . "\n";
+ $line .= 'directmedia=no' . "\n";
+ $line .= 'nat=force_rport,comedia' . "\n";
} else if ($data['type'] == 'mbilling') {
$line = "\n\n[mbilling]\n";
diff --git a/protected/components/SendCreditDingConnect.php b/protected/components/SendCreditDingConnect.php
index dce7995fe..1c47557ee 100755
--- a/protected/components/SendCreditDingConnect.php
+++ b/protected/components/SendCreditDingConnect.php
@@ -21,9 +21,12 @@ public function getKey()
return $config['global']['ding_api'];
}
- public static function sendCredit($number, $send_value, $SkuCode, $test)
+ public static function sendCredit($number, $modelSendCreditRates, $SkuCode, $test)
{
+ $send_value = $modelSendCreditRates->idProduct->send_value;
+ $SkuCode = $modelSendCreditRates->idProduct->SkuCode;
+
if ($send_value == 0) {
$post = [[
@@ -31,7 +34,7 @@ public static function sendCredit($number, $send_value, $SkuCode, $test)
"SendValue" => 5,
"SendCurrencyIso" => "EUR",
"ReceiveValue" => 0,
- "SkuCode" => "BD_AX_TopUp",
+ "SkuCode" => $SkuCode,
"BatchItemRef" => "string",
]];
@@ -54,21 +57,41 @@ public static function sendCredit($number, $send_value, $SkuCode, $test)
if (isset($result->Items[0]->Price->ReceiveValue)) {
- $send_value = number_format(5 / $result->Items[0]->Price->ReceiveValue * $_POST['TransferToMobile']['amountValuesBDT'], 2);
- $end_value = number_format($send_value * 1.01);
+ if (isset($_POST['TransferToMobile']['amountValuesBDT']) && $_POST['TransferToMobile']['amountValuesBDT'] > 0) {
+ $send_value = ((5 / $result->Items[0]->Price->ReceiveValue) * $_POST['TransferToMobile']['amountValuesBDT']) * 1.01;
+ } else {
+ $send_value = ((5 / $result->Items[0]->Price->ReceiveValue) * $modelSendCreditRates->idProduct->product) * 1.01;
+ }
+ $send_value_to_api = $send_value;
+ $send_value = number_format($send_value, 2);
} else {
exit('invalid amount receiveValue');
}
+ /*
+ echo '
';
+ echo '';
+ print_r($modelSendCreditRates->getAttributes());
+ print_r($modelSendCreditRates->idProduct->getAttributes());
+ print_r($result);
+
+ echo '((5 / ' . $result->Items[0]->Price->ReceiveValue . ') *' . $_POST['TransferToMobile']['amountValuesBDT'] . ') + 1%)
';
+ echo 'send_value = ' . $send_value . "
";
+ exit;
+ */
+
+ } else {
+ $send_value_to_api = $send_value;
}
+
//SendCreditDingConnect::getProducts('VOBR');
if (preg_match('/^00/', $number)) {
$number = substr($number, 2);
}
$post = array(
"SkuCode" => $SkuCode,
- "SendValue" => $send_value,
+ "SendValue" => $send_value_to_api,
"AccountNumber" => $number,
"DistributorRef" => $number,
"ValidateOnly" => $test,
@@ -97,6 +120,11 @@ public static function sendCredit($number, $send_value, $SkuCode, $test)
print_r($result);
}
+ if ($result->TransferRecord->ProcessingState == 'Failed') {
+ unset($result->TransferRecord->ReceiptParams);
+
+ }
+
return $result->TransferRecord->ProcessingState == 'Complete' ? 'error_txt=Transaction successful' : 'error_txt=' . $result->ErrorCodes[0]->Code . ' ' . $result->ErrorCodes[0]->Context;
}
diff --git a/protected/components/SendCreditOrange2.php b/protected/components/SendCreditOrange2.php
index 728e43850..b128b2f0a 100755
--- a/protected/components/SendCreditOrange2.php
+++ b/protected/components/SendCreditOrange2.php
@@ -13,23 +13,93 @@ public function billElectricity($post, $modelSendCreditRates, $test)
{
$date = date_create($post['creationdate']);
+ switch ($_POST['TransferToMobile']['country']) {
+ case 'Benin':
+ $CC = 'BJ';
+ $id = 1;
+ break;
+ case 'Burkina Faso':
+ $CC = 'BF';
+ $id = 2;
+ break;
+ case 'Ivory Coast':
+ $CC = 'CI';
+ $id = 1;
+ break;
+ case 'Gambia':
+ $CC = 'GM';
+ $id = 1;
+ break;
+ case 'Ghana':
+ $CC = 'GH';
+ $id = 1;
+ break;
+ case 'Guinea':
+ $CC = 'GN';
+ $id = 1;
+ break;
+ case 'Guinea-Bissau':
+ $CC = 'GW';
+ $id = 1;
+ break;
+ case 'Mauritania':
+ $CC = 'MR';
+ $id = 1;
+ break;
+ case 'Morocco':
+ $CC = 'MA';
+ $id = 1;
+ break;
+ case 'Sierra Leone':
+ $CC = 'SL';
+ $id = 1;
+ break;
+ case 'Togo':
+ $CC = 'TG';
+ $id = 1;
+ break;
+ case 'Mali':
+ $CC = 'ML';
+ $id = 1;
+ break;
+ case 'Nigeria':
+ $CC = 'NG';
+ $id = 1;
+ break;
+ case 'Senegal':
+ $CC = 'SN';
+ $id = 1;
+ break;
+ default:
+ $CC = 'SN';
+ $id = 1;
+ return false;
+ break;
+ }
+
$order = array(
"beneficiary" => array(
- 'mobile' => '+221786434468',
- "name" => "Ibra",
+ 'mobile' => '+' . $post['phone'],
+ "name" => "ABC",
),
"type" => "bill",
"billOrderData" => [
"billType" => [
- "id" => 1,
+ "id" => $id,
+ "country" => [
+ "id" => $CC,
+ "name" => $_POST['TransferToMobile']['country'],
+ ],
],
- 'data' => "{\"number\":\"" . $post['number'] . "\",\"date\":\"" . date_format($date, "d/m/Y") . "\"}",
+ 'data' => "{\"number\":\"" . $post['number'] . "\",\"date\":\"" . date_format($date, "d/m/Y") . "\",\"distrubutionCode\":\"" . $_POST['TransferToMobile']['zipcode'] . "\"}",
],
"targetTotal" => $post['bill_amount'],
);
-
+ //echo '';
+ //print_r($order);
+ //exit;
return SendCreditOrange2::sendOrder($order);
}
@@ -37,17 +107,26 @@ public function billElectricity($post, $modelSendCreditRates, $test)
public static function sendCredit($number, $modelSendCreditRates, $test)
{
- $order = array(
- "type" => "cashpower",
- "targetTotal" => $modelSendCreditRates->idProduct->product,
- "beneficiary" => array(
- 'mobile' => '+' . $number,
- "name" => "ABC",
+ if (!isset($_POST['TransferToMobile']['meter'])) {
+ $order = SendCreditOrange2::sendPayment($number, $modelSendCreditRates, $test);
- ),
- "meterId" => $_POST['TransferToMobile']['meter'],
- );
+ } else {
+
+ if (preg_match('/-/', $modelSendCreditRates->idProduct->product)) {
+ $modelSendCreditRates->idProduct->product = $_POST['TransferToMobile']['amountValuesBDT'];
+ }
+
+ $order = array(
+ "type" => "cashpower",
+ "targetTotal" => $modelSendCreditRates->idProduct->product,
+ "beneficiary" => array(
+ 'mobile' => '+' . $number,
+ "name" => "ABC",
+ ),
+ "meterId" => $_POST['TransferToMobile']['meter'],
+ );
+ }
return SendCreditOrange2::sendOrder($order);
}
@@ -97,22 +176,17 @@ public function sendOrder($order = '')
curl_close($ch);
$output = json_decode($output, JSON_UNESCAPED_SLASHES);
-
if (isset($output['id'])) {
$output = (object) $output;
}
if (!isset($output->id) || !is_numeric($output->id)) {
- echo '';
- echo "
";
- print_r($data_string);
- print_r($output);
- echo "
RESPONSE
";
- return 'error_txt=' . print_r($output, true);
+ return 'error_txt=' . print_r($output['message'], true);
}
$transaction_id = $output->id;
+
if ($test == 1) {
$url = 'https://qa.baluwo.com/rest/v1/external/transaction/pay/' . $transaction_id;
} else {
@@ -137,7 +211,7 @@ public function sendOrder($order = '')
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
- if ($info == 204) {
+ if (preg_match('/204/', $info)) {
return 'error_txt=Transaction successful=Orange2=' . $transaction_id;
} else {
return 'error_txt=Error' . print_r($output, true);
@@ -161,9 +235,39 @@ public static function checkMetric($metric = '', $country = '')
}
switch ($_POST['TransferToMobile']['country']) {
+ case 'Benin':
+ $CC = 'BJ';
+ break;
+ case 'Burkina Faso':
+ $CC = 'BF';
+ break;
+ case 'Ivory Coast':
+ $CC = 'CI';
+ break;
case 'Gambia':
$CC = 'GM';
break;
+ case 'Ghana':
+ $CC = 'GH';
+ break;
+ case 'Guinea':
+ $CC = 'GN';
+ break;
+ case 'Guinea-Bissau':
+ $CC = 'GW';
+ break;
+ case 'Mauritania':
+ $CC = 'MR';
+ break;
+ case 'Morocco':
+ $CC = 'MA';
+ break;
+ case 'Sierra Leone':
+ $CC = 'SL';
+ break;
+ case 'Togo':
+ $CC = 'TG';
+ break;
case 'Mali':
$CC = 'ML';
break;
@@ -173,7 +277,6 @@ public static function checkMetric($metric = '', $country = '')
case 'Senegal':
$CC = 'SN';
break;
-
default:
return false;
break;
@@ -190,7 +293,7 @@ public static function checkMetric($metric = '', $country = '')
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 7);
curl_setopt($ch, CURLOPT_HEADER, true);
$output = curl_exec($ch);
@@ -204,24 +307,44 @@ public static function checkMetric($metric = '', $country = '')
return substr($output[1], 0, -2);
} else {
- return false;
+ return 'Unknown';
}
}
- public function sendPayment($data = '')
+ public function sendPayment($number, $modelSendCreditRates, $test)
{
- echo '';
- print_r($data);
- exit;
- $order = array(
- "type" => "airtime",
- "targetTotal" => $modelSendCreditRates->idProduct->product,
- "beneficiary" => array(
- 'mobile' => '+' . $number,
- "name" => "ABC",
- ));
+ $modelSendCreditProducts = SendCreditProducts::model()->findByPk((int) $modelSendCreditRates->id_product);
+
+ if (preg_match('/Bundle/', $modelSendCreditProducts->operator_name)) {
+ $type = 'airdata';
+ } else {
+ $type = 'airtime';
+ }
+
+ if (preg_match('/\-/', $modelSendCreditRates->idProduct->product)) {
+
+ $order = array(
+ "type" => $type,
+ "targetTotal" => $_POST['TransferToMobile']['amountValuesBDT'],
+ "beneficiary" => array(
+ 'mobile' => '+' . $number,
+ "name" => "ABC",
+
+ ));
+ } else {
+ $order = array(
+ "type" => $type,
+ "targetTotal" => $modelSendCreditRates->idProduct->product,
+ "beneficiary" => array(
+ 'mobile' => '+' . $number,
+ "name" => "ABC",
+
+ ));
+ }
+
+ return $order;
}
diff --git a/protected/components/SendCreditReload.php b/protected/components/SendCreditReload.php
index e3629dd45..66152453c 100755
--- a/protected/components/SendCreditReload.php
+++ b/protected/components/SendCreditReload.php
@@ -21,20 +21,24 @@ public function getToken()
*/
$client_id = $config['global']['reloadly_client_id'];
$client_secret = $config['global']['reloadly_client_secret'];
- $ch = curl_init();
+
+ $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://auth.reloadly.com/oauth/token");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
- $testing = "https://topups-sandbox.reloadly.com";
- $live = "https://topups.reloadly.com";
+ if ($config['global']['reloadly_sandbox'] == 1) {
+ $url = "https://topups-sandbox.reloadly.com";
+ } else {
+ $url = "https://topups.reloadly.com";
+ }
$requestBody = json_encode([
"client_id" => $client_id,
"client_secret" => $client_secret,
"grant_type" => "client_credentials",
- "audience" => $live,
+ "audience" => $url,
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
@@ -55,6 +59,7 @@ public function getToken()
public function getCountry($countryCode = '')
{
+
$ch = curl_init();
$response = curl_exec($ch);
curl_close($ch);
@@ -91,8 +96,8 @@ public function getCountry($countryCode = '')
public function getOperator($number = '', $access_token)
{
- $ch = curl_init();
+ $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://topups.reloadly.com/operators/auto-detect/phone/+" . $number . "/countries/BR?&includeBundles=true");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
@@ -148,12 +153,21 @@ public static function sendCredit($number, $modelSendCreditRates, $test)
if (isset($result->fxRate)) {
- $modelSendCreditRates->idProduct->send_value = number_format((1 / $result->fxRate * $_POST['TransferToMobile']['amountValuesBDT']), 2);
- $modelSendCreditRates->idProduct->send_value = number_format($modelSendCreditRates->idProduct->send_value * 1.01);
+ if (isset($_POST['TransferToMobile']['amountValuesBDT']) && $_POST['TransferToMobile']['amountValuesBDT'] > 0) {
+ $modelSendCreditRates->idProduct->send_value = ((1 / $result->fxRate) * $_POST['TransferToMobile']['amountValuesBDT']) * 1.01;
+ } else {
+ $modelSendCreditRates->idProduct->send_value = ((1 / $result->fxRate) * $modelSendCreditRates->idProduct->product) * 1.01;
+ }
+
+ $send_value_to_api = $modelSendCreditRates->idProduct->send_value;
+ $modelSendCreditRates->idProduct->send_value = number_format($modelSendCreditRates->idProduct->send_value, 2);
+
} else {
exit('invalid amount receiveValue');
}
+ } else {
+ $send_value_to_api = $modelSendCreditRates->idProduct->send_value;
}
$ch = curl_init();
@@ -173,8 +187,8 @@ public static function sendCredit($number, $modelSendCreditRates, $test)
'number' => '+13059547862',
],
'operatorId' => $operatorId,
- 'amount' => $modelSendCreditRates->idProduct->send_value,
- 'customIdentifier' => 'Transaction from user ' . Yii::app()->session['username'] . ' ' . time(),
+ 'amount' => $send_value_to_api,
+ //'customIdentifier' => 'Transaction from user ' . Yii::app()->session['username'] . ' ' . time(),
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestFields);
diff --git a/protected/components/SendCreditTanaSend.php b/protected/components/SendCreditTanaSend.php
new file mode 100755
index 000000000..1431da3a1
--- /dev/null
+++ b/protected/components/SendCreditTanaSend.php
@@ -0,0 +1,39 @@
+
+ * 16/01/2021
+ */
+
+class SendCreditTanaSend
+{
+
+ public static function sendCredit($number, $modelSendCreditRates, $type, $id, $test)
+ {
+
+ $config = LoadConfig::getConfig();
+
+ $userBD = $config['global']['BDService_username'];
+ $keyBD = $config['global']['BDService_token'];
+
+ $number = preg_replace('/^00/', '', $number);
+ $number = preg_replace('/^88/', '', $number);
+
+ if (preg_match('/\-/', $modelSendCreditRates->idProduct->product)) {
+ $send_value = $_POST['TransferToMobile']['amountValuesBDT'];
+ } else {
+ $send_value = $modelSendCreditRates->idProduct->product;
+ }
+
+ $url = "http://takasend.org/ezzeapi/request/flexiload?number=" . $number . "&amount=" . $send_value . "&type=1&id=" . $id . "&user=" . $userBD . "&key=" . $keyBD;
+
+ $result = file_get_contents($url);
+ if (preg_match('/SUCCESS/', $result)) {
+ return 'error_txt=Transaction successful=TanaSend=' . $id . '=' . $send_value;
+ } else {
+ return 'error_txt=Error' . print_r($result, true);
+ }
+
+ }
+}
diff --git a/protected/controllers/AtaController.php b/protected/controllers/AtaController.php
index 7978b9f59..ac7238592 100755
--- a/protected/controllers/AtaController.php
+++ b/protected/controllers/AtaController.php
@@ -33,7 +33,7 @@ public function actionIndex()
$mac = substr($mac, 0);
$proxy = $this->config['global']['ip_servers'];
- $Profile_Rule = "http://" . $proxy . "/mbilling/index.php/ata?mac=\$MAC";
+ $Profile_Rule = "http://" . $proxy . "/mbilling/index.php/ata?mac=$mac";
$modelo = explode(" ", $_SERVER["HTTP_USER_AGENT"]);
$modelSipuras = Sipuras::model()->find('macadr = :mac', array(':mac' => $mac));
diff --git a/protected/controllers/SendCreditSummaryController.php b/protected/controllers/SendCreditSummaryController.php
index 026c75162..e55fef593 100755
--- a/protected/controllers/SendCreditSummaryController.php
+++ b/protected/controllers/SendCreditSummaryController.php
@@ -22,7 +22,7 @@
class SendCreditSummaryController extends Controller
{
- public $attributeOrder = 't.id DESC';
+ public $attributeOrder = 't.date DESC';
public function actionRead($asJson = true, $condition = null)
{
@@ -40,6 +40,10 @@ public function actionRead($asJson = true, $condition = null)
? $_POST['SendCreditSummary']['service']
: 'All';
+ $model->number = isset($_POST['SendCreditSummary']['number'])
+ ? $_POST['SendCreditSummary']['number']
+ : '';
+
if (Yii::app()->session['isAdmin'] != 1) {
$_POST['SendCreditSummary']['id'] = Yii::app()->session['id_user'];
} else {
@@ -48,7 +52,7 @@ public function actionRead($asJson = true, $condition = null)
: 1;
}
- $this->filter = 'confirmed = 1 AND earned IS NOT NULL ';
+ $this->filter = 'confirmed IN (0,1) AND earned IS NOT NULL ';
if (isset($_POST['SendCreditSummary']['id']) && $_POST['SendCreditSummary']['id'] > 1) {
$this->filter .= ' AND id_user = :id_user';
$this->paramsFilter['id_user'] = $_POST['SendCreditSummary']['id'];
@@ -59,20 +63,38 @@ public function actionRead($asJson = true, $condition = null)
$this->paramsFilter['stopdate'] = $model->stopdate . ' 23:59:59';
if ($model->service != 'all') {
+
$this->filter .= ' AND service LIKE :service';
$this->paramsFilter['service'] = $model->service;
+
+ }
+
+ if (is_numeric($model->number)) {
+ $this->filter .= ' AND number LIKE :number';
+ $this->paramsFilter['number'] = $model->number . '%';
}
+ /*
+ $modelSendCreditSummary = SendCreditSummary::model()->findAll();
+ foreach ($modelSendCreditSummary as $key => $value) {
- $this->select = '*, count(*) count, sum(sell) total_sale, sum(cost) total_cost, sum(earned) earned, DATE(date) AS day, date';
- $this->group = 'day, service';
+ $modelRefill = Refill::model()->find('invoice_number = :key', [':key' => $value->id]);
+ if (isset($modelRefill->description)) {
+ # code...
+ $res = explode('-', $modelRefill->description);
+ $res = explode(' ', $res[0]);
+ $value->received_amout = $res[2] . ' ' . $res[3];
+
+ $value->save();
+ }
+
+ }
+ */
$modelSendCreditSummary = SendCreditSummary::model()->findAll(array(
'select' => $this->select,
- 'join' => $this->join,
'condition' => $this->filter,
'params' => $this->paramsFilter,
- 'order' => $this->order,
- 'group' => $this->group,
+ 'order' => 'date DESC, service',
));
$this->render('index', array(
diff --git a/protected/controllers/TransferMobileCreditController.php b/protected/controllers/TransferMobileCreditController.php
index 3e623cae2..c80db0078 100755
--- a/protected/controllers/TransferMobileCreditController.php
+++ b/protected/controllers/TransferMobileCreditController.php
@@ -36,6 +36,7 @@ class TransferMobileCreditController extends Controller
private $local_currency;
public $modelTransferToMobile = array();
public $operator_name;
+ public $received_amout;
private $number;
@@ -92,11 +93,11 @@ public function actionIndex($asJson = true, $condition = null)
if (isset($_POST['TransferToMobile']['amountValuesBDT']) && $_POST['TransferToMobile']['amountValuesBDT'] > 0) {
$this->modelTransferToMobile->amountValues = Yii::app()->session['interval_product_id'];
$_POST['TransferToMobile']['amountValues'] = Yii::app()->session['interval_product_id'];
- } else {
+ } else if (isset($_POST['TransferToMobile']['amountValues'])) {
$this->modelTransferToMobile->amountValues = $_POST['TransferToMobile']['amountValues'];
}
- if (!is_numeric($_POST['TransferToMobile']['amountValues'])) {
+ if (!isset($_POST['TransferToMobile']['amountValues']) || !is_numeric($_POST['TransferToMobile']['amountValues'])) {
$this->modelTransferToMobile->addError('amountValues', Yii::t('zii', 'Invalid amount'));
} elseif (!count($this->modelTransferToMobile->getErrors())) {
@@ -119,10 +120,19 @@ public function actionIndex($asJson = true, $condition = null)
),
));
- if (preg_match_all('/-/', $modelSendCreditRates->idProduct->product) && isset($_POST['TransferToMobile']['amountValuesEUR']) && $_POST['TransferToMobile']['amountValuesEUR'] > 0) {
+ if (preg_match_all('/\-/', $modelSendCreditRates->idProduct->product) && isset($_POST['TransferToMobile']['amountValuesEUR']) && $_POST['TransferToMobile']['amountValuesEUR'] > 0) {
+ $amouts = explode('-', $modelSendCreditRates->idProduct->product);
+
+ if ($_POST['TransferToMobile']['amountValuesBDT'] > $amouts[1] || $_POST['TransferToMobile']['amountValuesBDT'] < $amouts[0]) {
+ exit('
The selected amount is out of range. Try again');
+ }
$modelSendCreditRates->sell_price = $_POST['TransferToMobile']['amountValuesEUR'];
}
+ if (preg_match_all('/\-/', $modelSendCreditRates->idProduct->product) && (!is_numeric($_POST['TransferToMobile']['amountValuesEUR']) || !is_numeric($_POST['TransferToMobile']['amountValuesBDT']))) {
+ exit('
The selected amount is out of range. Try again');
+ }
+
$this->render('confirm', array(
'modelTransferToMobile' => $this->modelTransferToMobile,
'modelSendCreditRates' => $modelSendCreditRates,
@@ -154,22 +164,34 @@ public function actionIndex($asJson = true, $condition = null)
}
$amountDetails = null;
+ if (isset(Yii::app()->session['interval_product_interval'])) {
+
+ $values = explode("-", Yii::app()->session['interval_product_interval']);
+ Yii::app()->session['allowedAmount'] = $values;
+ Yii::app()->session['allowedAmountmin'] = $values[0];
+ Yii::app()->session['allowedAmountmax'] = $values[1];
+ $amountDetails = 'Amount (Min: ' . $values[0] . ' ' . Yii::app()->session['interval_currency'] . ', Max: ' . $values[1] . ' ' . Yii::app()->session['interval_currency'] . ')';
+ }
$this->render('index', array(
'modelTransferToMobile' => $this->modelTransferToMobile,
+ 'amountDetails' => $amountDetails,
));
}
- public function addInDataBase()
+ public function addInDataBase($confirmed = 1)
{
- $modelSendCreditSummary = new SendCreditSummary();
- $modelSendCreditSummary->id_user = Yii::app()->session['id_user'];
- $modelSendCreditSummary->service = 'Mobile Credit';
- $modelSendCreditSummary->number = $this->number;
- $modelSendCreditSummary->confirmed = 1;
- $modelSendCreditSummary->cost = $this->user_cost;
+
+ $modelSendCreditSummary = new SendCreditSummary();
+ $modelSendCreditSummary->id_user = Yii::app()->session['id_user'];
+ $modelSendCreditSummary->service = 'Mobile Credit';
+ $modelSendCreditSummary->number = $this->number;
+ $modelSendCreditSummary->confirmed = $confirmed;
+ $modelSendCreditSummary->cost = $this->user_cost;
+ $modelSendCreditSummary->operator_name = $this->operator_name;
+ $modelSendCreditSummary->received_amout = $this->local_currency . ' ' . $this->received_amout;
$modelSendCreditSummary->save();
$this->send_credit_id = $modelSendCreditSummary->id;
}
@@ -181,10 +203,11 @@ public function updateDataBase()
$profit = 'transfer_international_profit';
SendCreditSummary::model()->updateByPk($this->send_credit_id, array(
- 'profit' => $this->modelTransferToMobile->{$profit},
- 'amount' => $this->cost,
- 'sell' => number_format($this->sell_price, 2),
- 'earned' => number_format($this->sell_price - $this->user_cost, 2),
+ 'profit' => $this->modelTransferToMobile->{$profit},
+ 'amount' => $this->cost,
+ 'sell' => number_format($this->sell_price, 2),
+ 'earned' => number_format($this->sell_price - $this->user_cost, 2),
+ 'received_amout' => $this->local_currency . ' ' . $this->received_amout,
));
} else {
SendCreditSummary::model()->deleteByPk($this->send_credit_id);
@@ -198,6 +221,8 @@ public function sendActionTransferToMobile($action, $product = null)
$key = time();
$md5 = md5($this->login . $this->token . $key);
+ $this->url = 'https://airtime-api.dtone.com/cgi-bin/shop/topup?';
+
if ($action == 'topup') {
$modelSendCreditProducts = SendCreditProducts::model()->find(array(
'condition' => 'operator_name = :key AND product = :key1',
@@ -206,12 +231,14 @@ public function sendActionTransferToMobile($action, $product = null)
':key1' => $product,
),
));
- $this->url = "https://airtime.transferto.com/cgi-bin/shop/topup?";
+
+ $this->url = 'https://airtime-api.dtone.com/cgi-bin/shop/topup?';
$action .= '&msisdn=number&delivered_amount_info=1&product=' . $product . '&operatorid=' . $modelSendCreditProducts->operator_id . '&sms_sent=yes';
}
$url = $this->url . "login=" . $this->login . "&key=$key&md5=$md5&destination_msisdn=$number&action=" . $action;
+ //echo $url."
";
$arrContextOptions = array(
"ssl" => array(
"verify_peer" => false,
@@ -219,42 +246,8 @@ public function sendActionTransferToMobile($action, $product = null)
),
);
- if ($this->test == true && preg_match('/topup/', $action)) {
- return $result = 'transactionid=662680426
-msisdn=number
-destination_msisdn=5551982464731
-country=Brazil
-countryid=691
-operator=Vivo Brazil
-operatorid=708
-reference_operator=55674
-originating_currency=EUR
-destination_currency=BRL
-product_requested=7
-actual_product_sent=7
-wholesale_price=2.40
-retail_price=2.40
-balance=1320.90
-sms_sent=yes
-sms=
-cid1=
-cid2=
-cid3=
-local_info_value=7
-local_info_amount=7
-local_info_currency=BRL
-authentication_key=1529417078
-error_code=0
-error_txt=Transaction successful';
- } else {
-
- if (!$result = @file_get_contents($url, false, stream_context_create($arrContextOptions))) {
- $result = '';
- }
- }
-
- if ($this->test == true) {
- //echo $url . "
";
+ if (!$result = @file_get_contents($url, false, stream_context_create($arrContextOptions))) {
+ $result = '';
}
return $result;
@@ -281,20 +274,16 @@ public function calculateCost($product = 0, $post)
$user_profit = $this->modelTransferToMobile->{$methosProfit};
- if (isset($post['TransferToMobile']['amountValuesBDT']) && $post['TransferToMobile']['amountValuesBDT'] > 0) {
+ if (isset($_POST['TransferToMobile']['amountValuesBDT']) && $_POST['TransferToMobile']['amountValuesBDT'] > 0) {
- $this->user_cost = ($post['TransferToMobile']['amountValuesBDT'] * $this->cost) - ($post['TransferToMobile']['amountValuesBDT'] * $this->cost) * ($user_profit / 100);
- $this->user_profit = ($post['TransferToMobile']['amountValuesBDT'] * $this->cost) * ($user_profit / 100);
+ $this->user_cost = ($_POST['TransferToMobile']['amountValuesBDT'] * $this->cost) - ($_POST['TransferToMobile']['amountValuesBDT'] * $this->cost) * ($user_profit / 100);
+ $this->user_profit = ($_POST['TransferToMobile']['amountValuesBDT'] * $this->cost) * ($user_profit / 100);
} else {
$this->user_cost = $this->cost - ($this->cost * ($user_profit / 100));
$this->user_profit = $this->cost * ($user_profit / 100);
}
- if ($this->test == true) {
- echo 'cost=' . $this->cost . ', user_profit= ' . $this->cost * ($this->user_profit / 100) . ' user_profit=' . $this->user_profit . "
";
- }
-
if ($this->modelTransferToMobile->id_user > 1) {
//check if agent have credit
@@ -313,7 +302,17 @@ public function calculateCost($product = 0, $post)
$agentProfit = $modelAgent->{$methosProfit};
- $this->agent_cost = $this->cost - ($this->cost * ($agentProfit / 100));
+ if (isset($_POST['TransferToMobile']['amountValuesBDT']) && is_numeric($_POST['TransferToMobile']['amountValuesBDT'])) {
+
+ $this->agent_cost = ($_POST['TransferToMobile']['amountValuesBDT'] * $this->cost) - ($_POST['TransferToMobile']['amountValuesBDT'] * $this->cost) * ($agentProfit / 100);
+
+ } else {
+ $modelSendCreditProducts = SendCreditProducts::model()->findByPk((int) $_POST['TransferToMobile']['amountValues']);
+ $modelSendCreditRates = SendCreditRates::model()->find($modelSendCreditProducts->id);
+
+ $this->agent_cost = $modelSendCreditProducts->wholesale_price - ($modelSendCreditProducts->wholesale_price * $agentProfit / 100);
+
+ }
if ($this->test == true) {
echo 'agentProfit=' . $agentProfit . ' | $this->agent_cost=' . $this->agent_cost . "
";
@@ -326,16 +325,29 @@ public function actionGetBuyingPrice()
$currency = $this->config['global']['fm_transfer_currency'];
- $modelSendCreditProducts = SendCreditProducts::model()->findByPk((int) $_GET['id']);
+ if ($_GET['id'] == 0 && $_GET['valueAmoutBDT'] > 0) {
+ $modelSendCreditProducts = SendCreditProducts::model()->findByPk((int) $_SESSION['interval_product_id']);
+
+ $user_profit = $this->modelTransferToMobile->transfer_international_profit;
+
+ $cost = $_GET['valueAmoutBDT'] * $modelSendCreditProducts->wholesale_price;
- Yii::app()->session['operatorId'] = $modelSendCreditProducts->operator_id;
+ $user_cost = $cost - ($cost * ($user_profit / 100));
+ echo $currency . ' ' . number_format($user_cost, 2);
- $cost = $modelSendCreditProducts->wholesale_price;
+ } else {
+
+ $modelSendCreditProducts = SendCreditProducts::model()->findByPk((int) $_GET['id']);
+
+ Yii::app()->session['operatorId'] = $modelSendCreditProducts->operator_id;
- $user_profit = $this->modelTransferToMobile->transfer_international_profit;
+ $cost = $modelSendCreditProducts->wholesale_price;
- $user_cost = $cost - ($cost * ($user_profit / 100));
- echo $currency . ' ' . number_format($user_cost, 2);
+ $user_profit = $this->modelTransferToMobile->transfer_international_profit;
+
+ $user_cost = $cost - ($cost * ($user_profit / 100));
+ echo $currency . ' ' . number_format($user_cost, 2);
+ }
}
@@ -396,8 +408,11 @@ public function confirmRefill()
echo $modelSendCreditRates->idProduct->provider . "
";
exit;
*/
-
- $this->addInDataBase();
+ if ($modelSendCreditRates->idProduct->provider == 'TanaSend') {
+ $this->addInDataBase(0);
+ } else {
+ $this->addInDataBase(1);
+ }
if ($this->test == true) {
echo "REMOVE " . $this->user_cost . " from user " . $this->modelTransferToMobile->username . "
";
@@ -406,27 +421,29 @@ public function confirmRefill()
if ($modelSendCreditRates->idProduct->provider == 'Reload') {
$result = SendCreditReload::sendCredit($this->number, $modelSendCreditRates, $this->test);
} elseif ($modelSendCreditRates->idProduct->provider == 'Ding') {
- $result = SendCreditDingConnect::sendCredit($this->number, $modelSendCreditRates->idProduct->send_value, $modelSendCreditRates->idProduct->SkuCode, $this->test);
+ $result = SendCreditDingConnect::sendCredit($this->number, $modelSendCreditRates, $modelSendCreditRates->idProduct->SkuCode, $this->test);
} else if ($modelSendCreditRates->idProduct->provider == 'Orange2') {
$result = SendCreditOrange2::sendCredit($this->number, $modelSendCreditRates, $this->test);
- } else {
+ } else if ($modelSendCreditRates->idProduct->provider == 'TanaSend') {
+ $result = SendCreditTanaSend::sendCredit($this->number, $modelSendCreditRates, 'MobileCredit', $this->send_credit_id, $this->test);
+ } else if ($modelSendCreditRates->idProduct->provider == 'TransferTo') {
$result = $this->sendActionTransferToMobile('topup', $product);
}
- $this->checkResult($result);
+ $this->checkResult($result, $modelSendCreditRates);
$this->updateDataBase();
exit;
}
- public function checkResult($result)
+ public function checkResult($result, $modelSendCreditRates = [])
{
$result = explode("error_txt=", $result);
if (preg_match("/Transaction successful/", $result[1])) {
- $this->releaseCredit($result, '');
+ $this->releaseCredit($result, '', $modelSendCreditRates);
} else {
echo '';
@@ -438,25 +455,14 @@ public function checkResult($result)
}
- public function releaseCredit($result, $status)
+ public function releaseCredit($result, $status, $modelSendCreditRates = [])
{
- if (preg_match('/Orange2/', $result[1])) {
+ if (preg_match('/Orange2|TanaSend/', $result[1])) {
$result = explode("=", $result[1]);
}
- if ($status != 'error') {
- User::model()->updateByPk(Yii::app()->session['id_user'],
- array(
- 'credit' => new CDbExpression('credit - ' . $this->user_cost),
- )
- );
- }
-
- if ($this->test == true) {
- echo 'cost=' . $this->cost . '. user_cost=' . $this->user_cost . "
";
- echo $this->modelTransferToMobile->transfer_show_selling_price . "
";
- }
+ $modelUserOld = User::model()->findByPk(Yii::app()->session['id_user']);
$argument = $this->modelTransferToMobile->transfer_show_selling_price;
if ($argument < 10) {
@@ -472,22 +478,61 @@ public function releaseCredit($result, $status)
$this->showprice = number_format($this->cost * $fee, 2);
- if ($result[1] == 'Orange2') {
+ if (preg_match('/TanaSend/', $result[1])) {
+ $this->received_amout = $result[3];
+ $description = 'Send Credit ' . $this->local_currency . ' ' . $result[3] . ' - +' . $this->number . ' via ' . $this->operator_name . ' - EUR ' . number_format($this->sell_price, 2);
+ } else if (preg_match('/Orange2/', $result[1])) {
- $description = 'Send Credit ' . $this->local_currency . ' ' . $this->modelTransferToMobile->product . ' - +' . $this->number . ' via ' . $this->operator_name . ' - EUR ' . $this->sell_price . '. TransactionID =' . $result[2];
+ if (preg_match('/\-/', $modelSendCreditRates->idProduct->product)) {
+ $this->modelTransferToMobile->product = $_POST['TransferToMobile']['amountValuesBDT'];
+ }
+ $this->received_amout = $this->modelTransferToMobile->product;
+ $description = 'Send Credit ' . $this->local_currency . ' ' . $this->modelTransferToMobile->product . ' - +' . $this->number . ' via ' . $this->operator_name . ' - EUR ' . number_format($this->sell_price, 2);
if (isset($_POST['TransferToMobile']['metric']) && strlen($_POST['TransferToMobile']['metric'])) {
$description .= ' - Meter ' . $_POST['TransferToMobile']['metric'];
- # code...
}
+ } elseif ($modelSendCreditRates->idProduct->provider == 'Ding') {
+
+ if (preg_match('/\-/', $modelSendCreditRates->idProduct->product)) {
+ $this->modelTransferToMobile->product = $_POST['TransferToMobile']['amountValuesBDT'];
+ }
+ $this->received_amout = $this->modelTransferToMobile->product;
+ $description = 'Send Credit ' . $this->local_currency . ' ' . $this->modelTransferToMobile->product . ' - +' . $this->number . ' via ' . $this->operator_name . ' - EUR ' . number_format($this->sell_price, 2);
+ } elseif ($modelSendCreditRates->idProduct->provider == 'Reload') {
+
+ if (preg_match('/\-/', $modelSendCreditRates->idProduct->product)) {
+ $this->modelTransferToMobile->product = $_POST['TransferToMobile']['amountValuesBDT'];
+ }
+ $this->received_amout = $this->modelTransferToMobile->product;
+ $description = 'Send Credit ' . $this->local_currency . ' ' . $this->modelTransferToMobile->product . ' - +' . $this->number . ' via ' . $this->operator_name . ' - EUR ' . number_format($this->sell_price, 2);
} else {
- $description = 'Send Credit ' . $this->local_currency . ' ' . $this->modelTransferToMobile->product . ' - +' . $this->number . ' via ' . $this->operator_name . ' - EUR ' . $this->sell_price;
+ $this->received_amout = $this->modelTransferToMobile->product;
+ $description = 'Send Credit ' . $this->local_currency . ' ' . $this->modelTransferToMobile->product . ' - +' . $this->number . ' via ' . $this->operator_name . ' - EUR ' . number_format($this->sell_price, 2);
+ }
+
+ if ($modelSendCreditRates->idProduct->provider == 'Ding') {
+ $description .= '. DG';
+ } else if ($modelSendCreditRates->idProduct->provider == 'Reload') {
+ $description .= '. RL';
+ } else if ($modelSendCreditRates->idProduct->provider == 'TanaSend') {
+ $description .= '. TS';
+ } else if ($modelSendCreditRates->idProduct->provider == 'Orange2') {
+ $description .= '. OR';
+ } else if ($modelSendCreditRates->idProduct->provider == 'TransferTo') {
+ $description .= '. DO';
}
if ($this->test == true) {
echo $description;
}
+ User::model()->updateByPk(Yii::app()->session['id_user'],
+ array(
+ 'credit' => new CDbExpression('credit - ' . $this->user_cost),
+ )
+ );
+
$payment = 1;
$values = ":id_user, :costUser, :description, $payment";
$field = 'id_user,credit,description,payment';
@@ -499,17 +544,15 @@ public function releaseCredit($result, $status)
$command = Yii::app()->db->createCommand($sql);
$command->bindValue(":id_user", Yii::app()->session['id_user'], PDO::PARAM_INT);
$command->bindValue(":costUser", $this->user_cost * -1, PDO::PARAM_STR);
- $command->bindValue(":description", $description, PDO::PARAM_STR);
+ $command->bindValue(":description", $description . ' Old credit ' . $modelUserOld->credit, PDO::PARAM_STR);
$command->execute();
- $msg = $result[1];
- if ($result[1] == 'Orange2') {
- $msg = $result[0] . "
TransactionID " . $result[2];
- }
+ $msg = "
Transaction successful";
+
echo '
';
if ($this->test == true) {
@@ -517,13 +560,14 @@ public function releaseCredit($result, $status)
}
if ($this->modelTransferToMobile->id_user > 1) {
- if ($status != 'error') {
- $sql = "UPDATE pkg_user SET credit = credit - :costAgent WHERE id = :id";
- $command = Yii::app()->db->createCommand($sql);
- $command->bindValue(":id", $this->modelTransferToMobile->id_user, PDO::PARAM_INT);
- $command->bindValue(":costAgent", $this->agent_cost, PDO::PARAM_STR);
- $command->execute();
- }
+
+ $modelAgentOld = User::model()->findByPk($this->modelTransferToMobile->id_user);
+
+ User::model()->updateByPk($this->modelTransferToMobile->id_user,
+ array(
+ 'credit' => new CDbExpression('credit - ' . $this->agent_cost),
+ )
+ );
$payment = 1;
$values = ":id_user, :costAgent, :description, $payment";
@@ -540,7 +584,7 @@ public function releaseCredit($result, $status)
$command = Yii::app()->db->createCommand($sql);
$command->bindValue(":id_user", $this->modelTransferToMobile->id_user, PDO::PARAM_INT);
$command->bindValue(":costAgent", $this->agent_cost * -1, PDO::PARAM_STR);
- $command->bindValue(":description", $description, PDO::PARAM_STR);
+ $command->bindValue(":description", $description . ' Old credit ' . $modelAgentOld->credit, PDO::PARAM_STR);
$command->execute();
if ($this->test == true) {
@@ -584,6 +628,7 @@ public function actionMsisdn_info()
//request provider code to ding and chech if exist products to Ding
$operatorid = SendCreditDingConnect::getProviderCode($this->number);
}
+
//find products whit trasnferto operatorid
$modelSendCreditProducts = SendCreditProducts::model()->findAll('operator_id = :key AND status = 1', array(':key' => $operatorid));
@@ -643,7 +688,7 @@ public function actionMsisdn_info()
if ($this->test == true) {
echo $product->id . ' -> ' . $product->currency_dest . ' ' . $product->product . ' = ' . $product->currency_orig . ' ' . trim($modelSendCreditRates[$i]->sell_price) . "
";
}
- $values[trim($product->id)] = '
' . $product->currency_dest . ' ' . trim($product->product) . ' =
' . $product->currency_orig . ' ' . trim($modelSendCreditRates[$i]->sell_price);
+ $values[trim($product->id)] = '
' . $product->currency_dest . ' ' . trim($product->product) . ' =
' . $product->currency_orig . ' ' . number_format(trim($modelSendCreditRates[$i]->sell_price), 2);
Yii::app()->session['is_interval'] = false;
} else {
Yii::app()->session['is_interval'] = true;
@@ -693,7 +738,7 @@ public function actionPrintRefill()
$number = explode(" ", $modelRefill->description);
- echo "Cellulare.: " . $number[5] . "
";
+ echo "
Cellulare.: " . $number[5] . "
";
if (preg_match('/Meter/', $modelRefill->description)) {
$tmp = explode('Meter', $modelRefill->description);
@@ -710,13 +755,15 @@ public function actionPrintRefill()
$tmp = explode(' -', $tmp[1]);
$product = $tmp[0];
- echo 'Prodotto: ' . $product . ' ' . $operator . "
";
+ echo $product . ' ' . $operator . "
";
- echo "Importo: EUR
";
+ echo "Importo: EUR
";
echo $config['global']['fm_transfer_print_footer'] . "
";
- echo '
Print | ';
+ echo '
Print | ';
+ echo '
Start new request | ';
+
echo '';
} else {
echo ' Invalid reffil';
@@ -731,12 +778,17 @@ public function actionGetProducts()
'params' => array(':key' => $_GET['operator']),
));
+ if (!isset($modelSendCreditProducts[0]->operator_id)) {
+ return;
+ }
+
$operatorId = $modelSendCreditProducts[0]->operator_id;
$ids_products = array();
foreach ($modelSendCreditProducts as $key => $products) {
$ids_products[] = $products->id;
}
+
//get the user prices to mount the amount combo
$criteria = new CDbCriteria();
$criteria->addInCondition('id_product', $ids_products);
@@ -749,20 +801,22 @@ public function actionGetProducts()
$i = 0;
?>
- $product): ?>
-
- product)): ?>
-
- session['is_interval'] = false;?>
-
-
-
+ $product):
+ // echo '
';
+ //print_r($product->getAttributes());?>
+
+ product)): ?>
+
+ session['is_interval'] = false;?>
+
+
+
session['is_interval'] = true;?>
session['interval_currency'] = $product->currency_dest;?>
diff --git a/protected/controllers/TransferMobileMoneyController.php b/protected/controllers/TransferMobileMoneyController.php
index d2b453d23..e3f9eac66 100755
--- a/protected/controllers/TransferMobileMoneyController.php
+++ b/protected/controllers/TransferMobileMoneyController.php
@@ -44,6 +44,8 @@ class TransferMobileMoneyController extends Controller
public $modelTransferToMobile = array();
public $operator_name;
private $number;
+ public $received_amout;
+
public function init()
{
@@ -78,10 +80,6 @@ public function actionIndex($asJson = true, $condition = null)
$this->number = $this->modelTransferToMobile->number = (int) $_POST['TransferToMobile']['number'];
- if (isset($this->number) && $this->number == '5551982464731') {
- $this->test = true;
- }
-
if (isset($this->number) && substr($this->number, 0, 2) == '00') {
$this->number = substr($this->number, 2);
}
@@ -105,8 +103,8 @@ public function actionIndex($asJson = true, $condition = null)
),
));
- $_POST['TransferToMobile']['amountValuesBDT'] = $modelSendCreditProducts->product;
- $_POST['TransferToMobile']['amountValuesEUR'] = $modelSendCreditRates->sell_price;
+ $_POST['TransferToMobile']['amountValuesBDT'] = !isset($_POST['TransferToMobile']['amountValuesBDT']) || $_POST['TransferToMobile']['amountValuesBDT'] == '' ? $modelSendCreditProducts->product : $_POST['TransferToMobile']['amountValuesBDT'];
+ $_POST['TransferToMobile']['amountValuesEUR'] = !isset($_POST['TransferToMobile']['amountValuesEUR']) || $_POST['TransferToMobile']['amountValuesEUR'] == '' ? $modelSendCreditRates->sell_price : $_POST['TransferToMobile']['amountValuesEUR'];
$_POST['TransferToMobile']['amountValues'] = $_POST['amountValues'];
} else {
$modelSendCreditRates = [];
@@ -145,10 +143,29 @@ public function actionIndex($asJson = true, $condition = null)
$methods = [];
- if ($this->modelTransferToMobile->transfer_bkash) {
+ $modelSendCreditProducts = SendCreditProducts::model()->findAll(array(
+ 'condition' => 'operator_name LIKE :key1 AND country = :key AND status = 1 AND type = :key2',
+ 'params' => array(
+ ':key' => $_POST['TransferToMobile']['country'],
+ ':key1' => '%Bkash%',
+ ':key2' => 'Mobile Money',
+ ),
+ ));
+
+ if (isset($modelSendCreditProducts[0]->id)) {
$methods["bkash"] = "Bkash";
}
- if ($this->modelTransferToMobile->transfer_dbbl_rocket) {
+
+ $modelSendCreditProducts = SendCreditProducts::model()->findAll(array(
+ 'condition' => 'operator_name LIKE :key1 AND country = :key AND status = 1 AND type = :key2',
+ 'params' => array(
+ ':key' => $_POST['TransferToMobile']['country'],
+ ':key1' => '%Rocket%',
+ ':key2' => 'Mobile Money',
+ ),
+ ));
+
+ if (isset($modelSendCreditProducts[0]->id)) {
$methods["dbbl_rocket"] = "DBBL/Rocket";
}
@@ -172,8 +189,28 @@ public function actionIndex($asJson = true, $condition = null)
$this->actionGetProducts();
- Yii::app()->session['allowedAmount'] = $values;
- $amountDetails = 'Amount (Min: ' . $values[0] . ' BDT, Max: ' . $values[1] . ' BDT)';
+ $modelSendCreditProducts = SendCreditProducts::model()->findAll(array(
+ 'condition' => 'operator_name LIKE :key1 AND country = :key AND status = 1 AND type = :key2 AND product LIKE "%-%" ',
+ 'params' => array(
+ ':key' => $_POST['TransferToMobile']['country'],
+ ':key1' => '%' . $_POST['TransferToMobile']['method'] . '%',
+ ':key2' => 'Mobile Money',
+ ),
+ ));
+
+ if (!isset($modelSendCreditProducts[0]->product)) {
+ exit('No products found');
+ }
+
+ if (isset($modelSendCreditProducts[0]->product)) {
+ $values = explode("-", $modelSendCreditProducts[0]->product);
+ $amountDetails = 'Amount (Min: ' . $values[0] . ' BDT, Max: ' . $values[1] . ' BDT)';
+ } else {
+ $amountDetails = '';
+ }
+
+ Yii::app()->session['allowedAmount'] = $values;
+
$view = 'selectAmount';
$this->modelTransferToMobile->country = $_POST['TransferToMobile']['country'];
} else {
@@ -181,6 +218,8 @@ public function actionIndex($asJson = true, $condition = null)
$this->modelTransferToMobile->country = $_POST['TransferToMobile']['country'];
}
+ //echo $view . "
";
+
$this->render($view, array(
'modelTransferToMobile' => $this->modelTransferToMobile,
'methods' => $methods,
@@ -192,12 +231,15 @@ public function actionIndex($asJson = true, $condition = null)
public function addInDataBase()
{
- $modelSendCreditSummary = new SendCreditSummary();
- $modelSendCreditSummary->id_user = Yii::app()->session['id_user'];
- $modelSendCreditSummary->service = $_POST['TransferToMobile']['method'];
- $modelSendCreditSummary->number = $this->number;
- $modelSendCreditSummary->confirmed = 0;
- $modelSendCreditSummary->cost = $this->user_cost;
+ $modelSendCreditSummary = new SendCreditSummary();
+ $modelSendCreditSummary->id_user = Yii::app()->session['id_user'];
+ $modelSendCreditSummary->service = 'Mobile Money';
+ $modelSendCreditSummary->number = $this->number;
+ $modelSendCreditSummary->confirmed = 0;
+ $modelSendCreditSummary->cost = $this->user_cost;
+ $modelSendCreditSummary->provider = 'TanaSend';
+ $modelSendCreditSummary->operator_name = $this->operator_name;
+ $modelSendCreditSummary->received_amout = 'BDT ' . $this->received_amout;
$modelSendCreditSummary->save();
$this->send_credit_id = $modelSendCreditSummary->id;
}
@@ -207,12 +249,13 @@ public function updateDataBase()
if ($this->sell_price > 0 && $this->user_cost > 0) {
- $profit = 'transfer_' . $_POST['TransferToMobile']['method'] . '_profit';
+ $profit = 'transfer_flexiload_profit';
SendCreditSummary::model()->updateByPk($this->send_credit_id, array(
- 'profit' => $this->modelTransferToMobile->{$profit},
- 'amount' => $this->cost,
- 'sell' => number_format($this->sell_price, 2),
- 'earned' => number_format($this->sell_price - $this->user_cost, 2),
+ 'profit' => $this->modelTransferToMobile->{$profit},
+ 'amount' => $this->cost,
+ 'sell' => number_format($this->sell_price, 2),
+ 'earned' => number_format($this->sell_price - $this->user_cost, 2),
+ 'received_amout' => 'BDT ' . $this->received_amout,
));
} else {
SendCreditSummary::model()->deleteByPk($this->send_credit_id);
@@ -247,42 +290,8 @@ public function sendActionTransferToMobile($action, $product = null)
),
);
- if ($this->test == true && preg_match('/topup/', $action)) {
- return $result = 'transactionid=662680426
-msisdn=number
-destination_msisdn=5551982464731
-country=Brazil
-countryid=691
-operator=Vivo Brazil
-operatorid=708
-reference_operator=55674
-originating_currency=EUR
-destination_currency=BRL
-product_requested=7
-actual_product_sent=7
-wholesale_price=2.40
-retail_price=2.40
-balance=1320.90
-sms_sent=yes
-sms=
-cid1=
-cid2=
-cid3=
-local_info_value=7
-local_info_amount=7
-local_info_currency=BRL
-authentication_key=1529417078
-error_code=0
-error_txt=Transaction successful';
- } else {
-
- if (!$result = @file_get_contents($url, false, stream_context_create($arrContextOptions))) {
- $result = '';
- }
- }
-
- if ($this->test == true) {
- //echo $url . "
";
+ if (!$result = @file_get_contents($url, false, stream_context_create($arrContextOptions))) {
+ $result = '';
}
return $result;
@@ -290,16 +299,22 @@ public function sendActionTransferToMobile($action, $product = null)
public function sendActionBDService()
{
- $type = $this->modelTransferToMobile->method == 'dbbl_rocket' ? 'DBBL' : $this->modelTransferToMobile->method;
+ $userBD = $this->config['global']['BDService_username'];
+ $keyBD = $this->config['global']['BDService_token'];
+ $type = $this->modelTransferToMobile->method == 'dbbl_rocket' ? 'DBBL' : $this->modelTransferToMobile->method;
- $url = $this->url . "/ezzeapi/request/" . $type . "?number=" . $this->modelTransferToMobile->number . "&amount=" . $_POST['TransferToMobile']['amountValuesBDT'] . "&type=1&id=" . $this->send_credit_id . "&user=" . $this->login . "&key=" . $this->token;
+ $number = preg_replace('/^00/', '', $this->modelTransferToMobile->number);
+ $number = preg_replace('/^88/', '', $number);
- if ($this->test == true) {
- $result = 'SUCCESS';
+ if ((isset($_POST['method']) && $_POST['method'] == 'bkash') || (isset($_POST['TransferToMobile']['method']) && $_POST['TransferToMobile']['method'] == 'bkash')) {
+ $url = "http://takasend.org/ezzeapi/request/bkash?number=" . $number . "&amount=" . $_POST['TransferToMobile']['amountValuesBDT'] . "&type=1&id=" . $this->send_credit_id . "&user=" . $userBD . "&key=" . $keyBD . "";
} else {
- if (!$result = @file_get_contents($url, false, stream_context_create($arrContextOptions))) {
- $result = '';
- }
+
+ $url = "http://takasend.org/ezzeapi/request/DBBL?number=" . $number . "&amount=" . $_POST['TransferToMobile']['amountValuesBDT'] . "&type=1&id=" . $this->send_credit_id . "&user=" . $userBD . "&key=" . $keyBD . "";
+ }
+
+ if (!$result = @file_get_contents($url, false, stream_context_create($arrContextOptions))) {
+ $result = '';
}
return $result;
@@ -308,13 +323,9 @@ public function sendActionBDService()
public function calculateCost($product = 0)
{
- $methosProfit = 'transfer_' . $_POST['TransferToMobile']['method'] . '_profit';
-
- if ($this->test == true) {
- echo "
" . 'cost=' . $this->cost . ' - prodict=' . $product . "
";
- }
+ $methosProfit = 'transfer_flexiload_profit';
- if ($this->modelTransferToMobile->credit + $this->modelTransferToMobile->creditlimit < $this->cost) {
+ if ($this->modelTransferToMobile->credit + $this->modelTransferToMobile->creditlimit < $this->user_cost) {
echo '
';
+ echo '';
exit;
}
- $user_profit = $this->modelTransferToMobile->{$methosProfit};
-
- $this->user_cost = $this->cost - ($this->cost * ($user_profit / 100));
-
- $this->user_profit = $this->cost * ($user_profit / 100);
+ if (isset(Yii::app()->session['is_interval']) && Yii::app()->session['is_interval'] == 1) {
+ // echo '$this->cost=' . $this->cost . "
";
+ //echo $_POST['TransferToMobile']['amountValuesBDT'] . "
";
- if ($this->test == true) {
- echo 'cost=' . $this->cost . ', user_profit= ' . $this->cost * ($this->user_profit / 100) . ' user_profit=' . $this->user_profit . "
";
+ $this->cost = $_POST['TransferToMobile']['amountValuesBDT'] * $this->cost;
+ $this->sell_price = $_POST['TransferToMobile']['amountValuesBDT'] * $this->sell_price;
}
+ // echo 'cost ' . $this->cost . "
";
+ // echo 'user_profit ' . $user_profit . "
";
+ $this->user_cost = $this->cost - ($this->cost * ($user_profit / 100));
+ // echo 'user_cost ' . $this->user_cost . "
";
+ $this->user_profit = $this->cost * ($user_profit / 100);
+ //exit;
if ($this->modelTransferToMobile->id_user > 1) {
//check if agent have credit
@@ -528,7 +642,7 @@ public function calculateCost($product = 0)
exit;
}
- $agentProfit = $modelAgent->{$methosProfit};
+ $agentProfit = $modelAgent->transfer_bkash_profit;
$this->agent_cost = $this->cost - ($this->cost * ($agentProfit / 100));
@@ -541,16 +655,40 @@ public function calculateCost($product = 0)
public function actionGetBuyingPrice()
{
- $currency = $this->config['global']['BDService_cambio'];
+ $currency = '€';
+
+ $user_profit = $this->modelTransferToMobile->transfer_bkash_profit;
+
+ if ($_GET['id'] > 0) {
+
+ $modelSendCreditProducts = SendCreditProducts::model()->findByPk((int) $_GET['id']);
+
+ $cost = $modelSendCreditProducts->wholesale_price;
+
+ $user_cost = $cost - ($cost * ($user_profit / 100));
+ echo $currency . ' ' . number_format($user_cost, 2);
+
+ } else {
+ $modelSendCreditProducts = SendCreditProducts::model()->findByPk((int) $_SESSION['interval_product_id']);
+
+ $cost = $_GET['valueAmoutBDT'] * $modelSendCreditProducts->wholesale_price;
+
+ $user_cost = $cost - ($cost * ($user_profit / 100));
+ echo $currency . ' ' . number_format($user_cost, 2);
+ }
+
+ }
+
+ public function actionGetBuyingPriceBill()
+ {
- $rateinitial = $this->modelTransferToMobile->transfer_bdservice_rate / 100 + 1;
- //cost to send to provider selected value + admin rate * exchange
- $cost = $_GET['amountValues'] * $rateinitial * $this->config['global']['BDService_cambio'];
- $product = 0;
$currency = '€';
- $methosProfit = 'transfer_' . $_GET['method'] . '_profit';
- $user_profit = $this->modelTransferToMobile->{$methosProfit};
+ $user_profit = $this->modelTransferToMobile->transfer_bkash_profit;
+
+ $modelSendCreditProducts = SendCreditProducts::model()->findByPk((int) $_SESSION['interval_product_id']);
+
+ $cost = $_GET['valueAmoutBDT'] * $modelSendCreditProducts->wholesale_price;
$user_cost = $cost - ($cost * ($user_profit / 100));
echo $currency . ' ' . number_format($user_cost, 2);
@@ -575,6 +713,8 @@ public function checkResult($result)
public function releaseCredit($result, $status)
{
+ $modelUserOld = User::model()->findByPk(Yii::app()->session['id_user']);
+
$result = explode("=", $result);
if ($this->test == true) {
@@ -601,25 +741,37 @@ public function releaseCredit($result, $status)
} else {
$description = '';
}
- //Send Credit BDT 150 to 01630593593 via flexiload at 2.25"
- $description .= 'Send Credit BDT ' . $this->modelTransferToMobile->amountValuesBDT . ' - ' . $this->modelTransferToMobile->number . ' via ' . $this->modelTransferToMobile->method . ' - EUR ' . $this->sell_price;
- if ($this->test == true) {
- echo $description;
+ if (isset($_POST['TransferToMobile']['meter'])) {
+ $this->received_amout = $this->modelTransferToMobile->amountValuesBDT;
+ //Send Credit BDT 150 to 01630593593 via flexiload at 2.25"
+ $description .= 'Send Credit ' . $this->local_currency . ' ' . $this->modelTransferToMobile->amountValuesBDT . ' - ' . $this->modelTransferToMobile->number . '- meter no. ' . $_POST['TransferToMobile']['meter'] . ' via ' . $_POST['TransferToMobile']['type'] . ' ' . $_POST['TransferToMobile']['country'] . ' - EUR ' . number_format($this->sell_price, 2);
+
+ } else {
+ $this->received_amout = $this->modelTransferToMobile->bill_amount;
+ $description .= 'Send Credit ' . $this->local_currency . ' ' . $this->modelTransferToMobile->bill_amount . ' - ' . $this->modelTransferToMobile->phone . '- bill no. ' . $_POST['TransferToMobile']['number'] . ' - date ' . $_POST['TransferToMobile']['creationdate'] . ' via ' . $_POST['TransferToMobile']['type'] . ' ' . $_POST['TransferToMobile']['country'] . ' - EUR ' . number_format($this->sell_price, 2);
}
+ //echo "description = $description
";
+ //echo "user_cost = $this->user_cost
send_credit_id";
- $field = 'id_user,credit,description,payment,invoice_number';
+ User::model()->updateByPk(Yii::app()->session['id_user'],
+ array(
+ 'credit' => new CDbExpression('credit - ' . $this->user_cost),
+ )
+ );
+
+ $payment = 1;
+ $values = ":id_user, :costUser, :description, $payment";
+ $field = 'id_user,credit,description,payment';
$sql = "INSERT INTO pkg_refill ($field) VALUES ($values)";
$command = Yii::app()->db->createCommand($sql);
$command->bindValue(":id_user", Yii::app()->session['id_user'], PDO::PARAM_INT);
$command->bindValue(":costUser", $this->user_cost * -1, PDO::PARAM_STR);
- $command->bindValue(":description", $description, PDO::PARAM_STR);
+ $command->bindValue(":description", $description . '. OR Old credit ' . $modelUserOld->credit, PDO::PARAM_STR);
$command->execute();
- $msg = $result[1] . "
TransactionID " . $result[3];
+ $msg = $result[1];
echo '';
echo '
Success: ' . $msg . '' . "
";
@@ -633,13 +785,18 @@ public function releaseCredit($result, $status)
if ($this->modelTransferToMobile->id_user > 1) {
- $payment = 0;
+ $modelAgentOld = User::model()->findByPk($this->modelTransferToMobile->id_user);
+
+ User::model()->updateByPk($this->modelTransferToMobile->id_user,
+ array(
+ 'credit' => new CDbExpression('credit - ' . $this->agent_cost),
+ )
+ );
+
+ $payment = 1;
$values = ":id_user, :costAgent, :description, $payment";
$field = 'id_user,credit,description,payment';
- $values .= ",$this->send_credit_id";
- $field .= ',invoice_number';
-
if ($this->test == true) {
echo 'UPDATE AGENT CREDIT -> ' . $sql . "
";
}
@@ -648,7 +805,7 @@ public function releaseCredit($result, $status)
$command = Yii::app()->db->createCommand($sql);
$command->bindValue(":id_user", $this->modelTransferToMobile->id_user, PDO::PARAM_INT);
$command->bindValue(":costAgent", $this->agent_cost * -1, PDO::PARAM_STR);
- $command->bindValue(":description", $description, PDO::PARAM_STR);
+ $command->bindValue(":description", $description . '. OR Old credit ' . $modelAgentOld->credit, PDO::PARAM_STR);
$command->execute();
if ($this->test == true) {
@@ -658,56 +815,6 @@ public function releaseCredit($result, $status)
}
}
- public function actionPrintRefill()
- {
-
- if (isset($_GET['id'])) {
- echo '
';
- $config = LoadConfig::getConfig();
- $id_refill = $_GET['id'];
-
- $modelRefill = Refill::model()->findByPk((int) $id_refill, 'id_user = :key', array(':key' => Yii::app()->session['id_user']));
-
- echo $config['global']['fm_transfer_print_header'] . "
";
-
- echo $modelRefill->idUser->company_name . "
";
- echo $modelRefill->idUser->address . ', ' . $modelRefill->idUser->city . "
";
- echo "Trx ID: " . $modelRefill->id . "
";
-
- echo $modelRefill->date . "
";
-
- $number = explode(" ", $modelRefill->description);
-
- echo "Cellulare.: " . $number[5] . "
";
-
- if (preg_match('/Meter/', $modelRefill->description)) {
- $tmp = explode('Meter', $modelRefill->description);
- echo 'Meter: ' . $tmp[1] . "
";
- }
-
- $tmp = explode('EUR ', $modelRefill->description);
- $tmp = explode('. T', $tmp[1]);
- $amount = $tmp[0];
-
- $tmp = explode('via ', $modelRefill->description);
- $operator = strtok($tmp[1], '-');
- $tmp = explode('Send Credit ', $modelRefill->description);
- $tmp = explode(' -', $tmp[1]);
- $product = $tmp[0];
-
- echo 'Prodotto: ' . $product . ' ' . $operator . "
";
-
- echo "Importo: EUR
";
-
- echo $config['global']['fm_transfer_print_footer'] . "
";
-
- echo 'Print | ';
- echo '';
- } else {
- echo ' Invalid reffil';
- }
- }
-
public function actionConvertCurrency()
{
$method = 'Payment';
@@ -755,7 +862,9 @@ public function actionConvertCurrency()
),
));
- echo $amount = number_format(($amountEUR - $modelSendCreditRates->sell_price) / $modelSendCreditProducts[0]->wholesale_price, 0, '', '');
+ echo $amount = number_format($amountEUR / $modelSendCreditRates->sell_price, 0, '', '');
+ Yii::app()->session['sell_price'] = $amount;
+ Yii::app()->session['id_product'] = $product->id;
} else {
/*
@@ -784,7 +893,7 @@ public function actionConvertCurrency()
),
));
- echo $amount = number_format(($amountBDT * $product->wholesale_price) + $modelSendCreditRates->sell_price, 2);
+ echo $amount = number_format($amountBDT * $modelSendCreditRates->sell_price, 2);
Yii::app()->session['sell_price'] = $amount;
Yii::app()->session['id_product'] = $product->id;
}
@@ -804,4 +913,13 @@ public function actionCheckNumber($value = '')
}
}
+ public function actionGetProductTax()
+ {
+
+ $modelSendCreditProducts = SendCreditProducts::model()->findByPk((int) $_GET['id']);
+
+ Yii::app()->session['product_id'] = $_GET['id'];
+ echo $modelSendCreditProducts->info;
+ }
+
}
diff --git a/protected/controllers/TransferToMobileController copy.php b/protected/controllers/TransferToMobileController copy.php
new file mode 100755
index 000000000..95af14f27
--- /dev/null
+++ b/protected/controllers/TransferToMobileController copy.php
@@ -0,0 +1,981 @@
+
+ *
+ */
+
+/*
+add the cron to check the BDService transaction status
+echo "
+ * * * * * php /var/www/html/mbilling/cron.php bdservice
+" >> /var/spool/cron/root
+ */
+
+class TransferToMobileController extends Controller
+{
+ private $url;
+ private $amounts = 0;
+ private $user_cost = 0;
+ private $agent_cost = 0;
+ private $login;
+ private $token;
+ private $currency;
+ private $send_credit_id;
+ private $user_profit;
+ private $test = false;
+ private $cost;
+ private $showprice;
+ private $sell_price;
+ private $local_currency;
+ public $modelTransferToMobile = array();
+ public $operator_name;
+
+ public function init()
+ {
+
+ if (isset($_POST['TransferToMobile']['number']) && $_POST['TransferToMobile']['number'] == '5551982464731') {
+ $this->test = true;
+ }
+
+ if (isset($_POST['TransferToMobile']['number']) && substr($_POST['TransferToMobile']['number'], 0, 2) == '00') {
+ $_POST['TransferToMobile']['number'] = substr($_POST['TransferToMobile']['number'], 2);
+ }
+
+ $this->instanceModel = new User;
+ $this->abstractModel = User::model();
+ parent::init();
+
+ if (isset($_POST['TransferToMobile']['method'])) {
+
+ if ($_POST['TransferToMobile']['method'] == 'international') {
+ $this->login = $this->config['global']['fm_transfer_to_username'];
+ $this->token = $this->config['global']['fm_transfer_to_ token'];
+ $this->currency = $this->config['global']['fm_transfer_currency'];
+ $this->url = 'https://fm.transfer-to.com/cgi-bin/shop/topup?';
+ } else {
+ $this->login = $this->config['global']['BDService_username'];
+ $this->token = $this->config['global']['BDService_token'];
+ $this->currency = $this->config['global']['BDService_cambio'];
+ $this->url = $this->config['global']['BDService_url'];
+ }
+ }
+
+ $this->modelTransferToMobile = TransferToMobile::model()->findByPk((int) Yii::app()->session['id_user']);
+ }
+
+ public function actionRead($asJson = true, $condition = null)
+ {
+ if (isset($_POST['amountValues'])) {
+ $_POST['TransferToMobile']['amountValues'] = $_POST['amountValues'];
+ }
+ //if we already request the number info, check if select a valid amount
+ if (isset($_POST['TransferToMobile']['amountValues']) || isset($_POST['TransferToMobile']['amountValuesEUR'])) {
+
+ $this->modelTransferToMobile->method = $_POST['TransferToMobile']['method'];
+ $this->modelTransferToMobile->number = $_POST['TransferToMobile']['number'];
+ if ($this->modelTransferToMobile->method == 'international') {
+ $this->modelTransferToMobile->country = $_POST['TransferToMobile']['country'];
+ $this->modelTransferToMobile->operator = $_POST['TransferToMobile']['operator'];
+ }
+ if ($this->modelTransferToMobile->method == 'international') {
+
+ if (isset($_POST['TransferToMobile']['amountValuesBDT'])) {
+ $this->modelTransferToMobile->amountValues = Yii::app()->session['interval_product_id'];
+ $_POST['TransferToMobile']['amountValues'] = Yii::app()->session['interval_product_id'];
+ } else {
+ $this->modelTransferToMobile->amountValues = $_POST['TransferToMobile']['amountValues'];
+ }
+
+ }
+
+ if ($this->modelTransferToMobile->method != 'international') {
+ //check min max
+ $min = Yii::app()->session['allowedAmount'][0];
+ $max = Yii::app()->session['allowedAmount'][1];
+ // echo '
';
+
+ if ($_POST['TransferToMobile']['amountValuesBDT'] < $min) {
+ $this->modelTransferToMobile->addError('amountValuesBDT', Yii::t('zii', 'Amount is < then minimal allowed'));
+
+ } else if ($_POST['TransferToMobile']['amountValuesBDT'] > $max) {
+ $this->modelTransferToMobile->addError('amountValuesBDT', Yii::t('zii', 'Amount is > then maximum allowed'));
+ }
+ $this->modelTransferToMobile->amountValuesEUR = $_POST['TransferToMobile']['amountValuesEUR'];
+ $this->modelTransferToMobile->amountValuesBDT = $_POST['TransferToMobile']['amountValuesBDT'];
+
+ }
+
+ if ($this->modelTransferToMobile->method != 'international' && preg_match('/[A-Z][a-z]/', $_POST['TransferToMobile']['amountValuesBDT'])) {
+ $this->modelTransferToMobile->addError('amountValuesBDT', Yii::t('zii', 'Invalid amount'));
+ } elseif ($this->modelTransferToMobile->method == 'international' && !is_numeric($_POST['TransferToMobile']['amountValues'])) {
+ $this->modelTransferToMobile->addError('amountValues', Yii::t('zii', 'Invalid amount'));
+ } elseif (!count($this->modelTransferToMobile->getErrors())) {
+
+ if (!isset($_POST['TransferToMobile']['confirmed'])) {
+
+ if ($this->modelTransferToMobile->method == 'international') {
+
+ $modelSendCreditRates = SendCreditRates::model()->find(array(
+ 'condition' => 'id_user = :key',
+ 'params' => array(
+ ':key' => Yii::app()->session['id_user'],
+ ':key1' => $_POST['TransferToMobile']['amountValues'],
+ ),
+ 'with' => array(
+ 'idProduct' => array(
+ 'condition' => 'idProduct.id = :key1',
+ ),
+ ),
+ ));
+ $this->render('confirmInternational', array(
+ 'modelTransferToMobile' => $this->modelTransferToMobile,
+ 'modelSendCreditRates' => $modelSendCreditRates,
+ 'post' => $_POST,
+ ));
+ } else {
+ $this->render('confirmBDService', array(
+ 'modelTransferToMobile' => $this->modelTransferToMobile,
+ ));
+ }
+
+ exit;
+ } else {
+ $this->confirmRefill();
+ }
+
+ }
+
+ }
+ //check the number and methods.
+ elseif (isset($_POST['TransferToMobile']['method'])) {
+ if ($_POST['TransferToMobile']['method'] == '') {
+ $this->modelTransferToMobile->addError('method', Yii::t('zii', 'Please select a method'));
+ }
+
+ if ($_POST['TransferToMobile']['number'] == '' || !is_numeric($_POST['TransferToMobile']['number'])
+ || strlen($_POST['TransferToMobile']['number']) < 8
+ || preg_match('/ /', $_POST['TransferToMobile']['number'])) {
+ $this->modelTransferToMobile->addError('number', Yii::t('zii', 'Number invalid, try again'));
+ }
+
+ $this->modelTransferToMobile->method = $_POST['TransferToMobile']['method'];
+ $this->modelTransferToMobile->number = $_POST['TransferToMobile']['number'];
+
+ if ($_POST['TransferToMobile']['method'] == 'international') {
+ //if ok, request number information
+ if (!count($this->modelTransferToMobile->getErrors())) {
+ $this->actionMsisdn_info();
+ }
+ }
+ }
+
+ $methods = [];
+ if ($this->modelTransferToMobile->transfer_international) {
+ $methods["international"] = "International";
+ }
+ if ($this->modelTransferToMobile->transfer_flexiload) {
+ $methods["flexiload"] = "Flexiload";
+ }
+ if ($this->modelTransferToMobile->transfer_bkash) {
+ $methods["bkash"] = "Bkash";
+ }
+ if ($this->modelTransferToMobile->transfer_dbbl_rocket) {
+ $methods["dbbl_rocket"] = "DBBL/Rocket";
+ }
+
+ $view = !isset($_POST['TransferToMobile']['method']) || $_POST['TransferToMobile']['method'] == 'international' ? 'transferToMobile' : 'bDService';
+
+ $amountDetails = null;
+
+ if (isset($_POST['TransferToMobile']['method']) && strlen($_POST['TransferToMobile']['method']) && $_POST['TransferToMobile']['method'] != 'international') {
+
+ if ($_POST['TransferToMobile']['method'] == 'flexiload') {
+ $values = explode("-", $this->config['global']['BDService_flexiload']);
+ } elseif ($_POST['TransferToMobile']['method'] == 'dbbl_rocket') {
+ $values = explode("-", $this->config['global']['BDService_dbbl_rocket']);
+ } elseif ($_POST['TransferToMobile']['method'] == 'bkash') {
+ $values = explode("-", $this->config['global']['BDService_bkash']);
+ }
+ Yii::app()->session['allowedAmount'] = $values;
+ $amountDetails = 'Amount (Min: ' . $values[0] . ' BDT, Max: ' . $values[1] . ' BDT)';
+
+ }
+ if (count($methods)) {
+ $this->render($view, array(
+ 'modelTransferToMobile' => $this->modelTransferToMobile,
+ 'methods' => $methods,
+ 'amountDetails' => $amountDetails,
+ ));
+ } else {
+ echo '';
+ echo 'Not available any refill method for you';
+ echo '
';
+ exit;
+ }
+
+ }
+
+ public function addInDataBase()
+ {
+ $modelSendCreditSummary = new SendCreditSummary();
+ $modelSendCreditSummary->id_user = Yii::app()->session['id_user'];
+ $modelSendCreditSummary->service = $_POST['TransferToMobile']['method'];
+ $modelSendCreditSummary->number = $_POST['TransferToMobile']['number'];
+ $modelSendCreditSummary->confirmed = $_POST['TransferToMobile']['method'] == 'international' ? 1 : 0;
+ $modelSendCreditSummary->cost = $this->user_cost;
+ $modelSendCreditSummary->save();
+ $this->send_credit_id = $modelSendCreditSummary->id;
+ }
+
+ public function updateDataBase()
+ {
+
+ if ($this->sell_price > 0 && $this->user_cost > 0) {
+
+ $profit = 'transfer_' . $_POST['TransferToMobile']['method'] . '_profit';
+ SendCreditSummary::model()->updateByPk($this->send_credit_id, array(
+ 'profit' => $this->modelTransferToMobile->{$profit},
+ 'amount' => $this->cost,
+ 'sell' => number_format($this->sell_price, 2),
+ 'earned' => number_format($this->sell_price - $this->user_cost, 2),
+ ));
+ } else {
+ SendCreditSummary::model()->deleteByPk($this->send_credit_id);
+ }
+ }
+
+ public function sendActionTransferToMobile($action, $product = null)
+ {
+
+ $number = $this->modelTransferToMobile->number;
+ $key = time();
+ $md5 = md5($this->login . $this->token . $key);
+
+ if ($action == 'topup') {
+ $modelSendCreditProducts = SendCreditProducts::model()->find(array(
+ 'condition' => 'operator_name = :key AND product = :key1',
+ 'params' => array(
+ ':key' => $this->modelTransferToMobile->operator,
+ ':key1' => $product,
+ ),
+ ));
+ $this->url = "https://airtime.transferto.com/cgi-bin/shop/topup?";
+ $action .= '&msisdn=number&delivered_amount_info=1&product=' . $product . '&operatorid=' . $modelSendCreditProducts->operator_id . '&sms_sent=yes';
+ }
+
+ $url = $this->url . "login=" . $this->login . "&key=$key&md5=$md5&destination_msisdn=$number&action=" . $action;
+
+ $arrContextOptions = array(
+ "ssl" => array(
+ "verify_peer" => false,
+ "verify_peer_name" => false,
+ ),
+ );
+
+ if ($this->test == true && preg_match('/topup/', $action)) {
+ return $result = 'transactionid=662680426
+msisdn=number
+destination_msisdn=5551982464731
+country=Brazil
+countryid=691
+operator=Vivo Brazil
+operatorid=708
+reference_operator=55674
+originating_currency=EUR
+destination_currency=BRL
+product_requested=7
+actual_product_sent=7
+wholesale_price=2.40
+retail_price=2.40
+balance=1320.90
+sms_sent=yes
+sms=
+cid1=
+cid2=
+cid3=
+local_info_value=7
+local_info_amount=7
+local_info_currency=BRL
+authentication_key=1529417078
+error_code=0
+error_txt=Transaction successful';
+ } else {
+
+ if (!$result = @file_get_contents($url, false, stream_context_create($arrContextOptions))) {
+ $result = '';
+ }
+ }
+
+ if ($this->test == true) {
+ //echo $url . "
";
+ }
+
+ return $result;
+ }
+ public function sendActionBDService()
+ {
+
+ $type = $this->modelTransferToMobile->method == 'dbbl_rocket' ? 'DBBL' : $this->modelTransferToMobile->method;
+
+ $url = $this->url . "/ezzeapi/request/" . $type . "?number=" . $this->modelTransferToMobile->number . "&amount=" . $_POST['TransferToMobile']['amountValuesBDT'] . "&type=1&id=" . $this->send_credit_id . "&user=" . $this->login . "&key=" . $this->token;
+
+ if ($this->test == true) {
+ $result = 'SUCCESS';
+ } else {
+ if (!$result = @file_get_contents($url, false, stream_context_create($arrContextOptions))) {
+ $result = '';
+ }
+ }
+
+ return $result;
+ }
+
+ public function calculateCost($product = 0)
+ {
+
+ $methosProfit = 'transfer_' . $_POST['TransferToMobile']['method'] . '_profit';
+
+ if ($this->test == true) {
+ echo "
" . 'cost=' . $this->cost . ' - prodict=' . $product . "
";
+ }
+
+ if ($this->modelTransferToMobile->credit + $this->modelTransferToMobile->creditlimit < $this->cost) {
+
+ echo '';
+ exit;
+ }
+
+ $user_profit = $this->modelTransferToMobile->{$methosProfit};
+
+ $this->user_cost = $this->cost - ($this->cost * ($user_profit / 100));
+
+ $this->user_profit = $this->cost * ($user_profit / 100);
+
+ if ($this->test == true) {
+ echo 'cost=' . $this->cost . ', user_profit= ' . $this->cost * ($this->user_profit / 100) . ' user_profit=' . $this->user_profit . "
";
+ }
+
+ if ($this->modelTransferToMobile->id_user > 1) {
+
+ //check if agent have credit
+
+ $modelAgent = User::model()->findByPk($this->modelTransferToMobile->id_user);
+
+ if ($modelAgent->credit + $modelAgent->creditlimit < $this->cost) {
+
+ echo '';
+ exit;
+ }
+
+ $agentProfit = $modelAgent->{$methosProfit};
+
+ $this->agent_cost = $this->cost - ($this->cost * ($agentProfit / 100));
+
+ if ($this->test == true) {
+ echo 'agentProfit=' . $agentProfit . ' | $this->agent_cost=' . $this->agent_cost . "
";
+ }
+ }
+ }
+
+ public function actionGetBuyingPrice()
+ {
+
+ if ($_GET['method'] == 'international') {
+ $currency = $this->config['global']['fm_transfer_currency'];
+ } else {
+ $currency = $this->config['global']['BDService_cambio'];
+ }
+
+ if ($_GET['method'] == 'international') {
+
+ $modelSendCreditProducts = SendCreditProducts::model()->findByPk((int) $_GET['id']);
+
+ Yii::app()->session['operatorId'] = $modelSendCreditProducts->operator_id;
+
+ $cost = $modelSendCreditProducts->wholesale_price;
+ } else {
+
+ $rateinitial = $this->modelTransferToMobile->transfer_bdservice_rate / 100 + 1;
+ //cost to send to provider selected value + admin rate * exchange
+ $cost = $_GET['amountValues'] * $rateinitial * $this->config['global']['BDService_cambio'];
+ $product = 0;
+ $currency = '€';
+ }
+
+ $methosProfit = 'transfer_' . $_GET['method'] . '_profit';
+ $user_profit = $this->modelTransferToMobile->{$methosProfit};
+
+ $user_cost = $cost - ($cost * ($user_profit / 100));
+ echo $currency . ' ' . number_format($user_cost, 2);
+
+ }
+
+ public function confirmRefill()
+ {
+ /*print_r($_POST['TransferToMobile']);
+ exit;*/
+
+ if ($_POST['TransferToMobile']['method'] == 'international') {
+ $product = $_POST['TransferToMobile']['amountValues']; //is the amout to refill
+
+ $modelSendCreditRates = SendCreditRates::model()->find(array(
+ 'condition' => 'id_user = :key',
+ 'params' => array(
+ ':key' => Yii::app()->session['id_user'],
+ ':key1' => $_POST['TransferToMobile']['amountValues'],
+ ),
+ 'with' => array(
+ 'idProduct' => array(
+ 'condition' => 'idProduct.id = :key1',
+ ),
+ ),
+ ));
+
+ if (!isset($modelSendCreditRates->id)) {
+
+ echo '';
+ echo Yii::app()->session['id_user'] . ' ' . $product . ' ' . Yii::app()->session['operatorId'] . "
";
+ echo '
ERROR: 413';
+ echo '
Start new request ' . "
";
+ echo '
';
+ exit;
+ }
+
+ $this->sell_price = $modelSendCreditRates->sell_price;
+ $this->cost = $modelSendCreditRates->idProduct->wholesale_price;
+ $this->local_currency = $modelSendCreditRates->idProduct->currency_dest;
+ $this->operator_name = $modelSendCreditRates->idProduct->operator_name;
+ $this->modelTransferToMobile->product = $product = $modelSendCreditRates->idProduct->product;
+
+ } else {
+
+ $this->cost = $this->actionGetBuyingPriceDBService($_POST['TransferToMobile']['method'], $_POST['TransferToMobile']['amountValuesEUR'], $_POST['TransferToMobile']['amountValuesBDT']);
+ $product = 0;
+
+ }
+
+ $this->calculateCost($product);
+
+ $this->addInDataBase();
+
+ if ($this->test == true) {
+ echo "REMOVE " . $this->user_cost . " from user " . $this->modelTransferToMobile->username . "
";
+ }
+
+ if ($this->modelTransferToMobile->method == 'international') {
+
+ if ($modelSendCreditRates->idProduct->provider == 'Ding') {
+ $result = SendCreditDingConnect::sendCredit($_POST['TransferToMobile']['number'], $modelSendCreditRates->idProduct->send_value, $modelSendCreditRates->idProduct->SkuCode, $this->test);
+ } else if ($modelSendCreditRates->idProduct->provider == 'Orange2') {
+ $result = SendCreditOrange2::sendCredit($_POST['TransferToMobile']['number'], $modelSendCreditRates, $this->test);
+ } else {
+ $result = $this->sendActionTransferToMobile('topup', $product);
+ }
+
+ } else {
+ $result = $this->sendActionBDService($this->modelTransferToMobile);
+ }
+
+ $this->checkResult($result);
+
+ $this->updateDataBase();
+ exit;
+
+ }
+
+ public function checkResult($result)
+ {
+
+ if ($this->modelTransferToMobile->method == 'international') {
+
+ $result = explode("error_txt=", $result);
+
+ if (preg_match("/Transaction successful/", $result[1])) {
+ $this->releaseCredit($result, '');
+
+ } else {
+ echo '';
+ exit;
+ }
+
+ } else {
+
+ if (strlen($result) < 1) {
+
+ $this->releaseCredit($result, 'error');
+ exit;
+ } else if (preg_match("/ERROR|error/", $result)) {
+ echo '';
+ exit;
+ } elseif (preg_match("/SUCCESS/", strtoupper($result))) {
+ $this->releaseCredit($result, '');
+
+ }
+
+ }
+ }
+
+ public function releaseCredit($result, $status)
+ {
+
+ if (preg_match('/Orange2/', $result[1])) {
+ $result = explode("=", $result[1]);
+ }
+
+ if ($this->modelTransferToMobile->method == 'international' && $status != 'error') {
+ User::model()->updateByPk(Yii::app()->session['id_user'],
+ array(
+ 'credit' => new CDbExpression('credit - ' . $this->user_cost),
+ )
+ );
+ }
+
+ if ($this->test == true) {
+ echo 'cost=' . $this->cost . '. user_cost=' . $this->user_cost . "
";
+ echo $this->modelTransferToMobile->transfer_show_selling_price . "
";
+ }
+
+ $argument = $this->modelTransferToMobile->transfer_show_selling_price;
+ if ($argument < 10) {
+ $fee = '1.0' . $argument;
+ } else {
+ $fee = '1.' . $argument;
+ }
+
+ if ($this->test == true) {
+ echo $fee . "
";
+ echo $this->modelTransferToMobile->transfer_show_selling_price;
+ }
+
+ $this->showprice = number_format($this->cost * $fee, 2);
+
+ if ($this->modelTransferToMobile->method == 'international') {
+
+ if ($result[1] == 'Orange2') {
+
+ $description = 'Send Credit ' . $this->local_currency . ' ' . $this->modelTransferToMobile->product . ' - +' . $this->modelTransferToMobile->number . ' via ' . $this->operator_name . ' - EUR ' . $this->sell_price . '. TransactionID =' . $result[2];
+
+ if (isset($_POST['TransferToMobile']['metric']) && strlen($_POST['TransferToMobile']['metric'])) {
+ $description .= ' - Meter ' . $_POST['TransferToMobile']['metric'];
+ # code...
+ }
+ } else {
+ $description = 'Send Credit ' . $this->local_currency . ' ' . $this->modelTransferToMobile->product . ' - +' . $this->modelTransferToMobile->number . ' via ' . $this->operator_name . ' - EUR ' . $this->sell_price;
+ }
+
+ } else {
+ if ($status == 'error') {
+ $description = 'PENDING: ';
+ } else {
+ $description = '';
+ }
+ //Send Credit BDT 150 to 01630593593 via flexiload at 2.25"
+ $description .= 'Send Credit BDT ' . $_POST['TransferToMobile']['amountValuesBDT'] . ' - ' . $this->modelTransferToMobile->number . ' via ' . $this->modelTransferToMobile->method . ' - EUR ' . $_POST['TransferToMobile']['amountValuesEUR'];
+ $this->sell_price = $_POST['TransferToMobile']['amountValuesEUR'];
+ }
+
+ if ($this->test == true) {
+ echo $description;
+ }
+
+ $payment = $this->modelTransferToMobile->method == 'international' ? 1 : 0;
+ $values = ":id_user, :costUser, :description, $payment";
+ $field = 'id_user,credit,description,payment';
+
+ // if ($this->modelTransferToMobile->method != 'international') {
+ $values .= "," . $this->send_credit_id;
+ $field .= ',invoice_number';
+ // }
+
+ $sql = "INSERT INTO pkg_refill ($field) VALUES ($values)";
+ $command = Yii::app()->db->createCommand($sql);
+ $command->bindValue(":id_user", Yii::app()->session['id_user'], PDO::PARAM_INT);
+ $command->bindValue(":costUser", $this->user_cost * -1, PDO::PARAM_STR);
+ $command->bindValue(":description", $description, PDO::PARAM_STR);
+ $command->execute();
+
+ $msg = $this->modelTransferToMobile->method == 'international' ? $result[1] : $result;
+ if ($result[1] == 'Orange2') {
+ $msg = $result[0] . "
TransactionID " . $result[2];
+ }
+ echo '';
+
+ if ($this->test == true) {
+ echo $sql . "
";
+ }
+
+ if ($this->modelTransferToMobile->id_user > 1) {
+ if ($this->modelTransferToMobile->method == 'international' && $status != 'error') {
+ $sql = "UPDATE pkg_user SET credit = credit - :costAgent WHERE id = :id";
+ $command = Yii::app()->db->createCommand($sql);
+ $command->bindValue(":id", $this->modelTransferToMobile->id_user, PDO::PARAM_INT);
+ $command->bindValue(":costAgent", $this->agent_cost, PDO::PARAM_STR);
+ $command->execute();
+ }
+
+ $payment = $this->modelTransferToMobile->method == 'international' ? 1 : 0;
+ $values = ":id_user, :costAgent, :description, $payment";
+ $field = 'id_user,credit,description,payment';
+
+ //if ($modelTransferToMobile->method != 'international') {
+ $values .= ",$this->send_credit_id";
+ $field .= ',invoice_number';
+ //}
+
+ if ($this->test == true) {
+ echo 'UPDATE AGENT CREDIT -> ' . $sql . "
";
+ }
+
+ $sql = "INSERT INTO pkg_refill ($field) VALUES ($values)";
+ $command = Yii::app()->db->createCommand($sql);
+ $command->bindValue(":id_user", $this->modelTransferToMobile->id_user, PDO::PARAM_INT);
+ $command->bindValue(":costAgent", $this->agent_cost * -1, PDO::PARAM_STR);
+ $command->bindValue(":description", $description, PDO::PARAM_STR);
+ $command->execute();
+
+ if ($this->test == true) {
+ echo 'INSERT AGENT REFILL -> ' . $sql . "
";
+ }
+
+ }
+ }
+
+ public function actionMsisdn_info()
+ {
+
+ if (isset($_POST['TransferToMobile']['number'])) {
+
+ $number = $_POST['TransferToMobile']['number'];
+
+ $number = preg_match("/\+/", $number) ? $number : '+' . $number;
+
+ if (isset($this->config['global']['fm_transfer_to_username'])) {
+
+ $modelRefill = Refill::model()->find('description LIKE :key AND date BETWEEN :key1 AND NOW() AND payment = 1 AND id_user = :key2',
+ array(
+ ':key' => "%" . $number . "%",
+ ':key1' => date('Y-m-d H:i', mktime(date('H'), date('i') - 10, date('s'), date('m'), date('d'), date('Y'))),
+ ':key2' => Yii::app()->session['id_user'],
+ ));
+ if (isset($modelRefill->id)) {
+ echo '';
+ echo "You already send credit to this number. Wait minimal 10 minutes to new recharge";
+ echo '
';
+ exit;
+ }
+
+ $result = $this->sendActionTransferToMobile('msisdn_info');
+ //print_r($result);
+ if (preg_match("/Transaction successful/", $result)) {
+ $resultArray = explode("\n", $result);
+ $tmp = explode('=', $resultArray[3]);
+ $operatorid = trim(end($tmp));
+ } else {
+ //echo "Not foun product from TrasnferRo, try ding";
+ //request provider code to ding and chech if exist products to Ding
+ $operatorid = SendCreditDingConnect::getProviderCode($_POST['TransferToMobile']['number']);
+ }
+ //find products whit trasnferto operatorid
+ $modelSendCreditProducts = SendCreditProducts::model()->findAll('operator_id = :key AND status = 1', array(':key' => $operatorid));
+
+ if (!count($modelSendCreditProducts)) {
+
+ //not receive Operator ID FROM API. API OFF LINE. GET operator from country_code
+ $numberFormate = $_POST['TransferToMobile']['number'];
+ $numberFormate = substr($numberFormate, 0, 2) == '00' ? substr($numberFormate, 2) : $numberFormate;
+ $modelSendCreditProducts = SendCreditProducts::model()->findAll('country_code = SUBSTRING(:key,1,length(country_code)) AND status = 1',
+ array(
+ ':key' => $numberFormate,
+ ));
+ $forceOperatorSelect = true;
+ // echo $modelSendCreditProducts[0]->id . ' ' . $modelSendCreditProducts[0]->country_code;
+
+ }
+
+ if (!isset($modelSendCreditProducts[0])) {
+
+ echo '';
+ echo "
ERROR. No exist product to this number. Contact admin";
+ echo '
Start new request ' . "
";
+ echo '
';
+ exit;
+ }
+
+ $modelSendCreditProducts = SendCreditProducts::model()->findAll('status = 1 AND operator_name = :key AND country_code =:key1',
+ array(
+ ':key' => $modelSendCreditProducts[0]->operator_name,
+ ':key1' => $modelSendCreditProducts[0]->country_code,
+ ));
+
+ $ids_products = array();
+ foreach ($modelSendCreditProducts as $key => $products) {
+ $ids_products[] = $products->id;
+ }
+ //get the user prices to mount the amount combo
+ $criteria = new CDbCriteria();
+ $criteria->addInCondition('id_product', $ids_products);
+ $criteria->addCondition('id_user = :key');
+ $criteria->params[':key'] = Yii::app()->session['id_user'];
+
+ $modelSendCreditRates = SendCreditRates::model()->findAll($criteria);
+
+ if (!count($modelSendCreditRates)) {
+ exit('Before send credit, you need add your sell price');
+ }
+
+ $values = array();
+ $i = 0;
+
+ foreach ($modelSendCreditProducts as $key => $product) {
+
+ if (is_numeric($product->product)) {
+
+ if ($this->test == true) {
+ echo $product->id . ' -> ' . $product->currency_dest . ' ' . $product->product . ' = ' . $product->currency_orig . ' ' . trim($modelSendCreditRates[$i]->sell_price) . "
";
+ }
+ $values[trim($product->id)] = '' . $product->currency_dest . ' ' . trim($product->product) . ' = ' . $product->currency_orig . ' ' . trim($modelSendCreditRates[$i]->sell_price);
+ Yii::app()->session['is_interval'] = false;
+ } else {
+ Yii::app()->session['is_interval'] = true;
+ Yii::app()->session['interval_currency'] = $product->currency_dest;
+ Yii::app()->session['interval_product_id'] = $product->id;
+ Yii::app()->session['interval_product_interval'] = $product->product;
+ Yii::app()->session['interval_product_sell_price'] = trim($modelSendCreditRates[$i]->sell_price);
+
+ Yii::app()->session['allowedAmount'] = explode('-', $product->product);
+ }
+ $i++;
+
+ }
+
+ Yii::app()->session['amounts'] = isset($forceOperatorSelect) ? array() : $values;
+ Yii::app()->session['operatorId'] = $operatorid;
+ Yii::app()->session['ids_products'] = $ids_products;
+
+ $this->modelTransferToMobile->country = $modelSendCreditProducts[0]->country;
+ $this->modelTransferToMobile->operator = isset($forceOperatorSelect) ? '' : $modelSendCreditProducts[0]->operator_name;
+
+ return $this->modelTransferToMobile;
+
+ } else {
+ echo 'Service inactive';
+ }
+ }
+ }
+
+ public function actionGetProducts()
+ {
+
+ $modelSendCreditProducts = SendCreditProducts::model()->findAll(array(
+ 'condition' => 'operator_name = :key AND status = 1',
+ 'params' => array(':key' => $_GET['operator']),
+ ));
+
+ $operatorId = $modelSendCreditProducts[0]->operator_id;
+
+ $ids_products = array();
+ foreach ($modelSendCreditProducts as $key => $products) {
+ $ids_products[] = $products->id;
+ }
+ //get the user prices to mount the amount combo
+ $criteria = new CDbCriteria();
+ $criteria->addInCondition('id_product', $ids_products);
+ $criteria->addCondition('id_user = :key');
+ $criteria->params[':key'] = Yii::app()->session['id_user'];
+
+ $modelSendCreditRates = SendCreditRates::model()->findAll($criteria);
+
+ $values = array();
+ $i = 0;
+
+ ?>
+ $product): ?>
+
+
+
+
+ session['amounts'] = $values;
+ Yii::app()->session['operatorId'] = $operatorId;
+
+ }
+
+ public function actionGetBuyingPriceDBService($method = '', $valueAmoutEUR = '', $valueAmoutBDT = '')
+ {
+ $method = $method == '' ? $_GET['method'] : $method;
+ $methodOld = $method;
+ $method = $method == 'dbbl_rocket' ? 'Rocket' : $method;
+
+ $amountEUR = $valueAmoutEUR == '' ? $_GET['valueAmoutEUR'] : $valueAmoutEUR;
+ $amountBDT = $valueAmoutBDT == '' ? $_GET['valueAmoutBDT'] : $valueAmoutBDT;
+
+ $modelSendCreditProducts = SendCreditProducts::model()->findAll(array(
+ 'condition' => 'operator_name = :key AND operator_id = 0',
+ 'params' => array(':key' => 'Bangladesh ' . $method),
+ ));
+
+ foreach ($modelSendCreditProducts as $key => $value) {
+ $product = explode('-', $value->product);
+ if ($amountBDT >= $product[0] && $amountBDT <= $product[1]) {
+ $product = $value;
+ break;
+ }
+ }
+
+ $modelSendCreditRates = SendCreditRates::model()->find(array(
+ 'condition' => 'id_user = :key',
+ 'params' => array(
+ ':key' => Yii::app()->session['id_user'],
+ ':key1' => $product->product,
+ ),
+ 'with' => array(
+ 'idProduct' => array(
+ 'condition' => 'product = :key1 AND operator_id = 0',
+ ),
+ ),
+ ));
+
+ $amount = $amountEUR - $modelSendCreditRates->sell_price;
+
+ $methosProfit = 'transfer_' . $methodOld . '_profit';
+
+ $user_profit = $this->modelTransferToMobile->{$methosProfit};
+
+ $amountR = $amount - ($amount * ($user_profit / 100));
+
+ //$user_profit = $amount * ($user_profit / 100);
+
+ if (isset($_GET['method'])) {
+ echo 'EUR ' . $amountR;
+ } else {
+ return $amount;
+ }
+
+ }
+
+ public function actionConvertCurrency()
+ {
+ $method = $_GET['method'];
+ $method = $method == 'dbbl_rocket' ? 'Rocket' : $method;
+
+ $modelSendCreditProducts = SendCreditProducts::model()->findAll(array(
+ 'condition' => 'operator_name = :key AND operator_id = 0',
+ 'params' => array(':key' => 'Bangladesh ' . $method),
+ ));
+
+ if ($_GET['currency'] == 'EUR') {
+
+ /*
+ Request 2: to Send EUR 2.00, will show Selling price EUR 2.00 and BDT amount converted to BDT 125 to
+ send(2.00-0.75/0.01).
+ If click on "R", will show EUR 1.25.
+ */
+
+ $amountEUR = $_GET['amount'];
+
+ $amountBDT = $amountEUR / ($modelSendCreditProducts[0]->wholesale_price);
+
+ foreach ($modelSendCreditProducts as $key => $value) {
+ $product = explode('-', $value->product);
+ if ($amountBDT >= $product[0] && $amountBDT <= $product[1]) {
+ $product = $value;
+ break;
+ }
+ }
+
+ if (!isset($product->product)) {
+ exit('invalid');
+ }
+
+ $modelSendCreditRates = SendCreditRates::model()->find(array(
+ 'condition' => 'id_user = :key',
+ 'params' => array(
+ ':key' => Yii::app()->session['id_user'],
+ ':key1' => $product->product,
+ ),
+ 'with' => array(
+ 'idProduct' => array(
+ 'condition' => 'product = :key1 AND operator_id = 0',
+ ),
+ ),
+ ));
+
+ echo $amount = number_format(($amountEUR - $modelSendCreditRates->sell_price) / $modelSendCreditProducts[0]->wholesale_price, 0, '', '');
+ } else {
+
+ /*
+ Request 1: to Send BDT 150, will show Selling price EUR 2.25(150*0.01+0.75). If click on "R", will show EUR 1.5.
+ */
+ $amountBDT = $_GET['amount'];
+
+ foreach ($modelSendCreditProducts as $key => $value) {
+ $product = explode('-', $value->product);
+ if ($amountBDT >= $product[0] && $amountBDT <= $product[1]) {
+ $product = $value;
+ break;
+ }
+ }
+ $modelSendCreditRates = SendCreditRates::model()->find(array(
+ 'condition' => 'id_user = :key',
+ 'params' => array(
+ ':key' => Yii::app()->session['id_user'],
+ ':key1' => $product->product,
+ ),
+ 'with' => array(
+ 'idProduct' => array(
+ 'condition' => 'product = :key1 AND operator_id = 0',
+ ),
+ ),
+ ));
+
+ echo $amount = number_format(($amountBDT * $product->wholesale_price) + $modelSendCreditRates->sell_price, 2);
+
+ }
+ }
+
+ public function actionGetProductTax()
+ {
+
+ $modelSendCreditProducts = SendCreditProducts::model()->findByPk((int) $_GET['id']);
+ echo $modelSendCreditProducts->info;
+ }
+}
diff --git a/protected/controllers/TransferToMobileController.php b/protected/controllers/TransferToMobileController.php
index 6807e3a69..828527698 100755
--- a/protected/controllers/TransferToMobileController.php
+++ b/protected/controllers/TransferToMobileController.php
@@ -80,4 +80,70 @@ public function actionRead($asJson = true, $condition = null)
}
}
+
+ public function actionPrintRefill()
+ {
+
+ if (isset($_GET['id'])) {
+ echo '';
+ $config = LoadConfig::getConfig();
+ $id_refill = $_GET['id'];
+
+ $modelRefill = Refill::model()->findByPk((int) $id_refill, 'id_user = :key', array(':key' => Yii::app()->session['id_user']));
+
+ echo $config['global']['fm_transfer_print_header'] . "
";
+
+ echo $modelRefill->idUser->company_name . "
";
+ echo $modelRefill->idUser->address . ', ' . $modelRefill->idUser->city . "
";
+ echo "Trx ID: " . $modelRefill->id . "
";
+
+ echo $modelRefill->date . "
";
+
+ $number = explode(" ", $modelRefill->description);
+
+ echo "
Cellulare.: " . $number[5] . "
";
+
+ if (preg_match('/METER/', strtoupper($modelRefill->description))) {
+ $tmp = explode('METER NO.', strtoupper($modelRefill->description));
+ $tmp = explode('VIA', strtoupper($tmp[1]));
+ echo 'Meter: ' . $tmp[0] . "
";
+ }
+
+ // /SEND CREDIT XOF 2000 - 221771200120- BILL NO. 12345 - DATE 2021-03-01 VIA BILL_ELECTRICITY SENEGAL - EUR 8.00. OR OLD CREDIT 100.0001XOF 2000 Bill_Electricity Senegal
+
+ if (preg_match('/BILL NO/', strtoupper($modelRefill->description))) {
+ $tmp = explode('BILL NO.', strtoupper($modelRefill->description));
+ $tmp1 = explode('VIA', strtoupper($tmp[1]));
+ $tmp2 = explode('-', strtoupper($tmp1[0]));
+ echo 'Bill: ' . $tmp2[0] . "
";
+
+ $tmp4 = explode(' DATE ', strtoupper($modelRefill->description));
+
+ echo 'Date: ' . substr($tmp4[1], 0, 10) . "
";
+ }
+
+ $tmp = explode('EUR ', $modelRefill->description);
+ $tmp = explode('. T', $tmp[1]);
+ $amount = $tmp[0];
+
+ $tmp = explode('via ', $modelRefill->description);
+ $operator = strtok($tmp[1], '-');
+ $tmp = explode('Send Credit ', $modelRefill->description);
+ $tmp = explode(' -', $tmp[1]);
+ $product = $tmp[0];
+
+ echo $product . ' ' . $operator . "
";
+
+ echo "Importo: EUR " . strtok($amount, ' ') . "
";
+
+ echo $config['global']['fm_transfer_print_footer'] . "
";
+
+ echo 'Print |
';
+
+ echo 'Start new request | ';
+ echo '';
+ } else {
+ echo ' Invalid reffil';
+ }
+ }
}
diff --git a/protected/models/SendCreditSummary.php b/protected/models/SendCreditSummary.php
index 9321cc002..1e78a7bd1 100755
--- a/protected/models/SendCreditSummary.php
+++ b/protected/models/SendCreditSummary.php
@@ -45,7 +45,8 @@ public function rules()
{
return array(
array('id_user, confirmed', 'numerical', 'integerOnly' => true),
- array('service', 'length', 'max' => 50),
+ array('service,provider,received_amout', 'length', 'max' => 50),
+ array('operator_name', 'length', 'max' => 100),
array('number, cost, sell, earned, amount', 'length', 'max' => 20),
);
}
diff --git a/protected/views/sendCreditSummary/index.php b/protected/views/sendCreditSummary/index.php
index 284dd1e3d..c059d1685 100755
--- a/protected/views/sendCreditSummary/index.php
+++ b/protected/views/sendCreditSummary/index.php
@@ -16,18 +16,18 @@
$modelUser = User::model()->findAll();
$users = CHtml::listData($modelUser, 'id', 'username');?>
-
- labelEx($model, Yii::t('zii', 'Select a user')) ?>
-
- dropDownList($model,
+
+ labelEx($model, Yii::t('zii', 'Select a user')) ?>
+
+ dropDownList($model,
'id',
$users,
array('options' => array($_POST['SendCreditSummary']['id'] => array('selected' => true)))
); ?>
-
-
+
+
-
+
-
+
- labelEx($model, Yii::t('zii', 'To date')) ?>
+ labelEx($model, 'To date') ?>
widget(
'ext.jui.EJuiDateTimePicker',
@@ -64,7 +64,6 @@
'attribute' => 'stopdate',
'language' => 'en', //default Yii::app()->language
'mode' => 'date', //'datetime' or 'time' ('datetime' default)
-
'options' => array(
'dateFormat' => 'yy-mm-dd',
'timeFormat' => 'HH:mm:ss',
@@ -73,16 +72,21 @@
);
?>
-
+
+
+ labelEx($model, Yii::t('zii', 'Number')) ?>
+ textField($model, 'number', array('class' => 'input')) ?>
+ error($model, 'number') ?>
+
+
labelEx($model, Yii::t('zii', 'Service')) ?>
dropDownList($model, 'service', array(
'all' => 'All',
- 'International' => 'International',
- 'flexiload' => 'Flexiload',
- 'bkash' => 'Bkash',
- 'DBBL/Rocket' => 'DBBL/Rocket',
+ 'Mobile Credit' => 'Mobile Credit',
+ 'Mobile Money' => 'Mobile Money',
+ 'Payment' => 'Payment',
));
?>
@@ -92,68 +96,83 @@
'button')); ?>
endWidget();?>
-
-
-
-
-Day |
-Service |
-Amount |
-Total_cost |
-Total_sale |
-Earned |
-
-
-
-
-
- |
-
-
-
-
-
-
-
-
+
+
+
+
+
$value): ?>
- count;?>
- total_cost;?>
- total_sale;?>
- earned;?>
-
-
-day; ?> |
-service; ?> |
-count; ?> |
-total_cost, 2); ?> |
-total_sale, 2); ?> |
-earned, 2); ?> |
-
-
-
-
-
- |
-Total |
- |
- |
- |
- |
-
-
-
+
+ cost;?>
+ sell;?>
+ earned;?>
+
+
+
+
+
+
+
+
+ Date |
+ Service |
+ Number |
+ Operator |
+ Received Amount |
+ Cost |
+ Sell |
+ Profit |
+
+
+
+
+
+
+ $value): ?>
+
+ date; ?> |
+ service; ?> |
+ number; ?> |
+ operator_name; ?> |
+ received_amout; ?> |
+ cost, 2); ?> |
+ sell, 2); ?> |
+ earned, 2); ?> |
+
+
+
+
+
-
+
diff --git a/protected/views/transferPayment/insertDataBill.php b/protected/views/transferPayment/insertDataBill.php
index bc5e886f8..22bb70c08 100755
--- a/protected/views/transferPayment/insertDataBill.php
+++ b/protected/views/transferPayment/insertDataBill.php
@@ -32,12 +32,26 @@
- labelEx($modelTransferToMobile, Yii::t('zii', 'Invoice number')) ?>
+ labelEx($modelTransferToMobile, Yii::t('zii', 'Mobile number')) ?>
+ textField($modelTransferToMobile, 'phone', array('class' => 'input')) ?>
+ error($modelTransferToMobile, 'phone') ?>
+
+
+
+
+
+ labelEx($modelTransferToMobile, Yii::t('zii', 'Contract no')) ?>
textField($modelTransferToMobile, 'number', array('class' => 'input')) ?>
error($modelTransferToMobile, 'number') ?>
-
+
+
+ labelEx($modelTransferToMobile, Yii::t('zii', 'Distribution code')) ?>
+ textField($modelTransferToMobile, 'zipcode', array('class' => 'input')) ?>
+ error($modelTransferToMobile, 'zipcode') ?>
+
+
@@ -47,11 +61,10 @@
$this->widget(
'ext.jui.EJuiDateTimePicker',
array(
+
'model' => $modelTransferToMobile,
'attribute' => 'creationdate',
'language' => Yii::app()->language,
- //'mode' => 'datetime',//'datetime' or 'time' ('datetime' default)
-
'options' => array(
'dateFormat' => 'yy-mm-dd',
'timeFormat' => '',
@@ -64,17 +77,22 @@
- labelEx($modelTransferToMobile, "Bill amount (" . Yii::app()->session['currency_dest'] . ')') ?>
+ labelEx($modelTransferToMobile, 'bill_amount', array('label' => 'Bill Amount (' . strtoupper(Yii::app()->session['currency_dest']) . ')')); ?>
textField($modelTransferToMobile, 'bill_amount', array('id' => 'bill_amount', 'class' => 'input', 'onkeyup' => 'showPriceEUR()')) ?>
error($modelTransferToMobile, 'bill_amount') ?>
-
+
- labelEx($modelTransferToMobile, "Paid Amount (" . Yii::app()->session['currency_orig'] . ')') ?>
- textField($modelTransferToMobile, 'amountValuesEUR', array('id' => 'amountValuesEUR', 'class' => 'input', 'onkeyup' => 'showPriceBDT()')) ?>
+ labelEx($modelTransferToMobile, 'amountValuesEUR', array('label' => 'Paid Amount (' . strtoupper(Yii::app()->session['currency_orig']) . ')')); ?>
+ textField($modelTransferToMobile, 'amountValuesEUR', array(
+ 'id' => 'amountValuesEUR',
+ 'class' => 'input',
+ 'onkeyup' => 'showPriceBDT()',
+ 'readonly' => true,
+)) ?>
error($modelTransferToMobile, 'amountValuesEUR') ?>
@@ -87,9 +105,10 @@
'onclick' => "return button2(event)",
'id' => 'secondButton'));
?>
-
+
+
+
+
+ document.getElementById('TransferToMobile_creationdate').value = '';
+ function getBuyingPrice(argument) {
+
+
+
+ valueAmoutBDT = document.getElementById('bill_amount').value;
+ var id = 0;
+
+
+
+ amountValuesEUR = document.getElementById('amountValuesEUR').value;
+
+ if (document.getElementById('buying_price').value != 'R') {
+ document.getElementById('buying_price').value = 'R';
+ }else{
+
+
+ var http = new XMLHttpRequest()
+
+ http.onreadystatechange = function() {
+ if (this.readyState == 4 && this.status == 200) {
+ document.getElementById('buying_price').value = this.responseText;
+ }
+ };
+
+ http.open("GET", "../../index.php/transferPayment/getBuyingPriceBill?id="+id+"&valueAmoutBDT="+valueAmoutBDT+"&valueAmoutEUR="+amountValuesEUR+"&country=",true)
+ http.send(null);
+
+ }
+
+
+ }
+
+
function showPriceEUR() {
diff --git a/protected/views/transferPayment/insertDataPre.php b/protected/views/transferPayment/insertDataPre.php
new file mode 100755
index 000000000..b4b6285a0
--- /dev/null
+++ b/protected/views/transferPayment/insertDataPre.php
@@ -0,0 +1,214 @@
+insertdataPre
+
+
+
+beginWidget('CActiveForm', array(
+ 'id' => 'contactform',
+ 'htmlOptions' => array('class' => 'rounded'),
+ 'enableAjaxValidation' => false,
+ 'clientOptions' => array('validateOnSubmit' => true),
+ 'errorMessageCssClass' => 'error',
+));
+?>
+
+
+
+
+
+
+
+
+ labelEx($modelTransferToMobile, Yii::t('yii', 'Operator')) ?>
+ textField($modelTransferToMobile, 'method', array('class' => 'input', 'readonly' => true)) ?>
+ error($modelTransferToMobile, 'method') ?>
+
+
+
+
+
+ labelEx($modelTransferToMobile, Yii::t('yii', 'Number')) ?>
+ textField($modelTransferToMobile, 'number', array('class' => 'input', 'readonly' => true)) ?>
+ error($modelTransferToMobile, 'number') ?>
+
+
+
+
+
+ labelEx($modelTransferToMobile, Yii::t('yii', 'Meter')) ?>
+ textField($modelTransferToMobile, 'metric', array('class' => 'input')) ?>
+ error($modelTransferToMobile, 'metric') ?>
+
+
+hiddenField($modelTransferToMobile, 'method', array('value' => $selectedMethod)); ?>
+
+
+
+
+
+
+ session['amounts'] as $key => $value): ?>
+
+
+
+
+
+
+
+
+
+
+
+ 'button',
+ 'onclick' => "return button2(event)",
+ 'id' => 'secondButton'));
+?>
+
+
+
+
+endWidget();?>
+
+
+
+
+
diff --git a/protected/views/transferPayment/insertMeter.php b/protected/views/transferPayment/insertMeter.php
index 086ff2732..c9e317630 100755
--- a/protected/views/transferPayment/insertMeter.php
+++ b/protected/views/transferPayment/insertMeter.php
@@ -71,7 +71,28 @@
function checknumber() {
meter = document.getElementById('meter').value;
country = document.getElementById('country').value;
-
+ document.getElementById("secondButton").style.display = 'none';
+
+ countries = ['Benin',
+ 'Burkina Faso' ,
+ 'Ivory Coast' ,
+ 'Gambia' ,
+ 'Ghana' ,
+ 'Guinea' ,
+ 'Guinea Bissau',
+ 'Mali' ,
+ 'Mauritania' ,
+ 'Morocco' ,
+ 'Nigeria' ,
+ 'Senegal' ,
+ 'Sierra Leone' ,
+ 'Togo'];
+
+ if ( !countries.includes(country)) {
+ document.getElementById("secondButton").style.display = 'inline';
+
+ return;
+ }
if (meter > 0) {
document.getElementById("check_number").style.display = 'none';
document.getElementById("buttondivWait").innerHTML = "Wait! ";
@@ -79,7 +100,7 @@ function checknumber() {
http.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
- alert("Meter operator name is: "+this.responseText);
+ alert("Meter owner is: "+this.responseText);
document.getElementById("check_number").style.display = 'inline';
document.getElementById("buttondivWait").innerHTML = "";
diff --git a/protected/views/transferPayment/insertNumber.php b/protected/views/transferPayment/insertNumber.php
index b4dd54212..c47a36ec8 100755
--- a/protected/views/transferPayment/insertNumber.php
+++ b/protected/views/transferPayment/insertNumber.php
@@ -46,10 +46,10 @@
- labelEx($modelTransferToMobile, Yii::t('zii', 'Number')) ?>
+ labelEx($modelTransferToMobile, Yii::t('zii', 'Phone Number')) ?>
textField($modelTransferToMobile, 'number', array('class' => 'input')) ?>
error($modelTransferToMobile, 'number') ?>
-
+
diff --git a/protected/views/transferPayment/selectAmount.php b/protected/views/transferPayment/selectAmount.php
index 8a3aa8057..5f84bc6d5 100755
--- a/protected/views/transferPayment/selectAmount.php
+++ b/protected/views/transferPayment/selectAmount.php
@@ -68,11 +68,13 @@
'style' => 'color:blue; font-size:20',
)) ?>
error($modelTransferToMobile, 'amountValuesBDT') ?>
+
+
@@ -81,7 +83,7 @@
session['amounts'] as $key => $value): ?>
@@ -90,8 +92,10 @@
-
-
+
@@ -119,13 +123,23 @@
function getBuyingPrice(argument) {
+
+ if (document.getElementById('amountfielBDT') && document.getElementById('amountfielBDT').value > 0) {
+ valueAmoutBDT = document.getElementById('amountfielBDT').value;
+ var id = 0;
+ }else{
+ var id = document.getElementById('productinput'+window.productInputSelected).value;
+ valueAmoutBDT = 0;
+ }
+
+
amountValuesEUR = document.getElementById('amountfielEUR').value;
- valueAmoutBDT = document.getElementById('amountfielBDT').value;
+
if (document.getElementById('buying_price').value != 'R') {
document.getElementById('buying_price').value = 'R';
}else{
- if (amountValuesEUR > 0) {
+
var http = new XMLHttpRequest()
http.onreadystatechange = function() {
@@ -134,9 +148,9 @@ function getBuyingPrice(argument) {
}
};
- http.open("GET", "../../index.php/transferPayment/getBuyingPriceDBService?valueAmoutBDT="+valueAmoutBDT+"&valueAmoutEUR="+amountValuesEUR+"&country=",true)
+ http.open("GET", "../../index.php/transferPayment/getBuyingPrice?id="+id+"&valueAmoutBDT="+valueAmoutBDT+"&valueAmoutEUR="+amountValuesEUR+"&country=",true)
http.send(null);
- }
+
}
@@ -193,6 +207,9 @@ function showPriceEUR() {
http.open("GET", "../../index.php/transferPayment/convertCurrency?currency=EUR&amount="+valueAmoutEUR+"&country=",true)
http.send(null);
+ }else{
+ document.getElementById('amountfielEUR').value = 'Invalid';
+ document.getElementById('secondButton').style.display = 'none';
}
@@ -210,9 +227,22 @@ function showPriceBDT() {
}
valueAmoutBDT = document.getElementById('amountfielBDT').value;
+ //verify if inserted amount is allowed
+ min = 'session['allowedAmountmin']; ?>';
+ max = 'session['allowedAmountmax']; ?>';
- if (valueAmoutBDT > 0) {
+ if (parseInt(valueAmoutBDT) < parseInt(min)) {
+ document.getElementById('amountfielEUR').value = 'Invalid Min';
+ document.getElementById('secondButton').style.display = 'none';
+ }
+ else if (parseInt(valueAmoutBDT) > parseInt(max)) {
+
+ console.log(parseInt(valueAmoutBDT) + ' > '+parseInt(max));
+ document.getElementById('amountfielEUR').value = 'Invalid Max';
+ document.getElementById('secondButton').style.display = 'none';
+ }
+ else if (valueAmoutBDT > 0) {
var http = new XMLHttpRequest()
http.onreadystatechange = function() {
@@ -221,11 +251,15 @@ function showPriceBDT() {
document.getElementById('amountfielEUR').value = this.responseText;
document.getElementById('buying_price').style.display = 'inline';
document.getElementById('buying_price').value = 'R';
+ document.getElementById('secondButton').style.display = 'inline';
}
};
http.open("GET", "../../index.php/transferPayment/convertCurrency?currency=BDT&amount="+valueAmoutBDT+"&country=",true)
http.send(null);
+ }else{
+ document.getElementById('amountfielEUR').value = 'Invalid';
+ document.getElementById('secondButton').style.display = 'none';
}
@@ -234,10 +268,23 @@ function showPriceBDT() {
function handleChange1(argument,total) {
- for (var i = 0; i < total ; i++) {
+ document.getElementById('secondButton').style.display = 'inline';
+
+ if (document.getElementById('amountfielEUR') ) {
+ document.getElementById('amountfielEUR').value = '';
+ }
+ if (document.getElementById('amountfielBDT')) {
+ document.getElementById('amountfielBDT').value = '';
+ }
+
+
+ for (var i = 0; i < 30 ; i++) {
+ if ( !document.getElementById('productLabel'+i)) {
+ break;
+ }
document.getElementById('productLabel'+i).style.backgroundColor = '#fff';
}
- document.getElementById('productLabel'+argument).style.backgroundColor = 'dd8980';
+ document.getElementById('productLabel'+argument).style.backgroundColor = '#dd8980';
document.getElementById('productinput'+argument).checked = true;
window.productInputSelected = argument
@@ -245,8 +292,18 @@ function handleChange1(argument,total) {
document.getElementById('buying_price').style.display = 'inline';
document.getElementById('buying_price').value = 'R';
- document.getElementById('amountfielEUR').value = '';
- document.getElementById('amountfielBDT').value = '';
+ idProduct = document.getElementById('productinput'+argument).value;
+ var http = new XMLHttpRequest()
+ http.onreadystatechange = function() {
+ if (this.readyState == 4 && this.status == 200) {
+ document.getElementById('aditionalInfo').style.display = 'inline';
+ document.getElementById('aditionalInfoText').innerHTML = this.responseText;
+
+
+ }
+ }
+ http.open("GET", "../../index.php/TransferPayment/getProductTax?id="+idProduct);
+ http.send(null);
}
diff --git a/protected/views/transferPayment/selectCountry.php b/protected/views/transferPayment/selectCountry.php
index 2d7c53bb8..cf11ca5ef 100755
--- a/protected/views/transferPayment/selectCountry.php
+++ b/protected/views/transferPayment/selectCountry.php
@@ -33,7 +33,7 @@
findAll(array(
- 'condition' => ' type = :key1',
+ 'condition' => ' type = :key1 AND status = 1',
'params' => array(
':key1' => 'Payment',
),
diff --git a/protected/views/transferPayment/selectOperator.php b/protected/views/transferPayment/selectOperator.php
new file mode 100755
index 000000000..b3f1c3c88
--- /dev/null
+++ b/protected/views/transferPayment/selectOperator.php
@@ -0,0 +1,72 @@
+select operator
+
+
+
+
+
+beginWidget('CActiveForm', array(
+ 'id' => 'contactform',
+ 'htmlOptions' => array('class' => 'rounded'),
+ 'enableAjaxValidation' => false,
+ 'clientOptions' => array('validateOnSubmit' => true),
+ 'errorMessageCssClass' => 'error',
+));
+?>
+
+
+ 'input');
+
+?>
+
+
+ method ?>
+
+
+ labelEx($modelTransferToMobile, Yii::t('yii', 'Operator')) ?>
+
+ dropDownList($modelTransferToMobile, 'method',
+ $methods,
+ array(
+ 'empty' => Yii::t('yii', 'Select the Operator'),
+ 'disabled' => strlen($modelTransferToMobile->country) > 3,
+ 'onchange' => "this.form.submit()",
+ )); ?>
+ error($modelTransferToMobile, 'method') ?>
+
+
+
+
+
+
+
+
+
+
+
+ 'button',
+ 'id' => 'secondButton'));
+?>
+
+
+
+
+
+endWidget();?>
+
+
+
+
diff --git a/resources/css/signup.css b/resources/css/signup.css
index 18f740c1f..a9bdc809e 100755
--- a/resources/css/signup.css
+++ b/resources/css/signup.css
@@ -115,4 +115,12 @@ button.css3button {
-webkit-box-shadow: 0px 1px 3px rgba(000, 000, 000, 0.5), inset 0px 0px 3px rgba(255, 255, 255, 1);
box-shadow: 0px 1px 3px rgba(000, 000, 000, 0.5), inset 0px 0px 3px rgba(255, 255, 255, 1);
text-shadow: 0px -1px 0px rgba(000, 000, 000, 0.1), 0px 1px 0px rgba(255, 255, 255, 1);
+}
+.hasDatepicker {
+ font-family: Arial, Verdana;
+ font-size: 15px;
+ padding: 5px;
+ border: 1px solid #b9bdc1;
+ width: 380px;
+ color: #797979;
}
\ No newline at end of file