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