/
inc_entity_item_form.php
936 lines (736 loc) · 32.6 KB
/
inc_entity_item_form.php
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
<?php
/* visualization functions */
include_once "inc_entity_item.php";
class eiseEntityItemForm extends eiseEntityItem {
function __construct($oSQL, $intra, $entID, $entItemID, $conf = array()){
parent::__construct($oSQL, $intra, $entID, $entItemID, $conf);
$this->getEntityItemAllData();
}
function form($arrConfig=Array()){
$arrDefaultConf = array('flagHideDraftStatusStay'=>true);
$arrConfig = array_merge($arrDefaultConf, $arrConfig);
$entItemID = $this->entItemID;
$oSQL = $this->oSQL;
$entID = $this->entID;
$item = $this->item;
if (!$this->flagArchive){
?>
<form action="<?php echo $_SERVER["PHP_SELF"] ; ?>" method="POST" id="entForm" class="eiseIntraForm">
<input type="hidden" name="DataAction" id="DataAction" value="update">
<input type="hidden" name="entID" id="entID" value="<?php echo $entID ; ?>">
<input type="hidden" name="<?php echo "{$entID}"; ?>ID" id="<?php echo "{$entID}"; ?>ID" value="<?php echo $item[$this->entItemIDField] ; ?>">
<input type="hidden" name="aclOldStatusID" id="aclOldStatusID" value="<?php echo $item["{$entID}StatusID"] ; ?>">
<input type="hidden" name="aclNewStatusID" id="aclNewStatusID" value="">
<input type="hidden" name="actID" id="actID" value="">
<input type="hidden" name="aclGUID" id="aclGUID" value="">
<input type="hidden" name="aclToDo" id="aclToDo" value="">
<input type="hidden" name="aclComments" id="aclComments" value="">
<?php
}
?>
<table width="100%">
<tbody>
<tr>
<td width="50%">
<h1><?php echo $item["entTitle{$this->intra->local}"]." ".$item[$this->entItemIDField] ; ?>
<?php echo ($this->flagArchive ? " (".$this->intra->translate("Archive").")" : "") ; ?></h1>
<?php
$this->showEntityItemFields( array_merge($arrConfig, Array('showComments'=>true)));
$this->showFiles();
?>
</td>
<td width="50%">
<?php
echo $this->showActions($arrConfig["actionCallBack"]);
?>
<?php
$this->showActivityLog($arrConfig)
?>
</td>
</tr>
<?php
if ($arrConfig["extraFieldset"]!=""){
?>
<tr><td colspan="2"><?php eval($arrConfig["extraFieldset"]); ?></td></tr>
<?php
}
?>
</tbody>
</table>
</form>
<script>
$(document).ready(function(){
$('.eiseIntraForm').
eiseIntraForm().
eiseIntraEntityItemForm({flagUpdateMultiple: false});
});
</script>
<?php
//echo "<pre>";
//print_r($this->item);
}
function showActions($actionCallBack=""){
$oSQL = $this->oSQL;
$item = $this->item;
if (!$this->intra->arrUsrData["FlagWrite"]
|| (count($this->conf['STA'][$this->staID]['ACT'])==0 && count($this->item["ACL"])==0)
) return;
?>
<fieldset class="eiseIntraActions eiseIntraSubForm"><legend><?php echo $this->intra->translate("Actions") ; ?></legend>
<?php
$entID = $this->entID;
$entItemID = $this->entItemID;
$staID = $this->staID;
$ii = 0;
foreach ($this->item["ACL"] as $ix=>$rwACL){
$this->showActionInfo($rwACL, $actionCallBack);
$staID = ($ii==0 ? $rwACL["aclNewStatusID"] : $staID);
$ii++;
}
if (!$this->flagArchive){
echo $this->showActionRadios();
if ($this->intra->arrUsrData["FlagWrite"]){
echo "<div align=\"center\"><input class=\"eiseIntraSubmit\" id=\"btnsubmit\" type=\"submit\" value=\"".$this->intra->translate("Run")."\"></div>";
}
}
?>
</fieldset>
<?php
}
function showEntityItemFields($arrConfig = Array()){
$strLocal = $this->intra->local;
$oSQL = $this->oSQL;
$item = $this->item;
$entID = $this->entID;
$entItemID = $this->entItemID;
if(empty($this->conf["ATR"])){
throw new Exception("Attribute set not found");
}
echo "<fieldset class=\"eiseIntraMainForm\"><legend>".($arrConfig['title']
? $arrConfig['title']
: $this->intra->translate("Data"))."</legend>\r\n";
echo $this->getFieldsHTML($arrConfig, $this);
if ($this->entItemID){
if ($arrConfig["showComments"]){
// Comments
$this->showCommentsField();
}
}
echo "</fieldset>\r\n\r\n";
}
function showFieldset($title, $id, $arrAtr, $strExtraField=''){
$oSQL = $this->intra->oSQL;
$intra = $this->intra;
?>
<fieldset id="<?php echo $id ?>"><legend><?php echo $title; ?></legend>
<?php
echo $strExtraField;
if (count($arrAtr)==0)
$arrAtr = array_keys($this->conf['ATR']);
foreach($arrAtr as $atr){
$strFields .= $this->field($atr);
}
echo $strFields;
?>
</fieldset>
<?php
}
/**
*
*/
function field( $atr, $arrConf_ = array() ){
$intra = $this->intra;
if ($atr=='__comments'){
return $this->showComments();
}
if(!isset($this->conf['STA'][(int)$this->staID]['satFlagShowInForm'][$atr]))
return '';
$rwAtr = $this->conf['ATR'][$atr];
$arrConf = array('type'=>$rwAtr['atrType']
, 'text' => $this->item[$rwAtr["atrID"]."_text"]
, 'source' => $rwAtr['atrDataSource']
, 'source_prefix' => $rwAtr['atrProgrammerReserved']
, 'FlagWrite' => $this->conf['STA'][(int)$this->staID]['satFlagShowInForm'][$atr]
, 'UOM' => $rwAtr['atrUOMTypeID']
, 'textIfNull' => $intra->translate($rwAtr['atrTextIfNull'])
);
if($rwAtr['atrClasses'])
$arrConf['class'] = $rwAtr['atrClasses'];
$arrConf = array_merge(
$arrConf
, $arrConf_
);
return $this->intra->field($rwAtr["atrTitle{$intra->local}"], $rwAtr['atrID'], $this->item[$rwAtr["atrID"]], $arrConf);
}
function showActivityLog($arrConfig=array()){
$strLocal = $this->intra->local;
$oSQL = $this->oSQL;
$entID = $this->entID;
$entItemID = $this->entItemID;
$intra = $this->intra;
?>
<fieldset><legend><?php echo $this->intra->translate("Activity Log") ; ?></legend>
<?php
// показываем статусы вместе с stlArrivalAction
// потом внутри статуса показываем действия, выполненные во время стояния в статусе
foreach($this->item["STL"] as $stlGUID => $rwSTL){
if ($arrConfig['flagHideDraftStatusStay'] && $rwSTL['stlStatusID']==='0')
continue;
?>
<div class="eiseIntraLogStatus">
<div class="eiseIntraLogTitle"><span class="eiseIntra_stlTitle"><?php echo ($rwSTL["stlTitle{$this->intra->local}"]!=""
? $rwSTL["stlTitle{$this->intra->local}"]
: $rwSTL["staTitle"]); ?></span>
<span class="eiseIntra_stlATA"><?php echo $intra->dateSQL2PHP($rwSTL["stlATA"], $rwSTL["staTrackPrecision"]); ?></span>
<span class="eiseIntra_stlATD"><?php echo ( $rwSTL["stlATD"] ? $intra->DateSQL2PHP($rwSTL["stlATD"], $rwSTL["staTrackPrecision"]) : $intra->translate("current time")); ?></span>
</div>
<div class="eiseIntraLogData">
<?php
if (isset($rwSTL["ACL"]))
foreach ($rwSTL["ACL"] as $rwNAct){
$this->showActionInfo($rwNAct);
}
// linked attributes
if (isset($rwSTL["SAT"]))
foreach($rwSTL["SAT"] as $atrID => $rwATV){
$rwATV = array_merge($this->conf['ATR'][$atrID], $rwATV);
$rwATV["FlagWrite"] = false;
?>
<div class="eiseIntraField"><label><?php echo $rwATV["atrTitle{$this->intra->local}"] ; ?>:</label>
<?php
echo $this->showAttributeValue($rwATV, "_".$rwSTL["stlGUID"]); ?>
</div>
<?php
}
?>
</div>
</div>
<?php
$this->showActionInfo($rwSTL["stlArrivalAction"]);
}
?>
</fieldset>
<?php
if (count($this->item['ACL_Cancelled']) > 0 ) {
?>
<fieldset><legend><?php echo $this->intra->translate("Cancelled actions") ; ?></legend>
<?php
$ii = 0;
foreach ($this->item["ACL_Cancelled"] as $rwACL) {
if ($rwACL["aclActionPhase"]!=3) continue;
$this->showActionInfo($rwACL, $actionCallBack);
$staID = ($ii==0 ? $rwACL["aclNewStatusID"] : $staID);
$ii++;
}
?>
</fieldset>
<?php
}
}
function showActionInfo($rwACT, $actionCallBack=""){
$entID = $this->entID;
$strLocal = $this->intra->local;
$flagAlwaysShow = ($rwACT["aclActionPhase"]<2 ? true : false);
$flagEditable = ($rwACT["aclActionPhase"]<2 && $this->intra->arrUsrData["FlagWrite"]==true && !$this->flagArchive);
?>
<div class="eiseIntraLogAction">
<div class="eiseIntraLogTitle" id="aclTitle_<?php echo $rwACT["aclGUID"] ; ?>" title="Last edited: <?php echo htmlspecialchars($rwACT["aclEditBy"]."@".Date("d.m.Y H:i", strtotime($rwACT["aclEditDate"]))).
"\r\n / ".$rwACT["aclEntityItemID"]."|".$rwACT["aclGUID"]; ?>"><?php
echo
($rwACT["aclActionPhase"]==2 // if action is complete, show past tense
? $rwACT["actTitlePast{$strLocal}"]
: $rwACT["actTitle{$strLocal}"]).
($rwACT["staID_Old"]!=$rwACT["staID_New"]
? " (".$rwACT["staTitle{$strLocal}_Old"]." > ".$rwACT["staTitle{$strLocal}_New"].")"
: ""
);
echo ($this->flagArchive
? ($rwACT["aclActionPhase"]==3
? " (".$this->intra->translate("cancelled").")"
: ($rwACT["aclActionPhase"]<2
? " (".$this->intra->translate("incomplete").")"
: "")
)
: ""
);?></div>
<div class="eiseIntraLogData">
<?php
// timestamps
foreach($rwACT['aatFlagTimestamp'] as $ts=>$field)
if (strpos($field, 'acl')===0){
?>
<div class="eiseIntraField">
<label><?php echo $ts ?>:</label><?php
echo $this->showAttributeValue(Array("atrID"=>$field
, "value" => $rwACT["acl{$ts}"]
, "atrType"=>$rwACT["actTrackPrecision"]
, "FlagWrite"=>$flagEditable
, "aatFlagMandatory"=>true
), "_".$rwACT["aclGUID"]);
?>
</div>
<?php
}
// linked attributes
if (isset($rwACT["AAT"]))
foreach($rwACT["AAT"] as $ix => $rwATV){
$rwATV = array_merge($this->conf['ATR'][$ix], $rwATV);
$rwATV["FlagWrite"] = $flagEditable;
?>
<div class="eiseIntraField"><label><?php
echo $rwATV["atrTitle{$this->intra->local}"] ;
?>:</label><?php
echo $this->showAttributeValue($rwATV, "_".$rwACT["aclGUID"]); ?>
</div>
<?php
}
if ($rwACT['aclComments']){
?>
<div class="eiseIntraField"><label><?php
echo $this->intra->translate('Comments');
?>:</label><div class="eiseIntraValue"><i><?php echo $rwACT['aclComments'] ?></i></div>
</div>
<?php
}
eval($actionCallBack.";");
?>
</div>
<?php
if ($rwACT["aclActionPhase"]<2 && !$this->flagArchive){
?><div align="center"><?php
if ($rwACT["aclActionPhase"]=="0"){
?><input name="start_<?php echo $aclGUID ; ?>" id="start_<?php echo $rwACT["aclGUID"] ; ?>"
type="button" value="Start" class="eiseIntraActionButton">
<?php
}
if ($rwACT["aclActionPhase"]=="1"){
?><input name="finish_<?php echo $aclGUID ; ?>" id="finish_<?php echo $rwACT["aclGUID"] ; ?>"
type="button" value="Finish" class="eiseIntraActionButton">
<?php
}
?><input name="cancel_<?php echo $aclGUID ; ?>" id="cancel_<?php echo $rwACT["aclGUID"] ; ?>"
type="button" value="Cancel" class="eiseIntraActionButton"></div>
<?php
}
?>
</div>
<?php
}
function showTimestampField($atrName, $flagEditable, $value, $suffix){
return $this->showAttributeValue(Array("atrID"=>$atrName
, "atrType"=>"datetime"
, "satFlagEditable"=>$flagEditable
, "aatFlagMandatory"=>true
, "value" => $value)
, $suffix);
}
function showActivityLog_simple($arrConfig=Array()) {
$strLoc = $this->intra->local;
$arrStatus = $this->getActionLog($arrConfig);
$strRes = "<fieldset><legend>Status".($arrConfig['staTitle'] ? ": ".$arrConfig['staTitle'] : "")."</legend>";
$strRes .= "<div style=\"max-height:100px; overflow-y: auto;\">\r\n";
$strRes .= "<table width='100%' class='eiseIntraHistoryTable'>\r\n";
for ($i=0;$i<count($arrStatus);$i++){
$strRes .= "<tr class='tr".($i % 2)."' valign='top'>\r\n";
if ($arrStatus[$i]["aclActionPhase"]==2) {
$strRes .= "<td nowrap><b>".$arrStatus[$i]["actTitlePast"]."</b></td>\r\n";
} else {
$strRes .= "<td nowrap>Started "<b>".$arrStatus[$i]["actTitle"]."</b>"</td>\r\n";
}
$strRes .= "<td nowrap>".($arrStatus[$i]["aclEditBy"] ? $this->intra->getUserData($arrStatus[$i]["aclEditBy"]) : '')."</td>";
$strRes .= "<td nowrap>".date("d.m.Y H:i", strtotime($arrStatus[$i]["aclEditDate"]))."</td>";
$strRes .= "</tr>";
if ($arrStatus[$i]["aclComments"]) {
$strRes .= "<tr class='tr".($i % 2)."'>";
$strRes .= "<td nowrap style=\"text-align:right;\"><b>Comments:</b></td>\r\n";
$strRes .= "<td colspan='2' nowrap><i>".$arrStatus[$i]["aclComments"]."</i><br /> </td>";
$strRes .= "</tr>";
}
}
$strRes .= "</table>\r\n";
$strRes .= "</div>\r\n";
$strRes .= "</fieldset>\r\n\r\n";
return $strRes;
}
function getActionLog($arrConfig = array()){
$arrACL = array();
$sql = "SELECT stbl_action_log.*
, stbl_action.*
, STA_OLD.staTitle{$this->intra->local} as staTitle_old
, STA_NEW.staTitle{$this->intra->local} as staTitle_new
FROM stbl_action_log
INNER JOIN stbl_action ON actID= aclActionID
LEFT OUTER JOIN stbl_status STA_OLD ON STA_OLD.staID=aclOldStatusID AND STA_OLD.staEntityID=actEntityID
LEFT OUTER JOIN stbl_status STA_NEW ON STA_NEW.staID=aclOldStatusID AND STA_NEW.staEntityID=actEntityID
WHERE aclEntityItemID='{$this->entItemID}' AND actEntityID='{$this->entID}'".
(!$arrConfig['flagIncludeUpdate'] ? " AND aclActionID<>2" : "")
."
ORDER BY aclInsertDate DESC, aclNewStatusID DESC, aclATA DESC";
$rs = $this->oSQL->do_query($sql);
$flagHasCreate = false;
while ($rw = $this->oSQL->fetch_array($rs)) {
if(!$rw['usrID']) $rw['usrName'] = $rw['aclInsertBy'];
if($rw['actID']==1)
$flagHasCreate = true;
$acl = array(
'alGUID' => $rw['aclGUID']
, 'actID' => $rw['actID']
, 'aclActionPhase' => $rw['aclActionPhase']
, 'aclOldStatusID' => $rw['aclOldStatusID']
, 'aclNewStatusID' => $rw['aclNewStatusID']
, 'actTitle' => $rw['actTitle'.$this->intra->local]
, 'actTitlePast' => $rw['actTitlePast'.$this->intra->local]
, 'aclComments' => $rw['aclComments']
, 'aclEditBy' => $this->intra->translate('%s by %s', ucfirst($rw['actTitlePast'.$this->intra->local]), $this->intra->getUserData($rw['aclEditBy']))
, 'aclEditDate' => $this->intra->datetimeSQL2PHP($rw["aclEditDate"])
, 'aclATA' => date("{$this->intra->conf['dateFormat']}"
.(strtotime($rw["aclATA"])!=strtotime(date('Y-m-d', strtotime($rw["aclATA"]))) ? " {$this->intra->conf['timeFormat']}" : '')
, strtotime($rw["aclATA"]))
);
$arrACL[] = $acl;
}
if(!$flagHasCreate){
$arrACL[] = array(
'alGUID' => '0'
, 'actID' => 1
, 'aclActionPhase' => 2
, 'aclOldStatusID' => null
, 'aclNewStatusID' => 0
, 'actTitle' => $this->conf['ACT'][1]["actTitle{$this->intra->local}"]
, 'actTitlePast' => $this->conf['ACT'][1]["actTitlePast{$this->intra->local}"]
, 'aclEditBy' => $this->intra->translate('%s by %s', $this->conf['ACT'][1]["actTitlePast{$this->intra->local}"], $this->intra->getUserData($this->item["{$this->conf['entPrefix']}InsertBy"]))
, 'aclEditDate' => $this->intra->datetimeSQL2PHP($this->item["{$this->conf['entPrefix']}InsertDate"])
, 'aclATA' => $this->intra->datetimeSQL2PHP($this->item["{$this->conf['entPrefix']}InsertDate"])
);
}
$this->oSQL->free_result($rs);
return $arrACL;
}
function showActionLog_skeleton(){
$strRes = "<div id=\"eiseIntraActionLog\" title=\"".$this->intra->translate('Action Log')."\" class=\"eif-action-log\">\r\n";
$strRes .= "<table class='eiseIntraActionLogTable'>\r\n";
$strRes .= "<tbody class=\"eif_ActionLog\">";
$strRes .= "<tr class=\"eif_template eif_evenodd\">\r\n";
$strRes .= "<td class=\"eif_actTitlePast\"></td>\r\n";
$strRes .= "<td class=\"eif_aclEditBy\"></td>";
$strRes .= "<td class=\"eif_aclATA\" style=\"text-align:right;\"></td>";
$strRes .= "</tr>";
$strRes .= "<tr class=\"eif_template eif_evenodd eif_invisible\">";
$strRes .= "<td class=\"eif_commentsTitle\">".$this->intra->translate("Comments").":</td>\r\n";
$strRes .= "<td colspan='2' class=\"eif_aclComments\"></td>";
$strRes .= "</tr>";
$strRes .= "<tr class=\"eif_notfound\">";
$strRes .= "<td colspan='3'>".$this->intra->translate("No Events Found")."</td>";
$strRes .= "</tr>";
$strRes .= "<tr class=\"eif_spinner\">";
$strRes .= "<td colspan='3'></td>";
$strRes .= "</tr>";
$strRes .= "</tbody>";
$strRes .= "</table>\r\n";
$strRes .= "</div>\r\n";
return $strRes;
}
/***********************************************************************************/
/* Comments Routines */
/***********************************************************************************/
function showComments(){
$oSQL = $this->oSQL;
$intra = $this->intra;
$strComments = '';
$strComments .= '<div class="eiseIntraField">'."\r\n";
$strComments .= '<label>'.$this->intra->translate("Comments").':</label>'."\r\n";
$strComments .= '<div class="eiseIntraValue">'."\r\n";
if ($this->intra->arrUsrData["FlagWrite"] && !$this->flagArchive){
$strComments .= '<textarea class="eiseIntraComment"></textarea>'."\r\n";
}
foreach ($this->item["comments"] as $ix => $rwSCM){
$strComments .= '<div id="scm_'.$rwSCM["scmGUID"].'" class="eiseIntraComment'.($intra->usrID==$rwSCM["scmInsertBy"] ? " eiseIntraComment_removable" : "").'">'."\r\n";
$strComments .= '<div class="eiseIntraComment_userstamp">'.$intra->getUserData($rwSCM["scmInsertBy"]).' '.$intra->translate('at').' '.$intra->dateSQL2PHP($rwSCM["scmInsertDate"], "d.m.Y H:i")."\r\n";
$strComments .= '</div>'."\r\n";
$strComments .= '<div>'.str_replace("\n", "<br>", htmlspecialchars($rwSCM["scmContent"] )).'</div>'."\r\n";
$strComments .= '</div>'."\r\n";
}
$strComments .= '</div>'."\r\n";
$strComments .= '<div class="eiseIntraComment_contols">'."\r\n";
$strComments .= '<input type="button" class="eiseIntraComment_add ss_sprite ss_add">'."\r\n";
$strComments .= '<input type="button" class="eiseIntraComment_remove ss_sprite ss_delete">'."\r\n";
$strComments .= '</div>'."\r\n";
$strComments .= '</div>'."\r\n";
return $strComments;
}
// old version
function showCommentsField(){
$oSQL = $this->oSQL;
$intra = $this->intra;
?>
<div class="eiseIntraField">
<label><?php echo $this->intra->translate("Comments"); ?>:</label>
<div class="eiseIntraValue">
<?php
if ($this->intra->arrUsrData["FlagWrite"] && !$this->flagArchive){?>
<textarea class="eiseIntraComment"></textarea>
<?php
}
foreach ($this->item["comments"] as $ix => $rwSCM){
?>
<div id="scm_<?php echo $rwSCM["scmGUID"] ; ?>" class="eiseIntraComment<?php echo ($intra->usrID==$rwSCM["scmInsertBy"] ? " eiseIntraComment_removable" : "") ?>">
<div class="eiseIntraComment_userstamp"><?php echo $intra->getUserData($rwSCM["scmInsertBy"]).' '.$intra->translate('at').' '.$intra->dateSQL2PHP($rwSCM["scmInsertDate"], "d.m.Y H:i");
?></div>
<div><?php echo str_replace("\n", "<br>", htmlspecialchars($rwSCM["scmContent"] )); ?></div>
</div>
<?php
}
?>
</div>
<?php
?>
<div class="eiseIntraComment_contols">
<input type="button" class="eiseIntraComment_add ss_sprite ss_add">
<input type="button" class="eiseIntraComment_remove ss_sprite ss_delete">
</div>
</div>
<?php
}
/***********************************************************************************/
/* File Attachment Routines */
/***********************************************************************************/
function showFileAttachDiv(){
$entID = $this->entID;
$entItemID = $this->entItemID;
?>
<div id="divAttach" style="display:none;">
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" enctype="multipart/form-data" onsubmit="
if (document.getElementById('attachment').value==''){
alert ('File is not specified.');
document.getElementById('attachment').focus();
return false;
}
var btnUpl = document.getElementById('btnUpload');
btnUpl.value = 'Loading...';
btnUpl.disabled = true;
return true;
">
<input type="hidden" name="DataAction" id="DataAction" value="attachFile" />
<input type="hidden" name="entID_Attach" id="entItemID_Attach" value="<?php echo $entID ; ?>" />
<input type="hidden" name="entItemID_Attach" id="entItemID_Attach" value="<?php echo $entItemID ; ?>" />
<span class="field_title_top">Choose file</span>:<br />
<input type="file" id="attachment" name="attachment" ><br />
<input type="submit" value="Upload" id="btnUpload" style="width: 180px; font-weight:bold;" /><input
type="button" value="Cancel" onclick="$('#divAttach').dialog('close');" style="width:80px;" />
</form>
</div>
<?php
}
function showFiles(){
$entID = $this->entID;
$entItemID = $this->entItemID;
$intra = $this->intra;
$arrFil = $this->getFiles();
if (count($arrFil) > 0) {
?>
<fieldset><legend><?php echo $this->intra->translate("Files") ; ?></legend>
<div style="max-height:100px; overflow-y: auto;">
<table width="100%" class="eiseIntraHistoryTable">
<thead>
<tr>
<th>File</th>
<th colspan="2">Uploaded</th>
<th> </th>
</th>
</thead>
<tbody>
<?php
$i =0;
foreach($arrFil as $ix=>$rwFile){
?>
<tr class="tr<?php echo $i%2 ; ?>">
<td width="100%"><a href="<?php echo $rwFile["filName"]['h'] ; ?>" target="_blank"><?php echo $rwFile["filName"]['v'] ; ?></a></td>
<td><?php echo $rwFile["filEditBy"] ; ?></td>
<td><?php echo $rwFile["filEditDate"] ; ?></td>
<td class="eiseIntra_unattach" id="fil_<?php echo $rwFile["filGUID"] ; ?>" title="Delete"> X </td>
</tr>
<?php
$i++;
}
?>
</tbody>
</table>
</div>
</fieldset>
<?php
}
}
function showFileAttachForm(){
$entID = $this->entID;
$entItemID = $this->entItemID;
$strDiv = '';
$strDiv .= '<form id="eif_frmAttach" action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data" onsubmit="
if (document.getElementById(\'eif_attachment\').value==\'\'){
alert (\'File is not specified.\');
document.getElementById(\'eif_attachment\').focus();
return false;
}
var btnUpl = document.getElementById(\'eif_btnUpload\');
btnUpl.value = \'Loading...\';
btnUpl.disabled = true;
return true;
">'."\r\n";
$strDiv .= '<input type="hidden" name="DataAction" id="DataAction_attach" value="attachFile">'."\r\n";
$strDiv .= '<input type="hidden" name="entID_Attach" id="entItemID_Attach" value="'.$this->entID.'">'."\r\n";
$strDiv .= '<input type="hidden" name="entItemID_Attach" id="entItemID_Attach" value="'.$entItemID.'">'."\r\n";
//$strDiv .= '<label>'.$this->intra->translate('Choose file').': </label>'."\r\n";
$strDiv .= '<div class="eif-file-dropzone"><div class="eif-file-dropzone-title">'.$this->intra->translate('Drop files here or click to choose').'<i> </i></div><i class="eif-file-dropzone-spinner"> </i></div>';
$strDiv .= '<input type="file" id="eif_attachment" class="eif-attachment" name="attachment[]" multiple style="display: none;">'."\r\n";
$strDiv .= '<input type="submit" value="Upload" id="eif_btnUpload">'."\r\n";
$strDiv .= '</form>'."\r\n";
return $strDiv;
}
function showFileList_skeleton(){
$strRes = "<div id=\"eiseIntraFileList\" class=\"eif-file-dialog\" title=\"".$this->intra->translate('Files')."\">\r\n";
if ($this->intra->arrUsrData['FlagWrite']){
$strRes .= $this->showFileAttachForm();
}
$strRes .= "<table class=\"eiseIntraFileListTable\">\r\n";
$strRes .= "<thead>\r\n";
$strRes .= "<tr>\r\n";
$strRes .= "<th>".$this->intra->translate('File')."</th>\r\n";
$strRes .= "<th colspan=\"2\">".$this->intra->translate('Uploaded')."</th>\r\n";
$strRes .= "<th class=\"eif_filUnattach\"> </th>\r\n";
$strRes .= "</tr>\r\n";
$strRes .= "</thead>\r\n";
$strRes .= "<tbody class=\"eif_FileList\">";
$strRes .= "<tr class=\"eif_template eif_evenodd\">\r\n";
$strRes .= "<td><a href=\"\" class=\"eif_filName\" target=_blank></a></td>\r\n";
$strRes .= "<td class=\"eif_filEditBy\"></td>";
$strRes .= "<td class=\"eif_filEditDate\"></td>";
$strRes .= "<td class=\"eif_filUnattach\"><input type=\"hidden\" class=\"eif_filGUID\"> X </td>";
$strRes .= "</tr>";
$strRes .= "<tr class=\"eif_notfound\">";
$strRes .= "<td colspan=3>".$this->intra->translate("No Files Attached")."</td>";
$strRes .= "</tr>";
$strRes .= "<tr class=\"eif_spinner\">";
$strRes .= "<td colspan=3></td>";
$strRes .= "</tr>";
$strRes .= "</tbody>";
$strRes .= "</table>\r\n";
$strRes .= "</div>\r\n";
return $strRes;
}
function showMessages_skeleton(){
$oldFlagWrite = $this->intra->arrUsrData['FlagWrite'];
$this->intra->arrUsrData['FlagWrite'] = true;
$strRes = '<div id="eiseIntraMessages" title="'.$this->intra->translate('Messages').'">'."\n";
$strRes .= '<div class="eiseIntraMessage eif_template eif_evenodd">'."\n";
$strRes .= '<div class="eif_msgInsertDate"></div>';
$strRes .= '<div class="eiseIntraMessageField"><label>'.$this->intra->translate('From').':</label><span class="eif_msgFrom"></span></div>';
$strRes .= '<div class="eiseIntraMessageField"><label>'.$this->intra->translate('To').':</label><span class="eif_msgTo"></span></div>';
$strRes .= '<div class="eiseIntraMessageField eif_invisible"><label>'.$this->intra->translate('CC').':</label><span class="eif_msgCC"></span></div>';
$strRes .= '<div class="eiseIntraMessageField eif_invisible"><label>'.$this->intra->translate('Subject').':</label><span class="eif_msgSubject"></span></div>';
$strRes .= '<pre class="eif_msgText"></div>';
$strRes .= '</pre>'."\n";
$strRes .= '<div class="eif_notfound">';
$strRes .= '<td colspan=3>'.$this->intra->translate('No Messages Found').'</td>';
$strRes .= '</div>';
$strRes .= '<div class="eif_spinner">';
$strRes .= '</div>';
$strRes .= '<div class="eiseIntraMessageButtons"><input type="button" id="msgNew" value="'.$this->intra->translate('New Message').'">';
$strRes .= '</div>';
$strRes .= "</div>\r\n";
$strRes .= '<form id="eiseIntraMessageForm" title="'.$this->intra->translate('New Message').'" class="eiseIntraForm" method="POST">'."\n";
$strRes .= '<input type="hidden" name="DataAction" id="DataAction_attach" value="messageSend">'."\r\n";
$strRes .= '<input type="hidden" name="entID" id="entID_Message" value="'.$this->entID.'">'."\r\n";
$strRes .= '<input type="hidden" name="entItemID" id="entItemID_Message" value="'.$this->entItemID.'">'."\r\n";
$strRes .= '<div class="eiseIntraMessageField"><label>'.$this->intra->translate('To').':</label>'
.$this->intra->showAjaxDropdown('msgToUserID', '', array('required'=>true, 'strTable'=>'svw_user')).'</div>';
$strRes .= '<div class="eiseIntraMessageField"><label>'.$this->intra->translate('CC').':</label>'
.$this->intra->showAjaxDropdown('msgCCUserID', '', array('strTable'=>'svw_user')).'</div>';
$strRes .= '<div class="eiseIntraMessageField"><label>'.$this->intra->translate('Subject').':</label>'.$this->intra->showTextBox('msgSubject', '').'</div>';
$strRes .= '<div class="eiseIntraMessageBody">'.$this->intra->showTextArea('msgText', '').'</div>';
$strRes .= '<div class="eiseIntraMessageButtons"><input type="submit" id="msgPost" value="'.$this->intra->translate('Send').'">
<input type="button" id="msgClose" value="'.$this->intra->translate('Close').'">
</div>';
$strRes .= "</form>\r\n";
$this->intra->arrUsrData['FlagWrite'] = $oldFlagWrite;
return $strRes;
}
public function getMessages(){
$oSQL = $this->oSQL;
$entID = $this->entID;
$entItemID = $this->entItemID;
$intra = $this->intra;
$sqlMsg = "SELECT *
, (SELECT optText FROM svw_user WHERE optValue=msgFromUserID) as msgFrom
, (SELECT optText FROM svw_user WHERE optValue=msgToUserID) as msgTo
, (SELECT optText FROM svw_user WHERE optValue=msgCCUserID) as msgCC
FROM stbl_message WHERE msgEntityID='$entID' AND msgEntityItemID='{$entItemID}'
ORDER BY msgInsertDate DESC";
$rsMsg = $oSQL->q($sqlMsg);
return $intra->result2JSON($rsMsg);
$arrMsg = array();
while ($rw = $oSQL->f($rsMsg)) {
$arrMsg[] = $rw;
}
$this->oSQL->free_result($rsMsg);
return $arrMsg;
}
/**
* This static function echoes HTML of 'My Favorites' (Bookmarks) block to be obtained with AJAX for display on the system front page. It echoes <fieldset> with <div class="ei-accordion"> to apply jQueryUI's accordion widget.
* If the user has no items favorited, it just echoes nothing.
* This function call is added to inc_ajax_details.php that included into project/ajax_details.php
*
* @return void
*/
public static function getBookmarks($arrDescr = array()){
GLOBAL $intra;
$oSQL = $intra->oSQL;
$expires = 2;
header("Pragma: public");
header("Cache-Control: maxage=".$expires);
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
$sql = "SELECT *
FROM stbl_bookmark
WHERE bkmUserID='{$intra->usrID}'
ORDER BY bkmEntityID, bkmInsertDate DESC";
$rs = $oSQL->do_query($sql);
if ($oSQL->num_rows($rs)) {
?><fieldset id="ei-bookmarks"><legend><?php echo $intra->translate('My Favorites');?></legend>
<div class='ei-accordion'>
<?php
$entity = '';
while ($rw=$oSQL->fetch_array($rs)){
if ($rw['bkmEntityID']!=$entity){
if ($entity) echo "</div>\r\n";
$sql = "SELECT * FROM stbl_entity WHERE entID='".$rw['bkmEntityID']."'";
$rsE = $oSQL->do_query($sql);
$rwE = $oSQL->fetch_array($rsE);
$entID = $rwE['entID'];
$table = $rwE['entTable'];
$entItemIDField = eiseEntity::getItemIDField($rwE);
$descr = ($arrDescr[$entID] ? $arrDescr[$entID] : "##{$entItemIDField}##");
$form = preg_replace('/^(tbl_)/', '', $table).'_form.php';
?><h3><a href='#'><?php echo $rwE["entTitle{$intra->local}Mul"];?></a></h3>
<div>
<?php
}
$o = new eiseEntityItem($oSQL, $intra, $entID, $rw['bkmEntityItemID']);
$description = $descr;
foreach($o->item as $field=>$valRaw){
$val = $intra->formatByType2PHP($o->conf['ATR'][$field]['atrType'], $valRaw);
$description = str_replace('##'.$field.'##', $val, $description);
}
echo "<div><a href='".$form."?".$entID."ID=".$o->item[$entID."ID"]."&hash=".md5($o->item[$entID.'EditDate'])."'>"
,'<div>'.htmlentities($description).'</div>'
,"</a>"
,'<div><small>',$o->item["staTitle{$intra->local}"],' ',date('d.m.Y H:i',strtotime($o->item[$entID."EditDate"])),'</small></div>'
,"</div>\r\n";
$entity = $rw['bkmEntityID'];
}
?>
</div>
</fieldset>
<?php
}
}
}
?>