%PDF-
%PDF-
Mini Shell
Mini Shell
var express = require('express');
var router = express.Router();
var bcrypt = require('bcrypt')
var formidable = require('formidable');
var fs = require('fs');
var path = require('path');
var con = require('../../config');
var secured = require('../middleware/login');
var db = require('../models');
//get method/route for sll structure list/view,
router.get('/', secured, function(req, res, next) {
// var orgId = 0;
var user = req.user;
let orgId = user.orgId ;
db.OrganisationStructure.findAll({ where: {orgId: orgId}, include: [{ all: true, nested: true }], order: [['parentId','ASC']] } ).then(structures => {
isOrganized = false;
if(structures.length > 0) { //structure not already organized
isOrganized =true;
}
console.log(structures[3])
res.render('structure/index', { user, structures: structures, isOrganized});
})
.catch(error => {
// Ooops, do some error-handling
console.log(error);
})
});
router.get('/:uuid', secured, function(req, res, next) {
// var orgId = 0;
var user = req.user;
let orgId = user.orgId ;
db.Notification.findOne({ where: {uuid: req.params.uuid}} ).then(notification => {
if(!notification){
req.flash('error', 'Notification not found!' );
res.redirect('/dashboard');
}
notification.seen = 1;
notification.save({fields:['seen']})
.then(()=>{
res.redirect(notification.url)
});
})
.catch(error => {
// Ooops, do some error-handling
console.log(error);
})
});
module.exports = router;
Zerion Mini Shell 1.0