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