Exemplo n.º 1
0
    $data = @file_get_contents($url);
    if (!$data) {
        throw new Exception('Could not connect');
    }
    $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
    $array = $json->decode($data);
    if (!$array) {
        throw new Exception('Could not parse the JSON');
    }
    if ($array['error']) {
        throw new Exception('Google reported an error: ' . $array['error']);
    }
    return (double) $array['rhs'];
}
try {
    $rate = exchangeRate(1, 'usd', 'aud');
    $settings->setsetting('aud', $rate);
} catch (Exception $exception) {
    // log $exception->getMessage()
    echo 'Due to technical difficulties, we couldn\'t get the exchange rate';
}
$lastPaidBlockQ = mysql_query("select blockNumber from rounds where paid = 1 order by blockNumber desc limit 1");
if ($lastPaidBlock = mysql_fetch_object($lastPaidBlockQ)) {
    $block = $lastPaidBlock->blockNumber;
    mysql_query("delete from shares_history where blockNumber < {$block} and (upstream_result != 'Y' or upstream_result is null) limit 500000") or die("Error clearing shares: " . mysql_error());
}
$difficulty = $bitcoinController->query("getdifficulty");
$hashrate = $settings->getsetting('currenthashrate');
$time_to_find = CalculateTimePerBlock($difficulty, $hashrate);
$intpart = floor($time_to_find);
$fraction = $time_to_find - $intpart;
Exemplo n.º 2
0
function updateChargesLocalUsd($bl, $eta, $paymentType, $charge)
{
    // Obtener los cargos LOCALES o FUERA DE BL y dolarizar
    global $dbf;
    $rateNoUSD = 0;
    $rateUSD = 0;
    // FRT
    $sqlF = "\n    SELECT sum(Monto) as Monto,Currency\n    from Z_MS_CHARGES BL\n    where BL.Bill_of_Lading_Number='{$bl}'\n    AND BL .Payment_Type = '{$paymentType}'\n    AND Charge='{$charge}'\n    GROUP BY Currency";
    $total = 0;
    $totalG = 0;
    $dbf->query($sqlF);
    while ($dbf->next_record()) {
        $cur = $dbf->f('Currency');
        $total = $dbf->f('Monto');
        // Dolarizar
        if ($cur != 'USD') {
            $total = exchangeRate($cur, $eta, $total);
            $totalG = $total;
        } else {
            $total = $total + $totalG;
        }
    }
    return $total;
}
Exemplo n.º 3
0
     //echo "THC_CC: $thcCC $cur  | $ori | $pol | $pod | $des | $bl | $company | $eta  <br>";
     $frtCC = exchangeRate($cur, $eta, $frtCC);
     $frtPP = exchangeRate($cur, $eta, $frtPP);
     $frtEE = exchangeRate($cur, $eta, $frtEE);
     $thcCC = exchangeRate($cur, $eta, $thcCC);
     $thcPP = exchangeRate($cur, $eta, $thcPP);
     $thcEE = exchangeRate($cur, $eta, $thcEE);
     $preCC = exchangeRate($cur, $eta, $preCC);
     $prePP = exchangeRate($cur, $eta, $prePP);
     $preEE = exchangeRate($cur, $eta, $preEE);
     $oncCC = exchangeRate($cur, $eta, $oncCC);
     $oncPP = exchangeRate($cur, $eta, $oncPP);
     $oncEE = exchangeRate($cur, $eta, $oncEE);
     $otrosCC = exchangeRate($cur, $eta, $otrosCC);
     $otrosPP = exchangeRate($cur, $eta, $otrosPP);
     $otrosEE = exchangeRate($cur, $eta, $otrosEE);
 }
 // --------------------------
 // Grabar al SION
 // 1. Identificar BUQUE
 // 2. Cargar datos a SION
 // --------------------------
 // 1. Identificar BUQUE
 if ($impoExpo == "E") {
     // ------------------
     // BUQUE EXPORT
     // ------------------
     $idBarco = 0;
     $puerto = getPuerto($pol);
     $sql2 = "\n                        SELECT Id_barco\n                        FROM BARCO\n                        WHERE Nombre='{$vessel}' and Viaje='{$voyage}' and Eta1='{$eta}' and Puerto='{$puerto}' and Impo_expo='{$impoExpo}'\n                        ";
     $result = mysql_query($sql2, $dbSION);
Exemplo n.º 4
0
function updateChargesUsd($bl, $eta, $paymentType, $code, $flgOC = 0)
{
    // Obtener los cargos del BL desde MscLink y dolarizar por Bl.
    global $sionConect, $conn2;
    global $linkSrv, $linkDB, $linkUsr, $linkPass;
    //$dsn = "Driver={SQL Server};Server=$linkSrv;Database=$linkDB;Integrated Security=SSPI;Persist Security Info=False;";
    //$conn2 = odbc_connect($dsn, $linkUsr, $linkPass);
    $rateNoUSD = 0;
    $rateUSD = 0;
    // FRT
    $sqlF = "\n    SELECT sum(Result_Std) as Monto,Currency\n    from Interlink_DFeed90.dfeed.FNTB_Charge (0, NULL) BL\n    where BL .Payment_Type = '{$paymentType}'\n    ";
    if ($flgOC == 1) {
        if ($paymentType == "P") {
            $sqlF .= " AND BL.Charge_DTX_Code not in ('ONC','PRE' ,'FRT', 'THC','DOC') ";
        } else {
            $sqlF .= " AND BL.Charge_DTX_Code not in ('ONC','PRE' ,'FRT', 'THC') ";
        }
    } else {
        $sqlF .= " AND BL.Charge_DTX_Code = '{$code}' ";
    }
    // Se comento esto por que no estaba haciendo match en la b.d.
    // -- AND BL.Invoice_Type_Desc='Ocean Invoices'
    $sqlF .= "\n    AND BL.Bill_of_Lading_Number='{$bl}'\n    GROUP BY Currency\n    ";
    $total = 0;
    $totalG = 0;
    $rs2 = odbc_exec($conn2, $sqlF);
    while ($myrow = odbc_fetch_array($rs2)) {
        $cur = $myrow['Currency'];
        $total = $myrow['Monto'];
        // Dolarizar
        if ($cur != 'USD') {
            $total = exchangeRate($cur, $eta, $total);
            $totalG = $total;
        } else {
            $total = $total + $totalG;
        }
    }
    //odbc_close($conn2);
    return $total;
}
Exemplo n.º 5
0
function updateChargesLocalUsd($bl, $eta, $paymentType, $charge)
{
    // Obtener los cargos LOCALES o FUERA DE BL y dolarizar
    global $conn2;
    $rateNoUSD = 0;
    $rateUSD = 0;
    $sqlF = "\n    SELECT sum(Result_Std) as Monto,Currency\n    from Interlink_DFeed90.dfeed.FNTB_Charge (0, NULL) BL\n    where BL.Bill_of_Lading_Number='{$bl}'\n    AND BL .Payment_Type = '{$paymentType}'\n    AND Charge='{$charge}'\n    GROUP BY Currency\n    ";
    $total = 0;
    $totalG = 0;
    $rs2 = odbc_exec($conn2, $sqlF);
    while ($myrow = odbc_fetch_array($rs2)) {
        $cur = $myrow['Currency'];
        $total = $myrow['Monto'];
        // Dolarizar
        if ($cur != 'USD') {
            $total = exchangeRate($cur, $eta, $total);
            $totalG = $total;
        } else {
            $total = $total + $totalG;
        }
    }
    return $total;
}
function updateChargesUsd($bl, $eta, $paymentType, $code, $flgOC = 0)
{
    // Obtener los cargos del BL desde MscLink y dolarizar por Bl.
    global $dbf;
    $rateNoUSD = 0;
    $rateUSD = 0;
    // FRT
    $sqlF = "\n    SELECT sum(Monto) as Monto,Currency\n    from Z_CHARGES_MSCLINK_NESTOR BL\n    where BL.Bill_of_Lading_Number='{$bl}' AND BL .Payment_Type = '{$paymentType}'\n    ";
    if ($flgOC == 1) {
        $sqlF .= " AND BL.Charge_DTX_Code not in ('ONC','PRE' ,'FRT', 'THC') ";
    } else {
        $sqlF .= " AND BL.Charge_DTX_Code = '{$code}' ";
    }
    // Se comento esto por que no estaba haciendo match en la b.d.
    // -- AND BL.Invoice_Type_Desc='Ocean Invoices'
    $sqlF .= "\n    GROUP BY Currency\n    ";
    $total = 0;
    $totalG = 0;
    $dbf->query($sqlF);
    while ($dbf->next_record()) {
        $cur = $dbf->f('Currency');
        $total = $dbf->f('Monto');
        // Dolarizar
        if ($cur != 'USD') {
            $total = exchangeRate($cur, $eta, $total);
            $totalG = $total;
        } else {
            $total = $total + $totalG;
        }
    }
    return $total;
}