~jlungo/zhris/trunk

« back to all changes in this revision

Viewing changes to interface/html5/views/payperiod/PayPeriodScheduleViewController.js

  • Committer: Juma Lungo
  • Date: 2017-11-16 08:54:53 UTC
  • Revision ID: juma.lungo@zalongwa.com-20171116085453-q3jxht0gcab8jbya
codebase commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
PayPeriodScheduleViewController = BaseViewController.extend( {
 
2
 
 
3
        el: '#pay_period_schedule_view_container', //Must set el here and can only set string, so events can work
 
4
        user_preference_api: null,
 
5
        type_array: null,
 
6
        pay_period_starts_on_array: null,
 
7
        start_week_day_array: null,
 
8
        transaction_date_array: null,
 
9
        transaction_date_business_day_array: null,
 
10
        time_zone_array: null,
 
11
        shift_assigned_day_array: null,
 
12
        timesheet_verify_type_array: null,
 
13
        sub_pay_periods_view_controller: null,
 
14
 
 
15
        initialize: function( options ) {
 
16
 
 
17
                this._super( 'initialize', options );
 
18
                this.edit_view_tpl = 'PayPeriodScheduleEditView.html';
 
19
                this.permission_id = 'pay_period_schedule';
 
20
                this.viewId = 'PayPeriodSchedule';
 
21
                this.script_name = 'PayPeriodScheduleView';
 
22
                this.table_name_key = 'pay_period_schedule';
 
23
                this.context_menu_name = $.i18n._( 'Pay Period Schedule' );
 
24
                this.navigation_label = $.i18n._( 'Pay Period Schedule' ) + ':';
 
25
                this.api = new (APIFactory.getAPIClass( 'APIPayPeriodSchedule' ))();
 
26
                this.user_preference_api = new (APIFactory.getAPIClass( 'APIUserPreference' ))();
 
27
 
 
28
                this.invisible_context_menu_dic[ContextMenuIconName.copy] = true; //Hide some context menus
 
29
                this.invisible_context_menu_dic[ContextMenuIconName.mass_edit] = true;
 
30
                this.render();
 
31
                this.buildContextMenu();
 
32
                this.initData();
 
33
 
 
34
                this.setSelectRibbonMenuIfNecessary( 'PayPeriodSchedule' );
 
35
 
 
36
        },
 
37
 
 
38
        openEditView: function( id ) {
 
39
                Global.setUINotready();
 
40
                TTPromise.add('init','init');
 
41
                TTPromise.wait();
 
42
 
 
43
                var $this = this;
 
44
 
 
45
                if ( $this.edit_only_mode ) {
 
46
 
 
47
                        $this.initOptions( function( result ) {
 
48
 
 
49
                                if ( !$this.edit_view ) {
 
50
                                        $this.initEditViewUI( $this.viewId, $this.edit_view_tpl );
 
51
                                }
 
52
 
 
53
                                $this.getPayPeriodScheduleData( id, function( result ) {
 
54
                                        // Waiting for the (APIFactory.getAPIClass( 'API' )) returns data to set the current edit record.
 
55
                                        $this.current_edit_record = result;
 
56
 
 
57
                                        $this.initEditView();
 
58
 
 
59
                                } );
 
60
 
 
61
                        } );
 
62
 
 
63
                } else {
 
64
                        if ( !this.edit_view ) {
 
65
                                this.initEditViewUI( $this.viewId, $this.edit_view_tpl );
 
66
                        }
 
67
 
 
68
 
 
69
                }
 
70
 
 
71
        },
 
72
 
 
73
        getPayPeriodScheduleData: function( id, callBack ) {
 
74
                var filter = {};
 
75
                filter.filter_data = {};
 
76
                filter.filter_data.id = [id];
 
77
 
 
78
                this.api['get' + this.api.key_name]( filter, {
 
79
                        onResult: function( result ) {
 
80
                                var result_data = result.getResult();
 
81
 
 
82
                                if ( !result_data ) {
 
83
                                        result_data = [];
 
84
                                }
 
85
                                result_data = result_data[0];
 
86
 
 
87
                                callBack( result_data );
 
88
 
 
89
                        }
 
90
                } );
 
91
        },
 
92
 
 
93
        initOptions: function( callBack ) {
 
94
                var $this = this;
 
95
 
 
96
                var options = [
 
97
                        {option_name: 'type'},
 
98
                        {option_name: 'transaction_date'},
 
99
                        {option_name: 'transaction_date_business_day'},
 
100
                        {option_name: 'shift_assigned_day'},
 
101
                        {option_name: 'time_zone', field_name: '', api: this.user_preference_api},
 
102
                        {option_name: 'timesheet_verify_type'},
 
103
                        {option_name: 'start_week_day'}
 
104
 
 
105
                ];
 
106
 
 
107
                this.initDropDownOptions( options, function( result ) {
 
108
 
 
109
                        $this.transaction_date_array.push( {
 
110
                                        fullValue: -1,
 
111
                                        value: -1,
 
112
                                        label: $.i18n._( '- Last Day Of Month -' ),
 
113
                                        id: 2000
 
114
                                }
 
115
                        );
 
116
 
 
117
                        $this.user_preference_api.getOptions( 'start_week_day', {
 
118
                                onResult: function( res ) {
 
119
                                        var result = res.getResult();
 
120
                                        $this.pay_period_starts_on_array = Global.buildRecordArray( result );
 
121
 
 
122
                                        if ( callBack ) {
 
123
                                                callBack( result ); // First to initialize drop down options, and then to initialize edit view UI.
 
124
                                        }
 
125
                                }
 
126
                        } );
 
127
 
 
128
                } );
 
129
 
 
130
        },
 
131
 
 
132
        onTabShow: function( e, ui ) {
 
133
 
 
134
                var key = this.edit_view_tab_selected_index;
 
135
                this.editFieldResize( key );
 
136
                if ( !this.current_edit_record ) {
 
137
                        return;
 
138
                }
 
139
 
 
140
                if ( this.edit_view_tab_selected_index === 2 ) {
 
141
 
 
142
                        if ( this.current_edit_record.id ) {
 
143
                                this.edit_view_tab.find( '#tab_pay_period' ).find( '.first-column-sub-view' ).css( 'display', 'block' );
 
144
                                this.initSubPayPeriodsView();
 
145
                        } else {
 
146
                                this.edit_view_tab.find( '#tab_pay_period' ).find( '.first-column-sub-view' ).css( 'display', 'none' );
 
147
                                this.edit_view.find( '.save-and-continue-div' ).css( 'display', 'block' );
 
148
                        }
 
149
 
 
150
                } else if ( this.edit_view_tab_selected_index === 3 ) {
 
151
 
 
152
                        if ( this.current_edit_record.id ) {
 
153
                                this.edit_view_tab.find( '#tab_audit' ).find( '.first-column-sub-view' ).css( 'display', 'block' );
 
154
                                this.initSubLogView( 'tab_audit' );
 
155
                        } else {
 
156
                                this.edit_view_tab.find( '#tab_audit' ).find( '.first-column-sub-view' ).css( 'display', 'none' );
 
157
                                this.edit_view.find( '.save-and-continue-div' ).css( 'display', 'block' );
 
158
                        }
 
159
                } else {
 
160
                        this.buildContextMenu( true );
 
161
                        this.setEditMenu();
 
162
                }
 
163
        },
 
164
 
 
165
        setTabStatus: function() {
 
166
 
 
167
                $( this.edit_view_tab.find( 'ul li a[ref="tab_pay_period_schedule"]' ) ).parent().show();
 
168
                if ( this.is_mass_editing ) {
 
169
                        $( this.edit_view_tab.find( 'ul li a[ref="tab_pay_period"]' ) ).parent().hide();
 
170
                        $( this.edit_view_tab.find( 'ul li a[ref="tab_audit"]' ) ).parent().hide();
 
171
                        this.edit_view_tab.tabs( 'select', 0 );
 
172
                } else {
 
173
                        $( this.edit_view_tab.find( 'ul li a[ref="tab_pay_period"]' ) ).parent().show();
 
174
                        if ( this.subAuditValidate() ) {
 
175
                                $( this.edit_view_tab.find( 'ul li a[ref="tab_audit"]' ) ).parent().show();
 
176
                        } else {
 
177
                                $( this.edit_view_tab.find( 'ul li a[ref="tab_audit"]' ) ).parent().hide();
 
178
                                this.edit_view_tab.tabs( 'select', 0 );
 
179
                        }
 
180
 
 
181
                }
 
182
 
 
183
                this.editFieldResize( 0 );
 
184
 
 
185
        },
 
186
 
 
187
        initTabData: function() {
 
188
                if ( this.edit_view_tab.tabs( 'option', 'selected' ) === 2 ) {
 
189
                        if ( this.current_edit_record.id ) {
 
190
                                this.edit_view_tab.find( '#tab_pay_period' ).find( '.first-column-sub-view' ).css( 'display', 'block' );
 
191
                                this.initSubPayPeriodsView();
 
192
                        } else {
 
193
                                this.edit_view_tab.find( '#tab_pay_period' ).find( '.first-column-sub-view' ).css( 'display', 'none' );
 
194
                                this.edit_view.find( '.save-and-continue-div' ).css( 'display', 'block' );
 
195
                        }
 
196
                } else if ( this.edit_view_tab.tabs( 'option', 'selected' ) === 3 ) {
 
197
                        if ( this.current_edit_record.id ) {
 
198
                                this.edit_view_tab.find( '#tab_audit' ).find( '.first-column-sub-view' ).css( 'display', 'block' );
 
199
                                this.initSubLogView( 'tab_audit' );
 
200
                        } else {
 
201
                                this.edit_view_tab.find( '#tab_audit' ).find( '.first-column-sub-view' ).css( 'display', 'none' );
 
202
                                this.edit_view.find( '.save-and-continue-div' ).css( 'display', 'block' );
 
203
                        }
 
204
                }
 
205
        },
 
206
 
 
207
        initSubPayPeriodsView: function() {
 
208
                var $this = this;
 
209
 
 
210
                if ( this.sub_pay_periods_view_controller ) {
 
211
                        this.sub_pay_periods_view_controller.buildContextMenu( true );
 
212
                        this.sub_pay_periods_view_controller.setDefaultMenu();
 
213
                        $this.sub_pay_periods_view_controller.parent_value = $this.current_edit_record.id;
 
214
                        $this.sub_pay_periods_view_controller.parent_edit_record = $this.current_edit_record;
 
215
                        $this.sub_pay_periods_view_controller.initData(); //Init data in this parent view
 
216
                        return;
 
217
                }
 
218
 
 
219
                Global.loadScript( 'views/payroll/pay_periods/PayPeriodsViewController.js', function() {
 
220
 
 
221
                        var tab_pay_period_schedule = $this.edit_view_tab.find( '#tab_pay_period' );
 
222
 
 
223
                        var firstColumn = tab_pay_period_schedule.find( '.first-column-sub-view' );
 
224
 
 
225
                        Global.trackView( 'Sub' + 'PayPeriods' + 'View' );
 
226
                        PayPeriodsViewController.loadSubView( firstColumn, beforeLoadView, afterLoadView );
 
227
 
 
228
                } );
 
229
 
 
230
                function beforeLoadView() {
 
231
 
 
232
                }
 
233
 
 
234
                function afterLoadView( subViewController ) {
 
235
 
 
236
                        $this.sub_pay_periods_view_controller = subViewController;
 
237
                        $this.sub_pay_periods_view_controller.parent_key = 'pay_period_schedule_id';
 
238
                        $this.sub_pay_periods_view_controller.parent_value = $this.current_edit_record.id;
 
239
                        $this.sub_pay_periods_view_controller.parent_edit_record = $this.current_edit_record;
 
240
                        $this.sub_pay_periods_view_controller.parent_view_controller = $this;
 
241
                        $this.sub_pay_periods_view_controller.initData(); //Init data in this parent view
 
242
                }
 
243
        },
 
244
 
 
245
        onFormItemChange: function( target, doNotValidate ) {
 
246
 
 
247
                this.setIsChanged( target );
 
248
                this.setMassEditingFieldsWhenFormChange( target );
 
249
                var key = target.getField();
 
250
                var c_value = target.getValue();
 
251
 
 
252
                this.current_edit_record[key] = c_value;
 
253
 
 
254
                if ( key === 'type_id' ) {
 
255
 
 
256
                        this.onTypeChange();
 
257
                } else if ( key === 'timesheet_verify_type_id' ) {
 
258
                        this.onVerifyTypeChange();
 
259
                }
 
260
 
 
261
                if ( !doNotValidate ) {
 
262
                        this.validate();
 
263
                }
 
264
        },
 
265
 
 
266
        removeEditView: function() {
 
267
 
 
268
                this._super( 'removeEditView' );
 
269
                this.sub_pay_periods_view_controller = null;
 
270
 
 
271
        },
 
272
 
 
273
        onVerifyTypeChange: function() {
 
274
                if ( this.current_edit_record.timesheet_verify_type_id === 10 ) {
 
275
                        this.detachElement( 'timesheet_verify_before_end_date' );
 
276
                        this.detachElement( 'timesheet_verify_before_transaction_date' );
 
277
                } else {
 
278
                        this.attachElement( 'timesheet_verify_before_end_date' );
 
279
                        this.attachElement( 'timesheet_verify_before_transaction_date' );
 
280
                }
 
281
 
 
282
                this.editFieldResize();
 
283
        },
 
284
 
 
285
        _continueDoCopyAsNew: function() {
 
286
                var $this = this;
 
287
                this.is_add = true;
 
288
 
 
289
                LocalCacheData.current_doing_context_action = 'copy_as_new';
 
290
 
 
291
                var selectedId;
 
292
 
 
293
                if ( Global.isSet( this.edit_view ) ) {
 
294
 
 
295
                        this.current_edit_record.id = '';
 
296
                        var navigation_div = this.edit_view.find( '.navigation-div' );
 
297
                        navigation_div.css( 'display', 'none' );
 
298
                        this.setEditMenu();
 
299
                        this.setTabStatus();
 
300
 
 
301
                        $this.onTypeChange(); //Override for this;
 
302
                        this.is_changed = false;
 
303
                        ProgressBar.closeOverlay();
 
304
 
 
305
                } else {
 
306
 
 
307
                        var filter = {};
 
308
                        var grid_selected_id_array = this.getGridSelectIdArray();
 
309
                        var grid_selected_length = grid_selected_id_array.length;
 
310
 
 
311
                        if ( grid_selected_length > 0 ) {
 
312
                                selectedId = grid_selected_id_array[0];
 
313
                        } else {
 
314
                                TAlertManager.showAlert( $.i18n._( 'No selected record' ) );
 
315
                                return;
 
316
                        }
 
317
 
 
318
                        filter.filter_data = {};
 
319
                        filter.filter_data.id = [selectedId];
 
320
 
 
321
                        this.api['get' + this.api.key_name]( filter, {
 
322
                                onResult: function( result ) {
 
323
 
 
324
                                        $this.onCopyAsNewResult( result );
 
325
 
 
326
                                }
 
327
                        } );
 
328
                }
 
329
 
 
330
        },
 
331
 
 
332
        onTypeChange: function() {
 
333
 
 
334
                if ( this.current_edit_record.type_id === 5 ) {
 
335
                        this.detachElement( 'anchor_date' );
 
336
                } else {
 
337
 
 
338
                        if ( this.current_edit_record.id ) {
 
339
                                this.detachElement( 'anchor_date' );
 
340
                        } else {
 
341
                                this.attachElement( 'anchor_date' );
 
342
                        }
 
343
 
 
344
                }
 
345
 
 
346
                if ( this.current_edit_record.type_id === 5 ) {
 
347
                        this.detachElement( 'primary' );
 
348
                        this.detachElement( 'primary_day_of_month' );
 
349
                        this.detachElement( 'primary_transaction_day_of_month' );
 
350
                        this.detachElement( 'secondary' );
 
351
                        this.detachElement( 'secondary_day_of_month' );
 
352
                        this.detachElement( 'secondary_transaction_day_of_month' );
 
353
                        this.attachElement( 'annual_pay_periods' );
 
354
                        this.detachElement( 'start_day_of_week' );
 
355
                        this.detachElement( 'transaction_date' );
 
356
                        this.detachElement( 'transaction_date_bd' );
 
357
 
 
358
                } else if ( this.current_edit_record.type_id === 10 || this.current_edit_record.type_id === 20 || this.current_edit_record.type_id === 100 || this.current_edit_record.type_id === 200 ) {
 
359
                        this.detachElement( 'primary' );
 
360
                        this.detachElement( 'primary_day_of_month' );
 
361
                        this.detachElement( 'primary_transaction_day_of_month' );
 
362
                        this.detachElement( 'secondary' );
 
363
                        this.detachElement( 'secondary_day_of_month' );
 
364
                        this.detachElement( 'secondary_transaction_day_of_month' );
 
365
                        this.detachElement( 'annual_pay_periods' );
 
366
                        this.attachElement( 'start_day_of_week' );
 
367
                        this.attachElement( 'transaction_date' );
 
368
                        this.attachElement( 'transaction_date_bd' );
 
369
 
 
370
                } else if ( this.current_edit_record.type_id === 30 ) {
 
371
                        this.attachElement( 'primary' );
 
372
                        this.attachElement( 'primary_day_of_month' );
 
373
                        this.attachElement( 'primary_transaction_day_of_month' );
 
374
                        this.attachElement( 'secondary' );
 
375
                        this.attachElement( 'secondary_day_of_month' );
 
376
                        this.attachElement( 'secondary_transaction_day_of_month' );
 
377
                        this.detachElement( 'annual_pay_periods' );
 
378
                        this.detachElement( 'start_day_of_week' );
 
379
                        this.detachElement( 'transaction_date' );
 
380
                        this.attachElement( 'transaction_date_bd' );
 
381
                } else if ( this.current_edit_record.type_id === 50 ) {
 
382
                        this.attachElement( 'primary' );
 
383
                        this.attachElement( 'primary_day_of_month' );
 
384
                        this.attachElement( 'primary_transaction_day_of_month' );
 
385
                        this.detachElement( 'secondary' );
 
386
                        this.detachElement( 'secondary_day_of_month' );
 
387
                        this.detachElement( 'secondary_transaction_day_of_month' );
 
388
                        this.detachElement( 'annual_pay_periods' );
 
389
                        this.detachElement( 'start_day_of_week' );
 
390
                        this.detachElement( 'transaction_date' );
 
391
                        this.attachElement( 'transaction_date_bd' );
 
392
                }
 
393
 
 
394
                this.editFieldResize();
 
395
        },
 
396
 
 
397
        setCurrentEditRecordData: function() {
 
398
                //Set current edit record data to all widgets
 
399
                for ( var key in this.current_edit_record ) {
 
400
                        var widget = this.edit_view_ui_dic[key];
 
401
                        if ( Global.isSet( widget ) ) {
 
402
                                switch ( key ) {
 
403
                                        default:
 
404
                                                widget.setValue( this.current_edit_record[key] );
 
405
                                                break;
 
406
                                }
 
407
 
 
408
                        }
 
409
                }
 
410
                this.onTypeChange();
 
411
                this.onVerifyTypeChange();
 
412
                this.collectUIDataToCurrentEditRecord();
 
413
                this.setEditViewDataDone();
 
414
        },
 
415
 
 
416
        buildEditViewUI: function() {
 
417
 
 
418
                this._super( 'buildEditViewUI' );
 
419
 
 
420
                var $this = this;
 
421
 
 
422
                this.setTabLabels( {
 
423
                        'tab_pay_period_schedule': $.i18n._( 'Pay Period Schedule' ),
 
424
                        'tab_advanced': $.i18n._( 'Advanced' ),
 
425
                        'tab_pay_period': $.i18n._( 'Pay Periods' ),
 
426
                        'tab_audit': $.i18n._( 'Audit' )
 
427
                } );
 
428
 
 
429
                if ( !this.edit_only_mode ) {
 
430
                        this.navigation.AComboBox( {
 
431
                                id: this.script_name + '_navigation',
 
432
                                api_class: (APIFactory.getAPIClass( 'APIPayPeriodSchedule' )),
 
433
                                allow_multiple_selection: false,
 
434
                                layout_name: ALayoutIDs.PAY_PERIOD_SCHEDULE,
 
435
                                navigation_mode: true,
 
436
                                show_search_inputs: true
 
437
                        } );
 
438
 
 
439
                        this.setNavigation();
 
440
                }
 
441
 
 
442
                //Tab 0 start
 
443
 
 
444
                var tab_pay_period_schedule = this.edit_view_tab.find( '#tab_pay_period_schedule' );
 
445
 
 
446
                var tab_pay_period_schedule_column1 = tab_pay_period_schedule.find( '.first-column' );
 
447
                this.edit_view_tabs[0] = [];
 
448
 
 
449
                this.edit_view_tabs[0].push( tab_pay_period_schedule_column1 );
 
450
 
 
451
                //Name
 
452
                var form_item_input = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
 
453
                form_item_input.TTextInput( {field: 'name', width: '100%'} );
 
454
                this.addEditFieldToColumn( $.i18n._( 'Name' ), form_item_input, tab_pay_period_schedule_column1, '' );
 
455
 
 
456
                form_item_input.parent().width( '45%' );
 
457
 
 
458
                // Description
 
459
                form_item_input = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
 
460
                form_item_input.TTextInput( {field: 'description', width: '100%'} );
 
461
                this.addEditFieldToColumn( $.i18n._( 'Description' ), form_item_input, tab_pay_period_schedule_column1 );
 
462
 
 
463
                form_item_input.parent().width( '45%' );
 
464
 
 
465
                // Pay Period Dates
 
466
                form_item_input = Global.loadWidgetByName( FormItemType.SEPARATED_BOX );
 
467
                form_item_input.SeparatedBox( {label: $.i18n._( 'Pay Period Dates' )} );
 
468
                this.addEditFieldToColumn( null, form_item_input, tab_pay_period_schedule_column1 );
 
469
 
 
470
                // Type
 
471
                form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
 
472
 
 
473
                form_item_input.TComboBox( {field: 'type_id'} );
 
474
                form_item_input.setSourceData( Global.addFirstItemToArray( $this.type_array ) );
 
475
                this.addEditFieldToColumn( $.i18n._( 'Type' ), form_item_input, tab_pay_period_schedule_column1 );
 
476
 
 
477
                // Primary
 
478
 
 
479
                form_item_input = Global.loadWidgetByName( FormItemType.SEPARATED_BOX );
 
480
                form_item_input.SeparatedBox( {label: $.i18n._( 'Primary' )} );
 
481
                this.addEditFieldToColumn( null, form_item_input, tab_pay_period_schedule_column1, '', null, true, false, 'primary' );
 
482
 
 
483
                // Pay Period Start Day of Month
 
484
                form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
 
485
 
 
486
                form_item_input.TComboBox( {field: 'primary_day_of_month'} );
 
487
                var widgetContainer = $( "<div class='widget-h-box'></div>" );
 
488
                var label = $( "<span class='widget-right-label'> " + $.i18n._( 'at 00:00' ) + "</span>" );
 
489
 
 
490
                widgetContainer.append( form_item_input );
 
491
                widgetContainer.append( label );
 
492
                form_item_input.setSourceData( Global.addFirstItemToArray( $this.transaction_date_array ) );
 
493
                this.addEditFieldToColumn( $.i18n._( 'Pay Period Start Day of Month' ), form_item_input, tab_pay_period_schedule_column1, '', widgetContainer, true );
 
494
 
 
495
                // Transaction Day Of Month
 
496
                form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
 
497
 
 
498
                form_item_input.TComboBox( {field: 'primary_transaction_day_of_month'} );
 
499
                form_item_input.setSourceData( Global.addFirstItemToArray( $this.transaction_date_array ) );
 
500
                this.addEditFieldToColumn( $.i18n._( 'Transaction Day Of Month' ), form_item_input, tab_pay_period_schedule_column1, '', null, true );
 
501
 
 
502
                // Secondary
 
503
                form_item_input = Global.loadWidgetByName( FormItemType.SEPARATED_BOX );
 
504
                form_item_input.SeparatedBox( {label: $.i18n._( 'Secondary' )} );
 
505
                this.addEditFieldToColumn( null, form_item_input, tab_pay_period_schedule_column1, '', null, true, false, 'secondary' );
 
506
 
 
507
                // Pay Period Start Day Of Month
 
508
                form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
 
509
 
 
510
                form_item_input.TComboBox( {field: 'secondary_day_of_month'} );
 
511
                widgetContainer = $( "<div class='widget-h-box'></div>" );
 
512
                label = $( "<span class='widget-right-label'> " + $.i18n._( 'at 00:00' ) + "</span>" );
 
513
 
 
514
                widgetContainer.append( form_item_input );
 
515
                widgetContainer.append( label );
 
516
                form_item_input.setSourceData( Global.addFirstItemToArray( $this.transaction_date_array ) );
 
517
                this.addEditFieldToColumn( $.i18n._( 'Pay Period Start Day of Month' ), form_item_input, tab_pay_period_schedule_column1, '', widgetContainer, true );
 
518
 
 
519
                // Transaction Day Of Month
 
520
                form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
 
521
 
 
522
                form_item_input.TComboBox( {field: 'secondary_transaction_day_of_month'} );
 
523
                form_item_input.setSourceData( Global.addFirstItemToArray( $this.transaction_date_array ) );
 
524
                this.addEditFieldToColumn( $.i18n._( 'Transaction Day Of Month' ), form_item_input, tab_pay_period_schedule_column1, '', null, true );
 
525
 
 
526
                // Annual Pay Periods
 
527
                form_item_input = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
 
528
 
 
529
                form_item_input.TTextInput( {field: 'annual_pay_periods'} );
 
530
                this.addEditFieldToColumn( $.i18n._( 'Annual Pay Periods' ), form_item_input, tab_pay_period_schedule_column1, '', null, true );
 
531
 
 
532
                // Pay Period Starts On
 
533
                form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
 
534
 
 
535
                form_item_input.TComboBox( {field: 'start_day_of_week'} );
 
536
                widgetContainer = $( "<div class='widget-h-box'></div>" );
 
537
                label = $( "<span class='widget-right-label'> " + $.i18n._( 'at 00:00' ) + "</span>" );
 
538
 
 
539
                widgetContainer.append( form_item_input );
 
540
                widgetContainer.append( label );
 
541
                form_item_input.setSourceData( Global.addFirstItemToArray( $this.pay_period_starts_on_array ) );
 
542
                this.addEditFieldToColumn( $.i18n._( 'Pay Period Starts On' ), form_item_input, tab_pay_period_schedule_column1, '', widgetContainer, true );
 
543
 
 
544
                // Transaction Date
 
545
                form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
 
546
 
 
547
                form_item_input.TComboBox( {field: 'transaction_date'} );
 
548
                widgetContainer = $( "<div class='widget-h-box'></div>" );
 
549
                label = $( "<span class='widget-right-label'> (" + $.i18n._( 'days after end of pay period' ) + ")</span>" );
 
550
 
 
551
                widgetContainer.append( form_item_input );
 
552
                widgetContainer.append( label );
 
553
                form_item_input.setSourceData( Global.addFirstItemToArray( $this.transaction_date_array ) );
 
554
                this.addEditFieldToColumn( $.i18n._( 'Transaction Date' ), form_item_input, tab_pay_period_schedule_column1, '', widgetContainer, true );
 
555
 
 
556
                // Transaction Always on Business Day
 
557
                form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
 
558
 
 
559
                form_item_input.TComboBox( {field: 'transaction_date_bd'} );
 
560
 
 
561
                form_item_input.setSourceData( Global.addFirstItemToArray( $this.transaction_date_business_day_array ) );
 
562
                this.addEditFieldToColumn( $.i18n._( 'Transaction Always on Business Day' ), form_item_input, tab_pay_period_schedule_column1, '', null, true );
 
563
 
 
564
                //Create Initial Pay Periods From
 
565
                form_item_input = Global.loadWidgetByName( FormItemType.DATE_PICKER );
 
566
 
 
567
                form_item_input.TDatePicker( {field: 'anchor_date'} );
 
568
                this.addEditFieldToColumn( $.i18n._( 'Create Initial Pay Periods From' ), form_item_input, tab_pay_period_schedule_column1, '', null, true );
 
569
 
 
570
                // employees
 
571
                form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
 
572
                form_item_input.AComboBox( {
 
573
                        api_class: (APIFactory.getAPIClass( 'APIUser' )),
 
574
                        allow_multiple_selection: true,
 
575
                        layout_name: ALayoutIDs.USER,
 
576
                        show_search_inputs: true,
 
577
                        set_empty: true,
 
578
                        field: 'user'
 
579
                } );
 
580
                this.addEditFieldToColumn( $.i18n._( 'Employees' ), form_item_input, tab_pay_period_schedule_column1 );
 
581
 
 
582
                //Tab 0 start
 
583
 
 
584
                var tab_advanced = this.edit_view_tab.find( '#tab_advanced' );
 
585
 
 
586
                var tab_advanced_column1 = tab_advanced.find( '.first-column' );
 
587
                this.edit_view_tabs[1] = [];
 
588
 
 
589
                this.edit_view_tabs[1].push( tab_advanced_column1 );
 
590
 
 
591
                // Overtime Week
 
592
                form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
 
593
 
 
594
                form_item_input.TComboBox( {field: 'start_week_day_id'} );
 
595
                form_item_input.setSourceData( Global.addFirstItemToArray( $this.start_week_day_array ) );
 
596
                this.addEditFieldToColumn( $.i18n._( 'Overtime Week' ), form_item_input, tab_advanced_column1, '' );
 
597
 
 
598
                // Time Zone
 
599
                form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
 
600
 
 
601
                form_item_input.TComboBox( {field: 'time_zone', set_empty: true} );
 
602
                form_item_input.setSourceData( Global.addFirstItemToArray( $this.time_zone_array ) );
 
603
                this.addEditFieldToColumn( $.i18n._( 'Time Zone' ), form_item_input, tab_advanced_column1 );
 
604
 
 
605
                // Minimum Time-Off Between Shifts
 
606
                form_item_input = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
 
607
                form_item_input.TTextInput( {field: 'new_day_trigger_time', mode: 'time_unit', need_parser_sec: true} );
 
608
 
 
609
                widgetContainer = $( "<div class='widget-h-box'></div>" );
 
610
                label = $( "<span class='widget-right-label'>(" + $.i18n._( 'Only for shifts that span midnight' ) + ")</span>" );
 
611
                widgetContainer.append( form_item_input );
 
612
                widgetContainer.append( label );
 
613
                this.addEditFieldToColumn( $.i18n._( 'Minimum Time-Off Between Shifts' ), form_item_input, tab_advanced_column1, '', widgetContainer );
 
614
 
 
615
                // Maximum Shift Time
 
616
                form_item_input = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
 
617
                form_item_input.TTextInput( {field: 'maximum_shift_time', mode: 'time_unit', need_parser_sec: true} );
 
618
 
 
619
                this.addEditFieldToColumn( $.i18n._( 'Maximum Shift Time' ), form_item_input, tab_advanced_column1, '', null );
 
620
 
 
621
                // Assign Shifts To
 
622
                form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
 
623
 
 
624
                form_item_input.TComboBox( {field: 'shift_assigned_day_id'} );
 
625
                form_item_input.setSourceData( Global.addFirstItemToArray( $this.shift_assigned_day_array ) );
 
626
                this.addEditFieldToColumn( $.i18n._( 'Assign Shifts To' ), form_item_input, tab_advanced_column1 );
 
627
 
 
628
                // TimeSheet Verification
 
629
                form_item_input = Global.loadWidgetByName( FormItemType.SEPARATED_BOX );
 
630
                form_item_input.SeparatedBox( {label: $.i18n._( 'TimeSheet Verification' )} );
 
631
                this.addEditFieldToColumn( null, form_item_input, tab_advanced_column1 );
 
632
 
 
633
                // Timesheet Verification
 
634
                form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
 
635
 
 
636
                form_item_input.TComboBox( {field: 'timesheet_verify_type_id'} );
 
637
                form_item_input.setSourceData( Global.addFirstItemToArray( $this.timesheet_verify_type_array ) );
 
638
                this.addEditFieldToColumn( $.i18n._( 'TimeSheet Verification' ), form_item_input, tab_advanced_column1 );
 
639
 
 
640
                // Verification Window Starts
 
641
                form_item_input = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
 
642
                form_item_input.TTextInput( {field: 'timesheet_verify_before_end_date', width: 30} );
 
643
 
 
644
                widgetContainer = $( "<div class='widget-h-box'></div>" );
 
645
                label = $( "<span class='widget-right-label'>" + $.i18n._( 'Day(s)' ) + ' (' + $.i18n._( 'Before Pay Period End Date' ) + ' )' + "</span>" );
 
646
                widgetContainer.append( form_item_input );
 
647
                widgetContainer.append( label );
 
648
                this.addEditFieldToColumn( $.i18n._( 'Verification Window Starts' ), form_item_input, tab_advanced_column1, '', widgetContainer, true );
 
649
 
 
650
                // Verification Windows Ends
 
651
                form_item_input = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
 
652
                form_item_input.TTextInput( {field: 'timesheet_verify_before_transaction_date', width: 30} );
 
653
 
 
654
                widgetContainer = $( "<div class='widget-h-box'></div>" );
 
655
                label = $( "<span class='widget-right-label'>" + $.i18n._( 'Day(s)' ) + ' (' + $.i18n._( 'Before Pay Period Transaction Date' ) + ' )' + "</span>" );
 
656
                widgetContainer.append( form_item_input );
 
657
                widgetContainer.append( label );
 
658
                this.addEditFieldToColumn( $.i18n._( 'Verification Windows Ends' ), form_item_input, tab_advanced_column1, '', widgetContainer, true );
 
659
 
 
660
        },
 
661
 
 
662
        buildSearchFields: function() {
 
663
 
 
664
                this._super( 'buildSearchFields' );
 
665
 
 
666
                this.search_fields = [
 
667
 
 
668
                        new SearchField( {
 
669
                                label: $.i18n._( 'Name' ),
 
670
                                in_column: 1,
 
671
                                field: 'name',
 
672
                                basic_search: true,
 
673
                                form_item_type: FormItemType.TEXT_INPUT
 
674
                        } ),
 
675
                        new SearchField( {
 
676
                                label: $.i18n._( 'Type' ),
 
677
                                in_column: 1,
 
678
                                field: 'type_id',
 
679
                                multiple: true,
 
680
                                basic_search: true,
 
681
                                layout_name: ALayoutIDs.OPTION_COLUMN,
 
682
                                form_item_type: FormItemType.AWESOME_BOX
 
683
                        } ),
 
684
                        new SearchField( {
 
685
                                label: $.i18n._( 'Description' ),
 
686
                                in_column: 1,
 
687
                                field: 'description',
 
688
                                basic_search: true,
 
689
                                form_item_type: FormItemType.TEXT_INPUT
 
690
                        } ),
 
691
                        new SearchField( {
 
692
                                label: $.i18n._( 'Created By' ),
 
693
                                in_column: 2,
 
694
                                field: 'created_by',
 
695
                                layout_name: ALayoutIDs.USER,
 
696
                                api_class: (APIFactory.getAPIClass( 'APIUser' )),
 
697
                                multiple: true,
 
698
                                basic_search: true,
 
699
                                script_name: 'EmployeeView',
 
700
                                form_item_type: FormItemType.AWESOME_BOX
 
701
                        } ),
 
702
                        new SearchField( {
 
703
                                label: $.i18n._( 'Updated By' ),
 
704
                                in_column: 2,
 
705
                                field: 'updated_by',
 
706
                                layout_name: ALayoutIDs.USER,
 
707
                                api_class: (APIFactory.getAPIClass( 'APIUser' )),
 
708
                                multiple: true,
 
709
                                basic_search: true,
 
710
                                script_name: 'EmployeeView',
 
711
                                form_item_type: FormItemType.AWESOME_BOX
 
712
                        } )
 
713
 
 
714
                ];
 
715
 
 
716
        }
 
717
 
 
718
} );