Commit | Line | Data |
---|---|---|
31a99426 PN |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.7 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2015 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * This api exposes CiviCRM Order records. | |
30 | * | |
31 | * @package CiviCRM_APIv3 | |
32 | */ | |
33 | ||
34 | /** | |
35 | * Retrieve a set of Order. | |
36 | * | |
37 | * @param array $params | |
38 | * Input parameters. | |
39 | * | |
40 | * @return array | |
41 | * Array of Order, if error an array with an error id and error message | |
42 | */ | |
43 | function civicrm_api3_order_get($params) { | |
44 | $contributions = array(); | |
45 | $params['api.line_item.get'] = array('qty' => array('<>' => 0)); | |
46 | $isSequential = FALSE; | |
47 | if (CRM_Utils_Array::value('sequential', $params)) { | |
48 | $params['sequential'] = 0; | |
49 | $isSequential = TRUE; | |
50 | } | |
51 | $result = civicrm_api3('Contribution', 'get', $params); | |
52 | if (!empty($result['values'])) { | |
53 | foreach ($result['values'] as $key => $contribution) { | |
54 | $contributions[$key] = $contribution; | |
55 | $contributions[$key]['line_items'] = $contribution['api.line_item.get']['values']; | |
56 | unset($contributions[$key]['api.line_item.get']); | |
57 | } | |
58 | } | |
59 | $params['sequential'] = $isSequential; | |
60 | return civicrm_api3_create_success($contributions, $params, 'Order', 'get'); | |
61 | } |