Newer
Older
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
namespace QUI\Memberships;
use QUI\CRUD\Factory;
use QUI\Utils\Grid;
use QUI;
class Handler extends Factory
{
/**
* @inheritdoc
* @return string
*/
public function getDataBaseTableName()
{
return 'quiqqer_memberships';
}
/**
* @inheritdoc
* @return string
*/
public function getChildClass()
{
return Membership::class;
}
/**
* @inheritdoc
* @return array
*/
public function getChildAttributes()
{
return array(
'title',
'description',
'content',
'duration',
'groupIds',
'autoRenew',
'editDate',
'editUser',
'createDate',
'createUser',
// these fields require quiqqer/order
'paymentInterval',
'netPrice',
'netPriceOffer',
// 'grossPrice',
'paymentMethodIds'
// @todo additional fields for quiqqer/contracts
);
}
/**
* Search memberships
*
* @param array $searchParams
* @param bool $countOnly (optional) - get count for search result only [default: false]
* @return array
*/
public function search($searchParams, $countOnly = false)
{
$memberships = array();
$Grid = new Grid($searchParams);
$gridParams = $Grid->parseDBParams($searchParams);
$whereOr = array();
if (!empty($searchParams['search'])) {
$search = $searchParams['search'];
$whereOr['title'] = array(
'type' => '%LIKE%',
'value' => $search
);
$whereOr['description'] = array(
'type' => '%LIKE%',
'value' => $search
);
$whereOr['content'] = array(
'type' => '%LIKE%',
'value' => $search
);
}
if ($countOnly) {
$result = QUI::getDataBase()->fetch(array(
'count' => 1,
'from' => $this->getDataBaseTableName(),
'where_or' => $whereOr
));
return current(current($result));
}
$result = QUI::getDataBase()->fetch(array(
'select' => array(
'id'
),
'from' => $this->getDataBaseTableName(),
'where_or' => $whereOr,
'limit' => $gridParams['limit']
));
foreach ($result as $row) {
$memberships[] = $this->getChild($row['id']);
}
return $memberships;
}
}