noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
icon_action.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
21
22/**
23 * @file
24 * @brief Utility , library of icon with javascript
25 */
26
27/**
28 * @brief Utility , library of icon with javascript
29 */
31{
32
33 /**
34 * Display a icon with a magnify glass
35 * @param string $id id of element
36 * @param string $p_javascript
37 * @param string $p_style optionnal HTML code
38 * @return type
39 */
40 static function icon_magnifier($id, $p_javascript, $p_style="")
41 {
42 $r="";
43 $r.=sprintf('<span id="%s" class=" smallbutton icon" style="%s" onclick="%s">%s</span>',
44 $id, $p_style, $p_javascript,ICON_SEARCH);
45 return $r;
46 }
47 /**
48 * Display a icon with a magnify glass
49 * @param string $id id of element
50 * @param string $p_javascript
51 * @param string $p_style optionnal HTML code
52 * @return type
53 */
54 static function button_magnifier($id, $p_javascript, $p_style="")
55 {
56 $r="";
57 $r.=sprintf('<input type="button" id="%s" class=" smallbutton icon" style="%s" onclick="%s" value="%s">',
58 $id, $p_style, $p_javascript,ICON_SEARCH);
59 return $r;
60 }
61
62 /**
63 *
64 * @param type $id
65 * @param type $p_javascript
66 * @param type $p_style
67 * @return type
68 */
69 static function icon_add($id, $p_javascript, $p_style="")
70 {
71 $r=sprintf('<input class="smallbutton icon" onclick="%s" id="%s" type="button" %s value="&#xe828;">',
72 $p_javascript, $id, $p_style);
73 return $r;
74 }
75 /**
76 *
77 * @param type $id
78 * @param type $p_javascript
79 * @param type $p_style
80 * @return type
81 */
82 static function icon_remove($id, $p_javascript, $p_style="")
83 {
84 $r=sprintf('<input class="smallbutton icon" onclick="%s" id="%s" type="button" %s value="&#xe828;">',
85 $p_javascript, $id, $p_style);
86 return $r;
87 }
88 /**
89 *
90 * @param string $id
91 * @param string $p_javascript
92 * @param string opt $p_style
93 * @return html string
94 */
95 static function clean_zone($id, $p_javascript, $p_style="")
96 {
97 $r=sprintf('<input class="smallbutton " onclick="%s" id="%s" value="%s" %s type="button" style="">',
98 $p_javascript, $id, ICON_CLEAN,$p_style
99 );
100 return $r;
101 }
102
103 /**
104 * Display a info in a bubble, text is in message_javascript
105 * @param integer $p_comment
106 * @see message_javascript.php
107 * @return html string
108 */
109 static function infobulle($p_comment)
110 {
111 $r='<span tabindex="-1" class="icon" style="cursor:pointer;display:inline;text-decoration:none;" onmouseover="showBulle(\''.$p_comment.'\')" onclick="showBulle(\''.$p_comment.'\')" onmouseout="hideBulle(0)">';
112 $r.="&#xf086;";
113 $r.='</span>';
114
115 return $r;
116 }
117 /**
118 * Display a info in a bubble, text is given as parameter
119 * @param string $p_comment
120 *
121 * @return html string
122 */
123 static function tips($p_comment)
124 {
125 $p_comment=noalyss_str_replace("'",' ',$p_comment);
126 $r='<span tabindex="-1" class="icon" style="cursor:pointer;display:inline;text-decoration:none;" onmouseover="displayBulle(\''.$p_comment.'\')" onclick="displayBulle(\''.$p_comment.'\')" onmouseout="hideBulle(0)">';
127 $r.="&#xf086;";
128 $r.='</span>';
129
130 return $r;
131 }
132 /**
133 * Display a info in a bubble, text is given as parameter
134 * @param string $p_comment
135 *
136 * @return html string
137 */
138 static function comment($p_comment)
139 {
140 $p_comment=noalyss_str_replace("'",' ',$p_comment);
141 $js=sprintf("displayBulle('%s')",$p_comment);
142
143 $r=sprintf('<span tabindex="-1" class="icon" style="cursor:pointer;display:inline;text-decoration:none;" onmouseover="%s" onclick="%s" onmouseout="hideBulle(0)">',
144 $js,$js);
145 $r.="&#xf0e5;";
146 $r.='</span>';
147
148 return $r;
149 }
150 /**
151 * Display a icon ON
152 * @param string $p_div id of element
153 * @param string $p_javascript
154 * @param string $p_style optionnal HTML code
155 * @return html string
156 */
157 static function iconon($p_id, $p_javascript, $p_style="")
158 {
159 $r=sprintf('<span style="color:green;cursor:pointer" id="%s" class="icon" style="%s" onclick="%s">&#xf205;</span>',
160 $p_id, $p_style, $p_javascript);
161 return $r;
162 }
163
164 /**
165 * Display a icon OFF
166 * @param string $p_div id of element
167 * @param string $p_javascript
168 * @param string $p_style optionnal HTML code
169 * @return html string
170 */
171 static function iconoff($p_id, $p_javascript, $p_style="")
172 {
173 $r=sprintf('<span style="color:red;cursor:pointer" id="%s" class="icon" style="%s" onclick="%s">&#xf204;</span>',
174 $p_id, $p_style, $p_javascript);
175 return $r;
176 }
177
178 /**
179 * Return a html string with an anchor which close the inside popup. (top-right corner)
180 * @param name of the DIV to close
181 */
182 static function close($p_div)
183 {
184 $r='';
185 $r.=sprintf('<A class="icon text-danger" onclick="removeDiv(\'%s\')">&#xe816;</A>',
186 $p_div);
187 return $r;
188 }
189
190 /**
191 * Display a icon for fix or move a div
192 * @param string $p_div id of the div to fix/move
193 * @param string $p_javascript
194 * @return html string
195 */
196 static function draggable($p_div)
197 {
198 $drag=sprintf('<span id="pin_%s" style="" class="icon " onclick="pin(\'%s\')" >'.UNPINDG.'</span>',
199 $p_div, $p_div);
200 return $drag;
201 }
202
203 /**
204 * Display a icon for zooming
205 * @param string $p_div id of the div to zoom
206 * @param string $p_javascript
207 * @return html string
208 */
209 static function zoom($p_div, $p_javascript)
210 {
211 $r=sprintf('<span id="span_%s" class="icon" onclick="%s">
212 &#xf08e;</span>', $p_div, $p_javascript);
213 return $r;
214 }
215
216 /**
217 * Display a warning in a bubble, text is in message_javascript
218 * @param integer $p_comment
219 * @see message_javascript.php
220 * @return html string
221 */
222 static function warnbulle($p_comment)
223 {
224 $r=sprintf('<span tabindex="-1" onmouseover="showBulle(\'%s\')" onclick="showBulle(\'%s\')" onmouseout="hideBulle(0)" style="color:red" class="icon">&#xe80e;</span>',
225 $p_comment, $p_comment);
226
227 return $r;
228 }
229
230 /**
231 * Return a html string with an anchor to hide a div, put it in the right corner
232 * @param $action action action to perform (message)
233 * @param $javascript javascript
234 * @note not protected against html
235 * @see Acc_Ledger::display_search_form
236 */
237 static function hide($action, $javascript)
238 {
239 $r='';
240 $r.='<span id="hide" style="" class="icon text-danger" onclick="'.$javascript.'">'.$action.'</span>';
241 return $r;
242 }
243 /**
244 * Return a html string with an anchor to hide a div, put it in the right corner
245 * @param $action action action to perform (message)
246 * @param $javascript javascript
247 * @note not protected against html
248 * @see Acc_Ledger::display_search_form
249 */
250 static function hide_icon( $p_id,$javascript)
251 {
252 $r='';
253 $r.='<span id="'.$p_id.'" class="icon" onclick="'.$javascript.'">'."&#xe83b;".'</span>';
254 return $r;
255 }
256 /**
257 * Return a html string with an eye
258 * @param type $javascript
259 * @return string
260 */
261 static function show_icon($p_id,$javascript) {
262 $r='';
263 $r.='<span id="'.$p_id.'" class="icon" onclick="'.$javascript.'">&#xe803;</span>';
264 return $r;
265
266 }
267 /**
268 * Display the icon of a trashbin
269 * @param string $p_id DOMid
270 * @param string $p_javascript
271 * @return htmlString
272 */
273 static function trash($p_id,$p_javascript)
274 {
275 $r='<span id="'.$p_id.'" onclick="'.$p_javascript.'" class="smallicon icon">&#xe80f;</span>';
276 return $r;
277 }
278 /**
279 * Display the icon to modify a idem
280 * @param type $p_id
281 * @param type $p_javascript
282 * @return string
283 */
284 static function modify($p_id,$p_javascript)
285 {
286 $r='<span id="'.$p_id.'" onclick="'.$p_javascript.'" class="smallicon icon" style="margin-left:5px">&#xe80d;</span>';
287
288 return $r;
289 }
290 /**
291 * Display the icon to modify a idem
292 * @param type $p_id
293 * @param type $p_javascript
294 * @return string
295 */
296 static function validate($p_id,$p_javascript)
297 {
298 $r='<span id="'.$p_id.'" onclick="'.$p_javascript.'" class="smallicon icon" style="background-color:lightgrey; border:1px solid blue;padding:2px;margin:0px 1px 0px 1px" >&#xe844;</span>';
299
300 return $r;
301 }
302 /**
303 * Display the icon to modify a idem
304 * @param type $p_id
305 * @param type $p_javascript
306 * @return string
307 */
308 static function cancel($p_id,$p_javascript)
309 {
310 $r='<span id="'.$p_id.'" onclick="'.$p_javascript.'" style="background-color:lightgrey; border:1px solid blue;padding:2px;margin:0px 1px 0px 1px" class="smallicon icon" >&#xe845;</span>';
311
312 return $r;
313 }
314 static function detail($p_id,$p_javascript)
315 {
316 $r=sprintf('<span id="%s" onclick="%s" class="smallicon icon" style="margin-left:5px">&#xe803;</span>',
317 $p_id,
318 $p_javascript);
319 return $r;
320 }
321
322 static function detail_anchor($p_id,$url)
323 {
324 $r=sprintf('
325 <A HREF="%s">
326 <span id="%s" class="smallicon icon" style="margin-left:5px">&#xe803;</span></A>',
327 $url
328 ,$p_id);
329
330 return $r;
331 }
332 static function more($p_id,$p_javascript)
333 {
334 $r=sprintf('<span id="%s" onclick="%s" class="smallicon icon" style="margin-left:5px">&#xe824;</span>',
335 $p_id,
336 $p_javascript);
337 return $r;
338 }
339 static function less($p_id,$p_javascript)
340 {
341 $r=sprintf('<span id="%s" onclick="%s" class="smallicon icon" style="margin-left:5px">&#xe827;</span>',
342 $p_id,
343 $p_javascript);
344 return $r;
345 }
346 /**
347 * When a mouse is over this or if you click on it , it will trigger the javascript
348 * @param domid $p_id
349 * @param string $p_javascript
350 * @return html string
351 */
352 static function menu_click($p_id,$p_javascript)
353 {
354
355 $r=sprintf('<input type="button" id="%s" onclick="%s" class="smallbutton icon" value="&#xf142;" style="font-weigth:bolder">',
356 $p_id,
357 $p_javascript);
358 return $r;
359 }
360 /**
361 * Display the icon of a padlock to lock or unlock element
362 * @param string $p_id DOMid
363 * @param string $p_javascript
364 * @return htmlString
365 */
366 static function lock($p_id,$p_javascript)
367 {
368 $lock_cur="&#xe831;";
369 $lock_next="&#xe832;";
370
371 $r=sprintf( '<span id="%s" is_locked="1" onclick="toggle_lock(\'%s\');%s" class="icon smallicon">%s</span>',
372 $p_id,
373 $p_id,
374 $p_javascript,
375 $lock_cur);
376 return $r;
377 }
378 /**
379 * Display the icon of a trashbin
380 * @param string $p_id DOMid
381 * @param string $p_javascript
382 * @return htmlString
383 */
384 static function unlock($p_id,$p_javascript)
385 {
386
387 $lock_cur="&#xe832;";
388
389 $r=sprintf( '<span id="%s" is_locked="0" onclick="toggle_lock(\'%s\');%s" class="icon smallicon">%s</span>',
390 $p_id,
391 $p_id,
392 $p_javascript,
393 $lock_cur);
394 return $r;
395 }
396 /**
397 * Display the icon of a slider
398 * @param string $p_id DOMid
399 * @param string $p_javascript
400 * @return htmlString
401 */
402 static function slider($p_id,$p_javascript)
403 {
404
405 $lock_cur="&#xf1de;";
406
407 $r=sprintf( '<span id="%s" onclick="%s" class="icon smallicon">%s</span>',
408 $p_id,
409 $p_javascript,
410 $lock_cur);
411 return $r;
412 }
413
414 /**
415 * Display a icon ON is $p_value == 1 otherwise OFF
416 * @param string $p_div id of element
417 * @param string $p_javascript
418 * @param string $p_style optionnal HTML code
419 * @param integer 0 or 1 , 0 means OFF and 1 means ON
420 * @return html string
421 */
422 static function icon_onoff($p_id,$p_javascript,$p_style,$p_value)
423 {
424 if ( $p_value == 1 ) { return \Icon_Action::iconon($p_id, $p_javascript,$p_style);}
425 if ( $p_value == 0 ) { return \Icon_Action::iconoff($p_id, $p_javascript,$p_style);}
426 }
427
428 static function checked ($p_id,$p_javascript="",$p_classrange="") {
429 $lock_cur="&#xe741;";
430 $r=sprintf( '<span id="%s" onclick="%s" class="icon smallicon %s" >%s</span>',
431 $p_id,
432 $p_javascript,
433 $p_classrange,
434 $lock_cur);
435 return $r;
436 }
437 static function unchecked ($p_id,$p_javascript="",$p_classrange="") {
438 $lock_cur="&#xf096";
439
440 $r=sprintf( '<span id="%s" onclick="%s" class="icon smallicon %s" >%s</span>',
441 $p_id,
442 $p_javascript,
443 $p_classrange,
444 $lock_cur);
445 return $r;
446 }
447 static function checkbox ($p_id,$p_javascript="",$p_value=0,$p_classrange="") {
448 if ( $p_value == 0 ) { return \Icon_Action::checked($p_id, $p_javascript,$p_classrange); }
449 if ( $p_value == 1 ) { return \Icon_Action::unchecked($p_id, $p_javascript,$p_classrange);}
450 }
451 static function full_size($p_div) {
452 $js=sprintf("full_size('%s')",$p_div);
453 $icon="&#xe80a;";
454 $r=sprintf('<span id="size_%s" onclick="%s" class="icon smallicon">%s</span>',
455 $p_div,$js,$icon);
456 return $r;
457 }
458 static function duplicate($p_js) {
459 $r=sprintf('<span id="%s" onclick="%s" class="icon smallicon">%s</span>',
460 uniqid(),$p_js,"&#xf0c5;");
461 return $r;
462 }
463 static function card($p_js) {
464 $r=sprintf('<span id="%s" onclick="%s" class="icon smallbutton">%s</span>',
465 uniqid(),$p_js,"&#xe843;");
466 return $r;
467 }
468 static function option($p_js) {
469 $r=sprintf('<span id="%s" onclick="%s" class="icon smallicon">%s</span>',
470 uniqid(),$p_js,"&#xf142;");
471 return $r;
472 }
473
474 /**
475 * @brief Increase size of input_text (p_domid) with p_domid
476 * @param $p_domid domid of the input "text" element
477 * @param $p_size size of the element
478 * @return string HTML string
479 */
480 static function longer($p_domid,$p_size) {
481 $r=sprintf('<span id="%s_longer" '.
482 ' onclick="enlarge_text(\'%s\',\'%s\') "'.
483 ' class="icon smallicon">%s</span>',
484 $p_domid,$p_domid,$p_size,"&#xf138");
485 return $r;
486 }
487 /**
488 * @brief Increase size of input_text (p_domid) with p_domid
489 * @param $p_domid domid of the input "text" element
490 * @param $p_size size of the element
491 * @return string HTML string
492 */
493 static function show_note($p_domid) {
494 $r='<span id="'.uniqid().'" class="smallicon icon" style="background-color:yellow" onclick="document.getElementById(\''.$p_domid.'\').show()">&#xf0f6;</span>';
495 return $r;
496 }
497
498 /**
499 * @brief hide or display an element, to be used for an accordon
500 * @param $p_id ip of the icon
501 * @param $p_id_to_hide element to hide or show
502 * @return HTML string
503 */
504 static function toggle_hide($p_id,$p_id_to_hide)
505 {
506 $javascript=sprintf("toggleHideShow('%s','%s',true)",$p_id_to_hide,$p_id);
507 $r=sprintf('<i id="%s" onclick="%s" class="smallicon icon icon-down-open-2" style="margin-left:5px"></i>',
508 $p_id,$javascript
509 );
510 return $r;
511 }
512
513}
span($p_string, $p_extra='')
Definition ac_common.php:43
for display
return false Description background color
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$opd_description style
Utility , library of icon with javascript.
static slider($p_id, $p_javascript)
Display the icon of a slider.
static unlock($p_id, $p_javascript)
Display the icon of a trashbin.
static menu_click($p_id, $p_javascript)
When a mouse is over this or if you click on it , it will trigger the javascript.
static warnbulle($p_comment)
Display a warning in a bubble, text is in message_javascript.
static modify($p_id, $p_javascript)
Display the icon to modify a idem.
static clean_zone($id, $p_javascript, $p_style="")
static more($p_id, $p_javascript)
static draggable($p_div)
Display a icon for fix or move a div.
static hide_icon( $p_id, $javascript)
Return a html string with an anchor to hide a div, put it in the right corner.
static checked($p_id, $p_javascript="", $p_classrange="")
static less($p_id, $p_javascript)
static icon_magnifier($id, $p_javascript, $p_style="")
Display a icon with a magnify glass.
static icon_onoff($p_id, $p_javascript, $p_style, $p_value)
Display a icon ON is $p_value == 1 otherwise OFF.
static zoom($p_div, $p_javascript)
Display a icon for zooming.
static icon_remove($id, $p_javascript, $p_style="")
static card($p_js)
static hide($action, $javascript)
Return a html string with an anchor to hide a div, put it in the right corner.
static duplicate($p_js)
static icon_add($id, $p_javascript, $p_style="")
static longer($p_domid, $p_size)
Increase size of input_text (p_domid) with p_domid.
static show_icon($p_id, $javascript)
Return a html string with an eye.
static detail_anchor($p_id, $url)
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
static detail($p_id, $p_javascript)
static show_note($p_domid)
Increase size of input_text (p_domid) with p_domid.
static full_size($p_div)
static checkbox($p_id, $p_javascript="", $p_value=0, $p_classrange="")
static validate($p_id, $p_javascript)
Display the icon to modify a idem.
static unchecked($p_id, $p_javascript="", $p_classrange="")
static trash($p_id, $p_javascript)
Display the icon of a trashbin.
static lock($p_id, $p_javascript)
Display the icon of a padlock to lock or unlock element.
static cancel($p_id, $p_javascript)
Display the icon to modify a idem.
static button_magnifier($id, $p_javascript, $p_style="")
Display a icon with a magnify glass.
static option($p_js)
const UNPINDG
Definition constant.php:350
const ICON_CLEAN
Definition constant.php:104
const ICON_SEARCH
Definition constant.php:103