H there,
I was looking at this example, combined with the API example posted at https://www.koolreport.com/forum/topics/234
here is the code:
function settings()
{
return array(
"dataSources"=>array(
"apiarray"=>array(
"class"=>'\koolreport\datasources\ArrayDataSource',
"dataFormat"=>"associate",
)
)
);
}
function setup()
{
Log::debug("PaymentAPIReport init");
$this->login();
$QueryPayments = $this->paymentRunQuery(
array(
"SortBy" => "paymentDate",
"payType" => "2",
"paymentGroup" => "15-20"
)
);
if(isset($QueryPayments['Payment']) && !empty($QueryPayments['Payment'])){
Log::debug("PaymentAPIReport GOOD");
}
$this->logout();
//dd($QueryPayments);
$this->src("apiarray")->load($QueryPayments)
->pipe(new Map([
"{value}" => function($row) {
$jsonData = $row["Payment"];
$jsonData = json_decode($jsonData, true);
$row["paymentNo"] = $jsonData["paymentNo"];
$row["amount"] = $jsonData["amount"];
return $row;
}
]))
->pipe($this->dataStore("result"));
I am getting:
"Undefined offset: 0"
C:\dev\ellison-travel\vendor\koolreport\core\src\datasources\ArrayDataSource.php
case "table":
$columnNames = $data[0];
$metaData = array("columns"=>array());
for ($i=0;$i<count($columnNames);$i++) {
$metaData["columns"][$columnNames[$i]] = array(
"type"=>(isset($data[1]))
?$this->guessType($data[1][$i]):"unknown",
);;
}
$this->sendMeta($metaData, $this);
$this->startInput(null);
$rowNum = count($data);
for ($i=1;$i<$rowNum;$i++) {
$this->next(array_combine($columnNames, $data[$i]), $this);
}
break;
case "associate":
default:
$metaData = array("columns"=>array());
foreach ($data[0] as $key=>$value) {
$metaData["columns"][$key]=array(
API is returning JSON with data, I can see in the browser when dd, Here is the return:
"Payment": [
{
"paymentNo": 207416,
"paymentDate": "2018-08-28T00:00:00.000Z",
"ckCCNo": "MC 54-X",
"amount": 120000,
"bank_LinkNo": "4",
"payType_LinkNo": "1",
"payMethod_LinkNo": "5",
"profile_LinkNo": 635,
"JERecord_LinkNo": null,
"submitTo_LinkCode": null,
"name": "NAMEie",
"profileType_LinkCode": "I",
"remarks": "text",
"paymentGroup": "1955",
"dateCleared": "2018-08-29T00:00:00.000Z",
"currencyCode": "",
"code": "",
"payeeName": "name",
"branch_LinkNo": 2,
"deposit_LinkNo": null,
"invoiceRef": null,
"attachmentCount": 0
},
{
"paymentNo": 207417,
"paymentDate": "2018-08-28T00:00:00.000Z",
"ckCCNo": "VI 45-X",
"amount": 120000,
"bank_LinkNo": "4",
"payType_LinkNo": "1",
"payMethod_LinkNo": "5",
"profile_LinkNo": 63975,
"JERecord_LinkNo": null,
"submitTo_LinkCode": null,
"name": "name of the cliente",
"profileType_LinkCode": "I",
"remarks":ffff",
"paymentGroup": "1955 - ",
"dateCleared": "2018-08-29T00:00:00.000Z",
"currencyCode": "",
"code": "",
"payeeName": "name of the lcient",
"branch_LinkNo": 2,
"deposit_LinkNo": null,
"invoiceRef": null,
"attachmentCount": 0
},
thank you very much