"use strict";(self.webpackChunktimetrex=self.webpackChunktimetrex||[]).push([["attendance-schedule-ScheduleViewController"],{6478:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("// ESM COMPAT FLAG\n__webpack_require__.r(__webpack_exports__);\n\n// EXPORTS\n__webpack_require__.d(__webpack_exports__, {\n \"ScheduleViewController\": () => (/* binding */ ScheduleViewController)\n});\n\n// EXTERNAL MODULE: ./interface/html5/services/TTVueUtils.js\nvar TTVueUtils = __webpack_require__(4966);\n// EXTERNAL MODULE: ./node_modules/vue/dist/vue.esm-bundler.js + 6 modules\nvar vue_esm_bundler = __webpack_require__(5166);\n;// CONCATENATED MODULE: ./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[1]!./node_modules/vue-loader/dist/index.js??ruleSet[1].rules[6].use[0]!./interface/html5/components/schedule/ScheduleControlBar.vue?vue&type=template&id=4f970b96&scoped=true\n\n\nconst _withScopeId = n => ((0,vue_esm_bundler/* pushScopeId */.dD)(\"data-v-4f970b96\"),n=n(),(0,vue_esm_bundler/* popScopeId */.Cn)(),n)\nconst _hoisted_1 = { class: \"tt-horizontal-vue-bar\" }\nconst _hoisted_2 = /*#__PURE__*/ _withScopeId(() => /*#__PURE__*/(0,vue_esm_bundler/* createElementVNode */._)(\"div\", { class: \"bar-column left\" }, null, -1 /* HOISTED */))\nconst _hoisted_3 = /*#__PURE__*/ _withScopeId(() => /*#__PURE__*/(0,vue_esm_bundler/* createElementVNode */._)(\"div\", { class: \"bar-column center\" }, [\n /*#__PURE__*/(0,vue_esm_bundler/* createElementVNode */._)(\"div\", { class: \"date-chooser-div\" })\n], -1 /* HOISTED */))\nconst _hoisted_4 = { class: \"bar-column right\" }\nconst _hoisted_5 = { class: \"bar-column schedule-mode\" }\nconst _hoisted_6 = { class: \"bar-column menu-item\" }\n\nfunction render(_ctx, _cache, $props, $setup, $data, $options) {\n const _component_SelectButton = (0,vue_esm_bundler/* resolveComponent */.up)(\"SelectButton\")\n const _component_TTContextButton = (0,vue_esm_bundler/* resolveComponent */.up)(\"TTContextButton\")\n\n return ((0,vue_esm_bundler/* openBlock */.wg)(), (0,vue_esm_bundler/* createElementBlock */.iD)(\"div\", _hoisted_1, [\n _hoisted_2,\n _hoisted_3,\n (0,vue_esm_bundler/* createElementVNode */._)(\"div\", _hoisted_4, [\n (0,vue_esm_bundler/* createElementVNode */._)(\"div\", _hoisted_5, [\n (0,vue_esm_bundler/* createVNode */.Wm)(_component_SelectButton, {\n modelValue: $data.schedule_mode_options_selected,\n \"onUpdate:modelValue\": _cache[0] || (_cache[0] = $event => (($data.schedule_mode_options_selected) = $event)),\n options: $props.schedule_mode_options,\n optionLabel: \"label\",\n optionValue: \"value\",\n onClick: _cache[1] || (_cache[1] = $event => {this.onScheduleModeChange();})\n }, null, 8 /* PROPS */, [\"modelValue\", \"options\"])\n ]),\n (0,vue_esm_bundler/* createElementVNode */._)(\"div\", _hoisted_6, [\n (0,vue_esm_bundler/* createVNode */.Wm)(_component_TTContextButton, {\n class: (0,vue_esm_bundler/* normalizeClass */.C_)(['no-wrap']),\n items: $props.schedule_settings_options\n }, null, 8 /* PROPS */, [\"items\"])\n ])\n ])\n ]))\n}\n;// CONCATENATED MODULE: ./interface/html5/components/schedule/ScheduleControlBar.vue?vue&type=template&id=4f970b96&scoped=true\n\n// EXTERNAL MODULE: ./node_modules/primevue/selectbutton/selectbutton.esm.js\nvar selectbutton_esm = __webpack_require__(1109);\n// EXTERNAL MODULE: ./interface/html5/components/context_menu/TTContextButton.vue + 24 modules\nvar TTContextButton = __webpack_require__(777);\n;// CONCATENATED MODULE: ./node_modules/vue-loader/dist/index.js??ruleSet[1].rules[6].use[0]!./interface/html5/components/schedule/ScheduleControlBar.vue?vue&type=script&lang=js\n\n\n\n\n/* harmony default export */ const ScheduleControlBarvue_type_script_lang_js = ({\n name: \"ScheduleControlBar\",\n created() {\n this.event_bus = new TTEventBus( {\n component_id: this.component_id\n } );\n this.event_bus.on( this.component_id, 'getValue', this.getValue, TTEventBusStatics.AUTO_CLEAR_ON_EXIT );\n this.event_bus.on( this.component_id, 'setValue', this.setValue, TTEventBusStatics.AUTO_CLEAR_ON_EXIT );\n this.event_bus.on( this.component_id, 'setScheduleSettingsState', this.setScheduleSettingsState, TTEventBusStatics.AUTO_CLEAR_ON_EXIT );\n this.event_bus.on( this.component_id, 'setSettingActive', this.setSettingActive, TTEventBusStatics.AUTO_CLEAR_ON_EXIT );\n this.event_bus.on( this.component_id, 'setSettingDeactivated', this.setSettingDeactivated, TTEventBusStatics.AUTO_CLEAR_ON_EXIT );\n },\n unmounted() {\n Debug.Text( 'Vue control bar component unmounted ('+ this.component_id +').', 'ScheduleControlBar.vue', 'ScheduleControlBar', 'unmounted', 2 );\n this.event_bus.autoClear();\n },\n props: { // passed in via root props from TimeSheetViewController\n view_id: {\n type: String,\n default: null\n },\n component_id: { /* Note: This is passed in via TTVueUtils.mountComponent param, and auto added to root_props. */\n type: String,\n default: null\n },\n schedule_mode_options: {\n type: Array,\n default: []\n },\n schedule_settings_options: {\n type: Array,\n default: []\n },\n },\n data() {\n return {\n removeEventsOnUnmount: [],\n schedule_mode_options_selected: 'week',\n }\n },\n // watch: {\n // schedule_mode_options_selected: function ( val ) {\n // this.event_bus.emit( this.component_id, 'scheduleModeOnChange', {\n // key: 'schedule_mode_options_selected',\n // value: val\n // });\n // },\n // },\n computed: {\n },\n methods: {\n // getValue( event_data ) {\n // // Validate\n // if ( event_data.key && ['schedule_mode_options_selected'].includes( event_data.key) ) {\n // EventBus.emit( this.vue_control_bar_id +'.getValueReturn', {\n // key: event_data.key,\n // value: this[ event_data.key ]\n // });\n // return this[ event_data.key ];\n // } else if ( event_data.key && ['all_employee_btn', 'daily_totals_btn', 'weekly_totals_btn', 'strict_range_btn'].includes( event_data.key) ) {\n //\n // } else {\n // // invalid\n // }\n // },\n setValue( event_data ) {\n var valid_editable_fields = ['schedule_mode_options_selected'];\n // Validate\n if( event_data.key && event_data.key && valid_editable_fields.includes( event_data.key) ) {\n this[ event_data.key ] = event_data.value;\n } else {\n // invalid\n Debug.Error( 'Invalid parameters passed to function.', 'ScheduleControlBar.vue', 'ScheduleControlBar', 'setValue', 1 );\n\n }\n },\n getScheduleSettingsState( item_id ) {\n var item = this.schedule_settings_options.find( element => element.id === item_id );\n if( item ) {\n return item.active;\n } else {\n Debug.Error( 'Item not found ('+ item_id +'). Check supplied id.', 'ScheduleControlBar.vue', 'ScheduleControlBar', 'getScheduleSettingsState', 1 );\n return undefined;\n }\n },\n setScheduleSettingsState( event_data ) {\n var item = this.schedule_settings_options.find( element => element.id === event_data.item_id );\n if( item ) {\n item[ event_data.item_field ] = event_data.item_value;\n } else {\n Debug.Error( 'Item not found ('+ event_data.item_id +'). Check supplied id.', 'ScheduleControlBar.vue', 'ScheduleControlBar', 'setScheduleSettingsState', 1 );\n }\n },\n setSettingActive( event_data ) {\n var item = this.schedule_settings_options.find( element => element.id === event_data.item_id );\n if( item ) {\n item.setOnlySelfActive();\n } else {\n Debug.Error( 'Item not found ('+ event_data.item_id +'). Check supplied id.', 'ScheduleControlBar.vue', 'ScheduleControlBar', 'setSettingActive', 1 );\n }\n },\n setSettingDeactivated( event_data ) {\n var item = this.schedule_settings_options.find( element => element.id === event_data.item_id );\n if( item ) {\n item.setOnlySelfDeactivated();\n } else {\n Debug.Error( 'Item not found ('+ event_data.item_id +'). Check supplied id.', 'ScheduleControlBar.vue', 'ScheduleControlBar', 'setOnlySelfDeactivated', 1 );\n }\n },\n onScheduleModeChange() {\n this.event_bus.emit( this.component_id, 'scheduleModeOnChange', {\n key: 'schedule_mode_options_selected',\n value: this.schedule_mode_options_selected\n });\n },\n },\n components: {\n SelectButton: selectbutton_esm/* default */.Z,\n TTContextButton: TTContextButton/* default */.Z\n }\n});\n\n;// CONCATENATED MODULE: ./interface/html5/components/schedule/ScheduleControlBar.vue?vue&type=script&lang=js\n \n// EXTERNAL MODULE: ./node_modules/vue-loader/dist/exportHelper.js\nvar exportHelper = __webpack_require__(3744);\n;// CONCATENATED MODULE: ./interface/html5/components/schedule/ScheduleControlBar.vue\n\n\n\n\n;\n\n\nconst __exports__ = /*#__PURE__*/(0,exportHelper/* default */.Z)(ScheduleControlBarvue_type_script_lang_js, [['render',render],['__scopeId',\"data-v-4f970b96\"]])\n\n/* harmony default export */ const ScheduleControlBar = (__exports__);\n;// CONCATENATED MODULE: ./interface/html5/views/attendance/schedule/ScheduleViewController.js\n/* provided dependency */ var _ = __webpack_require__(9050);\n/* provided dependency */ var $ = __webpack_require__(9755);\n\n\n\nclass ScheduleViewController extends BaseViewController {\n\tconstructor( options = {} ) {\n\t\t_.defaults( options, {\n\t\t\tel: '#schedule_view_container', //Must set el here and can only set string, so events can work\n\n\n\n\t\t\tuser_group_api: null,\n\n\t\t\tstatus_array: null,\n\n\t\t\tuser_group_array: null,\n\n\t\t\ttoggle_button: null,\n\n\t\t\tstart_date_picker: null,\n\n\t\t\tstart_date: null,\n\n\t\t\tend_date: null,\n\n\t\t\tfull_schedule_data: null,\n\n\t\t\tschedule_columns: null,\n\n\t\t\tfull_format: 'ddd-MMM-DD-YYYY',\n\n\t\t\tweekly_format: 'ddd, MMM DD',\n\n\t\t\tfinal_schedule_data_array: [],\n\n\t\t\thas_date_array: [],\n\n\t\t\tno_date_array: [],\n\n\t\t\tshift_key_name_array: [],\n\n\t\t\tselect_cells_Array: [], //Timesheet grid\n\n\t\t\tselect_all_shifts_array: [], //Timesheet grid.\n\n\t\t\tselect_shifts_array: [], //Timesheet grid.\n\n\t\t\tselect_recurring_shifts_array: [], //Timesheet grid.\n\n\t\t\tall_employee_btn: null,\n\n\t\t\tdaily_totals_btn: null,\n\n\t\t\tweekly_totals_btn: null,\n\n\t\t\tstrict_range_btn: null,\n\n\t\t\tmonth_date_row_array: null,\n\n\t\t\tmonth_date_row_tr_ids: null, // month date tr id in grid table\n\n\t\t\tmonth_date_row_position: null, //month date tr position in table\n\n\t\t\tmonth_current_header_number: 0, //0 is default column header\n\n\t\t\tday_header_width: 0,\n\n\t\t\tday_hour_width: 40,\n\n\t\t\tselect_drag_menu_id: '', //Do drag move or copy\n\n\t\t\tis_override: false,\n\n\t\t\tnotify_user_schedule_change: false,\n\n\t\t\tscroll_position: 0,\n\n\t\t\tselected_user_ids: [],\n\n\t\t\tprev_total_time: 0,\n\n\t\t\tprev_status_id: null,\n\n\t\t\tis_mass_adding: false,\n\n\t\t\tcalculate_cell_number: 0,\n\n\t\t\tscroll_interval: null,\n\n\t\t\tscroll_unit: 0,\n\n\t\t\tholiday_data_dic: {},\n\n\t\t\tabsence_policy_api: null,\n\n\t\t\tjob_api: null,\n\t\t\tjob_item_api: null,\n\t\t\tuser_api: null,\n\t\t\tdepartment_api: null,\n\t\t\tpunch_tag_api: null,\n\t\t\tdefault_punch_tag: [],\n\t\t\tprevious_punch_tag_selection: [],\n\n\t\t\tyear_mode_original_date: null, //set this when search for yer mode with use_date_picker true, so Keep select date in ritict mode\n\t\t\tevents: {},\n\t\t\tvue_control_bar_id: ''\n\t\t} );\n\n\t\tsuper( options );\n\t}\n\n\tinit( options ) {\n\t\t//this._super('initialize', options );\n\t\tthis.permission_id = 'schedule';\n\t\tthis.script_name = 'ScheduleView';\n\t\tthis.viewId = 'Schedule';\n\t\tthis.table_name_key = 'schedule';\n\t\tthis.context_menu_name = $.i18n._( 'Schedules' );\n\t\tthis.navigation_label = $.i18n._( 'Schedule' );\n\t\tthis.api = TTAPI.APISchedule;\n\t\tthis.user_group_api = TTAPI.APIUserGroup;\n\t\tthis.absence_policy_api = TTAPI.APIAbsencePolicy;\n\t\tthis.company_api = TTAPI.APICompany;\n\t\tthis.user_api = TTAPI.APIUser;\n\t\tthis.currency_api = TTAPI.APICurrency;\n\t\tthis.event_bus = new TTEventBus({ view_id: this.viewId });\n\n\n\t\tif ( Global.getProductEdition() >= 20 ) {\n\t\t\tthis.job_api = TTAPI.APIJob;\n\t\t\tthis.job_item_api = TTAPI.APIJobItem;\n\t\t\tthis.punch_tag_api = TTAPI.APIPunchTag;\n\t\t\tthis.department_api = TTAPI.APIDepartment;\n\t\t}\n\n\t\tthis.api_absence_policy = TTAPI.APIAbsencePolicy;\n\n\t\tthis.scroll_position = 0;\n\n\t\tthis.initPermission();\n\t\tthis.render();\n\t\tthis.buildContextMenu();\n\n\t\tthis.initData();\n\t}\n\n\tjobUIValidate( p_id ) {\n\n\t\tif ( !p_id ) {\n\t\t\tp_id = this.permission_id;\n\t\t}\n\n\t\tif ( PermissionManager.validate( 'job', 'enabled' ) &&\n\t\t\tPermissionManager.validate( p_id, 'edit_job' ) &&\n\t\t\t( Global.getProductEdition() >= 20 ) ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tjobItemUIValidate( p_id ) {\n\n\t\tif ( !p_id ) {\n\t\t\tp_id = this.permission_id;\n\t\t}\n\n\t\tif ( PermissionManager.validate( 'job_item', 'enabled' ) &&\n\t\t\tPermissionManager.validate( p_id, 'edit_job_item' ) ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpunchTagUIValidate( p_id ) {\n\n\t\tif ( !p_id ) {\n\t\t\tp_id = this.permission_id;\n\t\t}\n\n\t\tif ( PermissionManager.validate( 'punch_tag', 'enabled' ) &&\n\t\t\tPermissionManager.validate( p_id, 'edit_job_item' ) ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tbranchUIValidate( p_id ) {\n\n\t\tif ( !p_id ) {\n\t\t\tp_id = this.permission_id;\n\t\t}\n\n\t\tif ( PermissionManager.validate( p_id, 'edit_branch' ) ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tdepartmentUIValidate( p_id ) {\n\n\t\tif ( !p_id ) {\n\t\t\tp_id = this.permission_id;\n\t\t}\n\n\t\tif ( PermissionManager.validate( p_id, 'edit_department' ) ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tunscheduledEmployeeUIValidate() {\n\n\t\tif ( PermissionManager.validate( 'schedule', 'view' ) || PermissionManager.validate( 'schedule', 'view_child' ) ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t//Speical permission check for views, need override\n\tinitPermission() {\n\t\tsuper.initPermission();\n\n\t\tthis.show_search_tab = true;\n\t\t//See buildSearchFields() for additional permission checks.\n\t\t// if ( PermissionManager.validate( this.permission_id, 'view' ) || PermissionManager.validate( this.permission_id, 'view_child' ) ) {\n\t\t// \tthis.show_search_tab = true;\n\t\t// } else {\n\t\t// \tthis.show_search_tab = false;\n\t\t// }\n\n\t\tif ( this.jobUIValidate() ) {\n\t\t\tthis.show_job_ui = true;\n\t\t} else {\n\t\t\tthis.show_job_ui = false;\n\t\t}\n\n\t\tif ( this.jobItemUIValidate() ) {\n\t\t\tthis.show_job_item_ui = true;\n\t\t} else {\n\t\t\tthis.show_job_item_ui = false;\n\t\t}\n\n\t\tif ( this.punchTagUIValidate() ) {\n\t\t\tthis.show_punch_tag_ui = true;\n\t\t} else {\n\t\t\tthis.show_punch_tag_ui = false;\n\t\t}\n\n\t\tif ( this.branchUIValidate() ) {\n\t\t\tthis.show_branch_ui = true;\n\t\t} else {\n\t\t\tthis.show_branch_ui = false;\n\t\t}\n\n\t\tif ( this.departmentUIValidate() ) {\n\t\t\tthis.show_department_ui = true;\n\t\t} else {\n\t\t\tthis.show_department_ui = false;\n\t\t}\n\t}\n\n\t//only be call once when open this view\n\tinitData() {\n\t\tvar $this = this;\n\n\t\t//Remove tab if any\n\t\tGlobal.removeViewTab( this.viewId );\n\t\tProgressBar.showOverlay();\n\t\tthis.initOptions();\n\n\t\t//For regular employees who currently can't see the \"Saved Search and Layout\" tab, try to be smarter about what columns they do see by default.\n\t\tthis.default_display_columns = [];\n\t\tif ( PermissionManager.validate( this.permission_id, 'edit_branch' ) ) {\n\t\t\tthis.default_display_columns.push( 'branch' );\n\t\t}\n\t\tif ( PermissionManager.validate( this.permission_id, 'edit_department' ) ) {\n\t\t\tthis.default_display_columns.push( 'department' );\n\t\t}\n\t\tif ( Global.getProductEdition() >= 20 ) {\n\t\t\tif ( PermissionManager.validate( this.permission_id, 'edit_job' ) ) {\n\t\t\t\tthis.default_display_columns.push( 'job' );\n\t\t\t}\n\t\t\tif ( PermissionManager.validate( this.permission_id, 'edit_job_item' ) ) {\n\t\t\t\tthis.default_display_columns.push( 'job_item' );\n\t\t\t}\n\t\t}\n\n\t\tvar date = new Date();\n\n\t\tif ( Global.UNIT_TEST_MODE == true ) {\n\t\t\tLocalCacheData.last_schedule_selected_date = '15-Feb-18';\n\t\t}\n\n\t\tvar format = Global.getLoginUserDateFormat();\n\t\tvar dateStr = date.format( format );\n\n\t\tif ( !LocalCacheData.last_schedule_selected_date ) {\n\t\t\tif ( LocalCacheData.current_select_date && Global.strToDate( LocalCacheData.current_select_date, 'YYYY-MM-DD' ) ) { //Select date get from URL.\n\t\t\t\tthis.setDatePickerValue( Global.strToDate( LocalCacheData.current_select_date, 'YYYY-MM-DD' ).format() );\n\t\t\t\tLocalCacheData.current_select_date = '';\n\t\t\t} else {\n\t\t\t\tthis.setDatePickerValue( dateStr );\n\t\t\t}\n\t\t} else {\n\t\t\tthis.setDatePickerValue( LocalCacheData.last_schedule_selected_date );\n\t\t}\n\n\t\tthis.setMoveOrDropMode( this.select_drag_menu_id ? this.select_drag_menu_id : 'move' );\n\t\t//Issue #3280 - Race condition where previous search layout will not exist in UI when expected as API for custom field data has not returned yet.\n\t\t//ScheduleViewController overrides initData() from BaseViewController that waits on the custom field promise to resolve before continuing.\n\t\tTTPromise.wait( 'BaseViewController', 'getCustomFields', function() {\n\t\t\t$this.getAllColumns( function() {\n\t\t\t\t$this.initLayout();\n\t\t\t} );\n\t\t} );\n\t}\n\n\tsetToggleButtonValue( val ) {\n\n\t\tif ( this.toggle_button ) {\n\t\t\tthis.toggle_button.setValue( val );\n\n\t\t\tthis.setToggleButtonUrl();\n\t\t}\n\t}\n\n\tsetToggleButtonUrl() {\n\n\t\tvar mode = this.getMode();\n\t\tvar default_date = this.start_date_picker.getDefaultFormatValue();\n\t\tif ( !this.edit_view ) {\n\t\t\tGlobal.setURLToBrowser( Global.getBaseURL() + '#!m=' + this.viewId + '&mode=' + mode );\n\t\t}\n\t}\n\n\tsetDatePickerValue( val ) {\n\n\t\tthis.start_date_picker.setValue( val );\n\n\t\t//this.setDateUrl();\n\n\t\tLocalCacheData.last_schedule_selected_date = val;\n\t}\n\n\tgetAllColumns( callBack ) {\n\n\t\tvar $this = this;\n\t\tthis.api.getOptions( 'columns', {\n\t\t\tonResult: function( columns_result ) {\n\t\t\t\tvar columns_result_data = columns_result.getResult();\n\t\t\t\t$this.all_columns = Global.buildColumnArray( columns_result_data );\n\n\t\t\t\t$this.api.getOptions( 'group_columns', {\n\t\t\t\t\tonResult: function( group_columns_result ) {\n\n\t\t\t\t\t\tvar all_columns = Global.buildColumnArray( columns_result_data );\n\t\t\t\t\t\tvar group_columns_result_data = group_columns_result.getResult();\n\n\t\t\t\t\t\tvar final_all_columns = [];\n\n\t\t\t\t\t\tvar all_len = all_columns.length;\n\t\t\t\t\t\tvar group_len = group_columns_result_data.length;\n\n\t\t\t\t\t\tfor ( var i = 0; i < group_len; i++ ) {\n\t\t\t\t\t\t\tvar group_column_id = group_columns_result_data[i];\n\t\t\t\t\t\t\tfor ( var j = 0; j < all_len; j++ ) {\n\t\t\t\t\t\t\t\tvar column = all_columns[j];\n\t\t\t\t\t\t\t\tif ( column.value === group_column_id ) {\n\t\t\t\t\t\t\t\t\tfinal_all_columns.push( column );\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t$this.all_columns = final_all_columns;\n\n\t\t\t\t\t\t$this.column_selector.setUnselectedGridData( $this.all_columns );\n\t\t\t\t\t\tif ( callBack ) {\n\t\t\t\t\t\t\tcallBack();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t}\n\t\t} );\n\t}\n\n\tinitLayout() {\n\t\tvar $this = this;\n\t\t$this.getAllLayouts( function() {\n\t\t\t$this.setSelectLayout();\n\t\t\t$this.search( true, false ); //Make sure we setDefaultMenu is TRUE so autoOpenEditViewIfNecessary() is called.\n\t\t} );\n\t}\n\n\tinitOptions() {\n\t\tvar $this = this;\n\n\t\tthis.initDropDownOption( 'status', '', this.api );\n\n\t\tthis.user_group_api.getUserGroup( '', false, false, {\n\t\t\tonResult: function( res ) {\n\t\t\t\tres = res.getResult();\n\n\t\t\t\tres = Global.buildTreeRecord( res );\n\t\t\t\t$this.user_group_array = res;\n\n\t\t\t\tif ( $this.basic_search_field_ui_dic['group_ids'] ) {\n\t\t\t\t\t$this.basic_search_field_ui_dic['group_ids'].setSourceData( res );\n\t\t\t\t}\n\t\t\t\tif ( $this.adv_search_field_ui_dic['group_ids'] ) {\n\t\t\t\t\t$this.adv_search_field_ui_dic['group_ids'].setSourceData( res );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\tgetSelectDate() {\n\t\tvar retval = this.start_date_picker.getValue();\n\n\t\tif ( retval == 'Invalid date' ) {\n\t\t\tretval = new Date();\n\t\t}\n\n\t\treturn retval;\n\t}\n\n\tgetGridSelectIdArray() {\n\n\t\tvar result = [];\n\t\tvar len = this.select_all_shifts_array.length;\n\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\tvar item = this.select_all_shifts_array[i];\n\t\t\tif ( item.id && item.id != TTUUID.zero_id && item.id != TTUUID.not_exist_id ) {\n\t\t\t\tresult.push( item.id );\n\t\t\t}\n\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetSelectedItem() {\n\n\t\tvar selected_item = null;\n\t\tif ( this.edit_view ) {\n\t\t\tselected_item = this.current_edit_record;\n\t\t} else {\n\n\t\t\tif ( this.select_all_shifts_array.length > 0 ) {\n\t\t\t\tselected_item = this.select_all_shifts_array[0];\n\t\t\t}\n\n\t\t}\n\n\t\tif ( selected_item ) {\n\t\t\treturn Global.clone( selected_item );\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t_continueDoCopyAsNew() {\n\t\tvar $this = this;\n\t\tthis.setCurrentEditViewState( 'new' );\n\t\tLocalCacheData.current_doing_context_action = 'copy_as_new';\n\n\t\tif ( Global.isSet( this.edit_view ) ) {\n\n\t\t\tthis.current_edit_record.id = '';\n\t\t\tvar navigation_div = this.edit_view.find( '.navigation-div' );\n\t\t\tnavigation_div.css( 'display', 'none' );\n\t\t\tthis.setCurrentEditRecordData(); // Reset data to widgets to reset all widgets stat\n\t\t\tthis.setEditMenu();\n\t\t\tthis.setTabStatus();\n\t\t\tthis.is_changed = false;\n\t\t\tProgressBar.closeOverlay();\n\n\t\t} else {\n\n\t\t\tvar filter = {};\n\t\t\tvar grid_selected_id_array = this.getGridSelectIdArray();\n\t\t\tvar grid_selected_length = grid_selected_id_array.length;\n\n\t\t\tif ( grid_selected_length > 0 ) {\n\t\t\t\tvar selectedId = grid_selected_id_array[0];\n\t\t\t} else {\n\t\t\t\tvar select_shift = Global.clone( $this.select_all_shifts_array[0] );\n\t\t\t\tselect_shift = $this.resetSomeFields( select_shift );\n\t\t\t\t$this.current_edit_record = select_shift;\n\t\t\t\t$this.openEditView();\n\t\t\t\t$this.initEditView();\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tfilter.filter_data = {};\n\t\t\tfilter.filter_data.id = [selectedId];\n\n\t\t\tthis.api['get' + this.api.key_name]( filter, {\n\t\t\t\tonResult: function( result ) {\n\n\t\t\t\t\tvar result_data = result.getResult();\n\n\t\t\t\t\t//#2571 - result_data is undefined (when result_data === true there is no result[0])\n\t\t\t\t\tif ( !result_data || result_data === true ) {\n\t\t\t\t\t\tTAlertManager.showAlert( $.i18n._( 'Record does not exist' ) );\n\t\t\t\t\t\t$this.onCancelClick();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t$this.openEditView(); // Put it here is to avoid if the selected one is not existed in data or have deleted by other pragram. in this case, the edit view should not be opend.\n\n\t\t\t\t\tresult_data = result_data[0];\n\n\t\t\t\t\tresult_data.id = '';\n\n\t\t\t\t\tif ( $this.sub_view_mode && $this.parent_key ) {\n\t\t\t\t\t\tresult_data[$this.parent_key] = $this.parent_value;\n\t\t\t\t\t}\n\n\t\t\t\t\t$this.current_edit_record = result_data;\n\t\t\t\t\t$this.initEditView();\n\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\tonViewClick( record, noRefreshUI ) {\n\t\tthis.setCurrentEditViewState( 'view' );\n\n\t\tvar record_id = this.getViewSelectedRecordId( record );\n\t\tif ( Global.isFalseOrNull( record_id ) ) {\n\t\t\tTTPromise.add( 'Schedule', 'init' );\n\t\t\tthis.openEditView();\n\t\t\tvar select_shift = Global.clone( this.select_all_shifts_array[0] );\n\t\t\tselect_shift = this.resetSomeFields( select_shift );\n\t\t\tthis.current_edit_record = select_shift;\n\n\t\t\tvar $this = this;\n\t\t\tTTPromise.wait( 'Schedule', 'init', function() {\n\t\t\t\t$this.initEditView();\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\t\tthis.setCurrentSelectedRecord( record_id );\n\n\t\tthis.openEditView();\n\n\t\tvar filter = this.getAPIFilters();\n\n\t\treturn this.doViewAPICall( filter );\n\t}\n\n\tgetCommonFields() {\n\t\tvar baseRecord;\n\t\t$.each( this.select_all_shifts_array, function( index, value ) {\n\t\t\tif ( !baseRecord ) {\n\t\t\t\tbaseRecord = Global.clone( value );\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tfor ( var key in value ) {\n\t\t\t\tbaseRecord[key] !== value[key] && delete baseRecord[key];\n\t\t\t}\n\t\t} );\n\n\t\treturn baseRecord;\n\t}\n\n\tonMassEditClick() {\n\t\tvar $this = this;\n\t\tvar filter = {};\n\t\tvar grid_selected_id_array = [];\n\t\tthis.setCurrentEditViewState( 'mass_edit' );\n\t\tthis.mass_edit_record_ids = [];\n\n\t\tgrid_selected_id_array = this.getGridSelectIdArray();\n\t\t$this.openEditView();\n\n\t\t$.each( grid_selected_id_array, function( index, value ) {\n\t\t\t$this.mass_edit_record_ids.push( value );\n\t\t} );\n\n\t\t$this.selected_user_ids = [];\n\t\t$.each( this.select_all_shifts_array, function( index, value ) {\n\t\t\tvar shift = value;\n\t\t\tif ( shift.hasOwnProperty( 'user_id' ) ) {\n\t\t\t\t$this.selected_user_ids.push( shift.user_id );\n\t\t\t}\n\n\t\t} );\n\n\t\tfilter.filter_data = {};\n\t\tfilter.filter_data.id = this.mass_edit_record_ids;\n\n\t\tif ( this.mass_edit_record_ids.length !== this.select_all_shifts_array.length ) {\n\t\t\tonMassEditResult( this.getCommonFields() );\n\t\t\treturn;\n\t\t}\n\n\t\tthis.api['getCommon' + this.api.key_name + 'Data']( filter, {\n\t\t\tonResult: function( result ) {\n\n\t\t\t\tvar result_data = result.getResult();\n\n\t\t\t\tif ( !result_data ) {\n\t\t\t\t\tresult_data = [];\n\t\t\t\t}\n\t\t\t\tonMassEditResult( result_data );\n\n\t\t\t}\n\t\t} );\n\n\t\tfunction onMassEditResult( result_data ) {\n\t\t\t$this.api['getOptions']( 'unique_columns', {\n\t\t\t\tonResult: function( result ) {\n\t\t\t\t\t$this.unique_columns = result.getResult();\n\t\t\t\t\t$this.api['getOptions']( 'linked_columns', {\n\t\t\t\t\t\tonResult: function( result1 ) {\n\n\t\t\t\t\t\t\t$this.linked_columns = result1.getResult();\n\n\t\t\t\t\t\t\tif ( $this.sub_view_mode && $this.parent_key ) {\n\t\t\t\t\t\t\t\tresult_data[$this.parent_key] = $this.parent_value;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t$this.current_edit_record = result_data;\n\t\t\t\t\t\t\t$this.is_mass_editing = true;\n\t\t\t\t\t\t\t$this.initEditView();\n\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\tonEditClick( record_id, noRefreshUI ) {\n\t\t// #2644: Note: This code fixes a bug where the edit screen is not opened on first try, but is on second. Likely due to the TTPromise and potential race conditions. See commit history for details.\n\t\tTTPromise.add( 'Schedule', 'init' );\n\t\tthis.setCurrentEditViewState( 'edit' );\n\t\tthis.openEditView();\n\n\t\trecord_id = this.getEditSelectedRecordId( record_id );\n\t\tif ( Global.isFalseOrNull( record_id ) ) {\n\t\t\tthis.openEditView();\n\t\t\tvar select_shift = Global.clone( this.select_all_shifts_array[0] );\n\t\t\tselect_shift = this.resetSomeFields( select_shift );\n\t\t\tthis.current_edit_record = select_shift;\n\t\t\tthis.current_edit_record.user_ids = [this.current_edit_record.user_id]; //#2610 - ensure that edit record is properly formed in respect to user_ids\n\t\t\tthis.is_viewing = false;\n\n\t\t\tvar $this = this;\n\t\t\tTTPromise.wait( 'Schedule', 'init', function() {\n\t\t\t\t$this.initEditView();\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\t\tthis.setCurrentSelectedRecord( record_id );\n\n\t\tvar filter = this.getAPIFilters();\n\n\t\treturn this.doEditAPICall( filter );\n\t}\n\n\tdoDeleteAPICall( remove_ids, callback ) {\n\t\tif ( !callback ) {\n\t\t\tcallback = {\n\t\t\t\tonResult: function( result ) {\n\t\t\t\t\tProgressBar.closeOverlay();\n\t\t\t\t\tdoNext.call( this, result );\n\t\t\t\t\tif ( result.isValid() ) {\n\t\t\t\t\t\tthis.onDeleteDone( result );\n\t\t\t\t\t\tif ( this.edit_view ) {\n\t\t\t\t\t\t\tthis.removeEditView();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.setCurrentEditViewState( '' );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tTAlertManager.showErrorAlert( result );\n\t\t\t\t\t}\n\t\t\t\t}.bind( this )\n\t\t\t};\n\t\t}\n\t\tif ( remove_ids && remove_ids.length > 0 ) {\n\t\t\treturn this.api['delete' + this.api.key_name]( remove_ids, callback );\n\t\t} else {\n\t\t\tdoNext.call( this, {\n\t\t\t\tisValid: function() {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\tfunction doNext( result ) {\n\t\t\t//Issue #3034 - TypeError: Cannot read properties of undefined (reading 'id').\n\t\t\t//Because deleting recurring schedules does not go through the normal pathway, we need to reset state\n\t\t\t//so that Vue does not decide we on an edit view and retrieve the wrong context menu array.\n\t\t\t//Otherwise JavaScript exceptions may trigger when reading an empty context menu array during other actions.\n\t\t\tif ( this.edit_view ) {\n\t\t\t\tthis.removeEditView();\n\t\t\t} else {\n\t\t\t\tthis.setCurrentEditViewState( '' );\n\t\t\t}\n\n\t\t\t//Since we can't delete recurring schedules, we need to override them as absent without a absence policy instead.\n\t\t\tvar recurring_delete_shifts_array = [];\n\t\t\tfor ( var i = 0; i < this.select_cells_Array.length; i++ ) {\n\t\t\t\tif ( this.select_cells_Array[i].shift ) {\n\t\t\t\t\tthis.select_cells_Array[i].shift.status_id = '20'; //Set shift to absent.\n\t\t\t\t\trecurring_delete_shifts_array.push( this.select_cells_Array[i].shift );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( recurring_delete_shifts_array.length > 0 ) {\n\t\t\t\tthis.api.setSchedule( recurring_delete_shifts_array, {\n\t\t\t\t\tonResult: function() {\n\t\t\t\t\t\tthis.search();\n\t\t\t\t\t}.bind( this )\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tif ( result.isValid() ) {\n\t\t\t\t\tthis.search();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tgetCustomContextMenuModel() {\n\t\tvar context_menu_model = {\n\t\t\tgroups: {\n\t\t\t\tdrag_and_drop: {\n\t\t\t\t\tlabel: $.i18n._( 'Drag & Drop' ),\n\t\t\t\t\tid: this.viewId + 'drag_and_drop'\n\t\t\t\t}\n\t\t\t},\n\t\t\texclude: [\n\t\t\t\t'export_excel',\n\t\t\t\t'save_and_next',\n\t\t\t\t'delete_and_next',\n\t\t\t\t'copy'\n\t\t\t],\n\t\t\tinclude: [\n\t\t\t\t// Note Drag&Drop icons will be conditionally prepended here later in code for list view modes.\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'Jump To' ),\n\t\t\t\t\tid: 'jump_to_header',\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\taction_group: 'jump_to',\n\t\t\t\t\taction_group_header: true,\n\t\t\t\t\tpermission_result: false, // to hide it in legacy context menu and avoid errors in legacy parsers.\n\t\t\t\t\tsort_order: 9030\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'TimeSheet' ),\n\t\t\t\t\tid: 'timesheet',\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\taction_group: 'jump_to',\n\t\t\t\t\tgroup: 'navigation',\n\t\t\t\t\tpermission_result: true,\n\t\t\t\t\tsort_order: 9030\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'Edit Employee' ),\n\t\t\t\t\tid: 'edit_employee',\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\taction_group: 'jump_to',\n\t\t\t\t\tgroup: 'navigation',\n\t\t\t\t\tpermission_result: true,\n\t\t\t\t\tsort_order: 9030\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'Import' ),\n\t\t\t\t\tid: 'import_icon',\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\taction_group: 'import_export',\n\t\t\t\t\tgroup: 'other',\n\t\t\t\t\tvue_icon: 'tticon tticon-file_download_black_24dp',\n\t\t\t\t\tpermission_result: PermissionManager.checkTopLevelPermission( 'ImportCSVSchedule' ),\n\t\t\t\t\tsort_order: 9025\n\t\t\t\t}\n\t\t\t]\n\t\t};\n\n\t\t// Edit Views\n\n\t\tcontext_menu_model.include.push( {\n\t\t\tlabel: $.i18n._( 'Print' ),\n\t\t\tid: 'print',\n\t\t\taction_group_header: true,\n\t\t\taction_group: 'print',\n\t\t\tmenu_align: 'right',\n\t\t\tsort_order: 9020,\n\t\t\t} );\n\n\t\tcontext_menu_model.include.push( {\n\t\t\tlabel: $.i18n._( 'Individual Schedules' ),\n\t\t\tid: 'pdf_schedule',\n\t\t\taction_group: 'print',\n\t\t\tmenu_align: 'right',\n\t\t\tsort_order: 9020\n\t\t} );\n\n\t\tcontext_menu_model.include.push(\n\t\t\t{\n\t\t\t\tlabel: $.i18n._( 'Find Available' ),\n\t\t\t\tid: 'find_available',\n\t\t\t\tvue_icon: 'tticon tticon-search_black_24dp',\n\t\t\t\tmenu_align: 'right',\n\t\t\t\tpermission_result: true,\n\t\t\t\tshow_on_right_click: true,\n\t\t\t\tsort_order: 7000\n\t\t\t}\n\t\t);\n\n\t\tif ( PermissionManager.validate( 'request', 'add' ) ) {\n\t\t\tcontext_menu_model.include.push( {\n\t\t\t\tlabel: $.i18n._( 'Add Request' ),\n\t\t\t\tid: 'AddRequest',\n\t\t\t\tvue_icon: 'tticon tticon-post_add_black_24dp',\n\t\t\t\tmenu_align: 'right',\n\t\t\t\tpermission_result: true,\n\t\t\t\tpermission: true,\n\t\t\t\tshow_on_right_click: true,\n\t\t\t\tsort_order: 7010\n\t\t\t} );\n\t\t}\n\n\t\tif ( !this.is_edit && !this.is_mass_editing && !this.is_viewing ) {\n\t\t\tcontext_menu_model.include.unshift( // Add to begginning of array to preserve item order.\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'Drag & Drop: Move' ),\n\t\t\t\t\tid: 'move',\n\t\t\t\t\taction_group: 'drag_and_drop',\n\t\t\t\t\tmulti_select_group: 1,\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\tgroup: 'drag_and_drop',\n\t\t\t\t\tpermission_result: true,\n\t\t\t\t\tsort_order: 8050\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'Drag & Drop: Copy' ),\n\t\t\t\t\tid: 'drag_copy',\n\t\t\t\t\taction_group: 'drag_and_drop',\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\tmulti_select_group: 1,\n\t\t\t\t\tgroup: 'drag_and_drop',\n\t\t\t\t\tpermission_result: true,\n\t\t\t\t\tsort_order: 8060\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'Drag & Drop: Swap' ),\n\t\t\t\t\tid: 'swap',\n\t\t\t\t\taction_group: 'drag_and_drop',\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\tmulti_select_group: 1,\n\t\t\t\t\tgroup: 'drag_and_drop',\n\t\t\t\t\tpermission_result: true,\n\t\t\t\t\tsort_order: 8070\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: 'separator_drag_and_drop_1',\n\t\t\t\t\taction_group: 'drag_and_drop',\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\tseparator: true,\n\t\t\t\t\tsort_order: 8080\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'Drag & Drop: Overwrite' ),\n\t\t\t\t\tid: 'override',\n\t\t\t\t\taction_group: 'drag_and_drop',\n\t\t\t\t\tmulti_select_group: 2,\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\tgroup: 'drag_and_drop',\n\t\t\t\t\tpermission_result: true,\n\t\t\t\t\tsort_order: 8090\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tif ( Global.getProductEdition() >= 15 ) {\n\t\t\t\tcontext_menu_model.include.unshift(\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: $.i18n._( 'Drag & Drop: Notify Employee' ),\n\t\t\t\t\t\tid: 'notify_user_schedule_change',\n\t\t\t\t\t\taction_group: 'drag_and_drop',\n\t\t\t\t\t\tmulti_select_group: 3,\n\t\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\t\tgroup: 'drag_and_drop',\n\t\t\t\t\t\tpermission_result: true,\n\t\t\t\t\t\tsort_order: 8100\n\t\t\t\t\t} );\n\t\t\t}\n\n\t\t}\n\n\t\tif ( PermissionManager.validate( 'schedule', 'view' ) || PermissionManager.validate( 'schedule', 'view_child' ) ) {\n\t\t\tcontext_menu_model.include.push(\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'Group - Combined' ),\n\t\t\t\t\tid: 'pdf_schedule_group_combined',\n\t\t\t\t\taction_group: 'print',\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\tsort_order: 9020,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'Group - Separated' ),\n\t\t\t\t\tid: 'pdf_schedule_group',\n\t\t\t\t\taction_group: 'print',\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\tsort_order: 9020,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'Group - Separated (Page Breaks)' ),\n\t\t\t\t\tid: 'pdf_schedule_group_pagebreak',\n\t\t\t\t\taction_group: 'print',\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\tsort_order: 9020,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tcontext_menu_model.include.push(\n\t\t);\n\n\t\tif ( ( PermissionManager.validate( 'punch', 'add' ) && ( PermissionManager.validate( 'punch', 'edit' ) || PermissionManager.validate( 'punch', 'edit_child' ) ) ) ) {\n\t\t\tcontext_menu_model.include.push(\n\t\t\t\t{\n\t\t\t\t\tlabel: '', //Empty label. vue_icon is displayed instead of text.\n\t\t\t\t\tid: 'other_header',\n\t\t\t\t\taction_group: 'other',\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\taction_group_header: true,\n\t\t\t\t\tvue_icon: 'tticon tticon-more_vert_black_24dp',\n\t\t\t\t\tsort_order: 9050\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: $.i18n._( 'Auto Punch' ),\n\t\t\t\t\tid: 'AutoPunch',\n\t\t\t\t\taction_group: 'other',\n\t\t\t\t\tmenu_align: 'right',\n\t\t\t\t\tgroup: 'other',\n\t\t\t\t\tpermission_result: true,\n\t\t\t\t\tpermission: true,\n\t\t\t\t\tshow_on_right_click: true,\n\t\t\t\t\tsort_order: 9050\n\t\t\t\t} );\n\t\t}\n\n\t\treturn context_menu_model;\n\t}\n\n\tparseCustomContextModelForEditViews( context_menu_model ) {\n\n\t\tcontext_menu_model = super.parseCustomContextModelForEditViews( context_menu_model );\n\n\t\tif ( this.determineContextMenuMountAttributes().menu_type === 'editview_contextmenu' ) {\n\t\t\tcontext_menu_model.exclude.push(\n\t\t\t\t'move',\n\t\t\t\t'drag_copy',\n\t\t\t\t'swap',\n\t\t\t\t'override',\n\t\t\t\t'notify_user_schedule_change',\n\t\t\t\t'print',\n\t\t\t\t'pdf_schedule',\n\t\t\t\t'pdf_schedule_group_combined',\n\t\t\t\t'pdf_schedule_group',\n\t\t\t\t'pdf_schedule_group_pagebreak'\n\t\t\t);\n\t\t}\n\n\t\treturn context_menu_model;\n\t}\n\n\tonReportMenuClick( id ) {\n\t\tthis.onNavigationClick( id );\n\t}\n\n\tonCustomContextClick( id ) {\n\t\tswitch ( id ) {\n\t\t\tcase 'move':\n\t\t\tcase 'drag_copy':\n\t\t\tcase 'swap':\n\t\t\t\tthis.setMoveOrDropMode( id );\n\t\t\t\tbreak;\n\t\t\tcase 'override':\n\t\t\t\tthis.onOverrideClick();\n\t\t\t\tbreak;\n\t\t\tcase 'notify_user_schedule_change':\n\t\t\t\tthis.onNotifyUserScheduleChangeClick();\n\t\t\t\tbreak;\n\t\t\tcase 'edit_employee':\n\t\t\tcase 'timesheet':\n\t\t\t\tthis.onNavigationClick( id );\n\t\t\t\tbreak;\n\t\t\tcase 'find_available':\n\t\t\t\tthis.onFindAvailableClick( id );\n\t\t\t\tbreak;\n\t\t\tcase 'AutoPunch':\n\t\t\t\tthis.addPunchesFromScheduledShifts( id );\n\t\t\t\tbreak;\n\t\t\tcase 'AddRequest':\n\t\t\t\tthis.addRequestFromScheduledShifts( id );\n\t\t\t\tbreak;\n\t\t\tcase 'import_icon':\n\t\t\t\tthis.onImportClick();\n\t\t\t\tbreak;\n\t\t\tcase 'pdf_schedule':\n\t\t\tcase 'pdf_schedule_group':\n\t\t\tcase 'pdf_schedule_group_combined':\n\t\t\tcase 'pdf_schedule_group_pagebreak':\n\t\t\t\tthis.onReportMenuClick( id );\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\taddRequestFromScheduledShifts( id ) {\n\t\tif ( Global.getProductEdition() <= 10 ) {\n\t\t\tTAlertManager.showAlert( Global.getUpgradeMessage() );\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( shift_array && shift_array.length <= 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tvar shift_array = this.select_cells_Array;\n\t\tvar first_shift = ( shift_array[0] ) ? shift_array[0] : null;\n\t\tvar last_shift = ( shift_array[shift_array.length - 1] ) ? shift_array[shift_array.length - 1] : null;\n\t\tif ( !first_shift || !last_shift ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tvar request = this.api.getScheduleDefaultData( this.select_cells_Array, { async: false } ).getResult();\n\t\tvar shift_status = 10;\n\t\tvar type_id = 40;\n\n\t\tvar mon = false, tue = false, wed = false, thu = false, fri = false, sat = false, sun = false;\n\n\t\tfor ( var w in shift_array ) {\n\t\t\tif ( first_shift.shift == undefined && shift_array[w].shift ) {\n\t\t\t\t//Set the archetype to the first day with a shift.\n\t\t\t\tfirst_shift = shift_array[w];\n\t\t\t}\n\n\t\t\t//Set selected days of the week.\n\t\t\tvar d = new Date( shift_array[w].time_stamp_num );\n\t\t\tswitch ( d.getDay() ) {\n\t\t\t\tcase 0:\n\t\t\t\t\tsun = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 1:\n\t\t\t\t\tmon = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\ttue = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\twed = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 4:\n\t\t\t\t\tthu = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 5:\n\t\t\t\t\tfri = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 6:\n\t\t\t\t\tsat = true;\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// delete ( d ); #2792 In the new ES6 conversion, delete is causing errors, but technically should never have worked anyway. Potentially never did anything. Could maybe delete. Try null first.\n\t\t\td = null;\n\t\t}\n\n\t\trequest.mon = mon;\n\t\trequest.tue = tue;\n\t\trequest.wed = wed;\n\t\trequest.thu = thu;\n\t\trequest.fri = fri;\n\t\trequest.sat = sat;\n\t\trequest.sun = sun;\n\n\t\tif ( first_shift && first_shift.date ) {\n\t\t\tvar start_date = first_shift.date;\n\t\t}\n\n\t\tif ( last_shift && last_shift.date ) {\n\t\t\tvar end_date = last_shift.date;\n\t\t}\n\n\t\tif ( first_shift ) {\n\t\t\tif ( first_shift.shift && first_shift.shift.status_id == 10 && first_shift.shift.user_id && first_shift.shift.user_id != TTUUID.zero_id ) {\n\t\t\t\tshift_status = 20;\n\t\t\t\ttype_id = 30;\n\t\t\t}\n\t\t}\n\n\t\trequest.status_id = shift_status;\n\t\trequest.type_id = type_id;\n\t\trequest.user_id = LocalCacheData.getLoginUser().id;\n\t\trequest.full_name = LocalCacheData.getLoginUser().full_name;\n\t\tif ( start_date ) {\n\t\t\trequest.date_stamp = start_date;\n\t\t\trequest.start_date = start_date;\n\t\t}\n\n\t\tif ( end_date ) {\n\t\t\trequest.end_date = end_date;\n\t\t}\n\n\t\tif ( first_shift.start_time ) {\n\t\t\trequest.start_time = first_shift.start_time;\n\t\t}\n\n\t\tif ( first_shift.end_time ) {\n\t\t\trequest.end_time = first_shift.end_time;\n\t\t}\n\n\t\tif ( first_shift.branch_id ) {\n\t\t\trequest.branch_id = first_shift.branch_id;\n\t\t}\n\n\t\tif ( first_shift.department_id ) {\n\t\t\trequest.department_id = first_shift.department_id;\n\t\t}\n\n\t\tif ( first_shift.job_id ) {\n\t\t\trequest.job_id = first_shift.job_id;\n\t\t}\n\n\t\tif ( first_shift.job_item_id ) {\n\t\t\trequest.job_item_id = first_shift.job_item_id;\n\t\t}\n\n\t\tif ( first_shift.punch_tag_id ) {\n\t\t\trequest.punch_tag_id = first_shift.punch_tag_id;\n\t\t}\n\n\t\tIndexViewController.openEditView( this, 'Request', request, 'openAddView' );\n\t}\n\n\taddPunchesFromScheduledShifts( id ) {\n\n\t\tif ( Global.getProductEdition() <= 10 ) {\n\t\t\tTAlertManager.showAlert( Global.getUpgradeMessage() );\n\t\t\treturn false;\n\t\t}\n\t\tif ( this.select_cells_Array == undefined || this.select_cells_Array.length < 1 ) {\n\t\t\tTAlertManager.showAlert( 'No schedules selected. You can\\'t autopunch no schedules.' );\n\t\t\treturn false;\n\t\t}\n\n\t\tvar shift_array = this.select_cells_Array;\n\t\tvar schedules = {};\n\t\tvar users = [];\n\t\tschedules.schedule = [];\n\t\tschedules.recurring = [];\n\n\t\tfor ( var i = 0; i < shift_array.length; i++ ) {\n\t\t\tif ( shift_array[i].shift != undefined ) { //avoid when no user scheduled.\n\t\t\t\tif ( shift_array[i].shift.id\n\t\t\t\t\t&& shift_array[i].shift.id != TTUUID.zero_id\n\t\t\t\t\t&& shift_array[i].shift.id != TTUUID.not_exist_id\n\t\t\t\t) {\n\t\t\t\t\tschedules.schedule.push( shift_array[i].shift.id );\n\t\t\t\t} else if ( shift_array[i].shift.recurring_schedule_id\n\t\t\t\t\t&& shift_array[i].shift.recurring_schedule_id != TTUUID.not_exist_id\n\t\t\t\t) {\n\t\t\t\t\tschedules.recurring.push( shift_array[i].shift.recurring_schedule_id );\n\t\t\t\t}\n\t\t\t\tusers.push( shift_array[i].shift.user_id );\n\t\t\t}\n\t\t}\n\n\t\tthis.api.addPunchesFromScheduledShifts( schedules, {\n\t\t\tonResult: function( result ) {\n\t\t\t\tif ( result.isValid() ) {\n\t\t\t\t\tUserGenericStatusWindowController.open( result.getAttributeInAPIDetails( 'user_generic_status_batch_id' ), [LocalCacheData.getLoginUser().id] );\n\t\t\t\t} else {\n\t\t\t\t\tTAlertManager.showErrorAlert( result );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\tgetSelectEmployee() {\n\t\tvar shift = this.select_cells_Array[0];\n\n\t\t//Error: Uncaught TypeError: Cannot read property 'user_id' of undefined in /interface/html5/#!m=Schedule&date=20141117&mode=week&a=new&tab=Schedule line 1116\n\t\tif ( !shift || shift.user_id == TTUUID.zero_id ) {\n\t\t\tshift = { user_id: LocalCacheData.getLoginUser().id };\n\t\t} else if ( shift.user_id && shift.user_id != TTUUID.zero_id ) {\n\t\t\tshift = { user_id: shift.user_id };\n\t\t}\n\n\t\tif ( this.edit_view && this.current_edit_record ) {\n\t\t\tshift.user_id = this.current_edit_record.user_id;\n\t\t}\n\n\t\treturn shift.user_id;\n\t}\n\n\tonFindAvailableClick() {\n\t\tif ( Global.getProductEdition() <= 10 ) {\n\t\t\tTAlertManager.showAlert( Global.getUpgradeMessage() );\n\t\t\treturn;\n\t\t}\n\n\t\tvar $this = this;\n\t\tvar args = {};\n\t\targs.selected = [];\n\t\tvar len = this.select_all_shifts_array.length;\n\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\tvar item = this.select_all_shifts_array[i];\n\t\t\targs.selected.push( item );\n\t\t}\n\n\t\tLocalCacheData.extra_filter_for_next_open_view = {};\n\t\tLocalCacheData.extra_filter_for_next_open_view.filter_data = args;\n\n\t\tIndexViewController.openWizard( 'FindAvailableWizard', null, function( employee_id, notify_users ) {\n\t\t\t$this.onFindAvailableClose( employee_id, args.selected, notify_users );\n\t\t} );\n\t}\n\n\tonFindAvailableClose( employee_id, shift_array, notify_users ) {\n\t\tvar $this = this;\n\t\tvar len = shift_array.length;\n\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\tvar item = shift_array[i];\n\t\t\titem.user_id = employee_id;\n\t\t\titem.replaced_id = item.id;\n\t\t\titem.notify_user_schedule_change = notify_users;\n\t\t\tdelete item.id;\n\t\t}\n\n\t\tthis.api.setSchedule( shift_array, {\n\t\t\tonResult: function( result ) {\n\t\t\t\tif ( !result.isValid() ) {\n\t\t\t\t\tTAlertManager.showErrorAlert( result );\n\t\t\t\t}\n\t\t\t\t$this.search();\n\t\t\t}\n\t\t} );\n\t}\n\n\tonImportClick() {\n\t\tvar $this = this;\n\t\tIndexViewController.openWizard( 'ImportCSVWizard', 'Schedule', function() {\n\t\t\t$this.search();\n\t\t} );\n\t}\n\n\tonNavigationClick( iconName ) {\n\n\t\tif ( !this.checkScheduleData() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar post_data;\n\n\t\tswitch ( iconName ) {\n\t\t\tcase 'edit_employee':\n\t\t\t\tIndexViewController.openEditView( this, 'Employee', this.getSelectEmployee() );\n\t\t\t\tbreak;\n\t\t\tcase 'timesheet':\n\t\t\t\tvar filter = { filter_data: {} };\n\t\t\t\tfilter.user_id = this.getSelectEmployee();\n\n\t\t\t\tif ( this.edit_view ) {\n\t\t\t\t\tfilter.base_date = this.current_edit_record.date_stamp;\n\t\t\t\t} else {\n\t\t\t\t\tfilter.base_date = this.start_date_picker.getValue();\n\t\t\t\t}\n\t\t\t\tGlobal.addViewTab( this.viewId, $.i18n._( 'Schedules' ), window.location.href );\n\t\t\t\tIndexViewController.goToView( 'TimeSheet', filter );\n\n\t\t\t\tbreak;\n\t\t\tcase 'pdf_schedule':\n\t\t\tcase 'pdf_schedule_group_combined':\n\t\t\tcase 'pdf_schedule_group':\n\t\t\tcase 'pdf_schedule_group_pagebreak':\n\t\t\t\tfilter = Global.convertLayoutFilterToAPIFilter( this.select_layout );\n\n\t\t\t\tif ( !filter ) {\n\t\t\t\t\tfilter = {};\n\t\t\t\t}\n\t\t\t\tfilter.time_period = {};\n\t\t\t\tfilter.time_period.time_period = 'custom_date';\n\t\t\t\tfilter.time_period.start_date = this.full_schedule_data.schedule_dates.start_display_date;\n\t\t\t\tfilter.time_period.end_date = this.full_schedule_data.schedule_dates.end_display_date;\n\n\t\t\t\tif ( filter.time_period.start_date == filter.time_period.end_date ) {\n\t\t\t\t\tvar new_end_date = new Date( new Date( this.start_date.getTime() ).setDate( this.start_date.getDate() + 6 ) );\n\t\t\t\t\tfilter.time_period.end_date = new_end_date.format();\n\t\t\t\t}\n\n\t\t\t\tpost_data = { 0: filter, 1: iconName };\n\t\t\t\tthis.doFormIFrameCall( post_data );\n\t\t\t\tbreak;\n\n\t\t}\n\t}\n\n\tdoFormIFrameCall( postData ) {\n\t\tGlobal.APIFileDownload( 'APIScheduleSummaryReport', 'getScheduleSummaryReport', postData );\n\t}\n\n\tsetScheduleGridDragAble() {\n\t\tvar mode = this.getMode();\n\n\t\tswitch ( mode ) {\n\t\t\tcase ScheduleViewControllerMode.DAY:\n\t\t\t\tthis.setWeekModeDragAble();\n\t\t\t\tbreak;\n\t\t\tcase ScheduleViewControllerMode.WEEK:\n\t\t\t\tthis.setWeekModeDragAble();\n\t\t\t\tbreak;\n\t\t\tcase ScheduleViewControllerMode.MONTH:\n\t\t\t\tthis.setWeekModeDragAble();\n\t\t\t\tbreak;\n\t\t\tcase ScheduleViewControllerMode.YEAR:\n\t\t\t\tthis.setWeekModeDragAble();\n\t\t\t\tbreak;\n\t\t}\n\n\t\tvar $this = this;\n\t\t//set bottom drag to scroll area\n\t\t$( '.schedule-grid-div' ).off( 'dragover' ).on( 'dragover', function( e ) {\n\n\t\t\tvar grid_div = $( '.schedule-grid-div' );\n\t\t\tvar grid_pos = grid_div.offset().top;\n\n\t\t\tvar mouse_y = e.originalEvent.clientY;\n\t\t\tvar grid_height = grid_div.height();\n\n\t\t\tif ( mouse_y > ( grid_pos + grid_height ) ) {\n\t\t\t\t$this.scroll_unit = mouse_y - ( grid_pos + grid_height );\n\t\t\t\tif ( !$this.scroll_interval ) {\n\t\t\t\t\t$this.scroll_interval = setInterval( function() {\n\t\t\t\t\t\tvar div = $this.grid.grid.parent().parent();\n\t\t\t\t\t\tdiv.scrollTop( div.scrollTop() + $this.scroll_unit );\n\t\t\t\t\t}, 50 );\n\t\t\t\t}\n\t\t\t} else if ( mouse_y < ( grid_pos + 15 ) && mouse_y > ( grid_pos - 50 ) ) {\n\t\t\t\t$this.scroll_unit = ( grid_pos + 15 ) - mouse_y;\n\t\t\t\tif ( !$this.scroll_interval ) {\n\t\t\t\t\t$this.scroll_interval = setInterval( function() {\n\t\t\t\t\t\tvar div = $this.grid.grid.parent().parent();\n\t\t\t\t\t\tdiv.scrollTop( div.scrollTop() - $this.scroll_unit );\n\t\t\t\t\t}, 50 );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tclearInterval( $this.scroll_interval );\n\t\t\t\t$this.scroll_interval = null;\n\t\t\t}\n\n\t\t} );\n\n\t\t$( '.schedule-grid-div' ).off( 'dragend' ).on( 'dragend', function( e ) {\n\n\t\t\tif ( $this.scroll_interval ) {\n\t\t\t\tclearInterval( $this.scroll_interval );\n\t\t\t\t$this.scroll_interval = null;\n\t\t\t}\n\n\t\t} );\n\n\t\t$( '.schedule-grid-div td' ).unbind( 'dragenter' ).bind( 'dragenter', function( event ) {\n\t\t\tevent.preventDefault();\n\t\t\t$( '.schedule-drag-over' ).removeClass( 'schedule-drag-over' );\n\n\t\t\tif ( $( this ).attr( 'draggable' ) || $( this ).parents( 'td' ).attr( 'draggable' ) ) {\n\t\t\t\t$( this ).addClass( 'schedule-drag-over' );\n\t\t\t}\n\t\t} );\n\t}\n\n\tsetWeekModeDragAble() {\n\t\tvar $this = this;\n\t\tvar position = 0;\n\n\t\tvar cells = this.grid.grid.find( '.date-column' ).parents( 'td' );\n\n\t\tcells.attr( 'draggable', true );\n\n\t\tcells.unbind( 'dragstart' ).bind( 'dragstart', function( event ) {\n\t\t\tvar td = event.target;\n\t\t\tif ( $this.select_all_shifts_array.length < 1 || !$( td ).hasClass( 'ui-state-highlight' ) || !$this.select_drag_menu_id ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tvar container = $( '
' );\n\n\t\t\tvar len = $this.select_all_shifts_array.length;\n\n\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\tvar shift = $this.select_all_shifts_array[i];\n\t\t\t\tvar span = $( '' );\n\n\t\t\t\tif ( shift.status_id == 20 ) {\n\t\t\t\t\tspan.text( $this.getAbsenceCellValue( shift ) );\n\t\t\t\t} else {\n\t\t\t\t\tspan.text( shift.start_time + ' - ' + shift.end_time );\n\t\t\t\t}\n\n\t\t\t\tcontainer.append( span );\n\t\t\t}\n\n\t\t\t$( 'body' ).find( '.drag-holder-div' ).remove();\n\n\t\t\t$( 'body' ).append( container );\n\n\t\t\tevent.originalEvent.dataTransfer.setData( 'Text', 'schedule' );//JUST ELEMENT references is ok here NO ID\n\n\t\t\tif ( event.originalEvent.dataTransfer.setDragImage ) {\n\t\t\t\tevent.originalEvent.dataTransfer.setDragImage( container[0], 0, 0 );\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} );\n\n\t\tcells.unbind( 'drop' ).bind( 'drop', function( event ) {\n\t\t\tevent.preventDefault();\n\t\t\tif ( event.stopPropagation ) {\n\t\t\t\tevent.stopPropagation(); // stops the browser from redirecting.\n\t\t\t}\n\n\t\t\t$( '.drag-holder-div' ).remove();\n\n\t\t\tvar target_empty_row = false;\n\t\t\tvar delete_old_items = false;\n\n\t\t\tvar new_shifts_array = [];\n\t\t\tvar delete_shifts_array = [];\n\t\t\tvar recurring_delete_shifts_array = [];\n\n\t\t\tvar target_cell = event.currentTarget;\n\n\t\t\tvar selected_shifts = $this.select_cellls_and_shifts_array;\n\t\t\t//Error: Uncaught TypeError: Cannot read property 'length' of undefined in interface/html5/#!m=Schedule&date=20151213&mode=week line 1420\n\t\t\tif ( !selected_shifts ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar first_target_row_index;\n\t\t\tvar first_target_cell_index;\n\n\t\t\tfirst_target_row_index = target_cell.parentNode.rowIndex - 1;\n\t\t\tfirst_target_cell_index = target_cell.cellIndex;\n\n\t\t\tvar row_index_offset = 0;\n\t\t\tvar cell_index_offset = 0;\n\n\t\t\tvar first_selected_row_index;\n\t\t\tvar first_selected_cell_index;\n\n\t\t\tvar colModel = $this.grid.grid.getGridParam( 'colModel' );\n\n\t\t\tif ( $this.select_drag_menu_id === 'move' ) {\n\t\t\t\tdelete_old_items = true;\n\t\t\t} else {\n\t\t\t\tdelete_old_items = false;\n\t\t\t}\n\n\t\t\tvar len = selected_shifts.length;\n\n\t\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\t\tvar cell = selected_shifts[i];\n\t\t\t\tvar shift;\n\n\t\t\t\tif ( i === 0 ) {\n\t\t\t\t\tfirst_selected_row_index = cell.row_id;\n\t\t\t\t\tfirst_selected_cell_index = cell.cell_index;\n\t\t\t\t} else {\n\t\t\t\t\tif ( !target_empty_row ) {\n\t\t\t\t\t\trow_index_offset = cell.row_id - first_selected_row_index;\n\t\t\t\t\t}\n\t\t\t\t\tcell_index_offset = cell.cell_index - first_selected_cell_index;\n\t\t\t\t}\n\n\t\t\t\tif ( cell.shift ) {\n\t\t\t\t\tshift = cell.shift;\n\t\t\t\t} else {\n\t\t\t\t\tvar target_row_index = first_target_row_index + row_index_offset;\n\t\t\t\t\tvar target_cell_index = first_target_cell_index + cell_index_offset;\n\t\t\t\t\tif ( target_cell_index > colModel.length - 1 ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tvar target_data = $this.getDataByCellIndex( target_row_index, target_cell_index );\n\t\t\t\t\tvar target_row = $this.schedule_source[target_row_index];\n\n\t\t\t\t\tif ( !target_row || !target_row.user_id ) {\n\t\t\t\t\t\ttarget_empty_row = true;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tshift.branch_id = shift.branch ? shift.branch_id : '';\n\t\t\t\tshift.department_id = shift.department ? shift.department_id : '';\n\t\t\t\tshift.job_id = shift.job_id ? shift.job_id : '';\n\t\t\t\tshift.job_item_id = shift.job_item_id ? shift.job_item_id : '';\n\t\t\t\tshift.punch_tag_id = shift.punch_tag_id ? shift.punch_tag_id : '';\n\n\t\t\t\ttarget_row_index = first_target_row_index + row_index_offset;\n\t\t\t\ttarget_cell_index = first_target_cell_index + cell_index_offset;\n\n\t\t\t\tif ( target_cell_index > colModel.length - 1 ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\ttarget_data = $this.getDataByCellIndex( target_row_index, target_cell_index );\n\t\t\t\ttarget_row = $this.schedule_source[target_row_index];\n\n\t\t\t\tif ( !target_row || !target_row.user_id ) {\n\t\t\t\t\ttarget_empty_row = true;\n\t\t\t\t}\n\n\t\t\t\tif ( target_row ) {\n\t\t\t\t\tif ( target_row.type === ScheduleViewControllerRowType.DATE ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( !target_data || target_empty_row ) {\n\t\t\t\t\t\tvar date_stamp;\n\n\t\t\t\t\t\t//Error: TypeError: colModel[target_cell_index] is undefined in /interface/html5/framework/jquery.min.js?v=8.0.0-20141230-153210 line 2 > eval line 1443\n\t\t\t\t\t\tif ( colModel ) {\n\t\t\t\t\t\t\tif ( $this.getMode() === ScheduleViewControllerMode.MONTH ) {\n\t\t\t\t\t\t\t\t//Error: \"TypeError: Cannot read property 'format' of null\"\n\t\t\t\t\t\t\t\t// when user drags a scedule to a non-date grid element we need to quietly fail\n\t\t\t\t\t\t\t\tvar related_date = $this.getCellRelatedDate( target_row_index, colModel, target_cell_index, colModel[target_cell_index].name );\n\t\t\t\t\t\t\t\tif ( related_date ) {\n\t\t\t\t\t\t\t\t\tdate_stamp = related_date.format();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdate_stamp = Global.strToDate( colModel[target_cell_index].name, $this.full_format ).format();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( !date_stamp || date_stamp == 'Invalid date' ) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttarget_data = {};\n\n\t\t\t\t\t\tif ( !target_row.user_id ) { //Only happens in month mode;\n\t\t\t\t\t\t\ttarget_data = shift;\n\t\t\t\t\t\t\ttarget_data.date_stamp = date_stamp;\n\t\t\t\t\t\t\ttarget_data.start_date_stamp = date_stamp;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttarget_data.user_id = target_row.user_id;\n\t\t\t\t\t\t\ttarget_data.branch = target_row.branch;\n\t\t\t\t\t\t\ttarget_data.branch_id = target_row.branch ? target_row.branch_id : '';\n\t\t\t\t\t\t\ttarget_data.schedule_policy_id = target_row.schedule_policy_id;\n\t\t\t\t\t\t\ttarget_data.department_id = target_row.department ? target_row.department_id : '';\n\t\t\t\t\t\t\ttarget_data.department = target_row.department;\n\t\t\t\t\t\t\ttarget_data.job_id = target_row.job_id ? target_row.job_id : '';\n\t\t\t\t\t\t\ttarget_data.job = target_row.job;\n\t\t\t\t\t\t\ttarget_data.job_item_id = target_row.job_item_id ? target_row.job_item_id : '';\n\t\t\t\t\t\t\ttarget_data.punch_tag_id = target_row.punch_tag_id ? target_row.punch_tag_id : '';\n\t\t\t\t\t\t\ttarget_data.job_item = target_row.job_item;\n\t\t\t\t\t\t\ttarget_data.date_stamp = date_stamp;\n\t\t\t\t\t\t\ttarget_data.start_date_stamp = date_stamp;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tvar new_shift = Global.clone( shift );\n\n\t\t\t\tif ( $this.select_drag_menu_id !== 'swap' ) {\n\t\t\t\t\tnew_shift.id = '';\n\t\t\t\t\tnew_shift.date_stamp = target_data.date_stamp;\n\t\t\t\t\tnew_shift.start_date_stamp = target_data.start_date_stamp;\n\t\t\t\t\tnew_shift.user_id = target_data.user_id;\n\t\t\t\t\t// When dragging an open shift to an empty cell in a user row with no branch column visible, the branch id value now defaults to user default branch id\n\t\t\t\t\tnew_shift.branch_id = target_data.branch ? target_data.branch_id : TTUUID.not_exist_id;\n\t\t\t\t\tnew_shift.department_id = target_data.department ? target_data.department_id : TTUUID.not_exist_id;\n\t\t\t\t\tnew_shift.job_id = target_data.job_id ? target_data.job_id : TTUUID.not_exist_id;\n\t\t\t\t\tnew_shift.job_item_id = target_data.job_item_id ? target_data.job_item_id : TTUUID.not_exist_id;\n\t\t\t\t\tnew_shift.punch_tag_id = target_data.punch_tag_id ? target_data.punch_tag_id : TTUUID.not_exist_id;\n\n\t\t\t\t\tif ( $this.is_override ) {\n\t\t\t\t\t\tnew_shift.overwrite = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( $this.notify_user_schedule_change ) {\n\t\t\t\t\t\tnew_shift.notify_user_schedule_change = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tnew_shifts_array.push( new_shift );\n\t\t\t\t\tif ( shift.id && shift.id != TTUUID.zero_id ) {\n\t\t\t\t\t\tdelete_shifts_array.push( shift.id );\n\t\t\t\t\t} else if ( shift.user_id != TTUUID.zero_id && shift.user_id != TTUUID.not_exist_id ) {\n\t\t\t\t\t\t//If dragging (move) a recurring shift assigned to a user and dropping on another user, switch the source shift to Absent in the process, otherwise both shifts will exist as being worked.\n\t\t\t\t\t\t// However when dragging from a OPEN shift as the source, that isn't required, as the OPEN shift will automatically be filled.\n\t\t\t\t\t\tshift.status_id = '20';\n\t\t\t\t\t\trecurring_delete_shifts_array.push( shift );\n\t\t\t\t\t} else if ( shift.user_id == TTUUID.zero_id ) {\n\t\t\t\t\t\tdelete_old_items = false; //Never delete old items when the source is a OPEN shift.\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\tvar temp_selected_data = Global.clone( new_shift );\n\t\t\t\t\tvar temp_target_data = Global.clone( target_data );\n\n\t\t\t\t\tif ( !temp_target_data.start_date ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tfor ( var key in target_data ) {\n\t\t\t\t\t\tif ( key !== 'id' &&\n\t\t\t\t\t\t\tkey !== 'user_id' &&\n\t\t\t\t\t\t\tkey !== 'date_stamp' &&\n\t\t\t\t\t\t\tkey !== 'start_date_stamp' &&\n\t\t\t\t\t\t\tkey !== 'branch_id' &&\n\t\t\t\t\t\t\tkey !== 'department_id' &&\n\t\t\t\t\t\t\tkey !== 'job_id' &&\n\t\t\t\t\t\t\tkey !== 'job_item_id' &&\n\t\t\t\t\t\t\tkey !== 'punch_tag_id' &&\n\t\t\t\t\t\t\tkey !== 'branch' &&\n\t\t\t\t\t\t\tkey !== 'department' &&\n\t\t\t\t\t\t\tkey !== 'job' &&\n\t\t\t\t\t\t\tkey !== 'job_item' &&\n\t\t\t\t\t\t\tkey !== 'schedule_policy_id' ) {\n\n\t\t\t\t\t\t\ttarget_data[key] = temp_selected_data[key];\n\t\t\t\t\t\t\tnew_shift[key] = temp_target_data[key];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// When dragging an open shift to an empty cell in a user row with no branch column visible, the branch id value now defaults to user default branch id\n\t\t\t\t\ttarget_data.branch_id = target_data.branch ? target_data.branch_id : TTUUID.not_exist_id;\n\t\t\t\t\ttarget_data.department_id = target_data.department ? target_data.department_id : TTUUID.not_exist_id;\n\t\t\t\t\ttarget_data.job_id = target_data.job_id ? target_data.job_id : TTUUID.not_exist_id;\n\t\t\t\t\ttarget_data.job_item_id = target_data.job_item_id ? target_data.job_item_id : TTUUID.not_exist_id;\n\t\t\t\t\ttarget_data.punch_tag_id = target_data.punch_tag_id ? target_data.punch_tag_id : TTUUID.not_exist_id;\n\n\t\t\t\t\tnew_shifts_array.push( target_data );\n\t\t\t\t\tnew_shifts_array.push( new_shift );\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( new_shifts_array.length > 0 ) {\n\t\t\t\t$this.api.setSchedule( new_shifts_array, {\n\t\t\t\t\tonResult: function( res ) {\n\t\t\t\t\t\tif ( res.isValid() ) {\n\t\t\t\t\t\t\tif ( delete_old_items ) {\n\t\t\t\t\t\t\t\tif ( delete_shifts_array.length > 0 ) {\n\t\t\t\t\t\t\t\t\t$this.api.deleteSchedule( delete_shifts_array, {\n\t\t\t\t\t\t\t\t\t\tonResult: function() {\n\t\t\t\t\t\t\t\t\t\t\tif ( recurring_delete_shifts_array.length > 0 ) {\n\t\t\t\t\t\t\t\t\t\t\t\t$this.api.setSchedule( recurring_delete_shifts_array, {\n\t\t\t\t\t\t\t\t\t\t\t\t\tonResult: function() {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t$this.search();\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\t$this.search();\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} else if ( recurring_delete_shifts_array.length > 0 ) {\n\t\t\t\t\t\t\t\t\t$this.api.setSchedule( recurring_delete_shifts_array, {\n\t\t\t\t\t\t\t\t\t\tonResult: function() {\n\t\t\t\t\t\t\t\t\t\t\t$this.search();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t$this.search();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t$this.search();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tTAlertManager.showErrorAlert( res );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t} );\n\n\t\tcells.unbind( 'dragenter' ).bind( 'dragenter', function( event ) {\n\t\t\tevent.preventDefault();\n\t\t} );\n\n\t\tcells.unbind( 'dragover' ).bind( 'dragover', function( event ) {\n\t\t\tevent.preventDefault(); //Must prevent tihs\n\n\t\t} );\n\t\tcells.unbind( 'dragend' ).bind( 'dragend', function( event ) {\n\n\t\t\t$( '.drag-holder-div' ).remove();\n\t\t\t$( '.schedule-drag-over' ).removeClass( 'schedule-drag-over' );\n\n\t\t} );\n\t}\n\n\tresetSomeFields( item ) {\n\t\titem.branch_id = item.branch ? item.branch_id : '';\n\t\titem.department_id = item.department ? item.department_id : '';\n\t\titem.job_id = item.job ? item.job_id : '';\n\t\titem.job_item_id = item.job_item ? item.job_item_id : '';\n\t\titem.punch_tag_id = item.punch_tag_id ? item.punch_tag_id : [];\n\n\t\treturn item;\n\t}\n\n\t_createParametersForAdd() {\n\t\tvar result = [], user;\n\t\tif ( this.select_cells_Array.length > 0 ) {\n\t\t\tfor ( var i = 0, n = this.select_cells_Array.length; i < n; i++ ) {\n\t\t\t\tvar item = this.select_cells_Array[i];\n\t\t\t\tuser = {};\n\t\t\t\tuser.user_id = item.user_id;\n\t\t\t\tuser.branch_id = item.branch_id;\n\t\t\t\tuser.department_id = item.department_id;\n\t\t\t\tuser.job_id = item.job_id;\n\t\t\t\tuser.job_item_id = item.job_item_id;\n\t\t\t\tuser.punch_tag_id = item.punch_tag_id;\n\t\t\t\tuser.date = item.date;\n\t\t\t\tresult.push( user );\n\t\t\t}\n\t\t}\n\n\t\tif ( result.length < 1 ) {\n\t\t\tvar login_user = LocalCacheData.getLoginUser();\n\t\t\tuser = {};\n\t\t\tuser.user_id = login_user.id;\n\t\t\tuser.branch_id = login_user.branch_id;\n\t\t\tuser.department_id = login_user.department_id;\n\t\t\tuser.job_id = login_user.job_id;\n\t\t\tuser.job_item_id = login_user.job_item_id;\n\t\t\tuser.punch_tag_id = login_user.punch_tag_id;\n\t\t\tuser.date = this.getSelectDate();\n\t\t\tresult.push( user );\n\t\t}\n\t\treturn result;\n\t}\n\n\tonAddClick( doing_save_and_new ) {\n\n\t\tvar $this = this;\n\t\tthis.setCurrentEditViewState( 'new' );\n\n\t\tif ( this.select_cells_Array.length > 1 ) {\n\t\t\tthis.is_mass_adding = true;\n\t\t}\n\n\t\t$this.openEditView();\n\n\t\tvar args;\n\t\tif ( !doing_save_and_new ) {\n\t\t\targs = this._createParametersForAdd();\n\t\t} else {\n\t\t\targs = [\n\t\t\t\t{\n\t\t\t\t\tuser_id: this.current_edit_record.user_id,\n\t\t\t\t\tbranch_id: this.current_edit_record.branch_id,\n\t\t\t\t\tdepartment_id: this.current_edit_record.department_id,\n\t\t\t\t\tjob_id: this.current_edit_record.job_id,\n\t\t\t\t\tjob_item_id: this.current_edit_record.job_item_id,\n\t\t\t\t\tpunch_tag_id: this.current_edit_record.punch_tag_id,\n\t\t\t\t\tdate: this.current_edit_record.date_stamp\n\t\t\t\t}\n\t\t\t];\n\t\t}\n\n\t\tthis.api['get' + this.api.key_name + 'DefaultData']( args, {\n\t\t\tonResult: function( result ) {\n\t\t\t\tvar select_shift;\n\t\t\t\tvar result_data = result.getResult();\n\n\t\t\t\tselect_shift = result_data;\n\t\t\t\tif ( $this.select_cells_Array.length >= 1 ) {\n\t\t\t\t\tfor ( var i = 0, n = args.length; i < n; i++ ) {\n\t\t\t\t\t\tvar item = args[i];\n\t\t\t\t\t\tif ( i == 0 ) {\n\t\t\t\t\t\t\tselect_shift.branch_id = item.branch_id;\n\t\t\t\t\t\t\tselect_shift.department_id = item.department_id;\n\t\t\t\t\t\t\tselect_shift.job_id = item.job_id;\n\t\t\t\t\t\t\tselect_shift.job_item_id = item.job_item_id;\n\t\t\t\t\t\t\tselect_shift.punch_tag_id = item.punch_tag_id;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t( select_shift.branch_id !== item.branch_id && select_shift.branch_id !== '-2' ) ? select_shift.branch_id = '-2' : item.branch_id;\n\t\t\t\t\t\t\t( select_shift.department_id !== item.department_id && select_shift.department_id !== '-2' ) ? select_shift.department_id = '-2' : item.department_id;\n\t\t\t\t\t\t\t( select_shift.job_id !== item.job_id && select_shift.job_id !== '-2' ) ? select_shift.job_id = '-2' : item.job_id;\n\t\t\t\t\t\t\t( select_shift.job_item_id !== item.job_item_id && select_shift.job_item_id !== '-2' ) ? select_shift.job_item_id = '-2' : item.job_item_id;\n\t\t\t\t\t\t\t( select_shift.punch_tag_id !== item.punch_tag_id && select_shift.punch_tag_id !== '-2' ) ? select_shift.punch_tag_id = '-2' : item.punch_tag_id;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( !doing_save_and_new ) {\n\t\t\t\t\tselect_shift.date_stamp = $this.getSelectDate();\n\n\t\t\t\t} else {\n\t\t\t\t\tvar temp_date = Global.strToDate( $this.current_edit_record.date_stamp );\n\t\t\t\t\tselect_shift.date_stamp = new Date( new Date( temp_date.getTime() ).setDate( temp_date.getDate() + 1 ) ).format();\n\n\t\t\t\t}\n\n\t\t\t\tif ( !select_shift.start_date_stamp ) {\n\t\t\t\t\tselect_shift.start_date_stamp = select_shift.date_stamp;\n\t\t\t\t}\n\n\t\t\t\tselect_shift.id = '';\n\n\t\t\t\tif ( $this.sub_view_mode && $this.parent_key ) {\n\t\t\t\t\tresult_data[$this.parent_key] = $this.parent_value;\n\t\t\t\t}\n\n\t\t\t\t$this.current_edit_record = select_shift;\n\t\t\t\t$this.initEditView();\n\n\t\t\t}\n\t\t} );\n\t}\n\n\topenEditView() {\n\n\t\tif ( !this.edit_view ) {\n\t\t\tthis.initEditViewUI( 'Schedule', 'ScheduleEditView.html' );\n\t\t}\n\t\tthis.previous_absence_policy_id = false;\n\t}\n\n\t//set widget disablebility if view mode or edit mode\n\tsetEditViewWidgetsMode() {\n\t\tvar did_clean_dic = {};\n\t\tfor ( var key in this.edit_view_ui_dic ) {\n\t\t\tif ( !this.edit_view_ui_dic.hasOwnProperty( key ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tvar widget = this.edit_view_ui_dic[key];\n\t\t\twidget.css( 'opacity', 1 );\n\t\t\tvar column = widget.parent().parent().parent();\n\t\t\tvar tab_id = column.parent().attr( 'id' );\n\t\t\tif ( !column.hasClass( 'v-box' ) ) {\n\t\t\t\tif ( !did_clean_dic[tab_id] ) {\n\t\t\t\t\tdid_clean_dic[tab_id] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( this.is_viewing ) {\n\t\t\t\tif ( Global.isSet( widget.setEnabled ) ) {\n\t\t\t\t\twidget.setEnabled( false );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( Global.isSet( widget.setEnabled ) ) {\n\t\t\t\t\twidget.setEnabled( true );\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t}\n\n\tsetJobValueWhenUserChanged( job, job_id_col_name, filter_data ) {\n\t\tvar $this = this;\n\n\t\t//Error: Uncaught TypeError: Cannot set property 'job_item_id' of null in /interface/html5/#!m=TimeSheet&date=20150126&user_id=54286 line 6785\n\t\tif ( !$this.current_edit_record ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( this.edit_view_ui_dic['user_ids'] && this.edit_view_ui_dic['user_ids'].is( ':visible' ) ) {\n\t\t\tfilter_data['user_id'] = this.edit_view_ui_dic['user_ids'].getValue();\n\n\t\t\t//If more than one user is selected, don't filter by user_id at all, show all jobs and let the validation system handle it.\n\t\t\tif ( filter_data['user_id'].length == 1 ) {\n\t\t\t\tfilter_data['user_id'] = filter_data['user_id'][0];\n\t\t\t} else {\n\t\t\t\tfilter_data['user_id'] = false;\n\t\t\t}\n\t\t} else {\n\t\t\tfilter_data['user_id'] = this.current_edit_record['user_id'];\n\t\t}\n\n\t\tvar job_widget = $this.edit_view_ui_dic[job_id_col_name];\n\t\tvar current_job_id = job_widget.getValue();\n\t\tjob_widget.setSourceData( null ); //Clear out source data so its reloaded when the Job dropdown is expanded again.\n\t\tjob_widget.setCheckBox( true );\n\t\tthis.edit_view_ui_dic['job_item_quick_search'].setCheckBox( true );\n\n\t\tvar args = {};\n\t\targs.filter_data = filter_data;\n\t\t$this.edit_view_ui_dic[job_id_col_name].setDefaultArgs( args );\n\n\t\treturn;\n\t}\n\n\tonFormItemChange( target, doNotValidate ) {\n\t\tvar $this = this;\n\t\tthis.setIsChanged( target );\n\t\tthis.setMassEditingFieldsWhenFormChange( target );\n\t\tvar key = target.getField();\n\t\tvar c_value = target.getValue();\n\t\tthis.current_edit_record[key] = c_value;\n\n\t\tswitch ( key ) {\n\t\t\tcase 'job_id':\n\t\t\t\tif ( Global.getProductEdition() >= 20 ) {\n\t\t\t\t\tthis.edit_view_ui_dic['job_quick_search'].setValue( target.getValue( true ) ? ( target.getValue( true ).manual_id ? target.getValue( true ).manual_id : '' ) : '' );\n\t\t\t\t\tthis.setJobItemValueWhenJobChanged( target.getValue( true ), 'job_item_id', {\n\t\t\t\t\t\tstatus_id: 10,\n\t\t\t\t\t\tjob_id: this.current_edit_record.job_id\n\t\t\t\t\t} );\n\t\t\t\t\tthis.edit_view_ui_dic['job_quick_search'].setCheckBox( true );\n\t\t\t\t\tthis.setPunchTagValuesWhenCriteriaChanged( this.getPunchTagFilterData(), 'punch_tag_id' );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'job_item_id':\n\t\t\t\tif ( Global.getProductEdition() >= 20 ) {\n\t\t\t\t\tthis.edit_view_ui_dic['job_item_quick_search'].setValue( target.getValue( true ) ? ( target.getValue( true ).manual_id ? target.getValue( true ).manual_id : '' ) : '' );\n\t\t\t\t\tthis.edit_view_ui_dic['job_item_quick_search'].setCheckBox( true );\n\t\t\t\t\tthis.setPunchTagValuesWhenCriteriaChanged( this.getPunchTagFilterData(), 'punch_tag_id' );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'punch_tag_id':\n\t\t\t\tif ( Global.getProductEdition() >= 20 ) {\n\t\t\t\t\tif ( c_value !== TTUUID.zero_id && c_value !== false && c_value.length > 0 ) {\n\t\t\t\t\t\tthis.setPunchTagQuickSearchManualIds( target.getSelectItems() );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.edit_view_ui_dic['punch_tag_quick_search'].setValue( '' );\n\t\t\t\t\t}\n\t\t\t\t\t$this.previous_punch_tag_selection = c_value;\n\t\t\t\t\t//Reset source data to make sure correct punch tags are always shown.\n\t\t\t\t\tthis.edit_view_ui_dic['punch_tag_id'].setSourceData( null );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'branch_id':\n\t\t\t\tif ( Global.getProductEdition() >= 20 ) {\n\t\t\t\t\tthis.setPunchTagValuesWhenCriteriaChanged( this.getPunchTagFilterData(), 'punch_tag_id' );\n\t\t\t\t\tthis.setJobValueWhenCriteriaChanged( 'job_id', {\n\t\t\t\t\t\tstatus_id: 10,\n\t\t\t\t\t\tuser_id: this.current_edit_record.user_id,\n\t\t\t\t\t\tpunch_branch_id: this.current_edit_record.branch_id,\n\t\t\t\t\t\tpunch_department_id: this.current_edit_record.department_id\n\t\t\t\t\t} );\n\t\t\t\t\tthis.setDepartmentValueWhenBranchChanged( target.getValue( true ), 'department_id', {\n\t\t\t\t\t\tbranch_id: this.current_edit_record.branch_id,\n\t\t\t\t\t\tuser_id: this.current_edit_record.user_id\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'department_id':\n\t\t\t\tif ( Global.getProductEdition() >= 20 ) {\n\t\t\t\t\tthis.setPunchTagValuesWhenCriteriaChanged( this.getPunchTagFilterData(), 'punch_tag_id' );\n\t\t\t\t\tthis.setJobValueWhenCriteriaChanged( 'job_id', {\n\t\t\t\t\t\tstatus_id: 10,\n\t\t\t\t\t\tuser_id: this.current_edit_record.user_id,\n\t\t\t\t\t\tpunch_branch_id: this.current_edit_record.branch_id,\n\t\t\t\t\t\tpunch_department_id: this.current_edit_record.department_id\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'job_quick_search':\n\t\t\tcase 'job_item_quick_search':\n\t\t\t\tif ( Global.getProductEdition() >= 20 ) {\n\t\t\t\t\tthis.onJobQuickSearch( key, c_value );\n\t\t\t\t\tthis.setPunchTagValuesWhenCriteriaChanged( this.getPunchTagFilterData(), 'punch_tag_id' );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'punch_tag_quick_search':\n\t\t\t\tif ( Global.getProductEdition() >= 20 ) {\n\t\t\t\t\tthis.onPunchTagQuickSearch( c_value, this.getPunchTagFilterData(), 'punch_tag_id' );\n\n\t\t\t\t\t//Don't validate immediately as onPunchTagQuickSearch is doing async API calls, and it would cause a guaranteed validation failure.\n\t\t\t\t\tdoNotValidate = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'status_id':\n\t\t\t\tthis.onTypeChange( true );\n\t\t\t\tbreak;\n\t\t\tcase 'user_id':\n\t\t\tcase 'user_ids':\n\t\t\t\tthis.setEditMenu();\n\n\t\t\t\tthis.setAbsencePolicyWhenUserChanged();\n\n\t\t\t\tif ( Global.getProductEdition() >= 20 ) {\n\t\t\t\t\tif ( this.edit_view_ui_dic['job_id'] ) {\n\t\t\t\t\t\tthis.setJobValueWhenUserChanged( this.edit_view_ui_dic['job_id'].getValue( true ), 'job_id', {\n\t\t\t\t\t\t\tstatus_id: 10,\n\t\t\t\t\t\t\tuser_id: this.edit_view_ui_dic[key].getValue(),\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.setPunchTagValuesWhenCriteriaChanged( this.getPunchTagFilterData(), 'punch_tag_id' );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase 'start_date_stamps':\n\t\t\t\tthis.setEditMenu();\n\t\t\t\tthis.current_edit_record['start_date_stamp'] = c_value;\n\t\t\t\tbreak;\n\n\t\t}\n\n\t\tif ( key == 'absence_policy_id' ) {\n\t\t\tthis.previous_absence_policy_id = this.current_edit_record.absence_policy_id;\n\t\t}\n\n\t\tif ( key === 'date_stamp' ||\n\t\t\tkey === 'start_date_stamps' ||\n\t\t\tkey === 'start_date_stamp' ||\n\t\t\tkey === 'start_time' ||\n\t\t\tkey === 'end_time' ||\n\t\t\tkey === 'schedule_policy_id' ||\n\t\t\tkey === 'absence_policy_id' ) {\n\n\t\t\tif ( this.current_edit_record['date_stamp'] !== '' &&\n\t\t\t\tthis.current_edit_record['start_time'] !== '' &&\n\t\t\t\tthis.current_edit_record['end_time'] !== '' ) {\n\n\t\t\t\tvar startTime = this.current_edit_record['date_stamp'] + ' ' + this.current_edit_record['start_time'];\n\t\t\t\tvar endTime = this.current_edit_record['date_stamp'] + ' ' + this.current_edit_record['end_time'];\n\t\t\t\tvar schedulePolicyId = this.current_edit_record['schedule_policy_id'];\n\t\t\t\tvar user_id = this.current_edit_record.user_id;\n\n\t\t\t\tthis.api.getScheduleTotalTime( startTime, endTime, schedulePolicyId, user_id, {\n\t\t\t\t\tonResult: function( total_time ) {\n\n\t\t\t\t\t\t//Uncaught TypeError: Cannot set property 'total_time' of null\n\t\t\t\t\t\t//Error: Uncaught TypeError: Cannot read property 'setValue' of undefined in interface/html5/#!m=Schedule&date=20160202&mode=week&a=new&tab=Schedule line 1799\n\t\t\t\t\t\tif ( !$this.edit_view || !$this.current_edit_record || !$this.edit_view_ui_dic['total_time'] ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t//Fixed exception that total_time is null\n\t\t\t\t\t\tif ( total_time ) {\n\t\t\t\t\t\t\ttotal_time = total_time.getResult();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttotal_time = $this.current_edit_record.total_time ? $this.current_edit_record.total_time : 0;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t$this.current_edit_record.total_time = total_time;\n\t\t\t\t\t\ttotal_time = Global.getTimeUnit( total_time );\n\t\t\t\t\t\t$this.edit_view_ui_dic['total_time'].setValue( total_time );\n\n\t\t\t\t\t\t$this.onAvailableBalanceChange();\n\n\t\t\t\t\t}\n\t\t\t\t} );\n//\n\n\t\t\t} else {\n\t\t\t\tthis.onAvailableBalanceChange();\n\t\t\t}\n\n\t\t}\n\n\t\tif ( !doNotValidate ) {\n\t\t\tthis.validate();\n\t\t}\n\t}\n\n\tsetAbsencePolicyWhenUserChanged() {\n\n\t\tvar $this = this;\n\t\tvar absence_widget = $this.edit_view_ui_dic['absence_policy_id'];\n\t\tabsence_widget.setSourceData( null );\n\t\tvar old_value = absence_widget.getValue();\n\n\t\tvar args = {};\n\t\targs.filter_data = { id: old_value };\n\n\t\targs = this.setAbsencePolicyFilter( args );\n\n\t\tif ( old_value ) {\n\n\t\t\t$this.absence_policy_api.getAbsencePolicy( args, {\n\t\t\t\tonResult: function( task_result ) {\n\n\t\t\t\t\t// Returning early to help mitigate #2889 - \"Error: Uncaught TypeError: Cannot set property 'absence_policy_id' of null\"\n\t\t\t\t\t// This can happen when the user saves or leaves the page before the API call is completed.\n\t\t\t\t\tif ( $this.current_edit_record === null || $this.current_edit_record === undefined ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tvar data = task_result.getResult();\n\n\t\t\t\t\tif ( data.length > 0 ) {\n\t\t\t\t\t\tabsence_widget.setValue( old_value );\n\t\t\t\t\t\t$this.current_edit_record.absence_policy_id = old_value;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tabsence_widget.setValue( false );\n\t\t\t\t\t\t$this.current_edit_record.absence_policy_id = false;\n\t\t\t\t\t}\n\t\t\t\t\t$this.onAvailableBalanceChange();\n\t\t\t\t\t$this.validate();\n\n\t\t\t\t}\n\t\t\t} );\n\t\t} else {\n\t\t\tthis.onAvailableBalanceChange();\n\t\t\tthis.validate();\n\t\t}\n\t}\n\n\t//Make sure this.current_edit_record is updated before validate\n\tvalidate() {\n\t\tvar $this = this;\n\t\tvar record = {};\n\t\tif ( this.is_mass_adding ) {\n\t\t\trecord = [];\n\t\t\t$.each( this.select_cells_Array, function( index, value ) {\n\t\t\t\tif ( value.hasOwnProperty( 'user_id' ) && value.hasOwnProperty( 'date' ) && value.date ) {\n\t\t\t\t\tvar commonRecord = Global.clone( $this.current_edit_record );\n\t\t\t\t\tdelete commonRecord.user_ids;\n\t\t\t\t\tdelete commonRecord.start_dates;\n\t\t\t\t\tcommonRecord.id = '';\n\t\t\t\t\tcommonRecord.user_id = value.user_id;\n\t\t\t\t\tcommonRecord.start_date_stamp = value.date;\n\t\t\t\t\tcommonRecord = $this.buildMassAddRecord( commonRecord );\n\t\t\t\t\trecord.push( commonRecord );\n\t\t\t\t}\n\t\t\t} );\n\t\t} else if ( this.is_mass_editing ) {\n\t\t\tfor ( var key in this.edit_view_ui_dic ) {\n\t\t\t\tif ( !this.edit_view_ui_dic.hasOwnProperty( key ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tvar widget = this.edit_view_ui_dic[key];\n\t\t\t\tif ( Global.isSet( widget.isChecked ) ) {\n\t\t\t\t\tif ( widget.isChecked() && widget.getEnabled() ) {\n\t\t\t\t\t\trecord[key] = widget.getValue();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( this.mass_edit_record_ids.length > 0 ) {\n\t\t\t\tvar checkFields = record;\n\t\t\t\trecord = [];\n\t\t\t\t$.each( this.mass_edit_record_ids, function( index, value ) {\n\t\t\t\t\tvar commonRecord = Global.clone( checkFields );\n\t\t\t\t\tcommonRecord.id = value;\n\t\t\t\t\tcommonRecord = $this.processAddRecord( commonRecord );\n\t\t\t\t\trecord.push( commonRecord );\n\t\t\t\t} );\n\t\t\t\t$.each( this.select_all_shifts_array, function( index, value ) {\n\t\t\t\t\tif ( !value.id || value.id == TTUUID.zero_id ) {\n\t\t\t\t\t\tvar commonRecord = Global.clone( value );\n\t\t\t\t\t\tfor ( var key in checkFields ) {\n\t\t\t\t\t\t\tcommonRecord[key] = checkFields[key];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcommonRecord = $this.processAddRecord( commonRecord );\n\t\t\t\t\t\trecord.push( commonRecord );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t\trecord = this.getRecordsFromUserIDs( record );\n\t\t\t} else {\n\t\t\t\tvar record_array = [];\n\t\t\t\t$.each( this.select_all_shifts_array, function( index, value ) {\n\t\t\t\t\tif ( !value.id || value.id == TTUUID.zero_id ) {\n\t\t\t\t\t\tvar commonRecord = Global.clone( value );\n\t\t\t\t\t\tfor ( var key in record ) {\n\t\t\t\t\t\t\tcommonRecord[key] = record[key];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcommonRecord = $this.processAddRecord( commonRecord );\n\t\t\t\t\t\trecord_array.push( commonRecord );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t\tif ( record_array.length < 1 ) {\n\t\t\t\t\tif ( this.select_cells_Array.length > 0 ) {\n\t\t\t\t\t\t$this.processAddRecord( record );\n\t\t\t\t\t\trecord = this.getRecordsFromUserIDs( [record] );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\trecord = record_array;\n\t\t\t\t\trecord = this.getRecordsFromUserIDs( record );\n\t\t\t\t}\n\t\t\t}\n\n\t\t} else {\n\t\t\t//Error: Uncaught TypeError: Cannot read property 'indexOf' of undefined in interface/html5/#!m=Schedule&date=20151204&mode=day line 1954\n\t\t\tif ( this.current_edit_record && this.current_edit_record.start_date_stamp &&\n\t\t\t\t( this.current_edit_record.start_date_stamp.indexOf( ' - ' ) > 0 ||\n\t\t\t\t\t$.type( this.current_edit_record.start_date_stamp ) === 'array' ) ) {\n\t\t\t\tif ( this.current_edit_record.start_date_stamp.indexOf( ' - ' ) > 0 ) {\n\t\t\t\t\tthis.current_edit_record.start_date_stamp = this.parserDatesRange( this.current_edit_record.start_date_stamp );\n\t\t\t\t}\n\t\t\t\trecord = [];\n\t\t\t\tfor ( var i = 0; i < this.current_edit_record.start_date_stamp.length; i++ ) {\n\t\t\t\t\tvar commonRecord = Global.clone( $this.current_edit_record );\n\t\t\t\t\tcommonRecord.start_date_stamp = this.current_edit_record.start_date_stamp[i];\n\t\t\t\t\tif ( this.select_cells_Array.length > 0 ) {\n\t\t\t\t\t\t$this.processAddRecord( commonRecord );\n\t\t\t\t\t}\n\t\t\t\t\trecord.push( commonRecord );\n\t\t\t\t}\n\t\t\t\trecord = this.getRecordsFromUserIDs( record );\n\t\t\t} else {\n\t\t\t\trecord = Global.clone( this.current_edit_record );\n\t\t\t\tif ( this.select_cells_Array.length > 0 ) {\n\t\t\t\t\t$this.processAddRecord( record );\n\t\t\t\t}\n\t\t\t\trecord = this.getRecordsFromUserIDs( [record] );\n\t\t\t}\n\n\t\t}\n\t\tthis.api['validate' + this.api.key_name]( record, {\n\t\t\tonResult: function( result ) {\n\t\t\t\t$this.validateResult( result );\n\t\t\t}\n\t\t} );\n\t}\n\n\tgetRecordsFromUserIDs( record ) {\n\t\tvar result = [];\n\n\t\tfor ( var j = 0; j < record.length; j++ ) {\n\t\t\tvar common_record = record[j];\n\n\t\t\tif ( common_record.user_ids && common_record.user_ids.length > 0 ) {\n\t\t\t\tfor ( var y = 0; y < common_record.user_ids.length; y++ ) {\n\t\t\t\t\tvar user_id = common_record.user_ids[y];\n\t\t\t\t\tif ( Global.isObject( user_id ) && user_id.id ) {\n\t\t\t\t\t\tuser_id = user_id.id;\n\t\t\t\t\t}\n\n\t\t\t\t\tvar new_common_record = Global.clone( common_record );\n\t\t\t\t\tnew_common_record.user_id = user_id;\n\t\t\t\t\tresult.push( new_common_record );\n\n\t\t\t\t}\n\t\t\t} else {\n\n\t\t\t\tif ( ( !this.current_edit_record || !this.current_edit_record.id || this.current_edit_record.id == TTUUID.zero_id ) && !this.is_mass_editing ) {\n\t\t\t\t\tcommon_record.user_id = TTUUID.zero_id;\n\t\t\t\t}\n\n\t\t\t\tresult.push( common_record );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tonSaveAndCopy( ignoreWarning ) {\n\t\tvar $this = this;\n\t\tif ( !Global.isSet( ignoreWarning ) ) {\n\t\t\tignoreWarning = false;\n\t\t}\n\t\tthis.is_add = true;\n\t\tthis.is_changed = false;\n\t\tLocalCacheData.current_doing_context_action = 'save_and_copy';\n\t\tvar record = this.current_edit_record;\n\t\trecord = this.processAddRecord( record );\n\t\trecord = this.getRecordsFromUserIDs( [record] );\n\n\t\tif ( this.current_edit_record.start_date_stamp.indexOf( ' - ' ) > 0 ||\n\t\t\t$.type( this.current_edit_record.start_date_stamp ) === 'array' ) {\n\n\t\t\tif ( this.current_edit_record.start_date_stamp.indexOf( ' - ' ) > 0 ) {\n\t\t\t\tthis.current_edit_record.start_date_stamp = this.parserDatesRange( this.current_edit_record.start_date_stamp );\n\t\t\t}\n\n\t\t\trecord = [];\n\t\t\tfor ( var i = 0; i < this.current_edit_record.start_date_stamp.length; i++ ) {\n\t\t\t\tvar commonRecord = Global.clone( $this.current_edit_record );\n\t\t\t\tcommonRecord.start_date_stamp = this.current_edit_record.start_date_stamp[i];\n\t\t\t\tcommonRecord = this.processAddRecord( commonRecord );\n\t\t\t\trecord.push( commonRecord );\n\t\t\t}\n\t\t\trecord = this.getRecordsFromUserIDs( record );\n\t\t}\n\n\t\tthis.clearNavigationData();\n\t\tthis.api['set' + this.api.key_name]( record, false, false, ignoreWarning, {\n\t\t\tonResult: function( result ) {\n\t\t\t\tif ( $this.current_edit_record ) {\n\t\t\t\t\tvar current_date_str = $this.current_edit_record.start_date_stamp;\n\n\t\t\t\t\tif ( $.type( current_date_str ) === 'array' ) {\n\t\t\t\t\t\tcurrent_date_str = current_date_str[current_date_str.length - 1];\n\t\t\t\t\t}\n\n\t\t\t\t\tvar current_date = Global.strToDate( current_date_str );\n\t\t\t\t\tvar next_date = new Date( new Date( current_date.getTime() ).setDate( current_date.getDate() + 1 ) );\n\n\t\t\t\t\t$this.current_edit_record.start_date_stamp = next_date.format();\n\n\t\t\t\t\t$this.onSaveAndCopyResult( result );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\tonSaveAndNewClick( ignoreWarning ) {\n\t\tvar $this = this;\n\t\tif ( !Global.isSet( ignoreWarning ) ) {\n\t\t\tignoreWarning = false;\n\t\t}\n\t\tthis.setCurrentEditViewState( 'new' );\n\t\tvar record = this.current_edit_record;\n\t\trecord = this.processAddRecord( record );\n\t\trecord = this.getRecordsFromUserIDs( [record] );\n\n\t\tif ( this.current_edit_record.start_date_stamp.indexOf( ' - ' ) > 0 ||\n\t\t\t$.type( this.current_edit_record.start_date_stamp ) === 'array' ) {\n\n\t\t\tif ( this.current_edit_record.start_date_stamp.indexOf( ' - ' ) > 0 ) {\n\t\t\t\tthis.current_edit_record.start_date_stamp = this.parserDatesRange( this.current_edit_record.start_date_stamp );\n\t\t\t}\n\n\t\t\trecord = [];\n\t\t\tfor ( var i = 0; i < this.current_edit_record.start_date_stamp.length; i++ ) {\n\t\t\t\tvar commonRecord = Global.clone( $this.current_edit_record );\n\t\t\t\tcommonRecord.start_date_stamp = this.current_edit_record.start_date_stamp[i];\n\t\t\t\tcommonRecord = this.processAddRecord( commonRecord );\n\t\t\t\trecord.push( commonRecord );\n\t\t\t}\n\t\t\trecord = this.getRecordsFromUserIDs( record );\n\t\t}\n\n\t\tthis.api['set' + this.api.key_name]( record, false, ignoreWarning, {\n\t\t\tonResult: function( result ) {\n\t\t\t\t$this.onSaveAndNewResult( result );\n\t\t\t}\n\t\t} );\n\t}\n\n\tbuildSelectedCellsRecord() {\n\t\tvar $this = this;\n\t\tvar retval = [];\n\t\t$.each( this.select_cells_Array, function( index, value ) {\n\t\t\tif ( value.hasOwnProperty( 'user_id' ) && value.hasOwnProperty( 'date' ) && value.date ) {\n\t\t\t\tvar commonRecord = Global.clone( $this.current_edit_record );\n\t\t\t\tdelete commonRecord.user_ids;\n\t\t\t\tdelete commonRecord.start_dates;\n\t\t\t\tcommonRecord.id = '';\n\t\t\t\tcommonRecord.user_id = value.user_id;\n\t\t\t\tcommonRecord.start_date_stamp = value.date;\n\t\t\t\tcommonRecord = $this.buildMassAddRecord( commonRecord );\n\n\t\t\t\tretval.push( commonRecord );\n\t\t\t}\n\n\t\t} );\n\n\t\treturn retval;\n\t}\n\n\tbuildMassAddRecord( record ) {\n\t\tvar massAddArgs = this._createParametersForAdd();\n\t\tfor ( var i = 0, n = massAddArgs.length; i < n; i++ ) {\n\t\t\tvar item = massAddArgs[i];\n\t\t\tif ( record.user_id === item.user_id ) {\n\t\t\t\trecord.branch_id == '-2' ? ( record.branch_id = item.branch_id ) : record.branch_id;\n\t\t\t\trecord.department_id == '-2' ? ( record.department_id = item.department_id ) : record.department_id;\n\t\t\t\trecord.job_id == '-2' ? ( record.job_id = item.job_id ) : record.job_id;\n\t\t\t\trecord.job_item_id == '-2' ? ( record.job_item_id = item.job_item_id ) : record.job_item_id;\n\t\t\t\trecord.punch_tag_id == '-2' ? ( record.punch_tag_id = item.punch_tag_id ) : record.punch_tag_id;\n\t\t\t}\n\t\t}\n\t\treturn record;\n\t}\n\n\tprocessAddRecord( record ) {\n\t\tvar massAddArgs = this._createParametersForAdd();\n\t\tfor ( var i = 0, n = massAddArgs.length; i < n; i++ ) {\n\t\t\tvar item = massAddArgs[i];\n\t\t\trecord.branch_id == '-2' ? ( record.branch_id = item.branch_id ) : record.branch_id;\n\t\t\trecord.department_id == '-2' ? ( record.department_id = item.department_id ) : record.department_id;\n\t\t\trecord.job_id == '-2' ? ( record.job_id = item.job_id ) : record.job_id;\n\t\t\trecord.job_item_id == '-2' ? ( record.job_item_id = item.job_item_id ) : record.job_item_id;\n\t\t\trecord.punch_tag_id == '-2' ? ( record.punch_tag_id = item.punch_tag_id ) : record.punch_tag_id;\n\t\t\tbreak;\n\t\t}\n\t\treturn record;\n\t}\n\n\tgetSelectedId( record, field, massAddArgs ) {\n\t\tfor ( var i = 0, n = massAddArgs.length; i < n; i++ ) {\n\t\t\tvar item = massAddArgs[i];\n\t\t\tif ( record.user_id === item.user_id ) {\n\t\t\t\trecord[field] = item[field];\n\t\t\t}\n\t\t}\n\t}\n\n\tonSaveAndContinue( ignoreWarning ) {\n\t\tvar $this = this;\n\t\tif ( !Global.isSet( ignoreWarning ) ) {\n\t\t\tignoreWarning = false;\n\t\t}\n\t\tthis.is_changed = false;\n\t\tthis.is_add = false;\n\t\tLocalCacheData.current_doing_context_action = 'save_and_continue';\n\t\tvar record = this.current_edit_record;\n\t\trecord = this.processAddRecord( record );\n\t\trecord = this.uniformVariable( record );\n\n\t\tif ( this.current_edit_record.start_date_stamp && ( this.current_edit_record.start_date_stamp.indexOf( ' - ' ) > 0 || $.type( this.current_edit_record.start_date_stamp ) === 'array' ) ) {\n\t\t\tif ( this.current_edit_record.start_date_stamp.indexOf( ' - ' ) > 0 ) {\n\t\t\t\tthis.current_edit_record.start_date_stamp = this.parserDatesRange( this.current_edit_record.start_date_stamp );\n\t\t\t}\n\n\t\t\trecord = [];\n\t\t\tfor ( var i = 0; i < this.current_edit_record.start_date_stamp.length; i++ ) {\n\t\t\t\tvar commonRecord = Global.clone( $this.current_edit_record );\n\t\t\t\tcommonRecord.start_date_stamp = this.current_edit_record.start_date_stamp[i];\n\t\t\t\tcommonRecord = this.processAddRecord( commonRecord );\n\t\t\t\trecord.push( commonRecord );\n\t\t\t}\n\t\t\trecord = this.getRecordsFromUserIDs( record );\n\t\t} else {\n\t\t\trecord = this.getRecordsFromUserIDs( [record] );\n\t\t}\n\n\t\tthis.api['set' + this.api.key_name]( record, false, ignoreWarning, {\n\t\t\tonResult: function( result ) {\n\t\t\t\t$this.previous_absence_policy_id = false;\n\t\t\t\t$this.onSaveAndContinueResult( result );\n\n\t\t\t}\n\t\t} );\n\t}\n\n\tonSaveClick( ignoreWarning ) {\n\t\tvar $this = this;\n\t\tvar record;\n\t\tif ( !Global.isSet( ignoreWarning ) ) {\n\t\t\tignoreWarning = false;\n\t\t}\n\t\tLocalCacheData.current_doing_context_action = 'save';\n\n\t\tif ( this.is_mass_adding ) {\n\t\t\trecord = this.buildSelectedCellsRecord();\n\t\t} else if ( this.is_mass_editing ) {\n\n\t\t\tvar checkFields = this.getChangedFields();\n\n\t\t\trecord = [];\n\n\t\t\t$.each( this.mass_edit_record_ids, function( index, value ) {\n\t\t\t\tvar commonRecord = Global.clone( checkFields );\n\t\t\t\tcommonRecord.id = value;\n\t\t\t\tcommonRecord = $this.processAddRecord( commonRecord );\n\t\t\t\trecord.push( commonRecord );\n\n\t\t\t} );\n\n\t\t\t$.each( this.select_all_shifts_array, function( index, value ) {\n\t\t\t\tif ( !value.id || value.id == TTUUID.zero_id ) {\n\t\t\t\t\tvar commonRecord = Global.clone( value );\n\t\t\t\t\tfor ( var key in checkFields ) {\n\t\t\t\t\t\tcommonRecord[key] = checkFields[key];\n\t\t\t\t\t}\n\t\t\t\t\tcommonRecord = $this.processAddRecord( commonRecord );\n\t\t\t\t\trecord.push( commonRecord );\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t} else if ( this.current_edit_record.start_date_stamp.indexOf( ' - ' ) > 0 ||\n\t\t\t$.type( this.current_edit_record.start_date_stamp ) === 'array' ) {\n\n\t\t\tif ( this.current_edit_record.start_date_stamp.indexOf( ' - ' ) > 0 ) {\n\t\t\t\tthis.current_edit_record.start_date_stamp = this.parserDatesRange( this.current_edit_record.start_date_stamp );\n\t\t\t}\n\n\t\t\trecord = [];\n\t\t\tfor ( var i = 0; i < this.current_edit_record.start_date_stamp.length; i++ ) {\n\t\t\t\tvar commonRecord = Global.clone( $this.current_edit_record );\n\t\t\t\tcommonRecord.start_date_stamp = this.current_edit_record.start_date_stamp[i];\n\t\t\t\tcommonRecord = $this.processAddRecord( commonRecord );\n\t\t\t\trecord.push( commonRecord );\n\t\t\t}\n\n\t\t\trecord = this.getRecordsFromUserIDs( record );\n\n\t\t} else {\n\n\t\t\trecord = this.current_edit_record;\n\t\t\trecord = $this.processAddRecord( record );\n\t\t\trecord = this.getRecordsFromUserIDs( [record] );\n\n\t\t}\n\n\t\tthis.api['set' + this.api.key_name]( record, false, ignoreWarning, {\n\t\t\tonResult: function( result ) {\n\t\t\t\tif ( result.isValid() ) {\n\t\t\t\t\tvar result_data = result.getResult();\n\t\t\t\t\t//#2571 - Cannot read property 'id' of null\n\t\t\t\t\tif ( result_data === true && $this.current_edit_record ) {\n\t\t\t\t\t\t$this.refresh_id = $this.current_edit_record.id;\n\t\t\t\t\t} else if ( TTUUID.isUUID( result_data ) && result_data != TTUUID.zero_id && result_data != TTUUID.not_exist_id ) {\n\t\t\t\t\t\t$this.refresh_id = result_data;\n\t\t\t\t\t}\n\t\t\t\t\t$this.search( false, false );\n\t\t\t\t\t$this.previous_absence_policy_id = false;\n\n\t\t\t\t\t$this.removeEditView();\n\n\t\t\t\t} else {\n\t\t\t\t\t//BUG#2073 - Pulled out the error message box that was showing the result array as its \"toString\" representation. ([object][object]);\n\t\t\t\t\t$this.setErrorTips( result );\n\t\t\t\t\t$this.setErrorMenu();\n\t\t\t\t}\n\n\t\t\t}\n\t\t} );\n\t}\n\n\tremoveEditView() {\n\t\tsuper.removeEditView();\n\n\t\tthis.setMoveOrDropMode( this.select_drag_menu_id ? this.select_drag_menu_id : 'move' );\n\t\tthis.selected_user_ids = [];\n\t\tthis.is_mass_adding = false;\n\t}\n\n\tsetEditMenuSaveAndContinueIcon( context_btn ) {\n\t\tthis.saveAndContinueValidate( context_btn );\n\n\t\tif ( this.is_mass_editing || this.is_viewing || this.is_mass_adding || this.isMassEmployeeOrDate() ) {\n\t\t\tContextMenuManager.disableMenuItem( this.determineContextMenuMountAttributes().id, context_btn.id, false );\n\t\t}\n\t}\n\n\tisMassEmployeeOrDate() {\n\n\t\tif ( this.current_edit_record && this.current_edit_record.start_date_stamps && ( this.current_edit_record.start_date_stamps.indexOf( ' - ' ) > 0 ||\n\t\t\t$.type( this.current_edit_record.start_date_stamps ) === 'array' && this.current_edit_record.start_date_stamps.length > 1\n\t\t) ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( this.current_edit_record && this.current_edit_record.user_ids && this.current_edit_record.user_ids.length > 1 ) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tsetEditMenuSaveAndAddIcon( context_btn ) {\n\t\tthis.saveAndNewValidate( context_btn );\n\n\t\tif ( this.is_viewing || this.is_mass_editing || this.is_mass_adding ) {\n\t\t\tContextMenuManager.disableMenuItem( this.determineContextMenuMountAttributes().id, context_btn.id, false );\n\t\t}\n\t}\n\n\tsetEditMenuSaveAndCopyIcon( context_btn ) {\n\t\tthis.saveAndCopyValidate( context_btn );\n\n\t\tif ( this.is_viewing || this.is_mass_editing || this.is_mass_adding ) {\n\t\t\tContextMenuManager.disableMenuItem( this.determineContextMenuMountAttributes().id, context_btn.id, false );\n\t\t}\n\t}\n\n\tonTypeChange( getRate ) {\n\t\tif ( this.current_edit_record.status_id == 20 ) {\n\t\t\tthis.attachElement( 'absence_policy_id' );\n\t\t} else {\n\t\t\tthis.detachElement( 'absence_policy_id' );\n\t\t}\n\t}\n\n\tsetEditViewData() {\n\n\t\tvar $this = this;\n\t\tsuper.setEditViewData(); //Set Navigation\n\t\t$this.onTypeChange( false );\n\t}\n\n\tcheckOpenPermission() {\n\t\tif ( Global.getProductEdition() >= 15 && PermissionManager.validate( 'schedule', 'view_open' ) ) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tgetCustomFieldReferenceField() {\n\t\treturn 'note';\n\t}\n\n\tbuildEditViewUI() {\n\n\t\tvar $this = this;\n\n\t\tvar form_item_input;\n\t\tvar widgetContainer;\n\n\t\t// #VueContextMenu# After we add the edit_view to the page in initEditViewUI(), add the context menu (Vue needs a valid id in dom)\n\t\tif( ContextMenuManager.getMenu( this.determineContextMenuMountAttributes().id ) === undefined ) {\n\t\t\tthis.buildContextMenu();\n\t\t} else {\n\t\t\tDebug.Warn( 'Context Menu ('+ this.determineContextMenuMountAttributes().id +') already exists for: '+ this.viewId, 'ScheduleViewController.js', 'ScheduleViewController', 'buildEditViewUI', 10 );\n\t\t}\n\n\t\tthis.edit_view_close_icon = this.edit_view.find( '.close-icon' );\n\t\tthis.edit_view_close_icon.hide();\n\t\tthis.edit_view_close_icon.click( function() {\n\t\t\t$this.onCloseIconClick();\n\t\t} );\n\n\t\tvar tab_model = {\n\t\t\t'tab_schedule': { 'label': $.i18n._( 'Schedule' ) },\n\t\t\t'tab_audit': true,\n\t\t};\n\t\tthis.setTabModel( tab_model );\n\n\t\t//Tab 0 start\n\n\t\tvar tab_schedule = this.edit_view_tab.find( '#tab_schedule' );\n\n\t\tvar tab_schedule_column1 = tab_schedule.find( '.first-column' );\n\n\t\t//Employee\n\n\t\tvar production_edition_id = Global.getProductEdition();\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );\n\t\tform_item_input.AComboBox( {\n\t\t\tapi_class: TTAPI.APIUser,\n\t\t\tallow_multiple_selection: false,\n\t\t\tlayout_name: 'global_user',\n\t\t\tshow_search_inputs: true,\n\t\t\tset_empty: !this.checkOpenPermission(),\n\t\t\tset_open: this.checkOpenPermission(),\n\t\t\tfield: 'user_id'\n\t\t} );\n\n\t\tvar default_args = {};\n\t\tdefault_args.permission_section = 'schedule';\n\t\tform_item_input.setDefaultArgs( default_args );\n\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Employee' ), form_item_input, tab_schedule_column1, '', null, true );\n\n\t\t//Mass Add Employees\n\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );\n\t\tform_item_input.AComboBox( {\n\t\t\tapi_class: TTAPI.APIUser,\n\t\t\tallow_multiple_selection: true,\n\t\t\tlayout_name: 'global_user',\n\t\t\tshow_search_inputs: true,\n\t\t\tset_empty: !this.checkOpenPermission(),\n\t\t\tset_open: this.checkOpenPermission(),\n\t\t\taddition_source_function: ( function( target, source_data ) {\n\t\t\t\treturn $this.onEmployeeSourceCreate( target, source_data );\n\t\t\t} ),\n\t\t\tfield: 'user_ids'\n\t\t} );\n\n\t\tdefault_args = {};\n\t\tdefault_args.permission_section = 'schedule';\n\t\tform_item_input.setDefaultArgs( default_args );\n\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Employee' ), form_item_input, tab_schedule_column1, '', null, true );\n\n\t\t//Status\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );\n\n\t\tform_item_input.TComboBox( { field: 'status_id' } );\n\t\tform_item_input.setSourceData( $this.status_array );\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Status' ), form_item_input, tab_schedule_column1 );\n\n\t\t//Absence Policy\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );\n\n\t\tform_item_input.AComboBox( {\n\t\t\tapi_class: TTAPI.APIAbsencePolicy,\n\t\t\tallow_multiple_selection: false,\n\t\t\tlayout_name: 'global_absences',\n\t\t\tshow_search_inputs: true,\n\t\t\tset_empty: true,\n\t\t\tfield: 'absence_policy_id'\n\t\t} );\n\n\t\tform_item_input.customSearchFilter = function( filter ) {\n\t\t\treturn $this.setAbsencePolicyFilter( filter );\n\t\t};\n\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Absence Policy' ), form_item_input, tab_schedule_column1, '', null, true );\n\n\t\t//Available Balance\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.TEXT );\n\t\tform_item_input.TText( { field: 'available_balance' } );\n\n\t\twidgetContainer = $( '
' );\n\t\tthis.available_balance_info = $( '' );\n\n\t\twidgetContainer.append( form_item_input );\n\t\twidgetContainer.append( this.available_balance_info );\n\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Available Balance' ), form_item_input, tab_schedule_column1, '', widgetContainer, true );\n\n\t\tif ( !this.current_edit_record || ( this.current_edit_record.user_ids && this.current_edit_record.user_ids.length > 1 ) ) {\n\t\t\tthis.detachElement( 'available_balance' );\n\t\t}\n\n\t\t//Date\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.DATE_PICKER );\n\n\t\tform_item_input.TDatePicker( { field: 'start_date_stamp', validation_field: 'date_stamp' } );\n\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Date' ), form_item_input, tab_schedule_column1, '', null, true );\n\n\t\t//Dates\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.DATE_PICKER );\n\n\t\tform_item_input.TRangePicker( { field: 'start_date_stamps' } );\n\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Date' ), form_item_input, tab_schedule_column1, '', null, true );\n\n\t\t//Mass Add Date\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );\n\n\t\tform_item_input.AComboBox( {\n\t\t\tallow_multiple_selection: true,\n\t\t\tlayout_name: 'global_option_column',\n\t\t\tshow_search_inputs: false,\n\t\t\tset_empty: true,\n\t\t\tfield: 'start_dates'\n\t\t} );\n\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Date' ), form_item_input, tab_schedule_column1, '', null, true );\n\n\t\t//Start Time\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.TIME_PICKER );\n\t\tform_item_input.TTimePicker( { field: 'start_time' } );\n\n\t\tthis.addEditFieldToColumn( $.i18n._( 'In' ), form_item_input, tab_schedule_column1, '', null, true );\n\n\t\t//End Time\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.TIME_PICKER );\n\t\tform_item_input.TTimePicker( { field: 'end_time' } );\n\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Out' ), form_item_input, tab_schedule_column1, '', null, true );\n\n\t\t//Total\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.TEXT );\n\t\tform_item_input.TText( { field: 'total_time' } );\n\t\tform_item_input.css( 'cursor', 'pointer' );\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Total' ), form_item_input, tab_schedule_column1 );\n\n\t\t//Schedule Policy\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );\n\n\t\tform_item_input.AComboBox( {\n\t\t\tapi_class: TTAPI.APISchedulePolicy,\n\t\t\tallow_multiple_selection: false,\n\t\t\tlayout_name: 'global_schedule',\n\t\t\tshow_search_inputs: true,\n\t\t\tset_empty: true,\n\t\t\tfield: 'schedule_policy_id'\n\t\t} );\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Schedule Policy' ), form_item_input, tab_schedule_column1 );\n\n\t\t//Default Branch\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );\n\n\t\tform_item_input.AComboBox( {\n\t\t\tapi_class: TTAPI.APIBranch,\n\t\t\tallow_multiple_selection: false,\n\t\t\tlayout_name: 'global_branch',\n\t\t\tshow_search_inputs: true,\n\t\t\tset_empty: true,\n\t\t\tfield: 'branch_id',\n\t\t\taddition_source_function: ( function( target, source_data ) {\n\t\t\t\treturn $this.onSourceDataCreate( target, source_data );\n\t\t\t} ),\n\t\t\t//FIXME: Follow -2 to the API do not switch to UUID unless absolutely necessary?\n\t\t\tadded_items: [\n\t\t\t\t{ value: TTUUID.not_exist_id, label: Global.default_item },\n\t\t\t\t{ value: '-2', label: Global.selected_item }\n\t\t\t]\n\t\t} );\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Branch' ), form_item_input, tab_schedule_column1, '', null, true );\n\n\t\tif ( !this.show_branch_ui ) {\n\t\t\tthis.detachElement( 'branch_id' );\n\n\t\t}\n\n\t\t//Department\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );\n\n\t\tform_item_input.AComboBox( {\n\t\t\tapi_class: TTAPI.APIDepartment,\n\t\t\tallow_multiple_selection: false,\n\t\t\tlayout_name: 'global_department',\n\t\t\tshow_search_inputs: true,\n\t\t\tset_empty: true,\n\t\t\tfield: 'department_id',\n\t\t\taddition_source_function: ( function( target, source_data ) {\n\t\t\t\treturn $this.onSourceDataCreate( target, source_data );\n\t\t\t} ),\n\t\t\tadded_items: [\n\t\t\t\t{ value: TTUUID.not_exist_id, label: Global.default_item },\n\t\t\t\t{ value: '-2', label: Global.selected_item }\n\t\t\t]\n\t\t} );\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Department' ), form_item_input, tab_schedule_column1, '', null, true );\n\n\t\tif ( !this.show_department_ui ) {\n\t\t\tthis.detachElement( 'department_id' );\n\n\t\t}\n\n\t\tif ( Global.getProductEdition() >= 20 ) {\n\t\t\t//Job\n\t\t\tform_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );\n\n\t\t\tform_item_input.AComboBox( {\n\t\t\t\tapi_class: TTAPI.APIJob,\n\t\t\t\tallow_multiple_selection: false,\n\t\t\t\tlayout_name: 'global_job',\n\t\t\t\tshow_search_inputs: true,\n\t\t\t\tset_empty: true,\n\t\t\t\tsetRealValueCallBack: ( function( val ) {\n\n\t\t\t\t\tif ( val ) {\n\t\t\t\t\t\tjob_coder.setValue( val.manual_id );\n\t\t\t\t\t}\n\t\t\t\t} ),\n\t\t\t\tfield: 'job_id',\n\t\t\t\taddition_source_function: ( function( target, source_data ) {\n\t\t\t\t\treturn $this.onSourceDataCreate( target, source_data );\n\t\t\t\t} ),\n\t\t\t\tadded_items: [\n\t\t\t\t\t{ value: TTUUID.not_exist_id, label: Global.default_item },\n\t\t\t\t\t{ value: '-2', label: Global.selected_item }\n\t\t\t\t]\n\t\t\t} );\n\n\t\t\twidgetContainer = $( '
' );\n\n\t\t\tvar job_coder = Global.loadWidgetByName( FormItemType.TEXT_INPUT );\n\t\t\tjob_coder.TTextInput( { field: 'job_quick_search', disable_keyup_event: true } );\n\t\t\tjob_coder.addClass( 'job-coder' );\n\n\t\t\twidgetContainer.append( job_coder );\n\t\t\twidgetContainer.append( form_item_input );\n\t\t\tthis.addEditFieldToColumn( $.i18n._( 'Job' ), [form_item_input, job_coder], tab_schedule_column1, '', widgetContainer, true );\n\n\t\t\tif ( !this.show_job_ui ) {\n\t\t\t\tthis.detachElement( 'job_id' );\n\t\t\t}\n\n\t\t\t//Job Item\n\t\t\tform_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );\n\n\t\t\tform_item_input.AComboBox( {\n\t\t\t\tapi_class: TTAPI.APIJobItem,\n\t\t\t\tallow_multiple_selection: false,\n\t\t\t\tlayout_name: 'global_job_item',\n\t\t\t\tshow_search_inputs: true,\n\t\t\t\tset_empty: true,\n\t\t\t\tsetRealValueCallBack: ( function( val ) {\n\n\t\t\t\t\tif ( val ) {\n\t\t\t\t\t\tjob_item_coder.setValue( val.manual_id );\n\t\t\t\t\t}\n\t\t\t\t} ),\n\t\t\t\tfield: 'job_item_id',\n\t\t\t\taddition_source_function: ( function( target, source_data ) {\n\t\t\t\t\treturn $this.onSourceDataCreate( target, source_data );\n\t\t\t\t} ),\n\t\t\t\tadded_items: [\n\t\t\t\t\t{ value: TTUUID.not_exist_id, label: Global.default_item },\n\t\t\t\t\t{ value: '-2', label: Global.selected_item }\n\t\t\t\t]\n\t\t\t} );\n\n\t\t\twidgetContainer = $( '
' );\n\n\t\t\tvar job_item_coder = Global.loadWidgetByName( FormItemType.TEXT_INPUT );\n\t\t\tjob_item_coder.TTextInput( { field: 'job_item_quick_search', disable_keyup_event: true } );\n\t\t\tjob_item_coder.addClass( 'job-coder' );\n\n\t\t\twidgetContainer.append( job_item_coder );\n\t\t\twidgetContainer.append( form_item_input );\n\t\t\tthis.addEditFieldToColumn( $.i18n._( 'Task' ), [form_item_input, job_item_coder], tab_schedule_column1, '', widgetContainer, true );\n\n\t\t\tif ( !this.show_job_item_ui ) {\n\t\t\t\tthis.detachElement( 'job_item_id' );\n\t\t\t}\n\n\t\t\t//Punch Tag\n\t\t\tform_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );\n\n\t\t\tform_item_input.AComboBox( {\n\t\t\t\tapi_class: TTAPI.APIPunchTag,\n\t\t\t\tallow_multiple_selection: true,\n\t\t\t\tlayout_name: 'global_punch_tag',\n\t\t\t\tshow_search_inputs: true,\n\t\t\t\tset_empty: true,\n\t\t\t\tget_real_data_on_multi: true,\n\t\t\t\tsetRealValueCallBack: ( ( punch_tags, get_real_data ) => {\n\t\t\t\t\tif ( punch_tags ) {\n\t\t\t\t\t\tthis.setPunchTagQuickSearchManualIds( punch_tags, get_real_data );\n\t\t\t\t\t}\n\t\t\t\t} ),\n\t\t\t\tfield: 'punch_tag_id',\n\t\t\t\taddition_source_function: ( function( target, source_data ) {\n\t\t\t\t\treturn $this.onSourceDataCreatePunchTag( target, source_data );\n\t\t\t\t} ),\n\t\t\t\tadded_items: [\n\t\t\t\t\t{ value: TTUUID.not_exist_id, label: Global.default_item }\n\t\t\t\t]\n\t\t\t} );\n\n\t\t\twidgetContainer = $( '
' );\n\n\t\t\tvar punch_tag_coder = Global.loadWidgetByName( FormItemType.TEXT_INPUT );\n\t\t\tpunch_tag_coder.TTextInput( { field: 'punch_tag_quick_search', disable_keyup_event: true } );\n\t\t\tpunch_tag_coder.addClass( 'job-coder' );\n\n\t\t\twidgetContainer.append( punch_tag_coder );\n\t\t\twidgetContainer.append( form_item_input );\n\t\t\tthis.addEditFieldToColumn( $.i18n._( 'Tags' ), [form_item_input, punch_tag_coder], tab_schedule_column1, '', widgetContainer, true );\n\n\n\t\t\tif ( !this.show_punch_tag_ui ) {\n\t\t\t\tthis.detachElement( 'punch_tag_id' );\n\t\t\t}\n\t\t}\n\n\t\t//Note\n\t\tform_item_input = Global.loadWidgetByName( FormItemType.TEXT_AREA );\n\t\tform_item_input.TTextArea( { field: 'note', width: '100%' } );\n\t\tthis.addEditFieldToColumn( $.i18n._( 'Note' ), form_item_input, tab_schedule_column1, '', null, null, true );\n\t\tform_item_input.parent().width( '45%' );\n\n\t\tif ( Global.getProductEdition() >= 15 && this.is_viewing == false ) {\n\t\t\t//Notify Employee\n\t\t\tform_item_input = Global.loadWidgetByName( FormItemType.CHECKBOX );\n\t\t\tform_item_input.TCheckbox( { field: 'notify_user_schedule_change' } );\n\t\t\tthis.addEditFieldToColumn( $.i18n._( 'Notify Employee' ), form_item_input, tab_schedule_column1, '', null, true );\n\t\t}\n\n\t\tTTPromise.resolve( 'Schedule', 'init' );\n\t}\n\n\tsetDefaultMenuDeleteIcon( context_btn, grid_selected_length ) {\n\t\tif ( !this.deletePermissionValidate( 'schedule' ) || this.edit_only_mode ) {\n\t\t\tContextMenuManager.hideMenuItem( this.determineContextMenuMountAttributes().id, context_btn.id, false )\n\t\t}\n\n\t\tif ( grid_selected_length > 0 && this.deleteOwnerOrChildPermissionValidate( 'schedule' ) ) {\n\t\t\tContextMenuManager.disableMenuItem( this.determineContextMenuMountAttributes().id, context_btn.id, true );\n\t\t} else {\n\t\t\tContextMenuManager.disableMenuItem( this.determineContextMenuMountAttributes().id, context_btn.id, false );\n\t\t}\n\t}\n\n\tonAvailableBalanceChange() {\n\t\tif ( this.current_edit_record.status_id == 20\n\t\t\t&& this.current_edit_record.hasOwnProperty( 'absence_policy_id' )\n\t\t\t&& this.current_edit_record.absence_policy_id && !this.is_mass_editing ) {\n\t\t\tthis.getAvailableBalance();\n\t\t} else {\n\t\t\tthis.detachElement( 'available_balance' );\n\t\t}\n\t}\n\n\tparserDatesRange( date ) {\n\t\tvar dates = date.split( ' - ' );\n\t\tvar resultArray = [];\n\t\tvar beginDate = Global.strToDate( dates[0] );\n\t\tvar endDate = Global.strToDate( dates[1] );\n\n\t\tvar nextDate = beginDate;\n\n\t\twhile ( nextDate.getTime() < endDate.getTime() ) {\n\t\t\tresultArray.push( nextDate.format() );\n\t\t\tnextDate = new Date( new Date( nextDate.getTime() ).setDate( nextDate.getDate() + 1 ) );\n\t\t}\n\n\t\tresultArray.push( dates[1] );\n\n\t\treturn resultArray;\n\t}\n\n\tgetSelectUsersArray() {\n\t\tvar result = [];\n\t\tvar cells_array = this.select_cells_Array;\n\t\tvar len = cells_array.length;\n\t\tvar date_dic = {};\n\n\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\tvar item = cells_array[i];\n\n\t\t\t// If select empty cell with no user inside, set user_id to 0 as OPEN\n\t\t\tif ( !item.user_id ) {\n\t\t\t\titem.user_id = TTUUID.zero_id;\n\t\t\t}\n\n\t\t\tdate_dic[item.user_id] = true;\n\t\t}\n\n\t\tfor ( var key in date_dic ) {\n\t\t\tresult.push( key );\n\t\t}\n\n\t\tif ( result.length === 0 ) {\n\t\t\tresult.push( this.getDefaultUser() );\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetSelectDateArray() {\n\t\tvar result = [];\n\n\t\tvar cells_array = this.select_cells_Array;\n\n\t\tvar len = cells_array.length;\n\n\t\tvar date_dic = {};\n\t\tfor ( var i = 0; i < len; i++ ) {\n\t\t\tvar item = cells_array[i];\n\n\t\t\tif ( item.date ) {\n\t\t\t\tdate_dic[item.date] = true;\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( var key in date_dic ) {\n\t\t\tresult.push( key );\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetAvailableBalance() {\n\t\tvar $this = this;\n\t\tvar user_id = this.current_edit_record.user_id;\n\t\tvar total_time = this.current_edit_record.total_time;\n\t\tvar last_date_stamp = this.current_edit_record.start_date_stamp;\n\n\t\t//On first run, set previous_absence_policy_id.\n\t\tif ( this.previous_absence_policy_id == false ) {\n\t\t\tthis.previous_absence_policy_id = this.current_edit_record.absence_policy_id;\n\t\t}\n\n\t\t//For mass adding case, select multiple cells and click new\n\t\tif ( this.is_mass_adding ) {\n\t\t\tif ( this.current_edit_record.user_ids.length > 1 ) {\n\t\t\t\tthis.detachElement( 'available_balance' );\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tuser_id = this.current_edit_record.user_ids[0];\n\t\t\t\tif ( !user_id ) {\n\t\t\t\t\tthis.detachElement( 'available_balance' );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttotal_time = total_time * this.current_edit_record.start_dates.length;\n\t\t\tlast_date_stamp = this.current_edit_record.start_dates[this.current_edit_record.start_dates.length - 1];\n\t\t} else {\n\t\t\t//get dates from date ranger\n\t\t\tif ( last_date_stamp.indexOf( ' - ' ) > 0 || $.type( last_date_stamp ) === 'array' ) {\n\t\t\t\tif ( last_date_stamp.indexOf( ' - ' ) > 0 ) {\n\t\t\t\t\tlast_date_stamp = this.parserDatesRange( last_date_stamp );\n\t\t\t\t}\n\n\t\t\t\tif ( last_date_stamp.length > 0 ) {\n\t\t\t\t\ttotal_time = total_time * last_date_stamp.length;\n\t\t\t\t\tlast_date_stamp = last_date_stamp[last_date_stamp.length - 1];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ( !this.current_edit_record || !this.current_edit_record.id || this.current_edit_record.id == TTUUID.zero_id ) && !this.is_mass_editing ) {\n\t\t\t\tif ( this.current_edit_record.user_ids.length < 1 || this.current_edit_record.user_ids.length > 1 ) {\n\t\t\t\t\tthis.detachElement( 'available_balance' );\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\tuser_id = this.current_edit_record.user_ids[0];\n\t\t\t\t\tif ( !user_id ) {\n\t\t\t\t\t\tthis.detachElement( 'available_balance' );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//Check if the user is editing a existing record that was originally Status=Working, and changing it to Status=Absent, in that case we can't adjust for the existing total time and must clear it out.\n\t\tif ( this.current_edit_record && this.current_edit_record.id && this.prev_status_id == 10 && this.edit_view_ui_dic['status_id'].getValue() == 20 ) {\n\t\t\tthis.prev_total_time = 0;\n\t\t}\n\n\t\tif ( this.current_edit_record.absence_policy_id != TTUUID.zero_id ) {\n\t\t\tthis.api_absence_policy.getProjectedAbsencePolicyBalance(\n\t\t\t\tthis.current_edit_record.absence_policy_id,\n\t\t\t\tuser_id,\n\t\t\t\tlast_date_stamp,\n\t\t\t\ttotal_time,\n\t\t\t\tthis.prev_total_time,\n\t\t\t\tthis.previous_absence_policy_id, {\n\t\t\t\t\tonResult: function( result ) {\n\t\t\t\t\t\t$this.getBalanceHandler( result, last_date_stamp );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tthis.getBalanceHandler( false, last_date_stamp );\n\t\t}\n\t}\n\n\tbuildSearchAndLayoutUI() {\n\t\tvar layout_div = this.search_panel.find( 'div #saved_layout_content_div' );\n\n\t\t//Display Columns\n\n\t\tvar form_item = $( $.fn.SearchPanel.html.form_item );\n\t\tvar form_item_label = form_item.find( '.form-item-label' );\n\t\tvar form_item_input_div = form_item.find( '.form-item-input-div' );\n\n\t\tthis.column_selector = Global.loadWidgetByName( FormItemType.AWESOME_DROPDOWN );\n\n\t\tthis.column_selector = this.column_selector.ADropDown( {\n\t\t\tdisplay_show_all: false,\n\t\t\tid: 'column_selector',\n\t\t\tkey: 'value',\n\t\t\tallow_drag_to_order: true,\n\t\t\tdisplay_close_btn: false,\n\t\t\tdisplay_column_settings: false,\n\t\t\tstatic_height: 150\n\t\t} );\n\n\t\tform_item_label.text( $.i18n._( 'Display Columns' ) );\n\t\tform_item_input_div.append( this.column_selector );\n\n\t\tlayout_div.append( form_item );\n\n\t\tlayout_div.append( '
' );\n\n\t\tthis.column_selector.setColumns( [\n\t\t\t{ name: 'label', index: 'label', label: $.i18n._( 'Column Name' ), width: 100, sortable: false }\n\t\t] );\n\n\t\t//Save and update layout\n\n\t\tform_item = $( $.fn.SearchPanel.html.form_item );\n\t\tform_item_label = form_item.find( '.form-item-label' );\n\t\tform_item_input_div = form_item.find( '.form-item-input-div' );\n\n\t\tform_item_label.text( $.i18n._( 'Save Search As' ) );\n\n\t\tthis.save_search_as_input = Global.loadWidgetByName( FormItemType.TEXT_INPUT );\n\t\tthis.save_search_as_input.TTextInput();\n\n\t\tvar save_btn = $( '' );\n\n\t\tform_item_input_div.append( this.save_search_as_input );\n\t\tform_item_input_div.append( save_btn );\n\n\t\tvar $this = this;\n\t\tsave_btn.click( function() {\n\t\t\t$this.onSaveNewLayout();\n\t\t} );\n\n\t\t//Previous Saved Layout\n\n\t\tthis.previous_saved_layout_div = $( '
' );\n\n\t\tform_item_input_div.append( this.previous_saved_layout_div );\n\n\t\tform_item_label = $( '' + $.i18n._( 'Previous Saved Searches' ) + ':' );\n\t\tthis.previous_saved_layout_div.append( form_item_label );\n\n\t\tthis.previous_saved_layout_selector = $( '