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