Create
From PokeTALK developers
Contents |
Description
Returns user billing data
Usage
ptReport.create(from_date, to_date, callback);
or
var result = ptReport.create(from_date, to_date);
Parameters
| Required | Name | Type | Description |
|---|---|---|---|
| required | from_date | date | MySQL date formatted YY-mm-dd, i.e 2009-01-25 |
| required | to_date | date | MySQL date formatted YY-mm-dd, i.e 2009-01-25 |
| optional | callback | function | optional callback function to call after execution |
Response
object (JSON)
{"start_balance":float,
"result":[
{"date":date,
"from":string,
"to":string,
"billsec":integer,
"credit":float,
"debit":float
},
{...},
{...},
{...}
]
}| Parameter | Type | Description |
|---|---|---|
| start_balance | float | returns user balance to start date. |
| result | variable | returns user billing items array, false otherwise. |
| Array |
| Parameter | Type | Description |
|---|---|---|
| date | date | date of . |
| from | string | from phone number. |
| to | string | to phone number. |
| billsec | integer | call duration (sec). |
| credit | float | deposit sum ($). |
| debit | float | call cost ($). |
Example
Use result object
var item; var html = ""; // Get billing records for January 2009 var report = ptReport.create("2008-12-31", "2009-02-01"); if(!report.result){ html = 'No billing records for this period'; }else{ // Get report length var len = report.result.length; // Create report HTML for(var i=0; i<len; i++){ item = report.result[i]; // Print calls records only if(item.debit != 0){ html += item.date+" "+item.from+" "+item.to+" "item.billsec+" "+item.debit+"<br />"; } } } // Print HTML document.write(html);
Use callback function
ptReport.create("2008-12-31", "2009-02-01", function(report){ if(!report.result){ alert('No billing records for this period'); return; } var item; var html = ""; // get report length var len = report.result.length; // create contact list HTML for(var i=0; i<len; i++){ item = report.result[i]; // Print calls records only if(item.debit != 0){ html += item.date+" "+item.from+" "+item.to+" "item.billsec+" "+item.debit+"<br />"; } } // print HTML document.write(html); });

