dolibarr 21.0.3
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.badge-pill, .tabs .badge {
71 padding-right: .5em;
72 padding-left: .5em;
73 border-radius: 0.25rem;
74}
75
76.badge-dot {
77 padding: 0;
78 border-radius: 50%;
79 padding: 0.45em;
80 vertical-align: text-top;
81}
82
83a.badge:focus, a.badge:hover {
84 text-decoration: none;
85}
86
87.liste_titre .badge:not(.nochangebackground) {
88 background-color: <?php print $badgeSecondary; ?>;
89 color: #fff;
90}
91
92span.badgeneutral {
93 padding: 2px 7px 2px 7px;
94 background-color: #e4e4e4;
95 color: #666;
96 border-radius: 10px;
97 white-space: nowrap;
98}
99
100
101/* PRIMARY */
102.badge-primary{
103 color: #fff !important;
104 background-color: <?php print $badgePrimary; ?>;
105}
106a.badge-primary.focus, a.badge-primary:focus {
107 outline: 0;
108 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgePrimary, 0.5); ?>;
109}
110a.badge-primary:focus, a.badge-primary:hover {
111 color: #fff !important;
112 background-color: <?php print colorDarker($badgePrimary, 10); ?>;
113}
114
115/* SECONDARY */
116.badge-secondary, .tabs .badge {
117 color: #fff !important;
118 background-color: <?php print $badgeSecondary; ?>;
119}
120a.badge-secondary.focus, a.badge-secondary:focus {
121 outline: 0;
122 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSecondary, 0.5); ?>;
123}
124a.badge-secondary:focus, a.badge-secondary:hover {
125 color: #fff !important;
126 background-color: <?php print colorDarker($badgeSecondary, 10); ?>;
127}
128
129/* SUCCESS */
130.badge-success {
131 color: #fff !important;
132 background-color: <?php print $badgeSuccess; ?>;
133}
134a.badge-success.focus, a.badge-success:focus {
135 outline: 0;
136 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSuccess, 0.5); ?>;
137}
138a.badge-success:focus, a.badge-success:hover {
139 color: #fff !important;
140 background-color: <?php print colorDarker($badgeSuccess, 10); ?>;
141}
142
143/* DANGER */
144.badge-danger {
145 color: #fff !important;
146 background-color: <?php print $badgeDanger; ?>;
147}
148a.badge-danger.focus, a.badge-danger:focus {
149 outline: 0;
150 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDanger, 0.5); ?>;
151}
152a.badge-danger:focus, a.badge-danger:hover {
153 color: #fff !important;
154 background-color: <?php print colorDarker($badgeDanger, 10); ?>;
155}
156
157/* WARNING */
158.badge-warning {
159 color: #fff !important;
160 background-color: <?php print $badgeWarning; ?>;
161}
162a.badge-warning.focus, a.badge-warning:focus {
163 outline: 0;
164 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeWarning, 0.5); ?>;
165}
166a.badge-warning:focus, a.badge-warning:hover {
167 color: #212529 !important;
168 background-color: <?php print colorDarker($badgeWarning, 10); ?>;
169}
170
171/* WARNING colorblind */
172body[class*="colorblind-"] .badge-warning {
173 background-color: <?php print $colorblind_deuteranopes_badgeWarning; ?>;
174 }
175body[class*="colorblind-"] a.badge-warning.focus,body[class^="colorblind-"] a.badge-warning:focus {
176 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($colorblind_deuteranopes_badgeWarning, 0.5); ?>;
177}
178body[class*="colorblind-"] a.badge-warning:focus, a.badge-warning:hover {
179 background-color: <?php print colorDarker($colorblind_deuteranopes_badgeWarning, 10); ?>;
180}
181
182/* INFO */
183.badge-info {
184 color: #fff !important;
185 background-color: <?php print $badgeInfo; ?>;
186}
187a.badge-info.focus, a.badge-info:focus {
188 outline: 0;
189 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeInfo, 0.5); ?>;
190}
191a.badge-info:focus, a.badge-info:hover {
192 color: #fff !important;
193 background-color: <?php print colorDarker($badgeInfo, 10); ?>;
194}
195
196/* LIGHT */
197.badge-light {
198 color: #212529 !important;
199 background-color: <?php print $badgeLight; ?>;
200}
201a.badge-light.focus, a.badge-light:focus {
202 outline: 0;
203 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeLight, 0.5); ?>;
204}
205a.badge-light:focus, a.badge-light:hover {
206 color: #212529 !important;
207 background-color: <?php print colorDarker($badgeLight, 10); ?>;
208}
209
210/* DARK */
211.badge-dark {
212 color: #fff !important;
213 background-color: <?php print $badgeDark; ?>;
214}
215a.badge-dark.focus, a.badge-dark:focus {
216 outline: 0;
217 box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDark, 0.5); ?>;
218}
219a.badge-dark:focus, a.badge-dark:hover {
220 color: #fff !important;
221 background-color: <?php print colorDarker($badgeDark, 10); ?>;
222}
223
224
225@media only screen and (max-width: 570px)
226{
227 span.badge.badge-status {
228 overflow: hidden;
229 max-width: 130px;
230 text-overflow: ellipsis;
231 }
232}
233
234
235/* STATUS BADGES */
236<?php
237for ($i = 0; $i <= 10; $i++) {
238 /* Default Status */
239 _createStatusBadgeCss((string) $i, '', "STATUS".$i);
240
241 // create status for accessibility
242 _createStatusBadgeCss((string) $i, 'colorblind_deuteranopes_', "COLORBLIND STATUS".$i, 'body[class*="colorblind-"] ');
243}
244
245_createStatusBadgeCss('1b', '', "STATUS1b");
246_createStatusBadgeCss('4b', '', "STATUS4b");
247
248
258function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentLabel = '', $cssPrefix = '')
259{
260 global ${$statusVarNamePrefix.'badgeStatus'.$statusName}, ${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName};
261
262 if (!empty(${$statusVarNamePrefix.'badgeStatus'.$statusName})) {
263 print "\n/* ".strtoupper($commentLabel)." */\n";
264
265 $thisBadgeBackgroundColor = $thisBadgeBorderColor = ${$statusVarNamePrefix.'badgeStatus'.$statusName};
266
267 $TBadgeBorderOnly = array('0', '1b', '3', '4b', '5', '7', '10');
268 $thisBadgeTextColor = colorIsLight(${$statusVarNamePrefix.'badgeStatus'.$statusName}) ? '#212529' : '#ffffff';
269
270 if (!empty(${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName})) {
271 $thisBadgeTextColor = ${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName};
272 }
273
274 if (in_array((string) $statusName, $TBadgeBorderOnly)) {
275 $thisBadgeTextColor = '#212529';
276 $thisBadgeBackgroundColor = "";
277 }
278
279 if (in_array((string) $statusName, array('0', '5', '9'))) {
280 $thisBadgeTextColor = '#999999';
281 }
282 if (in_array((string) $statusName, array('6'))) {
283 $thisBadgeTextColor = '#777777';
284 }
285
286 // badge-statusX
287 print $cssPrefix.".badge-status".$statusName." {\n";
288 print " color: ".$thisBadgeTextColor." !important;\n";
289 if (in_array((string) $statusName, $TBadgeBorderOnly)) {
290 print " border-color: ".$thisBadgeBorderColor." !important;\n";
291 }
292 if ($thisBadgeBackgroundColor != '') {
293 print " background-color: ".$thisBadgeBackgroundColor." !important;\n";
294 }
295 print "}\n";
296
297 print $cssPrefix.".font-status".$statusName." {\n";
298 if ($thisBadgeBackgroundColor != '') {
299 print " color: ".$thisBadgeBackgroundColor." !important;\n";
300 }
301 print "}\n";
302
303 print $cssPrefix.".badge-status".$statusName.".focus, ".$cssPrefix.".badge-status".$statusName.":focus {\n";
304 print " outline: 0;\n";
305 print " box-shadow: 0 0 0 0.2rem ".colorHexToRgb($thisBadgeBackgroundColor, 0.5)." !important;\n";
306 print "}\n";
307
308 // badge-statusX:focus
309 print $cssPrefix.".badge-status".$statusName.":focus, ".$cssPrefix.".badge-status".$statusName.":hover {\n";
310 print " color: ".$thisBadgeTextColor." !important;\n";
311 //print " background-color: " . colorDarker($thisBadgeBackgroundColor, 10) . ";\n";
312 if (in_array((string) $statusName, $TBadgeBorderOnly)) {
313 print " border-color: ".colorDarker($thisBadgeBorderColor, 10)." !important;\n";
314 }
315 print "}\n";
316 }
317}
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.