From ae90c95292c9b2944f52cce46fc7cd463b4a2ced Mon Sep 17 00:00:00 2001 From: luis daniel lucio quiroz Date: Thu, 24 Jul 2014 03:06:33 +0000 Subject: [PATCH] add support to save buying price for destination (billing) --- app/destinations/app_languages.php | 18 +++++++++++++---- app/destinations/destination_edit.php | 29 ++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/app/destinations/app_languages.php b/app/destinations/app_languages.php index e1022cccc9..52997f9b59 100644 --- a/app/destinations/app_languages.php +++ b/app/destinations/app_languages.php @@ -142,16 +142,26 @@ $text['label-false']['pt-pt'] = "Não"; $text['label-false']['fr-fr'] = "Non"; - $text['label-monthly_price']['en-us'] = "Monthly price"; - $text['label-monthly_price']['es-cl'] = "Precio mensual"; - $text['label-monthly_price']['pt-pt'] = "Preço mensal"; - $text['label-monthly_price']['fr-fr'] = "Prix mensuel"; + $text['label-monthly_price']['en-us'] = "Monthly selling price"; + $text['label-monthly_price']['es-cl'] = "Precio mensual de venta"; + $text['label-monthly_price']['pt-pt'] = "Preço mensal de venta"; + $text['label-monthly_price']['fr-fr'] = "Prix mensuel à vendre"; + + $text['label-monthly_price_buy']['en-us'] = "Monthly buy price"; + $text['label-monthly_price_buy']['es-cl'] = "Precio mensual de compra"; + $text['label-monthly_price_buy']['pt-pt'] = "Preço mensal compra"; + $text['label-monthly_price_buy']['fr-fr'] = "Prix mensuel d'achat"; $text['description-monthly_price']['en-us'] = "Enter monthly price to bill for this destination (only when inbound)"; $text['description-monthly_price']['es-cl'] = "Ingrese el precio mensual a cobrar por este destino (sólo entrante)"; $text['description-monthly_price']['pt-pt'] = "Digite o preço mensal de conta para este destino (somente quando entrada)"; $text['description-monthly_price']['fr-fr'] = "Entrez prix mensuel de projet de loi pour cette destination (uniquement lorsque entrant)"; + $text['description-monthly_price_buy']['en-us'] = "Enter monthly price you pay for this destination (only when inbound)"; + $text['description-monthly_price_buy']['es-cl'] = "Ingrese el precio mensual que usted paga por este destino (sólo entrante)"; + $text['description-monthly_price_buy']['pt-pt'] = "Digite o preço mensal de paga para este destino (somente quando entrada)"; + $text['description-monthly_price_buy']['fr-fr'] = "Entrez prix mensuel de projet de achat pour cette destination (uniquement lorsque entrant)"; + $text['label-accountcode']['en-us'] = "Account code"; $text['label-accountcode']['es-cl'] = "Código de cuenta"; $text['label-accountcode']['pt-pt'] = "Codigo de cuenta"; diff --git a/app/destinations/destination_edit.php b/app/destinations/destination_edit.php index 2675a7797f..bd6270a6ff 100644 --- a/app/destinations/destination_edit.php +++ b/app/destinations/destination_edit.php @@ -37,6 +37,7 @@ else { if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billing/app_config.php")){ require_once "app/billing/resources/functions/currency.php"; + require_once "app/billing/resources/functions/rating.php"; } //add multi-lingual support @@ -67,8 +68,10 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billing/app_config. $fax_uuid = check_str($_POST["fax_uuid"]); $destination_enabled = check_str($_POST["destination_enabled"]); $destination_description = check_str($_POST["destination_description"]); - $destination_sell = check_str($_POST["destination_sell"]); + $destination_sell = check_float($_POST["destination_sell"]); $currency = check_str($_POST["currency"]); + $destination_buy = check_float($_POST["destination_buy"]); + $currency_buy = check_str($_POST["currency_buy"]); $destination_accountcode = check_str($_POST["destination_accountcode"]); $destination_carrier = check_str($_POST["destination_carrier"]); } @@ -377,6 +380,16 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //redirect the user if ($action == "add") { $_SESSION["message"] = $text['message-add']; + // billing + if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billing/app_config.php")){ + $db2 = new database; + $db2->sql = "SELECT currency FROM v_billings WHERE type_value='$destination_accountcode'"; + $db2->result = $db2->execute(); + $default_currency = (strlen($_SESSION['billing']['currency']['text'])?$_SESSION['billing']['currency']['text']:'USD'); + $billing_currency = (strlen($db2->result[0]['currency'])?$db2->result[0]['currency']:$default_currency); + $destination_sell_current_currency = currency_convert($destination_sell,$billing_currency,$currency); + unset($db2->sql, $db2->result); + } } if ($action == "update") { $_SESSION["message"] = $text['message-update']; @@ -406,6 +419,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $destination_description = $row["destination_description"]; $currency = $row["currency"]; $destination_sell = $row["destination_sell"]; + $destination_buy = $row["destination_buy"]; + $currency_buy = $row["currency_buy"]; $destination_accountcode = $row["destination_accountcode"]; $destination_carrier = $row["destination_carrier"]; break; //limit to 1 row @@ -643,6 +658,18 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; + echo " ".$text['label-monthly_price_buy'].":\n"; + echo "\n"; + echo "\n"; + echo " \n"; + currency_select($currency_buy,0,'currency_buy'); + echo "
\n"; + echo $text['description-monthly_price_buy']."\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo " ".$text['label-carrier'].":\n";