PluginProbe
ShiftController Employee Shift Scheduling / 4.9.85
ShiftController Employee Shift Scheduling v4.9.85
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / hc3 / ui / element / input / datepicker.php

datepicker.php in ShiftController Employee Shift Scheduling 4.9.85, at hc3/ui/element/input/datepicker.php

70 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 class HC3_Ui_Element_Input_Datepicker extends HC3_Ui_Abstract_Input
3 {
4 protected $el = 'input';
5 protected $uiType = 'input/datepicker';
6 public $dateFormat, $valueFormatted, $weekStartsOn;
7
8 public function __construct( $htmlFactory, $name, $label = NULL, $value = NULL, $valueFormatted = NULL, $dateFormat = NULL, $weekStartsOn = 0 )
9 {
10 parent::__construct( $htmlFactory, $name, $label, $value );
11
12 $this->dateFormat = $dateFormat;
13 $this->valueFormatted = $valueFormatted;
14 $this->weekStartsOn = $weekStartsOn;
15 }
16
17 public function render()
18 {
19 static $jsShown = FALSE;
20
21 /* hidden field to store our value */
22 $hidden = $this->htmlFactory->makeInputHidden( $this->name(), $this->value );
23
24 /* text field to display */
25 $display_name = $this->name() . '_display';
26
27 $text = $this->htmlFactory->makeInputText( $display_name, $this->label, $this->valueFormatted );
28
29 $text
30 ->addAttr( 'class', 'hc-datepicker2' )
31 ->addAttr( 'readonly', 'true' )
32 ->addAttr( 'class', 'hc-xs-block' )
33 ->addAttr( 'data-date-format', $this->dateFormat )
34 ->addAttr( 'data-date-week-start', $this->weekStartsOn)
35 // ->addAttr( 'data-date-end-date', '25 Apr 2022' )
36 ;
37
38 // $text = $this->app->make('/form/text')
39 // ->addAttr('data-date-week-start', $t->weekStartsOn)
40 // ;
41
42 $js = NULL;
43
44 if( ! $jsShown ){
45 ob_start();
46 ?>
47
48 <script language="JavaScript">
49 document.addEventListener('DOMContentLoaded', function()
50 {
51 jQuery.fn.hc_datepicker2.dates['en'] = {
52 days: ["__Sun__", "__Mon__", "__Tue__", "__Wed__", "__Thu__", "__Fri__", "__Sat__", "__Sun__"],
53 daysShort: ["__Sun__", "__Mon__", "__Tue__", "__Wed__", "__Thu__", "__Fri__", "__Sat__", "__Sun__"],
54 daysMin: ["__Sun__", "__Mon__", "__Tue__", "__Wed__", "__Thu__", "__Fri__", "__Sat__", "__Sun__"],
55 months: ["__Jan__", "__Feb__", "__Mar__", "__Apr__", "__May__", "__Jun__", "__Jul__", "__Aug__", "__Sep__", "__Oct__", "__Nov__", "__Dec__"],
56 monthsShort: ["__Jan__", "__Feb__", "__Mar__", "__Apr__", "__May__", "__Jun__", "__Jul__", "__Aug__", "__Sep__", "__Oct__", "__Nov__", "__Dec__"],
57 today: "Today",
58 clear: "Clear"
59 };
60 });
61 </script>
62 <?php
63 $js = ob_get_clean();
64 $jsShown = TRUE;
65 }
66
67 $out = $this->htmlFactory->makeCollection( array($hidden, $text, $js) );
68 return $out;
69 }
70 }