Ejemplo n.º 1
0
 function title($model, $vlevel = HC_PRESENTER::VIEW_HTML)
 {
     $return = array();
     $label = $this->label($model, $vlevel);
     if (strlen($label)) {
         $return[] = $label;
     }
     switch ($vlevel) {
         case HC_PRESENTER::VIEW_TEXT:
             $return[] = ': ';
             break;
     }
     switch ($vlevel) {
         case HC_PRESENTER::VIEW_HTML_ICON:
             break;
         default:
             if ($model->exists()) {
                 $return[] = $model->name;
             } else {
                 $return[] = HCM::__('Unknown');
             }
             break;
     }
     $return = join('', $return);
     switch ($vlevel) {
         case HC_PRESENTER::VIEW_HTML:
             $color = $model->present_color();
             $color = HC_Lib::adjust_color_brightness($color, -30);
             $return = HC_Html_Factory::element('span')->add_attr('class', 'label')->add_attr('class', 'label-success')->add_attr('class', 'label-lg')->add_child($return)->add_attr('style', 'background-color: ' . $color . ';');
             break;
     }
     return $return;
 }
Ejemplo n.º 2
0
<?php

if (!$count) {
    return;
}
$temp_shift = HC_App::model('shift');
$linkto = HC_Lib::link('list/index', array('filter' => 'draft'));
$title = HC_Html_Factory::widget('list')->add_attr('class', 'list-inline')->add_attr('class', 'list-separated')->add_item('title', HC_Html_Factory::widget('titled', 'a')->add_attr('href', $linkto)->add_child(HCM::__('Draft Shifts')))->add_item('count', HC_Html_Factory::element('span')->add_attr('class', 'badge')->add_child($count));
$out = HC_Html_Factory::element('div')->add_attr('class', 'alert')->add_attr('class', 'alert-default-o')->add_child($title);
//$color = Hc_lib::random_html_color( 2 );
$color = '#dff0d8';
$color1 = HC_Lib::adjust_color_brightness($color, 0);
$color2 = HC_Lib::adjust_color_brightness($color, 20);
$out->add_attr('style', "background: repeating-linear-gradient(\r\n\t\t-45deg,\r\n\t\t{$color1},\r\n\t\t{$color1} 6px,\r\n\t\t{$color2} 6px,\r\n\t\t{$color2} 12px\r\n\t\t);\r\n\t");
echo $out->render();
Ejemplo n.º 3
0
 function render()
 {
     $sh = $this->shift();
     $t = HC_Lib::time();
     $titles = array();
     $iknow = $this->iknow();
     $wide = $this->wide();
     $use_color = FALSE;
     $use_color = TRUE;
     if ($wide && $wide === 'mini') {
         $use_color = TRUE;
     }
     if (in_array($sh->type, array($sh->_const("TYPE_TIMEOFF")))) {
         $display = array('date', 'time', 'user', 'location');
     } else {
         if (!$wide or $wide === 'mini') {
             $display = array('date', 'time', 'location', 'user');
         } elseif ($wide) {
             $display = array('date', 'time', 'user', 'location');
         }
     }
     foreach ($iknow as $ik) {
         $display = HC_Lib::remove_from_array($display, $ik);
     }
     // if( in_array($sh->type, array($sh->_const("TYPE_TIMEOFF"))) ){
     // $display = HC_Lib::remove_from_array($display, 'location');
     // }
     foreach ($display as $ds) {
         $title_view = '';
         switch ($ds) {
             case 'date':
                 $title_view = $sh->present_date(HC_PRESENTER::VIEW_RAW);
                 break;
             case 'time':
                 $title_view = $sh->present_time();
                 break;
             case 'location':
                 if (in_array($sh->type, array($sh->_const("TYPE_TIMEOFF")))) {
                     $title_view = '';
                     // $title_view = HCM::__('Timeoff');
                     // $title_view = $sh->present_location();
                 } else {
                     $title_view = $sh->present_location();
                 }
                 break;
             case 'user':
                 if ($sh->type == $sh->_const('TYPE_TIMEOFF') && !in_array('time', $display)) {
                     $title_view = $sh->present_type(HC_PRESENTER::VIEW_HTML_ICON) . $sh->present_user(HC_PRESENTER::VIEW_RAW);
                 } else {
                     // $titles[] = $sh->present_user();
                     if ($sh->user_id) {
                         $title_view = $sh->present_user(HC_PRESENTER::VIEW_RAW);
                     } else {
                         $title_view = $sh->present_user();
                     }
                 }
                 break;
         }
         // if( $title_view ){
         $titles[] = $title_view;
         // }
     }
     $wrap = HC_Html_Factory::element('div')->add_attr('class', array('alert', 'display-block'))->add_attr('class', array('alert-default-o'))->add_attr('class', array('no-underline'))->add_attr('class', array('alert-condensed2'))->add_attr('class', array('text-smaller'))->add_attr('class', array('squeeze-in'));
     foreach ($sh->present_status_class() as $status_class) {
         // $wrap->add_attr('class', 'alert-' . $status_class);
     }
     /* background color depends on location */
     if ($use_color) {
         $color = $sh->location->present_color();
     } else {
         $type = $sh->type;
         switch ($type) {
             case $sh->_const('TYPE_TIMEOFF'):
                 $wrap->add_attr('class', array('alert-archive'));
                 $color = '#ddd';
                 break;
             default:
                 $wrap->add_attr('class', array('alert-success-o'));
                 $color = '#dff0d8';
                 break;
         }
     }
     if ($sh->status == $sh->_const('STATUS_DRAFT')) {
         $color1 = HC_Lib::adjust_color_brightness($color, 0);
         $color2 = HC_Lib::adjust_color_brightness($color, 20);
         // $color1 = '#fff';
         // $color2 = '#eee';
         $wrap->add_attr('style', "background: repeating-linear-gradient(\r\n\t\t\t\t\t-45deg,\r\n\t\t\t\t\t{$color1},\r\n\t\t\t\t\t{$color1} 6px,\r\n\t\t\t\t\t{$color2} 6px,\r\n\t\t\t\t\t{$color2} 12px\r\n\t\t\t\t\t);\r\n\t\t\t\t");
     } else {
         $wrap->add_attr('style', 'background-color: ' . $color . ';');
         // $wrap->add_attr('class', 'alert-success');
     }
     if (!$sh->user_id) {
         $wrap->add_attr('class', 'hc-red-triangled');
     }
     //		echo $color;
     /* ID */
     if (in_array('id', $iknow)) {
         $wrap->add_child($sh->present_id());
     }
     /* build link title */
     $nolink = $this->nolink();
     $new_window = $this->new_window();
     $a_link = HC_Html_Factory::widget('titled', 'a');
     $link_to = 'shifts/zoom/index/id/' . $sh->id;
     $a_link->add_attr('href', HC_Lib::link($link_to)->url());
     if (!$new_window) {
         $a_link->add_attr('class', 'hc-flatmodal-loader');
     } else {
         $a_link->add_attr('target', '_blank');
         $a_link->add_attr('class', 'hc-parent-loader');
     }
     if ($nolink) {
         $a_title = HC_Html_Factory::widget('titled', 'span');
     } else {
         $a_title = HC_Html_Factory::widget('titled', 'a');
     }
     $a_title = HC_Html_Factory::widget('titled', 'span');
     $a_title->add_attr('class', array('squeeze-in'));
     // $a_title->add_attr('style', 'border: red 1px solid;');
     // $a_title->add_attr('style', 'border-color: ' . $sh->location->present_color());
     if ($wide === 'mini') {
         if (!$nolink) {
             $final_ttl = clone $a_link;
             $final_ttl->add_child('&nbsp;')->add_attr('style', 'display: block;');
             $final_ttl->add_attr('title', join(' ', $titles));
         }
         $a_title->add_child($final_ttl);
     } else {
         if (count($display) > 1) {
             if ($wide) {
                 $titles2 = HC_Html_Factory::widget('grid');
                 $titles2->set_slim();
                 $grid_width = array(2 => 6, 3 => 4, 4 => 3, 5 => 2, 6 => 2);
                 $grid_width = isset($grid_width[count($display)]) ? $grid_width[count($display)] : 2;
                 for ($ti = 0; $ti < count($titles); $ti++) {
                     $ttl = $titles[$ti];
                     // next title is empty?
                     if ($ti < count($titles) - 1 && !strlen($titles[$ti + 1])) {
                         $ti++;
                         $grid_width += $grid_width;
                     }
                     $final_ttl = $ttl;
                     if (!$nolink) {
                         $final_ttl = clone $a_link;
                         $final_ttl->add_child($ttl);
                     }
                     $titles2->add_item($final_ttl, $grid_width, array('class' => 'squeeze-in'));
                 }
             } else {
                 $titles2 = HC_Html_Factory::widget('list')->add_attr('class', 'list-unstyled');
                 $this_index = 0;
                 foreach ($titles as $ttl) {
                     if (!strlen($ttl)) {
                         continue;
                     }
                     $final_ttl = $ttl;
                     if (!$nolink) {
                         $final_ttl = clone $a_link;
                         $final_ttl->add_child($ttl);
                     }
                     $titles2->add_item($this_index, $final_ttl);
                     $titles2->add_item_attr($ttl, 'class', array('squeeze-in'));
                     $this_index++;
                 }
             }
             $a_title->add_attr('title', join(' ', $titles));
             $a_title->add_child($titles2);
         } else {
             $final_ttl = $titles;
             if (!$nolink) {
                 $final_ttl = clone $a_link;
                 $final_ttl->add_child($titles);
             }
             $final_ttl->add_attr('title', join(' ', $titles));
             $a_title->add_child($final_ttl);
         }
     }
     $wrap->add_child($a_title);
     /* EXTENSIONS */
     $extensions = HC_App::extensions();
     $more_content = $extensions->set_skip($iknow)->run('shifts/quickview', $sh, $wrap);
     if ($wide !== 'mini') {
         if ($more_content) {
             $more_wrap = HC_Html_Factory::widget('list')->add_attr('class', 'list-unstyled')->add_attr('class', 'list-separated')->add_attr('class', 'text-small');
             $added = 0;
             foreach ($more_content as $mck => $mc) {
                 if ($mck && in_array($mck, $iknow)) {
                     continue;
                 }
                 $more_wrap->add_item($mc);
                 $added++;
             }
             if ($added) {
                 $wrap->add_child($more_wrap);
             }
         }
     }
     /* THIS CHILDREN */
     if ($wide !== 'mini') {
         $children = $this->children();
         foreach ($children as $child) {
             $wrap->add_child($child);
         }
     }
     $wrap->add_attr('class', 'common-link-parent');
     return $wrap->render();
 }
Ejemplo n.º 4
0
 function status($model, $vlevel = HC_PRESENTER::VIEW_HTML)
 {
     list($label_text, $label_class) = $this->_status_details($model);
     $label_class = $this->status_class($model, TRUE);
     $type_text = $model->present_type(HC_PRESENTER::VIEW_RAW);
     switch ($vlevel) {
         case HC_PRESENTER::VIEW_HTML:
         case HC_PRESENTER::VIEW_HTML_ICON:
             // $return = HC_Html::label( $label_class, $label_text );
             // $type_label = $model->present_label( $vlevel );
             // $label_text = $type_label . $label_text;
             $label_text_text = $model->present_status(HC_PRESENTER::VIEW_RAW);
             $return = HC_Html_Factory::widget('titled', 'span')->add_attr('class', array('alert'))->add_attr('class', array('alert-condensed2'))->add_attr('title', $label_text_text)->add_child($label_text);
             if (!is_array($label_class)) {
                 $label_class = array($label_class);
             }
             foreach ($label_class as $lc) {
                 // $return->add_attr('class', 'alert-' . $lc);
                 // $return->add_attr('class', 'alert-' . $lc);
             }
             // $return->add_attr('class', 'alert-default-o');
             // $color = $model->location->present_color();
             $type = $model->type;
             switch ($type) {
                 case $model->_const('TYPE_TIMEOFF'):
                     $color = '#ddd';
                     $color = '#eee';
                     break;
                 default:
                     $color = '#dff0d8';
                     // $color = Hc_lib::random_html_color( 2 );
                     break;
             }
             if ($model->status == $model->_const('STATUS_DRAFT')) {
                 $color1 = HC_Lib::adjust_color_brightness($color, 0);
                 $color2 = HC_Lib::adjust_color_brightness($color, 20);
                 $return->add_attr('style', "background: repeating-linear-gradient(\n\t\t\t\t\t\t\t-45deg,\n\t\t\t\t\t\t\t{$color1},\n\t\t\t\t\t\t\t{$color1} 6px,\n\t\t\t\t\t\t\t{$color2} 6px,\n\t\t\t\t\t\t\t{$color2} 12px\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t");
             } else {
                 $return->add_attr('style', 'background-color: ' . $color . ';');
                 // $wrap->add_attr('class', 'alert-success');
             }
             break;
         case HC_PRESENTER::VIEW_TEXT:
             $return = join(': ', array(HCM::__('Status'), $type_text, $label_text));
             break;
         case HC_PRESENTER::VIEW_RAW:
             $type_label = $model->present_label($vlevel);
             $return = join(': ', array($type_text, $label_text));
             break;
     }
     return $return;
 }