-
Notifications
You must be signed in to change notification settings - Fork 6
/
farm_ledger.views.inc
61 lines (57 loc) · 1.6 KB
/
farm_ledger.views.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* @file
* Provides Views data for farm_ledger.module.
*/
/**
* Implements hook_views_data_alter().
*/
function farm_ledger_views_data_alter(array &$data) {
// Create unit price field, filter, and sort using fraction decimal handlers.
$fraction_fields = [
'numerator' => 'unit_price_numerator',
'denominator' => 'unit_price_denominator',
];
$data['quantity__unit_price']['unit_price_value'] = [
'title' => t('Unit price'),
'help' => t('Value of the unit price, in decimal format.'),
'real field' => 'unit_price_numerator',
'field' => [
'id' => 'fraction',
'additional fields' => $fraction_fields,
'click sortable' => TRUE,
],
'sort' => [
'id' => 'fraction',
'additional fields' => $fraction_fields,
],
'filter' => [
'id' => 'fraction',
'additional fields' => $fraction_fields,
],
];
// Create total price field, filter, and sort using fraction decimal
// handlers.
$fraction_fields = [
'numerator' => 'total_price_numerator',
'denominator' => 'total_price_denominator',
];
$data['quantity__total_price']['total_price_value'] = [
'title' => t('Total price'),
'help' => t('Value of the total price, in decimal format.'),
'real field' => 'total_price_numerator',
'field' => [
'id' => 'fraction',
'additional fields' => $fraction_fields,
'click sortable' => TRUE,
],
'sort' => [
'id' => 'fraction',
'additional fields' => $fraction_fields,
],
'filter' => [
'id' => 'fraction',
'additional fields' => $fraction_fields,
],
];
}