-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpag1.m
2051 lines (1496 loc) · 70 KB
/
pag1.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function varargout = pag1(varargin)
% pag1 MATLAB code for pag1.fig
% pag1, by itself, creates a new pag1 or raises the existing
% singleton*.
%
% H = pag1 returns the handle to a new pag1 or the handle to
% the existing singleton*.
%
% pag1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in pag1.M with the given input arguments.
%
% pag1('Property','Value',...) creates a new pag1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before pag1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to pag1_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help pag1
% Last Modified by GUIDE v2.5 24-Aug-2018 10:50:24
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @pag1_OpeningFcn, ...
'gui_OutputFcn', @pag1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before pag1 is made visible.
function pag1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to pag1 (see VARARGIN)
% Choose default command line output for pag1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes pag1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = pag1_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function menu_Callback(hObject, eventdata, handles)
% hObject handle to menu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function sel_txt_Callback(hObject, eventdata, handles)
% hObject handle to sel_txt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% personal_cell=table2cell(LISTADODEPERSONALSISTEMAS);
[filename, pathname] = uigetfile({'*.txt'},'File Selector');
fullpathname=strcat(pathname,filename);
set(handles.text2,'String',strcat('El archivo seleccionado es: ',fullpathname));
filename=fullfile(fullpathname);
Loaded_file=readtable(filename);
assignin('base','Loaded_file',Loaded_file);
clean_clock=sortrows(Loaded_file(:,[3 6 7]),1);
assignin('base','clean_clock',clean_clock);
personal_table=evalin('base', 'LISTADODEPERSONALSISTEMAS');
sorted_table_CI=sortrows(personal_table,1);
sorted_table_Name=sortrows(personal_table,2);
sorted_table_ID=sortrows(personal_table,3);
personal_table_CI_first=[personal_table(:,1) personal_table(:,2) personal_table(:,3)];
personal_table_Name_first=[personal_table(:,2) personal_table(:,1) personal_table(:,3)];
personal_table_ID_first=[personal_table(:,3) personal_table(:,2) personal_table(:,1)];
assignin('base','personal_table_ID_first',personal_table_ID_first);
assignin('base','personal_table_CI_first',personal_table_CI_first);
assignin('base','sorted_table_CI',sorted_table_CI);
assignin('base','sorted_table_Name',sorted_table_Name);
assignin('base','sorted_table_ID',sorted_table_ID);
CIs=personal_table(:,1);
Names=personal_table(:,2);
IDs=personal_table(:,3);
assignin('base','clean_personal',personal_table);
assignin('base','CIs',CIs);
assignin('base','IDs',IDs);
assignin('base','Names',Names);
guidata(hObject,handles);
% populate pops
set(handles.ID_popupmenu,'String',table2cell(IDs));
set(handles.CI_popupmenu,'String',table2cell(CIs));
set(handles.name_popupmenu,'String',table2cell(Names));
% set(handles.horario_popupmenu,'String',(Horarios));
% pop_ID to edit_ID
pop_ID_index=get(handles.ID_popupmenu,'Value');
assignin('base','pop_ID_index',pop_ID_index);
pop_ID_items=get(handles.ID_popupmenu,'String');
assignin('base','pop_ID_items',pop_ID_items);
pop_sel_item_ID = pop_ID_items{pop_ID_index};
assignin('base','pop_sel_item_ID',pop_sel_item_ID);
set(handles.ID_edit_box,'String',pop_sel_item_ID);
% pop_CI to edit_CI
pop_CI_index=get(handles.CI_popupmenu,'Value');
pop_CI_items=get(handles.CI_popupmenu,'String');
pop_sel_item_CI = pop_CI_items{pop_CI_index};
set(handles.CI_edit_box,'String',pop_sel_item_CI);
% pop_ID to pop_CI
CI_list_index = find(table2array(IDs)==str2double(pop_sel_item_ID));
assignin('base','CI_list_index',CI_list_index);
sel_CI=personal_table_ID_first(CI_list_index,3);
assignin('base','sel_CI',sel_CI);
set(handles.CI_popupmenu,'Value',CI_list_index);
% pop_CI to CI_show
set(handles.CI_show,'String',table2array(personal_table_ID_first(CI_list_index,2)));
assignin('base','nombre_trabajador',table2array(table2array(personal_table_ID_first(CI_list_index,2))));
% pop_ID to table
clean_db_sel_indexes = find(table2array(clean_clock(:,1))==str2double(pop_sel_item_ID));
assignin('base','clean_db_sel_indexes',clean_db_sel_indexes);
% set(handles.uitable1,'Data',table2cell(clean_clock(clean_db_sel_indexes,:)));
clean_db_sel_data=clean_clock(clean_db_sel_indexes,:);
assignin('base','clean_db_sel_data',clean_db_sel_data);
% pop_ID to name_popupmenu
set(handles.name_popupmenu,'Value',CI_list_index);
% --- Executes on selection change in ID_popupmenu.
function ID_popupmenu_Callback(hObject, eventdata, handles)
% hObject handle to ID_popupmenu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns ID_popupmenu contents as cell array
% contents{get(hObject,'Value')} returns selected item from ID_popupmenu
IDs=evalin('base', 'IDs');
personal_table_ID_first=evalin('base', 'personal_table_ID_first');
clean_clock=evalin('base', 'clean_clock');
% pop_ID to edit_ID
pop_ID_index=get(handles.ID_popupmenu,'Value');
pop_ID_items=get(handles.ID_popupmenu,'String');
pop_sel_item_ID = pop_ID_items{pop_ID_index};
assignin('base','pop_sel_item_ID',pop_sel_item_ID);
set(handles.ID_edit_box,'String',pop_sel_item_ID);
% pop_ID to pop_CI
CI_list_index = find(table2array(IDs)==str2double(pop_sel_item_ID));
assignin('base','CI_list_index',CI_list_index);
sel_CI=personal_table_ID_first(CI_list_index,3);
assignin('base','sel_CI',sel_CI);
set(handles.CI_popupmenu,'Value',CI_list_index);
% pop_CI to edit_CI
pop_CI_index=get(handles.CI_popupmenu,'Value');
pop_CI_items=get(handles.CI_popupmenu,'String');
pop_sel_item_CI = pop_CI_items{pop_CI_index};
set(handles.CI_edit_box,'String',pop_sel_item_CI);
% pop_CI to CI_show
set(handles.CI_show,'String',table2array(personal_table_ID_first(CI_list_index,2)));
assignin('base','nombre_trabajador',table2array(personal_table_ID_first(CI_list_index,2)));
% pop_ID to table
clean_db_sel_indexes = find(table2array(clean_clock(:,1))==str2double(pop_sel_item_ID));
assignin('base','clean_db_sel_indexes',clean_db_sel_indexes);
% set(handles.uitable1,'Data',table2cell(clean_clock(clean_db_sel_indexes,:)));
clean_db_sel_data=clean_clock(clean_db_sel_indexes,:);
assignin('base','clean_db_sel_data',clean_db_sel_data);
% pop_ID to name_popupmenu
set(handles.name_popupmenu,'Value',CI_list_index);
% Filtrar fecha
filtrar_fecha_Callback(handles.filtrar_fecha,[],handles);
% --- Executes during object creation, after setting all properties.
function ID_popupmenu_CreateFcn(hObject, eventdata, handles)
% hObject handle to ID_popupmenu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function ID_edit_box_Callback(hObject, eventdata, handles)
% hObject handle to ID_edit_box (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of ID_edit_box as text
% str2double(get(hObject,'String')) returns contents of ID_edit_box as a double
search_str=get(handles.ID_edit_box,'String');
personal_table_ID_first=evalin('base', 'personal_table_ID_first');
clean_clock=evalin('base', 'clean_clock');
% edit_ID to pop_ID
ID_list_index = find(table2array(personal_table_ID_first)==search_str);
assignin('base','ID_list_index',ID_list_index);
set(handles.ID_popupmenu,'Value',ID_list_index);
% edit_ID to pop_CI
set(handles.CI_popupmenu,'Value',ID_list_index);
% pop_CI to edit_CI
pop_CI_index=get(handles.CI_popupmenu,'Value');
pop_CI_items=get(handles.CI_popupmenu,'String');
pop_sel_item_CI = pop_CI_items{pop_CI_index};
set(handles.CI_edit_box,'String',pop_sel_item_CI);
% pop_CI to CI_show
set(handles.CI_show,'String',table2array(personal_table_ID_first(ID_list_index,2)));
assignin('base','nombre_trabajador',table2array(personal_table_ID_first(ID_list_index,2)));
% pop_ID to table
clean_db_sel_indexes = find(table2array(clean_clock(:,1))==table2array(personal_table_ID_first(ID_list_index,1)));
assignin('base','clean_db_sel_indexes',clean_db_sel_indexes);
% set(handles.uitable1,'Data',table2cell(clean_clock(clean_db_sel_indexes,:)));
clean_db_sel_data=clean_clock(clean_db_sel_indexes,:);
assignin('base','clean_db_sel_data',clean_db_sel_data);
% pop_ID to name_popupmenu
set(handles.name_popupmenu,'Value',ID_list_index);
% Filtrar fecha
filtrar_fecha_Callback(handles.filtrar_fecha,[],handles);
% --- Executes during object creation, after setting all properties.
function ID_edit_box_CreateFcn(hObject, eventdata, handles)
% hObject handle to ID_edit_box (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in CI_popupmenu.
function CI_popupmenu_Callback(hObject, eventdata, handles)
% hObject handle to CI_popupmenu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns CI_popupmenu contents as cell array
% contents{get(hObject,'Value')} returns selected item from CI_popupmenu
personal_table_ID_first=evalin('base', 'personal_table_ID_first');
clean_clock=evalin('base', 'clean_clock');
% pop_CI to edit_CI
pop_CI_index=get(handles.CI_popupmenu,'Value');
pop_CI_items=get(handles.CI_popupmenu,'String');
pop_sel_item_CI = pop_CI_items{pop_CI_index};
set(handles.CI_edit_box,'String',pop_sel_item_CI);
% pop_CI to CI_show
set(handles.CI_show,'String',table2array(personal_table_ID_first(pop_CI_index,2)));
assignin('base','nombre_trabajador',table2array(personal_table_ID_first(pop_CI_index,2)));
% pop_CI to pop_ID
set(handles.ID_popupmenu,'Value',pop_CI_index);
% pop_ID to edit_ID
pop_ID_index=get(handles.ID_popupmenu,'Value');
pop_ID_items=get(handles.ID_popupmenu,'String');
pop_sel_item_ID = pop_ID_items{pop_ID_index};
assignin('base','pop_sel_item_ID',pop_sel_item_ID);
set(handles.ID_edit_box,'String',pop_sel_item_ID);
% pop_ID to table
clean_db_sel_indexes = find(table2array(clean_clock(:,1))==table2array(personal_table_ID_first(pop_CI_index,1)));
assignin('base','clean_db_sel_indexes',clean_db_sel_indexes);
% set(handles.uitable1,'Data',table2cell(clean_clock(clean_db_sel_indexes,:)));
clean_db_sel_data=clean_clock(clean_db_sel_indexes,:);
assignin('base','clean_db_sel_data',clean_db_sel_data);
% pop_ID to name_popupmenu
set(handles.name_popupmenu,'Value',pop_CI_index);
% Filtrar fecha
filtrar_fecha_Callback(handles.filtrar_fecha,[],handles);
% --- Executes during object creation, after setting all properties.
function CI_popupmenu_CreateFcn(hObject, eventdata, handles)
% hObject handle to CI_popupmenu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function CI_edit_box_Callback(hObject, eventdata, handles)
% hObject handle to CI_edit_box (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of CI_edit_box as text
% str2double(get(hObject,'String')) returns contents of CI_edit_box as a double
search_str=get(handles.CI_edit_box,'String');
personal_table_CI_first=evalin('base', 'personal_table_CI_first');
clean_clock=evalin('base', 'clean_clock');
% edit_CI to pop_CI
CI_list_index = find(table2array(personal_table_CI_first)==search_str);
assignin('base','ID_list_index',CI_list_index);
set(handles.CI_popupmenu,'Value',CI_list_index);
% edit_CI to pop_ID
set(handles.ID_popupmenu,'Value',CI_list_index);
% pop_ID to edit_ID
pop_ID_index=get(handles.ID_popupmenu,'Value');
pop_ID_items=get(handles.ID_popupmenu,'String');
pop_sel_item_ID = pop_ID_items{pop_ID_index};
set(handles.ID_edit_box,'String',pop_sel_item_ID);
% pop_ID to CI_show
set(handles.CI_show,'String',table2array(personal_table_CI_first(CI_list_index,2)));
assignin('base','nombre_trabajador',table2array(personal_table_CI_first(CI_list_index,2)));
% pop_ID to table
clean_db_sel_indexes = find(table2array(clean_clock(:,1))==table2array(personal_table_CI_first(CI_list_index,3)));
assignin('base','clean_db_sel_indexes',clean_db_sel_indexes);
% set(handles.uitable1,'Data',table2cell(clean_clock(clean_db_sel_indexes,:)));
clean_db_sel_data=clean_clock(clean_db_sel_indexes,:);
assignin('base','clean_db_sel_data',clean_db_sel_data);
% pop_ID to name_popupmenu
set(handles.name_popupmenu,'Value',CI_list_index);
% Filtrar fecha
filtrar_fecha_Callback(handles.filtrar_fecha,[],handles);
% --- Executes during object creation, after setting all properties.
function CI_edit_box_CreateFcn(hObject, eventdata, handles)
% hObject handle to CI_edit_box (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function in_date_Callback(hObject, eventdata, handles)
% hObject handle to in_date (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of in_date as text
% str2double(get(hObject,'String')) returns contents of in_date as a double
% --- Executes during object creation, after setting all properties.
function in_date_CreateFcn(hObject, eventdata, handles)
% hObject handle to in_date (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function end_date_Callback(hObject, eventdata, handles)
% hObject handle to end_date (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of end_date as text
% str2double(get(hObject,'String')) returns contents of end_date as a double
% --- Executes during object creation, after setting all properties.
function end_date_CreateFcn(hObject, eventdata, handles)
% hObject handle to end_date (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in filtrar_fecha.
function filtrar_fecha_Callback(hObject, eventdata, handles)
% hObject handle to filtrar_fecha (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
horario_popupmenu_Callback(handles.horario_popupmenu,[],handles);
in_date_raw=get(handles.in_date,'String');
end_date_raw=get(handles.end_date,'String');
assignin('base','end_date_raw',end_date_raw);
assignin('base','in_date_raw',in_date_raw);
in_date=datestr(in_date_raw,'yyyy-mm-dd');
t1=datetime(in_date);
assignin('base','t1',t1);
end_date=datestr(end_date_raw,'yyyy-mm-dd');
t2=datetime(end_date);
assignin('base','t2',t2);
% dates to be compared with
dates_between=datestr(t1:t2,'yyyy/mm/dd');
assignin('base','dates_between',dates_between);
% Displaying dates
clean_db_sel_data=evalin('base', 'clean_db_sel_data');
dates_between_cell=cellstr(dates_between);
size_dates_between_cell=size(dates_between_cell);
clean_db_sel_data_cell=table2cell(clean_db_sel_data);
assignin('base','size_dates_between_cell',size_dates_between_cell);
% Get indexes
for k = 1:size_dates_between_cell
D.(sprintf('index_day%d', k)) = find(strcmp((clean_db_sel_data_cell(:,2)),dates_between_cell{k}));
end
m=transpose(struct2cell(D));
assignin('base','indexes_cell',m);
% Get data
for k = 1:size_dates_between_cell
E.(sprintf('data_day%d', k)) = (clean_db_sel_data{m{k},3});
end
n=transpose(struct2cell(E));
assignin('base','data_day_cell',n);
% Making even row and column data cell
col = size(n,2);
row = cellfun('size',n,1);
out_p = cell(max(row),col);
for k = 1:col
out_p(1:row(k),k) = n{k};
end
y=out_p;
size_y=size(y);
for j = 1:size_y(1)
for i = 1:size_y(2)
if isempty(y{j,i})
y{j,i} = '00:00:00';
end
end
end
% timbradas duration
timbradas_all(size_y(1),size_y(2)) = duration([00 00 00]);
for j = 1:size_y(1)
for i = 1:size_y(2)
timbradas_all(j,i) = duration(str2num(cell2mat(strrep(y(j,i),':',' '))));
end
end
final=sort(timbradas_all,'ascend');
% move 0s
size_y=size(final);
moved_r=final;
for i = 1:size_y(1)
for j = 1:size_y(2)
if final(i,j) == duration([00 00 00])
vieja=moved_r;
moved_r(1:end-1,j)=vieja(2:end,j);
moved_r(end,j)=vieja(1,j);
vieja=moved_r;
end
end
end
final=moved_r;
assignin('base','final',final);
assignin('base','out_p',out_p);
columns=transpose(cellstr(datestr(dates_between_cell,'ddd dd mmm yyyy','local')));
assignin('base','columns',columns);
size_old_data=size(out_p);
descartadas_data{size_old_data(1),size_old_data(2)}=[];
set(handles.descartadas_table,'Data',descartadas_data);
set(handles.data_table,'Data',cellstr(final));
set(handles.descuentos_table,'ColumnWidth',{'auto'});
set(handles.original_table,'Data',out_p);
set(handles.data_table,'ColumnName',columns);
set(handles.horario_full_table,'ColumnName',columns);
set(handles.descartadas_table,'ColumnName',columns);
set(handles.descuentos_table,'ColumnName',columns);
set(handles.original_table,'ColumnName',columns);
set(handles.horas_extras_table,'ColumnName',columns);
rnames_descuentos = {'D.E.','D.A.','D.S.','P.P','C.H.','Multa'};
assignin('base','rnames_descuentos',rnames_descuentos);
set(handles.descuentos_table,'RowName',rnames_descuentos);
set(handles.horario_popupmenu,'Value',1);
rnames_horas_extras_table = {'Normales','L-V 50%','L-V 25%','Mad 100%','S-D 100%','Fer. 100%'};
set(handles.horas_extras_table,'RowName',rnames_horas_extras_table);
assignin('base','rnames_horas_extras_table',rnames_horas_extras_table);
rnames_suma_extras_table = {'Normales','L-V 50%','L-V 25%','Mad 100%','S-D 100%','Fer. 100%'};
set(handles.suma_extras_table,'RowName',rnames_suma_extras_table);
horario=evalin('base', 'horario');
horario_full=repmat(horario,1,size_dates_between_cell(1));
assignin('base','horario_full',horario_full);
set(handles.horario_full_table,'Data',horario_full);
% names={'name1';'name2';'name3'};
% checkbox1={false;false;false};
C = cell(size_dates_between_cell(1),1);
C(:) = {true};
yourdata =[transpose(columns) C] ;
columnname = {'Día', 'Check'};
columnformat = {'char', 'logical'};
columneditable = [false true];
set(handles.aut_extras_table,'Units','normalized',...
'Data', yourdata,...
'ColumnName', columnname,...
'ColumnFormat', columnformat,...
'ColumnEditable', columneditable,...
'RowName',[],'BackgroundColor',[.7 .9 .8],'ForegroundColor',[0 0 0],...
'ColumnWidth',{'auto'});
% aprobadas=get(handles.aut_extras_table,'Data');
% assignin('base','aprobadas',aprobadas);
% --- Executes on selection change in name_popupmenu.
function name_popupmenu_Callback(hObject, eventdata, handles)
% hObject handle to name_popupmenu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns name_popupmenu contents as cell array
% contents{get(hObject,'Value')} returns selected item from name_popupmenu
personal_table_ID_first=evalin('base', 'personal_table_ID_first');
personal_table_CI_first=evalin('base', 'personal_table_CI_first');
clean_clock=evalin('base', 'clean_clock');
% pop_name to edit_ID
pop_name_index=get(handles.name_popupmenu,'Value');
pop_name_items=get(handles.ID_popupmenu,'String');
pop_sel_item_name = pop_name_items{pop_name_index};
set(handles.ID_edit_box,'String',pop_sel_item_name);
% edit_ID to pop_ID
search_str=get(handles.ID_edit_box,'String');
ID_list_index = find(table2array(personal_table_ID_first)==search_str);
assignin('base','ID_list_index',ID_list_index);
set(handles.ID_popupmenu,'Value',ID_list_index);
% edit_ID to pop_CI
set(handles.CI_popupmenu,'Value',ID_list_index);
% pop_CI to edit_CI
pop_CI_index=get(handles.CI_popupmenu,'Value');
pop_CI_items=get(handles.CI_popupmenu,'String');
pop_sel_item_CI = pop_CI_items{pop_CI_index};
set(handles.CI_edit_box,'String',pop_sel_item_CI);
% pop_ID to table
clean_db_sel_indexes = find(table2array(clean_clock(:,1))==table2array(personal_table_CI_first(ID_list_index,3)));
assignin('base','clean_db_sel_indexes',clean_db_sel_indexes);
% set(handles.uitable1,'Data',table2cell(clean_clock(clean_db_sel_indexes,:)));
clean_db_sel_data=clean_clock(clean_db_sel_indexes,:);
assignin('base','clean_db_sel_data',clean_db_sel_data);
% pop_ID to CI_show
set(handles.CI_show,'String',table2array(personal_table_CI_first(ID_list_index,2)));
assignin('base','nombre_trabajador',table2array(personal_table_CI_first(ID_list_index,2)));
% Filtrar fecha
filtrar_fecha_Callback(handles.filtrar_fecha,[],handles);
% --- Executes during object creation, after setting all properties.
function name_popupmenu_CreateFcn(hObject, eventdata, handles)
% hObject handle to name_popupmenu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in horario_popupmenu.
function horario_popupmenu_Callback(hObject, eventdata, handles)
% hObject handle to horario_popupmenu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns horario_popupmenu contents as cell array
% contents{get(hObject,'Value')} returns selected item from horario_popupmenu
% size_dates_between_cell=evalin('base', 'size_dates_between_cell');
% Horarios = {'Profesor';'Administrativo';'Especial'};
%
% set(handles.horario_popupmenu,'String',Horarios);
pop_horario_index=get(handles.horario_popupmenu,'Value');
pop_horario_items=get(handles.horario_popupmenu,'String');
pop_sel_item_horario = pop_horario_items{pop_horario_index};
Profesor = cellstr(string(duration([8 00 00; 10 45 00; 11 00 00; 13 00 00; 13 45 00; 15 45 00; 16 00 00; 17 00 00])));
Administrativo = cellstr(string(duration([8 00 00; 13 00 00; 13 45 00; 16 45 00;])));
At_Cliente = cellstr(string(duration([8 00 00; 13 00 00; 13 00 00; 16 00 00;])));
Especial = cellstr(string(duration([5 00 00; 5 45 00; 5 00 00; 5 00 00; 5 45 00; 5 45 00; 5 00 00; 1 00 00])));
rnames_data = {'Entrada','S. Alm.','E. Alm.','Salida'};
assignin('base','rnames_data',rnames_data);
rnames_total_horas_duration = {'Mañana','Tarde','Total'};
assignin('base','rnames_total_horas_duration',rnames_total_horas_duration);
rnames_total_descuentos = {'D.E.','D.A.','D.S.','P.P','C.H.','Multa','Total'};
assignin('base','rnames_total_descuentos',rnames_total_descuentos);
rnames_horas_extras_table = {'Normales','L-V 50%','L-V 25%','Mad 100%','S-D 100%','Fer. 100%'};
assignin('base','rnames_horas_extras_table',rnames_horas_extras_table);
switch pop_sel_item_horario
case 'Profesor'
set(handles.Horario,'Data',Profesor);
assignin('base','horario',Profesor);
% horario_full=repmat(Profesor,1,size_dates_between_cell(1));
% set(handles.horario_full_table,'Data',horario_full);
% assignin('base','horario_full',horario_full);
case 'Administrativo'
set(handles.Horario,'Data',Administrativo);
set(handles.data_table,'RowName',rnames_data);
set(handles.horario_full_table,'RowName',rnames_data);
set(handles.suma_horas_table,'RowName',rnames_total_horas_duration);
set(handles.suma_descuentos_table,'RowName',rnames_total_descuentos);
set(handles.suma_extras_table,'RowName',rnames_horas_extras_table);
assignin('base','horario',Administrativo);
% horario_full=repmat(Administrativo,1,size_dates_between_cell(1));
% set(handles.horario_full_table,'Data',horario_full);
% assignin('base','horario_full',horario_full);
case 'Especial'
set(handles.Horario,'Data',Especial);
assignin('base','horario',Especial);
% horario_full=repmat(Especial,1,size_dates_between_cell(1));
% set(handles.horario_full_table,'Data',horario_full);
% assignin('base','horario_full',horario_full);
end
% --- Executes during object creation, after setting all properties.
function horario_popupmenu_CreateFcn(hObject, eventdata, handles)
% hObject handle to horario_popupmenu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in Actualizar.
function Actualizar_Callback(hObject, eventdata, handles)
% hObject handle to Actualizar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% filtrar_fecha_Callback(handles.filtrar_fecha,[],handles);
% horario_popupmenu_Callback(handles.horario_popupmenu,[],handles);
% aprobadas=get(handles.aut_extras_table,'Data');
% assignin('base','aprobadas',aprobadas);
% --- Executes when selected cell(s) is changed in data_table.
function data_table_CellSelectionCallback(hObject, eventdata, handles)
% hObject handle to data_table (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% Indices: row and column indices of the cell(s) currently selecteds
% handles structure with handles and user data (see GUIDATA)
if ~isempty(eventdata.Indices)
selectedRow = eventdata.Indices(1);
selectedCol = eventdata.Indices(2);
assignin('base','selectedRow',selectedRow);
assignin('base','selectedCol',selectedCol);
end
% --- Executes on button press in insert_down.
function insert_down_Callback(hObject, eventdata, handles)
% hObject handle to insert_down (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
selectedRow=evalin('base', 'selectedRow');
selectedCol=evalin('base', 'selectedCol');
old_data = get(handles.data_table,'Data');
size_old_data=size(old_data);
old_column=old_data(:,selectedCol);
% Preallocate space for cell
new_column{size_old_data(1)+1,1}=[];
% Allocate 1st part
new_column(1:selectedRow)=old_column(1:selectedRow);
% Allocate last part
new_column(selectedRow+2:end)=old_column(selectedRow+1:end);
old_data{end+1,end}=[];
old_data(:,selectedCol)=new_column;
%Limpiar
out_final = old_data(~all(cellfun(@numel,old_data)==0,2),:);
set(handles.data_table,'Data',out_final);
% --- Executes on button press in insert_up.
function insert_up_Callback(hObject, eventdata, handles)
% hObject handle to insert_up (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
selectedRow=evalin('base', 'selectedRow');
selectedCol=evalin('base', 'selectedCol');
old_data = get(handles.data_table,'Data');
size_old_data=size(old_data);
old_column=old_data(:,selectedCol);
% Preallocate space for cell
new_column{size_old_data(1)+1,1}=[];
% Allocate 1st part
new_column(1:selectedRow-1)=old_column(1:selectedRow-1);
% Allocate last part
new_column(selectedRow+1:end)=old_column(selectedRow:end);
old_data{end+1,end}=[];
old_data(:,selectedCol)=new_column;
%Limpiar
out_final = old_data(~all(cellfun(@numel,old_data)==0,2),:);
set(handles.data_table,'Data',out_final);
% --- Executes on button press in move_up.
function move_up_Callback(hObject, eventdata, handles)
% hObject handle to move_up (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
selectedRow=evalin('base', 'selectedRow');
selectedCol=evalin('base', 'selectedCol');
old_data = get(handles.data_table,'Data');
size_old_data=size(old_data);
previous_value=old_data(selectedRow,selectedCol);
old_column=old_data(:,selectedCol);
% Preallocate space for cell
new_column{size_old_data(1),1}=[];
% Allocate 1st part
new_column(1:selectedRow-2)=old_column(1:selectedRow-2);
% Allocate last part
new_column(selectedRow+1:end)=old_column(selectedRow+1:end);
% Move value up
new_column(selectedRow-1)=previous_value;
old_data(:,selectedCol)=new_column;
%Limpiar
out_final = old_data(~all(cellfun(@numel,old_data)==0,2),:);
set(handles.data_table,'Data',out_final);
% --- Executes on button press in move_down.
function move_down_Callback(hObject, eventdata, handles)
% hObject handle to move_down (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
selectedRow=evalin('base', 'selectedRow');
selectedCol=evalin('base', 'selectedCol');
old_data = get(handles.data_table,'Data');
size_old_data=size(old_data);
previous_value=old_data(selectedRow,selectedCol);
old_column=old_data(:,selectedCol);
% Preallocate space for cell
new_column{size_old_data(1),1}=[];
% Allocate 1st part
new_column(1:selectedRow-1)=old_column(1:selectedRow-1);
% Allocate last part
new_column(selectedRow+2:end)=old_column(selectedRow+2:end);
% Move value up
new_column(selectedRow+1)=previous_value;
old_data(:,selectedCol)=new_column;
%Limpiar
out_final = old_data(~all(cellfun(@numel,old_data)==0,2),:);
set(handles.data_table,'Data',out_final);
% --- Executes when entered data in editable cell(s) in data_table.
function data_table_CellEditCallback(hObject, eventdata, handles)
% hObject handle to data_table (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% Indices: row and column indices of the cell(s) edited
% PreviousData: previous data for the cell(s) edited
% EditData: string(s) entered by the user
% NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
% Error: error string when failed to convert EditData to appropriate value for Data
% handles structure with handles and user data (see GUIDATA)
function hora_edit_Callback(hObject, eventdata, handles)
% hObject handle to hora_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of hora_edit as text
% str2double(get(hObject,'String')) returns contents of hora_edit as a double
% --- Executes during object creation, after setting all properties.
function hora_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to hora_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in insertar.
function insertar_Callback(hObject, eventdata, handles)
% hObject handle to insertar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
in_hour=get(handles.hora_edit,'String');
assignin('base','in_hour',in_hour);
selectedRow=evalin('base', 'selectedRow');
selectedCol=evalin('base', 'selectedCol');
old_data = get(handles.data_table,'Data');
old_data(selectedRow,selectedCol)=cellstr(in_hour);
%Limpiar
out_final = old_data(~all(cellfun(@numel,old_data)==0,2),:);
set(handles.data_table,'Data',out_final);