accountSrv.getAccount().then(function (account) {
staffUnitRes.query({'account._id': account._id}, function (staffUnit) {
if (staffUnit.length > 0) {
ticketBoxRouteRes.query({'staffUnits._id': staffUnit[0]._id}, function (tbRoutes) {
var allBoxes = _.pluck(tbRoutes, 'sourceTicketBox');
var officeWorkMenuIndex = _.findIndex($scope.menu, {name: 'officeWork'});
_.forEach(allBoxes, function (box) {
$scope.menu[officeWorkMenuIndex].subElems.push({
icon: 'fa fa-inbox',
title: box.title,
name: 'officeWork.' + box._id,
accessName: 'officeWork.' + box._id + '.list',
url: '#!/officeWork',
isHidden: true
});
});
filterMenuByAccess($scope.menu);
})
} else {
filterMenuByAccess($scope.menu);
}
})
});