<?php
//no direct accees
defined ('_JEXEC') or die ('restricted aceess');

class SppagebuilderAddonJd_timing extends SppagebuilderAddons{

	public function render() {

		$class = (isset($this->addon->settings->class) && $this->addon->settings->class) ? $this->addon->settings->class : '';
		$title = (isset($this->addon->settings->title) && $this->addon->settings->title) ? $this->addon->settings->title : '';
		$icon = (isset($this->addon->settings->icon) && $this->addon->settings->icon) ? $this->addon->settings->icon : '';

        $background_color = (isset($this->addon->settings->background_color) && $this->addon->settings->background_color) ? 'background-color:'.$this->addon->settings->background_color.';' : '';
		$text_color = (isset($this->addon->settings->text_color) && $this->addon->settings->text_color) ? 'color:'.$this->addon->settings->text_color.';' : '';
        $margin_top = (isset($this->addon->settings->margin_top) && $this->addon->settings->margin_top) ? 'margin-top:'.$this->addon->settings->margin_top.';' : 'margin-top:0px;';
        $margin_bottom = (isset($this->addon->settings->margin_bottom) && $this->addon->settings->margin_bottom) ? 'margin-bottom:'.$this->addon->settings->margin_bottom.';' : 'margin-bottom:0px;';
        $title_font_size = (isset($this->addon->settings->title_font_size) && $this->addon->settings->title_font_size) ? 'font-size:'.$this->addon->settings->title_font_size.';' : 'font-size:20px;';

        $output  = '<div class="jd_timetable'.(empty($class)?'':' '.$class).'" style="'.$background_color.$text_color.'">
					<h3 class="jd_timetable_heading" style="'.$margin_top.$margin_bottom.$title_font_size.'">'.(!empty($icon)?'<img src="' . JURI::base(true) . '/' . $icon.'"/>':'').$title.'</h3>';
		$output .= '<div class="clr"></div>';
        //Image
        $output .= '<div class="jd_timing">';
        if(!empty($this->addon->settings->mon_fri) || !empty($this->addon->settings->sat) || !empty($this->addon->settings->sun)){
            $output .='<div class="jd_timing"><ul>';
            if(!empty($this->addon->settings->mon_fri)){
            $output .= '<li class="list">
                            <span class="day">'.JText::_('JD_TIMING_MONDAY_FRIDAY').'</span>
                            <span class="time">'.$this->addon->settings->mon_fri.'</span>
                        </li>';
            }
            if(!empty($this->addon->settings->sat)){
            $output .= '<li class="list">
                            <span class="day">'.JText::_('JD_TIMING_SATURDAY').'</span>
                            <span class="time">'.$this->addon->settings->sat.'</span>
                        </li>';
            }
            if(!empty($this->addon->settings->sun)){
                $output .= '<li class="list">
                            <span class="day">'.JText::_('JD_TIMING_SUNDAY').'</span>
                            <span class="time">'.$this->addon->settings->sun.'</span>
                        </li>';
            }
            $output .= '</ul></div>';
        }
        $output .= '</div></div>';
        
        return $output;
	}

	public function css() {
        return;
	}
}