v.2.13
-Add delete reports
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
.module('app')
|
||||
.controller('ReportsCtrl', ReportsCtrl);
|
||||
|
||||
ReportsCtrl.$inject = ['$scope', 'smartRequest'];
|
||||
function ReportsCtrl($scope, smartRequest) {
|
||||
ReportsCtrl.$inject = ['$scope', 'smartRequest', 'Notification'];
|
||||
function ReportsCtrl($scope, smartRequest, Notification) {
|
||||
var date = new Date();
|
||||
|
||||
var formatted = ('0' + date.getDate()).slice(-2) + '.' + ('0' + (date.getMonth() + 1)).slice(-2) + '.' + date.getFullYear();
|
||||
@@ -25,9 +25,33 @@
|
||||
$scope.printers = [];
|
||||
|
||||
$scope.update = function() {
|
||||
smartRequest.get('report/history', function(data) {
|
||||
smartRequest.get('v1/reports', function(data) {
|
||||
$scope.history = data.reports;
|
||||
});
|
||||
smartRequest.get('v1/settings?code=11', function (data) {
|
||||
$scope.delete_shift_value = data.value;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.deleteReport = function (report) {
|
||||
Notification.primary('Дождитесь удаления! Страница обновится автоматически.');
|
||||
smartRequest.post('v1/deletedata', {
|
||||
value: 'delete_report',
|
||||
report_id: report.id
|
||||
}, function (data) {
|
||||
$scope.status = data.status;
|
||||
$scope.message = data.message;
|
||||
if (data.status == 'success') {
|
||||
Notification.success(data.message);
|
||||
setTimeout(function() {
|
||||
//location.reload();
|
||||
$scope.update();
|
||||
}, 1000);
|
||||
}
|
||||
if ($scope.status == 'error') {
|
||||
Notification.error(data.message);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reportDelete = function() {
|
||||
|
||||
@@ -65,7 +65,9 @@
|
||||
if (data.status == 'success') {
|
||||
Notification.success(data.message);
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
//location.reload();
|
||||
$scope.update();
|
||||
$('#preload-modal').modal('hide');
|
||||
}, 1000);
|
||||
}
|
||||
if ($scope.status == 'error') {
|
||||
|
||||
@@ -102,11 +102,22 @@
|
||||
<td>{{ report.name }}</td>
|
||||
<td>{{ report.start_date }}</td>
|
||||
<td>{{ report.end_date }}</td>
|
||||
<td>
|
||||
<td ng-if="delete_shift_value == 0">
|
||||
<button class="btn btn-sm white" ng-click="archiveReport(report.type, report.start_date, report.end_date)">
|
||||
<i class="material-icons"></i>
|
||||
</button>
|
||||
</td>
|
||||
<td ng-if="delete_shift_value > 0">
|
||||
<div class="dropdown inline" style="margin-top: -5px; position: absolute;">
|
||||
<button class="btn white dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="padding: 0.2rem 0.4rem">
|
||||
<i class="material-icons"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu pull-right dropdown-menu-scale">
|
||||
<a class="dropdown-item" ng-click="archiveReport(report.type, report.start_date, report.end_date)">Просмотр</a>
|
||||
<a class="dropdown-item" ng-click="deleteReport(report)">Удалить отчет</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user