diff options
Diffstat (limited to 'php')
-rw-r--r-- | php/backend.php | 1 | ||||
-rw-r--r-- | php/fulfillment.php | 2 | ||||
-rw-r--r-- | php/history.js | 26 | ||||
-rw-r--r-- | php/history.php | 2 |
4 files changed, 28 insertions, 3 deletions
diff --git a/php/backend.php b/php/backend.php index a0cce83..bd70feb 100644 --- a/php/backend.php +++ b/php/backend.php @@ -34,7 +34,6 @@ CURLOPT_CUSTOMREQUEST => "GET"); curl_setopt_array($c, $options); $r = curl_exec($c); - file_put_contents("/tmp/php.out", print_r($r, true)); return array("status_code" => curl_getinfo($c, CURLINFO_HTTP_CODE), "body" => $r); } diff --git a/php/fulfillment.php b/php/fulfillment.php index 048150d..a9c27bf 100644 --- a/php/fulfillment.php +++ b/php/fulfillment.php @@ -23,7 +23,7 @@ $rec_proposal = make_contract(intval($_GET['transaction_id']), $now); $response = post_to_backend("/contract", $rec_proposal); - http_response_code($response["code"]); + http_response_code($response["status_code"]); if (200 != $response["status_code"]) { echo build_error($response, "Failed to reconstruct the contract", diff --git a/php/history.js b/php/history.js index 54444f4..3db11be 100644 --- a/php/history.js +++ b/php/history.js @@ -1,3 +1,29 @@ +var FRACTION = 100000000; + +/** + * Stringify amounts + */ +function parse_amount(amount){ + var v = amount.value + (amount.fraction/FRACTION); + return v + " " + amount.currency; +} + +/** + * Parse Taler date ("/Date(TIMESTAMP)/") string + */ + function get_date(date){ + var split = date.match(/Date\((.*)\)/); + var seconds; + if(isNaN(seconds = Number(split[1]))){ + console.error("Malformed date gotten from backend"); + return; + } + console.log("Extracting timestamp", split[1]); + var d = new Date(seconds * 1000); + return d; +} + + function submit_history(){ var table = document.getElementById("history"); /* We don't want to kill the first child */ diff --git a/php/history.php b/php/history.php index 70bd3b0..93ac315 100644 --- a/php/history.php +++ b/php/history.php @@ -9,7 +9,7 @@ } $now = new DateTime(); - $now->subtract(new DateInterval(sprintf("P%sD", $_GET['days'])); + $now->sub(new DateInterval(sprintf("P%sD", $_GET['days']))); $response = get_to_backend("/history", array("date"=>$now->getTimestamp())); if (200 != $response["status_code"]){ |