# shiftcontroller/4.9.66/hc3/ui/element/input/timerange.php

ShiftController Employee Shift Scheduling, version 4.9.66. 59 lines.

- Page: https://pluginprobe.com/plugins/shiftcontroller/4.9.66/code/hc3/ui/element/input/timerange.php
- Raw: https://pluginprobe.com/plugins/shiftcontroller/4.9.66/raw/hc3/ui/element/input/timerange.php
- Modified: 2023-05-29T12:46:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/shiftcontroller/4.9.66/code/hc3/ui/element/input/timerange.php#L10-L20`.

```php
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
class HC3_Ui_Element_Input_TimeRange extends HC3_Ui_Abstract_Input
{
	protected $el = 'select';
	protected $uiType = 'input/timerange';
	protected $timeFormatOptions = array();

	public function __construct( $htmlFactory, $name, $label = NULL, $timeFormatOptions = array(), $value = array() )
	{
		parent::__construct( $htmlFactory, $name, $label, $value );
		$this->timeFormatOptions = $timeFormatOptions;
	}

	public function setValue( $value )
	{
		if( ! is_array($value) ){
			$value = explode( '-', $value );
		}
		$this->value = $value;
		return $this;
	}

	public function render()
	{
		$input_value = NULL;
		if( $this->value && is_array($this->value) ){
			$input_value = array();
			foreach( $this->value as $v ){
				$input_value[] = $v;
			}
			$input_value = join('-', $input_value);
		}
		$hidden = $this->htmlFactory->makeInputHidden( $this->name(), $input_value );

		$display = $this->htmlFactory->makeBlock()
			->addAttr('class', 'hcj-display')
			;

		$out = $this->htmlFactory->makeCollection( array($hidden, $display) );
		$out = $this->htmlFactory->makeBlock( $out )
			->addAttr('class', 'hcj-timerange-input')
			;

	// time options
		$data_atts = array(
			'time-format'	=> $this->timeFormatOptions,
			);
		foreach( $data_atts as $k => $v ){
			$out->addAttr('data-' . $k, htmlentities(json_encode($v)));
		}

		if( strlen($this->label) ){
			$out = $this->htmlFactory->makeLabelled( $this->label, $out, $this->htmlId() );
		}

		return $out;
	}
}

```
