|
@@ -8135,3 +8135,88 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
|
|
|
|
|
|
return '<div class="inline-block divButAction"><'.$tag.' '.$compiledAttributes.'>'.$html.'</'.$tag.'></div>';
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * Function dolGetButtonTitle : this kind of buttons are used in title in list
|
|
|
+ *
|
|
|
+ * @param string $label label of button
|
|
|
+ * @param string $helpText optional : content for help tooltip
|
|
|
+ * @param string $iconClass class for icon element
|
|
|
+ * @param string $url the url for link
|
|
|
+ * @param string $id attribute id of button
|
|
|
+ * @param int $userRight user action right
|
|
|
+ * @param array $params various params for future : recommended rather than adding more function arguments
|
|
|
+ * @return string html button
|
|
|
+ */
|
|
|
+function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $url = '', $id = '', $userRight = 1, $params = array())
|
|
|
+{
|
|
|
+ global $langs;
|
|
|
+
|
|
|
+ $class = 'title-button' ;
|
|
|
+
|
|
|
+ $attr=array(
|
|
|
+ 'class' => $class
|
|
|
+ ,'href' => empty($url)?'':$url
|
|
|
+ );
|
|
|
+
|
|
|
+ if(!empty($helpText)){
|
|
|
+ $attr['title'] = dol_escape_htmltag($helpText);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($userRight)){
|
|
|
+ $attr['class'] .= ' title-button-refused';
|
|
|
+ $attr['title'] = dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions"));
|
|
|
+ $attr['href'] = '';
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($attr['title'])){
|
|
|
+ $attr['class'] .= ' classfortooltip';
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($id)){
|
|
|
+ $attr['id'] = $id;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Override attr
|
|
|
+ if(!empty($params['attr']) && is_array($params['attr'])){
|
|
|
+ foreach($params['attr'] as $key => $value){
|
|
|
+ if($key == 'class'){
|
|
|
+ $attr['class'].= ' '.$value;
|
|
|
+ }
|
|
|
+ elseif($key == 'classOverride'){
|
|
|
+ $attr['class'] = $value;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ $attr[$key] = $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($attr['href']) && empty($attr['href'])){
|
|
|
+ unset($attr['href']);
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO : add a hook
|
|
|
+
|
|
|
+ // escape all attribute
|
|
|
+ $attr = array_map('dol_escape_htmltag', $attr);
|
|
|
+
|
|
|
+ $TCompiledAttr = array();
|
|
|
+ foreach($attr as $key => $value){
|
|
|
+ $TCompiledAttr[] = $key.'="'.$value.'"';
|
|
|
+ }
|
|
|
+
|
|
|
+ $compiledAttributes = !empty($TCompiledAttr)?implode(' ', $TCompiledAttr):'';
|
|
|
+
|
|
|
+ $tag = !empty($attr['href'])?'a':'span';
|
|
|
+
|
|
|
+
|
|
|
+ $button ='<'.$tag.' '.$compiledAttributes.' >';
|
|
|
+ $button.= '<span class="'.$iconClass.' valignmiddle"></span>';
|
|
|
+ $button.= '<span class="valignmiddle text-plus-circle">'.$label.'</span>';
|
|
|
+ $button.= '</'.$tag.'>';
|
|
|
+
|
|
|
+ return $button;
|
|
|
+}
|