forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reportMyVideos.php
160 lines (153 loc) · 7.12 KB
/
reportMyVideos.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
<div class="row">
<div class="form-group col-sm-3">
<label for="datefromVideosRep" class="col-sm-2 col-form-label"><?php echo __('From'); ?>:</label>
<div class="col-sm-10">
<input type="text" class="form-control datepicker" id="datefromVideosRep">
</div>
</div>
<div class="form-group col-sm-3">
<label for="datetoVideosRep" class="col-sm-2 col-form-label"><?php echo __('To'); ?>:</label>
<div class="col-sm-10">
<input type="text" class="form-control datepicker" id="datetoVideosRep">
</div>
</div>
<?php
if (Permissions::canAdminUsers()) {
?>
<div class="form-group col-sm-3">
<input id="inputUserOwner" placeholder="<?php echo __("User"); ?>" class="form-control">
<input type="hidden" id="inputUserOwner_id">
<script>
$(document).ready(function () {
$("#inputUserOwner").autocomplete({
minLength: 0,
source: function (req, res) {
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>objects/users.json.php',
type: "POST",
data: {
searchPhrase: req.term
},
success: function (data) {
res(data.rows);
}
});
},
focus: function (event, ui) {
$("#inputUserOwner").val(ui.item.user);
return false;
},
select: function (event, ui) {
$("#inputUserOwner").val(ui.item.user);
$("#inputUserOwner_id").val(ui.item.id);
return false;
}
}).autocomplete("instance")._renderItem = function (ul, item) {
return $("<li>").append("<div>" + item.creator + item.email + "</div>").appendTo(ul);
};
});
</script>
</div>
<?php
}
?>
<div class="form-group col-sm-3">
<button class="btn btn-primary" id="refreshMyVideosRep"><i class="fa fa-refresh"></i> <?php echo __('Refresh'); ?></button>
<button onclick="getVideoViewsAndWatchingTimeCSV();" class="btn btn-primary" >
<i class="fas fa-file-csv"></i> <?php echo __('CSV File'); ?>
</button>
</div>
</div>
<table id="dtMyVideosRep" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th><?php echo __('Video'); ?></th>
<th><?php echo __('Total Views'); ?></th>
<th><?php echo __('Watching Time'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo __('Video'); ?></th>
<th><?php echo __('Total Views'); ?></th>
<th><?php echo __('Watching Time'); ?></th>
</tr>
</tfoot>
</table>
<script type="text/javascript">
function getDataFromVideoRep() {
return {
dateFrom: $("#datefromVideosRep").val(),
dateTo: $("#datetoVideosRep").val(),
users_id: (($("#inputUserOwner").val()) ? ($("#inputUserOwner_id").val()) : 0)
};
}
function getVideoViewsAndWatchingTimeCSV() {
var url = webSiteRootURL + "view/videoViewsAnWatchingTime.csv.php";
var data = getDataFromVideoRep();
for (var item in data) {
url = addGetParam(url, item, data[item]);
}
document.location = url;
}
$(document).ready(function () {
$("#datefromVideosRep").datepicker();
$("#datefromVideosRep").datepicker("setDate", "<?php echo date("m/d/Y", strtotime("-30 days")); ?>");
$("#datetoVideosRep").datepicker();
$("#datetoVideosRep").datepicker("setDate", "<?php echo date("m/d/Y"); ?>");
$('#refreshMyVideosRep').click(function () {
$('#dtMyVideosRep').DataTable().ajax.reload();
});
$('#dtMyVideosRep').DataTable({
"language": {
"decimal": "",
"emptyTable": "<?php echo __("No data available in table"); ?>",
"info": "<?php echo __("Showing _START_ to _END_ of _TOTAL_ entries"); ?>",
"infoEmpty": "<?php echo __("Showing 0 to 0 of 0 entries"); ?>",
"infoFiltered": "<?php echo __("(filtered from _MAX_ total entries)"); ?>",
"infoPostFix": "",
"thousands": ",",
"lengthMenu": "<?php echo __("Show _MENU_ entries"); ?>",
"loadingRecords": "<?php echo __("Loading..."); ?>",
"processing": "<?php echo __("Processing..."); ?>",
"search": "<?php echo __("Search"); ?>:",
"zeroRecords": "<?php echo __("No matching records found"); ?>",
"paginate": {
"first": "<?php echo __("First"); ?>",
"last": "<?php echo __("Last"); ?>",
"next": "<?php echo __("Next"); ?>",
"previous": "<?php echo __("Previous"); ?>"
},
"aria": {
"sortAscending": "<?php echo __(": activate to sort column ascending"); ?>",
"sortDescending": "<?php echo __(": activate to sort column descending"); ?>"
}
},
"ajax": {
'type': 'POST',
'url': "<?php echo $global['webSiteRootURL']; ?>view/reportMyVideos.json.php",
'data': getDataFromVideoRep,
},
"footerCallback": function (row, data, start, end, display) {
var api = this.api(), data;
// Update footer by showing the total with the reference of the column index
var totalViewsAllVideos = 0;
var totalWatchingTimeAllVideosHuman = '';
if (data[0]) {
totalViewsAllVideos = data[0].totalViewsAllVideos;
totalWatchingTimeAllVideosHuman = data[0].totalWatchingTimeAllVideosHuman;
}
$(api.column(0).footer()).html('Total');
$(api.column(1).footer()).html(totalViewsAllVideos);
$(api.column(2).footer()).html(totalWatchingTimeAllVideosHuman);
},
"columns": [
{"data": "title", render: function (data, type, row) {
return '<button class="btn btn-default btn-block" onclick="avideoModalIframe(webSiteRootURL +\'view/videoViewsInfo.php?videos_id=' + row.videos_id + '\');return false;">' + row.title + '</button>';
}},
{"data": "total_views"},
{"data": "seconds_watching_video_human"},
]
});
});
</script>