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