dolibarr 21.0.0-alpha
badges.inc.php
1<?php
2/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
3 */
4if (!defined('ISLOADEDBYSTEELSHEET')) {
5 die('Must be call by steelsheet');
6}
7'
8@phan-var-force string $badgePrimary
9@phan-var-force string $badgeSecondary
10@phan-var-force string $badgeSuccess
11@phan-var-force string $badgeDanger
12@phan-var-force string $badgeWarning
13@phan-var-force string $badgeInfo
14@phan-var-force string $badgeLight
15@phan-var-force string $badgeDark
16@phan-var-force string $colorblind_deuteranopes_badgeWarning
17';
18?>
19/* Badge style is based on bootstrap framework */
20
21.badge {
22 display: inline-block;
23 padding: .1em .35em;
24 font-size: 80%;
25 font-weight: 700 !important;
26 line-height: 1;
27 text-align: center;
28 white-space: nowrap;
29 vertical-align: baseline;
30 border-radius: .25rem;
31 transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
32 border-width: 2px;
33 border-style: solid;
34 border-color: rgba(255,255,255,0);
35 box-sizing: border-box;
36}
37
38.badge-status {
39 font-size: 0.95em;
40 padding: .19em .35em; /* more than 0.19 generate a change into height of lines */
41}
42.tabBar .arearef .statusref .badge-status, .tabBar .arearefnobottom .statusref .badge-status {
43 font-size: 1.1em;
44 padding: .4em .4em;
45}
46/* Force values for small screen 767 */
47@media only screen and (max-width: 767px)
48{
49 .tabBar .arearef .statusref .badge-status, .tabBar .arearefnobottom .statusref .badge-status {
50 font-size: 0.95em;
51 padding: .3em .2em;
52 }
53}
54
55.badge-pill, .tabs .badge {
56 padding-right: .5em;
57 padding-left: .5em;
58 border-radius: 0.25rem;
59}
60
61.badge-dot {
62 padding: 0;
63 border-radius: 50%;
64 padding: 0.45em;
65 vertical-align: text-top;
66}
67
68a.badge:focus, a.badge:hover {
69 text-decoration: none;
70}
71
72.liste_titre .badge:not(.nochangebackground) {
73 background-color: <?php print $badgeSecondary; ?>;
74 color: #fff;
75}
76
77span.badgeneutral {
78 padding: 2px 7px 2px 7px;
79 background-color: #e4e4e4;
80 color: #666;
81 border-radius: 10px;
82 white-space: nowrap;
83}
84
85
86/* PRIMARY */
87.badge-primary{
88 color: #fff !important;
89 background-color: <?php print $badgePrimary; ?>;
90}
91a.badge-primary.focus, a.badge-primary:focus {
92 outline: 0;
93 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgePrimary, 0.5); ?>;
94}
95a.badge-primary:focus, a.badge-primary:hover {
96 color: #fff !important;
97 background-color: <?php print colorDarker($badgePrimary, 10); ?>;
98}
99
100/* SECONDARY */
101.badge-secondary, .tabs .badge {
102 color: #fff !important;
103 background-color: <?php print $badgeSecondary; ?>;
104}
105a.badge-secondary.focus, a.badge-secondary:focus {
106 outline: 0;
107 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSecondary, 0.5); ?>;
108}
109a.badge-secondary:focus, a.badge-secondary:hover {
110 color: #fff !important;
111 background-color: <?php print colorDarker($badgeSecondary, 10); ?>;
112}
113
114/* SUCCESS */
115.badge-success {
116 color: #fff !important;
117 background-color: <?php print $badgeSuccess; ?>;
118}
119a.badge-success.focus, a.badge-success:focus {
120 outline: 0;
121 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSuccess, 0.5); ?>;
122}
123a.badge-success:focus, a.badge-success:hover {
124 color: #fff !important;
125 background-color: <?php print colorDarker($badgeSuccess, 10); ?>;
126}
127
128/* DANGER */
129.badge-danger {
130 color: #fff !important;
131 background-color: <?php print $badgeDanger; ?>;
132}
133a.badge-danger.focus, a.badge-danger:focus {
134 outline: 0;
135 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDanger, 0.5); ?>;
136}
137a.badge-danger:focus, a.badge-danger:hover {
138 color: #fff !important;
139 background-color: <?php print colorDarker($badgeDanger, 10); ?>;
140}
141
142/* WARNING */
143.badge-warning {
144 color: #fff !important;
145 background-color: <?php print $badgeWarning; ?>;
146}
147a.badge-warning.focus, a.badge-warning:focus {
148 outline: 0;
149 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeWarning, 0.5); ?>;
150}
151a.badge-warning:focus, a.badge-warning:hover {
152 color: #212529 !important;
153 background-color: <?php print colorDarker($badgeWarning, 10); ?>;
154}
155
156/* WARNING colorblind */
157body[class*="colorblind-"] .badge-warning {
158 background-color: <?php print $colorblind_deuteranopes_badgeWarning; ?>;
159 }
160body[class*="colorblind-"] a.badge-warning.focus,body[class^="colorblind-"] a.badge-warning:focus {
161 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($colorblind_deuteranopes_badgeWarning, 0.5); ?>;
162}
163body[class*="colorblind-"] a.badge-warning:focus, a.badge-warning:hover {
164 background-color: <?php print colorDarker($colorblind_deuteranopes_badgeWarning, 10); ?>;
165}
166
167/* INFO */
168.badge-info {
169 color: #fff !important;
170 background-color: <?php print $badgeInfo; ?>;
171}
172a.badge-info.focus, a.badge-info:focus {
173 outline: 0;
174 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeInfo, 0.5); ?>;
175}
176a.badge-info:focus, a.badge-info:hover {
177 color: #fff !important;
178 background-color: <?php print colorDarker($badgeInfo, 10); ?>;
179}
180
181/* LIGHT */
182.badge-light {
183 color: #212529 !important;
184 background-color: <?php print $badgeLight; ?>;
185}
186a.badge-light.focus, a.badge-light:focus {
187 outline: 0;
188 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeLight, 0.5); ?>;
189}
190a.badge-light:focus, a.badge-light:hover {
191 color: #212529 !important;
192 background-color: <?php print colorDarker($badgeLight, 10); ?>;
193}
194
195/* DARK */
196.badge-dark {
197 color: #fff !important;
198 background-color: <?php print $badgeDark; ?>;
199}
200a.badge-dark.focus, a.badge-dark:focus {
201 outline: 0;
202 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDark, 0.5); ?>;
203}
204a.badge-dark:focus, a.badge-dark:hover {
205 color: #fff !important;
206 background-color: <?php print colorDarker($badgeDark, 10); ?>;
207}
208
209
210@media only screen and (max-width: 570px)
211{
212 span.badge.badge-status {
213 overflow: hidden;
214 max-width: 130px;
215 text-overflow: ellipsis;
216 }
217}
218
219
220/* STATUS BADGES */
221<?php
222for ($i = 0; $i <= 10; $i++) {
223 /* Default Status */
224 _createStatusBadgeCss((string) $i, '', "STATUS".$i);
225
226 // create status for accessibility
227 _createStatusBadgeCss((string) $i, 'colorblind_deuteranopes_', "COLORBLIND STATUS".$i, 'body[class*="colorblind-"] ');
228}
229
230_createStatusBadgeCss('1b', '', "STATUS1b");
231_createStatusBadgeCss('4b', '', "STATUS4b");
232
233
243function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentLabel = '', $cssPrefix = '')
244{
245 global ${$statusVarNamePrefix.'badgeStatus'.$statusName}, ${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName};
246
247 if (!empty(${$statusVarNamePrefix.'badgeStatus'.$statusName})) {
248 print "\n/* ".strtoupper($commentLabel)." */\n";
249
250 $thisBadgeBackgroundColor = $thisBadgeBorderColor = ${$statusVarNamePrefix.'badgeStatus'.$statusName};
251
252 $TBadgeBorderOnly = array('0', '1b', '3', '4b', '5', '7', '10');
253 $thisBadgeTextColor = colorIsLight(${$statusVarNamePrefix.'badgeStatus'.$statusName}) ? '#212529' : '#ffffff';
254
255 if (!empty(${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName})) {
256 $thisBadgeTextColor = ${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName};
257 }
258
259 if (in_array((string) $statusName, $TBadgeBorderOnly)) {
260 $thisBadgeTextColor = '#212529';
261 $thisBadgeBackgroundColor = "";
262 }
263
264 if (in_array((string) $statusName, array('0', '5', '9'))) {
265 $thisBadgeTextColor = '#999999';
266 }
267 if (in_array((string) $statusName, array('6'))) {
268 $thisBadgeTextColor = '#777777';
269 }
270
271 // badge-statusX
272 print $cssPrefix.".badge-status".$statusName." {\n";
273 print " color: ".$thisBadgeTextColor." !important;\n";
274 if (in_array((string) $statusName, $TBadgeBorderOnly)) {
275 print " border-color: ".$thisBadgeBorderColor." !important;\n";
276 }
277 if ($thisBadgeBackgroundColor != '') {
278 print " background-color: ".$thisBadgeBackgroundColor." !important;\n";
279 }
280 print "}\n";
281
282 print $cssPrefix.".font-status".$statusName." {\n";
283 if ($thisBadgeBackgroundColor != '') {
284 print " color: ".$thisBadgeBackgroundColor." !important;\n";
285 }
286 print "}\n";
287
288 print $cssPrefix.".badge-status".$statusName.".focus, ".$cssPrefix.".badge-status".$statusName.":focus {\n";
289 print " outline: 0;\n";
290 print " box-shadow: 0 0 0 0.2rem ".colorHexToRgb($thisBadgeBackgroundColor, 0.5)." !important;\n";
291 print "}\n";
292
293 // badge-statusX:focus
294 print $cssPrefix.".badge-status".$statusName.":focus, ".$cssPrefix.".badge-status".$statusName.":hover {\n";
295 print " color: ".$thisBadgeTextColor." !important;\n";
296 //print " background-color: " . colorDarker($thisBadgeBackgroundColor, 10) . ";\n";
297 if (in_array((string) $statusName, $TBadgeBorderOnly)) {
298 print " border-color: ".colorDarker($thisBadgeBorderColor, 10)." !important;\n";
299 }
300 print "}\n";
301 }
302}
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition security.php:640
colorHexToRgb($hex, $alpha=false, $returnArray=false)
colorDarker($hex, $percent)
colorIsLight($stringcolor)
Return true if the color is light.