Example #1
0
 public function color($model)
 {
     if ($model->id) {
         $min_brightness = 180;
         $return = Hc_lib::random_html_color($model->id, $min_brightness);
     } else {
         $return = '#ddd';
     }
     return $return;
 }
Example #2
0
    $final_title[] = '</li>';
}
if ($wide_view && (isset($title['staff']) or isset($title['location']))) {
    $final_title[] = '<li>';
    $final_title[] = '<ul class="list-inline">';
    list($this_title_title, $this_title_icon) = Hc_lib::parse_icon($title['time']);
    $final_title[] = '<li class="squeeze-in pull-left" style="width: 50%;" title="' . $this_title_title . '">';
    $final_title[] = $title['time'];
    $final_title[] = '</li>';
    $this_title = '&nbsp;';
    if (isset($title['staff'])) {
        $this_title = $title['staff'];
    } elseif (isset($title['location'])) {
        $this_title = $title['location'];
    }
    list($this_title_title, $this_title_icon) = Hc_lib::parse_icon($this_title);
    if ($trade_label) {
        $this_title_title = $trade_label;
    }
    $final_title[] = '<li class="squeeze-in pull-right" style="width: 50%;" title="' . $this_title_title . '">';
    $final_title[] = $this_title;
    $final_title[] = '</li>';
    $final_title[] = '</ul>';
    $final_title[] = '<div class="clearfix"></div>';
    $final_title[] = '</li>';
} else {
    if (isset($title['time'])) {
        $final_title[] = '<li>';
        $final_title[] = $title['time'];
        $final_title[] = '</li>';
    }
Example #3
0
	<div class="collapse navbar-collapse nts-navbar-collapse">
		<ul class="nav navbar-nav">
		<?php 
foreach ($menu as $m) {
    ?>
			<?php 
    $current_one = isset($m['active']) && $m['active'] ? TRUE : FALSE;
    $li_class = array();
    if (isset($m['children']) && $m['children']) {
        $li_class[] = 'dropdown';
    }
    if ($current_one) {
        $li_class[] = 'active';
    }
    $li_class = join(' ', $li_class);
    list($link_title, $link_icon) = Hc_lib::parse_icon($m['title']);
    ?>

			<li class="<?php 
    echo $li_class;
    ?>
">

			<?php 
    if (isset($m['children']) && $m['children']) {
        ?>

				<a class="dropdown-toggle" data-toggle="dropdown" href="#" title="<?php 
        echo $link_title;
        ?>
">
 public function color($model)
 {
     $return = Hc_lib::random_html_color($model->id);
     return $return;
 }
Example #5
0
 static function wrap_input($label, $input, $aligned = TRUE)
 {
     $return = '';
     $inputs = is_array($input) ? $input : array($input);
     $label = Hc_lib::parse_lang($label);
     $surroundClass = 'form-group';
     if (is_object($input) && $input->error) {
         $surroundClass .= ' has-error';
     } elseif (count($inputs) > 1) {
         reset($inputs);
         foreach ($inputs as $in) {
             if (is_object($in) && $in->error) {
                 $surroundClass .= ' has-error';
                 break;
             }
         }
     }
     $return .= '<div class="' . $surroundClass . '">';
     if (is_object($input) && $input->type == 'checkbox') {
         if ($aligned) {
             //				$return .= '<div class="col-sm-10 col-sm-offset-2">';
             $return .= '<div class="control-holder">';
         } else {
             $return .= '<div class="col-sm-12">';
         }
     } else {
         //			$return .= '<label class="col-sm-2 control-label">';
         $return .= '<label class="control-label">';
         $return .= $label;
         $return .= '</label>';
         //			$return .= '<div class="col-sm-10">';
         $return .= '<div class="control-holder">';
     }
     foreach ($inputs as $input) {
         if (is_object($input) && $input->type == 'checkbox') {
             $return .= '<div class="checkbox">';
             $return .= '<label>';
             $return .= $input->view;
             if (count($inputs) <= 1) {
                 $return .= ' ' . $label;
             }
             $return .= '</label>';
             if ($input->error) {
                 $return .= '<span class="help-inline">' . $input->error . '</span>';
             }
             if ($input->help) {
                 $return .= '<span class="help-block">' . $input->help . '</span>';
             }
             $return .= '</div>';
         } else {
             $wrap_start = '';
             $wrap_end = '';
             if (!is_object($input) or in_array($input->type, array('labelData'))) {
                 if (count($inputs) < 2) {
                     $wrap_start = '<p class="form-control-static">';
                     $wrap_end = '</p>';
                 }
             }
             if (is_object($input)) {
                 $return .= $wrap_start . $input->view . $wrap_end;
             } else {
                 $return .= $wrap_start . $input . $wrap_end;
             }
             if (is_object($input)) {
                 if ($input->error) {
                     $return .= '<span class="help-inline">' . $input->error . '</span>';
                 }
                 if ($input->help) {
                     $return .= '<span class="help-block">' . $input->help . '</span>';
                 }
             }
         }
     }
     $return .= '</div>';
     $return .= '</div>';
     return $return;
 }
Example #6
0
    static function nav_tabs($tabs, $shown = '', $field = '', $id = '', $extra = '')
    {
        if (!$shown) {
            $all_tabs = array_keys($tabs);
            $shown = $all_tabs[0];
        }
        $id = $id ? $id : hc_random();
        $out = array();
        $startup = '<ul class="nav nav-tabs" id="' . $id . '"';
        if ($extra) {
            $startup .= ' ' . $extra;
        }
        $startup .= '>';
        $out[] = $startup;
        reset($tabs);
        reset($tabs);
        foreach ($tabs as $tab_id => $t) {
            if ($tab_id == $shown) {
                $out[] = '<li class="active">';
            } else {
                $out[] = '<li>';
            }
            if (is_array($t)) {
                $t1 = array_shift($t);
                $title = trim(strip_tags($t1['title']));
                $out[] = '<a title="' . $title . '" class="dropdown-toggle" data-toggle="dropdown" href="#">';
                $out[] = $t1['title'];
                $out[] = ' <span class="caret"></span>';
                $out[] = '</a>';
                $out[] = '<ul class="dropdown-menu">';
                foreach ($t as $t2) {
                    list($link_title, $link_icon) = Hc_lib::parse_icon($t2['title']);
                    $title = trim(strip_tags($t2['title']));
                    $out[] = '<li>';
                    $out[] = '<a title="' . $link_title . '" href="' . $t2['href'] . '">';
                    $out[] = $link_icon . $link_title;
                    $out[] = '</a>';
                    $out[] = '</li>';
                }
                $out[] = '</ul>';
            } else {
                $title = trim(strip_tags($t));
                if (substr($tab_id, 0, 1) == '_') {
                    $out[] = '<a title="' . $title . '">' . $t . '</a>';
                } else {
                    $out[] = '<a href="#' . $tab_id . '" data-toggle="tab" title="' . $title . '">' . $t . '</a>';
                }
            }
            $out[] = '</li>';
        }
        $out[] = '</ul>';
        if ($field) {
            $out[] = '<script language="JavaScript">';
            $out[] = <<<EOT
jQuery('#{$id} a[data-toggle="tab"]').on('shown.bs.tab', function (e)
{
\tvar active_tab = e.target.hash.substr(1); // strip the starting #
\tjQuery(this).closest('form').find('[name={$field}]').val( active_tab );
});
EOT;
            if ($shown) {
                $out[] = <<<EOT
\tjQuery('#{$id}').closest('form').find('[name={$field}]').val( "{$shown}" );
EOT;
            }
            $out[] = '</script>';
        }
        $out = join("\n", $out);
        return $out;
    }
Example #7
0
if (!$is_my) {
    ?>
	<li>
		<i class="fa-fw fa fa-user"></i> <?php 
    echo $sh->user->get()->title();
    ?>
	</li>
<?php 
}
?>

<?php 
if (count($menu) == 1) {
    ?>
	<?php 
    list($title, $title_icon) = Hc_lib::parse_icon($menu[0]['title']);
    ?>
	<li>
		<?php 
    echo $title_icon;
    ?>
		<a class="btn btn-default btn-sm" title="<?php 
    echo $title;
    ?>
" href="<?php 
    echo $menu[0]['href'];
    ?>
">
			<?php 
    echo $title;
    ?>
Example #8
0
function hc_form_input($field, $defaults = array(), $errors = array(), $show_label = TRUE)
{
    $out = '';
    if (isset($field['hide']) && $field['hide']) {
        return;
    }
    $keep = array('conf', 'data', 'id', 'name', 'value', 'type', 'required', 'label', 'options', 'readonly', 'disabled', 'style', 'extra', 'text_before', 'text_after', 'cols', 'rows', 'help');
    $unset = array('type', 'label', 'extra', 'text_before', 'text_after');
    reset($keep);
    $f = array();
    foreach ($keep as $k) {
        if (isset($field[$k])) {
            $f[$k] = $field[$k];
        }
    }
    $error = isset($errors[$f['name']]) ? $errors[$f['name']] : '';
    $class = $error ? 'control-group error' : 'control-group';
    $required = (isset($f['required']) && $f['required'] or isset($field['rules']) && is_array($field['rules']) && in_array('required', $field['rules'])) ? TRUE : FALSE;
    $type = isset($f['type']) ? $f['type'] : '';
    $label = isset($f['label']) ? $f['label'] : '';
    $text_before = isset($f['text_before']) ? $f['text_before'] : '';
    $text_after = isset($f['text_after']) ? $f['text_after'] : '';
    $label = isset($f['label']) ? $f['label'] : '';
    $extra = '';
    if (isset($field['size'])) {
        if (isset($f['extra']['style'])) {
            $f['extra']['style'] .= '; width: ' . $field['size'] . 'em;';
        } else {
            $f['extra']['style'] = 'width: ' . $field['size'] . 'em;';
        }
    }
    if (isset($f['extra'])) {
        $extra = array();
        reset($f['extra']);
        foreach ($f['extra'] as $k => $v) {
            $extra[] = $k . '="' . $v . '"';
        }
        $extra = join(' ', $extra);
    }
    if (isset($defaults[$f['name']])) {
        $default = $defaults[$f['name']];
    } elseif (substr($f['name'], -2) == '[]' && isset($defaults[substr($f['name'], 0, -2)])) {
        $default = $defaults[substr($f['name'], 0, -2)];
    } elseif (isset($field['default'])) {
        $default = $field['default'];
    } else {
        $default = NULL;
    }
    foreach ($unset as $k) {
        unset($f[$k]);
    }
    if ($type == 'hidden') {
        $out .= form_hidden($f['name'], $default);
    } else {
        $label = Hc_lib::parse_lang($label);
        if ($show_label) {
            $out .= '<div class="' . $class . '">';
            $out .= '<label class="control-label" for="' . $f['name'] . '">' . $label;
            if ($required) {
                $out .= ' *';
            }
            $out .= '</label>';
            $out .= '<div class="controls">';
        }
        switch ($type) {
            case 'plain':
                if (isset($f['options']) && isset($f['options'][$default])) {
                    $view = $f['options'][$default];
                } else {
                    $view = $default;
                }
                $out .= $view;
                break;
            case 'label':
                if (isset($f['options']) && isset($f['options'][$default])) {
                    $view = $f['options'][$default];
                } else {
                    $view = $default;
                }
                $out .= '<span class="uneditable-input">' . $view . '</span>';
                break;
            case 'dropdown':
                if (isset($f['id'])) {
                    $extra .= ' id="' . $f['id'] . '"';
                }
                $this_name = $f['name'];
                $multiple = strpos($extra, 'multiple') !== FALSE;
                if ($multiple) {
                    $this_name = $f['name'] . '[]';
                }
                $out .= form_dropdown($this_name, $f['options'], set_value($f['name'], $default), $extra);
                if ($text_after) {
                    $out .= '&nbsp' . $text_after;
                }
                break;
            case 'textarea':
                $out .= form_textarea($f, set_value($f['name'], $default), $extra);
                break;
            case 'radio':
                $out .= '<div class="radio">';
                foreach ($f['options'] as $fk => $fv) {
                    $out .= '<label style="display: block;">';
                    $ff = $f;
                    unset($ff['options']);
                    $checked = $default == $fk ? TRUE : FALSE;
                    $out .= form_radio($ff, $fk, $checked, $extra);
                    $out .= Hc_lib::parse_lang($fv);
                    $out .= '</label>';
                }
                $out .= '</div>';
                break;
            case 'date':
                $out .= hc_form_date($f, $default, $extra);
                break;
            case 'time':
                $out .= hc_form_time($f, $default, $extra);
                break;
            case 'timeframe':
                $out .= hc_form_timeframe($f, $default, $extra);
                break;
            case 'weekday':
                $out .= hc_form_weekday($f, $default);
                break;
            case 'checkbox':
                if ($text_before) {
                    $out .= $text_before . '&nbsp';
                }
                $value = isset($f['value']) ? $f['value'] : 1;
                if (is_array($default)) {
                    $checked = in_array($value, $default) ? TRUE : FALSE;
                } else {
                    $checked = $default == $value ? TRUE : FALSE;
                }
                if (isset($f['readonly']) && $f['readonly']) {
                    $out .= form_hidden($f['name'], $value);
                    $extra .= ' disabled="disabled"';
                    $out .= form_checkbox($f['name'] . '_justview', $value, $checked, $extra);
                } else {
                    $out .= form_checkbox($f['name'], $value, $checked, $extra);
                }
                if ($text_after) {
                    $out .= '&nbsp' . $text_after;
                }
                break;
            case 'checkbox_set':
                if ($text_before) {
                    $out .= $text_before . '&nbsp';
                }
                $value = isset($f['value']) ? $f['value'] : $default;
                if (!is_array($value)) {
                    $value = array($value);
                }
                $this_out = array();
                foreach ($f['options'] as $option_value => $option_label) {
                    $checkbox_field = array('name' => $f['name'] . '[]', 'type' => 'checkbox', 'value' => $option_value);
                    $checked = in_array($option_value, $value) ? TRUE : FALSE;
                    $this_out[] = '<div class="checkbox checkbox-inline">';
                    $this_out[] = '<label>' . form_checkbox($checkbox_field, $option_value, $checked) . $option_label . '</label>';
                    $this_out[] = '</div>';
                }
                $out .= join(' ', $this_out);
                if ($text_after) {
                    $out .= '&nbsp' . $text_after;
                }
                break;
            case 'password':
                $f['type'] = 'password';
            default:
                if ($text_before) {
                    $out .= $text_before . '&nbsp';
                }
                $out .= form_input($f, $default, $extra);
                if ($text_after) {
                    $out .= '&nbsp' . $text_after;
                }
                break;
        }
        if ($error) {
            $out .= '<span class="help-inline">' . $error . '</span>';
        }
        if (isset($f['help']) && !$error) {
            $out .= '<span class="help-block"><em>' . Hc_lib::parse_lang($f['help']) . '</em></span>';
        }
    }
    return $out;
}
Example #9
0
 function prop_text($pname, $decorate = FALSE, $force_value = NULL)
 {
     $return = '';
     $CI =& ci_get_instance();
     $args = func_get_args();
     if (isset($args[2])) {
         $value = $args[2];
     } else {
         $method = 'get_' . $pname;
         if (method_exists($this, $method)) {
             $value = $this->{$method}();
         } else {
             $value = $this->{$pname};
         }
     }
     /* prop_text explicitely defined */
     if (!is_object($value) && isset($this->prop_text[$pname][$value])) {
         $return = is_array($this->prop_text[$pname][$value]) ? $this->prop_text[$pname][$value][0] : $this->prop_text[$pname][$value];
         $return = Hc_lib::parse_lang($return);
         if ($decorate && is_array($this->prop_text[$pname][$value])) {
             $class = $this->prop_text[$pname][$value][1];
             $return = '<span class="label label-' . $class . '">' . $return . '</span>';
         }
         return $return;
     }
     $f = $this->get_field($pname);
     if (!$f) {
         return $value;
     }
     $type = isset($f['type']) ? $f['type'] : 'text';
     switch ($type) {
         case 'date':
             $CI->load->library('hc_time');
             $CI->hc_time->setDateDb($value);
             $return = $CI->hc_time->formatDateFull();
             break;
         case 'time':
             $CI->load->library('hc_time');
             $return = $CI->hc_time->formatTimeOfDay($value);
             break;
         case 'boolean':
             $return = $value ? lang('common_yes') : lang('common_no');
             break;
         default:
             if (is_object($value)) {
                 $return = $value->get()->title();
             } else {
                 $return = $value;
             }
             break;
     }
     return $return;
 }
Example #10
0
$menu[] = '-divider-';
$menu[] = array('href' => ci_site_url(array('admin/shifts', 'delete', $sh->id)), 'title' => '<i class="fa fa-times text-danger"></i> ' . lang('shift_delete'), 'class' => 'hc-confirm');
/* add color to border to highlight different staff or location */
$more_style = '';
if ($use_color_code_staff) {
    if (!isset($current_staff) && $staff_count > 1) {
        if ($sh->user_id) {
            $random_color = Hc_lib::random_html_color($sh->user_id);
            $more_style .= 'border-left: ' . $random_color . ' 5px solid;';
        }
    }
}
if ($use_color_code_location) {
    if (!isset($current_location) && $location_count > 1) {
        if ($sh->location_id) {
            $random_color = Hc_lib::random_html_color($sh->location_id);
            $more_style .= 'border-right: ' . $random_color . ' 5px solid;';
        }
    }
}
?>

<a class="<?php 
echo $class;
?>
" href="#" data-toggle="dropdown" style="<?php 
echo $more_style;
?>
">
	<?php 
echo $title;
Example #11
0
        if (is_array($link_slug)) {
            $link_slug = join('/', $link_slug);
        }
        $this_disabled = FALSE;
        reset($disabled_panels);
        foreach ($disabled_panels as $dp) {
            if (substr($link_slug, 0, strlen($dp)) == $dp) {
                $this_disabled = TRUE;
                break;
            }
        }
        if ($this_disabled) {
            continue;
        }
        $link_title = $v[1];
        list($link_title, $link_icon) = Hc_lib::parse_icon($link_title);
        $link_view = ci_anchor($link_slug, $link_icon . $link_title);
    } else {
        $link_view = $v;
    }
    ?>

		<?php 
    if (substr($k, 0, strlen('_header')) == '_header') {
        ?>
			<li class="dropdown-header">
		<?php 
    } elseif (substr($k, 0, strlen('_divider')) == '_divider') {
        ?>
			<li class="divider">
		<?php