| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
#[AllowDynamicProperties] |
| 3 |
class SH4_Conf_Html_Admin_View_Datetime |
| 4 |
{ |
| 5 |
protected $ui = NULL; |
| 6 |
protected $settings = NULL; |
| 7 |
|
| 8 |
public function __construct( |
| 9 |
HC3_Hooks $hooks, |
| 10 |
|
| 11 |
HC3_Ui $ui, |
| 12 |
HC3_Ui_Layout1 $layout, |
| 13 |
HC3_Time $t, |
| 14 |
|
| 15 |
HC3_Settings $settings |
| 16 |
) |
| 17 |
{ |
| 18 |
$this->ui = $ui; |
| 19 |
$this->layout = $layout; |
| 20 |
$this->t = $t; |
| 21 |
|
| 22 |
$this->settings = $hooks->wrap($settings); |
| 23 |
$this->self = $hooks->wrap($this); |
| 24 |
} |
| 25 |
|
| 26 |
public function render() |
| 27 |
{ |
| 28 |
$values = array(); |
| 29 |
$pnames = array( |
| 30 |
'datetime_date_format', 'datetime_time_format', 'datetime_week_starts', 'full_day_count_as', |
| 31 |
'skip_weekdays', 'datetime_timezone', |
| 32 |
'datetime_min_time', 'datetime_max_time', 'datetime_step', |
| 33 |
'datetime_days_in_week', 'datetime_minimalistic_week', 'datetime_hide_schedule_reports', 'datetime_summary_by_calendar', 'datetime_hide_bottom_date_navigation', 'datetime_month_slim_view', 'datetime_compact_shift_label', |
| 34 |
'default_schedule_view', 'default_schedule_groupby', 'datetime_n_weeks', |
| 35 |
'pref_csv_separator' |
| 36 |
); |
| 37 |
foreach( $pnames as $pname ){ |
| 38 |
$values[$pname] = $this->settings->get($pname); |
| 39 |
} |
| 40 |
$inputs = array(); |
| 41 |
|
| 42 |
$inputs[] = $this->ui->makeInputSelect( |
| 43 |
'datetime_date_format', |
| 44 |
'__Date Format__', |
| 45 |
array( |
| 46 |
'd/m/Y' => date('d/m/Y'), |
| 47 |
'd-m-Y' => date('d-m-Y'), |
| 48 |
'n/j/Y' => date('n/j/Y'), |
| 49 |
'Y/m/d' => date('Y/m/d'), |
| 50 |
'd.m.Y' => date('d.m.Y'), |
| 51 |
'j M Y' => date('j M Y'), |
| 52 |
'Y-m-d' => date('Y-m-d'), |
| 53 |
), |
| 54 |
$values['datetime_date_format'] |
| 55 |
); |
| 56 |
|
| 57 |
$options = array( 'g:ia', 'g:i A', '12short', '12xshort', 'H:i', '24short', ); |
| 58 |
$inputOptions = array(); |
| 59 |
|
| 60 |
$testTimes = array( '202103130800', '202103131400', '202103131515' ); |
| 61 |
|
| 62 |
foreach( $options as $e ){ |
| 63 |
$view = array( ); |
| 64 |
foreach( $testTimes as $test ){ |
| 65 |
$this->t->setDateTimeDb( $test ); |
| 66 |
$view[] = $this->t->formatTime( $e ); |
| 67 |
} |
| 68 |
$view = join( ', ', $view ); |
| 69 |
$inputOptions[ $e ] = $view; |
| 70 |
} |
| 71 |
|
| 72 |
$inputs[] = $this->ui->makeInputSelect( |
| 73 |
'datetime_time_format', |
| 74 |
'__Time Format__', |
| 75 |
$inputOptions, |
| 76 |
$values['datetime_time_format'] |
| 77 |
); |
| 78 |
|
| 79 |
$inputs[] = $this->ui->makeInputSelect( |
| 80 |
'datetime_week_starts', |
| 81 |
'__Week Starts On__', |
| 82 |
array( |
| 83 |
0 => '__Sun__', |
| 84 |
1 => '__Mon__', |
| 85 |
2 => '__Tue__', |
| 86 |
3 => '__Wed__', |
| 87 |
4 => '__Thu__', |
| 88 |
5 => '__Fri__', |
| 89 |
6 => '__Sat__', |
| 90 |
), |
| 91 |
$values['datetime_week_starts'] |
| 92 |
); |
| 93 |
|
| 94 |
$countAsOptionsValues = range( 1, 24 ); |
| 95 |
$countAsOptionsKeys = array(); |
| 96 |
foreach( $countAsOptionsValues as $v ){ |
| 97 |
$countAsOptionsKeys[] = $v * (60 * 60); |
| 98 |
} |
| 99 |
$countAsOptions = array_combine( $countAsOptionsKeys, $countAsOptionsValues ); |
| 100 |
|
| 101 |
$inputs[] = $this->ui->makeInputSelect( |
| 102 |
'full_day_count_as', |
| 103 |
'__Full Day Counts As__' . ' (' . '__Hours__' . ')', |
| 104 |
$countAsOptions, |
| 105 |
$values['full_day_count_as'] |
| 106 |
); |
| 107 |
|
| 108 |
$inputs = $this->ui->makeGrid( $inputs ); |
| 109 |
|
| 110 |
$moreInputs = array(); |
| 111 |
|
| 112 |
// min/max time |
| 113 |
$moreInputs2 = array(); |
| 114 |
$moreInputs2[] = $this->ui->makeInputTime( |
| 115 |
'datetime_min_time', |
| 116 |
'__Min Start Time__', |
| 117 |
$values['datetime_min_time'], |
| 118 |
'nolimit' |
| 119 |
); |
| 120 |
$moreInputs2[] = $this->ui->makeInputTime( |
| 121 |
'datetime_max_time', |
| 122 |
'__Max End Time__', |
| 123 |
$values['datetime_max_time'], |
| 124 |
'nolimit' |
| 125 |
); |
| 126 |
|
| 127 |
$stepOptions = array( 1*60 => 1, 5*60 => 5, 10*60 => 10, 15*60 => 15, 20*60 => 20, 30*60 => 30, 60*60 => 60 ); |
| 128 |
$moreInputs2[] = $this->ui->makeInputSelect( |
| 129 |
'datetime_step', |
| 130 |
'__Time Increment__' . ' (' . '__Minutes__' . ')', |
| 131 |
$stepOptions, |
| 132 |
$values['datetime_step'] |
| 133 |
); |
| 134 |
|
| 135 |
$moreInputs2 = $this->ui->makeGrid( $moreInputs2 ); |
| 136 |
$moreInputs[] = $moreInputs2; |
| 137 |
|
| 138 |
// timezone |
| 139 |
$timezoneOptions = $this->t->getTimezones(); |
| 140 |
|
| 141 |
$defaultLabel = $this->t->getDefaultTimezone(); |
| 142 |
$defaultLabel = ' - ' . '__Default Timezone__' . ' - ' . ' [' . $defaultLabel . ']'; |
| 143 |
|
| 144 |
$timezoneOptions = array_merge( array('' => $defaultLabel), $timezoneOptions ); |
| 145 |
|
| 146 |
$moreInputs[] = $this->ui->makeInputSelect( |
| 147 |
'datetime_timezone', |
| 148 |
'__Timezone__', |
| 149 |
$timezoneOptions, |
| 150 |
$values['datetime_timezone'] |
| 151 |
); |
| 152 |
|
| 153 |
$this->t->setNow(); |
| 154 |
$currentTimeView = $this->t->formatDateWithWeekday() . ' ' . $this->t->formatTime(); |
| 155 |
$currentTimeView = '<div class="hc-muted2">' . $currentTimeView . '</div>'; |
| 156 |
|
| 157 |
$moreInputs[] = $currentTimeView; |
| 158 |
|
| 159 |
// disabled weekdays |
| 160 |
$disabledWeekdays = array(); |
| 161 |
$weekdays = $this->t->getWeekdays(); |
| 162 |
|
| 163 |
$currentDisabled = $this->settings->get( 'skip_weekdays', TRUE ); |
| 164 |
foreach( $weekdays as $wkd => $wkdName ){ |
| 165 |
$isChecked = in_array( $wkd, $currentDisabled ) ? TRUE : FALSE; |
| 166 |
$disabledWeekdays[] = $this->ui->makeInputCheckbox( 'skip_weekdays[]', $wkdName, $wkd, $isChecked ); |
| 167 |
} |
| 168 |
$disabledWeekdays = $this->ui->makeListInline( $disabledWeekdays ); |
| 169 |
$disabledWeekdays = $this->ui->makeLabelled( '__Days Of Week Disabled__', $disabledWeekdays ); |
| 170 |
$moreInputs[] = $disabledWeekdays; |
| 171 |
|
| 172 |
// hide schedule reports |
| 173 |
$hideScheduleReports = $this->ui->makeInputCheckbox( 'datetime_hide_schedule_reports', '__Hide Hours Reports In Schedule View__', 1, $values['datetime_hide_schedule_reports'] ); |
| 174 |
$moreInputs[] = $hideScheduleReports; |
| 175 |
|
| 176 |
// hide schedule reports |
| 177 |
$showSummaryByCalendar = $this->ui->makeInputCheckbox( 'datetime_summary_by_calendar', '__If the schedule view is grouped by employee, also show totals by calendar at the bottom__', 1, $values['datetime_summary_by_calendar'] ); |
| 178 |
$moreInputs[] = $showSummaryByCalendar; |
| 179 |
|
| 180 |
// hide bottom date navigation |
| 181 |
$hideBottomDateNavigation = $this->ui->makeInputCheckbox( 'datetime_hide_bottom_date_navigation', '__Hide Bottom Date Navigation In Schedule View__', 1, $values['datetime_hide_bottom_date_navigation'] ); |
| 182 |
$moreInputs[] = $hideBottomDateNavigation; |
| 183 |
|
| 184 |
// month slim view |
| 185 |
$moreInputs[] = $this->ui->makeInputCheckbox( 'datetime_month_slim_view', '__Slim Month Schedule Grouped View__', 1, $values['datetime_month_slim_view'] ); |
| 186 |
|
| 187 |
$thisValue = $this->settings->get( 'repeat_default_weeks' ); |
| 188 |
if( $thisValue ){ |
| 189 |
$thisOptions = range( 2, 20 ); |
| 190 |
$thisOptions = array_combine( $thisOptions, $thisOptions ); |
| 191 |
$moreInputs[] = $this->ui->makeInputSelect( 'repeat_default_weeks', '__Initial number of weeks for the repeat shift form__', $thisOptions, $thisValue ); |
| 192 |
} |
| 193 |
|
| 194 |
$thisOptions = array( 'abbr' => '__Abbreviation of calendar title__', 'abbr2' => '__Abbreviation of shift time title__', 'none' => '__Space__' ); |
| 195 |
$moreInputs[] = $this->ui->makeInputSelect( 'datetime_compact_shift_label', '__Shift Label In Compact View__', $thisOptions, $values['datetime_compact_shift_label'] ); |
| 196 |
|
| 197 |
$moreInputs[] = $this->ui->makeInputCheckbox( |
| 198 |
'datetime_minimalistic_week', |
| 199 |
'__Minimalistic Shift Widget In Week View__', |
| 200 |
1, |
| 201 |
$values['datetime_minimalistic_week'] |
| 202 |
); |
| 203 |
|
| 204 |
$thisOptions = range( 2, 21 ); |
| 205 |
$thisOptions = array_combine( $thisOptions, $thisOptions ); |
| 206 |
$moreInputs[] = $this->ui->makeInputSelect( |
| 207 |
'datetime_days_in_week', |
| 208 |
'__In Month View How Many Days Display In One Row__', |
| 209 |
$thisOptions, |
| 210 |
$values['datetime_days_in_week'] |
| 211 |
); |
| 212 |
|
| 213 |
// default schedule view |
| 214 |
$moreInputs3 = array(); |
| 215 |
// $defaultView = $this->ui->makeInputCheckbox( 'datetime_hide_schedule_reports', '__Hide Hours Reports In Schedule View__', 1, $values['datetime_hide_schedule_reports'] ); |
| 216 |
$defaultViewOptions = array( 'day' => '__Day__', 'week' => '__Week__', 'month' => '__Month__', '4weeks' => '__4 Weeks__', 'list' => '__List__' ); |
| 217 |
$defaultView = $this->ui->makeInputSelect( |
| 218 |
'default_schedule_view', |
| 219 |
'__Default Schedule View__', |
| 220 |
$defaultViewOptions, |
| 221 |
$values['default_schedule_view'] |
| 222 |
); |
| 223 |
$moreInputs3[] = $defaultView; |
| 224 |
|
| 225 |
$defaultGroupbyOptions = array( 'employee' => '__Employee__', 'calendar' => '__Calendar__', 'none' => '__None__' ); |
| 226 |
$defaultGroupby = $this->ui->makeInputSelect( |
| 227 |
'default_schedule_groupby', |
| 228 |
'__Default Schedule Group By__', |
| 229 |
$defaultGroupbyOptions, |
| 230 |
$values['default_schedule_groupby'] |
| 231 |
); |
| 232 |
$moreInputs3[] = $defaultGroupby; |
| 233 |
|
| 234 |
$nWeeksOptions = array( 3 => 3, 4 => 4, 5 => 5, 6 => 6 ); |
| 235 |
$nWeeks = $this->ui->makeInputSelect( |
| 236 |
'datetime_n_weeks', |
| 237 |
'__Multiple Weeks View__', |
| 238 |
$nWeeksOptions, |
| 239 |
$values['datetime_n_weeks'] |
| 240 |
); |
| 241 |
$moreInputs3[] = $nWeeks; |
| 242 |
|
| 243 |
$moreInputs3 = $this->ui->makeGrid( $moreInputs3 ); |
| 244 |
$moreInputs[] = $moreInputs3; |
| 245 |
|
| 246 |
$moreInputs[] = $this->ui->makeInputSelect( |
| 247 |
'pref_csv_separator', |
| 248 |
'__CSV Delimiter__', |
| 249 |
array( |
| 250 |
',' => ',', |
| 251 |
';' => ';', |
| 252 |
), |
| 253 |
$values['pref_csv_separator'] |
| 254 |
); |
| 255 |
|
| 256 |
$moreInputs = $this->ui->makeList( $moreInputs ); |
| 257 |
|
| 258 |
$inputs = $this->ui->makeList( array($inputs, $moreInputs) ); |
| 259 |
|
| 260 |
$out = $this->ui->makeForm( |
| 261 |
'admin/conf/datetime', |
| 262 |
$this->ui->makeList( |
| 263 |
array( $inputs, $this->ui->makeInputSubmit( '__Save__')->tag('primary') ) |
| 264 |
) |
| 265 |
); |
| 266 |
|
| 267 |
$this->layout |
| 268 |
->setContent( $out ) |
| 269 |
->setBreadcrumb( $this->self->breadcrumb() ) |
| 270 |
->setHeader( $this->self->header() ) |
| 271 |
// ->setMenu( $this->self->menu() ) |
| 272 |
; |
| 273 |
|
| 274 |
$out = $this->layout->render(); |
| 275 |
return $out; |
| 276 |
} |
| 277 |
|
| 278 |
public function header() |
| 279 |
{ |
| 280 |
$out = '__Date and Time__'; |
| 281 |
return $out; |
| 282 |
} |
| 283 |
|
| 284 |
public function breadcrumb() |
| 285 |
{ |
| 286 |
$return = array(); |
| 287 |
$return['admin'] = array( 'admin', '__Administration__' ); |
| 288 |
return $return; |
| 289 |
} |
| 290 |
} |