Debian Codegraph @

lib/types/pykotaBillingCodeType.inc

raw
1 <?php
2 /*
3
4 This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
5 Copyright (C) 2013 - 2025 Roland Gruber
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21 */
22
23 /**
24 * The account type for PyKota billing codes.
25 *
26 * @package types
27 * @author Roland Gruber
28 */
29
30 use LAM\TYPES\ConfiguredType;
31
32 /**
33 * The account type for PyKota billing codes.
34 *
35 * @package types
36 */
37 class pykotaBillingCodeType extends baseType {
38
39 /**
40 * Constructs a new billing code object.
41 *
42 * @param ConfiguredType $type configuration
43 */
44 public function __construct($type) {
45 parent::__construct($type);
46 $this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another billing code');
47 $this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to billing code list');
48 }
49
50 /**
51 * {@inheritDoc}
52 */
53 public function getAlias(): string {
54 return _("Billing codes");
55 }
56
57 /**
58 * {@inheritDoc}
59 */
60 public function getDescription(): string {
61 return _("PyKota billing codes");
62 }
63
64 /**
65 * {@inheritDoc}
66 */
67 public function getListClassName(): string {
68 return lamPykotaBillingCodeTypeList::class;
69 }
70
71 /**
72 * {@inheritDoc}
73 */
74 public function getDefaultListAttributes(): string {
75 return "#cn;#description;#pykotaBalance;#pykotaPageCounter";
76 }
77
78 /**
79 * {@inheritDoc}
80 */
81 public function getTitleBarTitle(accountContainer $container): ?string {
82 // get attributes
83 $attributes = [];
84 if ($container->getAccountModule('pykotaBillingCode') != null) {
85 $attributes = $container->getAccountModule('pykotaBillingCode')->getAttributes();
86 }
87 // check if pykotaBillingCode is set
88 if (isset($attributes['pykotaBillingCode'][0])) {
89 return htmlspecialchars($attributes['pykotaBillingCode'][0]);
90 }
91 // show new label
92 if ($container->isNewAccount) {
93 return _("New billing code");
94 }
95 // fall back to default
96 return parent::getTitleBarTitle($container);
97 }
98
99 /**
100 * {@inheritDoc}
101 */
102 public function getTitleBarSubtitle(accountContainer $container): string {
103 // get attributes
104 $attributes = [];
105 if ($container->getAccountModule('pykotaBillingCode') != null) {
106 $attributes = $container->getAccountModule('pykotaBillingCode')->getAttributes();
107 }
108 // check if description is set
109 if (isset($attributes['description'][0])) {
110 return htmlspecialchars($attributes['description'][0]);
111 }
112 // fall back to default
113 return parent::getTitleBarSubtitle($container);
114 }
115
116 /**
117 * {@inheritDoc}
118 * @see baseType::getIcon()
119 */
120 public function getIcon(): string {
121 return 'printer.svg';
122 }
123
124 }
125
126
127 /**
128 * Generates the list view.
129 *
130 * @package lists
131 * @author Roland Gruber
132 *
133 */
134 class lamPykotaBillingCodeTypeList extends lamList {
135
136 /**
137 * Constructor
138 *
139 * @param ConfiguredType $type account type
140 */
141 public function __construct(ConfiguredType $type) {
142 parent::__construct($type);
143 $this->labels = [
144 'nav' => _("Billing code count: %s"),
145 'error_noneFound' => _("No billing codes found!"),
146 'newEntry' => _("New billing code"),
147 'deleteEntry' => _("Delete selected billing codes")
148 ];
149 }
150
151 }