I am trying to use the Salesforce Analytics api to get a report filtered by date, but when I apply the date filters it does not seem to stick, only the default filter applies.
Here is the POST data that I am sending
{
"reportMetadata": {
"aggregates": [
"FORMULA1",
"FORMULA2",
"FORMULA3",
"RowCount"
],
"currency": null,
"detailColumns": [
"SUBJECT",
"DUE_DATE",
"PRIORITY",
"STATUS",
"TASK",
"ACCOUNT",
"CONTACT",
"LEAD",
"OPPORTUNITY"
],
"developerName": "me",
"groupingsAcross": [
{
"dateGranularity": "None",
"name": "CALLDISPOSITION",
"sortAggregate": null,
"sortOrder": "Asc"
}
],
"groupingsDown": [
{
"dateGranularity": "None",
"name": "ASSIGNED",
"sortAggregate": null,
"sortOrder": "Asc"
}
],
"historicalSnapshotDates": [],
"id": "00OC0000006nlWpMAI",
"name": "report",
"reportBooleanFilter": "1 AND 2 AND 3",
"reportFilters": [
{
"column": "CALLTYPE",
"operator": "equals",
"value": "Outbound"
},
{
"value": "2014-08-01",
"column": "Activity.qbdialer__Call_Date_Time__c",
"operator": "greaterOrEqual"
},
{
"value": "2014-08-31",
"column": "Activity.qbdialer__Call_Date_Time__c",
"operator": "lessOrEqual"
}
],
"reportFormat": "MATRIX",
"reportType": {
"label": "Tasks and Events",
"type": "Activity"
}
}
}
and here is what I get back
Array
(
[status] => Array
(
[http_code] => 200
)
[contents] => Array
(
[attributes] => Array
(
[completionDate] => 2014-08-19T17:23:26Z
[id] => 0LGC00000024PlIOAU
[ownerId] => 005C0000003KHKbIAO
[reportId] => 00OC0000006nlWpMAI
[reportName] => report
[requestDate] => 2014-08-19T17:23:25Z
[status] => Success
[type] => ReportInstance
)
[allData] => 1
[factMap] => Array
(
[T!2] => Array
(
[aggregates] => Array
(
[0] =>
[1] => Array
(
[label] => 6.67%
[value] => 6.66666667
)
[2] =>
[3] => Array
(
[label] => 1
[value] => 1
)
)
)
[T!T] => Array
(
[aggregates] => Array
(
[0] =>
[1] =>
[2] =>
[3] => Array
(
[label] => 15
[value] => 15
)
)
)
[T!1] => Array
(
[aggregates] => Array
(
[0] =>
[1] => Array
(
[label] => 13.33%
[value] => 13.33333333
)
[2] =>
[3] => Array
(
[label] => 2
[value] => 2
)
)
)
[0!0] => Array
(
[aggregates] => Array
(
[0] => Array
(
[label] => 3.00
[value] => 3
)
[1] =>
[2] => Array
(
[label] => 0.25
[value] => 0.25
)
[3] => Array
(
[label] => 12
[value] => 12
)
)
)
[0!T] => Array
(
[aggregates] => Array
(
[0] =>
[1] =>
[2] =>
[3] => Array
(
[label] => 15
[value] => 15
)
)
)
[T!0] => Array
(
[aggregates] => Array
(
[0] =>
[1] => Array
(
[label] => 80.00%
[value] => 80
)
[2] =>
[3] => Array
(
[label] => 12
[value] => 12
)
)
)
[0!2] => Array
(
[aggregates] => Array
(
[0] => Array
(
[label] => 0.00
[value] => 0
)
[1] =>
[2] => Array
(
[label] => 0.00
[value] => 0
)
[3] => Array
(
[label] => 1
[value] => 1
)
)
)
[0!1] => Array
(
[aggregates] => Array
(
[0] => Array
(
[label] => 1.00
[value] => 1
)
[1] =>
[2] => Array
(
[label] => 0.50
[value] => 0.5
)
[3] => Array
(
[label] => 2
[value] => 2
)
)
)
)
[groupingsAcross] => Array
(
[groupings] => Array
(
[0] => Array
(
[groupings] => Array
(
)
[key] => 0
[label] => -
[value] =>
)
[1] => Array
(
[groupings] => Array
(
)
[key] => 1
[label] => Contact
[value] => Contact
)
[2] => Array
(
[groupings] => Array
(
)
[key] => 2
[label] => Correct Contact
[value] => Correct Contact
)
)
)
[groupingsDown] => Array
(
[groupings] => Array
(
[0] => Array
(
[groupings] => Array
(
)
[key] => 0
[label] => first sftest1
[value] => 005C0000003KHKbIAO
)
)
)
[hasDetailRows] =>
[reportExtendedMetadata] => Array
(
[aggregateColumnInfo] => Array
(
[RowCount] => Array
(
[acrossGroupingContext] =>
[dataType] => int
[downGroupingContext] =>
[label] => Record Count
)
[FORMULA1] => Array
(
[acrossGroupingContext] => CALLDISPOSITION
[dataType] => double
[downGroupingContext] => ASSIGNED
[label] => Ring Time
)
[FORMULA3] => Array
(
[acrossGroupingContext] => CALLDISPOSITION
[dataType] => double
[downGroupingContext] => ASSIGNED
[label] => Average Ring Time
)
[FORMULA2] => Array
(
[acrossGroupingContext] => CALLDISPOSITION
[dataType] => percent
[downGroupingContext] => GRAND_SUMMARY
[label] => Group Average
)
)
[detailColumnInfo] => Array
(
[SUBJECT] => Array
(
[dataType] => string
[label] => Subject
)
[DUE_DATE] => Array
(
[dataType] => date
[label] => Date
)
[PRIORITY] => Array
(
[dataType] => picklist
[label] => Priority
)
[STATUS] => Array
(
[dataType] => picklist
[label] => Status
)
[TASK] => Array
(
[dataType] => boolean
[label] => Task
)
[ACCOUNT] => Array
(
[dataType] => string
[label] => Company / Account
)
[CONTACT] => Array
(
[dataType] => string
[label] => Contact
)
[LEAD] => Array
(
[dataType] => string
[label] => Lead
)
[OPPORTUNITY] => Array
(
[dataType] => string
[label] => Opportunity
)
)
[groupingColumnInfo] => Array
(
[ASSIGNED] => Array
(
[dataType] => string
[groupingLevel] => 0
[label] => Assigned
)
[CALLDISPOSITION] => Array
(
[dataType] => string
[groupingLevel] => 0
[label] => Call Result
)
)
)
[reportMetadata] => Array
(
[aggregates] => Array
(
[0] => FORMULA1
[1] => FORMULA2
[2] => FORMULA3
[3] => RowCount
)
[currency] =>
[detailColumns] => Array
(
[0] => SUBJECT
[1] => DUE_DATE
[2] => PRIORITY
[3] => STATUS
[4] => TASK
[5] => ACCOUNT
[6] => CONTACT
[7] => LEAD
[8] => OPPORTUNITY
)
[developerName] => Ring_Time_By_Agent
[groupingsAcross] => Array
(
[0] => Array
(
[dateGranularity] => None
[name] => CALLDISPOSITION
[sortAggregate] =>
[sortOrder] => Asc
)
)
[groupingsDown] => Array
(
[0] => Array
(
[dateGranularity] => None
[name] => ASSIGNED
[sortAggregate] =>
[sortOrder] => Asc
)
)
[historicalSnapshotDates] => Array
(
)
[id] => 00OC0000006nlWpMAI
[name] => report
[reportBooleanFilter] =>
[reportFilters] => Array
(
[0] => Array
(
[column] => CALLTYPE
[operator] => equals
[value] => Outbound
)
)
[reportFormat] => MATRIX
[reportType] => Array
(
[label] => Tasks and Events
[type] => Activity
)
)
)
)
As you can see in the results only the CALLTYPE column filter applied (this is the default filter).
Does anyone see anything wrong with the POST data that I am sending?
I have tried using other reports and other date columns to filter on, but it is always the same, only the default filters apply.
I found the answer. I was not setting the header Content-type to application/json. Once I did that the filters started working.
Related
After printing my $my_values['outer_group']['fieldset'] I'm getting the following output as per the data:
Array
(
[fieldset] => Array
(
[1] => Array
(
[title] => Dummy_Value1
[inner_group] => Array
(
[fieldset] => Array
(
[1] => Array
(
[id] => 11
[title] => Dummy_Value11
)
[2] => Array
(
[id] => 12
[title] => Dummy_Value12
)
[3] => Array
(
[id] => 13
[title] => Dummy_Value13
)
[actions] => Array
(
[add] => Add InnerGroup
[remove] => Remove InnerGroup
)
)
)
)
[2] => Array
(
[title] => Dummy_Value2
[inner_group] => Array
(
[fieldset] => Array
(
[1] => Array
(
[id] => 21
[title] => Dummy_Value21
)
[actions] => Array
(
[add] => Add InnerGroup
)
)
)
)
[actions] => Array
(
[add] => Add OuterGroup
[remove] => Remove OuterGroup
)
)
)
My requirement is to re-index the output data, hence I've performed the following code to re-index the same:
<?php
if (isset($my_values['outer_group']) && !empty($my_values['outer_group'])) {
$outer_types = $my_values['outer_group']['fieldset'];
$inner = [];
foreach ($outer_types as $outer_key => $outer_value) {
if (is_numeric($outer_key)) {
if (isset($outer_value['inner_group']['fieldset'])) {
foreach ($outer_value['inner_group']['fieldset'] as $k => $v) {
if (is_numeric($k)) {
$inner[] = [
'id' => $v['id'],
'title' => !empty($v['title']) ? $token->replace($v['title']) : NULL,
];
}
}
}
$my_values['outer'][$outer_key] = [
'title' => !empty($outer_value['title']) ? $token->replace($outer_value['title']) : NULL,
'inner' => $inner,
];
}
}
}
As per the output its getting re-indexed but with some errors in data. I'm getting trouble while populating the [inner] data, following is the output for the same:
Array
(
[0] => Array
(
[title] => Dummy_Value1
[inner] => Array
(
[0] => Array
(
[id] => 11
[title] => Dummy_Value11
)
[1] => Array
(
[id] => 12
[title] => Dummy_Value12
)
[2] => Array
(
[id] => 13
[title] => Dummy_Value13
)
)
)
[1] => Array
(
[title] => Dummy_Value2
[inner] => Array
(
[0] => Array
(
[id] => 11
[title] => Dummy_Value11
)
[1] => Array
(
[id] => 12
[title] => Dummy_Value12
)
[2] => Array
(
[id] => 13
[title] => Dummy_Value13
)
[3] => Array
(
[id] => 21
[title] => Dummy_Value21
)
)
)
)
Whereas, it should be:
Array
(
[0] => Array
(
[title] => Dummy_Value1
[inner] => Array
(
[0] => Array
(
[id] => 11
[title] => Dummy_Value11
)
[1] => Array
(
[id] => 12
[title] => Dummy_Value12
)
[2] => Array
(
[id] => 13
[title] => Dummy_Value13
)
)
)
[1] => Array
(
[title] => Dummy_Value2
[inner] => Array
(
[0] => Array
(
[id] => 21
[title] => Dummy_Value21
)
)
)
)
$inner = []; needs to be within the foreach loop so that it is empty before building each internal element.
Untested - but as follows:
<?php
if (isset($my_values['outer_group']) && !empty($my_values['outer_group'])) {
$outer_types = $my_values['outer_group']['fieldset'];
foreach ($outer_types as $outer_key => $outer_value) {
$inner = [];
if (is_numeric($outer_key)) {
if (isset($outer_value['inner_group']['fieldset'])) {
foreach ($outer_value['inner_group']['fieldset'] as $k => $v) {
if (is_numeric($k)) {
$inner[] = [
'id' => $v['id'],
'title' => !empty($v['title']) ? $token->replace($v['title']) : NULL,
];
}
}
}
$my_values['outer'][$outer_key] = [
'title' => !empty($outer_value['title']) ? $token->replace($outer_value['title']) : NULL,
'inner' => $inner,
];
}
}
}
i have two arrays and i want two merge using the same value within each array..
the first array is :
[0] => Array
(
[id] => 1
[uid] => 0090000157
[cid] => 0090000007
[extension] => 202
[secret] => Myojyo42f!
[leader] => 1
[simultaneous] =>
[confbridge_id] => 2
[created_at] => 2015-07-26 12:20:20
[updated_at] => 2015-07-26 12:20:20
)
[1] => Array
(
[id] => 2
[uid] => 0090000159
[cid] => 0090000007
[extension] =>
[secret] => Myojyo42f!
[leader] =>
[simultaneous] =>
[confbridge_id] => 2
[created_at] => 2015-07-26 14:23:41
[updated_at] => 2015-07-26 14:23:41
)
)
and the second array is:
Array
(
[0] => Array
(
[_id] => 55b52f4c2bab38fc63b6272a
[event] => ConfbridgeJoin
[channel] => SIP/peer_voip301confbridge-0000001b
[uniqueid] => 1437937478.63
[conference] => 0090000156
[calleridnum] => 0090000157
[calleridname] => 0090000157
[__v] => 0
[sipSetting] => Array
(
[accountcode] =>
[accountcode_naisen] => 202
[extentype] => 0
[extenrealname] =>
[name] => 0090000157
[secret] => Myojyo42f!
[username] => 0090000157
[context] => innercall_xdigit
[gid] => 101
[cid] => 0090000007
)
)
[1] => Array
(
[_id] => 55b53a2e2bab38fc63b6272b
[event] => ConfbridgeJoin
[channel] => SIP/peer_voip301confbridge-0000001c
[uniqueid] => 1437940260.66
[conference] => 0090000156
[calleridnum] => 0090000158
[calleridname] => UID2
[__v] => 0
[sipSetting] => Array
(
[accountcode] =>
[accountcode_naisen] => 203
[extentype] => 0
[extenrealname] =>
[name] => 0090000158
[secret] => Myojyo42f!
[username] => 0090000158
[context] => innercall_xdigit
[gid] => 101
[cid] => 0090000007
)
)
)
i want to merge array with the same value for example :
first array has = [uid] => 0090000157
second array has = [calleridnum] => 0090000157
is it possible to merge them?
this is my code
{foreach from=$participants item=participant key=p }
{foreach from=$conference_participants item=conference_participant key=c}
{if$participants.calleridnum == $conference_participants.uid}
//how to get data here ?
{/if}
{/foreach}
{/foreach}
Could this be what you're looking for?
Sorry for all the changes, I should have tested it... grr
(I've put this in PHPFiddle:
<pre>
<?php
$participants = [
[ 'calleridnum' => 1,
'test' => 'yay'
]
];
$conferance_participants = [
[ 'uid' => 1,
'test' => 'yay2',
'dit' => 'deze'
]
];
foreach ($participants as $participant=>$p) {
foreach ($conferance_participants as $conferance_participant=>$c) {
if ($p['calleridnum'] == $c['uid']) {
// ID's match do the magic here
foreach ( $c as $key=>$val ) {
if (!isset($p[$key])) {
// Value is new, copy the conferance_participant to the participant
$participants[$participant][$key] = $val;
}
} // Merging data
} // If: Match
}
}
print_r( $participants );
?>
)
Presently m working with CakePhp..i got some problem with combining two array and prepare for a json encoded array.. i used array_merge() property but its not working.. how can i encoded both of these two array..
M doing like this :
return json_encode(array_merge ($product_list,$price_list));
i have two php array as follows :
array 1:
Array
(
[0] => Array
(
[PriceList] => Array
(
[price_id] => 2
[price_name] => abc
[date_time] => 2015-07-06 16:22:56
[dealer_type] => Dealer
[purpose] => dealer
[status] => ACTIVE
)
)
[1] => Array
(
[PriceList] => Array
(
[price_id] => 3
[price_name] => xyz
[date_time] => 2015-07-06 16:22:56
[dealer_type] => Dealer
[purpose] => dealer
[status] => ACTIVE
)
)
)
array 2:
Array
(
[0] => Array
(
[Product] => Array
(
[cat_id] => 1
[subcat_id] => 3
[brand_id] => 1
[p_code] => PP12567
[name] => akai
[model_no] =>
[specification] => color tv
[color] =>
[quality] =>
[size] =>
[p_unavail] => 1
[demo_avail] => 0
[brochure] =>
[status] => active
)
[ProductPrice] => Array
(
[id] => 154
[p_code] => PP12567
[price_id] => 1
[quantity] => 233
[purchase_price] => 344.00
[selling_price] => 44.00
[discount_price] => 33.00
[tax] => 5.00
[datetime] => 2015-07-23 15:47:11
)
[ProductSubCategory] => Array
(
[subcat_id] => 3
[cat_id] => 1
[subcat_name] => samsung
[status] => active
)
[ProductCategory] => Array
(
[cat_id] => 1
[cat_name] => Electronics
[cat_type] => Product
[status] => active
)
)
[1] => Array
(
[Product] => Array
(
[cat_id] => 1
[subcat_id] => 4
[brand_id] => 1
[p_code] => PBC-676767
[name] => music
[model_no] => 33
[specification] =>
[color] =>
[quality] =>
[size] =>
[p_unavail] => 0
[demo_avail] => 0
[brochure] =>
[status] => active
)
[ProductPrice] => Array
(
[id] => 156
[p_code] => PBC-676767
[price_id] => 1
[quantity] => 767
[purchase_price] => 54.00
[selling_price] => 55.00
[discount_price] => 22.00
[tax] => 3.00
[datetime] => 2015-07-23 15:47:11
)
[ProductSubCategory] => Array
(
[subcat_id] => 4
[cat_id] => 1
[subcat_name] => sony
[status] => active
)
[ProductCategory] => Array
(
[cat_id] => 1
[cat_name] => Electronics
[cat_type] => Product
[status] => active
)
)
)
how to combine these two array into one and encoded into a json array..
You have to use array_merge but not directly on array1 and array2:
$toEncodeArray = [array_merge ($array1[0], $array2[0])] ;
If you only want the associative array (without the wrapping array), simply do:
$toEncodeArray = array_merge ($array1[0], $array2[0]) ;
I am working on Reporting of the Postal service Project and i wanted to display data with the help of pagination . i know we can overwrite pagination function in model . i have tried it but didn't work for me.
I have BillReport Model where i have created function. Below is my custom query which is showing Multiple Bills against one payment means Payment hasMany Bills. I can paginate Payment but i wanted to paginate Bill wise.
I have mapped the bills and payments in Billpaymentmap table and from that table i am getting array of below query.
I want to paginate related model which is associated with Payment . Payment Hasmany Bill.
$reversal = $this->query("SELECT Pay.*,C.id,C.name,U.id,U.username,Bill.account_no,Bill.id, Pay.*,PMap.data,PMap.paid_amount FROM dbo_payments As Pay INNER JOIN dbo_reverse_payments As RPay ON RPay.payment_id = Pay.id INNER JOIN dbo_payment_bill_maps As PMap ON PMap.payment_id = RPay.payment_id INNER JOIN dbo_users U ON U.id = Pay.cashier_id INNER JOIN dbo_clients As C ON C.id = U.client_id INNER JOIN dbo_bills As Bill ON Bill.id = PMap.bill_id WHERE Pay.reversal = 1 and $conditions ");
Array
(
[0] => Array
(
[Pay] => Array
(
[id] => 10
[location_id] => 133
[cashier_id] => 5
[client_id] => 2
[dealer_id] => 31
[receipt_no] => 58130
[pay_date] => 2015-02-18 12:42:28
[amount_paid] => 3715
[total_paid] => 3715
[change_due] => 0
[pay_method] => CA
[bank] =>
[ref_no] =>
[payment_type] => Bill
[reversal_fee] =>
[reversal_code] =>
[reversal] => 1
[reversal_date] =>
[reversed_by_id] =>
)
[C] => Array
(
[id] => 31
[name] => GAMPOST
)
[U] => Array
(
[id] => 5
[username] => admin
)
[Bill] => Array
(
[account_no] => 1910009
[id] => 1037079
)
[RPay] => Array
(
[id] => 1
[payment_id] => 10
[user_id] => 5
[reason] => LIC
[reversal_fee] =>
[created] => 2015-02-18 13:06:28
)
[PMap] => Array
(
[data] => a:3:{s:4:"name";s:6:"Ganesh";s:7:"address";s:17:"Test address 1sdk";s:11:"paymentType";s:4:"BILL";}
[paid_amount] => 3215.00
)
)
[1] => Array
(
[Pay] => Array
(
[id] => 10
[location_id] => 133
[cashier_id] => 5
[client_id] => 2
[dealer_id] => 31
[receipt_no] => 58130
[pay_date] => 2015-02-18 12:42:28
[amount_paid] => 3715
[total_paid] => 3715
[change_due] => 0
[pay_method] => CA
[bank] =>
[ref_no] =>
[payment_type] => Bill
[reversal_fee] =>
[reversal_code] =>
[reversal] => 1
[reversal_date] =>
[reversed_by_id] =>
)
[C] => Array
(
[id] => 31
[name] => GAMPOST
)
[U] => Array
(
[id] => 5
[username] => admin
)
[Bill] => Array
(
[account_no] => 546865468
[id] => 1037162
)
[RPay] => Array
(
[id] => 1
[payment_id] => 10
[user_id] => 5
[reason] => LIC
[reversal_fee] =>
[created] => 2015-02-18 13:06:28
)
[PMap] => Array
(
[data] => a:3:{s:4:"name";s:38:"Amit Trivedi Trivedi Trivedi Trivedi";s:7:"address";s:6:"Mamura";s:11:"paymentType";s:4:"BILL";}
[paid_amount] => 500.00
)
)
[2] => Array
(
[Pay] => Array
(
[id] => 7
[location_id] => 133
[cashier_id] => 5
[client_id] => 2
[dealer_id] => 31
[receipt_no] => 82053
[pay_date] => 2015-02-18 12:29:21
[amount_paid] => 8380
[total_paid] => 8380
[change_due] => 0
[pay_method] => CA
[bank] =>
[ref_no] =>
[payment_type] => Bill
[reversal_fee] =>
[reversal_code] =>
[reversal] => 1
[reversal_date] =>
[reversed_by_id] =>
)
[C] => Array
(
[id] => 31
[name] => GAMPOST
)
[U] => Array
(
[id] => 5
[username] => admin
)
[Bill] => Array
(
[account_no] => 1910001
[id] => 1037071
)
[RPay] => Array
(
[id] => 2
[payment_id] => 7
[user_id] => 5
[reason] => LF
[reversal_fee] =>
[created] => 2015-02-18 13:06:43
)
[PMap] => Array
(
[data] => a:3:{s:4:"name";s:6:"Tushar";s:7:"address";s:17:"Test address 1sdk";s:11:"paymentType";s:4:"BILL";}
[paid_amount] => 4665.00
)
)
[3] => Array
(
[Pay] => Array
(
[id] => 7
[location_id] => 133
[cashier_id] => 5
[client_id] => 2
[dealer_id] => 31
[receipt_no] => 82053
[pay_date] => 2015-02-18 12:29:21
[amount_paid] => 8380
[total_paid] => 8380
[change_due] => 0
[pay_method] => CA
[bank] =>
[ref_no] =>
[payment_type] => Bill
[reversal_fee] =>
[reversal_code] =>
[reversal] => 1
[reversal_date] =>
[reversed_by_id] =>
)
[C] => Array
(
[id] => 31
[name] => GAMPOST
)
[U] => Array
(
[id] => 5
[username] => admin
)
[Bill] => Array
(
[account_no] => 1910009
[id] => 1037079
)
[RPay] => Array
(
[id] => 2
[payment_id] => 7
[user_id] => 5
[reason] => LF
[reversal_fee] =>
[created] => 2015-02-18 13:06:43
)
[PMap] => Array
(
[data] => a:3:{s:4:"name";s:6:"Ganesh";s:7:"address";s:17:"Test address 1sdk";s:11:"paymentType";s:4:"BILL";}
[paid_amount] => 3215.00
)
)
[4] => Array
(
[Pay] => Array
(
[id] => 7
[location_id] => 133
[cashier_id] => 5
[client_id] => 2
[dealer_id] => 31
[receipt_no] => 82053
[pay_date] => 2015-02-18 12:29:21
[amount_paid] => 8380
[total_paid] => 8380
[change_due] => 0
[pay_method] => CA
[bank] =>
[ref_no] =>
[payment_type] => Bill
[reversal_fee] =>
[reversal_code] =>
[reversal] => 1
[reversal_date] =>
[reversed_by_id] =>
)
[C] => Array
(
[id] => 31
[name] => GAMPOST
)
[U] => Array
(
[id] => 5
[username] => admin
)
[Bill] => Array
(
[account_no] => 546865468
[id] => 1037162
)
[RPay] => Array
(
[id] => 2
[payment_id] => 7
[user_id] => 5
[reason] => LF
[reversal_fee] =>
[created] => 2015-02-18 13:06:43
)
[PMap] => Array
(
[data] => a:3:{s:4:"name";s:38:"Amit Trivedi Trivedi Trivedi Trivedi";s:7:"address";s:6:"Mamura";s:11:"paymentType";s:4:"BILL";}
[paid_amount] => 500.00
)
)
)
I have googled but i am not getting my answer. Can anyone please help me on this.
Thanks for reply.
I went through below link . i have given limit => 3 . it is giving me data upto 3 for Payments Not for Bills which are multiple against one Payment.
I need to paginate 'PaymentBillMap' data .
public $paginate = array('limit'=>'3',
'order'=>'Payment.pay_date',
'fields'=>array('Payment.id','Payment.location_id','Payment.dealer_id'));
public function trans_list_service(){
$params = $this->__commonopr();
$this->loadModel('Payment');
$this->loadModel('PaymentBillMap');
$conditions = array('Payment.location_id ' => 133);
// apply the custom conditions to the pagination
$payments = $this->paginate('Payment',$conditions);
$this->set('payments', $payments);
pr($payments);
}
Custom Query Pagination Cakephp
Array
(
[0] => Array
(
[Payment] => Array
(
[id] => 1
[location_id] => 133
[dealer_id] => 31
)
[PaymentBillMap] => Array
(
[0] => Array
(
[payment_id] => 1
[bill_id] => 1037153
[paid_amount] => 4656.00
[payment_type] => BILL
[trans_no] => 24862
[data] => a:3:{s:4:"name";s:6:"Ganesh";s:7:"address";s:7:"Dholpur";s:11:"paymentType";s:4:"BILL";}
)
[1] => Array
(
[payment_id] => 1
[bill_id] => 1037154
[paid_amount] => 4665.00
[payment_type] => BILL
[trans_no] => 48280
[data] => a:3:{s:4:"name";s:5:"AMITA";s:7:"address";s:10:"Ganganagar";s:11:"paymentType";s:4:"BILL";}
)
[2] => Array
(
[payment_id] => 1
[bill_id] => 1037155
[paid_amount] => 5787.00
[payment_type] => BILL
[trans_no] => 45996
[data] => a:3:{s:4:"name";s:9:"duryodhan";s:7:"address";s:5:"Jalor";s:11:"paymentType";s:4:"BILL";}
)
[3] => Array
(
[payment_id] => 1
[bill_id] => 1037156
[paid_amount] => 6688.00
[payment_type] => BILL
[trans_no] => 64019
[data] => a:3:{s:4:"name";s:6:"Dharaj";s:7:"address";s:8:"Jhalawar";s:11:"paymentType";s:4:"BILL";}
)
[4] => Array
(
[payment_id] => 1
[bill_id] => 1037157
[paid_amount] => 8795.00
[payment_type] => BILL
[trans_no] => 21308
[data] => a:3:{s:4:"name";s:4:"Amit";s:7:"address";s:9:"Jhunjhunu";s:11:"paymentType";s:4:"BILL";}
)
[5] => Array
(
[payment_id] => 1
[bill_id] => 1037158
[paid_amount] => 5654.00
[payment_type] => BILL
[trans_no] => 10980
[data] => a:3:{s:4:"name";s:5:"Gaesh";s:7:"address";s:4:"Pali";s:11:"paymentType";s:4:"BILL";}
)
[6] => Array
(
[payment_id] => 1
[bill_id] => 1037159
[paid_amount] => 3456.00
[payment_type] => BILL
[trans_no] => 79988
[data] => a:3:{s:4:"name";s:4:"Jitu";s:7:"address";s:14:"Sawai Madhopur";s:11:"paymentType";s:4:"BILL";}
)
[7] => Array
(
[payment_id] => 1
[bill_id] => 1037160
[paid_amount] => 4664.00
[payment_type] => BILL
[trans_no] => 26314
[data] => a:3:{s:4:"name";s:6:"Rajesh";s:7:"address";s:6:"Sirohi";s:11:"paymentType";s:4:"BILL";}
)
[8] => Array
(
[payment_id] => 1
[bill_id] => 1037161
[paid_amount] => 3565.00
[payment_type] => BILL
[trans_no] => 40148
[data] => a:3:{s:4:"name";s:4:"Gani";s:7:"address";s:5:"Baran";s:11:"paymentType";s:4:"BILL";}
)
[9] => Array
(
[payment_id] => 1
[bill_id] => 1037148
[paid_amount] => 3442.00
[payment_type] => BILL
[trans_no] => 48235
[data] => a:3:{s:4:"name";s:4:"Jitu";s:7:"address";s:5:"Ajmer";s:11:"paymentType";s:4:"BILL";}
)
[10] => Array
(
[payment_id] => 1
[bill_id] => 1037149
[paid_amount] => 4335.00
[payment_type] => BILL
[trans_no] => 71496
[data] => a:3:{s:4:"name";s:4:"amer";s:7:"address";s:5:"Alwar";s:11:"paymentType";s:4:"BILL";}
)
[11] => Array
(
[payment_id] => 1
[bill_id] => 1037150
[paid_amount] => 3535.00
[payment_type] => BILL
[trans_no] => 93135
[data] => a:3:{s:4:"name";s:6:"Dilip[";s:7:"address";s:9:"Bharatpur";s:11:"paymentType";s:4:"BILL";}
)
[12] => Array
(
[payment_id] => 1
[bill_id] => 1037151
[paid_amount] => 6453.00
[payment_type] => BILL
[trans_no] => 46714
[data] => a:3:{s:4:"name";s:7:"Suvarna";s:7:"address";s:11:"Chittorgarh";s:11:"paymentType";s:4:"BILL";}
)
[13] => Array
(
[payment_id] => 1
[bill_id] => 1037152
[paid_amount] => 5323.00
[payment_type] => BILL
[trans_no] => 43007
[data] => a:3:{s:4:"name";s:5:"Datta";s:7:"address";s:5:"Churu";s:11:"paymentType";s:4:"BILL";}
)
[14] => Array
(
[payment_id] => 1
[bill_id] => 1037136
[paid_amount] => 6456.00
[payment_type] => BILL
[trans_no] => 27701
[data] => a:3:{s:4:"name";s:6:"Faizan";s:7:"address";s:9:"Dungarpur";s:11:"paymentType";s:4:"BILL";}
)
[15] => Array
(
[payment_id] => 1
[bill_id] => 1037137
[paid_amount] => 7657.00
[payment_type] => BILL
[trans_no] => 29162
[data] => a:3:{s:4:"name";s:6:"Shamli";s:7:"address";s:7:"Jodhpur";s:11:"paymentType";s:4:"BILL";}
)
[16] => Array
(
[payment_id] => 1
[bill_id] => 1037138
[paid_amount] => 8688.00
[payment_type] => BILL
[trans_no] => 77181
[data] => a:3:{s:4:"name";s:6:"Tushat";s:7:"address";s:4:"Kota";s:11:"paymentType";s:4:"BILL";}
)
[17] => Array
(
[payment_id] => 1
[bill_id] => 1037139
[paid_amount] => 4657.00
[payment_type] => BILL
[trans_no] => 75049
[data] => a:3:{s:4:"name";s:5:"Danav";s:7:"address";s:7:"Udaipur";s:11:"paymentType";s:4:"BILL";}
)
[18] => Array
(
[payment_id] => 1
[bill_id] => 1037140
[paid_amount] => 6886.00
[payment_type] => BILL
[trans_no] => 48850
[data] => a:3:{s:4:"name";s:6:"Kailas";s:7:"address";s:7:"Bikaner";s:11:"paymentType";s:4:"BILL";}
)
[19] => Array
(
[payment_id] => 1
[bill_id] => 1037141
[paid_amount] => 7965.00
[payment_type] => BILL
[trans_no] => 11684
[data] => a:3:{s:4:"name";s:7:"Paravat";s:7:"address";s:5:"Dausa";s:11:"paymentType";s:4:"BILL";}
)
)
)
[1] => Array
(
[Payment] => Array
(
[id] => 2
[location_id] => 133
[dealer_id] => 31
)
[PaymentBillMap] => Array
(
[0] => Array
(
[payment_id] => 2
[bill_id] => 1037162
[paid_amount] => 500.00
[payment_type] => BILL
[trans_no] => 62066
[data] => a:3:{s:4:"name";s:37:"Amit Trivedi Trivedi Trivedi Trivedi";s:7:"address";s:6:"Mamura";s:11:"paymentType";s:4:"BILL";}
)
[1] => Array
(
[payment_id] => 2
[bill_id] => 1037079
[paid_amount] => 3215.00
[payment_type] => BILL
[trans_no] => 41810
[data] => a:3:{s:4:"name";s:6:"Ganesh";s:7:"address";s:17:"Test address 1sdk";s:11:"paymentType";s:4:"BILL";}
)
)
)
[2] => Array
(
[Payment] => Array
(
[id] => 3
[location_id] => 133
[dealer_id] => 31
)
[PaymentBillMap] => Array
(
[0] => Array
(
[payment_id] => 3
[bill_id] => 1037162
[paid_amount] => 500.00
[payment_type] => BILL
[trans_no] => 74439
[data] => a:3:{s:4:"name";s:38:"Amit Trivedi Trivedi Trivedi Trivedi";s:7:"address";s:6:"Mamura";s:11:"paymentType";s:4:"BILL";}
)
)
)
)
I have a multidimensional array and am trying to group them according to the value of array properties.
I'm trying to group them by id, but I won't actually know the id beforehand. So, it's not like I can put it in a for loop and say while i < 7, because I won't know that 7 is the maximum value for the id value,
Array (
[0] => Array (
[name] => R8900
[type] => public
[id] => 1
)
[1] => Array (
[name] => R8944
[type] => public
[id] => 1
)
[2] => Array (
[name] => R8922
[type] => private
[id] => 3
)
[3] => Array (
[name] => R8816
[type] => private
[id] => 3
)
[4] => Array (
[name] => R7434
[type] => VIP
[id] => 7
)
)
What I'm hoping to produce:
Array (
[1] => Array (
[0] => Array (
[name] => R8900
[type] => public
)
[1] => Array (
[name] => R8944
[type] => public
)
)
[3] => Array (
[2] => Array (
[name] => R8922
[type] => private
)
[3] => Array (
[name] => R8816
[type] => private
)
)
[7] => Array (
[4] => Array (
[name] => R7434
[type] => VIP
)
)
)
Something as simple as:
var result:Object = {};
for each(var i:Object in input)
{
if(!result.hasOwnProperty(i.id))
{
result[i.id] = [];
}
result[i.id].push(i);
delete i.id;
}