1
UserDateTotalViewController = BaseViewController.extend( {
3
el: '#user_date_total_view_container', //Must set el here and can only set string, so events can work
5
initialize: function( options ) {
6
this._super( 'initialize', options );
7
this.edit_view_tpl = 'UserDateTotalEditView.html';
8
this.permission_id = 'user_date_total';
9
this.script_name = 'UserDateTotalView';
10
this.viewId = 'UserDateTotal';
11
this.table_name_key = 'user_date_total';
12
this.context_menu_name = $.i18n._( 'Accumulated Time' );
13
this.navigation_label = $.i18n._( 'Accumulated Time' ) + ':';
14
this.api = new (APIFactory.getAPIClass( 'APIUserDateTotal' ))();
15
this.currency_api = new (APIFactory.getAPIClass( 'APICurrency' ))();
17
if ( PermissionManager.validate( this.permission_id, 'add' ) || PermissionManager.validate( this.permission_id, 'edit' ) ) {
18
$(this.el).find('.warning-message').text($.i18n._('WARNING: Manually modifying Accumulated Time records may prevent policies from being calculated properly and should only be done as a last resort when instructed to do so by a support representative.'));
20
$(this.el).find('.warning-message').hide();
23
this.initPermission();
26
if ( this.sub_view_mode ) {
27
this.buildContextMenu( true );
29
this.buildContextMenu();
32
//call init data in parent view
33
if ( !this.sub_view_mode ) {
37
this.setSelectRibbonMenuIfNecessary();
41
setGridSize: function() {
42
if ( (!this.grid || !this.grid.is( ':visible' )) ) {
45
this.grid.setGridWidth( $( this.el ).parent().width() - 2 );
46
this.grid.setGridHeight( $( this.el ).parent().parent().parent().height() - 100 );
49
setGridCellBackGround: function() {
51
var data = this.grid.getGridParam( 'data' );
53
//Error: TypeError: data is undefined in /interface/html5/framework/jquery.min.js?v=7.4.6-20141027-074127 line 2 > eval line 70
58
var len = data.length;
60
for ( var i = 0; i < len; i++ ) {
63
if ( item.is_override === true ) {
64
$( "tr[id='" + item.id + "']" ).addClass( 'user-data-total-override' );
69
initOptions: function() {
72
this.initDropDownOption( 'object_type' );
76
buildContextMenuModels: function() {
78
var menu = new RibbonMenu( {
79
label: this.context_menu_name,
80
id: this.viewId + 'ContextMenu',
85
var editor_group = new RibbonSubMenuGroup( {
86
label: $.i18n._( 'Editor' ),
87
id: this.viewId + 'Editor',
92
var other_group = new RibbonSubMenuGroup( {
93
label: $.i18n._( 'Other' ),
94
id: this.viewId + 'other',
99
var view = new RibbonSubMenu( {
100
label: $.i18n._( 'New' ),
101
id: ContextMenuIconName.add,
104
permission_result: true,
108
var view = new RibbonSubMenu( {
109
label: $.i18n._( 'View' ),
110
id: ContextMenuIconName.view,
113
permission_result: true,
117
var edit = new RibbonSubMenu( {
118
label: $.i18n._( 'Edit' ),
119
id: ContextMenuIconName.edit,
122
permission_result: true,
126
var mass_edit = new RibbonSubMenu( {
127
label: $.i18n._( 'Mass<br>Edit' ),
128
id: ContextMenuIconName.mass_edit,
130
icon: Icons.mass_edit,
131
permission_result: true,
135
var del = new RibbonSubMenu( {
136
label: $.i18n._( 'Delete' ),
137
id: ContextMenuIconName.delete_icon,
139
icon: Icons.delete_icon,
140
permission_result: true,
144
var delAndNext = new RibbonSubMenu( {
145
label: $.i18n._( 'Delete<br>& Next' ),
146
id: ContextMenuIconName.delete_and_next,
148
icon: Icons.delete_and_next,
149
permission_result: true,
153
var copy_as_new = new RibbonSubMenu( {
154
label: $.i18n._( 'Copy<br>as New' ),
155
id: ContextMenuIconName.copy_as_new,
158
permission_result: true,
162
var save = new RibbonSubMenu( {
163
label: $.i18n._( 'Save' ),
164
id: ContextMenuIconName.save,
167
permission_result: true,
171
var save_and_continue = new RibbonSubMenu( {
172
label: $.i18n._( 'Save<br>& Continue' ),
173
id: ContextMenuIconName.save_and_continue,
175
icon: Icons.save_and_continue,
176
permission_result: true,
180
var save_and_next = new RibbonSubMenu( {
181
label: $.i18n._( 'Save<br>& Next' ),
182
id: ContextMenuIconName.save_and_next,
184
icon: Icons.save_and_next,
185
permission_result: true,
189
var save_and_copy = new RibbonSubMenu( {
190
label: $.i18n._( 'Save<br>& Copy' ),
191
id: ContextMenuIconName.save_and_copy,
193
icon: Icons.save_and_copy,
194
permission_result: true,
198
var save_and_new = new RibbonSubMenu( {
199
label: $.i18n._( 'Save<br>& New' ),
200
id: ContextMenuIconName.save_and_new,
202
icon: Icons.save_and_new,
203
permission_result: true,
207
var cancel = new RibbonSubMenu( {
208
label: $.i18n._( 'Cancel' ),
209
id: ContextMenuIconName.cancel,
212
permission_result: true,
216
var import_csv = new RibbonSubMenu( {
217
label: $.i18n._( 'Import' ),
218
id: ContextMenuIconName.import_icon,
220
icon: Icons.import_icon,
221
permission_result: PermissionManager.checkTopLevelPermission( 'ImportCSVUserDateTotal' ),
230
onFormItemChange: function( target, doNotValidate ) {
232
this.setIsChanged( target );
233
this.setMassEditingFieldsWhenFormChange( target );
234
var key = target.getField();
235
var c_value = target.getValue();
236
this.current_edit_record[key] = c_value;
239
case 'object_type_id':
240
this.onTypeChange( true );
242
case 'regular_policy_id':
243
case 'absence_policy_id':
244
case 'overtime_policy_id':
245
case 'premium_policy_id':
246
case 'break_policy_id':
247
case 'meal_policy_id':
248
this.current_edit_record.src_object_id = c_value;
249
delete this.current_edit_record[key];
250
this.onSrcObjectChange( key );
254
this.calculateAmount();
258
if ( key !== 'override' ) {
259
this.edit_view_ui_dic.override.setValue( true );
260
this.current_edit_record.override = true;
263
if ( !doNotValidate ) {
269
calculateAmount: function() {
270
this.current_edit_record.total_time_amount = (this.current_edit_record.total_time / 3600) * parseFloat( this.current_edit_record.hourly_rate );
271
this.edit_view_ui_dic.total_time_amount.setValue( this.current_edit_record.total_time_amount.toFixed( 4 ) );
274
onAddClick: function() {
276
this.is_viewing = false;
277
this.is_edit = false;
279
LocalCacheData.current_doing_context_action = 'new';
280
$this.openEditView();
282
//Error: Uncaught TypeError: undefined is not a function in /interface/html5/views/BaseViewController.js?v=8.0.0-20141117-111140 line 897
284
$this.api['get' + $this.api.key_name + 'DefaultData'](
285
this.parent_edit_record.user_id,
286
this.parent_edit_record.date_stamp, {
287
onResult: function( result ) {
288
$this.onAddResult( result );
295
onAddResult: function( result ) {
297
var result_data = result.getResult();
299
if ( !result_data ) {
303
result_data.company = LocalCacheData.current_company.name;
305
if ( $this.sub_view_mode && $this.parent_key ) {
306
result_data[$this.parent_key] = $this.parent_value;
309
if ( !result_data.date_stamp ) {
310
result_data.date_stamp = this.parent_edit_record.date_stamp;
313
$this.current_edit_record = result_data;
314
$this.initEditView();
317
/* jshint ignore:start */
318
setDefaultMenu: function( doNotSetFocus ) {
321
//Error: Uncaught TypeError: Cannot read property 'length' of undefined in /interface/html5/#!m=Employee&a=edit&id=42411&tab=UserDateTotal line 282
322
if ( !this.context_menu_array ) {
326
if ( !Global.isSet( doNotSetFocus ) || !doNotSetFocus ) {
327
this.selectContextMenu();
330
this.setTotalDisplaySpan();
332
var len = this.context_menu_array.length;
334
var grid_selected_id_array = this.getGridSelectIdArray();
336
var grid_selected_length = grid_selected_id_array.length;
338
for ( var i = 0; i < len; i++ ) {
339
var context_btn = this.context_menu_array[i];
340
var id = $( context_btn.find( '.ribbon-sub-menu-icon' ) ).attr( 'id' );
341
context_btn.removeClass( 'invisible-image' );
342
context_btn.removeClass( 'disable-image' );
345
case ContextMenuIconName.add:
346
this.setDefaultMenuAddIcon( context_btn, grid_selected_length );
348
case ContextMenuIconName.edit:
349
this.setDefaultMenuEditIcon( context_btn, grid_selected_length );
351
case ContextMenuIconName.view:
352
this.setDefaultMenuViewIcon( context_btn, grid_selected_length );
354
case ContextMenuIconName.mass_edit:
355
this.setDefaultMenuMassEditIcon( context_btn, grid_selected_length );
357
case ContextMenuIconName.copy:
358
this.setDefaultMenuCopyIcon( context_btn, grid_selected_length );
360
case ContextMenuIconName.delete_icon:
361
this.setDefaultMenuDeleteIcon( context_btn, grid_selected_length );
363
case ContextMenuIconName.delete_and_next:
364
this.setDefaultMenuDeleteAndNextIcon( context_btn, grid_selected_length );
366
case ContextMenuIconName.save:
367
this.setDefaultMenuSaveIcon( context_btn, grid_selected_length );
369
case ContextMenuIconName.save_and_next:
370
this.setDefaultMenuSaveAndNextIcon( context_btn, grid_selected_length );
372
case ContextMenuIconName.save_and_continue:
373
this.setDefaultMenuSaveAndContinueIcon( context_btn, grid_selected_length );
375
case ContextMenuIconName.save_and_new:
376
this.setDefaultMenuSaveAndAddIcon( context_btn, grid_selected_length );
378
case ContextMenuIconName.save_and_copy:
379
this.setDefaultMenuSaveAndCopyIcon( context_btn, grid_selected_length );
381
case ContextMenuIconName.copy_as_new:
382
this.setDefaultMenuCopyAsNewIcon( context_btn, grid_selected_length );
384
case ContextMenuIconName.cancel:
385
this.setDefaultMenuCancelIcon( context_btn, grid_selected_length );
391
this.setContextMenuGroupVisibility();
395
/* jshint ignore:end */
397
initPermission: function() {
398
this._super( 'initPermission' );
400
if ( this.jobUIValidate() ) {
401
this.show_job_ui = true;
403
this.show_job_ui = false;
406
if ( this.jobItemUIValidate() ) {
407
this.show_job_item_ui = true;
409
this.show_job_item_ui = false;
412
if ( this.branchUIValidate() ) {
413
this.show_branch_ui = true;
415
this.show_branch_ui = false;
418
if ( this.departmentUIValidate() ) {
419
this.show_department_ui = true;
421
this.show_department_ui = false;
424
if ( this.goodQuantityUIValidate() ) {
425
this.show_good_quantity_ui = true;
427
this.show_good_quantity_ui = false;
430
if ( this.badQuantityUIValidate() ) {
431
this.show_bad_quantity_ui = true;
433
this.show_bad_quantity_ui = false;
436
if ( this.noteUIValidate() ) {
437
this.show_note_ui = true;
439
this.show_note_ui = false;
444
noteUIValidate: function( p_id ) {
450
if ( PermissionManager.validate( p_id, 'edit_note' ) ) {
456
branchUIValidate: function( p_id ) {
462
if ( PermissionManager.validate( p_id, 'edit_branch' ) ) {
468
departmentUIValidate: function( p_id ) {
474
if ( PermissionManager.validate( p_id, 'edit_department' ) ) {
480
jobUIValidate: function( p_id ) {
486
if ( PermissionManager.validate( "job", 'enabled' ) &&
487
PermissionManager.validate( p_id, 'edit_job' ) ) {
493
jobItemUIValidate: function( p_id ) {
499
if ( PermissionManager.validate( p_id, 'edit_job_item' ) ) {
505
goodQuantityUIValidate: function( p_id ) {
511
if ( PermissionManager.validate( p_id, 'edit_quantity' ) ) {
517
badQuantityUIValidate: function( p_id ) {
523
if ( PermissionManager.validate( p_id, 'edit_quantity' ) &&
524
PermissionManager.validate( p_id, 'edit_bad_quantity' ) ) {
530
setCurrency: function() {
532
if ( Global.isSet( this.current_edit_record.user_id ) ) {
534
filter.filter_data = {user_id: this.current_edit_record.user_id};
535
this.currency_api.getCurrency( filter, false, false, {
536
onResult: function( res ) {
537
res = res.getResult();
538
if ( Global.isArray( res ) ) {
539
$( '.userDateTotal-currency' ).text( res[0].symbol );
540
$( '.userDateTotal-code' ).text( res[0].iso_code );
542
$( '.userDateTotal-currency' ).text( '' );
543
$( '.userDateTotal-code' ).text( '' );
550
setCurrentEditRecordData: function() {
552
//Set current edit record data to all widgets
553
for ( var key in this.current_edit_record ) {
555
if ( !this.current_edit_record.hasOwnProperty( key ) ) {
558
var widget = this.edit_view_ui_dic[key];
561
var current_widget = this.edit_view_ui_dic['first_last_name'];
562
new (APIFactory.getAPIClass( 'APIUser' ))().getUser( {filter_data: {id: this.current_edit_record[key]}}, {
563
onResult: function( result ) {
565
if ( result.isValid() ) {
566
var user_data = result.getResult()[0];
569
//Error: Unable to get property 'first_name' of undefined or null reference in /interface/html5/ line 511
570
if ( user_data && user_data.first_name ) {
571
current_widget.setValue( user_data.first_name + ' ' + user_data.last_name );
573
current_widget.setValue( '' );
580
widget.setEnabled( false );
581
widget.setValue( this.current_edit_record[key] );
584
//Always default to true
585
this.current_edit_record.override = true;
586
widget.setValue( true );
590
widget.setValue( this.current_edit_record[key] );
596
this.collectUIDataToCurrentEditRecord();
597
this.setEditViewDataDone();
601
setEditViewDataDone: function() {
603
this._super( 'setEditViewDataDone' );
607
onTypeChange: function( reset ) {
608
this.detachElement( 'regular_policy_id' );
609
this.detachElement( 'absence_policy_id' );
610
this.detachElement( 'overtime_policy_id' );
611
this.detachElement( 'premium_policy_id' );
612
this.detachElement( 'meal_policy_id' );
613
this.detachElement( 'break_policy_id' );
615
if ( this.current_edit_record['object_type_id'] === 20 ) {
616
key = 'regular_policy_id';
617
} else if ( this.current_edit_record['object_type_id'] === 25 || this.current_edit_record['object_type_id'] === 50 ) {
618
key = 'absence_policy_id';
619
} else if ( this.current_edit_record['object_type_id'] === 30 ) {
620
key = 'overtime_policy_id';
621
} else if ( this.current_edit_record['object_type_id'] === 40 ) {
622
key = 'premium_policy_id';
623
} else if ( this.current_edit_record['object_type_id'] === 100 || this.current_edit_record['object_type_id'] === 101 ) {
624
key = 'meal_policy_id';
625
} else if ( this.current_edit_record['object_type_id'] === 110 || this.current_edit_record['object_type_id'] === 111 ) {
626
key = 'break_policy_id';
629
this.attachElement( key );
631
this.edit_view_ui_dic[key].setValue( '' );
632
this.edit_view_ui_dic['pay_code_id'].setValue( '' );
633
this.current_edit_record.src_object_id = false;
634
this.current_edit_record.pay_code_id = false;
635
this.edit_view_ui_dic['pay_code_id'].setEnabled( true );
636
} else if ( this.current_edit_record.src_object_id ) {
637
this.edit_view_ui_dic[key].setValue( this.current_edit_record.src_object_id );
638
this.edit_view_ui_dic['pay_code_id'].setEnabled( false );
641
this.edit_view_ui_dic['pay_code_id'].setEnabled( true );
642
this.current_edit_record.src_object_id = false;
644
this.editFieldResize();
647
onSrcObjectChange: function( key ) {
648
var full_value = this.edit_view_ui_dic[key].getValue( true );
649
if ( full_value && full_value.pay_code_id ) {
650
this.edit_view_ui_dic['pay_code_id'].setEnabled( false );
651
this.edit_view_ui_dic['pay_code_id'].setValue( full_value.pay_code_id );
652
this.current_edit_record.pay_code_id = full_value.pay_code_id;
654
this.edit_view_ui_dic['pay_code_id'].setEnabled( true );
655
this.edit_view_ui_dic['pay_code_id'].setValue( '' );
656
this.current_edit_record.pay_code_id = false;
661
search: function( set_default_menu, page_action, page_number, callBack ) {
663
this._super( 'search', set_default_menu, page_action, page_number, callBack )
666
getProperObjectType: function() {
669
for ( var i = 0; i < this.object_type_array.length; i++ ) {
670
var item = this.object_type_array[i];
672
if ( item.value === 20 ||
676
item.value === 100 ||
677
item.value === 110 ) {
686
buildEditViewUI: function() {
688
this._super( 'buildEditViewUI' );
693
'tab_user_date_total': $.i18n._( 'Accumulated Time' ),
694
'tab_audit': $.i18n._( 'Audit' )
697
this.navigation.AComboBox( {
698
api_class: (APIFactory.getAPIClass( 'APIUserDateTotal' )),
699
id: this.script_name + '_navigation',
700
allow_multiple_selection: false,
701
layout_name: ALayoutIDs.WAGE,
702
show_search_inputs: true,
703
navigation_mode: true
706
this.setNavigation();
710
var tab_user_date_total = this.edit_view_tab.find( '#tab_user_date_total' );
712
var tab_user_date_total_column1 = tab_user_date_total.find( '.first-column' );
713
var tab_user_date_total_column2 = tab_user_date_total.find( '.second-column' );
717
var form_item_input = Global.loadWidgetByName( FormItemType.TEXT );
718
form_item_input.TText( {field: 'first_last_name'} );
719
this.addEditFieldToColumn( $.i18n._( 'Employee' ), form_item_input, tab_user_date_total_column1, '' );
722
form_item_input = Global.loadWidgetByName( FormItemType.DATE_PICKER );
723
form_item_input.TDatePicker( {field: 'date_stamp'} );
725
this.addEditFieldToColumn( $.i18n._( 'Date' ), form_item_input, tab_user_date_total_column1 );
728
form_item_input = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
729
form_item_input.TTextInput( {field: 'total_time', mode: 'time_unit', need_parser_sec: true} );
731
this.addEditFieldToColumn( $.i18n._( 'Time' ), form_item_input, tab_user_date_total_column1, '', null, true );
734
form_item_input = Global.loadWidgetByName( FormItemType.COMBO_BOX );
736
form_item_input.TComboBox( {field: 'object_type_id'} );
737
form_item_input.setSourceData( Global.addFirstItemToArray( this.getProperObjectType() ) );
738
this.addEditFieldToColumn( $.i18n._( 'Type' ), form_item_input, tab_user_date_total_column1 );
741
form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
742
form_item_input.AComboBox( {
743
api_class: (APIFactory.getAPIClass( 'APIRegularTimePolicy' )),
744
allow_multiple_selection: false,
745
layout_name: ALayoutIDs.REGULAR_TIME_POLICY,
746
show_search_inputs: true,
748
field: 'regular_policy_id'
750
this.addEditFieldToColumn( $.i18n._( 'Policy' ), form_item_input, tab_user_date_total_column1, null, null, true );
751
this.detachElement( 'regular_policy_id' );
754
form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
755
form_item_input.AComboBox( {
756
api_class: (APIFactory.getAPIClass( 'APIAbsencePolicy' )),
757
allow_multiple_selection: false,
758
layout_name: ALayoutIDs.ABSENCES_POLICY,
759
show_search_inputs: true,
761
field: 'absence_policy_id'
763
this.addEditFieldToColumn( $.i18n._( 'Policy' ), form_item_input, tab_user_date_total_column1, null, null, true );
764
this.detachElement( 'absence_policy_id' );
767
form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
768
form_item_input.AComboBox( {
769
api_class: (APIFactory.getAPIClass( 'APIOvertimePolicy' )),
770
allow_multiple_selection: false,
771
layout_name: ALayoutIDs.OVER_TIME_POLICY,
772
show_search_inputs: true,
774
field: 'overtime_policy_id'
776
this.addEditFieldToColumn( $.i18n._( 'Policy' ), form_item_input, tab_user_date_total_column1, null, null, true );
777
this.detachElement( 'overtime_policy_id' );
780
form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
781
form_item_input.AComboBox( {
782
api_class: (APIFactory.getAPIClass( 'APIPremiumPolicy' )),
783
allow_multiple_selection: false,
784
layout_name: ALayoutIDs.PREMIUM_POLICY,
785
show_search_inputs: true,
787
field: 'premium_policy_id'
789
this.addEditFieldToColumn( $.i18n._( 'Policy' ), form_item_input, tab_user_date_total_column1, null, null, true );
790
this.detachElement( 'premium_policy_id' );
793
form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
794
form_item_input.AComboBox( {
795
api_class: (APIFactory.getAPIClass( 'APIMealPolicy' )),
796
allow_multiple_selection: false,
797
layout_name: ALayoutIDs.MEAL_POLICY,
798
show_search_inputs: true,
800
field: 'meal_policy_id'
802
this.addEditFieldToColumn( $.i18n._( 'Policy' ), form_item_input, tab_user_date_total_column1, null, null, true );
803
this.detachElement( 'meal_policy_id' );
806
form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
807
form_item_input.AComboBox( {
808
api_class: (APIFactory.getAPIClass( 'APIBreakPolicy' )),
809
allow_multiple_selection: false,
810
layout_name: ALayoutIDs.BREAK_POLICY,
811
show_search_inputs: true,
813
field: 'break_policy_id'
815
this.addEditFieldToColumn( $.i18n._( 'Policy' ), form_item_input, tab_user_date_total_column1, null, null, true );
816
this.detachElement( 'break_policy_id' );
819
form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
820
form_item_input.AComboBox( {
821
api_class: (APIFactory.getAPIClass( 'APIPayCode' )),
822
allow_multiple_selection: false,
823
layout_name: ALayoutIDs.PAY_CODE,
824
show_search_inputs: true,
828
this.addEditFieldToColumn( $.i18n._( 'Pay Code' ), form_item_input, tab_user_date_total_column1 );
831
form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
833
form_item_input.AComboBox( {
834
api_class: (APIFactory.getAPIClass( 'APIBranch' )),
835
allow_multiple_selection: false,
836
layout_name: ALayoutIDs.BRANCH,
837
show_search_inputs: true,
841
this.addEditFieldToColumn( $.i18n._( 'Branch' ), form_item_input, tab_user_date_total_column1, '', null, true );
843
if ( !this.show_branch_ui ) {
844
this.detachElement( 'branch_id' );
848
form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
850
form_item_input.AComboBox( {
851
api_class: (APIFactory.getAPIClass( 'APIDepartment' )),
852
allow_multiple_selection: false,
853
layout_name: ALayoutIDs.DEPARTMENT,
854
show_search_inputs: true,
856
field: 'department_id'
858
this.addEditFieldToColumn( $.i18n._( 'Department' ), form_item_input, tab_user_date_total_column1, '', null, true );
860
if ( !this.show_department_ui ) {
861
this.detachElement( 'department_id' );
864
if ( ( LocalCacheData.getCurrentCompany().product_edition_id >= 20 ) ) {
867
form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
869
form_item_input.AComboBox( {
870
api_class: (APIFactory.getAPIClass( 'APIJob' )),
871
allow_multiple_selection: false,
872
layout_name: ALayoutIDs.JOB,
873
show_search_inputs: true,
875
setRealValueCallBack: (function( val ) {
877
if ( val ) job_coder.setValue( val.manual_id );
882
widgetContainer = $( "<div class='widget-h-box'></div>" );
884
var job_coder = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
885
job_coder.TTextInput( {field: 'job_quick_search', disable_keyup_event: true} );
886
job_coder.addClass( 'job-coder' );
888
widgetContainer.append( job_coder );
889
widgetContainer.append( form_item_input );
890
this.addEditFieldToColumn( $.i18n._( 'Job' ), [form_item_input, job_coder], tab_user_date_total_column1, '', widgetContainer, true );
892
if ( !this.show_job_ui ) {
893
this.detachElement( 'job_id' );
897
form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
899
form_item_input.AComboBox( {
900
api_class: (APIFactory.getAPIClass( 'APIJobItem' )),
901
allow_multiple_selection: false,
902
layout_name: ALayoutIDs.JOB_ITEM,
903
show_search_inputs: true,
905
setRealValueCallBack: (function( val ) {
907
if ( val ) job_item_coder.setValue( val.manual_id );
912
widgetContainer = $( "<div class='widget-h-box'></div>" );
914
var job_item_coder = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
915
job_item_coder.TTextInput( {field: 'job_item_quick_search', disable_keyup_event: true} );
916
job_item_coder.addClass( 'job-coder' );
918
widgetContainer.append( job_item_coder );
919
widgetContainer.append( form_item_input );
920
this.addEditFieldToColumn( $.i18n._( 'Task' ), [form_item_input, job_item_coder], tab_user_date_total_column1, '', widgetContainer, true );
922
if ( !this.show_job_item_ui ) {
923
this.detachElement( 'job_item_id' );
929
form_item_input = Global.loadWidgetByName( FormItemType.DATE_PICKER );
930
form_item_input.TDatePicker( {field: 'start_time_stamp', mode: 'date_time'} );
931
this.addEditFieldToColumn( $.i18n._( 'Start Date/Time' ), form_item_input, tab_user_date_total_column2, '', null, true, true );
934
form_item_input = Global.loadWidgetByName( FormItemType.DATE_PICKER );
935
form_item_input.TDatePicker( {field: 'end_time_stamp', mode: 'date_time'} );
936
this.addEditFieldToColumn( $.i18n._( 'End Date/Time' ), form_item_input, tab_user_date_total_column2, '', null, true, true );
939
form_item_input = Global.loadWidgetByName( FormItemType.AWESOME_BOX );
940
form_item_input.AComboBox( {
941
api_class: (APIFactory.getAPIClass( 'APICurrency' )),
942
allow_multiple_selection: false,
943
layout_name: ALayoutIDs.CURRENCY,
944
show_search_inputs: true,
945
field: 'currency_id',
948
this.addEditFieldToColumn( $.i18n._( 'Currency' ), form_item_input, tab_user_date_total_column2 );
951
form_item_input = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
952
form_item_input.TTextInput( {field: 'base_hourly_rate', width: 90} );
954
widgetContainer = $( "<div class='widget-h-box'></div>" );
955
var currency = $( "<span class='userDateTotal-currency widget-left-label'></span>" );
956
var code = $( "<span class='userDateTotal-code widget-right-label'></span>" );
957
widgetContainer.append( currency );
958
widgetContainer.append( form_item_input );
959
widgetContainer.append( code );
961
this.addEditFieldToColumn( $.i18n._( 'Base Hourly Rate' ), form_item_input, tab_user_date_total_column2, '', widgetContainer, true );
964
form_item_input = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
965
form_item_input.TTextInput( {field: 'hourly_rate', width: 90} );
967
widgetContainer = $( "<div class='widget-h-box'></div>" );
968
currency = $( "<span class='userDateTotal-currency widget-left-label'></span>" );
969
code = $( "<span class='userDateTotal-code widget-right-label'></span>" );
970
widgetContainer.append( currency );
971
widgetContainer.append( form_item_input );
972
widgetContainer.append( code );
974
this.addEditFieldToColumn( $.i18n._( 'Hourly Rate' ), form_item_input, tab_user_date_total_column2, '', widgetContainer, true );
977
form_item_input = Global.loadWidgetByName( FormItemType.TEXT );
978
form_item_input.TText( {field: 'total_time_amount'} );
979
widgetContainer = $( "<div class='widget-h-box'></div>" );
980
currency = $( "<span class='userDateTotal-currency widget-left-label'></span>" );
981
code = $( "<span class='userDateTotal-code widget-right-label'></span>" );
982
widgetContainer.append( currency );
983
widgetContainer.append( form_item_input );
984
widgetContainer.append( code );
985
this.addEditFieldToColumn( $.i18n._( 'Total Amount' ), form_item_input, tab_user_date_total_column2, '', widgetContainer, true );
987
if ( ( LocalCacheData.getCurrentCompany().product_edition_id >= 20 ) ) {
990
var good = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
991
good.TTextInput( {field: 'quantity', width: 50} );
992
good.addClass( 'quantity-input' );
994
var good_label = $( "<span class='widget-right-label'>" + $.i18n._( 'Good' ) + ": </span>" );
996
var bad = Global.loadWidgetByName( FormItemType.TEXT_INPUT );
997
bad.TTextInput( {field: 'bad_quantity', width: 50} );
998
bad.addClass( 'quantity-input' );
1000
var bad_label = $( "<span class='widget-right-label'>/ " + $.i18n._( 'Bad' ) + ": </span>" );
1002
var widgetContainer = $( "<div class='widget-h-box'></div>" );
1004
widgetContainer.append( good_label );
1005
widgetContainer.append( good );
1006
widgetContainer.append( bad_label );
1007
widgetContainer.append( bad );
1009
this.addEditFieldToColumn( $.i18n._( 'Quantity' ), [good, bad], tab_user_date_total_column2, '', widgetContainer, true );
1011
if ( !this.show_bad_quantity_ui && !this.show_good_quantity_ui ) {
1012
this.detachElement( 'quantity' );
1014
if ( !this.show_bad_quantity_ui ) {
1019
if ( !this.show_good_quantity_ui ) {
1026
form_item_input = Global.loadWidgetByName( FormItemType.TEXT_AREA );
1027
form_item_input.TTextArea( {field: 'note', width: '100%'} );
1028
this.addEditFieldToColumn( $.i18n._( 'Note' ), form_item_input, tab_user_date_total_column2, '', null, true, true );
1029
form_item_input.parent().width( '45%' );
1031
if ( !this.show_note_ui ) {
1032
this.detachElement( 'note' );
1036
form_item_input = Global.loadWidgetByName( FormItemType.CHECKBOX );
1037
form_item_input.TCheckbox( {field: 'override'} );
1038
this.addEditFieldToColumn( $.i18n._( 'Override' ), form_item_input, tab_user_date_total_column2, '', null, true, true );
1042
cleanWhenUnloadView: function( callBack ) {
1044
$( '#user_date_total_view_container' ).remove();
1045
this._super( 'cleanWhenUnloadView', callBack );
1051
UserDateTotalViewController.loadView = function( container ) {
1053
Global.loadViewSource( 'UserDateTotal', 'UserDateTotalView.html', function( result ) {
1056
var template = _.template( result );
1058
if ( Global.isSet( container ) ) {
1059
container.html( template( args ) );
1061
Global.contentContainer().html( template( args ) );
1068
UserDateTotalViewController.loadSubView = function( container, beforeViewLoadedFun, afterViewLoadedFun ) {
1070
Global.loadViewSource( 'UserDateTotal', 'SubUserDateTotalView.html', function( result ) {
1073
var template = _.template( result );
1075
if ( Global.isSet( beforeViewLoadedFun ) ) {
1076
beforeViewLoadedFun();
1079
if ( Global.isSet( container ) ) {
1080
container.html( template( args ) );
1082
if ( Global.isSet( afterViewLoadedFun ) ) {
1083
afterViewLoadedFun( sub_user_date_total_view_controller );