add support to save buying price for destination (billing)

This commit is contained in:
luis daniel lucio quiroz 2014-07-24 03:06:33 +00:00
parent d2aa3e21e2
commit ae90c95292
2 changed files with 42 additions and 5 deletions

View File

@ -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";

View File

@ -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 "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-monthly_price_buy'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='number' min='0' step='0.01' name='destination_buy' maxlength='255' value=\"$destination_buy\">\n";
currency_select($currency_buy,0,'currency_buy');
echo "<br />\n";
echo $text['description-monthly_price_buy']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-carrier'].":\n";