-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
2035 lines (1669 loc) · 91.4 KB
/
Copy pathindex.php
File metadata and controls
2035 lines (1669 loc) · 91.4 KB
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
<?php
$reqws=0;
if (! $reqws && file_exists("../main.inc.php")) $reqws=@include("../main.inc.php"); // For root directory
if (! $reqws && file_exists("../../main.inc.php")) $reqws=@include("../../main.inc.php"); // For "custom"
dol_include_once('/core/class/html.form.class.php');
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
// dol_include_once('/interventionplus/class/agenda.class.php');
dol_include_once('/interventionplus/class/interventionplus.class.php');
dol_include_once('/interventionplus/class/interventionplus_historiques.class.php');
if (empty($conf->interventionplus->enabled) || !$user->rights->interventionplus->lire) accessforbidden();
$langs->loadLangs(array('interventionplus@interventionplus','companies', 'bills', 'interventions', 'agenda'));
$title = $langs->trans("menuagendaintervention");
// $agenda = new agenda($db);
$object = new Fichinter($db);
$interventionplus = new interventionplus($db);
$interventionplus->upgradeTheinterventionplusModule();
global $showallevents, $check_holiday;
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($object->table_element);
// $events = new agenda($db);
$user_ = new User($db);
if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
$filter = GETPOST("filter",'alpha',3);
// $filtert = GETPOST("filtert","int",3);
// $actioncode = GETPOST("search_actioncode", "array") ? GETPOST("search_actioncode", "array") : array('AC_RDV');
$actioncode = GETPOST("search_actioncode", "array") ? GETPOST("search_actioncode", "array") : [];
$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
$usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3);
$socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int");
// $check_holiday = GETPOST('check_holiday', 'int');
$check_holiday = GETPOST('check_holiday', 'int');
$filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
$showbirthday = GETPOST("showbirthday", "int") ? GETPOST("showbirthday", "int") : 1;
$default_showallevents = !empty($user->conf->INTERVENTIONPLUS_FILTER_SHOW_ALL_EVENTS) ? $user->conf->INTERVENTIONPLUS_FILTER_SHOW_ALL_EVENTS : '';
$default_check_holiday = !empty($user->conf->INTERVENTIONPLUS_FILTER_CHECK_HOLIDAY) ? $user->conf->INTERVENTIONPLUS_FILTER_CHECK_HOLIDAY : '';
global $showallevents, $check_holiday;
$showallevents = GETPOST("button_search_x") ? GETPOST("showallevents", "int") : $default_showallevents;
$check_holiday = GETPOST("button_search_x") ? GETPOST("check_holiday", "int") : $default_check_holiday;
// If not choice done on calendar owner (like on left menu link "Agenda"), we filter on user.
if (empty($filtert) && !getDolGlobalString('AGENDA_ALL_CALENDARS')) {
// $filtert = $user->id;
}
$newparam = '';
$param = $socid>0? '&socid='.$socid : '';
$param .= $filter>0? '&search_filter='.$filter : '';
$param .= $filtert>0? '&search_filtert='.$filtert : '';
$param .= $showbirthday>0? '&showbirthday='.$showbirthday : '';
$param .= $check_holiday>0? '&check_holiday='.$check_holiday : '';
$param .= $showallevents>0? '&showallevents='.$showallevents : '';
$param .= $actioncode ? '&'.http_build_query(['search_actioncode' => $actioncode]) : '';
// echo $check_holiday;
// $usergroup = GETPOST("usergroup","int",3);
// $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1;
$sortfield = GETPOST("sortfield", "alpha");
$sortorder = GETPOST("sortorder");
$page = GETPOST("page");
$year=GETPOST("year","int")?GETPOST("year","int"):date("Y");
$month=GETPOST("month","int")?GETPOST("month","int"):date("m");
$week=GETPOST("week","int")?GETPOST("week","int"):date("W");
$day=GETPOST("day","int")?GETPOST("day","int"):date("d");
$action =GETPOST('action') ? GETPOST('action') : (!empty($user->conf->INTERVENTIONPLUS_LAST_LIST_ON_AGENDA) ? $user->conf->INTERVENTIONPLUS_LAST_LIST_ON_AGENDA : 'show_month');
$search_status = GETPOST('search_status', 'alpha');
$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
if ($dateselect > 0) {
$day = GETPOST('dateselectday', 'int');
$month = GETPOST('dateselectmonth', 'int');
$year = GETPOST('dateselectyear', 'int');
}
$constuser = array(
'INTERVENTIONPLUS_LAST_LIST_ON_AGENDA' => $action,
// 'INTERVENTIONPLUS_FILTER_SHOW_ALL_EVENTS' => $showallevents,
// 'INTERVENTIONPLUS_FILTER_CHECK_HOLIDAY' => $check_holiday
);
dol_set_user_param($db, $conf, $user, $constuser);
if($user->conf->INTERVENTIONPLUS_LAST_LIST_ON_AGENDA == 'show_user'){
header('Location: ./peruser.php?action='.$user->conf->INTERVENTIONPLUS_LAST_LIST_ON_AGENDA);
exit;
}
$reshook = $hookmanager->executeHooks('interventionplusIncludeInAllInterfaces', $parameters = array(), $object, $action);
$demoplatform = !empty($conf->global->DOLIBARR_PLATEFORME_DEMO_MODULES) ? 1 : 0;
$s='<script type="text/javascript">' . "\n";
// var check_holiday = $('#check_holiday').val('');
// $s.="$('#check_holiday').val()";
$s.="function changes_check_(th) {";
$s.="if($(th).is(':checked')){";
$s.="$('.show_intervenplus').show();";
$s.="}else{";
$s.="$('.show_intervenplus').hide();";
$s.=" }";
$s.="} ";
$s.='</script>' . "\n";
$morejs = array();
$morecss = array('interventionplus/css/style.css.php');
$evenements = !empty($interventionplus->tousevenements) ? explode(',', $interventionplus->tousevenements) : [];
$actioncode = !empty($actioncode) && GETPOST('button_search_x') ? $actioncode : (!empty($evenements) && empty(GETPOST('button_search_x')) ? $evenements : []);
$now=dol_now();
$nowarray=dol_getdate($now);
$nowyear=$nowarray['year'];
$nowmonth=$nowarray['mon'];
$nowday=$nowarray['mday'];
$listofextcals=array();
// // die($filter);
// // print_r($events->datachart()['data_user']);die();
// // Define list of external calendars (global admin setup)
// if (empty($conf->global->AGENDA_DISABLE_EXT))
// {
// $i=0;
// while($i < $MAXAGENDA)
// {
// $i++;
// $source='AGENDA_EXT_SRC'.$i;
// $name='AGENDA_EXT_NAME'.$i;
// $offsettz='AGENDA_EXT_OFFSETTZ'.$i;
// $color='AGENDA_EXT_COLOR'.$i;
// $buggedfile='AGENDA_EXT_BUGGEDFILE'.$i;
// if (! empty($conf->global->$source) && ! empty($conf->global->$name))
// {
// // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
// $listofextcals[]=array('src'=>$conf->global->$source,'name'=>$conf->global->$name,'offsettz'=>$conf->global->$offsettz,'color'=>$conf->global->$color,'buggedfile'=>(isset($conf->global->buggedfile)?$conf->global->buggedfile:0));
// }
// }
// }
$userstoinclud = array();
if (empty($action) || $action=='show_month')
{
$prev = dol_get_prev_month($month, $year);
$prev_year = $prev['year'];
$prev_month = $prev['month'];
$next = dol_get_next_month($month, $year);
$next_year = $next['year'];
$next_month = $next['month'];
$max_day_in_prev_month = date("t",dol_mktime(0,0,0,$prev_month,1,$prev_year)); // Nb of days in previous month
$max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year)); // Nb of days in next month
// tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday)
$tmpday = -date("w",dol_mktime(12,0,0,$month,1,$year,true))+2; // date('w') is 0 fo sunday
$tmpday+=((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)-1);
if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week.
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
$firstdaytoshow=dol_mktime(0,0,0,$prev_month,$max_day_in_prev_month+$tmpday,$prev_year);
$next_day=7 - ($max_day_in_month+1-$tmpday) % 7;
if ($next_day < 6) $next_day+=7;
$lastdaytoshow=dol_mktime(0,0,0,$next_month,$next_day,$next_year);
}
if ($action=='show_week')
{
$prev = dol_get_first_day_week($day, $month, $year);
$prev_year = $prev['prev_year'];
$prev_month = $prev['prev_month'];
$prev_day = $prev['prev_day'];
$first_day = $prev['first_day'];
$first_month= $prev['first_month'];
$first_year = $prev['first_year'];
$week = $prev['week'];
$day = (int) $day;
$next = dol_get_next_week($first_day, $week, $first_month, $first_year);
$next_year = $next['year'];
$next_month = $next['month'];
$next_day = $next['day'];
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
$firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year);
$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd');
$max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year));
$tmpday = $first_day;
}
if ($action == 'show_day')
{
$prev = dol_get_prev_day($day, $month, $year);
$prev_year = $prev['year'];
$prev_month = $prev['month'];
$prev_day = $prev['day'];
$next = dol_get_next_day($day, $month, $year);
$next_year = $next['year'];
$next_month = $next['month'];
$next_day = $next['day'];
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
$firstdaytoshow=dol_mktime(0,0,0,$prev_month,$prev_day,$prev_year);
$lastdaytoshow=dol_mktime(0,0,0,$next_month,$next_day,$next_year);
}
$day1 = date('Y-m-d H:i',$firstdaytoshow);
$day2 = date('Y-m-d H:i',$lastdaytoshow);
// d('day1:'.$day1,0);
// d('day2:'.$day2,0);
$morejs = array('/interventionplus/js/script.js.php');
llxHeader($s, $title,'','','','',$morejs,$morecss,0);
$allevents=array();
if($interventionplus->showeventsdoliabrrinagenda){
$allevents = $interventionplus->getAllEvents($action, $day, $month, $year, $filtert, $socid, $actioncode, $firstdaytoshow, $lastdaytoshow);
}
// foreach ($allevents as $key => $value) {
// d($key.': Event in '.$db->idate($key));
// }
$nbrtotal='';
$nbrtotalnofiltr='';
// $param='';
$maxprint='';
// print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $nbrtotal, $nbrtotalnofiltr,'object_action');
$alltypes = $interventionplus->select_types();
$hookmanager->initHooks(array('agenda'));
// echo $filter;
// $events->fetchAll('','',0,0,$filter);
$sql = 'SELECT ';
if (!empty($usergroup) && $usergroup > 0) {
$sql .= " DISTINCT";
}
$sql .= " f.rowid, f.ref, f.fk_soc, f.fk_statut as status, f.description, f.datec as date_creation, f.tms as date_update, f.note_public, f.note_private,";
$sql .= " ef.interventionplus_start, ef.interventionplus_end, ef.interventionplus_technicien, ef.interventionplus_other_technicien,ef.interventionplus_responsable, ef.interventionplustype";
$sql .= " ,f.duree as dureetotal";
// $sql .= " ,t.label as type_interv, t.color";
$sql .= " , t.types";
if($interventionplus->dolibarrversion > 15) {
$sql .= ", f.ref_client";
}
$groupbyextraf ="";
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
$groupbyextraf .= ", ef.".$key;
}
}
$sql .= ', u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity as user_entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
$sql .= ', s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax , s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client';
$sql .= ', country.code as country_code';
$sql .= ' FROM '.MAIN_DB_PREFIX."fichinter as f";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinter_extrafields as ef on ef.fk_object=f.rowid";
$sql .= " LEFT JOIN (SELECT rowid, GROUP_CONCAT(label, '::', color, '::' SEPARATOR ',') as types FROM ".MAIN_DB_PREFIX."interventionplustype) as t on t.rowid IN (ef.interventionplustype)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid=ef.interventionplus_technicien";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid=f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
$sql .= ' WHERE f.entity IN (0,'.$conf->entity.')';
if(!$user->admin && !$user->rights->interventionplus->accesstoall){
if(!$user->rights->interventionplus->showinterventiondraft){
$sql .= ' AND (';
$sql .= ' f.fk_user_author='.$user->id;
$sql .= ' OR (';
$sql .= ' ef.interventionplus_status >= '.interventionplus::STATUS_PLANIFIER;
$sql .= ' AND f.fk_statut = '.Fichinter::STATUS_VALIDATED;
$sql .= ')';
$sql .= ')';
}
if(!$user->rights->interventionplus->manageraccess){
// $sql .= ' AND ef.interventionplus_status <= '.interventionplus::STATUS_SIGNED.' AND ef.interventionplus_status >= '.interventionplus::STATUS_PLANIFIER;
// $sql .= ' AND f.fk_statut='.Fichinter::STATUS_VALIDATED;
// $sql .= 'AND ef.interventionplus_technicien='.$user->id;
$sql .= ' AND ef.interventionplus_status <= '.interventionplus::STATUS_SIGNED;
$sql .= ' AND ( ';
$sql .= ' ((ef.interventionplus_technicien = '.$user->id.' OR ef.interventionplus_other_technicien='.$user->id.' OR ef.interventionplus_other_technicien LIKE "%,'.$user->id.',%" OR ef.interventionplus_other_technicien LIKE "'.$user->id.',%" OR ef.interventionplus_other_technicien LIKE "%,'.$user->id.'"))';
$sql .= ' OR (ef.interventionplus_responsable = '.$user->id.')';
$sql .= ' OR ';
$sql .= ' ( ';
$sql .= ' f.rowid IN ';
$sql .= ' ( ';
$sql .= 'SELECT ec.element_id FROM '.MAIN_DB_PREFIX.'element_contact AS ec WHERE ec.fk_socpeople = '.$user->id.' AND ec.fk_c_type_contact IN ';
$sql .= ' ( ';
$sql .= 'SELECT ct.rowid FROM '.MAIN_DB_PREFIX.'c_type_contact AS ct WHERE ct.element = "fichinter"';
$sql .= ' ) ';
$sql .= ' ) ';
$sql .= ' ) ';
$sql .= ' ) ';
}
}
if(!$user->admin && !$user->rights->interventionplus->accesstoall && $user->rights->interventionplus->manageraccess){
$sql .= ' AND (ef.interventionplus_responsable = '.$user->id.' OR (ef.interventionplus_technicien = '.$user->id.' OR ef.interventionplus_other_technicien='.$user->id.' OR ef.interventionplus_other_technicien LIKE "%,'.$user->id.',%" OR ef.interventionplus_other_technicien LIKE "'.$user->id.',%" OR ef.interventionplus_other_technicien LIKE "%,'.$user->id.'"))';
}
if(!$user->rights->interventionplus->showinterventiondraft){
$sql .= ' AND f.fk_statut NOT IN ('.urlencode(Fichinter::STATUS_DRAFT).')';
}
if ($search_status != '' && $search_status >= 0) {
if($search_status == 0 || $search_status == Fichinter::STATUS_CLOSED){
$sql .= ' AND f.fk_statut = '.urlencode($search_status);
}
elseif(!empty($interventionplus->intervention_champs_rdv_pris) && $search_status >= interventionplus::STATUS_PLANIFIE_AFFECTE && $search_status <= interventionplus::STATUS_PRE_PLANIFIE_NOAFFECTE){
$rdv = $interventionplus->intervention_champs_rdv_pris;
$sql .= ' AND f.fk_statut = '.urlencode(Fichinter::STATUS_VALIDATED);
$sql .= ' AND (ef.interventionplus_status = '.interventionplus::STATUS_PLANIFIER.' OR (ef.interventionplus_status <= 0 OR ef.interventionplus_status IS NULL))';
if($search_status == interventionplus::STATUS_PLANIFIE_AFFECTE){
$sql .= ' AND ef.interventionplus_technicien > 0';
$sql .= ' AND ef.interventionplus_start IS NOT NULL ';
$sql .= ' AND ef.interventionplus_end IS NOT NULL ';
$sql .= ' AND ef.'.$rdv.' IS NOT NULL ';
// $statuts_logo = 'status_planifier';
// $statuts_short = $langs->trans('InterventionPlanifieaffecte');
} elseif($search_status == interventionplus::STATUS_PLANIFIE_NO_AFFECTE) {
$sql .= ' AND (ef.interventionplus_technicien <= 0 OR ef.interventionplus_technicien IS NULL OR ef.interventionplus_technicien = "")';
$sql .= ' AND ef.interventionplus_start IS NOT NULL ';
$sql .= ' AND ef.interventionplus_end IS NOT NULL ';
$sql .= ' AND ef.'.$rdv.' IS NOT NULL ';
// $statuts_logo = 'status_planifier';
// $statuts_short = $langs->trans('InterventionPlanifieNoAffecte');
}elseif($search_status == interventionplus::STATUS_PRE_PLANIFIE_AFFECTE) {
$sql .= ' AND ef.interventionplus_technicien > 0';
$sql .= ' AND (ef.'.$rdv.' <= 0 OR ef.'.$rdv.' IS NULL OR ef.'.$rdv.' = "")';
// $statuts_logo = 'status_planifier';
// $statuts_short = $langs->trans('InterventionPrePlanifieaffecte');
} elseif($search_status == interventionplus::STATUS_PRE_PLANIFIE_NOAFFECTE) {
$sql .= ' AND (ef.interventionplus_technicien <= 0 OR ef.interventionplus_technicien IS NULL OR ef.interventionplus_technicien = "")';
$sql .= ' AND (ef.'.$rdv.' <= 0 OR ef.'.$rdv.' IS NULL OR ef.'.$rdv.' = "")';
// $sql .= ' AND (ef.interventionplus_start IS NULL OR ef.interventionplus_end IS NULL) ';
// $statuts_logo = 'status_planifier';
// $statuts_short = $langs->trans('InterventionPrePlanifienoaffecte');
}
}
elseif($search_status>0){
$sql .= ' AND f.fk_statut = '.urlencode(Fichinter::STATUS_VALIDATED);
if($search_status == 20)
$sql .= ' AND ef.interventionplus_status='.interventionplus::STATUS_A_FACTURER.' AND ef.interventionplus_numfacture>0';
elseif($search_status == interventionplus::STATUS_A_FACTURER)
$sql .= ' AND ef.interventionplus_status='.interventionplus::STATUS_A_FACTURER.' AND (ef.interventionplus_numfacture is null or ef.interventionplus_numfacture<=0 or ef.interventionplus_numfacture="")';
else
$sql .= ' AND ef.interventionplus_status='.$search_status;
}
}
$sql .= " AND (";
$sql .= " ( ef.interventionplus_start >= '".$day1."' AND ef.interventionplus_start <= '".$day2."')";
$sql .= " OR (ef.interventionplus_end >= '".$day1."' AND ef.interventionplus_end <= '".$day2."')";
$sql .= " )";
// filtert
$sql .= ((!empty($filtert) && $filtert != -1)) ? " AND (ef.interventionplus_technicien = ".$filtert." OR ef.interventionplus_other_technicien=".$filtert." OR ef.interventionplus_other_technicien LIKE '%,".$filtert.",%' OR ef.interventionplus_other_technicien LIKE '".$filtert.",%' OR ef.interventionplus_other_technicien LIKE '%,".$filtert."')" : "";
// Groups
// $sql .= ((!empty($usergroup) && $usergroup != -1)) ? " AND ef.interventionplus_grouptechnicien = ".$usergroup."" : "";
// Groups
$sql .= ((!empty($socid) && $socid != -1)) ? " AND f.fk_soc = ".$socid."" : "";
// ------------------------------------------------------------------------------------------------------------------------------------------------------ TO HIDE METRE
// $sql .= ' AND (ef.metreplus_interventionformetre IS NULL) ';
// ------------------------------------------------------------------------------------------------------------------------------------------------------
$sql .= " ORDER BY ef.interventionplus_start ASC ";
$resql = $db->query($sql);
$array_fetched_users = array();
$techniciensnames = array();
$data_array = array();
$z = 1;
$num = 0;
if ($resql) {
$num = $db->num_rows($resql);
// d($num,0);
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($resql);
// ----------------------------------------------------------------------------------------------------- Fichinter Object
$objectstatic = new Fichinter($db);
$objectstatic->id = $obj->rowid;
$objectstatic->ref = $obj->ref;
if($interventionplus->dolibarrversion > 15)
$objectstatic->ref_client = $obj->ref_client;
$objectstatic->statut = $obj->status;
$objectstatic->status = $obj->status;
$objectstatic->duration = $obj->dureetotal;
$objectstatic->array_options['options_interventionplustype'] = $obj->options_interventionplustype;
$objectstatic->array_options['options_interventionplus_status'] = $obj->options_interventionplus_status;
$objectstatic->array_options['options_interventionplus_numdevis'] = $obj->options_interventionplus_numdevis;
$objectstatic->array_options['options_interventionplus_numfacture'] = $obj->options_interventionplus_numfacture;
$objectstatic->array_options['options_interventionplus_start'] = $db->jdate($obj->options_interventionplus_start);
$objectstatic->array_options['options_interventionplus_end'] = $db->jdate($obj->options_interventionplus_end);
$objectstatic->array_options['options_interventionplus_signetechn'] = $obj->options_interventionplus_signetechn;
$objectstatic->array_options['options_interventionplus_signeclient'] = $obj->options_interventionplus_signeclient;
$objectstatic->array_options['options_interventionplus_technicien'] = $obj->options_interventionplus_technicien;
$objectstatic->array_options['options_interventionplus_other_technicien'] = $obj->options_interventionplus_other_technicien;
if(!empty($interventionplus->intervention_champs_rdv_pris)) {
$objectstatic->array_options['options_'.$interventionplus->intervention_champs_rdv_pris] = '';
if(isset($obj->{'options_'.$interventionplus->intervention_champs_rdv_pris})) {
$objectstatic->array_options['options_'.$interventionplus->intervention_champs_rdv_pris] = $obj->{'options_'.$interventionplus->intervention_champs_rdv_pris};
}
}
// ----------------------------------------------------------------------------------------------------- Company Object
$companystatic = new Societe($db);
$tmpnamecompany = '';
$companystatic->id = $obj->fk_soc;
$companystatic->name = $obj->name;
$companystatic->name_alias = $obj->alias;
$companystatic->client = $obj->client;
$companystatic->fournisseur = $obj->fournisseur;
$companystatic->code_client = $obj->code_client;
$companystatic->email = $obj->email;
$companystatic->phone = $obj->phone;
$companystatic->address = $obj->address;
$companystatic->zip = $obj->zip;
$companystatic->town = $obj->town;
$companystatic->country_code = $obj->country_code;
if($obj->fk_soc) {
$tmpnamecompany = $companystatic->getNomUrl(-1);
}
// ----------------------------------------------------------------------------------------------------- Technicien Object
$userstatic = new User($db);
$tmpnameuser = '';
$userstatic->id = $obj->options_interventionplus_technicien;
$userstatic->login = $obj->login;
$userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname;
$userstatic->email = $obj->user_email;
$userstatic->statut = $obj->user_statut;
$userstatic->entity = $obj->user_entity;
$userstatic->photo = $obj->photo;
$userstatic->office_phone = $obj->office_phone;
$userstatic->office_fax = $obj->office_fax;
$userstatic->user_mobile = $obj->user_mobile;
$userstatic->job = $obj->job;
$userstatic->gender = $obj->gender;
if($obj->options_interventionplus_technicien) {
$tmpnameuser = $userstatic->getNomUrl(-1);
}
$techniciensnames[(int) $obj->options_interventionplus_technicien] = $tmpnameuser;
// $resposalbe_ = new User($db);
// $resposalbe_->fetch($obj->interventionplus_responsable);
// ----------------------------------------------------------------------------------------------------- Label type Intervention
// if(strlen($obj->type_interv) > 20 ) {
// $label = substr($obj->type_interv,0,20).'...';
// }else
// $label = $obj->type_interv;
// ----------------------------------------------------------------------------------------------------- Data
$data = [
// 'others' => 'no',
'rowid' => $obj->rowid,
'fichinterobj'=> $objectstatic,
'label' => $obj->ref,
'datestart' => $db->jdate($obj->interventionplus_start),
'dateend' => $db->jdate($obj->interventionplus_end),
'date' => $obj->interventionplus_start,
'datend' => $obj->interventionplus_end,
// 'interv_type' => $obj->type_interv,
// 'responsable' => $resposalbe_,
'responsable_id' => $obj->interventionplus_responsable,
'technicien' => $obj->options_interventionplus_technicien,
'fk_soc' => $obj->fk_soc,
'usertechnicien_url' => $tmpnameuser,
'usertechnicien_txt' => $userstatic->getFullName($langs),
'companyfullname_url' => $tmpnamecompany
// 'color' => $obj->color
];
if($action == 'show_day') {
$data_array[(int)$obj->options_interventionplus_technicien][$z] = $data;
$id_other_techn = $obj->options_interventionplus_other_technicien;
$id_other_tech = !empty($id_other_techn) ? explode(',', $id_other_techn) : [];
if(!empty($id_other_tech)){
foreach ($id_other_tech as $key => $id_other) {
$other_userstatic = new User($db);
if(isset($array_fetched_users[$id_other])) {
$other_userstatic = $array_fetched_users[$id_other];
}
else{
$tmpres = $other_userstatic->fetch($id_other);
if($tmpres > 0) {
$array_fetched_users[$id_other] = $other_userstatic;
}
}
if(!empty($other_userstatic->id)) {
$z++;
$other_tmpnameuser = $other_userstatic->getNomUrl(-1);
$techniciensnames[$id_other] = $other_tmpnameuser;
$data['technicien'] = $id_other;
// $data['usertechnicien_url'] = $other_tmpnameuser;
// $data['usertechnicien_txt'] = $other_userstatic->getFullName($langs);
$data_array[$id_other][$z] = $data;
}
}
}
} else {
$data_array[$z] = $data;
}
$z++;
$userstoinclud[(int) $obj->options_interventionplus_technicien] = (int) $obj->options_interventionplus_technicien;
if(!empty($obj->options_interventionplus_other_technicien)){
$otherstechnicien = explode(',', $obj->options_interventionplus_other_technicien);
foreach ($otherstechnicien as $key => $idtech) {
$userstoinclud[(int) $idtech] = (int) $idtech;
}
}
$i++;
}
}else
dol_print_error($db);
// d($data_array);
$data_historique = array();
if($user->admin || $demoplatform) {
$objecthistoriq = new interventionplus_historiques($db);
$data_historique = $objecthistoriq->gethistoriqview($month, $year);
}
if ($search_status != '' && $search_status > -1) {
$param .= "&search_status=".urlencode($search_status);
}
if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month') $param.='&action='.$action;
$param.="&maxprint=".$maxprint;
//navigation bar
if (empty($action) || $action=='show_month')
{
$nav ="<a href=\"?year=".$prev_year."&month=".$prev_month.$param."\"><i class=\"fa fa-chevron-left\"></i></a> \n";
$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$month,1,$year),"%b %Y");
$nav.=" </span>\n";
$nav.=" <a href=\"?year=".$next_year."&month=".$next_month.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
$nav.=" (<a href=\"?year=".$nowyear."&month=".$nowmonth.$param."\">".$langs->trans("Today")."</a>)";
$picto='calendar';
}
if ($action=='show_week')
{
$nav ="<a href=\"?year=".$prev_year."&month=".$prev_month."&day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\" title=\"".dol_escape_htmltag($langs->trans("Previous"))."\"></i></a> \n";
$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$first_month,$first_day,$first_year),"%Y").", ".$langs->trans("Week")." ".$week;
$nav.=" </span>\n";
$nav.=" <a href=\"?year=".$next_year."&month=".$next_month."&day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n";
$nav.=" (<a href=\"?year=".$nowyear."&month=".$nowmonth."&day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
$picto='calendarweek';
}
if ($action=='show_day')
{
$nav ="<a href=\"?year=".$prev_year."&month=".$prev_month."&day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\"></i></a> \n";
$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$month,$day,$year),"daytextshort");
$nav.=" </span>\n";
$nav.=" <a href=\"?year=".$next_year."&month=".$next_month."&day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
$nav.=" (<a href=\"?year=".$nowyear."&month=".$nowmonth."&day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
$picto='calendarday';
}
// select Date
$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
$nav .= '<button type="submit" class="liste_titre button_search valignmiddle" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
// Add button
$newcardbutton = '';
$newcardbutton .= dolGetButtonTitle($langs->trans("NewIntervention"), '', 'fa fa-plus-circle', dol_buildpath('/interventionplus/card.php',1).'?action=create&options_interventionplus_nowday='.$nowday.'&options_interventionplus_nowmonth='.$nowmonth.'&options_interventionplus_nowyear='.$nowyear.'&backtopage='.urlencode($_SERVER["PHP_SELF"].(!empty($newparam) ? '?'.$newparam : '')));
// liste day moins year
// $viewmode = '';
// $viewmode .= '<a class="btnTitle'.($action == 'show_list' ? ' btnTitleSelected' : '').' reposition" href="'.dol_buildpath('/interventionplus/list.php',1).'">';
// $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
// $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
// $viewmode .= '<a class="btnTitle'.($action == 'show_month' ? ' btnTitleSelected' : '').' reposition" href="'.dol_buildpath('/interventionplus/index.php?action=show_month',1).'">';
// $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="pictoactionview block"');
// $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
// $viewmode .= '<a class="btnTitle'.($action == 'show_week' ? ' btnTitleSelected' : '').' reposition" href="'.dol_buildpath('/interventionplus/index.php?action=show_week',1).'">';
// $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
// $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
// $viewmode .= '<a class="btnTitle'.($action == 'show_day' ? ' btnTitleSelected' : '').' reposition" href="'.dol_buildpath('/interventionplus/index.php?action=show_day',1).'">';
// $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
// $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
// $viewmode .= '<a class="btnTitle '.($action == 'show_user' ? ' btnTitleSelected' : '').' reposition" href="'.dol_buildpath('/interventionplus/peruser.php?action=show_user',1).'">';
// $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
// $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
$viewmode = $interventionplus->interventionplus_TopVueButtons($action);
$massactionbutton ="";
$limit ="";
// print_r($day);die();
print '<div class="calendrinterventionplus">';
print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if (!empty($optioncss) && $optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="'.GETPOST('action').'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.'<span class="marginleftonly"></span>'.$newcardbutton, '', $limit, 1, 0, 1, $viewmode);
// Define the legend/list of calendard to show
$s=''; $link='';
// $showextcals=$listofextcals;
if (! empty($conf->use_javascript_ajax)) // If javascript on
{
$s.="\n".'<!-- Div to calendars selectors -->'."\n";
$s.='<script type="text/javascript">' . "\n";
$s.='jQuery(document).ready(function () {' . "\n";
$s.='jQuery("#check_birthday").click(function() { console.log("Toggle birthday"); jQuery(".family_birthday").toggle(); });' . "\n";
$s.='jQuery(".family_birthday").toggle();' . "\n";
if ($action=="show_week" || $action=="show_month" || empty($action))
{
// Code to enable drag and drop
$s.='jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n";
// Code to submit form
$s.='console.log("submit form to record new event");'."\n";
//$s.='console.log(event.target);';
$s.='var newval = jQuery(event.target).closest("div.dayevent").attr("id");'."\n";
$s.='console.log("found parent div.dayevent with id = "+newval);'."\n";
$s.='var frm=jQuery("#searchFormList");'."\n";
$s.='var newurl = ui.item.find("a.cal_event").attr("href");'."\n";
$s.='console.log(newurl);'."\n";
$s.='frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'."\n";
$s.='});'."\n";
}
$s.='});' . "\n";
$s.='</script>' . "\n";
// Local calendar
// $s.='<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda").' </div>';
// // External calendars
// if (is_array($showextcals) && count($showextcals) > 0)
// {
// $s.='<script type="text/javascript">' . "\n";
// $s.='jQuery(document).ready(function () {
// jQuery("table input[name^=\"check_ext\"]").click(function() {
// var name = $(this).attr("name");
// jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
// });
// });' . "\n";
// $s.='</script>' . "\n";
// // foreach ($showextcals as $val)
// // {
// // $htmlname = md5($val['name']);
// // $s.='<div class="nowrap inline-block"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked> ' . $val['name'] . ' </div>';
// // }
// }
// $s.='<div class="nowrap inline-block by_" >';
// $s.='<a href="'.dol_buildpath('/interventionplus/index.php?action=show_day',1).'" class="by_day">'.$langs->trans("by_day").'</a>';
// $s.='<a href="'.dol_buildpath('/interventionplus/index.php?action=show_week',1).'" class="by_week">'.$langs->trans("by_week").'</a>';
// $s.='<a href="'.dol_buildpath('/interventionplus/index.php?action=show_month',1).'" class="by_month">'.$langs->trans("by_month").'</a>';
// // $s.='<input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents");
// $s.='</div>';
if($action =="show_day")
$s.='<style>.by_day{background-color:#ebebeb}</style>';
elseif($action =="show_week")
$s.='<style>.by_week{background-color:#ebebeb}</style>';
else
$s.='<style>.by_month{background-color:#ebebeb}</style>';
// Calendars from hooks
$parameters=array(); $object=null;
$reshook=$hookmanager->executeHooks('addCalendarChoice',$parameters,$object,$action);
if (empty($reshook))
{
$s.= $hookmanager->resPrint;
}
elseif ($reshook > 1)
{
$s = $hookmanager->resPrint;
}
}
else // If javascript off
{
$newparam=$param; // newparam is for birthday links
$newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam);
if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1';
$link='<a href="'.dol_escape_htmltag($_SERVER['PHP_SELF']);
$link.='?'.dol_escape_htmltag($newparam);
$link.='">';
if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents");
else $link.=$langs->trans("AgendaHideBirthdayEvents");
$link.='</a>';
}
// $action ='show_month';
// print load_fiche_titre($s, $link.' '.$nav, '', 0, 0, 'tablelistofcalendars');
// print_r($data_array);die();
// for ($i=0; $i < count($events->rows); $i++) {
// # code...
// }
$maxnbofchar =0;
if (empty($action) || $action == 'show_month') // View by month
{
$newparam=$param; // newparam is for birthday links
$newparam=preg_replace('/showbirthday=/i','showbirthday_=',$newparam); // To avoid replacement when replace day= is done
$newparam=preg_replace('/action=show_month&?/i','',$newparam);
$newparam=preg_replace('/action=show_week&?/i','',$newparam);
$newparam=preg_replace('/day=[0-9]+&?/i','',$newparam);
$newparam=preg_replace('/month=[0-9]+&?/i','',$newparam);
$newparam=preg_replace('/year=[0-9]+&?/i','',$newparam);
$newparam=preg_replace('/viewcal=[0-9]+&?/i','',$newparam);
$newparam=preg_replace('/showbirthday_=/i','showbirthday=',$newparam); // Restore correct parameter
$newparam.='&viewcal=1';
// // ShowAllInterventions
// if($user->admin){
// print'<table width="100%" >';
// print'<tr>';
// print'<td>';
// print '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" onclick="changes_check_(this)" class="check_holiday" checked><label for="check_holiday"> <span class="check_show_all_interventions">'.$langs->trans("ShowAllInterventions").'</span></label> </div>';
// print'</td>';
// print'</tr>';
// print'</table>';
// }
// print $interventionplus->interventionsstatusindicator();
print '<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
$interventionplus->agenda_print_actions_filter($form, $filtert, $socid, $actioncode);
print '<table width="100%" class="noborder nocellnopadd cal_pannel cal_month">';
print ' <tr class="liste_titre tablefixedtr">';
// CULUMN
echo ' <td class="center">#</td>';
// END CULUMN
$i=0;
while ($i < 7)
{
print ' <td align="center" class="tdfordaytitleintevplus">';
$numdayinweek=(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7);
if (! empty($conf->dol_optimize_smallscreen))
{
$labelshort=array(0=>'SundayMin',1=>'MondayMin',2=>'TuesdayMin',3=>'WednesdayMin',4=>'ThursdayMin',5=>'FridayMin',6=>'SaturdayMin');
print strtoupper($langs->trans($labelshort[$numdayinweek]));
}
else print strtoupper($langs->trans("Day".$numdayinweek));
print ' </td>'."\n";
$i++;
}
echo ' </tr>'."\n";
$todayarray=dol_getdate($now,'fast');
$todaytms=dol_mktime(0, 0, 0, $todayarray['mon'], $todayarray['mday'], $todayarray['year']);
// In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month)
// var_dump($data_array);
for ($iter_week = 0; $iter_week < 6 ; $iter_week++)
{
echo " <tr>\n";
// CULUMN
// Get date of the current day, format 'yyyy-mm-dd'
if ($tmpday <= 0) { // If number of the current day is in previous month
$currdate0 = sprintf("%04d", $prev_year).sprintf("%02d", $prev_month).sprintf("%02d", $max_day_in_prev_month + $tmpday);
} elseif ($tmpday <= $max_day_in_month) { // If number of the current day is in current month
$currdate0 = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $tmpday);
} else // If number of the current day is in next month
{
$currdate0 = sprintf("%04d", $next_year).sprintf("%02d", $next_month).sprintf("%02d", $tmpday - $max_day_in_month);
}
// Get week number for the targeted date '$currdate0'
$numweek0 = date("W", strtotime(date($currdate0)));
// Show the week number, and define column width
echo ' <td class="center weeknumber opacitymedium" width="2%">'.$numweek0.'</td>';
// END CULUMN
for ($iter_day = 0; $iter_day < 7; $iter_day++)
{
/* Show days before the beginning of the current month (previous month) */
$dayevent = dol_mktime(0, 0, 0, $month, $tmpday, $year, 'gmt');
if ($tmpday <= 0)
{
$style='cal_other_month cal_past';
if ($iter_day == 6) $style.=' cal_other_month_right';
echo ' <td class="'.$style.' nowrap" width="14%" valign="top">';
// echo '<div class="contentoftdoverflowed">';
interventionplus_show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $data_array, $data_historique, $maxprint, $maxnbofchar, $newparam, $showinfo=0, $minheight=60, $nonew=0, (!empty($allevents[$dayevent]) ? $allevents[$dayevent] : array()), $alltypes);
// echo '</div>';
// Add all Events in Doliabrr
// if(!empty((!empty($allevents[$dayevent]) ? $allevents[$dayevent] : array()))){
// echo '<div class="dolievent">';
// show_day_events($db, $tmpday, $month, $year, $month, $style, (!empty($allevents[$dayevent]) ? $allevents[$dayevent] : array()), 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars);
// echo '</div>';
// }else{
// echo 'Aucun event';
// }
echo " </td>\n";
}
/* Show days of the current month */
elseif ($tmpday <= $max_day_in_month)
{
$curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year);
$style='cal_current_month';
if ($iter_day == 6) $style.=' cal_current_month_right';
$today=0;
if ($todayarray['mday']==$tmpday && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1;
if ($today) $style='cal_today';
if ($curtime < $todaytms) $style.=' cal_past';
//var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style);
echo ' <td class="'.$style.' nowrap" width="14%" valign="top">';
// echo '<div class="contentoftdoverflowed">';
interventionplus_show_day_events($db, $tmpday, $month, $year, $month, $style, $data_array, $data_historique, $maxprint, $maxnbofchar, $newparam, $showinfo=0, $minheight=60, $nonew=0, (!empty($allevents[$dayevent]) ? $allevents[$dayevent] : array()), $alltypes);
// echo '</div>';
// Add all Events in Doliabrr
// if(!empty((!empty($allevents[$dayevent]) ? $allevents[$dayevent] : array()))){
// echo '<div class="dolievent">';
// show_day_events($db, $tmpday, $month, $year, $month, $style, (!empty($allevents[$dayevent]) ? $allevents[$dayevent] : array()), 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars);
// echo '</div>';
// }else{
// echo 'Aucun event';
// }
echo " </td>\n";
}
/* Show days after the current month (next month) */
else
{
$style='cal_other_month';
if ($iter_day == 6) $style.=' cal_other_month_right';
echo ' <td class="'.$style.' nowrap" width="14%" valign="top">';
// echo '<div class="contentoftdoverflowed">';
interventionplus_show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $data_array, $data_historique, $maxprint, $maxnbofchar, $newparam, $showinfo=0, $minheight=60, $nonew=0, (!empty($allevents[$dayevent]) ? $allevents[$dayevent] : array()), $alltypes);
// echo '</div>';
// Add all Events in Doliabrr
// if(!empty((!empty($allevents[$dayevent]) ? $allevents[$dayevent] : array()))){
// echo '<div class="dolievent">';
// show_day_events($db, $tmpday, $month, $year, $month, $style, (!empty($allevents[$dayevent]) ? $allevents[$dayevent] : array()), 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars);
// echo '</div>';
// }else{
// echo 'Aucun event';
// }
echo "</td>\n";
}
$tmpday++;
}
echo " </tr>\n";
}
print "</table>\n";
print '</div>';
print '<input type="hidden" name="actionmove" value="mupdate">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
print '<input type="hidden" name="newdate" id="newdate">' ;
}
elseif ($action == 'show_week') // View by week
{
$newparam=$param; // newparam is for birthday links
$newparam=preg_replace('/showbirthday=/i','showbirthday_=',$newparam); // To avoid replacement when replace day= is done
$newparam=preg_replace('/action=show_month&?/i','',$newparam);
$newparam=preg_replace('/action=show_week&?/i','',$newparam);
$newparam=preg_replace('/day=[0-9]+&?/i','',$newparam);
$newparam=preg_replace('/month=[0-9]+&?/i','',$newparam);
$newparam=preg_replace('/year=[0-9]+&?/i','',$newparam);
$newparam=preg_replace('/viewweek=[0-9]+&?/i','',$newparam);
$newparam=preg_replace('/showbirthday_=/i','showbirthday=',$newparam); // Restore correct parameter
$newparam.='&viewweek=1';
print '<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
// // ShowAllInterventions
// if($user->admin){
// print'<table width="100%" >';
// print'<tr>';
// print'<td>';
// print '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_holiday" name="check_holiday" value="1" onclick="changes_check_(this)" class="check_holiday" checked><label for="check_holiday"> <span class="check_show_all_interventions">'.$langs->trans("ShowAllInterventions").'</span></label> </div>';
// print'</td>';
// print'</tr>';
// print'</table>';