1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverCommerce\OrdersAdmin\Extensions; |
4
|
|
|
|
5
|
|
|
use SilverStripe\ORM\DataExtension; |
6
|
|
|
use SilverStripe\Forms\TextField; |
7
|
|
|
use SilverStripe\Forms\FieldList; |
8
|
|
|
use SilverStripe\ORM\ArrayList; |
9
|
|
|
use SilverStripe\Forms\ReadonlyField; |
10
|
|
|
use SilverStripe\Core\Config\Config; |
11
|
|
|
use SilverCommerce\ContactAdmin\Model\Contact; |
12
|
|
|
use SilverCommerce\OrdersAdmin\Model\Invoice; |
13
|
|
|
use SilverCommerce\OrdersAdmin\Model\Estimate; |
14
|
|
|
use SilverCommerce\OrdersAdmin\Model\MemberAddress; |
|
|
|
|
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Add additional settings to a memeber object |
18
|
|
|
* |
19
|
|
|
* @package orders-admin |
20
|
|
|
* @subpackage extensions |
21
|
|
|
*/ |
22
|
|
|
class MemberExtension extends DataExtension |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Get a discount from the groups this member is in |
26
|
|
|
* |
27
|
|
|
* @return Discount |
|
|
|
|
28
|
|
|
*/ |
29
|
|
|
public function getDiscount() |
30
|
|
|
{ |
31
|
|
|
$discounts = ArrayList::create(); |
32
|
|
|
|
33
|
|
|
foreach ($this->owner->Groups() as $group) { |
34
|
|
|
foreach ($group->Discounts() as $discount) { |
35
|
|
|
$discounts->add($discount); |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$discounts->sort("Amount", "DESC"); |
40
|
|
|
|
41
|
|
|
return $discounts->first(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Get all invoices from a contact |
46
|
|
|
* |
47
|
|
|
* @return DataList |
|
|
|
|
48
|
|
|
*/ |
49
|
|
|
public function Invoices() |
50
|
|
|
{ |
51
|
|
|
return $this |
52
|
|
|
->owner |
53
|
|
|
->Contact() |
54
|
|
|
->Invoices(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Get all estimates from a contact |
59
|
|
|
* |
60
|
|
|
* @return DataList |
61
|
|
|
*/ |
62
|
|
|
public function Estimates() |
63
|
|
|
{ |
64
|
|
|
return $this |
65
|
|
|
->owner |
66
|
|
|
->Contact() |
67
|
|
|
->Estimates(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Get all invoices from a contact that are designated |
72
|
|
|
* "outstanding" |
73
|
|
|
* |
74
|
|
|
* @return DataList |
75
|
|
|
*/ |
76
|
|
|
public function OutstandingInvoices() |
77
|
|
|
{ |
78
|
|
|
return $this |
79
|
|
|
->owner |
80
|
|
|
->Contact() |
81
|
|
|
->OutstandingInvoices(); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Get all invoices from a contact that are designated |
86
|
|
|
* "historic" |
87
|
|
|
* |
88
|
|
|
* @return DataList |
89
|
|
|
*/ |
90
|
|
|
public function HistoricInvoices() |
91
|
|
|
{ |
92
|
|
|
return $this |
93
|
|
|
->owner |
94
|
|
|
->Contact() |
95
|
|
|
->HistoricInvoices(); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths